Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GEO] OGC compliant polygons fail with ambiguity #8672

Closed
nknize opened this issue Nov 26, 2014 · 2 comments
Closed

[GEO] OGC compliant polygons fail with ambiguity #8672

nknize opened this issue Nov 26, 2014 · 2 comments
Assignees
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug discuss

Comments

@nknize
Copy link
Contributor

nknize commented Nov 26, 2014

The GeoJSON specification (http://geojson.org/geojson-spec.html) does not mandate a specific order for polygon vertices thus leading to ambiguous polys around the dateline. To alleviate ambiguity the OGC requires vertex ordering for exterior rings according to the right-hand rule (ccw) with interior rings in the reverse order (cw) (http://www.opengeospatial.org/standards/sfa). While JTS expects all vertices in cw order (http://tsusiatsoftware.net/jts/jts-faq/jts-faq.html). Spatial4j circumvents the issue by not allowing polys to exceed 180 degs in width, thus choosing the smaller of the two polys. Since GEO core includes logic that determines orientation at runtime, the following OGC compliant poly will fail:

 {
  "geo_shape" : {
    "loc" : {
      "shape" : {
        "type" : "polygon",
        "coordinates" : [ [ 
          [ 176, 15 ], 
          [ -177, 10 ], 
          [ -177, -10 ], 
          [ 176, -15 ], 
          [ 172, 0 ],
          [ 176, 15] ], 
          [ [ -179, 5],
            [-179, -5],
            [176, -5],
            [176, 5],
            [-179, -5] ]
        ]
      }
    }
  }
}

One workaround is to manually transform coordinates in the supplied GeoJSON from -180:180 to a 0:360 coordinate system (e.g, -179 = 181). This, of course, fails to comply with OGC specs and requires clients roll their own transform.

The other (preferred) solution - and the purpose of this issue - is to correct the orientation logic such that GEO core supports OGC compliant polygons without the 180 degree restriction/workaround.

@nknize nknize added >bug discuss :Analytics/Geo Indexing, search aggregations of geo points and shapes labels Nov 26, 2014
@nknize nknize self-assigned this Nov 26, 2014
@nknize
Copy link
Contributor Author

nknize commented Nov 26, 2014

Follow feature branch feature/WKT_poly_vertex_order for WIP

nknize added a commit to nknize/elasticsearch that referenced this issue Dec 16, 2014
This feature branch implements OGC compliance for Polygon/Multi-polygon.  That is, vertex order for the exterior ring follows the right-hand rule (ccw) and all holes follow the left-hand rule (cw).  While GeoJSON imposes no restrictions, a user that wants to specify a complex poly across the dateline must do so in compliance with the OGC spec, otherwise a polygon that spans the globe will be assumed.

Reference issue elastic#8672

Fix orientation of outer and inner ring for polygon with holes.  Updated unit tests.  Bug exists in boundary condition on negative side of dateline.
nknize added a commit to nknize/elasticsearch that referenced this issue Dec 16, 2014
This commit adds the logic necessary for supporting polygon vertex ordering per OGC standards. Exterior rings will be treated in ccw (right-handed rule) and interior rings will be treated in cw (left-handed rule).  This feature change supports polygons that cross the dateline, and those that span the globe/map.  The unit tests have been updated and corrected to test various situations.  Greater test coverage will be provided in future commits.

Addresses elastic#8672
nknize added a commit that referenced this issue Dec 16, 2014
This feature branch implements OGC compliance for Polygon/Multi-polygon.  That is, vertex order for the exterior ring follows the right-hand rule (ccw) and all holes follow the left-hand rule (cw).  While GeoJSON imposes no restrictions, a user that wants to specify a complex poly across the dateline must do so in compliance with the OGC spec, otherwise a polygon that spans the globe will be assumed.

Reference issue #8672

Fix orientation of outer and inner ring for polygon with holes.  Updated unit tests.  Bug exists in boundary condition on negative side of dateline.
nknize added a commit that referenced this issue Dec 16, 2014
This commit adds the logic necessary for supporting polygon vertex ordering per OGC standards. Exterior rings will be treated in ccw (right-handed rule) and interior rings will be treated in cw (left-handed rule).  This feature change supports polygons that cross the dateline, and those that span the globe/map.  The unit tests have been updated and corrected to test various situations.  Greater test coverage will be provided in future commits.

Addresses #8672
nknize added a commit that referenced this issue Dec 16, 2014
This feature branch implements OGC compliance for Polygon/Multi-polygon.  That is, vertex order for the exterior ring follows the right-hand rule (ccw) and all holes follow the left-hand rule (cw).  While GeoJSON imposes no restrictions, a user that wants to specify a complex poly across the dateline must do so in compliance with the OGC spec, otherwise a polygon that spans the globe will be assumed.

Reference issue #8672

Fix orientation of outer and inner ring for polygon with holes.  Updated unit tests.  Bug exists in boundary condition on negative side of dateline.
nknize added a commit that referenced this issue Dec 16, 2014
This commit adds the logic necessary for supporting polygon vertex ordering per OGC standards. Exterior rings will be treated in ccw (right-handed rule) and interior rings will be treated in cw (left-handed rule).  This feature change supports polygons that cross the dateline, and those that span the globe/map.  The unit tests have been updated and corrected to test various situations.  Greater test coverage will be provided in future commits.

Addresses #8672
nknize added a commit that referenced this issue Dec 16, 2014
This feature branch implements OGC compliance for Polygon/Multi-polygon.  That is, vertex order for the exterior ring follows the right-hand rule (ccw) and all holes follow the left-hand rule (cw).  While GeoJSON imposes no restrictions, a user that wants to specify a complex poly across the dateline must do so in compliance with the OGC spec, otherwise a polygon that spans the globe will be assumed.

Reference issue #8672

Fix orientation of outer and inner ring for polygon with holes.  Updated unit tests.  Bug exists in boundary condition on negative side of dateline.
nknize added a commit that referenced this issue Dec 16, 2014
This commit adds the logic necessary for supporting polygon vertex ordering per OGC standards. Exterior rings will be treated in ccw (right-handed rule) and interior rings will be treated in cw (left-handed rule).  This feature change supports polygons that cross the dateline, and those that span the globe/map.  The unit tests have been updated and corrected to test various situations.  Greater test coverage will be provided in future commits.

Addresses #8672
@nknize
Copy link
Contributor Author

nknize commented Dec 16, 2014

Fixed in #8762

@nknize nknize closed this as completed Dec 16, 2014
nknize added a commit to nknize/elasticsearch that referenced this issue Dec 30, 2014
ShapeBuilder expected coordinates for Envelope types in strict Top-Left, Bottom-Right order. Given that GeoJSON does not enforce coordinate order (as seen in elastic#8672) clients could specify envelope bounds in any order and be compliant with the GeoJSON spec but not the ES ShapeBuilder logic. This change loosens the ShapeBuilder requirements on envelope coordinate order, reordering where necessary.

closes elastic#2544
closes elastic#9067
closes elastic#9079
closes elastic#9080
nknize added a commit that referenced this issue Dec 30, 2014
ShapeBuilder expected coordinates for Envelope types in strict Top-Left, Bottom-Right order. Given that GeoJSON does not enforce coordinate order (as seen in #8672) clients could specify envelope bounds in any order and be compliant with the GeoJSON spec but not the ES ShapeBuilder logic. This change loosens the ShapeBuilder requirements on envelope coordinate order, reordering where necessary.

closes #2544
closes #9067
closes #9079
closes #9080
nknize added a commit that referenced this issue Dec 30, 2014
ShapeBuilder expected coordinates for Envelope types in strict Top-Left, Bottom-Right order. Given that GeoJSON does not enforce coordinate order (as seen in #8672) clients could specify envelope bounds in any order and be compliant with the GeoJSON spec but not the ES ShapeBuilder logic. This change loosens the ShapeBuilder requirements on envelope coordinate order, reordering where necessary.

closes #2544
closes #9067
closes #9079
closes #9080
nknize added a commit to nknize/elasticsearch that referenced this issue Jan 27, 2015
PR elastic#8672 addresses ambiguous polygons - those that either cross the dateline or span the map - by complying with the OGC standard right-hand rule. Since ```GeoPolygonFilter``` is self contained logic, the fix in elastic#8672 did not address the issue for the ```GeoPolygonFilter```. This was identified in issue elastic#5968

This fixes the ambiguous polygon issue in ```GeoPolygonFilter``` by moving the dateline crossing code from ```ShapeBuilder``` to ```GeoUtils``` and reusing the logic inside the ```pointInPolygon``` method.  Unit tests are added to ensure support for coordinates specified in either standard lat/lon or great-circle coordinate systems.

closes elastic#5968
closes elastic#9304
nknize added a commit that referenced this issue Jan 27, 2015
PR #8672 addresses ambiguous polygons - those that either cross the dateline or span the map - by complying with the OGC standard right-hand rule. Since ```GeoPolygonFilter``` is self contained logic, the fix in #8672 did not address the issue for the ```GeoPolygonFilter```. This was identified in issue #5968

This fixes the ambiguous polygon issue in ```GeoPolygonFilter``` by moving the dateline crossing code from ```ShapeBuilder``` to ```GeoUtils``` and reusing the logic inside the ```pointInPolygon``` method.  Unit tests are added to ensure support for coordinates specified in either standard lat/lon or great-circle coordinate systems.

closes #5968
closes #9304
nknize added a commit that referenced this issue Jan 27, 2015
PR #8672 addresses ambiguous polygons - those that either cross the dateline or span the map - by complying with the OGC standard right-hand rule. Since ```GeoPolygonFilter``` is self contained logic, the fix in #8672 did not address the issue for the ```GeoPolygonFilter```. This was identified in issue #5968

This fixes the ambiguous polygon issue in ```GeoPolygonFilter``` by moving the dateline crossing code from ```ShapeBuilder``` to ```GeoUtils``` and reusing the logic inside the ```pointInPolygon``` method.  Unit tests are added to ensure support for coordinates specified in either standard lat/lon or great-circle coordinate systems.

closes #5968
closes #9304
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
This feature branch implements OGC compliance for Polygon/Multi-polygon.  That is, vertex order for the exterior ring follows the right-hand rule (ccw) and all holes follow the left-hand rule (cw).  While GeoJSON imposes no restrictions, a user that wants to specify a complex poly across the dateline must do so in compliance with the OGC spec, otherwise a polygon that spans the globe will be assumed.

Reference issue elastic#8672

Fix orientation of outer and inner ring for polygon with holes.  Updated unit tests.  Bug exists in boundary condition on negative side of dateline.
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
This commit adds the logic necessary for supporting polygon vertex ordering per OGC standards. Exterior rings will be treated in ccw (right-handed rule) and interior rings will be treated in cw (left-handed rule).  This feature change supports polygons that cross the dateline, and those that span the globe/map.  The unit tests have been updated and corrected to test various situations.  Greater test coverage will be provided in future commits.

Addresses elastic#8672
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
ShapeBuilder expected coordinates for Envelope types in strict Top-Left, Bottom-Right order. Given that GeoJSON does not enforce coordinate order (as seen in elastic#8672) clients could specify envelope bounds in any order and be compliant with the GeoJSON spec but not the ES ShapeBuilder logic. This change loosens the ShapeBuilder requirements on envelope coordinate order, reordering where necessary.

closes elastic#2544
closes elastic#9067
closes elastic#9079
closes elastic#9080
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
PR elastic#8672 addresses ambiguous polygons - those that either cross the dateline or span the map - by complying with the OGC standard right-hand rule. Since ```GeoPolygonFilter``` is self contained logic, the fix in elastic#8672 did not address the issue for the ```GeoPolygonFilter```. This was identified in issue elastic#5968

This fixes the ambiguous polygon issue in ```GeoPolygonFilter``` by moving the dateline crossing code from ```ShapeBuilder``` to ```GeoUtils``` and reusing the logic inside the ```pointInPolygon``` method.  Unit tests are added to ensure support for coordinates specified in either standard lat/lon or great-circle coordinate systems.

closes elastic#5968
closes elastic#9304
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug discuss
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant