Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Remote geo data and wraps geo-coding for Graticule and GeoCoder with a common API
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.document
.gitignore
.rspec
Gemfile
Gemfile.lock
LICENSE.txt
README.textile
Rakefile
VERSION
geo-remote.gemspec

README.textile

Geo Remote

  • Provides ability to get remote Geo data.
  • Wraps geocoding from the Graticule and Geocoder gems
  • common usage DSL
  • configuration API

Part of my library of “geo-” gems.

IP and location data

Uses freegeoip.net JSON API

RSpec 2 examples of API usage

require 'geo_magic/remote'

ip = GeoMagic::Remote.my_ip    
puts "ip: #{ip.inspect}"    

location = GeoMagic::Remote.location_of '74.200.247.59'
puts "city: #{location['city']}"    

Geocoder adapters

The following Geocode adapters are supported

  • Geocoder
  • Graticule
  • GraticuleMulti

Single Geocode Geocoder:

  # Use Graticule Multi geocoder, which tries multiple geocode services in succession!
  geocoder = GeoMagic.geo_coder(:type => :geocoder)
  # Set environment key to use or auto-detect if not explicitly passed as argument
  geocoder.configure 'map_api_keys.yaml', :development
  location = geocoder.instance.geocode "Mullerstrasse 9, Munich"
  location.city

Single Graticule Geocoder:

  # Use Graticule geocoder
  geocoder = GeoMagic.geo_coder(:type => graticule)
  geocoder.configure 'map_api_keys.yaml', :development
  location = geocoder.instance.geocode "Mullerstrasse 9, Munich"
  location.city

Multi Graticule Geocoder:

  # Use Graticule Multi geocoder, which tries multiple geocode services in succession!
  geocoder = GeoMagic.geo_coder(:type => graticule_multi)
  ..

Multi Graticule Customization:

  # Use Graticule Multi geocoder, which tries multiple geocode services in succession!
  geocoder = GeoMagic.geo_coder(:type => graticule_multi)
  location = geocoder.instance(:timeout => 3) do |result|
    [:address, :street].include?(result.precision)]
  end
  ..

Geocoder in Rails:

  geocoder = GeoMagic.geo_coder(:env => :rails).configure

  location = geocoder.instance.geocode "Mullerstrasse 9, Munich"
  location.city.should == 'Munich'

By default, the configuration expects a file in config/map_api_keys.yml containing the keys for each environment (see spec/fictures folder).
This can be customized if needed: geocoder.configure '../my_keys.yaml'

Contributing to geo-remote

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.
  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

Copyright © 2012 Kristian Mandrup. See LICENSE.txt for
further details.

Something went wrong with that request. Please try again.