Not all stations have UIC, use name instead

This commit is contained in:
Edward Betts 2024-10-31 11:29:08 +01:00
parent eaa6369dc9
commit 3c3939c525

View file

@ -237,9 +237,9 @@ def get_locations(trip: Trip) -> dict[str, StrDict]:
locations["ferry_terminal"][terminal["name"]] = terminal locations["ferry_terminal"][terminal["name"]] = terminal
for s in station_list: for s in station_list:
if s["uic"] in locations["station"]: if s["name"] in locations["station"]:
continue continue
locations["station"][s["uic"]] = s locations["station"][s["name"]] = s
return locations return locations
@ -336,7 +336,7 @@ def get_trip_routes(trip: Trip, data_dir: str) -> list[StrDict]:
assert t["type"] == "train" assert 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"]
geojson_filename = train_from.get("routes", {}).get(train_to["uic"]) geojson_filename = train_from.get("routes", {}).get(train_to["name"])
key = "_".join(["train"] + sorted([train_from["name"], train_to["name"]])) key = "_".join(["train"] + sorted([train_from["name"], train_to["name"]]))
if not geojson_filename: if not geojson_filename:
routes.append( routes.append(