[SERVER-15609] GeoWithin query returns wrong result Created: 12/Oct/14 Updated: 10/Dec/14 Resolved: 14/Oct/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying, Shell |
| Affects Version/s: | 2.4.9 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Oleg Fetisov | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | 2dsphere, geoWithin, geojson | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Ubuntu 14.04.1 LTS |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Operating System: | Linux | ||||||||
| Steps To Reproduce: | 1. Create collection.
2. Ensure index (2dsphere).
3. Add document into it.
4. Query geoWithin.
|
||||||||
| Participants: | |||||||||
| Description |
|
I've stuck with a problem of matching items inside a polygon (simple box). I can't figure out why the item which is inside the queried box is not resulting. So here what i have:
Here is my documents (i've tested different formats):
>db.testing.find({"point": {"$geoWithin": { }}})
But the problem is that it returns zero results!
and check it here.
If it's needed i could provide near 100 more of such points. |
| Comments |
| Comment by Thomas Rueckstiess [ 15/Oct/14 ] |
|
Hi Oleg, Here is some more background on the math involved: http://www.movable-type.co.uk/scripts/latlong.html I hope that helps. If you intended to work on a flat Euclidian geometry, then you need to use a "2d" index instead of "2dsphere". The latter considers the spherical surface for geo queries. Thomas |
| Comment by Oleg Fetisov [ 14/Oct/14 ] |
|
Thomas, thanks for the response! But I still can't get it. Could you please visualize also rectangle in which point got founded? Cause my algorithm is braking big region apart and in smaller regions( which are part of big region) new points got found. |
| Comment by Thomas Rueckstiess [ 14/Oct/14 ] |
|
Hi Oleg, The tool at geojsonlint.com unfortunately does not consider the curvature of the earth and instead just draws straight lines between the polygon coordinates. I've visualized the polygon in your example but considering geodesics rather than straight lines, and if zoomed in close enough, you can see that the point is actually not inside the polygon on a spherical surface. overview: zoomed in: I suspect the other points that are not being returned are similarly at the edge of the polygon so that they are no longer inside with spherical coordinates. Regards, |
| Comment by Oleg Fetisov [ 13/Oct/14 ] |
|
Here is a file with around 700 points that also must be in that region: |