-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wkt support staging #1387
Wkt support staging #1387
Conversation
@@ -8,6 +8,7 @@ import { PixiFeatureLine } from './PixiFeatureLine.js'; | |||
import { PixiFeaturePoint } from './PixiFeaturePoint.js'; | |||
import { PixiFeaturePolygon } from './PixiFeaturePolygon.js'; | |||
import { utilFetchResponse } from '../util/index.js'; | |||
import { parse as wktParse } from 'wkt'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New module import that correctly interprets WKT strings of all kinds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a number of comments to fix things now that I'm in 'review' mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a quick pass over this, and my initial impression is that it seems like you might be doing too much work?
My mental model of how this might work is like:
- in
_hashchange
, take thedata
param and try to parse it as WKT. - If that succeeds, you'll get some blob of GeoJSON
- call
this.setFile(geojson, '.geojson')
- Done? everything else in this file is already set up to deal with GeoJSON.
Excellent idea. Refactoring to do exactly this!
One downside: printing appropriate error messages with the overloaded |
…eparate renderer.
I'd force everything to just use Good callout on the downside of not being able to print appropriate error messages - I think that's probably another thing we don't do at all right now? e.g. if you pass it a bad geojson or PMTiles, I think it just silently fails today? We should probably eventually surface this somehow. |
Looks good! I do think we can simplify further and remove the arbitrary limitation to only include Polygon/Multipolygon types, but let's merge it so people can try it out. |
(re: #1387) All minor stuff: - move private functions to end of file - move variable cleanup stuff into a `_clear()` function - cleanup lint warnings, whitespace - `parseAsWkt` needs to return `null` if it wants to do nothing (before it returned `{}` which evaluates as truthy) - call .toUpperCase() on the wkt string, so it writes back to the url hash that way - don't report a `dataUsed` for wkt sources (similar to task boundaries) - make sure to check `typeof newData === 'string'` in `_hashchange` (sending non-string data to the wktparser fails) - lots of testing
This PR adds a new
wktPoly
param that very quickly gets basic POLYGON and MULTIPOLYGON support into Rapid.