Filter: Verweise auf nicht kopierte Streckenverläufe leeren (OVapi-Fahrpläne)

Sonst bricht pfaedle mit 'no shape with id' ab.

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 07:33:18 +02:00
parent 7ece7603a9
commit deaa6aa9cd
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -62,6 +62,9 @@ def make_feed(tmp: Path, shapes=True, files=FILES) -> Feed:
assert meta["feed_version"] == ("20261017" if files is FILES else "20261020"), meta assert meta["feed_version"] == ("20261017" if files is FILES else "20261020"), meta
assert meta["trips"] == 1 and meta["stop_times"] == 3, meta assert meta["trips"] == 1 and meta["stop_times"] == 3, meta
if shapes: if shapes:
trips = (tmp / "rail" / "trips.txt").read_text()
assert "SH1" not in trips # Verweise auf nicht kopierte shapes werden geleert
(tmp / "rail" / "trips.txt").write_text(trips.replace("812,", "812,SH1")) # wie pfaedle
(tmp / "rail" / "shapes.txt").write_text(SHAPE) (tmp / "rail" / "shapes.txt").write_text(SHAPE)
prepare.pack_shapes(tmp / "rail") prepare.pack_shapes(tmp / "rail")
assert not (tmp / "rail" / "shapes.txt").exists() assert not (tmp / "rail" / "shapes.txt").exists()
+3
View File
@@ -137,6 +137,9 @@ def filter_rail(zip_path: Path, out: Path, version: str | None = None) -> dict:
h, rd = rows(z, "trips.txt") h, rd = rows(z, "trips.txt")
trips = [r for r in rd if r[h.index("route_id")] in route_ids] trips = [r for r in rd if r[h.index("route_id")] in route_ids]
if "shape_id" in h: # shapes.txt kopieren wir nicht (pfaedle rechnet neu) -> Verweise leeren (z. B. OVapi)
for r in trips:
r[h.index("shape_id")] = ""
write_csv(out / "trips.txt", h, trips) write_csv(out / "trips.txt", h, trips)
trip_ids = {r[h.index("trip_id")] for r in trips} trip_ids = {r[h.index("trip_id")] for r in trips}
service_ids = {r[h.index("service_id")] for r in trips} service_ids = {r[h.index("service_id")] for r in trips}