Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

On-Demand Transit (GTFS-Flex)

1. Overview

Many transit agencies operate demand-responsive or microtransit services—such as dial-a-ride, curb-to-curb shuttles, or deviated fixed routes—modeled using the GTFS-Flex specification. Instead of fixed stop-to-stop timetables, GTFS-Flex defines polygonal service zones (locations.geojson), booking rules, operating time windows (start_pickup_drop_off_window / end_pickup_drop_off_window), and zone-to-zone travel rules (stop_times.txt).

In BAMBAM, a GTFS-Flex trip allows a traveler to walk to a pickup location within an active flex zone, board an on-demand vehicle that routes over the drivable road network within permitted pickup/drop-off zone pairs, and alight to walk to their final destination.


2. Setup

1. Import GTFS-Flex Feeds (bambam-gtfs-flex)

After building your road network (e.g., denver_buf/), run bambam-gtfs-flex import on a directory containing GTFS-Flex .zip archives for a specific service date (YYYYMMDD):

./rust/target/release/bambam-gtfs-flex import \
  denver_buf/gtfs \
  denver_buf/flex \
  20250901

This extracts all GTFS-Flex zones, operating windows, and zone-pair relations active on 20250901 and writes them to denver_buf/flex/:

  • gtfs-flex-zones.csv.gz
  • gtfs-flex-geometries.txt.gz
  • gtfs-flex-relations.csv.gz
  • gtfs-flex-metadata.json

2. Inject GTFS-Flex into bambam.toml (bambam_util gtfs-flex-config-app)

Use bambam_util gtfs-flex-config-app to automatically augment denver_buf/bambam.toml with the gtfs-flex mode and write denver_buf/bambam-gtfs-flex.toml:

./rust/target/release/bambam_util gtfs-flex-config-app \
  --base-file denver_buf/bambam.toml \
  --out-file denver_buf/bambam-gtfs-flex.toml \
  --flex-directory denver_buf/flex \
  --start-time "2025-09-01T08:00:00" \
  --graph-edge-list 2 \
  --map-edge-list 2 \
  --gtfs-flex-edge-list 2 \
  --overwrite

Here, --graph-edge-list 2, --map-edge-list 2, and --gtfs-flex-edge-list 2 instruct BAMBAM to attach the gtfs-flex service to edge list index 2 (the drive road network, since on-demand microtransit vehicles travel on drivable streets).

3. Run BAMBAM

cd denver_buf

../rust/target/release/bambam \
  --config-file bambam-gtfs-flex.toml \
  --query-file ../query/denver_extent.json

(See script/bambam_gtfs_flex_test.sh for a complete self-contained example script.)


3. What Happens

  1. Automated Configuration Injection (gtfs-flex-config-app):
    • Appends a fourth edge list (gtfs-flex) to [graph] and [mapping] backed by the drive network topology and geometries.
    • Adds "gtfs-flex" to the [label] modes and updates all multimodal traversal and constraint models.
    • Adds a [[search]] block for gtfs-flex combining the drive speed/time traversal models with the gtfs-flex zone traversal and departure-frontier constraint models.
    • Injects the trip start_time (2025-09-01T08:00:00) and adds the gtfs-flex mode constraints (allowing walk + gtfs-flex with a 0.5-mile walk limit on first/last legs and a 40-minute total time budget).
  2. Zone-Constrained On-Demand Routing:
    • During the search, a traveler can transition onto the gtfs-flex edge list at vertices inside a flex zone whose pickup window is active at start_time.
    • Once boarded in a pickup zone, the gtfs-flex traversal and constraint models track the active zone pair (gtfs-flex-relations.csv.gz), applying any boarding wait times (prior_notice_duration_min / zone delays) and restricting vehicle movement and alighting to valid drop-off zones within the service’s operating rules.
  3. Output Aggregation:
    • Destinations reachable within 10, 20, 30, and 40 minutes via gtfs-flex are written alongside walk, bike, and drive in result.csv and result.json.