-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
In http://www.mongodb.org/display/DOCS/Geospatial+Indexing it appears
you can get a distance back from MongoDB when making queries against a
model that has this form:
class User
..
field :latlng, :type => Array
index [[ :latlng, Mongo::GEO2D ]]
end
However, when I do this query (where res is a latitude, longitude
output from GeoKit):
@users = User.where(:latlng.within => {"$center" =>
[ res.ll.split(',').map
, radius ]}).order_by(:dis)
I get the results back in the correct order based on distance, but it
does not appear to filter anything out. And @users does not contain
any distance information.
Is there a way to access the :dis value from Mongoid or the ruby
driver? And what am I doing wrong so that the filtering is not working
correctly?