[SERVER-82435] 2dsphere index thinks clearly parallel lines intersect Created: 25/Oct/23 Updated: 01/Nov/23 Resolved: 30/Oct/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 5.0.9 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Bill Mills | Assignee: | Adam Harrison |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | 2dsphere, geojson | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: |
| Description |
|
Inserting a geojson polygon in a field indexed with 2dsphere fails, claiming two separate parallel lines of constant latitude intersect. Full repro in 5.0.9 below.
|
| Comments |
| Comment by Bill Mills [ 01/Nov/23 ] |
|
Hi adam.harrison@mongodb.com, thanks for taking the time! I'm really surprised by this, there must be something I don't understand about how MongoDB is interpreting these coordinates. I understand this geometry is on a sphere, but even (or especially) on a sphere, lines of constant latitude do not intersect. The only conclusion I can draw here, is that a line segment such as [101.5625, -45.25], [76.5625, -45.25] is not interpreted as being a line of constant latitude even though it starts and ends on the same circle. What is the correct way to define a polygon edge of constant latitude for a 2dsphere index? I suppose we can approximate it by putting lots of vertexes along the line rather than traversing 25 degrees at a time, but I'd rather avoid this because I suspect this is going to bloat the index size. Thanks again for your attention on this. |
| Comment by Adam Harrison [ 30/Oct/23 ] |
|
Hi Bill, Thanks for the clear reproduction! This looks like it is expected behavior. Note that 2dsphere indexes perform geospatial operations on an earth-like sphere. While these specific edges are parallel on an X-Y coordinate plane, they are actually intersect when mapped over a sphere like surface. I've attached screenshots showing both of these edges graphed across a sphere and the corresponding intersection that would be generated a result. We hope this helps! |