Skip to content

Add full "service day" support #488

@nkuehnel

Description

@nkuehnel

Some agencies define their gtfs in service days:
https://gtfs.org/documentation/schedule/reference/#:~:text=A%20service%20day%20may%20exceed,on%20a%20single%20service%20day.

Service day - A service day is a time period used to indicate route scheduling. The exact definition of service day varies from agency to agency but service days often do not correspond with calendar days. A service day may exceed 24:00:00 if service begins on one day and ends on a following day. For example, service that runs from 08:00:00 on Friday to 02:00:00 on Saturday, could be denoted as running from 08:00:00 to 26:00:00 on a single service day.

Which means that some services can go beyond 24 hours. However, when querying the r5r package early in the morning, I don't get connections from the late end of the previous service day. Let's say a service on Thursday runs from 05:00:00 to 27:00:00. If I query for Friday 01:00:00 am I do not get results for the late services that run until 27:00:00 on Thursday. The POSIXct type doesn't allow values beyond 24 hours. Would it be possible to support queries for lets say 25:00:00 or include results from that hour when I query 01:00:00 am on the next day?

Reproducible example here

departure_time <- as.POSIXct("2025-06-05 23:59:00",
                         format = "%Y-%m-%d %H:%M:%S",
                         tz     = "Europe/Berlin")

detailed_itineraries(
  r5r_core,
  origins            = origins,
  destinations       = destinations,
  mode               = c("WALK", "TRANSIT"),
  mode_egress        = "WALK",
  departure_datetime = departure_time,
  time_window        = 120,
  suboptimal_minutes = 0,
  max_trip_duration  = 120,
  walk_speed         = 4.8,
  max_rides          = 5,
  shortest_path      = FALSE,
  drop_geometry      = FALSE
)

In my case, this returns 12 options. However, as soon as I add one more minute (next day/midnight):

departure_time <- departure_time + minutes(1)

I only get two options.

Thanks for looking into this!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions