Skip to content

More than one GTFS-rt TripUpdate per vehicle is not supported #128

Open
@barbeau

Description

@barbeau

For develop-freq branch:

We've been working on adding a new agency (PSTA) to OBA Tampa, and have been working with their GTFS-rt feed under development, for schedule-based trips. One big difference between the feed that they are providing (http://97.76.252.61:8080/gtfsrt/trips?debug) vs. other feeds we've seen is that they are providing predictions both within the trip the vehicle is currently traveling as well as future trips in the same block.

When we provide this feed with more than one trip per vehicle to OBA, we see the following output:

2015-03-23 18:34:15,940 INFO  [GtfsRealtimeSource.java:232] : refreshing http://97.76.252.61:8080/gtfsrt/trips
2015-03-23 18:34:16,463 WARN  [GtfsRealtimeTripLibrary.java:139] : 
Multiple TripUpdates for vehicle 2903; taking newest.
2015-03-23 18:34:16,463 WARN  [GtfsRealtimeTripLibrary.java:139] : 
Multiple TripUpdates for vehicle 821; taking newest.
2015-03-23 18:34:16,463 WARN  [GtfsRealtimeTripLibrary.java:139] : 
Multiple TripUpdates for vehicle 2531; taking newest.
2015-03-23 18:34:16,464 WARN  [GtfsRealtimeTripLibrary.java:139] : 
Multiple TripUpdates for vehicle 2718; taking newest.
2015-03-23 18:34:16,464 WARN  [GtfsRealtimeTripLibrary.java:139] : 
Multiple TripUpdates for vehicle 2715; taking newest.
2015-03-23 18:34:16,464 WARN  [GtfsRealtimeTripLibrary.java:139] : 
Multiple TripUpdates for vehicle 2308; taking newest.
2015-03-23 18:34:16,464 WARN  [GtfsRealtimeTripLibrary.java:139] : 
Multiple TripUpdates for vehicle 2717; taking newest.
2015-03-23 18:34:16,464 WARN  [GtfsRealtimeTripLibrary.java:139] : 
Multiple TripUpdates for vehicle 2711; taking newest.
2015-03-23 18:34:16,464 WARN  [GtfsRealtimeTripLibrary.java:139] : 
Multiple TripUpdates for vehicle 2611; taking newest.
2015-03-23 18:34:16,464 WARN  [GtfsRealtimeTripLibrary.java:139] : 
Multiple TripUpdates for vehicle 2114; taking newest.
2015-03-23 18:34:16,464 WARN  [GtfsRealtimeTripLibrary.java:139] : 
Multiple TripUpdates for vehicle 2716; taking newest.

So, from our look at the code, it appears that for each poll of the GTFS-rt TripUpdates feed OBA is throwing out the older (timestamp-wise) of the two TripUpdates for the same vehicle running multiple trips in the block. Multiple trip_ids for the same vehicle in the same GTFS-rt TripUpdate feed is legal in GTFS-rt, so we should consume and process these updates.

@sheldonabrown I went ahead and pushed the develop-freq branch from the camsys repo as a new branch in this repo, since as we discussed this is probably the best branch to start from (the code for the combining of vehicle/trip GTFS-rt updates is significantly different in this branch than in master, introduced by @kurtraschke in 0b6bc53 to support frequency-based GTFS-rt updates as well):

https://github.com/OneBusAway/onebusaway-application-modules/tree/develop-freq

We see the same output showing the collision of multiple TripUpdates per vehicle in both the master and develop-freq branches. The above PSTA GTFS-rt is not frequency-based, but we're also introducing another agency (USF Bull Runner) into OBA Tampa that is frequency-based (type 0), another reason why we want to start there.

For schedule-based trips - to start further discussion on this, @cagryInside will submit a PR with one possible solution he tested that is based on the develop-freq branch. This solution concatenates the trip_id and vehicle_id as the key in the HashMap (instead of just vehicle_id), so that more than one TripUpdate per vehicle survives the groupTripUpdatesAndVehiclePositions() method. We no longer get the collision output in the console for PSTA's schedule-based TripUpdates after applying this fix. We'd welcome feedback on this (particularly from @kurtraschke, @sheldonabrown, or @bdferris) and possible alternate/improved ways to handle this.

For frequency-based trips - based on my understanding of GTFS-rt frequency-based (type 0) updates, if we go with the combined HashMap key implementation, we may want to combine trip_id + vehicle_id + start_time, if these fields are all provided. See an extended discussion here why start_time is needed. We have not tested this solution for either frequency or schedule based trips.

Note that this is related to, but not the same as, #127. This issue targets supporting more than one TripUpdate per vehicle (no matter how many stop_time_updates are included), while #127 targets exposing more than one stop_time_update per trip via the onebusaway-api-webapp.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions