From c65e60a1f13845df14364953170a4c19333d9beb Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 5 May 2024 14:57:13 +0300 Subject: [PATCH] Include ferry distances --- agenda/trip.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/agenda/trip.py b/agenda/trip.py index e8f542f..3bdf492 100644 --- a/agenda/trip.py +++ b/agenda/trip.py @@ -58,7 +58,9 @@ def load_trains( return trains -def load_ferries(data_dir: str) -> list[StrDict]: +def load_ferries( + data_dir: str, route_distances: travel.RouteDistances | None = None +) -> list[StrDict]: """Load ferries.""" ferries = load_travel("ferry", "ferries", data_dir) terminals = travel.parse_yaml("ferry_terminals", data_dir) @@ -70,6 +72,9 @@ def load_ferries(data_dir: str) -> list[StrDict]: item["from_terminal"] = from_terminal item["to_terminal"] = to_terminal + if route_distances: + travel.add_leg_route_distance(item, route_distances) + geojson = from_terminal["routes"].get(item["to"]) if geojson: item["geojson_filename"] = geojson @@ -131,7 +136,7 @@ def build_trip_list( travel_items = sorted( load_flights(data_dir) + load_trains(data_dir, route_distances=route_distances) - + load_ferries(data_dir), + + load_ferries(data_dir, route_distances=route_distances), key=depart_datetime, )