-
Notifications
You must be signed in to change notification settings - Fork 88
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
Clipping logic #37
base: main
Are you sure you want to change the base?
Clipping logic #37
Conversation
adds logic to clip geometries that are in overzoomed tiles
@@ -25,7 +25,7 @@ | |||
"node": true | |||
}, | |||
"scripts": { | |||
"test": "jshint lib && tape test/parse.test.js", | |||
"test": "jshint lib && tape test/parse.test.js && tape test/clip.test.js", |
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.
could this be tape test/*.test.js
so that assertions in the test suites are combined?
@tmcw - Sorry for the delay. package.json now changed to run all tests in batch |
I am not an expert on all this JS code, but what you are doing with vector tiles (as far as the clipping and scaling algorithm) does concern me in terms of making valid tiles as per the v2 specification. Rounding issues associated with scaling up from a higher precision set of data to a lower precision set of data can possibly cause inverted winding orders, duplicated points, and invalid polygons (mostly from interior rings touching the edges of exterior rings. Here is an example of a floating point rounding causing an inverting of winding order, while these are not floating point numbers the same problem can occur: An inverted interior ring could single the start of a new polygon and a future exterior ring could be considered an exterior ring of that polygon. This looks really ugly once it gets to the renderer. For duplicated points this is not considered valid per: https://github.com/mapbox/vector-tile-spec/tree/master/2.1#4332-lineto-command If you clipped an interior or exterior polygon to representable by only a line, it would no longer have a valid area. I did not see these sort of polygons being removed prior to being sent out. Currently in some of our code we are using the angus clipper to help clean up some of this, however, it requires intensive processing. Therefore, currently it is typically better to clip polygons like this on the client side. /cc @ycabon |
Issue that might be helpful: mapbox/vector-tile-spec#58 |
Thanks for your comments.
|
resolve merge conflict in mapbox PR
This PR adds the capability of deriving on the fly clipped geometries from a vector tile.
Part of the indexing work done here Esri/mapbox-gl-js#1 https://gist.github.com/odoe/ce6a150658526901ef27#file-vector-tile-pr-md
Each feature is created with extra properties.
dz
- delta in z between the native resolutions of the tile and the synthesized onexPos
- position in x of the synthesized tile in the native tile at dzyPos
- position in y of the synthesized tile in the native tile at dzThose properties are used to generate the clipped geometry when
loadGeometry()
is called.For tile with native extent greater than 4096,
loadGeometry()
scales down the coordinates to comply with the default 4k extent and work around the vertex buffer encoding using int16.If the clipped geometry is null, the feature isn't added the buckets.
This was the least invasive way in mapbox-gl-js. Probably there is another way to architecture this.