Closed mourner closed 8 years ago
OK, so Artem says we pass winding order as is, so there's no easy way to derive ring status... Could you consider winding order correction for a future release? It's pretty easy, and given that geometries are flattened, it would be extremely useful. Usual accepted order is CCW for outer rings, CW for rings.
Note that closing #53 will also close this issue, since polygon clipping procedure also resets winding order. Although fixing just the latter is much easier.
Could you consider winding order correction for a future release?
Wouldn't the spec need to change for rings to have a defined winding order, or are you suggesting giving an order that wasn't there in the tile when parsing one?
@pnorman yes, I'm suggesting changing the winding order of polygon rings depending on whether it's a hole or an outer ring. I don't see any problems with this since the original winding order is pretty much random and has no practical use.
:+1: for having a specified winding order.
@pnorman yes, I'm suggesting changing the winding order of polygon rings depending on whether it's a hole or an outer ring. I don't see any problems with this since the original winding order is pretty much random and has no practical use.
I don't see an issue with it either, but I'm just questioning if it's a mapnik-vector-tile issue or an issue that the specification doesn't require a winding order.
The fix for this would be to update both the specification (to require a winding order), and mapnik-vector-tile (to output spec-compliant windings).
Another thing to note is that Mapnik VT output doesn't have outer1, inner1, inner1, ..., outer2, inner2, ...
order — it can have outer rings and holes mixed up in random order, which is a problem when you're trying to figure out which is which.
Another approach is to just split MultiPolygons into several Polygon features. This is how Mapzen solved the issue: https://github.com/mapzen/mapbox-vector-tile/issues/4
@mourner yep, not an ideal solution, it would be nice to have multi-geometries directly supported in the spec.
Update here: my plan is to have mapnik-vector-tile ensure:
So, here are some examples then of how you would decode:
CCW
-> single polygon, no interior ringsCCW,CW,CW
-> single polygon, two interior ringsCCW,CCW,CCW
- > Multipolygon with 3 polygons, each with only an exterior ringCCW,CCW,CCW,CW
- > Multipolygon with 3 polygons, each with one exterior ring, and the final one with one exterior ring and one interior ringCW
-> single interior ring: degenerate, throw it outAs part of this push we need to ensure these winding order expectations are consistently maintained at a variety of steps. To that end I'll update the below set of check boxes as things progress:
This ticket is now resolved thanks to the work of many. Going to close with a short recap:
https://www.mapbox.com/blog/vector-tile-spec-changes/ is a good resource to learn more about what changed.
/cc @rouault
Do geometry rings have a defined winding order in vector tiles? E.g. counter-clockwise for outer rings and clockwise for rings? Or should I expect any order of any particular ring?
Winding order isn't mentioned anywhere in spec, but some polygon algorithms depend on a certain winding order. Also, some algorithms (especially triangulation) need to know if a polygon ring is a hole or an outer ring, which could also be derived from winding order if geometry is flattened.