Search code examples
ruby-on-railsruby-on-rails-3pluginsrubygemsgeolocation

Fetch results based upon distance, using latitude and longitude stored in database


I have a User Model and every user is having latitude and longitude stored in the table. I want to fetch all the users in the range of 30kms with a given latitude and longitude. Any plugin to calculate the distance using latitude and longitude from the table.


id   name   latitude  longitude

 1   abc    43.56     56.34

 2   xyz    46.34     57.87

 3   mno    50.34     23.56

Assume this is my table values(its just a sample data.). I want to fetch all the users within a range of 30kms from a given altitude like (34.89, 56.45)


Solution

  • Thinking sphinx has search, sort and filtering by distance from a latitude and longitude: http://freelancing-god.github.com/ts/en/geosearching.html