From 61a0025fe02ae128a54f97e82b9432ae475cbbfd Mon Sep 17 00:00:00 2001 From: Romain BERNARD <romain.bernard@uca.fr> Date: Thu, 29 Feb 2024 13:10:38 +0100 Subject: [PATCH] check next passage index before creating state --- .../Transit/TransitShortestPathPrecompute.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp b/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp index e20d98c..250a1a9 100644 --- a/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp +++ b/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp @@ -45,11 +45,16 @@ TransitStateContainer TransitShortestPathPrecompute::executeAlgorithm(const Grap if(currentState.getConnections().empty() || (currentState.getConnections().back().getLineRef() != lineStop.getLineRef() && currentState.getConnections().size() < 2)) // if new line is different than current line { - newState = TransitAlgorithmState(currentState, lineStop); - newState.setNodeIndex(nextNode); int nextPassageIndex = lineStop.getLineRef().findNextScheduledPassage(lineStop.getStopIndex(),currentState.getInstant()); - newState.setPassageIndex(nextPassageIndex); //get next passage for new line - newState.setInstant(lineStop.getLineRef().getInstant(lineStop.getStopIndex() + 1, nextPassageIndex)); //replace time with + if(nextPassageIndex == lineStop.getLineRef().scheduleSize()) { + newState.setInstant(INT16_MAX); + break; + } else { + newState = TransitAlgorithmState(currentState, lineStop); + newState.setNodeIndex(nextNode); + newState.setPassageIndex(nextPassageIndex); //get next passage for new line + newState.setInstant(lineStop.getLineRef().getInstant(lineStop.getStopIndex() + 1,nextPassageIndex)); //replace time with + } } else { newState = TransitAlgorithmState(currentState); newState.setNodeIndex(nextNode); -- GitLab