From 086de4f9257619324ee236e26e31bd9ee19f51c0 Mon Sep 17 00:00:00 2001 From: aleem uddin <aleem@unwiredlabs.com> Date: Thu, 25 Aug 2016 16:48:55 +0530 Subject: [PATCH] Added locationiq provider --- README.md | 11 +++++++++++ lib/geocoder/lookup.rb | 1 + lib/geocoder/lookups/locationiq.rb | 20 ++++++++++++++++++++ lib/geocoder/results/locationiq.rb | 6 ++++++ 4 files changed, 38 insertions(+) create mode 100644 lib/geocoder/lookups/locationiq.rb create mode 100644 lib/geocoder/results/locationiq.rb diff --git a/README.md b/README.md index 5dd78e2f..c14037ab 100644 --- a/README.md +++ b/README.md @@ -457,6 +457,17 @@ The [Google Places Details API](https://developers.google.com/places/documentati * **Terms of Service**: http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy * **Limitations**: Please limit request rate to 1 per second and include your contact information in User-Agent headers (eg: `Geocoder.configure(:http_headers => { "User-Agent" => "your contact info" })`). [Data licensed under Open Database License (ODbL) (you must provide attribution).](http://www.openstreetmap.org/copyright) +#### LocationIQ (`:locationiq`) + +* **API key**: required +* **Quota**: 6 request/second (30k req/day), then ability to purchase more +* **Region**: world +* **SSL support**: yes +* **Languages**: ? +* **Documentation**: http://locationiq.org/#docs +* **Terms of Service**: https://unwiredlabs.com/tos +* **Limitations**: [Data licensed under Open Database License (ODbL) (you must provide attribution).](http://www.openstreetmap.org/copyright) + #### OpenCageData (`:opencagedata`) * **API key**: required diff --git a/lib/geocoder/lookup.rb b/lib/geocoder/lookup.rb index fdc4a070..6cac49b1 100644 --- a/lib/geocoder/lookup.rb +++ b/lib/geocoder/lookup.rb @@ -23,6 +23,7 @@ module Geocoder # def street_services @street_services ||= [ + :locationiq, :dstk, :esri, :google, diff --git a/lib/geocoder/lookups/locationiq.rb b/lib/geocoder/lookups/locationiq.rb new file mode 100644 index 00000000..7f14d214 --- /dev/null +++ b/lib/geocoder/lookups/locationiq.rb @@ -0,0 +1,20 @@ +require 'geocoder/lookups/nominatim' +require "geocoder/results/locationiq" + +module Geocoder::Lookup + class Locationiq < Nominatim + def name + "Locationiq" + end + + def required_api_key_parts + ["api_key"] + end + + def query_url(query) + method = query.reverse_geocode? ? "reverse.php" : "search.php" + host = configuration[:host] || "locationiq.org/v1" + "#{protocol}://#{host}/#{method}?key=#{configuration.api_key}&" + url_query_string(query) + end + end +end diff --git a/lib/geocoder/results/locationiq.rb b/lib/geocoder/results/locationiq.rb new file mode 100644 index 00000000..a06ea85f --- /dev/null +++ b/lib/geocoder/results/locationiq.rb @@ -0,0 +1,6 @@ +require 'geocoder/results/nominatim' + +module Geocoder::Result + class Locationiq < Nominatim + end +end \ No newline at end of file -- GitLab