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 abea1ad commit 3607879
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions incident_scraper/external/geocoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from censusgeocode import CensusGeocode
from googlemaps import Client

from incident_scraper.models.address_parser import AddressParser
from incident_scraper.utils.constants import (
ENV_GOOGLE_MAPS_KEY,
INCIDENT_KEY_ADDRESS,
Expand Down Expand Up @@ -36,6 +37,7 @@ class Geocoder:

def __init__(self):
self.address_cache = {}
self.address_parser = AddressParser()
self.census_client = CensusGeocode()
self.google_client = Client(ENV_GOOGLE_MAPS_KEY)

Expand Down Expand Up @@ -64,7 +66,12 @@ def get_address_information(self, address: str, i_dict: dict) -> bool:

@staticmethod
def _cannot_geocode(address: str, and_cnt: [str]) -> bool:
return " to " in address or " or " in address or and_cnt > 1
return (
" to " in address
or " or " in address
or "Out of Area" in address
or and_cnt > 1
)

def _parse_and_process_address(self, address: str) -> dict:
address_lower = address.lower()
Expand All @@ -87,7 +94,10 @@ def _parse_between_addresses(self, address: str) -> None:
pass

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

return formatted_addr

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

0 comments on commit 3607879

Please sign in to comment.