44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
from data_access import Listing
|
|
from tqdm import tqdm
|
|
from rec import routing
|
|
|
|
|
|
def calculate_route(
|
|
listing_paths: list[str],
|
|
destination_address: str,
|
|
travel_mode: routing.TravelMode,
|
|
):
|
|
|
|
listings = Listing.get_all_listings(listing_paths)
|
|
|
|
# reduce listings to everything within 7 miles
|
|
filtered_listings = []
|
|
for listing in listings:
|
|
if listing.isRemoved:
|
|
print(f"Removed-Skip: Skipping {listing.identifier} "
|
|
"is already removed.")
|
|
continue
|
|
if listing.path_routing_json().exists():
|
|
print(f"Path-Skip: Skipping {listing.identifier} as path routing "
|
|
"already exists")
|
|
continue
|
|
if (listing.sqm_ocr is None or listing.sqm_ocr < 30
|
|
or listing.sqm_ocr > 200):
|
|
print((f"Floorplan-Skip: Skipping {listing.identifier} as "
|
|
f"sqm_ocr is {listing.sqm_ocr}"))
|
|
continue
|
|
filtered_listings.append(listing)
|
|
|
|
print(
|
|
f"Filtered listings from {len(listings)} to {len(filtered_listings)}")
|
|
|
|
for listing in tqdm(filtered_listings):
|
|
listing.calculate_route(
|
|
destination_address,
|
|
travel_mode,
|
|
recalculate=False,
|
|
)
|
|
traveltime = listing.travel_time[0]
|
|
duration_minutes = traveltime["duration"] / 60.0
|
|
|
|
tqdm.write(f"{listing.identifier} {duration_minutes}")
|