- pyproject.toml with all deps (geopandas, contextily, partridge, etc.)
- config/: area.json (3 OSM boundary relations), modes.yaml (subway/s_tog/
light_rail/regional/bus, S-tog scoped to route=light_rail network=Takst),
styling.yaml (zorder/widths/colours/palette/mask/labels)
- build_area.py: fetch 3 relations via OSM API, stitch rings, dissolve to
area.gpkg/area.geojson (City Pass approximation)
- download_osm.py: per-mode Overpass (mirror+backoff, out geom + recurse for
stops), writes {mode}.gpkg (lines+stops) + query text
- download_gtfs.py / gtfs_to_geopackage.py: stubs (blocked on Rejseplanen)
- data/ gitignored (regenerable); output/ tracked
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Download the Rejseplanen GTFS feed for the Copenhagen area.
|
|
|
|
STATUS: BLOCKED. Rejseplanen (journey planner) does not currently expose a
|
|
public GTFS download. This script documents the intended flow and exits
|
|
non-zero with guidance.
|
|
|
|
When a feed URL becomes available, set it here and the script will download
|
|
and unzip into data/raw/gtfs/.
|
|
"""
|
|
import sys
|
|
import urllib.request
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
from _common import GTFS_RAW
|
|
|
|
# Fill in once access is granted. Likely candidates:
|
|
# - Rejseplanen / DOT open-data portal
|
|
# - a static GTFS zip provided on request
|
|
GTFS_URL = None # e.g. "https://.../rejseplanen.zip"
|
|
|
|
|
|
def main():
|
|
if not GTFS_URL:
|
|
print(
|
|
"download_gtfs: BLOCKED — no GTFS feed URL configured.\n"
|
|
"Set GTFS_URL in this script once Rejseplanen grants access, then re-run.\n"
|
|
"The OSM-only pipeline (build_area -> download_osm -> prepare -> render)\n"
|
|
"is fully functional without GTFS; GTFS only enriches colours/stops.",
|
|
file=sys.stderr,
|
|
)
|
|
sys.exit(2)
|
|
GTFS_RAW.mkdir(parents=True, exist_ok=True)
|
|
zip_path = GTFS_RAW / "feed.zip"
|
|
print(f"downloading {GTFS_URL} -> {zip_path} ...", flush=True)
|
|
urllib.request.urlretrieve(GTFS_URL, zip_path)
|
|
with zipfile.ZipFile(zip_path) as z:
|
|
z.extractall(GTFS_RAW)
|
|
zip_path.unlink(missing_ok=True)
|
|
print(f"extracted GTFS txt files into {GTFS_RAW}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|