5 ms·
Cool! Working on a project that uses this a lot and this would've been very helpful two months ago. The geospatial indexing page in the Mongo docs is very helpf
by joelhaasnoot 16y ago
Cool! Working on a project that uses this a lot and this would've been very helpful two months ago. The geospatial indexing page in the Mongo docs is very helpful too.
One thing you leave out is the $nearSphere and related commands which can be used since MongoDB 1.7 or so to create better radiuses. It makes searching just that little more precise. There is one twist for it that had me stuck for a bit: the radius is in radians when using those commands.
Other than that: MongoDB makes it very very easy to create a location based mobile service. Throw in some node.js and some JSON, and you're set.
- mathias_10gen 16y agoIf you haven't seen it already, a quick Google hack for computing the radians to input into MongoDB: http://www.google.com/search?q=50+km+%2F+radius+of+earth http://www.google.com/search?q=50+km+%2F+radius+of+earth http://www.google.com/search?q=50+miles+%2F+radius+of+earth http://www.google.com/search?q=50+miles+%2F+radius+of+earth
- joelhaasnoot 16y agoYes, my code is just range/6418 or so. It just produces unexpectedly slow results when you don't realize :)