Skip to content

Commit

Permalink
Update geocoder.py
Browse files Browse the repository at this point in the history
  • Loading branch information
michplunkett committed Feb 17, 2024
1 parent 3cbdc6b commit 1417ba3
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions incident_scraper/external/geocoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
)


ORDINAL_STREET_REGEX = r"E\. \d{2}[a-z]{2} St."


class Geocoder:
"""
A class that houses code for both the Census and Google Maps geocoders.
Expand Down Expand Up @@ -57,9 +54,7 @@ def get_address_information(self, address: str, i_dict: dict) -> bool:
)

if INCIDENT_KEY_ADDRESS not in i_dict:
self._get_address_from_cache(
i_dict, self._google_validate_address(address)
)
self._parse_and_process_address(address)

# Return if an address was found.
return INCIDENT_KEY_ADDRESS in i_dict
Expand All @@ -80,7 +75,7 @@ def _parse_and_process_address(self, address: str) -> dict:
if self._cannot_geocode(address, and_cnt):
logging.info(f"Unable to process and geocode address: {address}")
self.address_cache[address] = self.NON_FINDABLE_ADDRESS_DICT
elif "between " in address.lower():
elif " between " in address_lower:
self._parse_between_addresses(address)
elif and_cnt == 1 or " at " in address_lower:
self._process_at_and_addresses(address)
Expand All @@ -90,14 +85,13 @@ def _parse_and_process_address(self, address: str) -> dict:

return self.address_cache[address]

def _parse_between_addresses(self, address: str) -> None:
def _parse_between_addresses(self, address: str) -> dict:
pass

def _process_at_and_addresses(self, address: str) -> None:
def _process_at_and_addresses(self, address: str) -> dict:
formatted_addr = self.address_parser.process_at_and_streets(address)
# search, save, and return

return formatted_addr
return self._google_validate_address(formatted_addr)

def _census_validate_address(self, address: str) -> dict:
"""Get address from Census geocoder.
Expand Down

0 comments on commit 1417ba3

Please sign in to comment.