Skip to content

Commit

Permalink
Remove province, it's really an alias for state
Browse files Browse the repository at this point in the history
  • Loading branch information
mnoack committed Dec 12, 2016
1 parent 2522012 commit 3903201
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
11 changes: 7 additions & 4 deletions lib/geokit/geo_loc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GeoLoc < LatLng
# Street number and street name are extracted from the street address
# attribute if they don't exist
attr_accessor :state_name, :state_code, :zip, :country_code, :country
attr_accessor :all, :district, :province, :sub_premise,
attr_accessor :all, :district, :sub_premise,
:neighborhood
attr_writer :state, :full_address, :street_number, :street_name, :formatted_address
attr_reader :city, :street_address
Expand All @@ -42,6 +42,10 @@ class GeoLoc < LatLng
# FCC Attributes
attr_accessor :district_fips, :state_fips, :block_fips

def province
state
end

# Constructor expects a hash of symbols to correspond with attributes.
def initialize(h = {})
@all = [self]
Expand All @@ -56,7 +60,6 @@ def initialize(h = {})
@state_name = h[:state_name]
@zip = h[:zip]
@country_code = h[:country_code]
@province = h[:province]
@success = false
@precision = 'unknown'
@full_address = nil
Expand Down Expand Up @@ -104,7 +107,7 @@ def formatted_address
def hash
res = {}
fields = [:success, :lat, :lng, :country_code, :city, :state, :zip,
:street_address, :province, :district, :provider, :full_address, :is_us?,
:street_address, :district, :provider, :full_address, :is_us?,
:ll, :precision, :district_fips, :state_fips, :block_fips, :sub_premise]
fields.each { |s| res[s] = send(s.to_s) }
res
Expand All @@ -130,7 +133,7 @@ def street_address=(address)
# state, zip, and country code. Only includes those attributes that are
# non-blank.
def to_geocodeable_s
a = [street_address, district, city, province, state, zip, country_code].compact
a = [street_address, district, city, state, zip, country_code].compact
a.delete_if { |e| !e || e == '' }
a.join(', ')
end
Expand Down
1 change: 0 additions & 1 deletion lib/geokit/geocoders/ca_geocoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def self.parse_xml(xml, loc)
loc.street_number = xml.elements['//stnumber'].text
loc.street_address = xml.elements['//staddress'].text
loc.state = xml.elements['//prov'].text
loc.province = xml.elements['//prov'].text
loc.zip = xml.elements['//postal'].text
loc.success = true
loc
Expand Down
3 changes: 1 addition & 2 deletions lib/geokit/geocoders/google.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,9 @@ def self.set_address_components(loc, addr)
loc.street_name = comp['long_name']
when types.include?('locality')
loc.city = comp['long_name']
when types.include?('administrative_area_level_1')
when types.include?('administrative_area_level_1') # state
loc.state_code = comp['short_name']
loc.state_name = comp['long_name']
loc.province = comp['short_name']
when types.include?('postal_code')
loc.zip = comp['long_name']
when types.include?('country')
Expand Down
5 changes: 3 additions & 2 deletions test/test_ca_geocoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CaGeocoderTest < BaseGeocoderTest #:nodoc: all
def setup
geocoder_class.key = 'SOMEKEYVALUE'
@ca_full_hash = { street_address: '2105 West 32nd Avenue',
city: 'Vancouver', province: 'BC', state: 'BC' }
city: 'Vancouver', state: 'BC' }
@ca_full_txt = '2105 West 32nd Avenue Vancouver BC'
end

Expand All @@ -34,7 +34,8 @@ def test_service_unavailable
private

def verify(location)
assert_equal 'BC', location.province
assert_equal 'BC', location.state
assert_equal 'BC', location.province # alias
assert_equal 'Vancouver', location.city
assert_equal '49.243086,-123.153684', location.ll
assert !location.is_us?
Expand Down
1 change: 0 additions & 1 deletion test/test_geoloc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def test_to_yaml
'lat', '',
'lng', '',
'precision', 'unknown',
'province', '',
'state', '',
'state_code', 'CA',
'state_name', '',
Expand Down

0 comments on commit 3903201

Please sign in to comment.