# \dontshow{
old_dt_threads <- data.table::setDTthreads(1)
# }
library(dplyr)
data_path <- system.file("extdata/poa_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
trip <- "T2-1@1#520"
# only the first and last stops of each trip have times
gtfs$stop_times |>
filter(trip_id == trip) |>
head()
# distances measured along the trips' shapes. some trips of this feed have
# times past midnight written as "00:xx:xx", which are fixed first
interpolated_gtfs <- suppressWarnings(interpolate_stop_times(gtfs))
interpolated_gtfs$stop_times |>
filter(trip_id == trip) |>
head()
# the speed is now known between every pair of consecutive stops
head(get_trip_speed(interpolated_gtfs, trip, by = "segment"))
# straight-line distances between stops, for a single trip
interpolated_gtfs <- interpolate_stop_times(
gtfs,
trip_id = trip,
method = "euclidean"
)
interpolated_gtfs$stop_times |>
filter(trip_id == trip) |>
head()
data.table::setDTthreads(old_dt_threads)
Run the code above in your browser using DataLab