koopjs / winnow

Deprecated
Apache License 2.0
90 stars 18 forks source link

Esri envelope geometry option converted to invalid GeoJSON polygon #110

Closed nheminger closed 5 years ago

nheminger commented 5 years ago

An Esri envelope option specified to Winnow is normalized to a GeoJSON Polygon incorrectly.

Input of envelope:

{"xmin":-180,"ymin":-180,"xmax":0,"ymax":0,"spatialReference":{"wkid":4326,"latestWkid":4326}}

Results in a geometry inside sql.js of:

{"type":"Polygon","coordinates":[[[-180,-180],[-180,0],[0,0],[0,-180],[-180,-180]]]}

This geometry does not validate according to http://geojsonlint.com/ because it is clockwise.

GeoJSON IETF RFC 7946 section 3.1.6. Polygon specifies a counter-clockwise order of coordinates for exterior polygon rings:

A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.

The order of coordinates in transform-envelope.js could use adjusting to be compliant with the RFC. This will enable better validation of the GeoJSON and any tests on them.

rgwozdz commented 5 years ago

Released fix in v 1.16.6.