Open morganherlocker opened 9 years ago
I think something like
eachRing(geojson, function(ring, type, index, index1, index2) {
});
Would work? That way we can pass in rings unchanged and avoid creating a new object
Oh nice, i like that. What's the indexN? Ring depth?
:+1: something like this would simplify lots of things, including stuff like the greiner-hormann code. Especially with the ability to filter between hulls/holes
Yep, ring within multipolygon. I guess 2 indexes would be enough
future todo: write a "wtf are linear rings" blog post
@lyzidiamond yeah, the geojson spec is actually a bit vague about linear rings, but my understanding is something like:
Might be nice to have this as a linkable part of the spec similar to bbox, which is also "sort-of-geojson-but-sort-of-not".
Yep, the GeoJSON spec is unclear. Rings are better explained (that's the intention, at least) in http://tools.ietf.org/html/draft-butler-geojson-05#section-2.1.6. All the JSON arrays in a Polygon's coordinates that match the definition of LineString coordinates are linear rings. There aren't any rings in any other context according to the draft.
future todo: write a "wtf are linear rings" blog post
I have this written, just need to do some final sketches and post.
I have some stuff done in this direction in my own projects, some kind of parser to play with rings in a not-so-painful way. If I can find some spare time, I could manage to put it al together and commit to TURF
Get each LinearRing from a Polygon, MultiPolygon, LineString, MultiLineString, or GeometryCollection. LinearRings are defined roundabout-ly in the geojson spec, and are useful for loads of algorithms.
These algorithms often need to know if the ring is a line, an outer ring (aka 'hull'), or an inner ring (aka 'hole'). Thoughts on delineation and this potential output format?
\cc @tchannel @tmcw @lyzidiamond @rukku