Observed Stop Events from GTFS-Realtime Trip Updates
Source:R/events.R
rt2s_events_from_trip_updates.RdReduces an archive of Trip Updates (many successive predictions per trip
and stop across polls) to observed stop events (see
observed-stop-events): per (trip, service date, stop visit), the
latest report wins - labeled "observed" when it was issued at or after
the vehicle's departure from the stop, "predicted-last" otherwise.
SKIPPED stops and CANCELED/DELETED trips become
explicit negative-information rows; NO_DATA rows are dropped with
a message.
Arguments
- updates
A data.frame as returned by
gtfsrealtime::read_gtfsrt_trip_updates(): one row per stop-time update withtrip_id,stop_idand/orstop_sequence,arrival_time/arrival_delay,departure_time/departure_delay, schedule relationships,start_date,vehicle_id,file_timestamp. Whentrip_idis absent (some producers, e.g. HSL, identify trips only by the GTFS-RT TripDescriptor), a stable identity is synthesized fromroute_id,direction_id,start_date, andstart_timeso predictions still group per operated trip.- baseline
Optional baseline static GTFS feed (object or zip path). Required to resolve delay-only updates (a delay without an absolute time can only be interpreted against the scheduled time).
- tz
Timezone of the feed's service days (used to resolve delay-only updates against baseline scheduled times). Default "UTC".
Details
A trip that serves a stop more than once (a loop) keeps one event per
visit, told apart by stop_sequence as GTFS-Realtime requires for
such stops. A stop counts as looped when one poll lists it under two
stop_sequence values; elsewhere all reports of a stop form one
visit even if a producer renumbers stops between polls. At a looped stop a
report without stop_sequence is ambiguous and dropped with a
warning. Delay-only updates are resolved against the baseline row with the
same stop_sequence when that row is the same stop (a warning names
sequences that point at another stop), else against a stop the scheduled
trip serves once. A trip without start_date whose report falls in
the first hour of a daylight-saving fall-back day belongs to the previous
service day, as GTFS counts that hour past 24:00 of the day before.