[SERVER-17092] $geoWithin does not return result on certains Polygons Created: 28/Jan/15 Updated: 28/Apr/18 Resolved: 28/Jan/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Michael THOMAS [X] | Assignee: | Siyuan Zhou |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||
| Operating System: | ALL | ||||||||||||||||
| Steps To Reproduce: |
1. Create dummy collection
2. Create 2dsphere index
3. Request with a non-working Polygon !
No result is return The lat/lng of the record is Paris, and France is entirely in the given Polygon (see attachment) |
||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
Dear, I encounter a special comportment with the $geoWithin command. with certains $box or $geometry, the request does not return any result. I try with small polygon and zoom out to bigger (bigger always contains smaller), at a certain range, with exactly the same request, no more result appears ! Maybe i missed something. Best Regards, Michael. |
| Comments |
| Comment by Siyuan Zhou [ 28/Jan/15 ] | |||||||
|
I guess your question is "Is $box different with GeoJSON polygon?" Yes. They are different. $box assumes the points you have are on a flat surface, while GeoJSON polygon will be interpreted as a shape on spherical surface, so the distance calculation and geometry relationship are different. Please see the documentation for more details. $box and GeoJSON $geoWithin. I recommend using GeoJSON since it gives the accurate result in your case and 2dsphere index will speed it up well. Thanks, | |||||||
| Comment by Michael THOMAS [X] [ 28/Jan/15 ] | |||||||
|
Yes, it's what my tests brings me to... 4 ways to draw a quad points polygon in a sphere Is the bounding box is proceed differently from quad the polygon before to query the index ? You're doing a Great Job, thanks for your quick answer. Best Regards, | |||||||
| Comment by Siyuan Zhou [ 28/Jan/15 ] | |||||||
|
The shortest path between longitude -112 and 117 is actually on the opposite of the sphere, as shown on the attached polygon view on sphere. To specify the polygon you want, please add some middle points along the edge of polygon, so that the longitude distance between any adjacent 2 points is less than 180 degree. Just FYI, another potentially unexpected effect is that the distortion of map projection. As you may have noticed, the edge is actually a curve on the map. If the geometry of query keeps growing, for geometries that have an area greater than the area of a single hemisphere, MongoDB queries for the smaller of the complementary geometries. Upcoming MongoDB 3.0 supports "Big Polygon" which defines a strict winding order for polygons to support polygon whose area is greater than a single hemisphere. Hope this answered your question. I am going to close this issue as "Working as Designed". Thanks, | |||||||
| Comment by Michael THOMAS [X] [ 28/Jan/15 ] | |||||||
|
With $geometry, Making tests with somes Polygons, it seems, it return the opposite of the requested polygon (as if the inverted polygon was applyed) | |||||||
| Comment by Michael THOMAS [X] [ 28/Jan/15 ] | |||||||
|
Correction : Using the bouding box command, we got the elements.
|