You can add a trip instance in realtime. Duplicate an existing trip prototype defined in the static GTFS data and schedule it at another time. To add a trip in realtime:
- Specify
schedule_relationship
asADDED
. - Identify the trip by referring to the static trip and use the
trip_id
. - Specify a new schedule using
start_time
. It’s recommended that thestart_time
be different from thestart_time
of the original trip. All arrival or departure times at stops are copied from the original trip and shifted accordingly unless explicitly specified.
It’s possible to add a trip for both the exact_times
trip and frequency trips cases. For a frequency-based static trip with exact_times
set to 0
, use schedule_relationship
of SCHEDULED
instead. The ADDED
trips will also be treated as scheduled.
Added trips must not contain block transfers as it’s not possible to add a trip with block transfers in realtime.
Add with TripUpdatesTo maintain reference to the added trip, the <trip_id, start_time, schedule_relationship
> tuple must remain stable. A stop_time_update
could be added to define predictions for the added trips.
Example code:
trip_update {
trip {
trip_id: xxx
start_time: 12:34:56
schedule_relationship: ADDED
}
}
To maintain reference to the added trip, the <trip_id, start_time, vehicle_id, schedule_relationship
> tuple must remain stable.
Example code:
vehicle {
trip {
trip_id: xxx
start_time: 12:34:56
schedule_relationship: ADDED
}
}
Additional trips don’t show up as part of the results. Instead, an additional service message is attached to existing trips. To indicate additional trips, specify ADDITIONAL_SERVICE
in the effect
field of the alert and indicate the appropriate informed_entity
. The alert can be added at agency, route, or trip levels.
Example code:
alert {
informed_entity {
trip: {
trip_id: "G5"
start_time: "15:15:00"
}
active_period {
start: 1284457468
end: 1284468072
}
effect: ADDITIONAL_SERVICE
...
}
This is how the ServiceAlerts information displays:
Changes to the GTFS specification
A GTFS proposal to support schedule_relationship=DUPLICATED
trips was approved. We’re currently working on the new GTFS spec to provide DUPLICATED
trips, which deprecates ADDED
trips. After Google supports the changes, we’ll update this article.
If you already added support for DUPLICATED
trip, refer to the migration guide.