This is a broad question to get me started in the right direction:
I would like to provide a location-based service so that users can tag
articles with a location (the place where the article took place), and
search (or list) articles by location.
This raises some questions:
Presumably best practice is to allow the user not to type free-form
locations, but to help them pick a location from a list?
Are there any frameworks that handle geographical hierarchies? For
example, an article may be tagged with a city name, and a user may want
to list all articles for a county, we’d need to know all of the cities
in each county or we’d return nothing.
The simplest thing may be to just have a flat list of places, with no
hierarchy, a list of cities and major towns for example?
Any broad advice on what’s out there to provide any
geographical/location services would be much appreciated!
I’m not going to be able to help this yet, but just to add to it. What
level of granularity do you want to provide? Can people search by the
places within a city? How about different shops/ outlets within a
city? Does it matter which branch generated the document?
I’m not going to be able to help this yet, but just to add to it. What
level of granularity do you want to provide?
For me, I could really get away with a flat list of worldwide cities,
which I guess would be the least level of granularity possible. However,
a 2-level service would be good so we would have a hierarchy of
county/parish<->city. Of course, for very large cities such as London,
it would be good to be able to split them further.
So in a nutshell, for my needs I think I could get by with a sensible
worldwide flat list, but if there’s a good, easy to integrate, worldwide
2-level service/framework, that would be great for me.
As for shops and outlets, that level of granularity would be a bit too
much for me, but actually, thinking about it, might be interesting!
I guess I was fishing around for clues on what was available.
It adds a number of geocode-specific methods to ActiveRecord which
allow you to query records based on their proximity to a location
(e.g. @locations = Location.find(:all, :origin => @address, :within => @within, :order => ‘distance’)). It can also automatically geocode a
location upon create using either Google, Yahoo, or GeoNames. You
provide your API key and GeoKit handles the grunt work. Very handy
tool.
I second Geokit, I’ve used it in almost every application I’ve built.
However, the main purpose of geokit is for getting the latitude and
longitude of a location and then performing distance calculations
between
that location and other locations (such as finding all locations within
a
certain distance of another location).
If you want to do something such as list cities or counties, you’ll
probably
need to get something like a ‘location database’ and slice and dice it
for
your needs. Unfortunately they usually cost money.
An alternative solution to showing all the articles in the same county
as a
city would be to use geokit to show all the articles within a certain
distance of a city. That could provide your users with a similar
experience.
Hope that helps.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.