Skip to content
Snippets Groups Projects
Commit c278f94c authored by Eric Hayes's avatar Eric Hayes
Browse files

This commit adds the Data Science Toolkit as a lookup type. The DSTK behaves...

This commit adds the Data Science Toolkit as a lookup type.  The DSTK behaves identically to the Google Maps API with the exception that it can be run behind your own firewall.  More information about this tool can be found here: http://www.datasciencetoolkit.org/
parent 6b0af4f6
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
...@@ -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