parameterize routing logic - extract api key as env var; allow searching dest by address; limit the number of listings to process to prevent accidental api key usage

This commit is contained in:
Viktor Barzin 2025-05-18 21:13:50 +00:00
parent 57f477c54d
commit 482fff689b
No known key found for this signature in database
GPG key ID: 4056458DBDBF8863
5 changed files with 116 additions and 89 deletions

View file

@ -166,14 +166,18 @@ class Listing:
return max_sqm
def calculate_route(self,
dest_lat: float,
dest_lon: float,
dest_address: str,
travel_mode: routing.TravelMode,
recalculate=False):
if self.path_routing_json().exists() and not recalculate:
return
result = routing.transit_route(self.latitude, self.longitude, dest_lat,
dest_lon)
result = routing.transit_route(
self.latitude,
self.longitude,
dest_address,
travel_mode,
)
with open(self.path_routing_json(), "w") as f:
json.dump(result, f)