Include heathrow airport pin on map for conference without booked flights

Closes: #115
This commit is contained in:
Edward Betts 2024-01-16 17:07:59 +00:00
parent b33da8485c
commit 39f9c98a51

View file

@ -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"))