views:

106

answers:

4

I am creating a rails application which will use geolocation. One can add a longi- and latitude to a record. If there are multiple records with geolocations, one can see a Google Map with nearby records, just like Twitter geolocation.

How can I store the coordinates (I don't mind to do calculations) and find nearby records? My database is MySQL.

Thanks.

+1  A: 

There are two approaches you could take, depending on your requirements:

  • Store the co-ordinates yourself (as you had planned). You should check out the Geokit gem which supports a MySQL backend and provides helpers for finding nearby locations.
  • Store your co-ords with with Simplegeo for which you can use this gem. Again, this takes care of your storage and finding nearby.
bjg
A: 

Have a look at Geokit. It is widely used in map-based applications.

auralbee
A: 

Geokit is OK for data after it is pulled from a database, but not if you are looking to structure a query from the database using spatial data. If you were only using mysql then you would be kind of stuck doing alot of calculations. Since you are using rails, you have at least this option: http://freelancing-god.github.com/ts/en/geosearching.html which should take care of a great deal of the calculations for you.

Geoff Lanotte
A: 

You can use acts_as_solr_reloaded to index and query your spatial data for this you need not to store latitude and longitude information in your main table but rather it creates a migration which creates a locals table where it stores the latitude and longitude information.And you can query the solr indexes using this also with latitude,longitude and radius.

Hitesh Manchanda