|
18 | 18 |
|
19 | 19 | package com.graphhopper.reader.gtfs;
|
20 | 20 |
|
| 21 | +import com.conveyal.gtfs.model.Entity; |
21 | 22 | import com.google.transit.realtime.GtfsRealtime;
|
22 | 23 | import com.graphhopper.*;
|
23 | 24 | import com.graphhopper.reader.osm.OSMReader;
|
@@ -221,14 +222,30 @@ private void parseSolutionsAndAddToResponse(List<Label> solutions, PointList way
|
221 | 222 | legs.addAll(0, walkPaths.get(accessNode(solution)).getLegs());
|
222 | 223 | legs.addAll(walkPaths.get(egressNode(solution)).getLegs());
|
223 | 224 | }
|
224 |
| - final PathWrapper pathWrapper = tripFromLabel.createPathWrapper(translation, waypoints, legs); |
225 |
| - // TODO: remove |
| 225 | + PathWrapper pathWrapper = tripFromLabel.createPathWrapper(translation, waypoints, legs); |
| 226 | + pathWrapper = decorateWithRealtimeUpdates(pathWrapper); |
226 | 227 | pathWrapper.setTime((solution.currentTime - initialTime.toEpochMilli()) * (arriveBy ? -1 : 1));
|
227 | 228 | response.add(pathWrapper);
|
228 | 229 | }
|
229 | 230 | response.getAll().sort(Comparator.comparingDouble(PathWrapper::getTime));
|
230 | 231 | }
|
231 | 232 |
|
| 233 | + private PathWrapper decorateWithRealtimeUpdates(PathWrapper pathWrapper) { |
| 234 | + pathWrapper.getLegs().forEach(leg -> { |
| 235 | + if (leg instanceof Trip.PtLeg) { |
| 236 | + Trip.PtLeg ptLeg = (Trip.PtLeg) leg; |
| 237 | + final GtfsRealtime.TripDescriptor tripDescriptor = GtfsRealtime.TripDescriptor.newBuilder() |
| 238 | + .setTripId(ptLeg.trip_id) |
| 239 | + .build(); |
| 240 | + realtimeFeed.getTripUpdate(tripDescriptor).ifPresent(tripUpdate -> { |
| 241 | + ptLeg.stops.forEach(stop -> { |
| 242 | + }); |
| 243 | + }); |
| 244 | + } |
| 245 | + }); |
| 246 | + return pathWrapper; |
| 247 | + } |
| 248 | + |
232 | 249 | private int accessNode(Label solution) {
|
233 | 250 | if (!arriveBy) {
|
234 | 251 | while (solution.parent.parent != null) {
|
|
0 commit comments