[SERVER-22001] geoNear spherical returning incorrect distance Created: 23/Dec/15 Updated: 02/Feb/16 Resolved: 02/Feb/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo |
| Affects Version/s: | 3.0.6 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Sean | Assignee: | David Storch |
| 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: |
|
||||
| Sprint: | Repl F (01/29/16), Query 10 (02/22/16) | ||||
| Participants: |
| Description |
|
Result:
These are the distances using different formulas: Problem: Looking at https://en.wikipedia.org/wiki/N-vector the below is wrong Shoulg be:
|
| Comments |
| Comment by David Storch [ 02/Feb/16 ] |
|
Hi sean_rand, Thanks for reporting this issue. After some investigation, I believe that this is working as designed. You are absolutely correct that the distance between (-25 lat, 40 lng) and (-24 lat, 40 lng) is about 111km. However, the system interprets this query as finding the distance between (40 lng, -25 lat) and (40 lng, -24 lat) which is about 85km. (As an aside, recent versions of MongoDB, including 3.0.x and 3.2.x versions, are using the S2 Geometry Library to compute the great circle distance. The custom implementation of the N-vector computation you are referring to is not being exercised by your example geoNear command.) As stated in the documentation for storing geospatial data in MongoDB, the data storage format is GeoJSON. This is somewhat buried in the docs, but GeoJSON does specify that latitude-longitude data is represented as (lng, lat) rather than (lat, lng): http://geojson.org/geojson-spec.html#positions. Please feel free to reach out if you have any further questions. Best, |
| Comment by Sean [ 23/Dec/15 ] |
|
Example code |