From e1e0512453be637c3774c5126557e9909b305843 Mon Sep 17 00:00:00 2001 From: m-kro Date: Wed, 9 Oct 2024 11:23:48 +0200 Subject: [PATCH] prevent incoherent position in routing to stop on first edge ref #15563 Signed-off-by: m-kro --- src/microsim/MSBaseVehicle.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/microsim/MSBaseVehicle.cpp b/src/microsim/MSBaseVehicle.cpp index 4d349020a563..6cc2190c0b62 100644 --- a/src/microsim/MSBaseVehicle.cpp +++ b/src/microsim/MSBaseVehicle.cpp @@ -279,8 +279,8 @@ MSBaseVehicle::reroute(SUMOTime t, const std::string& info, SUMOAbstractRouter jumps; if (myParameter->via.size() == 0) { - double firstPos = -1; - double lastPos = -1; + double firstPos = INVALID_DOUBLE; + double lastPos = INVALID_DOUBLE; stops = getStopEdges(firstPos, lastPos, jumps); if (stops.size() > 0) { double sourcePos = onInit ? 0 : getPositionOnLane(); @@ -1586,8 +1586,12 @@ MSBaseVehicle::getStopEdges(double& firstPos, double& lastPos, std::set& ju } } prev = &stop; - if (firstPos < 0) { - firstPos = stopPos; + if (firstPos == INVALID_DOUBLE) { + if (stop.parkingarea != nullptr && stop.edge == myRoute->begin()) { + firstPos = MAX2(0., stopPos); + } else { + firstPos = stopPos; + } } lastPos = stopPos; if (stop.pars.jump >= 0) {