[fix] add_admin_boundaries and adding cleaned up house number

This commit is contained in:
Al
2016-08-28 15:15:38 -04:00
parent bae04eb543
commit a58194ca2e
2 changed files with 5 additions and 2 deletions

View File

@@ -709,6 +709,8 @@ class AddressComponents(object):
containing_components = osm_components[i + 1:]
component = self.categorize_osm_component(country, props, containing_components)
if component is None:
continue
if (props.get('type'), safe_encode(props.get('id', ''))) in self.use_admin_center_ids:
props = props.get('admin_center', props)

View File

@@ -306,6 +306,8 @@ class OpenAddressesFormatter(object):
house_number = components.get(AddressFormatter.HOUSE_NUMBER, None)
if house_number:
house_number = self.cleanup_number(house_number)
if house_number is not None:
components[AddressFormatter.HOUSE_NUMBER] = house_number
postcode = components.get(AddressFormatter.POSTCODE, None)
if postcode:
@@ -324,10 +326,9 @@ class OpenAddressesFormatter(object):
# If there's a postcode, we can still use just the city/state/postcode, otherwise discard
if not (street and house_number) or street.lower() == house_number.lower() or (unit and street and street.lower() == unit.lower()):
components = self.components.drop_address(components)
if not postcode:
continue
components = self.components.drop_address(components)
# Now that checks, etc. are completed, fetch unit and add phrases, abbreviate, etc.
unit = components.get(AddressFormatter.UNIT, None)