0.03
Low commit activity in last 3 years
No release in over a year
Offline reverse geocoder. Uses GeoNames database
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 12.3.3
~> 3.2

Runtime

~> 0.2
 Project Readme

Build Status Code Climate Gem Version Gem

OfflineGeocoder

A gem for offline reverse geocoding. It uses data from the GeoNames project.

Installation

Add this line to your application's Gemfile:

gem 'offline_geocoder'

And then execute:

$ bundle

Or install it yourself as:

$ gem install offline_geocoder

Usage

require "offline_geocoder"
geocoder = OfflineGeocoder.new
results = geocoder.search(51.5214588, -0.1729636)
p results

The above code will output this:

{:lat=>51.51116, :lon=>-0.18426, :name=>"Bayswater", :admin1=>"England", :admin2=>"Greater London", :cc=>"GB", :country=>"United Kingdom"}

Alternatively, you can use named parameters when searching:

results = geocoder.search(lat: 51.5214588, lon: -0.1729636)

Searching for names or attributes

You can search for names, countries and such. The first result will be returned.

Searches are case sensitive and must match entirely. e.g. "York" will not find "New York", and "Cote dIvoire" will not match "Cote d'Ivoire".

require "offline_geocoder"
geocoder = OfflineGeocoder.new
aus = geocoder.search(name: "Bayswater")
p aus
gb = geocoder.search(name: "Bayswater", country: "United Kingdom")
p gb

The above code will output this:

{:lat=>-37.85, :lon=>145.26667, :name=>"Bayswater", :admin1=>"Victoria", :admin2=>"Knox", :cc=>"AU", :country=>"Australia"}
{:lat=>51.51116, :lon=>-0.18426, :name=>"Bayswater", :admin1=>"England", :admin2=>"Greater London", :cc=>"GB", :country=>"United Kingdom"}

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Contact Me

If you find any bugs or have a problem while using this library, please open an issue in this repo (or a pull request :)).