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

Scheduled Transit (GTFS)

1. Overview

Public transit operates on fixed routes and published timetables rather than continuous, on-demand roadway speeds. Modeling transit accessibility requires capturing:

  • First- and last-mile access: Walking from an origin to a transit stop, walking between stops to transfer routes, and walking from the alighting stop to the final destination.
  • Schedule-dependent waiting and in-vehicle travel: A traveler arriving at a transit stop at time \(t\) must wait until the next scheduled departure \(t_{\text{dep}} \ge t\) on that route before traversing the stop-to-stop link and arriving at \(t_{\text{arr}}\).

BAMBAM models scheduled public transit using GTFS (General Transit Feed Specification) feeds. It snaps GTFS stops to vertices on the road network, builds a dedicated transit edge list representing stop-to-stop service patterns, compiles active departures within a target date and time window into a high-speed binary timetable (edges-schedules.rkyv), and couples the walk and transit networks into a multimodal graph.


2. Setup

Building the Transit Network (bambam_build_open_data.sh)

In script/bambam_build_open_data.sh, stages 2 through 4 (gtfs-download, gtfs-import, and gtfs-config) download GTFS archives from a Mobility Data Catalog CSV manifest, compile the transit edge list and schedule tables into denver_buf/transit/, and generate denver_buf/bambam_gtfs.toml:

./script/bambam_build_open_data.sh \
  --extent-file query/denver_470_buffer.txt \
  --output-dir denver_buf \
  --gtfs-manifest path/to/mobility_catalog_manifest.csv \
  --subdivision-name "Colorado" \
  --from-stage network \
  --to-stage gtfs-config

Under the hood, these stages run:

  1. bambam-transit download: Downloads GTFS .zip feeds matching the country/subdivision filter into denver_buf/gtfs/.
  2. bambam-transit import: Filters feeds to the study extent, maps service calendars to the target date/time window (e.g., 08:00:00 to 09:00:00), snaps stops to vertices-compass.csv.gz, and writes denver_buf/transit/edges-compass.csv.gz and denver_buf/transit/edges-schedules.rkyv.
  3. bambam_util gtfs-config: Reads denver_buf/bambam.toml and writes denver_buf/bambam_gtfs.toml with the transit edge list, transit schedule traversal model, and "transit" multimodal label injected.

Modifying bambam_gtfs.toml

To evaluate transit trips during your target departure window, ensure bambam_gtfs.toml includes:

  1. A start_datetime input plugin so schedule lookups know when the trip begins:
    [[plugin.input_plugins]]
    type = "inject"
    format = "key_value"
    write_mode = "overwrite"
    key = "start_datetime"
    value = "2025-09-01 08:00:00"
    
  2. A transit mode entry under the trip_modes input plugin defining the multimodal leg rules (such as a maximum of 4 legs, up to 10 minutes of walking, and at least 3 minutes on transit):
    [plugin.input_plugins.modes.transit]
    multimodal_label = true
    max_trip_legs = 4
    constraints = [
        { type = "mode_time_limit", mode = "walk", max = 10.0, unit = "minutes" },
        { type = "mode_leg_time_limit", mode = "transit", min = 3.0, unit = "minutes" },
        { type = "allowed_modes", values = ["walk", "transit"] },
    ]
    

Running BAMBAM

cd denver_buf

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

3. What Happens

  1. Multimodal Graph Construction:
    • BAMBAM loads the walk, bike, drive, and transit edge lists over the shared vertex set (vertices-compass.csv.gz). Because GTFS stops were snapped to road network vertices during gtfs-import, travelers can seamlessly transition between walk edges and transit edges at any transit stop vertex.
  2. Schedule-Aware Tree Search:
    • For each grid cell’s transit query, the search starts at start_datetime (e.g., 8:00 AM) on the walk network.
    • When the search reaches a vertex with outgoing transit edges, it transitions from walk to transit (incrementing the trip leg counter).
    • The transit traversal model consults transit/edges-schedules.rkyv to find the earliest departure at or after the traveler’s current arrival time at that stop. The link travel time is computed as: \[\Delta t = (t_{\text{departure}} - t_{\text{arrival}}) + (t_{\text{next\_stop}} - t_{\text{departure}})\] capturing both schedule wait/transfer time and in-vehicle travel time.
    • At downstream stops, the traveler can either stay aboard the transit vehicle, transfer to another transit route, or alight back onto the walk network to reach final destinations, subject to the 10-minute total walk limit and 40-minute total trip time limit.
  3. Output Aggregation:
    • Reached destinations and opportunities along the multimodal walk+transit tree are binned into 10-, 20-, 30-, and 40-minute intervals and written to result.csv and result.json with mode = "transit".