views:

45

answers:

1
for post in db.datasets.find({"loc":{"$near":[50,50]}}).limit(10):

How do I get the distance between the document and "50,50"?

+1  A: 

google("mongodb geospatial") then do Ctrl-F, type "distance" (without the quotes), click on the "Next" arrow 3 times, read the section on the geoNear command.

You may want to read the section entitled "The Earth is Round but Maps are Flat" ... all about what can go wrong if you're not using the "Sphere" queries.

John Machin