Learn R Programming

GTFSwizard (version 1.1.0)

set_dwelltime: Set Dwell Time for GTFS Stops

Description

The `set_dwelltime` function updates the arrival and departure times in the `stop_times` table of a GTFS object based on a specified dwell time duration. The function modifies the dwell time for selected trips and stops, or for all trips and stops by default.

Usage

set_dwelltime(gtfs, duration = 30, trips = "all", stops = "all")

Value

A modified GTFS object with updated arrival and departure times in the `stop_times` table.

Arguments

gtfs

A GTFS object, preferably of class `wizardgtfs`. If not, the function will attempt to convert it using `GTFSwizard::as_wizardgtfs()`.

duration

A numeric value specifying the desired dwell time in seconds. Defaults to 30 seconds.

trips

A character vector of trip IDs for which the dwell time will be updated. Use `'all'` to update all trips (default).

stops

A character vector of stop IDs for which the dwell time will be updated. Use `'all'` to update all stops (default).

Details

This function calculates the midpoint between the original `arrival_time` and `departure_time` for the specified trips and stops. It then adjusts these times based on the desired dwell time (`duration`), ensuring that the dwell time is evenly distributed around the midpoint.

See Also

[GTFSwizard::as_wizardgtfs()], [GTFSwizard::get_dwelltimes()]

Examples

Run this code
# Set dwell time to 30 seconds for specific trips and stops
set_dwelltime(for_rail_gtfs, duration = 30,
               trips = for_rail_gtfs$trips$trip_id[1:2],
               stops = for_rail_gtfs$stops$stop_id[1:2])

Run the code above in your browser using DataLab