Reputation: 4388
I have a user model which stores the lat and log of a user in latitude and longitude field.
Now I have a arbitrary point (lat and longitude).
Now what is the best way to find all the users which lies in the radius of 10kms of that arbitrary point.
Does geocoder gem does it?
Thanks
Upvotes: 1
Views: 772
Reputation: 4388
Yup Geocoder have this feature ie to check if it any point (latitude, longitude) lies within certain radius of certian point.
Lets say an arbitrary object of model X with fields latitude = x and longitude = y be obj
Now to find any similar object within m miles radius from obj we can do
obj.nearbys(m)
This query will return all X's which lies within x miles radius form obj
Upvotes: 1
Reputation: 8402
Geocoder does seem to have what you need. You could also roll your own.
Upvotes: 1