feat: add logging and string representation

This commit is contained in:
moanos [he/him] 2025-01-07 15:04:43 +01:00
parent 74f54c7b31
commit 7c076e0bc3

View File

@ -123,12 +123,14 @@ class GeoAPI:
def get_geojson_for_query(self, location_string):
try:
if self.api_format == 'nominatim':
logging.info(f"Querying nominatim instance for: {location_string} ({self.api_url})")
result = self.requests.get(self.api_url,
{"q": location_string,
"format": "jsonv2"},
headers=self.headers).json()
geofeatures = GeoFeature.geofeatures_from_nominatim_result(result)
elif self.api_format == 'photon':
logging.info(f"Querying photon instance for: {location_string} ({self.api_url})")
result = self.requests.get(self.api_url,
{"q": location_string},
headers=self.headers).json()
@ -167,6 +169,9 @@ class LocationProxy:
def __eq__(self, other):
return self.place_id == other.place_id
def __str__(self):
return self.name
@property
def position(self):
return (self.latitude, self.longitude)