[SERVER-24549] $geoWithin query using $polygon or $geometry gives different result Created: 14/Jun/16 Updated: 14/Jul/16 Resolved: 14/Jun/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo |
| Affects Version/s: | 3.2.6 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | gbac | Assignee: | Unassigned |
| 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: | Add a geometry in the collection :
With $geometry gives NO result:
With $polygon returns my Point :
|
||||||||||||||||||||||||||||||||||||||||||||
| Participants: |
| Description |
|
Using MongoDB 3.2 i'm trying to use 2dsphere queries on a collection of Points. Lets say i have à collection cust_5_abcd with a 2dsphere index on the_geom field. Now i'm trying to query this Point using $geoWithin to get all data inside a specific Polygon. This is where i'm getting different result if i use $geometry with the GeoJSON definition , or with $polygon and the strict coordinates. Maybe something in the documentation is missing or something i misunderstood. With $geometry gives NO result. |
| Comments |
| Comment by gbac [ 15/Jun/16 ] |
|
Thanks for the answer. However i'm kind of confused by this implementation logic. Any chance it will get implemented in futur version ? |
| Comment by Ramon Fernandez Marina [ 14/Jun/16 ] |
|
gbac, if I'm reading the documentation correctly this is expected behavior. When using $polygon a planar geometry is calculated, and the point falls inside the polygon you describe. But when you use GeoJSON a spherical geometry is used, and the point falls outside the geometry:
In the future I'd recommend you use this website (which is just a hosted version of this tool) to check your geometries. |
| Comment by gbac [ 14/Jun/16 ] |
|
The polygon for the query : "type": "Polygon", And my ticket on stackoverflow in case of : http://stackoverflow.com/questions/37676794/mongodb-geowithin-query-using-polygon-or-geometry-gives-different-result?noredirect=1 |