A client/wrapper for foursquare's sparse geocoding / reverse geocoding server Twofishes (https://github.com/foursquare/twofishes).
Add this line to your application's Gemfile:
gem'twofishes'And then execute:
$ bundleOr install it yourself as:
$ gem install twofishesTwofishes.configuredo |config|
config.host='127.0.0.1'# server addressconfig.port=8080# thrift portconfig.timeout=3# request timeout in secondsconfig.connect_timeout=0.5# connection timeout in secondsconfig.retries=2# how many times to retry a requestendRequest 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.
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.
Ruby 2+
- Fork it ( http://github.com/masone/twofishes/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Run tests (
rake test) - Push to the branch (
git push origin my-new-feature) - Create new Pull Request