diff --git a/agenda/trip.py b/agenda/trip.py index 25f4aee..906e475 100644 --- a/agenda/trip.py +++ b/agenda/trip.py @@ -315,6 +315,8 @@ def get_locations(trip: Trip) -> dict[str, StrDict]: "station": {}, "airport": {}, "ferry_terminal": {}, + "coach_station": {}, + "bus_stop": {}, } station_list = [] @@ -323,7 +325,13 @@ def get_locations(trip: Trip) -> dict[str, StrDict]: case "train": station_list += stations_from_travel(t) case "coach": - station_list += [t["from_station"], t["to_station"]] + for field in ("from_station", "to_station"): + s = t[field] + locations["coach_station"][s["name"]] = s + case "bus": + for field in ("from_station", "to_station"): + s = t[field] + locations["bus_stop"][s["name"]] = s case "flight": for field in "from_airport", "to_airport": if field in t: @@ -445,6 +453,24 @@ def get_trip_routes(trip: Trip, data_dir: str) -> list[StrDict]: } ) continue + if t["type"] == "bus": + bus_from, bus_to = t["from_station"], t["to_station"] + key = "_".join(["bus"] + sorted([bus_from["name"], bus_to["name"]])) + if t.get("geojson_filename"): + filename = os.path.join("bus_routes", t["geojson_filename"]) + routes.append( + {"type": "bus", "key": key, "geojson_filename": filename} + ) + else: + routes.append( + { + "type": "bus", + "key": key, + "from": latlon_tuple(bus_from), + "to": latlon_tuple(bus_to), + } + ) + continue if t["type"] == "train": for leg in t["legs"]: train_from, train_to = leg["from_station"], leg["to_station"] diff --git a/static/js/map.js b/static/js/map.js index a150008..a527585 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -6,6 +6,8 @@ var emojiByType = { "station": "🚉", "airport": "✈️", "ferry_terminal": "🚢", + "coach_station": "🚌", + "bus_stop": "🚏", "accommodation": "🏨", "conference": "🖥️", "event": "🍷"