diff --git a/lib/geocoder.rb b/lib/geocoder.rb index 5bce2283b9e2463c76edf7ba9e4e99e1bd830ff7..b73e6e9cf2d71eaabee62652f58751f5fbb88c04 100644 --- a/lib/geocoder.rb +++ b/lib/geocoder.rb @@ -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 ## diff --git a/test/services_test.rb b/test/services_test.rb index b01b84abcbdb03c4c2f466f6b39859d687b26774..479ce2e79ec7e0cf2020da392ec9e817fca8fb82 100644 --- a/test/services_test.rb +++ b/test/services_test.rb @@ -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 diff --git a/test/test_helper.rb b/test/test_helper.rb index 137f756fdbad489f0880c08e64f452d0bf2ef7cb..94d3ebf072e31f6dad5da7ba9ec4b40b927e5aaf 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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