I've looked into storing locations with Ruby today. Haven't found what one could call best practices, but discovered a lot of interesting gems.
The initial idea was to save the address, zip code and country code. This way we could find out about the location and region with a reverse lookup. Preferably without hitting an external service.
Here we go:
-
jgv/area
Not sure what it includes, but certainly not data from Switzerland -
monterail/zip-codes
US only -
midwire/my_zipcode_gem
This one looked promising, unfortunately US only as well -
midwire/free_zipcode_data
US only –.– -
elecnix/ruby-geonames
Getting closer. Ruby gem for a pretty cool service called GeoNames that let's you lookup all kind of location related data. -
jim/carmen
This one almost did it for me. Unfortunately the Swiss regions are a mix of french and german. Could do a PR but I feel like this needs to be correct from the start. -
hexorx/countries
Another interesting one. But also weird localizations for Swiss regions... -
geokit/geokit
Not what I intended in the beginning. But the best I've found so far. -
alexreisner/geocoder
And last but not least geocoder. Also hits external services for looking up information.
The ones that do not hit external services unfortunately had wrong localizations. I could create a PR for fixing the ones from Switzerland. The problem is I also need location data from other countries and I don't know if the provided information is correct or not. That's why I'm going with geokit/geokit or alexreisner/geocoder. Both seem well maintained and popular.