Skip to content
No description or website provided.
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.travis.yml
Changelog.md
Gemfile
Gemfile.lock
MIT-LICENCE
README.md
Rakefile
TODO.md
geocoding_lite.gemspec

README.md

Geocoding Lite Build Status Gem Version

Lookup addresses, zip codes, cities and geographical coordinates.

Table of contents

  1. What is geocoding?
  2. Installation
  3. Geocoding in action
  4. Reverse geocoding
  5. Important things to know
  6. Contributing
  7. Author

What is geocoding?

Geocoding is the process of finding associated geographic coordinates (often expressed as latitude and longitude) from other geographic data, such as street addresses, or ZIP codes (postal codes). With geographic coordinates the features can be mapped and entered into Geographic Information Systems, or the coordinates can be embedded into media such as digital photographs via geotagging.

http://en.wikipedia.org/wiki/Geocoding

Installation

gem install geocoding_lite

Geocoding in action

It's super simple! Follow the example:

require 'geocoding_lite'

results = '12783 Pico Blvd, Santa Monica'.geocoding_lookup

puts results

Will output this

[
  {
    :address => "Pico Boulevard, Santa Monica, CA, USA", 
    :lat     => 34.0176723, 
    :lng     => -118.4727648, 
    :types   => ["route"]
  }, {
    :address => "West Pico Boulevard, CA, USA", 
    :lat     => 34.0373139, 
    :lng     => -118.4343903, 
    :types   => ["route"]
  }, {
    :address => "Santa Monica Boulevard, Santa Monica, CA, USA", 
    :lat     => 34.023733, 
    :lng     => -118.485698, 
    :types   => ["route"]
  }
]

Reverse geocoding

You can also do reverse lookups. Hooray! For instance, if you're extracting gps coordinates info from your smartphone photo library and you want to see what is the closest address to the location where the photo is taken.

See the following example:

require 'geocoding_lite'

# Coordinates of Brookly NY.
# Note that when doing reverse geocoding you need 
# to put your coordinates in an array. 
# The size of array is 2 elements.
#   coordinates[0] for lattitude
#   coordinates[1] for longitude
coordinates = [40.714224, -73.961452]

puts coordinates.geocoding_lookup.first

Should return this:

{
  :address => "287 Bedford Avenue, Brooklyn, NY 11211, USA", 
  :lat     => 40.7140334, 
  :lng     => -73.9614979, 
  :types   => ["street_address"]
}

Important things to know

Geocoding Lite is based on Google's geocoding API and therefore it's a subject to certain limitations. One of the limitations is that using this library, a user can make up to 2500 requests a day so, please, use it responsibly. For more info please check the link below.

https://developers.google.com/maps/documentation/geocoding/#Limits

Also, if you are looking for more powerful geocoding library I recommend you trying geocoder.

http://www.rubygeocoder.com/

Contributing

Any help on this project is very welcome. Please feel free to fork, modify and make pull requests. Also make sure you check the TODO file when the file is present in the repository.

Author

Geocoding Lite was written by Vladimir Ivic (vladimir.ivic at icloud.com) and is released under the MIT license.

Something went wrong with that request. Please try again.