This is a Python-based test harness which can be used to simulate a GTFS-realtime feed with trips on a frequency-based route. Specifically, it simulates arrivals on the AirBART route (obtain BART GTFS here), at the AirBART_OAK stop. For convenience, the script simulates two vehicles, which are perpetually three and seven minutes away, respectively.
- Install the Google Protocol Buffers library, including Python bindings. On Ubuntu, this can be done with
sudo apt-get install libprotobuf-dev libprotobuf7
. - Get
gtfs_realtime.proto
fromhttps://developers.google.com/transit/gtfs-realtime/gtfs-realtime.proto
and place it in the same directory asbartTest.py
. - Generate the Python GTFS-realtime bindings by running
protoc --python_out=. gtfs-realtime.proto
. - Install the remaining Python dependencies with
pip install flask
.
Run the script with python bartTest.py
. The generated feed is available at http://localhost:5000/feed
, and the text debug output is available at http://localhost:5000/debug
. Note that the test configuration is sensitive to the time of day and day of week—AirBART does not run all day long, and the Sunday service has a different trip ID from the Monday-Saturday service.
For Monday-Saturday service between 6 AM and midnight San Francisco time, the trip ID is M-FSAT2UP
, while for Sunday service between 8 AM and midnight, the trip ID is SUN1UP
. Of course, the times in frequencies.txt
could be manually edited to make the feed more useful for testing at all times.