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 duplicated trips in GTFS-realtime #216

Closed
ghost opened this issue Apr 24, 2020 · 13 comments
Closed

Add duplicated trips in GTFS-realtime #216

ghost opened this issue Apr 24, 2020 · 13 comments
Labels
GTFS Realtime Issues and Pull Requests that focus on GTFS Realtime Support: Needs Help Needs support to answer outstanding questions and/or feedback.

Comments

@ghost
Copy link

ghost commented Apr 24, 2020

Case: An added trip is created in a CAD/AVL system by duplicating an existing trip or block and then assigning a schedule offset (so the duplicated trip operates XX mins before or after the original trip)

Question: What is the best way to represent such added trips in GTFS-realtime?

Two possible approaches are (1) assigning a unique entity_id and unique trip_id to the duplicated trip or (2) assigning a unique entity_id with the same trip_id from the schedule but a different start_time than the scheduled trip.

Approach 2 seems better since then consumers would know which trip (and so its shape and stop_times) was duplicated, but 1) can two trips in the same GTFS-realtime feed have the same trip_id? 2) If yes, does this cause any issues for consumers?

Is there a better approach?

@skinkie
Copy link
Contributor

skinkie commented Apr 24, 2020

@ritesh-warade-ibigroup the approach that you lay out might even depend on the case. The added trip that you describe is a reinforcement trip. For that I could imagine using 2 concurrently. But for really added or modified trips (different route) I would say that 1 is preferable.

@barbeau
Copy link
Collaborator

barbeau commented Apr 24, 2020

@ritesh-warade-ibigroup In short, there isn't an official way to duplicate trips in the current GTFS-RT spec. Google supports (2) with ADDED schedule_relationship, but we actually want to move away from this to a more robust solution (one reason being that others use ADDED differently).

Goining forward, the "right" way to duplicate a trip in GTFS-realtime is the new DUPLICATED schedule_relationship in ServiceChanges v3.1:
https://docs.google.com/document/d/1oPfQ6Xvui0g3xiy1pNiyu5cWFLhvrTVyvYsMVKGyGWM/edit#bookmark=id.46iq4ddo589j

I'm actually in the process of working on a new PR that's a subset of Service Changes, pulling out the fields to support DUPLICATED, so we could move this forward and deprecate ADDED for this reason. Is this something that you could use?

@skinkie
Copy link
Contributor

skinkie commented Apr 24, 2020

@barbeau I hope we can still use ADDED for the other purpose :)

@barbeau
Copy link
Collaborator

barbeau commented Apr 24, 2020

@skinkie ADDED will be soft-deprecated in the .proto, meaning that you could still consume and produce it if you like for your own purposes. But no promises on a community consensus on what it actually means :).

@sunny-lirr
Copy link

Is the goal for ServiceChanges to not only represent near-term temporary conditions such as detours or rail replacement buses but also true real time operating conditions that require adding trips or skipping stops? The current ADDED field can also be used for real time extra trips or added stops that only affect the current instance of a trip.

As an LIRR example, when a train (A) is canceled ad-hoc (unplanned), the next train (B) will often add stops to handle the passengers of the first train. In both our internal systems and our forthcoming GTFS-RT release, the output will consist of marking both A and B as CANCELED and creating a copy of B with the added stops under a new trip ID as ADDED.

@barbeau
Copy link
Collaborator

barbeau commented Apr 27, 2020

Is the goal for ServiceChanges to not only represent near-term temporary conditions such as detours or rail replacement buses but also true real time operating conditions that require adding trips or skipping stops?

Yes, ServiceChanges can add entire new trips in real-time via a new Trip object. It mirrors the contents in trips.txt and, similarly, there is a new StopTime that mirrors stop_times.txt too.

There is a draft .proto here with the additions if you want to take a look:
MobilityData#47

...as well as draft Java bindings for prototyping here:
MobilityData/gtfs-realtime-bindings#58

As an LIRR example, when a train (A) is canceled ad-hoc (unplanned), the next train (B) will often add stops to handle the passengers of the first train. In both our internal systems and our forthcoming GTFS-RT release, the output will consist of marking both A and B as CANCELED and creating a copy of B with the added stops under a new trip ID as ADDED.

Yes, with the full ServiceChanges additions you'd mark A and B as CANCELED, and then add the new trip (which is similar to B but adds stops) as a completely new Trip entity, complete with StopTime entities that include all stops (including the "new" stops).

If it was a detour with new stops that aren't in static GTFS CSV files, you can add new Stop entities as well in the protobuf feed.

@paulswartz
Copy link
Contributor

MBTA uses ADDED trips with the first pattern (new entity ID, new trip ID).

@ghost
Copy link
Author

ghost commented Apr 28, 2020

Thank you all!

@barbeau re:

I'm actually in the process of working on a new PR that's a subset of Service Changes, pulling out the fields to support DUPLICATED, so we could move this forward and deprecate ADDED for this reason. Is this something that you could use?

Yes, this is probably something that we can use. (Hopefully what you come up with is not super complicated)

@barbeau barbeau changed the title Added trips in GTFS-realtime Add duplicated trips in GTFS-realtime Apr 29, 2020
@barbeau
Copy link
Collaborator

barbeau commented Apr 29, 2020

@ritesh-warade-ibigroup Not complicated at all - essentially you'd swap ADDED for DUPLICATED, identify the trip from CSV GTFS via TripDescriptor.trip_id, and specify the new service date and/or time to run in two new fields. I'll work on publishing the draft shortly.

@ghost
Copy link
Author

ghost commented Apr 30, 2020

@barbeau sounds good. can you post a link to the draft here when you publish?

@barbeau
Copy link
Collaborator

barbeau commented Apr 30, 2020

@ritesh-warade-ibigroup Will do.

@barbeau
Copy link
Collaborator

barbeau commented May 4, 2020

@ritesh-warade-ibigroup I've opened a PR for a proposal to support DUPLICATED trips at #221.

@barbeau barbeau added GTFS Realtime Issues and Pull Requests that focus on GTFS Realtime Support: Needs Help Needs support to answer outstanding questions and/or feedback. labels Jun 18, 2020
@barbeau
Copy link
Collaborator

barbeau commented Sep 28, 2020

The proposal supporting DUPLICATED trips at #221 was voted on and adopted as an experimental feature, so I'm going to close this out.

@barbeau barbeau closed this as completed Sep 28, 2020
barbeau added a commit to MobilityData/GTFS_Realtime_Best-Practices that referenced this issue Apr 15, 2021
See google/transit#216. There are unofficial cases where stop_id and stop_sequence have differed in the past, that is cleaned up by DUPLICATED proposal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GTFS Realtime Issues and Pull Requests that focus on GTFS Realtime Support: Needs Help Needs support to answer outstanding questions and/or feedback.
Projects
None yet
Development

No branches or pull requests

4 participants