MongoDB has a very nice Geospatial Indexing feature. How can I use it in Rails with Mongoid?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can define geo indexes like this in mongoid
And for queries
$near command (without maxDistance)
$near command (with maxDistance)
Convert distance by 111.12 (one degree is approximately 111.12 kilometers) when using km, or leave distance as it is on using degree
$centerSphere / $nearSphere queries
This will find the items within the 10 km radius. Here we need to convert the distance/6371(earth radius) to get it work with km.
$box (bounding box queries)
This will help you to find the items within the given bounding box.