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

RoR Location Search


Sorry for the fairly open question but I was wondering whether anyone had any advice on the best way to create an app that searches for properties within a particular radius.

The best example of what I am looking to achieve is RightMove.

I was wondering what the best setup would be for adding city, town and postcode data and making it searchable.

I have been reading about Geocoder but was wondering whether this would be the best option for such an app or whether there are good alternatives. For example would you recommend storing all the location data in my own database or using an API to feed in this information.

Any advice or links people can offer really would be appreciated! Thanks.


Solution

  • The approach purely depends on the requirements and the availability of Geocoded data for the location for which you want the geocoded data.

    Using Geocoder gives you an advantage that you don't have to bother about updating your Geo-database for a given Location. It has its own downside (request timeout, Data not available for a particular location, Licensing, Query limits etc), but they can be addressed.

    If you are okay with storing the data in your DB, then you can achieve the same thing using Postgresql+PostGIS setup. PostGIS module gives you ability to do spatial querying in terms of Radius, checking if a given goe-point falls with-in a pre-defined polygon etc and since these are executed inside the DB, the performance is also very good. This approach has two advantages, you don't have to sign up for any service and no timeout errors. The downside of this approach is that you have to maintain/update the location data yourself.

    I have done a handful of ROR projects with the second approach and its working fine for us quite well.

    Hope this helps.