koopjs / FeatureServer

An open source Geoservices Implementation (deprecated)
https://geoservices.github.io
Other
104 stars 32 forks source link

Polygon Crossing positive/negative longitude #75

Closed dhatcher closed 6 years ago

dhatcher commented 6 years ago

If I have a polygon that crosses the positive/negative longitude line the feature server "normalizes" the points, which makes the polygon wrap around the entire world instead of crossing the boundary.
Example, this: [ [179.83539094650206, -18.623051084066553 ], [179.91769547325103,-18.487906116222785], [180.08230452674894,-18.487906116222785], [180.16460905349794,-18.623051084066553], [180.08230452674894,-18.75808871660612], [179.91769547325103,-18.75808871660612], [179.83539094650206, -18.623051084066553 ] ]

Is turned into this: [ [179.83539094650206, -18.623051084066553 ], [179.91769547325103,-18.487906116222785], [-179.917695473,-18.487906116222785], [-179.835390947,-18.623051084066553], [-179.917695473,-18.75808871660612], [179.91769547325103,-18.75808871660612], [179.83539094650206, -18.623051084066553 ] ]

dhatcher commented 6 years ago

For now I'm splitting my polygons into rings when they cross the border and adjusting the vertices myself. It would be nice to not need to do this however since it causes a line through the middle of the feature when selected on the map or when an outline is used in the symbology.

dmfenton commented 6 years ago

Acknowledged. I'll try to track this one down.

dmfenton commented 6 years ago

probably being laundered inside Terraformer when going between geojson and esri json

rgwozdz commented 6 years ago

@dhatcher I've run this one down. The coordinates you note in your polygon example are ordered in clockwise fashion, but the latest GeoJSON spec's "righthand rule" requires a polygon's exterior rings to be wound counter-clockwise. This is a change from the 2008 spec, but we'd like to stick to the latest spec - checking polygon winding is (potentially) computational expensive, as is rewinding if they don't conform. So it seems as though leaving this up to data sources and providers is the way to go.

I will document this requirement explicitly in provider spec. Will also add in some GeoJSON validation when koop's NODE_ENV!=='production'

rgwozdz commented 6 years ago

Closing this, but opening https://github.com/koopjs/FeatureServer/issues/110 to add the warnings for invalid geojson.