google / transit

https://gtfs.org/
Apache License 2.0
556 stars 173 forks source link

Defining a route type at the trip level #358

Open vpaturet opened 1 year ago

vpaturet commented 1 year ago

The current GTFS specification allows for defining a route type ("route_type" in routes.txt) at the route level which applies to every trips in that route. There are cases however where some trips in a given route are scheduled with an alternate transport mode. A typical example is replacement bus, where train trips are temporarily replaced by bus trips due to construction work on the railways. From a passenger's perspective, these replacement bus trips belong to the original route. There is no way to model this with the current GTFS specification.

MBTA came up with a solution for this use case: adding a custom field "trip_route_type" in trips.txt See:

Would it make sense to standardize this custom field "trip_route_type" in the GTFS specification?

jspetrak commented 1 year ago

From the rail perspective, replacement bus is technically a train with commercial category bus, and it calls train stations, not bus stations. I know it is confusing.

If we allow to modify route data on trip level, I would think also about routeless trips which most of the trains are, at least in Europe. And there usually less than more successful workarounds for that.

hannesj commented 1 year ago

Another possibility would be to mark a route to be part/replacement of another route. That way we could link those together and use the information to link the real-time alerts to both routes.

JohanEntur commented 1 year ago

The problem that arose here was that a deviation message said "train is cancelled" but the GTFS data showed a train (which was actually a bus).

barbagus commented 8 months ago

@jspetrak

From the rail perspective, replacement bus is technically a train with commercial category bus, and it calls train stations, not bus stations. I know it is confusing.

In #409 I make the case for regular bus services mixed with train services within the same route (French regional railways). Would you say your remark applies there as well ?

If we allow to modify route data on trip level, I would think also about routeless trips which most of the trains are, at least in Europe.

Could you elaborate on this please ? I am not sure to understand.

jfabi commented 6 months ago

Following here from https://github.com/google/transit/issues/409, sharing a bit more about the @mbta's experience with rail replacement buses:

Another possibility would be to mark a route to be part/replacement of another route. That way we could link those together and use the information to link the real-time alerts to both routes.

We are doing exactly this via another extension we designed and implemented, _multi_route_trips.txt_.

In the example below from our Needham Line route timetable, Train 839 and Train 841 are actually part of a different route_id for the Providence/Stoughton Line (they continue on to another destination beyond Forest Hills), but because the trips are linked to the Needham Line via _multi_routetrips.txt, we are able to show them on this webpage.

Screen Shot 2023-12-27 at 22 24 20

A similar treatment is used if, say, a shuttle bus replaced a portion or whole of a Needham Line trip.

We originally added the trip_route_type extension in order to be able to distinguish "replacement bus" trips with normal rail trips on the same route_id, however ultimately moved to using separate routes; having trips on both rail and bus route_ids stopping at shared stop_ids caused issues with more than one feed consumer. Perhaps this could be overcome with an addition to the spec, but backward-compatibility should be considered.

In our case, using a distinct route_id also allows us to give the bus service route/text colors that match the replacing buses, as well as separate route names—particularly useful in situations when a single bus service replaces multiple rail routes.