diff --git a/templates/trip_page.html b/templates/trip_page.html index 43b9ed5..0ea5ac5 100644 --- a/templates/trip_page.html +++ b/templates/trip_page.html @@ -5,6 +5,13 @@ {% set row = { "flight": flight_row, "train": train_row } %} {% block style %} + +{% if station_coordinates %} + +{% endif %} + {% set conference_column_count = 6 %} {% set accommodation_column_count = 7 %} {% set travel_column_count = 7 %} @@ -33,6 +40,11 @@ .grid-item { /* Additional styling for grid items can go here */ } + +#map { + height: 400px; +} + {% endblock %} @@ -65,7 +77,36 @@ {% endfor %} - {#
{{ trip | pprint }}#} + {% if station_coordinates %} + + {% endif %} {% endblock %} + +{% block scripts %} + +{% if station_coordinates %} + + + +{% endif %} +{% endblock %} diff --git a/web_view.py b/web_view.py index 1bbfbc9..8bb52ec 100755 --- a/web_view.py +++ b/web_view.py @@ -235,6 +235,26 @@ def trip_list() -> str: ) +def collect_station_coordinates(trip: Trip) -> list[tuple[float, float]]: + """Extract and deduplicate station coordinates from trip.""" + stations = {} + station_list = [] + for t in trip.travel: + if t["type"] != "train": + continue + station_list += [t["from_station"], t["to_station"]] + for leg in t["legs"]: + station_list.append(leg["from_station"]) + station_list.append(leg["to_station"]) + + for s in station_list: + if s["uic"] in stations: + continue + stations[s["uic"]] = s + + return [(s["latitude"], s["longitude"]) for s in stations.values()] + + @app.route("/trip/