From 39f9c98a51217b205807d7d50094e34bd36d1946 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 16 Jan 2024 17:07:59 +0000 Subject: [PATCH] Include heathrow airport pin on map for conference without booked flights Closes: #115 --- web_view.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/web_view.py b/web_view.py index 6c21472..4efd49c 100755 --- a/web_view.py +++ b/web_view.py @@ -7,6 +7,7 @@ import operator import os.path import sys import traceback +import typing from datetime import date, datetime, timedelta import flask @@ -20,6 +21,7 @@ import agenda.holidays import agenda.thespacedevs import agenda.trip from agenda import format_list_with_ampersand, travel +from agenda.types import StrDict app = flask.Flask(__name__) app.debug = False @@ -217,6 +219,7 @@ def trip_page(start: str) -> str: """Individual trip page.""" trip_iter = iter(agenda.trip.build_trip_list()) today = date.today() + data_dir = flask.current_app.config["PERSONAL_DATA"] prev_trip = None for trip in trip_iter: @@ -230,6 +233,22 @@ def trip_page(start: str) -> str: coordinates = agenda.trip.collect_trip_coordinates(trip) routes = agenda.trip.get_trip_routes(trip) + if any(route["type"] == "flight" for route in routes) and not any( + pin["type"] == "airport" for pin in coordinates + ): + airports = typing.cast( + dict[str, StrDict], travel.parse_yaml("airports", data_dir) + ) + lhr = airports["LHR"] + coordinates.append( + { + "name": lhr["name"], + "type": "airport", + "latitude": lhr["latitude"], + "longitude": lhr["longitude"], + } + ) + for route in routes: if "geojson_filename" in route: route["geojson"] = agenda.trip.read_geojson(route.pop("geojson_filename"))