From 23ec96b7619423da7110fe6f8c7cca2fbc5fb0ce Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Wed, 12 Jun 2024 22:45:01 +0200 Subject: [PATCH] also observe arrivals that end with a transfer --- .../pt/raptor/SwissRailRaptorCore.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java index 7e6a3a946be..100461b1529 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java @@ -561,15 +561,7 @@ public Map, 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); } } @@ -581,7 +573,15 @@ public Map, 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, TravelInfo> result = new HashMap<>(); @@ -597,6 +597,18 @@ public Map, 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;