[SERVER-2341] Geospacial calculations are off Created: 10/Jan/11  Updated: 29/May/12  Resolved: 26/Jan/11

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 1.7.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ryan Nitz Assignee: Mathias Stearn
Resolution: Duplicate Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-2342 $within: {$center} vs. $near and $max... Closed
Operating System: ALL
Participants:

 Description   

Here are my tests:

// Radius of the earth: 3959.8728
// Distance to Maplewood, NJ (in radians): 0.0036998565637149016
// Distance to Maplewood, NJ (in miles 0.0036998565637149016 * 3959.8728): 14.65

// Does not return Maplewood
db.example.find( { loc: { $nearSphere: [ -73.99171, 40.738868 ], $maxDistance: 0.0036998565637149016 }});

// To get a list of all places (with distance in radians):
db.runCommand(

{ geoNear : "example" , near : [-73.99171,40.738868], spherical: true }

);

// This should include Maplewood, does not.
db.runCommand(

{ geoNear : "example" , near : [-73.99171,40.738868], maxDistance : 0.0036998565637149016, spherical: true }

);

Venues:

geoDoc =

{"name" : '10gen Office', loc: [ -73.99171, 40.738868 ] }

db.example.insert(geoDoc);

geoDoc =

{"name" : 'Maplewood, NJ', loc: [ -74.2713, 40.73137 ] }

db.example.insert(geoDoc);



 Comments   
Comment by Mathias Stearn [ 10/Jan/11 ]

Distance calculations are correct. maxDistance is being applied incorrectly

Generated at Thu Feb 08 02:59:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.