Skip to content
Snippets Groups Projects
Commit d1f036f1 authored by Chris Myers's avatar Chris Myers
Browse files

added nominatim

parent d4550c68
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ module Geocoder
# All street address lookups, default first.
#
def street_lookups
[:google, :google_premier, :yahoo, :bing, :geocoder_ca, :yandex]
[:google, :google_premier, :yahoo, :bing, :geocoder_ca, :yandex, :nominatim]
end
##
......
......@@ -110,4 +110,22 @@ class ServicesTest < Test::Unit::TestCase
results = Geocoder.search("no results")
assert_equal 0, results.length
end
# --- Nominatim ---
def test_nominatim_result_components
Geocoder::Configuration.lookup = :nominatim
result = Geocoder.search("Madison Square Garden, New York, NY").first
assert_equal "10001", result.postal_code
end
def test_nominatim_address_formatting
Geocoder::Configuration.lookup = :nominatim
result = Geocoder.search("Madison Square Garden, New York, NY").first
assert_equal "Madison Square Garden, West 31st Street, Long Island City, New York City, New York, 10001, United States of America",
result.address
end
end
......@@ -150,6 +150,19 @@ module Geocoder
end
end
class Nominatim < Base
private #-----------------------------------------------------------------
def fetch_raw_data(query, reverse = false)
raise TimeoutError if query == "timeout"
raise SocketError if query == "socket_error"
file = case query
when "no results"; :no_results
else :madison_square_garden
end
read_fixture "nominatim_#{file}.json"
end
end
end
end
......
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