diff --git a/templates/trip_page.html b/templates/trip_page.html
index 13a6c88..1b8f2e0 100644
--- a/templates/trip_page.html
+++ b/templates/trip_page.html
@@ -93,6 +93,7 @@
{% endif %}
{% endblock %}
diff --git a/web_view.py b/web_view.py
index c771b0a..d53d433 100755
--- a/web_view.py
+++ b/web_view.py
@@ -296,6 +296,31 @@ def collect_trip_coordinates(trip: Trip) -> list[StrDict]:
]
+def latlon_tuple(stop: StrDict) -> tuple[float, float]:
+ """Given a transport stop return the lat/lon as a tuple."""
+ return (stop["latitude"], stop["longitude"])
+
+
+def get_trip_routes(
+ trip: Trip,
+) -> list[tuple[tuple[float, float], tuple[float, float]]]:
+ routes = []
+ for t in trip.travel:
+ if t["type"] == "flight":
+ if "from_airport" not in t or "to_airport" not in t:
+ continue
+ fly_from, fly_to = t["from_airport"], t["to_airport"]
+ routes.append((latlon_tuple(fly_from), latlon_tuple(fly_to)))
+
+ else:
+ assert t["type"] == "train"
+ for leg in t["legs"]:
+ train_from, train_to = leg["from_station"], leg["to_station"]
+ routes.append((latlon_tuple(train_from), latlon_tuple(train_to)))
+
+ return routes
+
+
@app.route("/trip/")
def trip_page(start: str) -> str:
"""Individual trip page."""
@@ -308,12 +333,14 @@ def trip_page(start: str) -> str:
flask.abort(404)
coordinates = collect_trip_coordinates(trip)
+ routes = get_trip_routes(trip)
return flask.render_template(
"trip_page.html",
trip=trip,
today=today,
coordinates=coordinates,
+ routes=routes,
get_country=agenda.get_country,
format_list_with_ampersand=format_list_with_ampersand,
)