parent
4a990a9fe5
commit
fd34190368
3 changed files with 123 additions and 22 deletions
27
web_view.py
27
web_view.py
|
|
@ -170,11 +170,35 @@ def trip_list() -> str:
|
|||
past = [item for item in trip_list if (item.end or item.start) < today]
|
||||
future = [item for item in trip_list if item.start > today]
|
||||
|
||||
future_coordinates = []
|
||||
seen_future_coordinates: set[tuple[str, str]] = set()
|
||||
future_routes = []
|
||||
seen_future_routes: set[str] = set()
|
||||
for trip in future:
|
||||
for stop in agenda.trip.collect_trip_coordinates(trip):
|
||||
key = (stop["type"], stop["name"])
|
||||
if key in seen_future_coordinates:
|
||||
continue
|
||||
future_coordinates.append(stop)
|
||||
seen_future_coordinates.add(key)
|
||||
|
||||
for route in agenda.trip.get_trip_routes(trip):
|
||||
if route["key"] in seen_future_routes:
|
||||
continue
|
||||
future_routes.append(route)
|
||||
seen_future_routes.add(route["key"])
|
||||
|
||||
for route in future_routes:
|
||||
if "geojson_filename" in route:
|
||||
route["geojson"] = agenda.trip.read_geojson(route.pop("geojson_filename"))
|
||||
|
||||
return flask.render_template(
|
||||
"trips.html",
|
||||
current=current,
|
||||
past=past,
|
||||
future=future,
|
||||
future_coordinates=future_coordinates,
|
||||
future_routes=future_routes,
|
||||
today=today,
|
||||
get_country=agenda.get_country,
|
||||
format_list_with_ampersand=format_list_with_ampersand,
|
||||
|
|
@ -194,6 +218,9 @@ def trip_page(start: str) -> str:
|
|||
|
||||
coordinates = agenda.trip.collect_trip_coordinates(trip)
|
||||
routes = agenda.trip.get_trip_routes(trip)
|
||||
for route in routes:
|
||||
if "geojson_filename" in route:
|
||||
route["geojson"] = agenda.trip.read_geojson(route.pop("geojson_filename"))
|
||||
|
||||
return flask.render_template(
|
||||
"trip_page.html",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue