This PR slightly changes how journey calculations in raptor work by changing some implicit assumptions.
General improvements
time_range can now be passed as a vector with a minimum and maximum departure time, for example travel_times(stop_times, "stop1a", time_range = c("17:00:00", "18:00:00")). This works for both travel_times and raptor. It's also possible to pass the vector as seconds.
added new interpolate_stop_times function to linearly interpolate missing stop_times
Improved "pipeability" of filter_stop_times and raptor.
library(tidytransit)
# find travel_times for trips departing on 2019-08-26 between 2 PM and 3:30 PM from
# Campus Dr at Arts Annex
gtfs_duke |>
interpolate_stop_times() |>
filter_feed_by_date("2019-08-26") |> # or filter_stop_times
travel_times(c("Campus Dr at Arts Annex (WB)", "Campus Dr at Arts Annex (EB)"),
time_range = c("14:00:00", "15:30:00"))
#> # A tibble: 62 × 8
#> from_stop_name to_stop_name travel_time journey_departure_time
#> <chr> <chr> <dbl> <time>
#> 1 Campus Dr at Arts Annex (WB) Campus Dr at… 0 14:00
#> 2 Campus Dr at Arts Annex (EB) Campus Dr at… 0 14:00
#> 3 Campus Dr at Arts Annex (EB) Campus Dr at… 60 14:04
#> 4 Campus Dr at Arts Annex (WB) Campus Dr at… 60 14:01
#> 5 Campus Dr at Arts Annex (WB) Campus Dr at… 120 14:01
#> 6 Campus Dr at Arts Annex (EB) Maxwell Ave … 120 14:05
#> 7 Campus Dr at Arts Annex (EB) East Campus … 180 14:04
#> 8 Campus Dr at Arts Annex (WB) Campus Dr at… 180 14:01
#> 9 Campus Dr at Arts Annex (WB) Campus Dr at… 240 14:01
#> 10 Campus Dr at Arts Annex (WB) West Campus … 360 14:01
#> # ℹ 52 more rows
#> # ℹ 4 more variables: journey_arrival_time <time>, transfers <int>,
#> # from_stop_id <chr>, to_stop_id <chr>
# Find trips arriving between 6 and 7 PM
gtfs_duke |>
interpolate_stop_times() |>
filter_stop_times("2019-08-26") |>
raptor(stop_ids = c("778060", "778061"),
time_range = c("18:00:00", "19:00:00"), arrival = TRUE)
#> from_stop_id to_stop_id travel_time journey_departure_time
#> 1: 778057 778060 31 68129
#> 2: 778058 778060 60 68100
#> 3: 778063 778061 60 67980
#> 4: 778065 778061 60 67980
#> 5: 778067 778061 120 67920
#> ---
#> 443: 778118 778061 8460 56580
#> 444: 2326138 778061 8640 56460
#> 445: 2326138 778061 8580 56460
#> 446: 778060 778060 0 64800
#> 447: 778061 778061 0 64800
#> journey_arrival_time transfers
#> 1: 68160 0
#> 2: 68160 0
#> 3: 68040 0
#> 4: 68040 0
#> 5: 68040 0
#> ---
#> 443: 65040 2
#> 444: 65100 2
#> 445: 65040 2
#> 446: 64800 0
#> 447: 64800 0
raptor now returns journeys from all stop_ids and stop_ids reached with an initial transfer. The number of journeys returned is generally larger than before, especially with keep="all".
raptor returns earliest (or latest) time of time_window as arrival/departure time for the initial stops, regardless of actual departures happening on these stops.
If time_range is a single number, travel_times and raptor use use the min_departure_time set in filter_stop_times (if available) instead of the earliest departure_time in stop_times
max_departure_time has been deprecated in favor of time_range
This PR also adds examples and updates the documentation.
This PR slightly changes how journey calculations in
raptor
work by changing some implicit assumptions.General improvements
time_range
can now be passed as a vector with a minimum and maximum departure time, for exampletravel_times(stop_times, "stop1a", time_range = c("17:00:00", "18:00:00"))
. This works for bothtravel_times
andraptor
. It's also possible to pass the vector as seconds.interpolate_stop_times
function to linearly interpolate missing stop_timesCreated on 2023-06-19 with reprex v2.0.2
Possibly breaking changes in
raptor
time_range
is a single number, travel_times and raptor use use themin_departure_time
set infilter_stop_times
(if available) instead of the earliestdeparture_time
in stop_timesmax_departure_time
has been deprecated in favor of time_rangeThis PR also adds examples and updates the documentation.