Binary file not shown.
@@ -57,7 +57,8 @@ class Stop(db.Model):
|
|||||||
longitude = db.Column(db.Float, nullable=False)
|
longitude = db.Column(db.Float, nullable=False)
|
||||||
# ";"-joined line refs serving this stop (e.g. "693" or "S2;U4;WLB"), from
|
# ";"-joined line refs serving this stop (e.g. "693" or "S2;U4;WLB"), from
|
||||||
# OSM route relations; empty when unknown. Used by the "Linie" autocomplete.
|
# OSM route relations; empty when unknown. Used by the "Linie" autocomplete.
|
||||||
lines = db.Column(db.String(255), nullable=False, default="")
|
# Text, not String(n): big interchanges (Linz Hbf) exceed a few hundred chars.
|
||||||
|
lines = db.Column(db.Text, nullable=False, default="")
|
||||||
|
|
||||||
def line_list(self) -> list[str]:
|
def line_list(self) -> list[str]:
|
||||||
return [ref for ref in self.lines.split(";") if ref]
|
return [ref for ref in self.lines.split(";") if ref]
|
||||||
|
|||||||
+11
-5
@@ -17,6 +17,7 @@ import csv
|
|||||||
import gzip
|
import gzip
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import unicodedata
|
import unicodedata
|
||||||
@@ -227,12 +228,17 @@ def fetch_route_members() -> tuple[list[tuple[str, int]], dict[int, tuple[str, f
|
|||||||
if el["id"] in seen_rel:
|
if el["id"] in seen_rel:
|
||||||
continue
|
continue
|
||||||
seen_rel.add(el["id"])
|
seen_rel.add(el["id"])
|
||||||
ref = (el.get("tags", {}).get("ref") or "").strip()
|
# A few relations pack several numbers into one ref ("407, 413").
|
||||||
if not ref:
|
refs = [r.strip() for r in re.split(r"[;,]", el["tags"]["ref"]) if r.strip()]
|
||||||
|
if not refs:
|
||||||
continue
|
continue
|
||||||
for m in el.get("members", []):
|
members = [
|
||||||
if m["type"] == "node" and m["role"] in STOP_ROLES:
|
m["ref"] for m in el.get("members", [])
|
||||||
ref_members.append((ref, m["ref"]))
|
if m["type"] == "node" and m["role"] in STOP_ROLES
|
||||||
|
]
|
||||||
|
for ref in refs:
|
||||||
|
for node_id in members:
|
||||||
|
ref_members.append((ref, node_id))
|
||||||
del payload
|
del payload
|
||||||
|
|
||||||
print(f" {len(seen_rel)} routes, {len(ref_members)} stop memberships", file=sys.stderr)
|
print(f" {len(seen_rel)} routes, {len(ref_members)} stop memberships", file=sys.stderr)
|
||||||
|
|||||||
Reference in New Issue
Block a user