Filter: alle / Nahverkehr / Fernverkehr

Einteilung nach Gattung (Schweiz: route_desc, Deutschland: Präfix der
Linie): ICE, IC, EC, ECE, EN, NJ, RJ(X), TGV, IR, … = Fernverkehr.
Auswahl bleibt im Browser gespeichert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X48pE4bzjHej8w9HyZXCjb
This commit is contained in:
Claude
2026-10-22 06:01:38 +02:00
parent 085a129a85
commit 8865e7abcf
5 changed files with 41 additions and 2 deletions
+15 -1
View File
@@ -5,6 +5,7 @@ import datetime as dt
import json
import math
import mmap
import re
from array import array
from bisect import bisect_right
from pathlib import Path
@@ -57,6 +58,17 @@ def travelled(length: float, duration: float, t: float) -> float:
return 0.5 * a * ta * ta + vmax * (t - ta)
# Gattungen des Fernverkehrs; alles andere (RE, RB, S, R, TER, …) gilt als Nahverkehr
LONG_DISTANCE = {"ICE", "IC", "ICN", "EC", "ECE", "ECM", "EN", "NJ", "RJ", "RJX", "TGV", "THA", "EST", "FLX",
"IR", "PE", "D"}
def long_distance(cat: str, line: str) -> bool:
# Schweiz: Gattung in route_desc; gtfs.de: nur in der Linie ("ICE 75", "IC 3")
m = re.match(r"[A-Za-z]+", cat or line or "")
return bool(m) and m.group(0).upper() in LONG_DISTANCE
class Feed:
def __init__(self, path: Path, today: dt.date | None = None):
self.path = path
@@ -79,6 +91,8 @@ class Feed:
"cat": r[h["route_desc"]] if "route_desc" in h else "",
"agency": agencies.get(r[h["agency_id"]], "") if "agency_id" in h else "",
}
route = self.routes[r[h["route_id"]]]
route["fv"] = long_distance(route["cat"], route["line"])
self.trip_index, self.trip_ids, self.trip_route, self.trip_service = {}, [], [], []
self.trip_headsign, self.trip_number, self.trip_shape = [], [], []
@@ -274,7 +288,7 @@ class Feed:
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [lon, lat]},
"properties": {
"id": f"{dstr}/{ti}", "line": route["line"], "cat": route["cat"],
"id": f"{dstr}/{ti}", "line": route["line"], "cat": route["cat"], "fv": route["fv"],
"nr": self.trip_number[ti], "to": self.trip_headsign[ti],
"delay": delay if r else None, "next": self.stop_name[self.st_stop[o + i]],
"heading": heading,