[SERVER-9948] Cannot index a polygon crossing the 180th meridian Created: 17/Jun/13  Updated: 25/Apr/18  Resolved: 26/Jun/13

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 2.4.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Frédéric De Jaeger Assignee: hari.khalsa@10gen.com
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

linux


Issue Links:
Duplicate
is duplicated by SERVER-34673 Create Index does not support GeoJSON... Closed
Operating System: Linux
Participants:

 Description   

I could not find a way to index a polygon (rectangle) crossing the 180th meridian.
Common sense suggest to let some longitudes overflow +- 180 like in this example:

{"type"=>"Polygon", "coordinates"=>[[[-185.0, 30], [-165.0, 30], [-165.0, 50], [-185.0, 50], [-185.0, 30]]]}

but it fails with the infamous error "Can't extract geo keys from object, malformed geometry?".

If I normalize the coordinates to not overflow +-180, then I don't see how mongodb could distinguish that small polygon from a large band going from meridian -165 to meridian +175.

I could try to split my polygon into two across the 180 meridian but then I fall onto https://jira.mongodb.org/browse/SERVER-8907



 Comments   
Comment by hari.khalsa@10gen.com [ 26/Jun/13 ]

-185 isn't a valid longitude, so use 175, and it will work. MongoDB always uses the smallest possible shape defined by a loop. Either we need to enforce a winding order on the vertices of a loop (contain everything to the left or to the right of the edges as we traverse them), or we need to always use the smallest (or largest) possible shape defined by a loop. We opt for always using the smallest shape defined by a loop.

As for SERVER-8907, I recently added support for the rest of the GeoJSON spec. It is not fully tested yet (only in the master branch, not in any releases yet), but if you want to experiment with it, I will promptly fix any bugs found.

Comment by Frédéric De Jaeger [ 17/Jun/13 ]

I forgot to mention that I'm using the 2dsphere index.

Generated at Thu Feb 08 03:21:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.