test/test_google_geocoder.rb in steveh-geokit-1.6.0 vs test/test_google_geocoder.rb in steveh-geokit-1.6.1
- old
+ new
@@ -40,11 +40,11 @@
end
def test_google_full_address
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_FULL)
- url = "http://maps.google.com/maps/geo?q=#{Geokit::Inflector.url_escape(@address)}&output=xml&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=Google&oe=utf-8&output=xml&q=#{Geokit::Inflector.url_escape(@address)}"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
res=Geokit::Geocoders::GoogleGeocoder.geocode(@address)
assert_equal "CA", res.state
assert_equal "San Francisco", res.city
assert_equal "37.792501,-122.393985", res.ll # slightly dif from yahoo
@@ -54,11 +54,11 @@
end
def test_google_full_address_with_geo_loc
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_FULL)
- url = "http://maps.google.com/maps/geo?q=#{Geokit::Inflector.url_escape(@full_address_short_zip)}&output=xml&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=Google&oe=utf-8&output=xml&q=#{Geokit::Inflector.url_escape(@full_address_short_zip)}"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
res=Geokit::Geocoders::GoogleGeocoder.geocode(@google_full_loc)
assert_equal "CA", res.state
assert_equal "San Francisco", res.city
assert_equal "37.792501,-122.393985", res.ll # slightly dif from yahoo
@@ -68,20 +68,20 @@
end
def test_google_full_address_accuracy
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_FULL)
- url = "http://maps.google.com/maps/geo?q=#{Geokit::Inflector.url_escape(@full_address_short_zip)}&output=xml&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=Google&oe=utf-8&output=xml&q=#{Geokit::Inflector.url_escape(@full_address_short_zip)}"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
res=Geokit::Geocoders::GoogleGeocoder.geocode(@google_full_loc)
assert_equal 8, res.accuracy
end
def test_google_city
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_CITY)
- url = "http://maps.google.com/maps/geo?q=#{Geokit::Inflector.url_escape(@address)}&output=xml&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=Google&oe=utf-8&output=xml&q=#{Geokit::Inflector.url_escape(@address)}"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
res=Geokit::Geocoders::GoogleGeocoder.geocode(@address)
assert_equal "CA", res.state
assert_equal "San Francisco", res.city
assert_equal "37.775,-122.418333", res.ll
@@ -92,20 +92,20 @@
end
def test_google_city_accuracy
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_CITY)
- url = "http://maps.google.com/maps/geo?q=#{Geokit::Inflector.url_escape(@address)}&output=xml&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=Google&oe=utf-8&output=xml&q=#{Geokit::Inflector.url_escape(@address)}"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
res=Geokit::Geocoders::GoogleGeocoder.geocode(@address)
assert_equal 4, res.accuracy
end
def test_google_city_with_geo_loc
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_CITY)
- url = "http://maps.google.com/maps/geo?q=#{Geokit::Inflector.url_escape(@address)}&output=xml&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=Google&oe=utf-8&output=xml&q=#{Geokit::Inflector.url_escape(@address)}"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
res=Geokit::Geocoders::GoogleGeocoder.geocode(@google_city_loc)
assert_equal "CA", res.state
assert_equal "San Francisco", res.city
assert_equal "37.775,-122.418333", res.ll
@@ -116,30 +116,30 @@
end
def test_google_suggested_bounds
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_RESULT_WITH_SUGGESTED_BOUNDS)
- url = "http://maps.google.com/maps/geo?q=#{Geokit::Inflector.url_escape(@full_address_short_zip)}&output=xml&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=Google&oe=utf-8&output=xml&q=#{Geokit::Inflector.url_escape(@full_address_short_zip)}"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
res = Geokit::Geocoders::GoogleGeocoder.geocode(@google_full_loc)
assert_instance_of Geokit::Bounds, res.suggested_bounds
assert_equal Geokit::Bounds.new(Geokit::LatLng.new(37.7893376, -122.3971525), Geokit::LatLng.new(37.7956328, -122.3908573)), res.suggested_bounds
end
def test_service_unavailable
response = MockFailure.new
- url = "http://maps.google.com/maps/geo?q=#{Geokit::Inflector.url_escape(@address)}&output=xml&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=Google&oe=utf-8&output=xml&q=#{Geokit::Inflector.url_escape(@address)}"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
assert !Geokit::Geocoders::GoogleGeocoder.geocode(@google_city_loc).success
end
def test_multiple_results
#Geokit::Geocoders::GoogleGeocoder.do_geocode('via Sandro Pertini 8, Ossona, MI')
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_MULTI)
- url = "http://maps.google.com/maps/geo?q=#{Geokit::Inflector.url_escape('via Sandro Pertini 8, Ossona, MI')}&output=xml&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=Google&oe=utf-8&output=xml&q=#{Geokit::Inflector.url_escape('via Sandro Pertini 8, Ossona, MI')}"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
res=Geokit::Geocoders::GoogleGeocoder.geocode('via Sandro Pertini 8, Ossona, MI')
assert_equal "Lombardy", res.state
assert_equal "Mesero", res.city
assert_equal "45.4966243,8.8527131", res.ll
@@ -163,11 +163,11 @@
#Geokit::Geocoders::GoogleGeocoder.do_reverse_geocode("40.4167413, -3.7032498")
madrid = Geokit::GeoLoc.new
madrid.lat, madrid.lng = "40.4167413", "-3.7032498"
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_REVERSE_MADRID)
- url = "http://maps.google.com/maps/geo?ll=#{Geokit::Inflector::url_escape(madrid.ll)}&output=xml&key=#{Geokit::Geocoders::google}&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=#{Geokit::Geocoders::google}&ll=#{Geokit::Inflector::url_escape(madrid.ll)}&oe=utf-8&output=xml"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).
returns(response)
res=Geokit::Geocoders::GoogleGeocoder.do_reverse_geocode(madrid.ll)
assert_equal madrid.lat.to_s.slice(1..5), res.lat.to_s.slice(1..5)
@@ -189,11 +189,11 @@
def test_country_code_biasing
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_COUNTRY_CODE_BIASED_RESULT)
- url = "http://maps.google.com/maps/geo?q=Syracuse&output=xml&gl=it&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?gl=it&key=Google&oe=utf-8&output=xml&q=Syracuse"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
biased_result = Geokit::Geocoders::GoogleGeocoder.geocode('Syracuse', :bias => 'it')
assert_equal 'IT', biased_result.country_code
assert_equal 'Sicily', biased_result.state
@@ -201,11 +201,11 @@
def test_bounds_biasing
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_BOUNDS_BIASED_RESULT)
- url = "http://maps.google.com/maps/geo?q=Winnetka&output=xml&ll=34.19769320884902,-118.54716002778494&spn=0.2470479999999995,0.29491400000000567&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=Google&ll=34.19769320884902%2C-118.54716002778494&oe=utf-8&output=xml&q=Winnetka&spn=0.2470479999999995%2C0.29491400000000567"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
bounds = Geokit::Bounds.normalize([34.074081, -118.694401], [34.321129, -118.399487])
biased_result = Geokit::Geocoders::GoogleGeocoder.geocode('Winnetka', :bias => bounds)
@@ -214,10 +214,10 @@
end
def test_too_many_queries
response = MockSuccess.new
response.expects(:body).returns(GOOGLE_TOO_MANY)
- url = "http://maps.google.com/maps/geo?q=#{Geokit::Inflector.url_escape(@address)}&output=xml&key=Google&oe=utf-8"
+ url = "http://maps.google.com/maps/geo?key=Google&oe=utf-8&output=xml&q=#{Geokit::Inflector.url_escape(@address)}"
Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
assert_raise Geokit::TooManyQueriesError do
res=Geokit::Geocoders::GoogleGeocoder.geocode(@address)
end
end