GTFS-Dense is a fast, binary serialization format for static public transit data (GTFS).
The goal of GTFS-Dense is to enable quick, offline loading of an entire GTFS network on memory-constrained devices like mobile phones and web browsers, eliminating the need to parse large text files.
GTFS-Dense uses Protocol Buffers (PBF) as its underlying encoding format. A converter tool reads a standard GTFS feed, resolves all relational links (e.g., connecting a trip to its stop times and shape), and writes the data into a nested, graph-like structure.
proto/- The Protocol Buffers schema.src/gtfsdense/- The main Python package.converter.py- The script to convert GTFS to GTFS-Dense.gtfs_dense_pb2.py- The generated Python code from the schema.
gtfs-dense-rust/- The Rust library for parsing GTFS-Dense.pyproject.toml- The Python project definition file.
To convert a GTFS .zip file to a .gtfsd file, use the converter script:
python -m src.gtfsdense.converter --input /path/to/your/gtfs.zip --output /path/to/your/output.gtfsdThis project uses setuptools for packaging and protoc for generating the protobuf code.
-
Install dependencies:
pip install -e . -
Modify the schema:
Edit
proto/gtfs-dense.proto. -
Regenerate the protobuf code:
protoc --python_out=src --proto_path=proto proto/gtfs-dense.proto
-
Build the library:
cd gtfs-dense-rust cargo build -
Run the example:
cargo run --example print_feed -- <path/to/your.gtfsd>