Skip to content
Snippets Groups Projects
Commit b15bdda0 authored by Alex Reisner's avatar Alex Reisner
Browse files

Merge pull request #475 from ejhayes/master

Support for Data Science Toolkit (DSTK) lookup.
parents 3c8647a8 780fe199
No related branches found
No related tags found
No related merge requests found
...@@ -3,3 +3,4 @@ rdoc/* ...@@ -3,3 +3,4 @@ rdoc/*
*.gem *.gem
.bundle .bundle
Gemfile.lock Gemfile.lock
.DS_Store
...@@ -311,6 +311,17 @@ The following is a comparison of the supported geocoding APIs. The "Limitations" ...@@ -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..." * **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])`. * **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 (`:yahoo`)
Yahoo BOSS is **not a free service**. As of November 17, 2012 Yahoo no longer offers a free geocoding API. Yahoo BOSS is **not a free service**. As of November 17, 2012 Yahoo no longer offers a free geocoding API.
......
...@@ -21,6 +21,7 @@ module Geocoder ...@@ -21,6 +21,7 @@ module Geocoder
# #
def street_services def street_services
[ [
:dstk,
:esri, :esri,
:google, :google,
:google_premier, :google_premier,
......
# 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
require 'geocoder/results/google'
module Geocoder::Result
class Dstk < Google
end
end
\ No newline at end of file
...@@ -98,6 +98,26 @@ class ServicesTest < Test::Unit::TestCase ...@@ -98,6 +98,26 @@ class ServicesTest < Test::Unit::TestCase
Geocoder::Lookup::GooglePremier.new.query_url(Geocoder::Query.new("Madison Square Garden, New York, NY")) Geocoder::Lookup::GooglePremier.new.query_url(Geocoder::Query.new("Madison Square Garden, New York, NY"))
end 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 --- # --- Yahoo ---
......
...@@ -119,6 +119,13 @@ module Geocoder ...@@ -119,6 +119,13 @@ module Geocoder
end end
end end
class Dstk
private
def fixture_prefix
"google"
end
end
class Yandex class Yandex
private private
def default_fixture_filename def default_fixture_filename
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment