[SERVER-13920] $geoIntersects returns false intersection on close non-intersecting polygons Created: 13/May/14  Updated: 21/Feb/17  Resolved: 13/May/14

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

Type: Bug Priority: Major - P3
Reporter: Michael Grundy Assignee: Greg Studer
Resolution: Done Votes: 0
Labels: 28qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File 13920-flat-earth.png     PNG File 13920-round-earth.png     File geoInt.js    
Issue Links:
Related
Operating System: ALL
Participants:

 Description   

$geoIntersects will show these two polygons as intersecting:

{ "type" : "Polygon", "coordinates" : [[[ 1.0,  3.0], [ 12.0,  3.0], [ 12.0,  8.0],  [ 1.0,  8.0], [ 1.0,  3.0]]] },
 
{ "type" : "Polygon", "coordinates" : [ [ [ 6, 9 ], [ 7, 9 ], [ 7, 8.02 ], [ 6, 8.02 ], [ 6, 9 ] ] ] }

The top of the first polygon is .02 degrees away from the bottom of the second one. The range of false intersections increases with lattitude. I wasn't able to reproduce this with longitudinally near polygons.



 Comments   
Comment by Kyle Suarez [ 21/Feb/17 ]

Hello nminoli,

Sorry to hear about your problem. As this ticket is closed, could you please open a new SERVER ticket with the details of your query so that our team can investigate it?

Thanks,
Kyle

Comment by Nicolas Minoli [ 21/Feb/17 ]

I am facing a similar problem, (best ilustrated here: Mongodb $geoIntersects giving wrong query results ).

What would be the workaround in order to avoid false intersects results?

Comment by Greg Studer [ 13/May/14 ]

As derick mentions, this is not a bug - GeoJSON shapes are by default in the WGS84 (spheroidal) coordinate reference system (CRS). Intuitively this means that lines of latitude are not shortest paths and curve upward (in the north) and downward (in the south).

Also note that GeoJSON polygons and $polygons are different in this respect - $polygons are interpreted as using a projected (flat) CRS (technically some kind of cylindrical projection).

Comment by Derick Rethans [ 13/May/14 ]

I don't think there is a bug here. The direct coordinates as a box might not overlap, but if you put them on a sphere, they do. The first attachment shows a flat earth model, and the second one a spherical earth model

Comment by J Rassi [ 13/May/14 ]

Assigning to hari.khalsa@10gen.com for triage.

Comment by Michael Grundy [ 13/May/14 ]

jstest that illustrates issue.

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