mapbox / geojsonhint

IMPORTANT: This repo will be archived. Use @placemarkio/check-geojson instead
ISC License
258 stars 37 forks source link

validate polygon geometry #48

Open jfirebaugh opened 8 years ago

jfirebaugh commented 8 years ago

It would be very useful to have a mode, perhaps not the default, that validates polygon geometry.

The validation should be at least strong enough to guarantee that any passing polygon is suitable for processing by geojson-vt. Then we could check incoming bug reports like https://github.com/mapbox/mapbox-gl-js/issues/3074, https://github.com/mapbox/mapbox-gl-js/issues/3032, and https://github.com/mapbox/mapbox-gl-js/issues/3080 against it, point the submitters to geojsonhint when their data turns out to be invalid, and perhaps even embed it in mapbox-gl-js as a GeoJSON source preflight mechanism.

cc @tmcw @mourner @lucaswoj @springmeyer @mapsam

mourner commented 8 years ago

Winding order is only important for multipolygons in vector tiles, it shouldn't affect geojson-vt otherwise. Invalid intersections checks are pretty expensive, so we probably shouldn't embed the check in mapbox-gl-js. Also, since the GeoJSON spec doesn't dictate polygon validity, ideally we should clean up invalid polygons in geojson-vt rather than imposing requirements — that's just an extremely challenging computational geometry task that is a long way to go, but will be done eventually since we need it anyway (because polygons can become invalid through simplification).

tmcw commented 8 years ago

Yep, definitely support this. I'm not sure offhand how much code this would require; my suspicion is it'd be pretty significant, and might motivate this as a separate module or a separate require-path.

@mourner in geojson-vt we have control, but I've encountered enough implementations of GIS-ish operations that don't tolerate self-intersections etc that I think a utility would be useful, and much less work + code change than fixing all those implementations.

jfirebaugh commented 6 years ago

Refs https://github.com/Turfjs/turf/issues/64