Skip to content

Commit

Permalink
Update geocoder_api.py
Browse files Browse the repository at this point in the history
Upgrade the geocoding functionality in the GeocoderApi class to accommodate scenarios where only partial address information, such as city and postcode, is available. Currently, the address_with_details method raises errors when incomplete address details are provided. As most of the companies are from scrapped data or hubspot and full address is not available, we can't create new companies in the DirectoryCompany table.
  • Loading branch information
antosomzi authored May 6, 2024
1 parent 16b9261 commit 4e8532e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions herepy/geocoder_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def address_with_boundingbox(

def address_with_details(
self,
house_number: int,
street: str,
house_number: Optional[int] = None,
street: Optional[str] = None,
city: str,
country: str,
lang: str = "en-US",
Expand All @@ -129,11 +129,16 @@ def address_with_details(
Raises:
HEREError"""

qq_query = ""
if house_number is not None:
qq_query += f"houseNumber={house_number};"
if street is not None:
qq_query += f"street={street};"
qq_query += f"city={city};"
qq_query += f"country={country}"

data = {
"qq": str.format("houseNumber={0};", house_number)
+ str.format("street={0};", street)
+ str.format("city={0};", city)
+ str.format("country={0}", country),
"qq": qq_query,
"apiKey": self._api_key,
"lang": lang,
}
Expand Down

0 comments on commit 4e8532e

Please sign in to comment.