Giter Club home page Giter Club logo

offline_geocoder's Introduction

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 :)).

offline_geocoder's People

Contributors

sildur avatar berkes avatar brateq avatar thewudu avatar spike886 avatar elbrujohalcon avatar nuzelac avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.