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:
parent
57f477c54d
commit
482fff689b
5 changed files with 116 additions and 89 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue