]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
Actually showing the closest neighbours instead of a fixed number of people within...
[rails.git] / app / models / user.rb
index c4b81e7abdb66d26db556237e5500a670e9d2fc5..2ad45e8acd7d87ae6e63d01583548e3bfe9b9900 100644 (file)
@@ -72,7 +72,7 @@ class User < ActiveRecord::Base
     return el1
   end
 
-  def nearby(radius = 50)
+  def nearby(radius = 50, num = 5)
     if self.home_lon and self.home_lat 
       gc = OSM::GreatCircle.new(self.home_lat, self.home_lon)
       bounds = gc.bounds(radius)
@@ -82,7 +82,7 @@ class User < ActiveRecord::Base
     else
       nearby = []
     end
-    return nearby
+    return nearby.first(num)
   end
 
   def distance(nearby_user)