Skip to content

Commit

Permalink
also observe arrivals that end with a transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
mrieser committed Jun 12, 2024
1 parent 52712f6 commit 23ec96b
Showing 1 changed file with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -561,15 +561,7 @@ public Map<Id<TransitStopFacility>, TravelInfo> calcLeastCostTree(double depTime
if (observer != null) {
for (int stopIndex = this.improvedStops.nextSetBit(0); stopIndex >= 0; stopIndex = this.improvedStops.nextSetBit(stopIndex + 1)) {
PathElement fromPE = this.arrivalPathPerStop[stopIndex];
PathElement backpointer = fromPE.comingFrom;
if (backpointer != null) {
while (backpointer.comingFrom != null) {
backpointer = backpointer.comingFrom;
}
TransitStopFacility departureStopFacility = backpointer.toRouteStop.routeStop.getStopFacility();
TransitStopFacility arrivalStopFacility = fromPE.toRouteStop.routeStop.getStopFacility();
observer.arrivedAtStop(fromPE.firstDepartureTime, arrivalStopFacility, fromPE.arrivalTime, fromPE.transferCount, () -> createRaptorRoute(departureStopFacility, arrivalStopFacility, fromPE, fromPE.firstDepartureTime));
}
observeArrival(fromPE, observer);
}
}

Expand All @@ -581,7 +573,15 @@ public Map<Id<TransitStopFacility>, TravelInfo> calcLeastCostTree(double depTime
if (this.improvedRouteStopIndices.isEmpty()) {
break;
}
}

if (observer != null) {
for (int stopIndex = this.tmpImprovedStops.nextSetBit(0); stopIndex >= 0; stopIndex = this.tmpImprovedStops.nextSetBit(stopIndex + 1)) {
PathElement fromPE = this.arrivalPathPerStop[stopIndex];
observeArrival(fromPE, observer);
}
}

}

// collect information for each stop
Map<Id<TransitStopFacility>, TravelInfo> result = new HashMap<>();
Expand All @@ -597,6 +597,18 @@ public Map<Id<TransitStopFacility>, TravelInfo> calcLeastCostTree(double depTime
return result;
}

private void observeArrival(PathElement pe, RaptorObserver observer) {
PathElement backpointer = pe.comingFrom;
if (backpointer != null) {
while (backpointer.comingFrom != null) {
backpointer = backpointer.comingFrom;
}
TransitStopFacility departureStopFacility = backpointer.toRouteStop.routeStop.getStopFacility();
TransitStopFacility arrivalStopFacility = pe.toRouteStop.routeStop.getStopFacility();
observer.arrivedAtStop(pe.firstDepartureTime, arrivalStopFacility, pe.arrivalTime, pe.transferCount, () -> createRaptorRoute(departureStopFacility, arrivalStopFacility, pe, pe.firstDepartureTime));
}
}

private TravelInfo getTravelInfo(PathElement destination, RaptorParameters parameters) {
PathElement firstStage = destination;
PathElement secondStage = null;
Expand Down

0 comments on commit 23ec96b

Please sign in to comment.