diff --git a/lib/geokit/geocoders/google.rb b/lib/geokit/geocoders/google.rb index f094f1f0..716609d7 100644 --- a/lib/geokit/geocoders/google.rb +++ b/lib/geokit/geocoders/google.rb @@ -216,6 +216,7 @@ def self.set_address_components(loc, addr) loc.country = comp['long_name'] when types.include?('administrative_area_level_2') loc.district = comp['long_name'] + loc.county = comp['long_name'] when types.include?('neighborhood') loc.neighborhood = comp['short_name'] # Use either sublocality or admin area level 3 if google does not return a city diff --git a/test/test_google_geocoder.rb b/test/test_google_geocoder.rb index 54526f4d..766e8f25 100644 --- a/test/test_google_geocoder.rb +++ b/test/test_google_geocoder.rb @@ -118,6 +118,7 @@ def test_google_city res = geocode(@address, :google_city) assert_nil res.street_address assert_equal 'CA', res.state + assert_equal 'San Francisco County', res.county assert_equal 'San Francisco', res.city assert_equal '37.7749295,-122.4194155', res.ll assert res.is_us? @@ -133,6 +134,7 @@ def test_google_sublocality res = geocode(@address, :google_sublocality) assert_equal '682 Prospect Place', res.street_address assert_equal 'NY', res.state + assert_equal 'Kings County', res.county assert_equal 'Brooklyn', res.city assert_equal '40.6745812,-73.9541582', res.ll assert res.is_us? @@ -148,6 +150,7 @@ def test_google_administrative_area_level_3 res = geocode(@address, :google_administrative_area_level_3) assert_equal '8 Barkwood Lane', res.street_address assert_equal 'NY', res.state + assert_equal 'Saratoga County', res.county assert_equal 'Clifton Park', res.city assert_equal '42.829583,-73.788174', res.ll assert res.is_us? @@ -175,6 +178,7 @@ def test_google_city_with_geo_loc TestHelper.expects(:last_url).with(url) res = geocode(@google_city_loc, :google_city) assert_equal 'CA', res.state + assert_equal 'San Francisco County', res.county assert_equal 'San Francisco', res.city assert_equal '37.7749295,-122.4194155', res.ll assert res.is_us? @@ -261,6 +265,7 @@ def test_reverse_geocode assert_equal 'google', res.provider assert_equal 'Madrid', res.city + assert_equal 'Madrid', res.county assert_equal 'Community of Madrid', res.state assert_equal 'Spain', res.country