spohlenz/mongomodel

Geospatial Indexing

Closed this issue · 1 comments

i thought it is possible to use the following:

index :ll => ::Mongo::GEO2D

but it will create a normal asc index on ll.

it would also be nice to implement the "$near" operator in mongomodel:
http://www.mongodb.org/display/DOCS/Geospatial+Indexing

This is now implemented in master. A new gem version will be released shortly.

class Point < MongoModel::Document
  property :position, Array, :default => [0,0]
  index :position => :geo2d, :min => -250, :max => 250
end

# Find point closest to [-50, 120]
Point.where(:position.near => [-50, 120]).first