Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for deleted trips & including real-time cancelations in trip search #4759

Merged
merged 5 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update GTFS-RT protbuf, handle deleted trips as canceled
  • Loading branch information
hannesj committed Jan 23, 2023
commit ffa67a6f5b157825d75ea66edee52b3271827471
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ public UpdateResult applyTripUpdates(
serviceDate
);
case CANCELED -> handleCanceledTrip(tripId, serviceDate);
case DELETED -> handleCanceledTrip(tripId, serviceDate);
case REPLACEMENT -> validateAndHandleModifiedTrip(
tripUpdate,
tripDescriptor,
Expand Down
76 changes: 48 additions & 28 deletions src/main/proto/gtfs-realtime.proto
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ message TripUpdate {
// Expected occupancy after departure from the given stop.
// Should be provided only for future stops.
// In order to provide departure_occupancy_status without either arrival or
// departure StopTimeEvents, ScheduleRelationship should be set to NO_DATA.
// departure StopTimeEvents, ScheduleRelationship should be set to NO_DATA.
optional VehiclePosition.OccupancyStatus departure_occupancy_status = 7;

// The relation between the StopTimeEvents and the static schedule.
enum ScheduleRelationship {
// The vehicle is proceeding in accordance with its static schedule of
Expand Down Expand Up @@ -250,7 +250,7 @@ message TripUpdate {
UNSCHEDULED = 3;
}
optional ScheduleRelationship schedule_relationship = 5
[default = SCHEDULED];
[default = SCHEDULED];

// Provides the updated values for the stop time.
// NOTE: This message is still experimental, and subject to change. It may be formally adopted in the future.
Expand Down Expand Up @@ -340,7 +340,7 @@ message TripUpdate {
optional int32 delay = 5;

// Defines updated properties of the trip, such as a new shape_id when there is a detour. Or defines the
// trip_id, start_date, and start_time of a DUPLICATED trip.
// trip_id, start_date, and start_time of a DUPLICATED trip.
// NOTE: This message is still experimental, and subject to change. It may be formally adopted in the future.
message TripProperties {
// Defines the identifier of a new trip that is a duplicate of an existing trip defined in (CSV) GTFS trips.txt
Expand Down Expand Up @@ -374,7 +374,7 @@ message TripUpdate {
// or a Shape in the (protobuf) real-time feed. The order of stops (stop sequences) for this trip must remain the same as
// (CSV) GTFS. Stops that are a part of the original trip but will no longer be made, such as when a detour occurs, should
// be marked as schedule_relationship=SKIPPED.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional string shape_id = 4;

// The extensions namespace allows 3rd-party developers to extend the
Expand Down Expand Up @@ -450,7 +450,7 @@ message VehiclePosition {
// The state of passenger occupancy for the vehicle or carriage.
// Individual producers may not publish all OccupancyStatus values. Therefore, consumers
// must not assume that the OccupancyStatus values follow a linear scale.
// Consumers should represent OccupancyStatus values as the state indicated
// Consumers should represent OccupancyStatus values as the state indicated
// and intended by the producer. Likewise, producers must use OccupancyStatus values that
// correspond to actual vehicle occupancy states.
// For describing passenger occupancy levels on a linear scale, see `occupancy_percentage`.
Expand Down Expand Up @@ -504,7 +504,7 @@ message VehiclePosition {
// including both seated and standing capacity, and current operating regulations allow.
// The value may exceed 100 if there are more passengers than the maximum designed capacity.
// The precision of occupancy_percentage should be low enough that individual passengers cannot be tracked boarding or alighting the vehicle.
// If multi_carriage_status is populated with per-carriage occupancy_percentage,
// If multi_carriage_status is populated with per-carriage occupancy_percentage,
// then this field should describe the entire vehicle with all carriages accepting passengers considered.
// This field is still experimental, and subject to change. It may be formally adopted in the future.
optional uint32 occupancy_percentage = 10;
Expand Down Expand Up @@ -539,7 +539,7 @@ message VehiclePosition {
// For example, the first carriage in the direction of travel has a value of 1.
// If the second carriage in the direction of travel has a value of 3,
// consumers will discard data for all carriages (i.e., the multi_carriage_details field).
// Carriages without data must be represented with a valid carriage_sequence number and the fields
// Carriages without data must be represented with a valid carriage_sequence number and the fields
// without data should be omitted (alternately, those fields could also be included and set to the "no data" values).
// This message/field is still experimental, and subject to change. It may be formally adopted in the future.
optional uint32 carriage_sequence = 5;
Expand All @@ -554,12 +554,12 @@ message VehiclePosition {
}

// Details of the multiple carriages of this given vehicle.
// The first occurrence represents the first carriage of the vehicle,
// given the current direction of travel.
// The number of occurrences of the multi_carriage_details
// The first occurrence represents the first carriage of the vehicle,
// given the current direction of travel.
// The number of occurrences of the multi_carriage_details
// field represents the number of carriages of the vehicle.
// It also includes non boardable carriages,
// like engines, maintenance carriages, etc… as they provide valuable
// It also includes non boardable carriages,
// like engines, maintenance carriages, etc… as they provide valuable
// information to passengers about where to stand on a platform.
// This message/field is still experimental, and subject to change. It may be formally adopted in the future.
repeated CarriageDetails multi_carriage_details = 11;
Expand All @@ -583,7 +583,7 @@ message Alert {
// Entities whose users we should notify of this alert.
repeated EntitySelector informed_entity = 5;

// Cause of this alert.
// Cause of this alert. If cause_detail is included, then Cause must also be included.
enum Cause {
UNKNOWN_CAUSE = 1;
OTHER_CAUSE = 2; // Not machine-representable.
Expand All @@ -600,7 +600,7 @@ message Alert {
}
optional Cause cause = 6 [default = UNKNOWN_CAUSE];

// What is the effect of this problem on the affected entity.
// What is the effect of this problem on the affected entity. If effect_detail is included, then Effect must also be included.
enum Effect {
NO_SERVICE = 1;
REDUCED_SERVICE = 2;
Expand Down Expand Up @@ -639,24 +639,33 @@ message Alert {

// Severity of this alert.
enum SeverityLevel {
UNKNOWN_SEVERITY = 1;
INFO = 2;
WARNING = 3;
SEVERE = 4;
UNKNOWN_SEVERITY = 1;
INFO = 2;
WARNING = 3;
SEVERE = 4;
}

optional SeverityLevel severity_level = 14 [default = UNKNOWN_SEVERITY];

// TranslatedImage to be displayed along the alert text. Used to explain visually the alert effect of a detour, station closure, etc. The image must enhance the understanding of the alert. Any essential information communicated within the image must also be contained in the alert text.
// The following types of images are discouraged : image containing mainly text, marketing or branded images that add no additional information.
// The following types of images are discouraged : image containing mainly text, marketing or branded images that add no additional information.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional TranslatedImage image = 15;
optional TranslatedImage image = 15;

// Text describing the appearance of the linked image in the `image` field (e.g., in case the image can't be displayed
// or the user can't see the image for accessibility reasons). See the HTML spec for alt image text - https://html.spec.whatwg.org/#alt.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional TranslatedString image_alternative_text = 16;


// Description of the cause of the alert that allows for agency-specific language; more specific than the Cause. If cause_detail is included, then Cause must also be included.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional TranslatedString cause_detail = 17;

// Description of the effect of the alert that allows for agency-specific language; more specific than the Effect. If effect_detail is included, then Effect must also be included.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional TranslatedString effect_detail = 18;

// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features
// and modifications to the spec.
Expand Down Expand Up @@ -799,7 +808,7 @@ message TripDescriptor {
CANCELED = 3;

// Should not be used - for backwards-compatibility only.
REPLACEMENT = 5 [deprecated=true];
REPLACEMENT = 5 [deprecated = true];

// An extra trip that was added in addition to a running schedule, for example, to replace a broken vehicle or to
// respond to sudden passenger load. Used with TripUpdate.TripProperties.trip_id, TripUpdate.TripProperties.start_date,
Expand All @@ -808,15 +817,26 @@ message TripDescriptor {
// (in calendar.txt or calendar_dates.txt) is operating within the next 30 days. The trip to be duplicated is
// identified via TripUpdate.TripDescriptor.trip_id. This enumeration does not modify the existing trip referenced by
// TripUpdate.TripDescriptor.trip_id - if a producer wants to cancel the original trip, it must publish a separate
// TripUpdate with the value of CANCELED. Trips defined in GTFS frequencies.txt with exact_times that is empty or
// equal to 0 cannot be duplicated. The VehiclePosition.TripDescriptor.trip_id for the new trip must contain
// TripUpdate with the value of CANCELED or DELETED. Trips defined in GTFS frequencies.txt with exact_times that is
// empty or equal to 0 cannot be duplicated. The VehiclePosition.TripDescriptor.trip_id for the new trip must contain
// the matching value from TripUpdate.TripProperties.trip_id and VehiclePosition.TripDescriptor.ScheduleRelationship
// must also be set to DUPLICATED.
// Existing producers and consumers that were using the ADDED enumeration to represent duplicated trips must follow
// the migration guide (https://github.com/google/transit/tree/master/gtfs-realtime/spec/en/examples/migration-duplicated.md)
// to transition to the DUPLICATED enumeration.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
DUPLICATED = 6;


// A trip that existed in the schedule but was removed and must not be shown to users.
// DELETED should be used instead of CANCELED to indicate that a transit provider would like to entirely remove
// information about the corresponding trip from consuming applications, so the trip is not shown as cancelled to
// riders, e.g. a trip that is entirely being replaced by another trip.
// This designation becomes particularly important if several trips are cancelled and replaced with substitute service.
// If consumers were to show explicit information about the cancellations it would distract from the more important
// real-time predictions.
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
DELETED = 7;
}
optional ScheduleRelationship schedule_relationship = 4;

Expand Down Expand Up @@ -950,12 +970,12 @@ message TranslatedString {
message TranslatedImage {
message LocalizedImage {
// String containing an URL linking to an image
// The image linked must be less than 2MB.
// The image linked must be less than 2MB.
// If an image changes in a significant enough way that an update is required on the consumer side, the producer must update the URL to a new one.
// The URL should be a fully qualified URL that includes http:// or https://, and any special characters in the URL must be correctly escaped. See the following http://www.w3.org/Addressing/URL/4_URI_Recommentations.html for a description of how to create fully qualified URL values.
// The URL should be a fully qualified URL that includes http:// or https://, and any special characters in the URL must be correctly escaped. See the following http://www.w3.org/Addressing/URL/4_URI_Recommentations.html for a description of how to create fully qualified URL values.
required string url = 1;

// IANA media type as to specify the type of image to be displayed.
// IANA media type as to specify the type of image to be displayed.
// The type must start with "image/"
required string media_type = 2;

Expand Down Expand Up @@ -997,7 +1017,7 @@ message Shape {
// See https://developers.google.com/protocol-buffers/docs/proto#specifying_field_rules
// NOTE: This field is still experimental, and subject to change. It may be formally adopted in the future.
optional string shape_id = 1;

// Encoded polyline representation of the shape. This polyline must contain at least two points.
// For more information about encoded polylines, see https://developers.google.com/maps/documentation/utilities/polylinealgorithm
// This field is required as per reference.md, but needs to be specified here optional because "Required is Forever"
Expand Down