Skip to content

Commit e2f0544

Browse files
committed
Dead end: decorate response with trip update -- not enough information available here, go one layer down.
1 parent eb18939 commit e2f0544

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

reader-gtfs/src/main/java/com/graphhopper/reader/gtfs/GraphHopperGtfs.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package com.graphhopper.reader.gtfs;
2020

21+
import com.conveyal.gtfs.model.Entity;
2122
import com.google.transit.realtime.GtfsRealtime;
2223
import com.graphhopper.*;
2324
import com.graphhopper.reader.osm.OSMReader;
@@ -221,14 +222,30 @@ private void parseSolutionsAndAddToResponse(List<Label> solutions, PointList way
221222
legs.addAll(0, walkPaths.get(accessNode(solution)).getLegs());
222223
legs.addAll(walkPaths.get(egressNode(solution)).getLegs());
223224
}
224-
final PathWrapper pathWrapper = tripFromLabel.createPathWrapper(translation, waypoints, legs);
225-
// TODO: remove
225+
PathWrapper pathWrapper = tripFromLabel.createPathWrapper(translation, waypoints, legs);
226+
pathWrapper = decorateWithRealtimeUpdates(pathWrapper);
226227
pathWrapper.setTime((solution.currentTime - initialTime.toEpochMilli()) * (arriveBy ? -1 : 1));
227228
response.add(pathWrapper);
228229
}
229230
response.getAll().sort(Comparator.comparingDouble(PathWrapper::getTime));
230231
}
231232

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+
232249
private int accessNode(Label solution) {
233250
if (!arriveBy) {
234251
while (solution.parent.parent != null) {

0 commit comments

Comments
 (0)