[SERVER-36089] Can't extract geo keys on a polygon with a nearly-touching hole Created: 12/Jul/18 Updated: 04/Nov/18 Resolved: 12/Oct/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo |
| Affects Version/s: | 3.4.13 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Zohar Bar-Yehuda | Assignee: | Kelsey Schubert |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Operating System: | ALL |
| Steps To Reproduce: | Attached python script debug_mongo_geo_error.py |
| Participants: |
| Description |
|
I'm trying to load polygon entities from OpenStreetMap into MongoDB, and encountered an error with the following object: https://www.openstreetmap.org/relation/7397686
While the hole in the large polygon is indeed fully contained in the polygon and does not intersect with it, inserting it with a 2DSphere index still fails. If I shift the hole polygon a few meters northwards (putting it a bit further away from the outer polygon), it inserts correctly |
| Comments |
| Comment by Kelsey Schubert [ 12/Oct/18 ] |
|
Hi zoharby, Sorry for the delay getting back to you. As a point of a clarification, it's the map that introduces the distortion not the database: a line on sphere is the shortest path between the two vertices. If you'd like to represent the shape you see on the map in the description, you could use interpolation, or alternatively, you could use Google Maps as in Nick's comment to draw the geodesic. Please note that the SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-users group. Kind regards, |
| Comment by Zohar Bar-Yehuda [ 18/Jul/18 ] |
|
Wow, never would have thought about that... Thanks! |
| Comment by Nick Brewer [ 17/Jul/18 ] |
|
I believe part of the disparity you're seeing here is that, if I'm not mistaken, OpenStreetMap renders longitude and latitude flatly, without accounting for curvature. Since 2dsphere accounts for mapping points on a sphere, there can be some distortion in terms of how polygons look as compared to a a grid-based shape. Our documentation has a good example of this. As an alternative, you could try removing the line of the inner hole that borders the lines of the polygon. You can drag GeoJSON data into this map for a more accurate depiction. Regards, Nick |