Geo spatial index in mongodb with node.js Geo spatial index in mongodb with node.js mongoose mongoose

Geo spatial index in mongodb with node.js


It's also worth noting that you will want longitude to come before latitude in your array. This will not affect you when you are using 2D, but it will when you are using 3D. Mathematically this makes sense as longitude is the X coordinate and latitude is the Y coordinate (x,y), but most of us are familiar with lat coming before long (and one of the best Mongo books out there has an example with lat before long, but it does not cover 2D).

Ultimately you're likely going to want to use 3D as 2D calculations are not accurate as you move away from the equator.


UPDATE: 2015-12-08The above is no longer relevant - please see updated answers/API docs


You may want some reference here on how to do it :) And for someone who comes after. Just in case, someone is interested

http://www.jmanzano.es/blog/?p=592