Skip to content

🌎 Client for foursquares Twofishes API, a sparse reverse geocoder (which is incredibly fast)

License

Notifications You must be signed in to change notification settings

masone/twofishes-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twofishes

Build Status Code Climate Dependency Status Gem Version

A client/wrapper for foursquare's sparse geocoding / reverse geocoding server Twofishes (https://github.com/foursquare/twofishes).

Installation

Add this line to your application's Gemfile:

gem 'twofishes'

And then execute:

$ bundle

Or install it yourself as:

$ gem install twofishes

Configuration

Twofishes.configure do |config|
  config.host = '127.0.0.1' # server address
  config.port = 8080 # thrift port
  config.timeout = 3 # request timeout in seconds
  config.connect_timeout = 0.5 # connection timeout in seconds
  config.retries = 2 # how many times to retry a request
end

Request timeouts are enforced per-try, so if you have a timeout of n and do m retries, the total time it could take is n*m.

Usage

Use the following methods to geocode / reverse geocode.

Twofishes::Client.geocode('Ljubljana')
Twofishes::Client.reverse_geocode([0, 0])

If you want the Twofishes server to return fields that are not included by default, you can pass geocode an Array of ResponseIncludes constants, illustrated by the example below.

Twofishes::Client.geocode('Zurich', includes: [ResponseIncludes::PARENTS])

Additional options are directly passed to the Twofishes server. You can for example give a language hint by doing:

Twofishes::Client.geocode('Zurich', lang: 'de')

For more parameters, have a look at the Twofishes' GeocodeRequest struct.

Compatibility

Ruby 2+

Contributing

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

About

🌎 Client for foursquares Twofishes API, a sparse reverse geocoder (which is incredibly fast)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages