Show bus stops and coach stations on trip map.

Add case "bus" to get_locations() and bus route handling to
get_trip_routes() in trip.py. Coach stations now populate a dedicated
"coach_station" dict instead of the train station list. Add
"coach_station" (🚌) and "bus_stop" (🚏) emoji types to map.js.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-02-18 12:13:42 +00:00
parent 363967b739
commit c87320415f
2 changed files with 29 additions and 1 deletions

View file

@ -315,6 +315,8 @@ def get_locations(trip: Trip) -> dict[str, StrDict]:
"station": {}, "station": {},
"airport": {}, "airport": {},
"ferry_terminal": {}, "ferry_terminal": {},
"coach_station": {},
"bus_stop": {},
} }
station_list = [] station_list = []
@ -323,7 +325,13 @@ def get_locations(trip: Trip) -> dict[str, StrDict]:
case "train": case "train":
station_list += stations_from_travel(t) station_list += stations_from_travel(t)
case "coach": 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": case "flight":
for field in "from_airport", "to_airport": for field in "from_airport", "to_airport":
if field in t: if field in t:
@ -445,6 +453,24 @@ def get_trip_routes(trip: Trip, data_dir: str) -> list[StrDict]:
} }
) )
continue 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": if t["type"] == "train":
for leg in t["legs"]: for leg in t["legs"]:
train_from, train_to = leg["from_station"], leg["to_station"] train_from, train_to = leg["from_station"], leg["to_station"]

View file

@ -6,6 +6,8 @@ var emojiByType = {
"station": "🚉", "station": "🚉",
"airport": "✈️", "airport": "✈️",
"ferry_terminal": "🚢", "ferry_terminal": "🚢",
"coach_station": "🚌",
"bus_stop": "🚏",
"accommodation": "🏨", "accommodation": "🏨",
"conference": "🖥️", "conference": "🖥️",
"event": "🍷" "event": "🍷"