# \dontshow{
old_dt_threads <- data.table::setDTthreads(1)
on.exit(data.table::setDTthreads(old_dt_threads), add = TRUE)
# }
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
# the trip is faster than 30 km/h between some of its stops
get_trip_speed(gtfs, "CPTM L07-0", by = "segment")
gtfs_capped <- set_max_speed(gtfs, max_speed = 30, trip_id = "CPTM L07-0")
get_trip_speed(gtfs_capped, "CPTM L07-0", by = "segment")
# the later stops are shifted, so the trip ends later
get_start_and_end_times(gtfs, trip_id = "CPTM L07-0")
get_start_and_end_times(gtfs_capped, trip_id = "CPTM L07-0")
# cap the speed only between two stops. the spans before and after them
# are not capped
gtfs_capped <- set_max_speed(
gtfs,
max_speed = 30,
trip_id = "CPTM L07-0",
first_stop = "18921",
last_stop = "18974"
)
get_trip_speed(gtfs_capped, "CPTM L07-0", by = "segment")
# cap the speed of all the trips of all routes of the GTFS feed
gtfs_capped <- set_max_speed(gtfs, max_speed = 8)
Run the code above in your browser using DataLab