This commit is contained in:
+7
-6
@@ -1,8 +1,8 @@
|
||||
"""Load the checked-in Austrian stop snapshot into the ``stops`` table.
|
||||
"""Load the checked-in DACH stop snapshot into the ``stops`` table.
|
||||
|
||||
The snapshot (data/stops_at.csv.gz) is produced by scripts/fetch_stops.py from
|
||||
OpenStreetMap data (© OpenStreetMap contributors, ODbL). Importing needs no
|
||||
network access.
|
||||
The snapshot (data/stops_dach.csv.gz) is produced by scripts/fetch_stops.py
|
||||
from OpenStreetMap data (© OpenStreetMap contributors, ODbL) for Austria,
|
||||
Germany and Switzerland. Importing needs no network access.
|
||||
|
||||
flask import-stops # import the checked-in snapshot
|
||||
flask import-stops --file X # import an alternative CSV(.gz)
|
||||
@@ -21,7 +21,7 @@ from flask.cli import with_appcontext
|
||||
|
||||
from models import Stop, Trip, db
|
||||
|
||||
SNAPSHOT_PATH = Path(__file__).resolve().parent / "data" / "stops_at.csv.gz"
|
||||
SNAPSHOT_PATH = Path(__file__).resolve().parent / "data" / "stops_dach.csv.gz"
|
||||
|
||||
|
||||
def normalize_name(value: str) -> str:
|
||||
@@ -69,6 +69,7 @@ def import_stops(path: Path | str = SNAPSHOT_PATH) -> dict[str, int]:
|
||||
name=name,
|
||||
name_normalized=normalize_name(name),
|
||||
stop_type=row["stop_type"] or "other",
|
||||
country=(row.get("country") or "AT").strip().upper(),
|
||||
municipality=(row.get("municipality") or "").strip() or None,
|
||||
latitude=float(row["latitude"]),
|
||||
longitude=float(row["longitude"]),
|
||||
@@ -120,7 +121,7 @@ def import_stops(path: Path | str = SNAPSHOT_PATH) -> dict[str, int]:
|
||||
)
|
||||
@with_appcontext
|
||||
def import_stops_command(file_path: str | None) -> None:
|
||||
"""Import Austrian public-transport stops into the database."""
|
||||
"""Import DACH public-transport stops into the database."""
|
||||
stats = import_stops(file_path or SNAPSHOT_PATH)
|
||||
click.echo(
|
||||
"Stops imported: "
|
||||
|
||||
Reference in New Issue
Block a user