|
16 | 16 | import org.opentripplanner.routing.algorithm.raptoradapter.transit.RaptorTransitData; |
17 | 17 | import org.opentripplanner.routing.algorithm.raptoradapter.transit.TripPatternForDate; |
18 | 18 | import org.opentripplanner.routing.algorithm.raptoradapter.transit.constrainedtransfer.TransferIndexGenerator; |
| 19 | +import org.opentripplanner.transit.model.network.StopPattern; |
19 | 20 | import org.opentripplanner.transit.model.network.TripPattern; |
20 | 21 | import org.opentripplanner.transit.model.timetable.TripIdAndServiceDate; |
21 | 22 | import org.opentripplanner.transit.model.timetable.TripTimes; |
@@ -66,6 +67,31 @@ public RealTimeRaptorTransitDataUpdater(TimetableRepository timetableRepository) |
66 | 67 | this.timetableRepository = timetableRepository; |
67 | 68 | } |
68 | 69 |
|
| 70 | + /// Updates the real-time [RaptorTransitData] to use the modified timetables. |
| 71 | + /// |
| 72 | + /// This method bridges the different update approaches: |
| 73 | + /// 1. `updatedTimetables` and `timetables` only contains [Timetable]s with real-time |
| 74 | + /// updates. This means that removed items are not present. |
| 75 | + /// 2. [RaptorTransitData] requires applying the changes to a previous snapshot: adding, |
| 76 | + /// updating and removing timetables. |
| 77 | + /// |
| 78 | + /// To support this the method has three tasks: |
| 79 | + /// 1. Collect [TripPatternForDate]s which have invalidated data (`oldTripPatternsForDate`). |
| 80 | + /// Trips may change in multiple ways and because of that may move between [TripPattern]s. To |
| 81 | + /// track a [TripIdAndServiceDate] it's previous state needs to be stored so that all relevant |
| 82 | + /// places may be updated. |
| 83 | + /// * a trip may have a new (real-time) Timetable, which results in two updated [Timetable]s |
| 84 | + /// * a trip may move between scheduled [StopPattern]s and/or real-time [StopPattern]s |
| 85 | + /// 2. Collect [TripPatternForDate]s which have valid data (`newTripPatternsForDate`). |
| 86 | + /// There are two options: |
| 87 | + /// 1. an update was received |
| 88 | + /// 2. no update was received, and so the previous updated should be removed. If the update |
| 89 | + /// was for a scheduled trip, then the schedule should be restored. |
| 90 | + /// 3. Remove the `oldTripPatternsForDate` and add the `newTripPatternsForDate` to the |
| 91 | + /// [RaptorTransitData]. |
| 92 | + /// |
| 93 | + /// @param updatedTimetables that changed with the current snapshot |
| 94 | + /// @param timetables which are affected by real-time updates |
69 | 95 | public void update( |
70 | 96 | Collection<Timetable> updatedTimetables, |
71 | 97 | Map<TripPattern, SortedSet<Timetable>> timetables |
|
0 commit comments