Show map of past trips

This commit is contained in:
Edward Betts 2024-01-14 12:17:22 +00:00
parent bd61b1bccd
commit 36b5d38274
4 changed files with 43 additions and 26 deletions

View file

@ -182,3 +182,31 @@ def get_trip_routes(trip: Trip) -> list[StrDict]:
)
return routes
def get_coordinates_and_routes(
trip_list: list[Trip],
) -> tuple[list[StrDict], list[StrDict]]:
coordinates = []
seen_coordinates: set[tuple[str, str]] = set()
routes = []
seen_routes: set[str] = set()
for trip in trip_list:
for stop in collect_trip_coordinates(trip):
key = (stop["type"], stop["name"])
if key in seen_coordinates:
continue
coordinates.append(stop)
seen_coordinates.add(key)
for route in get_trip_routes(trip):
if route["key"] in seen_routes:
continue
routes.append(route)
seen_routes.add(route["key"])
for route in routes:
if "geojson_filename" in route:
route["geojson"] = read_geojson(route.pop("geojson_filename"))
return (coordinates, routes)