Description
Users are being tripped up by the caveats related to spherical queries, especially the long/lat order requirement. If you use lat/long order queries will raise an assertion similar to this:
error:
{ "$err" : "assertion db/geo/2d.cpp:1385" }This is so common that the assert should really give a hint as to what the problem is.
Here's some example code for repro steps:
// Wrong!
switched to db mygeo
> var earthRadius = 6378;
> db.points.insert(
);
> db.points.insert(
);
> db.points.ensureIndex(
);
> db.points.find({location:{$nearSphere: [37.762,-122.441], $maxDistance: 1/earthRadius}});
error:
// Correct
> db.points.drop()
true
> db.points.insert(
);
> db.points.insert(
);
> db.points.ensureIndex(
);
> db.points.find({location:{$nearSphere: [-122.441, 37.762], $maxDistance: 1/earthRadius}});