#!/usr/bin/env python3 """Convert raw GTFS txt files into portable GeoPackage layers + a colour table. STATUS: BLOCKED on download_gtfs.py (no feed URL yet). Intended outputs (data/processed): gtfs_shapes.gpkg (shapes.txt -> LineString per shape_id, EPSG:4326) gtfs_stops.gpkg (stops.txt -> Point per stop, EPSG:4326) route_colors.csv (route_id, route_short_name, route_type, route_color) Uses partridge for fast GTFS parsing. prepare.py reads these when present and falls back to OSM-only data when absent. """ import sys from pathlib import Path from _common import GTFS_RAW, PROCESSED def main(): if not (GTFS_RAW / "routes.txt").exists(): print( "gtfs_to_geopackage: BLOCKED — no GTFS data found in " f"{GTFS_RAW}. Run download_gtfs.py first once a feed URL is set.", file=sys.stderr, ) sys.exit(2) # TODO (when GTFS available): # import partridge as pt # import geopandas as gpd # from shapely.geometry import LineString, Point # feed = pt.load_geo_feed(str(GTFS_RAW)) # shapes -> gtfs_shapes.gpkg (LineString per shape_id) # stops -> gtfs_stops.gpkg # routes -> route_colors.csv (route_id, route_short_name, route_type, route_color) print("gtfs_to_geopackage: not yet implemented (GTFS feed unavailable).") sys.exit(2) if __name__ == "__main__": main()