0.0
No commit activity in last 3 years
No release in over 3 years
A ruby gem for translating geo informations (e.g. zip code) to geo locations.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
~> 0.9.12.4
~> 0.2.3
>= 0
~> 2.14.1

Runtime

~> 1.3.9
 Project Readme

GeoLocator Dependency Status

A gem which packages a offline database to geocode zip codes and locations without the need for an external web service.

Installation

Add this line to your application's Gemfile:

gem 'geo_locator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install geo_locator

Usage

$ irb
2.1.0 :001 > require "geo_locator"
 => true
2.1.0 :002 > GeoLocator.locate(zip_code: 10115)
 => [{:lat=>52.5337069545604, :lon=>13.387223860255}]

You can use the format option to specify, how the coordinates should be returned. This is useful for example for elasticsearch. Supported values are :array, :hash, :string.

2.1.0 :003 > GeoLocator.locate(zip_code: 10115, format: :array)
 => [[13.387223860255, 52.5337069545604]]
2.1.0 :004 > GeoLocator.locate(zip_code: 10115, format: :hash)
 => [{:lat=>52.5337069545604, :lon=>13.387223860255}]
2.1.0 :005 > GeoLocator.locate(zip_code: 10115, format: :string)
 => ["52.5337069545604,13.387223860255"]

Instantiating GeoLocator

GeoLocator provides a class level locate method. Due to it's stateless nature, it cannot reuse internal database connections or cache requested coordinates. If you want this kind of optimizations, create an instance of GeoLocator, which provides a locate method with the same semantic as the class level method.

Actually, the class level locate creates a new instance of GeoLocator and calls locate on it, internally.

Limitations

  • only locations in Germany are supported
  • retrival of geo locations is only possible based on zip codes or city names

Contributing

  1. Fork it ( http://github.com//geo_locator/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Credits

This gem is based on data provided by OpenGeoDB (http://www.opengeodb.org).