Skip to content

Commit

Permalink
Add sorting to read from street_segment table
Browse files Browse the repository at this point in the history
  • Loading branch information
floptical committed Apr 18, 2024
1 parent 0bf80e7 commit f1e043c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions ais/engine/scripts/load_addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ def main():
WRITE_OUT = True

DEV = False # This will target a single address
DEV_ADDRESS = '1 Franklin Town Blvd Ste 2'
DEV_ADDRESS = "920-22 W GIRARD AVE"
DEV_ADDRESS_COMPS = {
# 'base_address': '1 FRANKLIN TOWN BLVD',
# 'address_high': '4726',
# 'street_name': 'ALDEN',
# 'street_suffix': 'WALK',
}
DEV_STREET_NAME = 'FRANKLIN TOWN BLVD'
DEV_STREET_NAME = 'W GIRARD AVE'

# Logging stuff.
address_errors = []
Expand Down Expand Up @@ -378,7 +378,6 @@ def main():
del parser_address_tags
address_tag_strings = set()


# spatial parcel id tags from address points:
print("Adding dor_parcel_id tags for address points via spatial join...")
dor_parcel_id_tag_stmt = '''
Expand Down Expand Up @@ -452,7 +451,7 @@ def main():

# # Include address with unit_type in 'has_base' link set
if address.unit_type is not None:
# if address.unit_type is not None or address.address_low_suffix is not None:
# if address.unit_type is not None or address.address_low_suffix is not None:
# Base link
base_link = {
'address_1': address.street_address,
Expand Down Expand Up @@ -618,11 +617,9 @@ def main():

print('** ADDRESS-STREETS **')


class ContinueIteration(Exception):
pass


def had_street_warning(street_address, reason, notes=None):
'''
Convenience function to log street warnings as they happen.
Expand All @@ -635,7 +632,6 @@ def had_street_warning(street_address, reason, notes=None):
}
address_warnings.append(warning)


def had_street_error(street_address, reason, notes=None):
'''
This is a wrapper around had_street_warning that raises an error.
Expand All @@ -646,7 +642,6 @@ def had_street_error(street_address, reason, notes=None):
had_street_warning(street_address, reason, notes=notes)
raise ContinueIteration


# START WORK
if WRITE_OUT:
print('Deleting existing address-streets...')
Expand All @@ -662,7 +657,9 @@ def had_street_error(street_address, reason, notes=None):
'right_to'
]
seg_map = {}
seg_rows = street_segment_table.read(fields=seg_fields)
seg_rows = street_segment_table.read(
fields=seg_fields, sort=["STREET_FULL", "LEFT_FROM", "RIGHT_FROM"]
)
for seg_row in seg_rows:
street_full = seg_row['street_full']
street_full_segs = seg_map.setdefault(street_full, [])
Expand Down Expand Up @@ -926,7 +923,7 @@ def had_street_error(street_address, reason, notes=None):
parcel_address = Address(street_address)
except ValueError:
# TODO: this should never happen
#print('Could not parse parcel address: {}'.format(street_address))
# print('Could not parse parcel address: {}'.format(street_address))
continue

street_full = parcel_address.street_full
Expand Down

0 comments on commit f1e043c

Please sign in to comment.