diff --git a/src/libsumo/Person.cpp b/src/libsumo/Person.cpp index 0384845e728e..0577d5324d00 100644 --- a/src/libsumo/Person.cpp +++ b/src/libsumo/Person.cpp @@ -242,7 +242,7 @@ Person::getEdges(const std::string& personID, int nextStageIndex) { throw TraCIException("The negative stage index must refer to a valid previous stage."); } std::vector edgeIDs; - for (auto& e : p->getEdges(nextStageIndex)) { + for (auto& e : p->getNextStage(nextStageIndex)->getEdges()) { if (e != nullptr) { edgeIDs.push_back(e->getID()); } @@ -788,7 +788,7 @@ Person::rerouteTraveltime(const std::string& personID) { if (newEdges.empty()) { throw TraCIException("Could not find new route for person '" + personID + "'."); } - ConstMSEdgeVector oldEdges = p->getEdges(firstIndex); + ConstMSEdgeVector oldEdges = p->getNextStage(firstIndex)->getEdges(); assert(!oldEdges.empty()); if (oldEdges.front()->getFunction() != SumoXMLEdgeFunc::NORMAL) { oldEdges.erase(oldEdges.begin()); diff --git a/src/microsim/output/MSDetectorFileOutput.cpp b/src/microsim/output/MSDetectorFileOutput.cpp index 4e3f6ad59583..bb55a65084c5 100644 --- a/src/microsim/output/MSDetectorFileOutput.cpp +++ b/src/microsim/output/MSDetectorFileOutput.cpp @@ -84,7 +84,7 @@ MSDetectorFileOutput::vehicleApplies(const SUMOTrafficObject& veh) const { end = v.getRoute().end(); } else if (veh.isPerson()) { const MSTransportable& p = dynamic_cast(veh); - route = p.getEdges(0); + route = p.getCurrentStage()->getEdges(); it = route.begin() + p.getRoutePosition(); end = route.end(); } diff --git a/src/microsim/transportables/MSTransportable.h b/src/microsim/transportables/MSTransportable.h index 2be2ee42f5c5..4c23226a8511 100644 --- a/src/microsim/transportables/MSTransportable.h +++ b/src/microsim/transportables/MSTransportable.h @@ -233,18 +233,11 @@ class MSTransportable : public SUMOTrafficObject { return *myStep; } - /// @brief Return the current stage - MSStage* getNextStage(int next) const { - assert(myStep + next >= myPlan->begin()); - assert(myStep + next < myPlan->end()); - return *(myStep + next); - } - - /// @brief Return the edges of the nth next stage - ConstMSEdgeVector getEdges(int next) const { - assert(myStep + next < myPlan->end()); - assert(myStep + next >= myPlan->begin()); - return (*(myStep + next))->getEdges(); + /// @brief Return the next (or previous) stage denoted by the offset + inline MSStage* getNextStage(int offset) const { + assert(myStep + offset >= myPlan->begin()); + assert(myStep + offset < myPlan->end()); + return *(myStep + offset); } /// @brief returns the numerical IDs of edges to be used (possibly of future stages)