Permalink
Browse files

added geoNear sphere support

  • Loading branch information...
kristianmandrup committed Mar 2, 2011
1 parent b127675 commit a4fbe413514699497c7397b99395a52e33102b08
Showing with 6 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +3 −0 README.textile
  3. +2 −2 lib/mongoid/geo/geo_near.rb
View
@@ -4,3 +4,4 @@ pkg/
spec/dummy/db/*.sqlite3
spec/dummy/log/*.log
spec/dummy/tmp/
+*.lock
View
@@ -136,6 +136,9 @@ end
# Find all positions sorted nearest to the address loation
nearest_positions = Position.geoNear(another_address.location, :pos)
+
+# perform distance locations in Speherical mode inside Mongo DB (default is :plane)
+nearest_positions = Position.geoNear(another_address.location, :pos, :sphere)
</pre>
h2. Mongoid Geo extra inclusions
@@ -8,9 +8,9 @@
module Mongoid
module Geo
module Near
- def geoNear(center, location_attribute)
+ def geoNear(center, location_attribute, mode = :plane)
center = center.respond_to?(:collection) ? center.send(location_attribute) : center
- query = create_query(self, center)
+ query = create_query(self, center, mode)
create_result(query_result(self, query, center, location_attribute))
end

0 comments on commit a4fbe41

Please sign in to comment.