diff --git a/.gitignore b/.gitignore index c94bfb4e2fb82925be8231893229c1e294f40b68..96a66d35cd7216c87cfd31e9aae3a8a8136d13d5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ rdoc/* *.gem .bundle Gemfile.lock +.DS_Store diff --git a/README.md b/README.md index dc023f5a05975442e71ae3e465b39c2a22daf1a7..840868a8f9d1073ee1da0aa10fb189e002824b24 100644 --- a/README.md +++ b/README.md @@ -311,6 +311,17 @@ The following is a comparison of the supported geocoding APIs. The "Limitations" * **Limitations**: "You must not use or display the Content without a corresponding Google map, unless you are explicitly permitted to do so in the Maps APIs Documentation, or through written permission from Google." "You must not pre-fetch, cache, or store any Content, except that you may store: (i) limited amounts of Content for the purpose of improving the performance of your Maps API Implementation..." * **Notes**: To use Google Premier set `Geocoder.configure(:lookup => :google_premier, :api_key => [key, client, channel])`. +#### Data Science Toolkit (`:dstk`) + +* **Host**: if you are running this behind your own firewall +* **Quota**: no quota if you are running on your own hardware +* **Region**: world +* **SSL support**: ? +* **Languages**: en +* **Documentation**: http://www.datasciencetoolkit.org/developerdocs +* **Terms of Service**: http://www.datasciencetoolkit.org/developerdocs#googlestylegeocoder +* **Limitations**: None. + #### Yahoo BOSS (`:yahoo`) Yahoo BOSS is **not a free service**. As of November 17, 2012 Yahoo no longer offers a free geocoding API. diff --git a/lib/geocoder/lookup.rb b/lib/geocoder/lookup.rb index 054d55cc7f520f530607969e2499224d2bcf4d47..6a6ee407e67b60b16fb2999b229a79ef01a89514 100644 --- a/lib/geocoder/lookup.rb +++ b/lib/geocoder/lookup.rb @@ -21,6 +21,7 @@ module Geocoder # def street_services [ + :dstk, :esri, :google, :google_premier, diff --git a/lib/geocoder/lookups/dstk.rb b/lib/geocoder/lookups/dstk.rb new file mode 100644 index 0000000000000000000000000000000000000000..6818605308d642fda5a2674e28d542e8b66bd141 --- /dev/null +++ b/lib/geocoder/lookups/dstk.rb @@ -0,0 +1,20 @@ +# More information about the Data Science Toolkit can be found at: +# http://www.datasciencetoolkit.org/. The provided APIs mimic the +# Google geocoding api. + +require 'geocoder/lookups/google' +require 'geocoder/results/dstk' + +module Geocoder::Lookup + class Dstk < Google + + def name + "Data Science Toolkit" + end + + def query_url(query) + host = configuration[:host] || "www.datasciencetoolkit.org" + "#{protocol}://#{host}/maps/api/geocode/json?" + url_query_string(query) + end + end +end diff --git a/lib/geocoder/results/dstk.rb b/lib/geocoder/results/dstk.rb new file mode 100644 index 0000000000000000000000000000000000000000..ce98fe6a51bc8c2a3bce8e4304e6482637406a2e --- /dev/null +++ b/lib/geocoder/results/dstk.rb @@ -0,0 +1,6 @@ +require 'geocoder/results/google' + +module Geocoder::Result + class Dstk < Google + end +end \ No newline at end of file diff --git a/test/services_test.rb b/test/services_test.rb index 906f4fd3edc1f5a05c503179dbbc2eb89e317ae4..022b42334940951666c89e037f4fa90f5f398fe1 100644 --- a/test/services_test.rb +++ b/test/services_test.rb @@ -98,6 +98,26 @@ class ServicesTest < Test::Unit::TestCase Geocoder::Lookup::GooglePremier.new.query_url(Geocoder::Query.new("Madison Square Garden, New York, NY")) end + # --- DSTK (Data Science Toolkit) --- + + def test_dstk_result_components + Geocoder.configure(:lookup => :dstk, :dstk => { :host => 'NOT_AN_ACTUAL_HOST' }) + result = Geocoder.search("Madison Square Garden, New York, NY").first + assert_equal "Manhattan", + result.address_components_of_type(:sublocality).first['long_name'] + end + + def test_dstk_query_url + Geocoder.configure(:lookup => :dstk, :dstk => { :host => 'NOT_AN_ACTUAL_HOST' }) + assert_equal "http://NOT_AN_ACTUAL_HOST/maps/api/geocode/json?address=Madison+Square+Garden%2C+New+York%2C+NY&language=en&sensor=false", + Geocoder::Lookup::Dstk.new.query_url(Geocoder::Query.new("Madison Square Garden, New York, NY")) + end + + def test_dstk_default_query_url + Geocoder.configure(:lookup => :dstk) + assert_equal "http://www.datasciencetoolkit.org/maps/api/geocode/json?address=Madison+Square+Garden%2C+New+York%2C+NY&language=en&sensor=false", + Geocoder::Lookup::Dstk.new.query_url(Geocoder::Query.new("Madison Square Garden, New York, NY")) + end # --- Yahoo --- diff --git a/test/test_helper.rb b/test/test_helper.rb index b74017d41d0d497d8b61b60ea933e452613cf452..24ca32c77fd49d49ec9c1aa75299ab2d1c975746 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -119,6 +119,13 @@ module Geocoder end end + class Dstk + private + def fixture_prefix + "google" + end + end + class Yandex private def default_fixture_filename