Skip to content

Commit

Permalink
fix: clean up and add city/county to standardized address
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Dec 18, 2024
1 parent 4a552c4 commit b8655b9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/masquerade/providers/web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ def get_candidate_from_single_line(single_line_address, out_spatial_reference):
def etl_candidate(ugrc_candidate: dict, spatial_reference: int) -> dict:
"""translates an UGRC Web API candidate to an Esri locator candidate"""
address = ugrc_candidate["address"] if "address" in ugrc_candidate else ugrc_candidate["matchAddress"]
try:
standardized_address = ugrc_candidate["standardizedAddress"]
except KeyError:
standardized_address = None

match_city = address.split(",")[-1].strip()
city_or_county = open_sgid.get_city(
Expand All @@ -175,6 +171,14 @@ def etl_candidate(ugrc_candidate: dict, spatial_reference: int) -> dict:
if city_or_county and match_city.upper() != city_or_county.upper():
address = address.replace(match_city, city_or_county.upper())

try:
web_api_standardized_address = ugrc_candidate["standardizedAddress"]
standardized_address = (
f"{' '.join([part.title() for part in web_api_standardized_address.split(' ')])}, {city_or_county}"
)
except KeyError:
standardized_address = None

return {
"address": address,
"attributes": {
Expand Down

0 comments on commit b8655b9

Please sign in to comment.