Show ferry routes and terminals on the map
This commit is contained in:
parent
b9b849802d
commit
afa2a2e934
|
@ -66,8 +66,13 @@ def load_ferries(data_dir: str) -> list[StrDict]:
|
|||
|
||||
for item in ferries:
|
||||
assert item["from"] in by_name and item["to"] in by_name
|
||||
item["from_terminal"] = by_name[item["from"]]
|
||||
item["to_terminal"] = by_name[item["to"]]
|
||||
from_terminal, to_terminal = by_name[item["from"]], by_name[item["to"]]
|
||||
item["from_terminal"] = from_terminal
|
||||
item["to_terminal"] = to_terminal
|
||||
|
||||
geojson = from_terminal["routes"].get(item["to"])
|
||||
if geojson:
|
||||
item["geojson_filename"] = geojson
|
||||
|
||||
return ferries
|
||||
|
||||
|
@ -229,7 +234,7 @@ def collect_trip_coordinates(trip: Trip) -> list[StrDict]:
|
|||
locations = [
|
||||
("station", stations),
|
||||
("airport", airports),
|
||||
("ferry_terminals", ferry_terminals),
|
||||
("ferry_terminal", ferry_terminals),
|
||||
]
|
||||
for coord_type, coord_dict in locations:
|
||||
coords += [
|
||||
|
@ -252,7 +257,7 @@ def latlon_tuple(stop: StrDict) -> tuple[float, float]:
|
|||
|
||||
def read_geojson(data_dir: str, filename: str) -> str:
|
||||
"""Read GeoJSON from file."""
|
||||
return open(os.path.join(data_dir, "train_routes", filename + ".geojson")).read()
|
||||
return open(os.path.join(data_dir, filename + ".geojson")).read()
|
||||
|
||||
|
||||
def get_trip_routes(trip: Trip) -> list[StrDict]:
|
||||
|
@ -261,6 +266,18 @@ def get_trip_routes(trip: Trip) -> list[StrDict]:
|
|||
seen_geojson = set()
|
||||
for t in trip.travel:
|
||||
if t["type"] == "ferry":
|
||||
ferry_from, ferry_to = t["from_terminal"], t["to_terminal"]
|
||||
|
||||
key = "_".join(["ferry"] + sorted([ferry_from["name"], ferry_to["name"]]))
|
||||
filename = os.path.join("ferry_routes", t["geojson_filename"])
|
||||
|
||||
routes.append(
|
||||
{
|
||||
"type": "train",
|
||||
"key": key,
|
||||
"geojson_filename": filename,
|
||||
}
|
||||
)
|
||||
continue
|
||||
if t["type"] == "flight":
|
||||
if "from_airport" not in t or "to_airport" not in t:
|
||||
|
@ -300,7 +317,7 @@ def get_trip_routes(trip: Trip) -> list[StrDict]:
|
|||
{
|
||||
"type": "train",
|
||||
"key": key,
|
||||
"geojson_filename": geojson_filename,
|
||||
"geojson_filename": os.path.join("train_routes", geojson_filename),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ function emoji_icon(emoji) {
|
|||
var icons = {
|
||||
"station": emoji_icon("🚉"),
|
||||
"airport": emoji_icon("✈️"),
|
||||
"ferry_terminal": emoji_icon("✈️"),
|
||||
"accommodation": emoji_icon("🏨"),
|
||||
"conference": emoji_icon("🎤"),
|
||||
"event": emoji_icon("🍷"),
|
||||
|
|
Loading…
Reference in a new issue