LCOV - code coverage report
Current view: top level - src/libsumo - Vehicle.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 90.6 % 1709 1548
Test Date: 2026-10-12 15:53:19 Functions: 99.5 % 189 188

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2012-2026 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    Vehicle.cpp
      15              : /// @author  Jakob Erdmann
      16              : /// @author  Mirko Barthauer
      17              : /// @date    15.03.2017
      18              : ///
      19              : // C++ Vehicle API
      20              : /****************************************************************************/
      21              : #include <config.h>
      22              : 
      23              : #include <foreign/tcpip/storage.h>
      24              : #include <utils/geom/GeomHelper.h>
      25              : #include <utils/common/MsgHandler.h>
      26              : #include <utils/common/StringTokenizer.h>
      27              : #include <utils/common/StringUtils.h>
      28              : #include <utils/gui/globjects/GUIGlObjectTypes.h>
      29              : #include <utils/emissions/PollutantsInterface.h>
      30              : #include <utils/vehicle/SUMOVehicleParserHelper.h>
      31              : #include <microsim/traffic_lights/MSTrafficLightLogic.h>
      32              : #include <microsim/lcmodels/MSAbstractLaneChangeModel.h>
      33              : #include <microsim/devices/MSDevice.h>
      34              : #include <microsim/MSEdgeWeightsStorage.h>
      35              : #include <microsim/MSStop.h>
      36              : #include <microsim/MSVehicle.h>
      37              : #include <microsim/MSVehicleControl.h>
      38              : #include <microsim/MSVehicleTransfer.h>
      39              : #include <microsim/MSVehicleType.h>
      40              : #include <microsim/MSInsertionControl.h>
      41              : #include <microsim/MSNet.h>
      42              : #include <microsim/MSEdge.h>
      43              : #include <microsim/MSLane.h>
      44              : #include <microsim/MSParkingArea.h>
      45              : #include <microsim/MSJunctionLogic.h>
      46              : #include <microsim/devices/MSDevice_Taxi.h>
      47              : #include <microsim/devices/MSDispatch_TraCI.h>
      48              : #include <mesosim/MEVehicle.h>
      49              : #include <libsumo/StorageHelper.h>
      50              : #include <libsumo/TraCIDefs.h>
      51              : #include <libsumo/TraCIConstants.h>
      52              : #include "Helper.h"
      53              : #include "Route.h"
      54              : #include "Polygon.h"
      55              : #include "Vehicle.h"
      56              : 
      57              : #define CALL_MICRO_FUN(veh, fun, mesoResult) ((dynamic_cast<MSVehicle*>(veh) == nullptr ? (mesoResult) : dynamic_cast<MSVehicle*>(veh)->fun))
      58              : #define CALL_MESO_FUN(veh, fun, microResult) ((dynamic_cast<MEVehicle*>(veh) == nullptr ? (microResult) : dynamic_cast<MEVehicle*>(veh)->fun))
      59              : 
      60              : // ===========================================================================
      61              : // debug defines
      62              : // ===========================================================================
      63              : //#define DEBUG_NEIGHBORS
      64              : //#define DEBUG_DYNAMIC_SHAPES
      65              : //#define DEBUG_MOVEXY
      66              : #define DEBUG_COND (veh->isSelected())
      67              : 
      68              : 
      69              : 
      70              : namespace libsumo {
      71              : // ===========================================================================
      72              : // static member initializations
      73              : // ===========================================================================
      74              : SubscriptionResults Vehicle::mySubscriptionResults;
      75              : ContextSubscriptionResults Vehicle::myContextSubscriptionResults;
      76              : 
      77              : 
      78              : // ===========================================================================
      79              : // static member definitions
      80              : // ===========================================================================
      81              : bool
      82      8204931 : Vehicle::isVisible(const SUMOVehicle* veh) {
      83      8204931 :     return veh->isOnRoad() || veh->isParking() || veh->wasRemoteControlled();
      84              : }
      85              : 
      86              : 
      87              : bool
      88        23516 : Vehicle::isOnInit(const std::string& vehID) {
      89        23516 :     SUMOVehicle* sumoVehicle = MSNet::getInstance()->getVehicleControl().getVehicle(vehID);
      90        23516 :     return sumoVehicle == nullptr || sumoVehicle->getLane() == nullptr;
      91              : }
      92              : 
      93              : 
      94              : std::vector<std::string>
      95       197262 : Vehicle::getIDList() {
      96            0 :     std::vector<std::string> ids;
      97       197262 :     MSVehicleControl& c = MSNet::getInstance()->getVehicleControl();
      98      2112609 :     for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
      99      1915349 :         if (isVisible((*i).second)) {
     100      1890370 :             ids.push_back((*i).first);
     101              :         }
     102              :     }
     103       197260 :     return ids;
     104            2 : }
     105              : 
     106              : int
     107          143 : Vehicle::getIDCount() {
     108          143 :     return (int)getIDList().size();
     109              : }
     110              : 
     111              : 
     112              : double
     113       177349 : Vehicle::getSpeed(const std::string& vehID) {
     114       177349 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     115       177297 :     return isVisible(veh) ? veh->getSpeed() : INVALID_DOUBLE_VALUE;
     116              : }
     117              : 
     118              : double
     119           90 : Vehicle::getLateralSpeed(const std::string& vehID) {
     120           90 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     121           90 :     return isVisible(veh) ? CALL_MICRO_FUN(veh, getLaneChangeModel().getSpeedLat(), 0) : INVALID_DOUBLE_VALUE;
     122              : }
     123              : 
     124              : 
     125              : double
     126         4965 : Vehicle::getAcceleration(const std::string& vehID) {
     127         4965 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     128         4965 :     return isVisible(veh) ? CALL_MICRO_FUN(veh, getAcceleration(), 0) : INVALID_DOUBLE_VALUE;
     129              : }
     130              : 
     131              : 
     132              : double
     133         4135 : Vehicle::getSpeedWithoutTraCI(const std::string& vehID) {
     134         4135 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     135         4135 :     return isVisible(veh) ? CALL_MICRO_FUN(veh, getSpeedWithoutTraciInfluence(), veh->getSpeed()) : INVALID_DOUBLE_VALUE;
     136              : }
     137              : 
     138              : 
     139              : TraCIPosition
     140      1977105 : Vehicle::getPosition(const std::string& vehID, const bool includeZ) {
     141      1977105 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     142      1977095 :     if (isVisible(veh)) {
     143      1976921 :         return Helper::makeTraCIPosition(veh->getPosition(), includeZ);
     144              :     }
     145              :     return TraCIPosition();
     146              : }
     147              : 
     148              : 
     149              : TraCIPosition
     150          798 : Vehicle::getPosition3D(const std::string& vehID) {
     151          798 :     return getPosition(vehID, true);
     152              : }
     153              : 
     154              : 
     155              : double
     156          468 : Vehicle::getAngle(const std::string& vehID) {
     157          468 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     158          468 :     return isVisible(veh) ? GeomHelper::naviDegree(veh->getAngle()) : INVALID_DOUBLE_VALUE;
     159              : }
     160              : 
     161              : 
     162              : double
     163           18 : Vehicle::getSlope(const std::string& vehID) {
     164           18 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     165           18 :     return (veh->isOnRoad() || veh->isParking()) ? veh->getSlope() : INVALID_DOUBLE_VALUE;
     166              : }
     167              : 
     168              : 
     169              : std::string
     170      4123728 : Vehicle::getRoadID(const std::string& vehID) {
     171      4123728 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     172      4123726 :     return isVisible(veh) ? CALL_MICRO_FUN(veh, getLane()->getEdge().getID(), veh->getEdge()->getID()) : "";
     173              : }
     174              : 
     175              : 
     176              : std::string
     177        37623 : Vehicle::getLaneID(const std::string& vehID) {
     178        37623 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     179        37611 :     return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLane()->getID(), "") : "";
     180              : }
     181              : 
     182              : 
     183              : std::string
     184           44 : Vehicle::getShadowLaneID(const std::string& vehID) {
     185           44 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     186           44 :     MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
     187          128 :     return (microVeh != nullptr && microVeh->isOnRoad()) ? (Named::getIDSecure(microVeh->getLaneChangeModel().getShadowLane(),"")) : "";
     188              : }
     189              : 
     190              : 
     191              : int
     192        31562 : Vehicle::getLaneIndex(const std::string& vehID) {
     193        31562 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     194        31557 :     if (veh->isOnRoad()) {
     195        31499 :         MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
     196        31499 :         if (microVeh != nullptr) {
     197        31004 :             return microVeh->getLane()->getIndex();
     198              :         } else {
     199          495 :             MEVehicle* mesoVeh = dynamic_cast<MEVehicle*>(veh);
     200          495 :             return mesoVeh->getQueIndex();
     201              :         }
     202              :     } else {
     203              :         return INVALID_INT_VALUE;
     204              :     }
     205              : }
     206              : 
     207              : std::string
     208           99 : Vehicle::getSegmentID(const std::string& vehID) {
     209           99 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     210           95 :     return veh->isOnRoad() ? CALL_MESO_FUN(veh, getSegment()->getID(), "") : "";
     211              : }
     212              : 
     213              : int
     214           95 : Vehicle::getSegmentIndex(const std::string& vehID) {
     215           95 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     216           95 :     return veh->isOnRoad() ? CALL_MESO_FUN(veh, getSegment()->getIndex(), INVALID_INT_VALUE) : INVALID_INT_VALUE;
     217              : }
     218              : 
     219              : std::string
     220         2911 : Vehicle::getTypeID(const std::string& vehID) {
     221         2911 :     return Helper::getVehicleType(vehID).getID();
     222              : }
     223              : 
     224              : 
     225              : std::string
     226          135 : Vehicle::getRouteID(const std::string& vehID) {
     227          135 :     return Helper::getVehicle(vehID)->getRoute().getID();
     228              : }
     229              : 
     230              : 
     231              : double
     232           89 : Vehicle::getDeparture(const std::string& vehID) {
     233           89 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     234           89 :     return veh->hasDeparted() ? STEPS2TIME(veh->getDeparture()) : INVALID_DOUBLE_VALUE;
     235              : }
     236              : 
     237              : 
     238              : double
     239           89 : Vehicle::getDepartDelay(const std::string& vehID) {
     240           89 :     return STEPS2TIME(Helper::getVehicle(vehID)->getDepartDelay());
     241              : }
     242              : 
     243              : 
     244              : int
     245         3151 : Vehicle::getRouteIndex(const std::string& vehID) {
     246         3151 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     247         3151 :     return veh->hasDeparted() ? veh->getRoutePosition() : INVALID_INT_VALUE;
     248              : }
     249              : 
     250              : 
     251              : TraCIColor
     252          683 : Vehicle::getColor(const std::string& vehID) {
     253          683 :     return Helper::makeTraCIColor(Helper::getVehicle(vehID)->getParameter().color);
     254              : }
     255              : 
     256              : double
     257      4108790 : Vehicle::getLanePosition(const std::string& vehID) {
     258      4108790 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     259      4108785 :     return (veh->isOnRoad() || veh->isParking()) ? veh->getPositionOnLane() : INVALID_DOUBLE_VALUE;
     260              : }
     261              : 
     262              : double
     263         3300 : Vehicle::getLateralLanePosition(const std::string& vehID) {
     264         3300 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     265         3300 :     return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLateralPositionOnLane(), 0) : INVALID_DOUBLE_VALUE;
     266              : }
     267              : 
     268              : double
     269          451 : Vehicle::getCO2Emission(const std::string& vehID) {
     270          451 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     271          451 :     return isVisible(veh) ? veh->getEmissions<PollutantsInterface::CO2>() : INVALID_DOUBLE_VALUE;
     272              : }
     273              : 
     274              : double
     275           91 : Vehicle::getCOEmission(const std::string& vehID) {
     276           91 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     277           91 :     return isVisible(veh) ? veh->getEmissions<PollutantsInterface::CO>() : INVALID_DOUBLE_VALUE;
     278              : }
     279              : 
     280              : double
     281           91 : Vehicle::getHCEmission(const std::string& vehID) {
     282           91 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     283           91 :     return isVisible(veh) ? veh->getEmissions<PollutantsInterface::HC>() : INVALID_DOUBLE_VALUE;
     284              : }
     285              : 
     286              : double
     287           91 : Vehicle::getPMxEmission(const std::string& vehID) {
     288           91 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     289           91 :     return isVisible(veh) ? veh->getEmissions<PollutantsInterface::PM_X>() : INVALID_DOUBLE_VALUE;
     290              : }
     291              : 
     292              : double
     293           91 : Vehicle::getNOxEmission(const std::string& vehID) {
     294           91 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     295           91 :     return isVisible(veh) ? veh->getEmissions<PollutantsInterface::NO_X>() : INVALID_DOUBLE_VALUE;
     296              : }
     297              : 
     298              : double
     299          371 : Vehicle::getFuelConsumption(const std::string& vehID) {
     300          371 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     301          371 :     return isVisible(veh) ? veh->getEmissions<PollutantsInterface::FUEL>() : INVALID_DOUBLE_VALUE;
     302              : }
     303              : 
     304              : double
     305           91 : Vehicle::getNoiseEmission(const std::string& vehID) {
     306           91 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     307           91 :     return isVisible(veh) ? veh->getHarmonoise_NoiseEmissions() : INVALID_DOUBLE_VALUE;
     308              : }
     309              : 
     310              : double
     311          179 : Vehicle::getElectricityConsumption(const std::string& vehID) {
     312          179 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     313          179 :     return isVisible(veh) ? veh->getEmissions<PollutantsInterface::ELEC>() : INVALID_DOUBLE_VALUE;
     314              : }
     315              : 
     316              : int
     317          338 : Vehicle::getPersonNumber(const std::string& vehID) {
     318          338 :     return Helper::getVehicle(vehID)->getPersonNumber();
     319              : }
     320              : 
     321              : int
     322          351 : Vehicle::getPersonCapacity(const std::string& vehID) {
     323          351 :     return Helper::getVehicleType(vehID).getPersonCapacity();
     324              : }
     325              : 
     326              : 
     327              : double
     328           89 : Vehicle::getBoardingDuration(const std::string& vehID) {
     329           89 :     return STEPS2TIME(Helper::getVehicleType(vehID).getLoadingDuration(true));
     330              : }
     331              : 
     332              : 
     333              : std::vector<std::string>
     334          194 : Vehicle::getPersonIDList(const std::string& vehID) {
     335          194 :     return Helper::getVehicle(vehID)->getPersonIDList();
     336              : }
     337              : 
     338              : std::pair<std::string, double>
     339        39364 : Vehicle::getLeader(const std::string& vehID, double dist) {
     340        39364 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     341        39364 :     if (veh->isOnRoad()) {
     342        39283 :         std::pair<const MSVehicle* const, double> leaderInfo = veh->getLeader(dist, false);
     343        39283 :         const std::string leaderID = leaderInfo.first != nullptr ? leaderInfo.first->getID() : "";
     344        39283 :         double gap = leaderInfo.second;
     345              :         if (leaderInfo.first != nullptr
     346        30873 :                 && leaderInfo.first->getLane() != nullptr
     347        30873 :                 && leaderInfo.first->getLane()->isInternal()
     348          122 :                 && veh->getLane() != nullptr
     349        39405 :                 && (!veh->getLane()->isInternal()
     350            0 :                     || (veh->getLane()->getLinkCont().front()->getIndex() != leaderInfo.first->getLane()->getLinkCont().front()->getIndex()))) {
     351              :             // leader is a linkLeader (see MSLink::getLeaderInfo)
     352              :             // avoid internal gap values which may be negative (or -inf)
     353              :             gap = MAX2(0.0, gap);
     354              :         }
     355              :         return std::make_pair(leaderID, gap);
     356              :     } else {
     357              :         return std::make_pair("", -1);
     358              :     }
     359              : }
     360              : 
     361              : 
     362              : std::pair<std::string, double>
     363          243 : Vehicle::getFollower(const std::string& vehID, double dist) {
     364          243 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     365          239 :     if (veh->isOnRoad()) {
     366          231 :         std::pair<const MSVehicle* const, double> leaderInfo = veh->getFollower(dist);
     367              :         return std::make_pair(
     368          462 :                    leaderInfo.first != nullptr ? leaderInfo.first->getID() : "",
     369              :                    leaderInfo.second);
     370              :     } else {
     371              :         return std::make_pair("", -1);
     372              :     }
     373              : }
     374              : 
     375              : 
     376              : std::vector<TraCIJunctionFoe>
     377          158 : Vehicle::getJunctionFoes(const std::string& vehID, double dist) {
     378            0 :     std::vector<TraCIJunctionFoe> result;
     379          158 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
     380          158 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
     381          158 :     if (veh == nullptr) {
     382           64 :         WRITE_WARNING("getJunctionFoes not applicable for meso");
     383          126 :     } else if (veh->isOnRoad()) {
     384          126 :         if (dist == 0) {
     385           12 :             dist = veh->getCarFollowModel().brakeGap(veh->getSpeed()) + veh->getVehicleType().getMinGap();
     386              :         }
     387            0 :         const std::vector<const MSLane*> internalLanes;
     388              :         // distance to the end of the lane
     389          126 :         double curDist = -veh->getPositionOnLane();
     390          376 :         for (const MSLane* lane : veh->getUpcomingLanesUntil(dist)) {
     391          250 :             curDist += lane->getLength();
     392          250 :             if (lane->isInternal()) {
     393          116 :                 const MSLink* exitLink = lane->getLinkCont().front();
     394              :                 int foeIndex = 0;
     395              :                 const std::vector<MSLink::ConflictInfo>& conflicts = exitLink->getConflicts();
     396          116 :                 const MSJunctionLogic* logic = exitLink->getJunction()->getLogic();
     397          348 :                 for (const MSLane* foeLane : exitLink->getFoeLanes()) {
     398          232 :                     const MSLink::ConflictInfo& ci = conflicts[foeIndex];
     399          232 :                     if (ci.flag == MSLink::CONFLICT_NO_INTERSECTION) {
     400          112 :                         continue;
     401              :                     }
     402          120 :                     const double distBehindCrossing = ci.lengthBehindCrossing;
     403          120 :                     const MSLink* foeExitLink = foeLane->getLinkCont().front();
     404          120 :                     const double distToCrossing = curDist - distBehindCrossing;
     405          120 :                     const double foeDistBehindCrossing = ci.getFoeLengthBehindCrossing(foeExitLink);
     406          300 :                     for (auto item : foeExitLink->getApproaching()) {
     407              :                         const SUMOVehicle* foe = item.first;
     408              :                         TraCIJunctionFoe jf;
     409              :                         jf.foeId = foe->getID();
     410          180 :                         jf.egoDist = distToCrossing;
     411              :                         // approach information is from the start of the previous step
     412              :                         // but the foe vehicle then moved within that steop
     413          180 :                         const double prevFoeDist = SPEED2DIST(MSGlobals::gSemiImplicitEulerUpdate
     414              :                                                               ? foe->getSpeed()
     415              :                                                               : (foe->getSpeed() + foe->getPreviousSpeed()) / 2);
     416          180 :                         jf.foeDist = item.second.dist - foeDistBehindCrossing - prevFoeDist;
     417          180 :                         jf.egoExitDist = jf.egoDist + ci.conflictSize;
     418          180 :                         jf.foeExitDist = jf.foeDist + ci.getFoeConflictSize(foeExitLink);
     419              :                         jf.egoLane = lane->getID();
     420              :                         jf.foeLane = foeLane->getID();
     421          180 :                         jf.egoResponse = logic->getResponseFor(exitLink->getIndex()).test(foeExitLink->getIndex());
     422          180 :                         jf.foeResponse = logic->getResponseFor(foeExitLink->getIndex()).test(exitLink->getIndex());
     423          180 :                         result.push_back(jf);
     424          180 :                     }
     425          120 :                     foeIndex++;
     426              :                 }
     427              :             }
     428          126 :         }
     429          126 :     }
     430          158 :     return result;
     431            0 : }
     432              : 
     433              : 
     434              : double
     435          236 : Vehicle::getWaitingTime(const std::string& vehID) {
     436          236 :     return STEPS2TIME(Helper::getVehicle(vehID)->getWaitingTime());
     437              : }
     438              : 
     439              : 
     440              : double
     441          120 : Vehicle::getAccumulatedWaitingTime(const std::string& vehID) {
     442          120 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     443          120 :     return CALL_MICRO_FUN(veh, getAccumulatedWaitingSeconds(), INVALID_DOUBLE_VALUE);
     444              : }
     445              : 
     446              : 
     447              : double
     448          119 : Vehicle::getAdaptedTraveltime(const std::string& vehID, double time, const std::string& edgeID) {
     449          119 :     MSEdge* edge = Helper::getEdge(edgeID);
     450          119 :     double value = INVALID_DOUBLE_VALUE;
     451          119 :     Helper::getVehicle(vehID)->getWeightsStorage().retrieveExistingTravelTime(edge, time, value);
     452          119 :     return value;
     453              : }
     454              : 
     455              : 
     456              : double
     457          115 : Vehicle::getEffort(const std::string& vehID, double time, const std::string& edgeID) {
     458          115 :     MSEdge* edge = Helper::getEdge(edgeID);
     459          115 :     double value = INVALID_DOUBLE_VALUE;
     460          115 :     Helper::getVehicle(vehID)->getWeightsStorage().retrieveExistingEffort(edge, time, value);
     461          115 :     return value;
     462              : }
     463              : 
     464              : 
     465              : bool
     466           90 : Vehicle::isRouteValid(const std::string& vehID) {
     467              :     std::string msg;
     468          180 :     return Helper::getVehicle(vehID)->hasValidRoute(msg);
     469              : }
     470              : 
     471              : 
     472              : std::vector<std::string>
     473         3420 : Vehicle::getRoute(const std::string& vehID) {
     474            0 :     std::vector<std::string> result;
     475         3420 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     476         3420 :     const MSRoute& r = veh->getRoute();
     477        11481 :     for (MSRouteIterator i = r.begin(); i != r.end(); ++i) {
     478         8061 :         result.push_back((*i)->getID());
     479              :     }
     480         3420 :     return result;
     481            0 : }
     482              : 
     483              : 
     484              : int
     485           92 : Vehicle::getSignals(const std::string& vehID) {
     486           92 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     487           92 :     return CALL_MICRO_FUN(veh, getSignals(), MSVehicle::VEH_SIGNAL_NONE);
     488              : }
     489              : 
     490              : 
     491              : std::vector<TraCIBestLanesData>
     492           94 : Vehicle::getBestLanes(const std::string& vehID) {
     493            0 :     std::vector<TraCIBestLanesData> result;
     494           94 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(Helper::getVehicle(vehID));
     495           94 :     if (veh != nullptr && veh->isOnRoad()) {
     496          122 :         for (const MSVehicle::LaneQ& lq : veh->getBestLanes()) {
     497              :             TraCIBestLanesData bld;
     498           79 :             bld.laneID = lq.lane->getID();
     499           79 :             bld.length = lq.length;
     500           79 :             bld.occupation = lq.nextOccupation;
     501           79 :             bld.bestLaneOffset = lq.bestLaneOffset;
     502           79 :             bld.allowsContinuation = lq.allowsContinuation;
     503          370 :             for (const MSLane* const lane : lq.bestContinuations) {
     504          291 :                 if (lane != nullptr) {
     505          291 :                     bld.continuationLanes.push_back(lane->getID());
     506              :                 }
     507              :             }
     508           79 :             result.emplace_back(bld);
     509              :         }
     510              :     }
     511           94 :     return result;
     512            0 : }
     513              : 
     514              : 
     515              : std::vector<TraCINextTLSData>
     516         1356 : Vehicle::getNextTLS(const std::string& vehID) {
     517            0 :     std::vector<TraCINextTLSData> result;
     518         1356 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
     519         1341 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
     520         1341 :     if (veh != nullptr) {
     521              :         int view = 1;
     522         1098 :         double seen = veh->getEdge()->getLength() - veh->getPositionOnLane();
     523         1098 :         if (vehicle->isOnRoad()) {
     524         1058 :             const MSLane* lane = veh->getLane();
     525         1058 :             const std::vector<MSLane*>& bestLaneConts = veh->getBestLanesContinuation(lane);
     526         1058 :             seen = lane->getLength() - veh->getPositionOnLane();
     527         1058 :             std::vector<MSLink*>::const_iterator linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
     528         2978 :             while (!lane->isLinkEnd(linkIt)) {
     529         1920 :                 if (!lane->getEdge().isInternal()) {
     530          920 :                     if ((*linkIt)->isTLSControlled()) {
     531              :                         TraCINextTLSData ntd;
     532          668 :                         ntd.id = (*linkIt)->getTLLogic()->getID();
     533          668 :                         ntd.tlIndex = (*linkIt)->getTLIndex();
     534          668 :                         ntd.dist = seen;
     535          668 :                         ntd.state = (char)(*linkIt)->getState();
     536          668 :                         result.push_back(ntd);
     537              :                     }
     538              :                 }
     539         1920 :                 lane = (*linkIt)->getViaLaneOrLane();
     540         1920 :                 if (!lane->getEdge().isInternal()) {
     541          972 :                     view++;
     542              :                 }
     543         1920 :                 seen += lane->getLength();
     544         1920 :                 linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
     545              :             }
     546              :         }
     547              :         // consider edges beyond bestLanes
     548         1098 :         const int remainingEdges = (int)(veh->getRoute().end() - veh->getCurrentRouteEdge()) - view;
     549              :         //std::cout << SIMTIME << " remainingEdges=" << remainingEdges << " seen=" << seen << " view=" << view << " best=" << toString(bestLaneConts) << "\n";
     550         2246 :         for (int i = 0; i < remainingEdges; i++) {
     551         1148 :             const MSEdge* prev = *(veh->getCurrentRouteEdge() + view + i - 1);
     552         1148 :             const MSEdge* next = *(veh->getCurrentRouteEdge() + view + i);
     553         1148 :             const std::vector<MSLane*>* allowed = prev->allowedLanes(*next, veh->getVClass());
     554         1148 :             if (allowed != nullptr && allowed->size() != 0) {
     555         1272 :                 for (const MSLink* const link : allowed->front()->getLinkCont()) {
     556         1272 :                     if (&link->getLane()->getEdge() == next) {
     557         1148 :                         if (link->isTLSControlled()) {
     558              :                             TraCINextTLSData ntd;
     559              :                             ntd.id = link->getTLLogic()->getID();
     560          736 :                             ntd.tlIndex = link->getTLIndex();
     561          736 :                             ntd.dist = seen;
     562          736 :                             ntd.state = (char)link->getState();
     563          736 :                             result.push_back(ntd);
     564              :                         }
     565         1148 :                         seen += next->getLength() + link->getInternalLengthsAfter();
     566         1148 :                         break;
     567              :                     }
     568              :                 }
     569              :             } else {
     570              :                 // invalid route, cannot determine nextTLS
     571              :                 break;
     572              :             }
     573              :         }
     574              : 
     575              :     } else {
     576          486 :         WRITE_WARNING("getNextTLS not yet implemented for meso");
     577              :     }
     578         1341 :     return result;
     579           15 : }
     580              : 
     581              : std::vector<TraCINextStopData>
     582           93 : Vehicle::getNextStops(const std::string& vehID) {
     583           93 :     return getStops(vehID, 0);
     584              : }
     585              : 
     586              : std::vector<libsumo::TraCIConnection>
     587           36 : Vehicle::getNextLinks(const std::string& vehID) {
     588            0 :     std::vector<libsumo::TraCIConnection> result;
     589           36 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
     590           36 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
     591           36 :     if (!vehicle->isOnRoad()) {
     592              :         return result;
     593              :     }
     594           36 :     if (veh != nullptr) {
     595           33 :         const MSLane* lane = veh->getLane();
     596           33 :         const std::vector<MSLane*>& bestLaneConts = veh->getBestLanesContinuation(lane);
     597              :         int view = 1;
     598           33 :         const SUMOTime currTime = MSNet::getInstance()->getCurrentTimeStep();
     599           33 :         std::vector<MSLink*>::const_iterator linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
     600           93 :         while (!lane->isLinkEnd(linkIt)) {
     601           60 :             if (!lane->getEdge().isInternal()) {
     602           54 :                 const MSLink* link = (*linkIt);
     603          108 :                 const std::string approachedLane = link->getLane() != nullptr ? link->getLane()->getID() : "";
     604              :                 const bool hasPrio = link->havePriority();
     605              :                 const double speed = MIN2(lane->getSpeedLimit(), link->getLane()->getSpeedLimit());
     606           54 :                 const bool isOpen = link->opened(currTime, speed, speed, veh->getLength(),
     607           54 :                                                  veh->getImpatience(), veh->getVehicleType().getCarFollowModel().getMaxDecel(),
     608           54 :                                                  veh->getWaitingTime(), veh->getLateralPositionOnLane(), nullptr, false, veh);
     609           54 :                 const bool hasFoe = link->hasApproachingFoe(currTime, currTime, 0, SUMOVTypeParameter::getDefaultDecel());
     610           60 :                 const std::string approachedInternal = link->getViaLane() != nullptr ? link->getViaLane()->getID() : "";
     611           54 :                 const std::string state = SUMOXMLDefinitions::LinkStates.getString(link->getState());
     612           54 :                 const std::string direction = SUMOXMLDefinitions::LinkDirections.getString(link->getDirection());
     613              :                 const double length = link->getLength();
     614          162 :                 result.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
     615              :             }
     616           60 :             lane = (*linkIt)->getViaLaneOrLane();
     617           60 :             if (!lane->getEdge().isInternal()) {
     618           54 :                 view++;
     619              :             }
     620           60 :             linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
     621              :         }
     622              :         // consider edges beyond bestLanes
     623           33 :         const int remainingEdges = (int)(veh->getRoute().end() - veh->getCurrentRouteEdge()) - view;
     624           33 :         for (int i = 0; i < remainingEdges; i++) {
     625            0 :             const MSEdge* prev = *(veh->getCurrentRouteEdge() + view + i - 1);
     626            0 :             const MSEdge* next = *(veh->getCurrentRouteEdge() + view + i);
     627            0 :             const std::vector<MSLane*>* allowed = prev->allowedLanes(*next, veh->getVClass());
     628            0 :             if (allowed != nullptr && allowed->size() != 0) {
     629            0 :                 for (const MSLink* const link : allowed->front()->getLinkCont()) {
     630            0 :                     if (&link->getLane()->getEdge() == next) {
     631              :                         const std::string approachedLane = link->getLane() != nullptr ? link->getLane()->getID() : "";
     632              :                         const bool hasPrio = link->havePriority();
     633              :                         const double speed = MIN2(lane->getSpeedLimit(), link->getLane()->getSpeedLimit());
     634            0 :                         const bool isOpen = link->opened(currTime, speed, speed, veh->getLength(),
     635            0 :                                                          veh->getImpatience(), veh->getVehicleType().getCarFollowModel().getMaxDecel(),
     636            0 :                                                          veh->getWaitingTime(), veh->getLateralPositionOnLane(), nullptr, false, veh);
     637            0 :                         const bool hasFoe = link->hasApproachingFoe(currTime, currTime, 0, SUMOVTypeParameter::getDefaultDecel());
     638            0 :                         const std::string approachedInternal = link->getViaLane() != nullptr ? link->getViaLane()->getID() : "";
     639            0 :                         const std::string state = SUMOXMLDefinitions::LinkStates.getString(link->getState());
     640            0 :                         const std::string direction = SUMOXMLDefinitions::LinkDirections.getString(link->getDirection());
     641              :                         const double length = link->getLength();
     642            0 :                         result.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
     643              :                     }
     644              :                 }
     645              :             } else {
     646              :                 // invalid route, cannot determine nextTLS
     647              :                 break;
     648              :             }
     649              :         }
     650              :     } else {
     651            6 :         WRITE_WARNING("getNextLinks not yet implemented for meso");
     652              :     }
     653              :     return result;
     654            0 : }
     655              : 
     656              : std::vector<TraCINextStopData>
     657         3855 : Vehicle::getStops(const std::string& vehID, int limit) {
     658            0 :     std::vector<TraCINextStopData> result;
     659         3855 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
     660         3849 :     if (limit < 0) {
     661              :         // return past stops up to the given limit
     662              :         const StopParVector& pastStops = vehicle->getPastStops();
     663          518 :         const int n = (int)pastStops.size();
     664         1542 :         for (int i = MAX2(0, n + limit); i < n; i++) {
     665         2048 :             result.push_back(Helper::buildStopData(pastStops[i]));
     666              :         }
     667              :     } else {
     668        11228 :         for (const MSStop& stop : vehicle->getStops()) {
     669         8453 :             if (!stop.pars.collision) {
     670         8453 :                 TraCINextStopData nsd = Helper::buildStopData(stop.pars);
     671         8453 :                 nsd.duration = STEPS2TIME(stop.duration);
     672         8453 :                 result.push_back(nsd);
     673         8453 :                 if (limit > 0 && (int)result.size() >= limit) {
     674              :                     break;
     675              :                 }
     676         8453 :             }
     677              :         }
     678              :     }
     679         3849 :     return result;
     680            6 : }
     681              : 
     682              : 
     683              : int
     684         1782 : Vehicle::getStopState(const std::string& vehID) {
     685         1782 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
     686         1782 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
     687         1782 :     if (veh == nullptr) {
     688          444 :         WRITE_WARNING("getStopState not yet implemented for meso");
     689          444 :         return 0;
     690              :     }
     691              :     int result = 0;
     692         1338 :     if (veh->isStopped()) {
     693          237 :         const MSStop& stop = veh->getNextStop();
     694          237 :         result = stop.getStateFlagsOld();
     695              :     }
     696              :     return result;
     697              : }
     698              : 
     699              : 
     700              : double
     701          618 : Vehicle::getDistance(const std::string& vehID) {
     702          618 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     703          613 :     if (veh->hasDeparted()) {
     704          568 :         return veh->getOdometer();
     705              :     } else {
     706              :         return INVALID_DOUBLE_VALUE;
     707              :     }
     708              : }
     709              : 
     710              : 
     711              : double
     712         3274 : Vehicle::getDrivingDistance(const std::string& vehID, const std::string& edgeID, double pos, int laneIndex) {
     713         3274 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     714         3274 :     MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
     715         3274 :     if (veh->isOnRoad()) {
     716         3229 :         const MSLane* lane = microVeh != nullptr ? veh->getLane() : veh->getEdge()->getLanes()[0];
     717         6458 :         double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), pos,
     718         3229 :                           lane, Helper::getLaneChecking(edgeID, laneIndex, pos), veh->getRoutePosition());
     719         3229 :         if (distance == std::numeric_limits<double>::max()) {
     720              :             return INVALID_DOUBLE_VALUE;
     721              :         }
     722              :         return distance;
     723              :     } else {
     724              :         return INVALID_DOUBLE_VALUE;
     725              :     }
     726              : }
     727              : 
     728              : 
     729              : double
     730           91 : Vehicle::getDrivingDistance2D(const std::string& vehID, double x, double y) {
     731           91 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     732           91 :     if (veh == nullptr) {
     733              :         return INVALID_DOUBLE_VALUE;
     734              :     }
     735           91 :     if (veh->isOnRoad()) {
     736           46 :         MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
     737           46 :         const MSLane* lane = microVeh != nullptr ? veh->getLane() : veh->getEdge()->getLanes()[0];
     738           46 :         std::pair<MSLane*, double> roadPos = Helper::convertCartesianToRoadMap(Position(x, y), veh->getVehicleType().getVehicleClass());
     739           92 :         double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), roadPos.second,
     740           46 :                           lane, roadPos.first, veh->getRoutePosition());
     741           46 :         if (distance == std::numeric_limits<double>::max()) {
     742              :             return INVALID_DOUBLE_VALUE;
     743              :         }
     744           36 :         return distance;
     745              :     } else {
     746              :         return INVALID_DOUBLE_VALUE;
     747              :     }
     748              : }
     749              : 
     750              : 
     751              : double
     752           89 : Vehicle::getReferenceDistance(const std::string& vehID) {
     753           89 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     754           89 :     if (veh->hasDeparted()) {
     755           44 :         double lanePos = veh->getPositionOnLane();
     756           44 :         MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
     757           44 :         if (microVeh != nullptr && microVeh->getLane()->isInternal()) {
     758            0 :             lanePos = microVeh->getRoute().getDistanceBetween(0., lanePos, microVeh->getEdge()->getLanes()[0],
     759            0 :                       microVeh->getLane(), microVeh->getRoutePosition());
     760              :         }
     761           44 :         return veh->getEdge()->getDistanceAt(lanePos);
     762              :     } else {
     763              :         return INVALID_DOUBLE_VALUE;
     764              :     }
     765              : }
     766              : 
     767              : 
     768              : double
     769           89 : Vehicle::getAllowedSpeed(const std::string& vehID) {
     770           89 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     771           89 :     return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLane()->getVehicleMaxSpeed(veh), veh->getEdge()->getVehicleMaxSpeed(veh)) : INVALID_DOUBLE_VALUE;
     772              : }
     773              : 
     774              : 
     775              : double
     776          189 : Vehicle::getSpeedFactor(const std::string& vehID) {
     777          189 :     return Helper::getVehicle(vehID)->getChosenSpeedFactor();
     778              : }
     779              : 
     780              : 
     781              : int
     782           76 : Vehicle::getSpeedMode(const std::string& vehID) {
     783           76 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     784           76 :     return CALL_MICRO_FUN(veh, getInfluencer().getSpeedMode(), INVALID_INT_VALUE);
     785              : }
     786              : 
     787              : 
     788              : int
     789          178 : Vehicle::getLaneChangeMode(const std::string& vehID) {
     790          178 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     791          178 :     return CALL_MICRO_FUN(veh, getInfluencer().getLaneChangeMode(), INVALID_INT_VALUE);
     792              : }
     793              : 
     794              : 
     795              : int
     796          187 : Vehicle::getRoutingMode(const std::string& vehID) {
     797          187 :     return Helper::getVehicle(vehID)->getRoutingMode();
     798              : }
     799              : 
     800              : 
     801              : std::string
     802           90 : Vehicle::getLine(const std::string& vehID) {
     803           90 :     return Helper::getVehicle(vehID)->getParameter().line;
     804              : }
     805              : 
     806              : 
     807              : std::vector<std::string>
     808           90 : Vehicle::getVia(const std::string& vehID) {
     809           90 :     return Helper::getVehicle(vehID)->getParameter().via;
     810              : }
     811              : 
     812              : 
     813              : std::pair<int, int>
     814        14101 : Vehicle::getLaneChangeState(const std::string& vehID, int direction) {
     815        14101 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     816        14101 :     auto undefined = std::make_pair((int)LCA_UNKNOWN, (int)LCA_UNKNOWN);
     817        14101 :     return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLaneChangeModel().getSavedState(direction), undefined) : undefined;
     818              : }
     819              : 
     820              : 
     821              : std::string
     822        49602 : Vehicle::getParameter(const std::string& vehID, const std::string& key) {
     823        49602 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
     824              :     std::string error;
     825        49602 :     std::string result = veh->getPrefixedParameter(key, error);
     826        49602 :     if (error != "") {
     827          150 :         throw TraCIException(error);
     828              :     }
     829        49527 :     return result;
     830              : }
     831              : 
     832              : 
     833          104 : LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(Vehicle)
     834              : 
     835              : 
     836              : std::vector<std::pair<std::string, double> >
     837         4640 : Vehicle::getNeighbors(const std::string& vehID, const int mode) {
     838         4640 :     int dir = (1 & mode) != 0 ? -1 : 1;
     839         4640 :     bool queryLeaders = (2 & mode) != 0;
     840         4640 :     bool blockersOnly = (4 & mode) != 0;
     841         4640 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
     842         4640 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
     843            0 :     std::vector<std::pair<std::string, double> > result;
     844         4640 :     if (veh == nullptr) {
     845              :         return result;
     846              :     }
     847              : #ifdef DEBUG_NEIGHBORS
     848              :     if (DEBUG_COND) {
     849              :         std::cout << "getNeighbors() for veh '" << vehID << "': dir=" << dir
     850              :                   << ", queryLeaders=" << queryLeaders
     851              :                   << ", blockersOnly=" << blockersOnly << std::endl;
     852              :     }
     853              : #endif
     854         3430 :     if (veh->getLaneChangeModel().isOpposite()) {
     855              :         // getParallelLane works relative to lane forward direction
     856           96 :         dir *= -1;
     857              :     }
     858              : 
     859         3430 :     MSLane* targetLane = veh->getLane()->getParallelLane(dir);
     860         3430 :     if (targetLane == nullptr) {
     861              :         return result;
     862              :     }
     863              :     // need to recompute leaders and followers (#8119)
     864         2966 :     const bool opposite = &veh->getLane()->getEdge() != &targetLane->getEdge();
     865         2966 :     MSLeaderDistanceInfo neighbors(targetLane->getWidth(), nullptr, 0.);
     866         2966 :     if (queryLeaders) {
     867         1480 :         if (opposite) {
     868          232 :             double pos = targetLane->getOppositePos(veh->getPositionOnLane());
     869          232 :             neighbors = targetLane->getFollowersOnConsecutive(veh, pos, true);
     870              :         } else {
     871         1248 :             targetLane->addLeaders(veh, veh->getPositionOnLane(), neighbors);
     872              :         }
     873              :     } else {
     874         1486 :         if (opposite) {
     875          232 :             double pos = targetLane->getOppositePos(veh->getPositionOnLane());
     876          232 :             targetLane->addLeaders(veh, pos, neighbors);
     877          232 :             neighbors.fixOppositeGaps(true);
     878              :         } else {
     879         1254 :             neighbors = targetLane->getFollowersOnConsecutive(veh, veh->getBackPositionOnLane(), true);
     880              :         }
     881              :     }
     882         2966 :     if (blockersOnly) {
     883              :         // filter out vehicles that aren't blocking
     884         1480 :         MSLeaderDistanceInfo blockers(targetLane->getWidth(), nullptr, 0.);
     885         4832 :         for (int i = 0; i < neighbors.numSublanes(); i++) {
     886         3352 :             CLeaderDist n = neighbors[i];
     887         3352 :             if (n.first != nullptr) {
     888              :                 const MSVehicle* follower = veh;
     889              :                 const MSVehicle* leader = n.first;
     890         2132 :                 if (!queryLeaders) {
     891              :                     std::swap(follower, leader);
     892              :                 }
     893         4264 :                 const double secureGap = (follower->getCarFollowModel().getSecureGap(
     894         2132 :                                               follower, leader, follower->getSpeed(), leader->getSpeed(), leader->getCarFollowModel().getMaxDecel())
     895         2132 :                                           * follower->getLaneChangeModel().getSafetyFactor());
     896         2132 :                 if (n.second < secureGap) {
     897          936 :                     blockers.addLeader(n.first, n.second, 0, i);
     898              :                 }
     899              :             }
     900              :         }
     901         1480 :         neighbors = blockers;
     902         1480 :     }
     903              : 
     904         2966 :     if (neighbors.hasVehicles()) {
     905         5260 :         for (int i = 0; i < neighbors.numSublanes(); i++) {
     906         3776 :             CLeaderDist n = neighbors[i];
     907         3776 :             if (n.first != nullptr &&
     908              :                     // avoid duplicates
     909         1596 :                     (result.size() == 0 || result.back().first != n.first->getID())) {
     910         1888 :                 result.push_back(std::make_pair(n.first->getID(), n.second));
     911              :             }
     912              :         }
     913              :     }
     914              :     return result;
     915         2966 : }
     916              : 
     917              : 
     918              : double
     919          717 : Vehicle::getFollowSpeed(const std::string& vehID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
     920          717 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
     921          717 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
     922          717 :     if (veh == nullptr) {
     923            2 :         WRITE_ERROR("getFollowSpeed not applicable for meso");
     924            2 :         return INVALID_DOUBLE_VALUE;
     925              :     }
     926          715 :     MSVehicle* leader = dynamic_cast<MSVehicle*>(MSNet::getInstance()->getVehicleControl().getVehicle(leaderID));
     927          715 :     return veh->getCarFollowModel().followSpeed(veh, speed, gap, leaderSpeed, leaderMaxDecel, leader, MSCFModel::CalcReason::FUTURE);
     928              : }
     929              : 
     930              : 
     931              : double
     932           17 : Vehicle::getSecureGap(const std::string& vehID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
     933           17 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
     934           17 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
     935           17 :     if (veh == nullptr) {
     936            2 :         WRITE_ERROR("getSecureGap not applicable for meso");
     937            2 :         return INVALID_DOUBLE_VALUE;
     938              :     }
     939           15 :     MSVehicle* leader = dynamic_cast<MSVehicle*>(MSNet::getInstance()->getVehicleControl().getVehicle(leaderID));
     940           15 :     return veh->getCarFollowModel().getSecureGap(veh, leader, speed, leaderSpeed, leaderMaxDecel);
     941              : }
     942              : 
     943              : 
     944              : double
     945           17 : Vehicle::getStopSpeed(const std::string& vehID, const double speed, double gap) {
     946           17 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
     947           17 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
     948           17 :     if (veh == nullptr) {
     949            2 :         WRITE_ERROR("getStopSpeed not applicable for meso");
     950            2 :         return INVALID_DOUBLE_VALUE;
     951              :     }
     952           15 :     return veh->getCarFollowModel().stopSpeed(veh, speed, gap, MSCFModel::CalcReason::FUTURE);
     953              : }
     954              : 
     955              : double
     956         1760 : Vehicle::getStopDelay(const std::string& vehID) {
     957         1760 :     return Helper::getVehicle(vehID)->getStopDelay();
     958              : }
     959              : 
     960              : 
     961              : double
     962          116 : Vehicle::getImpatience(const std::string& vehID) {
     963          116 :     return Helper::getVehicle(vehID)->getImpatience();
     964              : }
     965              : 
     966              : 
     967              : double
     968         1759 : Vehicle::getStopArrivalDelay(const std::string& vehID) {
     969         1759 :     double result = Helper::getVehicle(vehID)->getStopArrivalDelay();
     970         1759 :     if (result == INVALID_DOUBLE) {
     971              :         return INVALID_DOUBLE_VALUE;
     972              :     } else {
     973         1289 :         return result;
     974              :     }
     975              : }
     976              : 
     977              : double
     978           89 : Vehicle::getTimeLoss(const std::string& vehID) {
     979           89 :     return Helper::getVehicle(vehID)->getTimeLossSeconds();
     980              : }
     981              : 
     982              : std::vector<std::string>
     983         9425 : Vehicle::getTaxiFleet(int taxiState) {
     984            0 :     std::vector<std::string> result;
     985        23083 :     for (MSDevice_Taxi* taxi : MSDevice_Taxi::getFleet()) {
     986        13658 :         if (taxi->getHolder().hasDeparted()) {
     987              :             if (taxiState == -1
     988         9432 :                     || (taxiState == 0 && taxi->getState() == 0)
     989        19998 :                     || (taxiState != 0 && (taxi->getState() & taxiState) == taxiState)) {
     990         6135 :                 result.push_back(taxi->getHolder().getID());
     991              :             }
     992              :         }
     993              :     }
     994         9425 :     return result;
     995            0 : }
     996              : 
     997              : std::vector<std::string>
     998          222 : Vehicle::getLoadedIDList() {
     999            0 :     std::vector<std::string> ids;
    1000          222 :     MSVehicleControl& c = MSNet::getInstance()->getVehicleControl();
    1001          675 :     for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
    1002          453 :         ids.push_back(i->first);
    1003              :     }
    1004          222 :     return ids;
    1005            0 : }
    1006              : 
    1007              : std::vector<std::string>
    1008          177 : Vehicle::getTeleportingIDList() {
    1009            0 :     std::vector<std::string> ids;
    1010          177 :     MSVehicleControl& c = MSNet::getInstance()->getVehicleControl();
    1011          608 :     for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
    1012          431 :         SUMOVehicle* veh = i->second;
    1013          431 :         if (veh->hasDeparted() && !isVisible(veh)) {
    1014           80 :             ids.push_back(veh->getID());
    1015              :         }
    1016              :     }
    1017          177 :     return ids;
    1018            0 : }
    1019              : 
    1020              : std::string
    1021           76 : Vehicle::getEmissionClass(const std::string& vehID) {
    1022           76 :     return PollutantsInterface::getName(Helper::getVehicleType(vehID).getEmissionClass());
    1023              : }
    1024              : 
    1025              : std::string
    1026           36 : Vehicle::getShapeClass(const std::string& vehID) {
    1027           36 :     return getVehicleShapeName(Helper::getVehicleType(vehID).getGuiShape());
    1028              : }
    1029              : 
    1030              : 
    1031              : double
    1032           38 : Vehicle::getLength(const std::string& vehID) {
    1033           38 :     return Helper::getVehicleType(vehID).getLength();
    1034              : }
    1035              : 
    1036              : 
    1037              : double
    1038           38 : Vehicle::getAccel(const std::string& vehID) {
    1039           38 :     return Helper::getVehicleType(vehID).getCarFollowModel().getMaxAccel();
    1040              : }
    1041              : 
    1042              : 
    1043              : double
    1044          400 : Vehicle::getDecel(const std::string& vehID) {
    1045          400 :     return Helper::getVehicleType(vehID).getCarFollowModel().getMaxDecel();
    1046              : }
    1047              : 
    1048              : 
    1049           42 : double Vehicle::getEmergencyDecel(const std::string& vehID) {
    1050           42 :     return Helper::getVehicleType(vehID).getCarFollowModel().getEmergencyDecel();
    1051              : }
    1052              : 
    1053              : 
    1054           38 : double Vehicle::getApparentDecel(const std::string& vehID) {
    1055           38 :     return Helper::getVehicleType(vehID).getCarFollowModel().getApparentDecel();
    1056              : }
    1057              : 
    1058              : 
    1059           38 : double Vehicle::getActionStepLength(const std::string& vehID) {
    1060           38 :     return Helper::getVehicleType(vehID).getActionStepLengthSecs();
    1061              : }
    1062              : 
    1063              : 
    1064           89 : double Vehicle::getLastActionTime(const std::string& vehID) {
    1065           89 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    1066           89 :     MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
    1067           89 :     if (microVeh != nullptr) {
    1068           78 :         return STEPS2TIME(microVeh->getLastActionTime());
    1069              :     } else {
    1070           11 :         MEVehicle* mesoVeh = dynamic_cast<MEVehicle*>(veh);
    1071           11 :         return STEPS2TIME(mesoVeh->getEventTime());
    1072              :     }
    1073              : }
    1074              : 
    1075              : 
    1076              : double
    1077           38 : Vehicle::getTau(const std::string& vehID) {
    1078           38 :     return Helper::getVehicleType(vehID).getCarFollowModel().getHeadwayTime();
    1079              : }
    1080              : 
    1081              : 
    1082              : double
    1083           40 : Vehicle::getImperfection(const std::string& vehID) {
    1084           40 :     return Helper::getVehicleType(vehID).getCarFollowModel().getImperfection();
    1085              : }
    1086              : 
    1087              : 
    1088              : double
    1089           36 : Vehicle::getSpeedDeviation(const std::string& vehID) {
    1090           36 :     return Helper::getVehicleType(vehID).getSpeedFactor().getParameter(1);
    1091              : }
    1092              : 
    1093              : 
    1094              : std::string
    1095           36 : Vehicle::getVehicleClass(const std::string& vehID) {
    1096           36 :     return toString(Helper::getVehicleType(vehID).getVehicleClass());
    1097              : }
    1098              : 
    1099              : 
    1100              : double
    1101           90 : Vehicle::getMinGap(const std::string& vehID) {
    1102           90 :     return Helper::getVehicleType(vehID).getMinGap();
    1103              : }
    1104              : 
    1105              : 
    1106              : double
    1107           89 : Vehicle::getMinGapLat(const std::string& vehID) {
    1108              :     try {
    1109          125 :         return StringUtils::toDouble(getParameter(vehID, "laneChangeModel.minGapLat"));
    1110           53 :     } catch (const TraCIException&) {
    1111              :         // legacy behavior
    1112           53 :         return Helper::getVehicleType(vehID).getMinGapLat();
    1113           53 :     }
    1114              : }
    1115              : 
    1116              : 
    1117              : double
    1118           38 : Vehicle::getMaxSpeed(const std::string& vehID) {
    1119           38 :     return Helper::getVehicleType(vehID).getMaxSpeed();
    1120              : }
    1121              : 
    1122              : 
    1123              : double
    1124           36 : Vehicle::getMaxSpeedLat(const std::string& vehID) {
    1125           36 :     return Helper::getVehicleType(vehID).getMaxSpeedLat();
    1126              : }
    1127              : 
    1128              : 
    1129              : std::string
    1130           36 : Vehicle::getLateralAlignment(const std::string& vehID) {
    1131           36 :     return toString(Helper::getVehicleType(vehID).getPreferredLateralAlignment());
    1132              : }
    1133              : 
    1134              : 
    1135              : double
    1136           38 : Vehicle::getWidth(const std::string& vehID) {
    1137           38 :     return Helper::getVehicleType(vehID).getWidth();
    1138              : }
    1139              : 
    1140              : 
    1141              : double
    1142           36 : Vehicle::getHeight(const std::string& vehID) {
    1143           36 :     return Helper::getVehicleType(vehID).getHeight();
    1144              : }
    1145              : 
    1146              : 
    1147              : double
    1148           44 : Vehicle::getMass(const std::string& vehID) {
    1149           44 :     return Helper::getVehicleType(vehID).getMass();
    1150              : }
    1151              : 
    1152              : 
    1153              : void
    1154        47617 : Vehicle::setStop(const std::string& vehID,
    1155              :                  const std::string& edgeID,
    1156              :                  double pos,
    1157              :                  int laneIndex,
    1158              :                  double duration,
    1159              :                  int flags,
    1160              :                  double startPos,
    1161              :                  double until) {
    1162        47617 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1163              :     SUMOVehicleParameter::Stop stopPars = Helper::buildStopParameters(edgeID,
    1164        47612 :                                           pos, laneIndex, startPos, flags, duration, until);
    1165              :     std::string error;
    1166        47626 :     if (!vehicle->addTraciStop(stopPars, error)) {
    1167           28 :         throw TraCIException(error);
    1168              :     }
    1169        47612 : }
    1170              : 
    1171              : 
    1172              : void
    1173          210 : Vehicle::replaceStop(const std::string& vehID,
    1174              :                      int nextStopIndex,
    1175              :                      const std::string& edgeID,
    1176              :                      double pos,
    1177              :                      int laneIndex,
    1178              :                      double duration,
    1179              :                      int flags,
    1180              :                      double startPos,
    1181              :                      double until,
    1182              :                      int teleport) {
    1183          210 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1184              :     std::string error;
    1185          208 :     if (edgeID == "") {
    1186              :         // only remove stop
    1187           84 :         const bool ok = vehicle->abortNextStop(nextStopIndex);
    1188           84 :         if (teleport != 0) {
    1189          118 :             if (!vehicle->rerouteBetweenStops(nextStopIndex, "traci:replaceStop", (teleport & 1), error)) {
    1190            0 :                 throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (" + error + ").");
    1191              :             }
    1192              :         } else {
    1193           33 :             MSVehicle* msVeh = dynamic_cast<MSVehicle*>(vehicle);
    1194           33 :             if (msVeh->getLane() != nullptr) {
    1195           27 :                 msVeh->updateBestLanes(true);
    1196              :             }
    1197              :         }
    1198           84 :         if (!ok) {
    1199            0 :             throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (invalid nextStopIndex).");
    1200              :         }
    1201              :     } else {
    1202              :         SUMOVehicleParameter::Stop stopPars = Helper::buildStopParameters(edgeID,
    1203          124 :                                               pos, laneIndex, startPos, flags, duration, until);
    1204              : 
    1205          124 :         if (!vehicle->replaceStop(nextStopIndex, stopPars, "traci:replaceStop", teleport != 0, error)) {
    1206           32 :             throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (" + error + ").");
    1207              :         }
    1208          124 :     }
    1209          192 : }
    1210              : 
    1211              : 
    1212              : void
    1213          232 : Vehicle::insertStop(const std::string& vehID,
    1214              :                     int nextStopIndex,
    1215              :                     const std::string& edgeID,
    1216              :                     double pos,
    1217              :                     int laneIndex,
    1218              :                     double duration,
    1219              :                     int flags,
    1220              :                     double startPos,
    1221              :                     double until,
    1222              :                     int teleport) {
    1223          232 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1224              :     SUMOVehicleParameter::Stop stopPars = Helper::buildStopParameters(edgeID,
    1225          232 :                                           pos, laneIndex, startPos, flags, duration, until);
    1226              : 
    1227              :     std::string error;
    1228          244 :     if (!vehicle->insertStop(nextStopIndex, stopPars, "traci:insertStop", teleport != 0, error)) {
    1229           34 :         throw TraCIException("Stop insertion failed for vehicle '" + vehID + "' (" + error + ").");
    1230              :     }
    1231          227 : }
    1232              : 
    1233              : 
    1234              : std::string
    1235          441 : Vehicle::getStopParameter(const std::string& vehID, int nextStopIndex, const std::string& param, bool customParam) {
    1236          441 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1237              :     try {
    1238          441 :         if (nextStopIndex >= (int)vehicle->getStops().size() || (nextStopIndex < 0 && -nextStopIndex > (int)vehicle->getPastStops().size())) {
    1239            0 :             throw ProcessError("Invalid stop index " + toString(nextStopIndex)
    1240            0 :                                + " (has " + toString(vehicle->getPastStops().size()) + " past stops and " + toString(vehicle->getStops().size()) + " remaining stops)");
    1241              : 
    1242              :         }
    1243              :         const SUMOVehicleParameter::Stop& pars = (nextStopIndex >= 0
    1244          441 :                 ? vehicle->getStop(nextStopIndex).pars
    1245          198 :                 : vehicle->getPastStops()[(int)vehicle->getPastStops().size() + nextStopIndex]);
    1246          441 :         if (customParam) {
    1247              :             // custom user parameter
    1248           20 :             return pars.getParameter(param, "");
    1249              :         }
    1250              : 
    1251          431 :         if (param == toString(SUMO_ATTR_EDGE)) {
    1252              :             return pars.edge;
    1253          404 :         } else if (param == toString(SUMO_ATTR_LANE)) {
    1254           72 :             return toString(SUMOXMLDefinitions::getIndexFromLane(pars.lane));
    1255          760 :         } else if (param == toString(SUMO_ATTR_BUS_STOP)
    1256          760 :                    || param == toString(SUMO_ATTR_TRAIN_STOP)) {
    1257              :             return pars.busstop;
    1258          380 :         } else if (param == toString(SUMO_ATTR_CONTAINER_STOP)) {
    1259              :             return pars.containerstop;
    1260          380 :         } else if (param == toString(SUMO_ATTR_CHARGING_STATION)) {
    1261              :             return pars.chargingStation;
    1262          380 :         } else if (param == toString(SUMO_ATTR_PARKING_AREA)) {
    1263              :             return pars.parkingarea;
    1264          380 :         } else if (param == toString(SUMO_ATTR_STARTPOS)) {
    1265           19 :             return toString(pars.startPos);
    1266          361 :         } else if (param == toString(SUMO_ATTR_ENDPOS)) {
    1267           19 :             return toString(pars.endPos);
    1268          342 :         } else if (param == toString(SUMO_ATTR_POSITION_LAT)) {
    1269           19 :             return toString(pars.posLat == INVALID_DOUBLE ? INVALID_DOUBLE_VALUE : pars.posLat);
    1270          323 :         } else if (param == toString(SUMO_ATTR_ARRIVAL)) {
    1271           19 :             return pars.arrival < 0 ? "-1" : time2string(pars.arrival);
    1272          304 :         } else if (param == toString(SUMO_ATTR_DURATION)) {
    1273           19 :             return pars.duration < 0 ? "-1" : time2string(pars.duration);
    1274          285 :         } else if (param == toString(SUMO_ATTR_UNTIL)) {
    1275           19 :             return pars.until < 0 ? "-1" : time2string(pars.until);
    1276          266 :         } else if (param == toString(SUMO_ATTR_EXTENSION)) {
    1277           19 :             return pars.extension < 0 ? "-1" : time2string(pars.extension);
    1278          247 :         } else if (param == toString(SUMO_ATTR_INDEX)) {
    1279           19 :             return toString(nextStopIndex + (int)vehicle->getPastStops().size());
    1280          228 :         } else if (param == toString(SUMO_ATTR_PARKING)) {
    1281           19 :             return toString(pars.parking);
    1282          209 :         } else if (param == toString(SUMO_ATTR_TRIGGERED)) {
    1283           19 :             return joinToString(pars.getTriggers(), " ");
    1284          190 :         } else if (param == toString(SUMO_ATTR_EXPECTED)) {
    1285           19 :             return joinToString(pars.awaitedPersons, " ");
    1286          171 :         } else if (param == toString(SUMO_ATTR_EXPECTED_CONTAINERS)) {
    1287            0 :             return joinToString(pars.awaitedContainers, " ");
    1288          171 :         } else if (param == toString(SUMO_ATTR_PERMITTED)) {
    1289           19 :             return joinToString(pars.permitted, " ");
    1290          152 :         } else if (param == toString(SUMO_ATTR_ACTTYPE)) {
    1291              :             return pars.actType;
    1292          133 :         } else if (param == toString(SUMO_ATTR_TRIP_ID)) {
    1293              :             return pars.tripId;
    1294          114 :         } else if (param == toString(SUMO_ATTR_SPLIT)) {
    1295              :             return pars.split;
    1296           95 :         } else if (param == toString(SUMO_ATTR_JOIN)) {
    1297              :             return pars.join;
    1298           76 :         } else if (param == toString(SUMO_ATTR_LINE)) {
    1299              :             return pars.line;
    1300           57 :         } else if (param == toString(SUMO_ATTR_SPEED)) {
    1301           19 :             return toString(pars.speed);
    1302           38 :         } else if (param == toString(SUMO_ATTR_STARTED)) {
    1303           19 :             return pars.started < 0 ? "-1" : time2string(pars.started);
    1304           19 :         } else if (param == toString(SUMO_ATTR_ENDED)) {
    1305           19 :             return pars.ended < 0 ? "-1" : time2string(pars.ended);
    1306            0 :         } else if (param == toString(SUMO_ATTR_ONDEMAND)) {
    1307            0 :             return toString(pars.onDemand);
    1308            0 :         } else if (param == toString(SUMO_ATTR_JUMP)) {
    1309            0 :             return pars.jump < 0 ? "-1" : time2string(pars.jump);
    1310            0 :         } else if (param == toString(SUMO_ATTR_JUMP_UNTIL)) {
    1311            0 :             return pars.jumpUntil < 0 ? "-1" : time2string(pars.jumpUntil);
    1312              :         } else {
    1313            0 :             throw ProcessError(TLF("Unsupported parameter '%'", param));
    1314              :         }
    1315            0 :     } catch (ProcessError& e) {
    1316            0 :         throw TraCIException("Could not get stop parameter for vehicle '" + vehID + "' (" + e.what() + ")");
    1317            0 :     }
    1318              : }
    1319              : 
    1320              : 
    1321              : 
    1322              : void
    1323          187 : Vehicle::setStopParameter(const std::string& vehID, int nextStopIndex,
    1324              :                           const std::string& param, const std::string& value,
    1325              :                           bool customParam) {
    1326          187 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1327              :     try {
    1328          187 :         MSStop& stop = vehicle->getStop(nextStopIndex);
    1329          187 :         SUMOVehicleParameter::Stop& pars = const_cast<SUMOVehicleParameter::Stop&>(stop.pars);
    1330          187 :         if (customParam) {
    1331           10 :             pars.setParameter(param, value);
    1332           10 :             return;
    1333              :         }
    1334              :         std::string error;
    1335          354 :         if (param == toString(SUMO_ATTR_EDGE)
    1336          349 :                 || param == toString(SUMO_ATTR_BUS_STOP)
    1337          345 :                 || param == toString(SUMO_ATTR_TRAIN_STOP)
    1338          345 :                 || param == toString(SUMO_ATTR_CONTAINER_STOP)
    1339          345 :                 || param == toString(SUMO_ATTR_CHARGING_STATION)
    1340          345 :                 || param == toString(SUMO_ATTR_PARKING_AREA)
    1341          517 :                 || param == toString(SUMO_ATTR_LANE)
    1342              :            ) {
    1343           14 :             int laneIndex = stop.lane->getIndex();
    1344           14 :             int flags = pars.getFlags() & 3;
    1345              :             std::string edgeOrStopID = value;
    1346           14 :             if (param == toString(SUMO_ATTR_LANE)) {
    1347            5 :                 laneIndex = StringUtils::toInt(value);
    1348            5 :                 edgeOrStopID = pars.edge;
    1349           18 :             } else if (param == toString(SUMO_ATTR_BUS_STOP)
    1350           14 :                        || param == toString(SUMO_ATTR_TRAIN_STOP)) {
    1351            4 :                 flags |= 8;
    1352            5 :             } else if (param == toString(SUMO_ATTR_CONTAINER_STOP)) {
    1353            0 :                 flags |= 16;
    1354            5 :             } else if (param == toString(SUMO_ATTR_CHARGING_STATION)) {
    1355            0 :                 flags |= 32;
    1356            5 :             } else if (param == toString(SUMO_ATTR_PARKING_AREA)) {
    1357            0 :                 flags |= 64;
    1358              :             }
    1359              :             // special case: replace stop
    1360           14 :             replaceStop(vehID, nextStopIndex, edgeOrStopID, pars.endPos, laneIndex, STEPS2TIME(pars.duration),
    1361           14 :                         flags, pars.startPos, STEPS2TIME(pars.until), 0);
    1362              : 
    1363          163 :         } else if (param == toString(SUMO_ATTR_STARTPOS)) {
    1364           20 :             pars.startPos = StringUtils::toDouble(value);
    1365           20 :             pars.parametersSet |= STOP_START_SET;
    1366          143 :         } else if (param == toString(SUMO_ATTR_ENDPOS)) {
    1367            5 :             pars.endPos = StringUtils::toDouble(value);
    1368            5 :             pars.parametersSet |= STOP_END_SET;
    1369          138 :         } else if (param == toString(SUMO_ATTR_POSITION_LAT)) {
    1370            5 :             pars.posLat = StringUtils::toDouble(value);
    1371            5 :             pars.parametersSet |= STOP_POSLAT_SET;
    1372          133 :         } else if (param == toString(SUMO_ATTR_ARRIVAL)) {
    1373            5 :             pars.arrival = string2time(value);
    1374            5 :             pars.parametersSet |= STOP_ARRIVAL_SET;
    1375          128 :         } else if (param == toString(SUMO_ATTR_DURATION)) {
    1376           10 :             pars.duration = string2time(value);
    1377           10 :             pars.parametersSet |= STOP_DURATION_SET;
    1378              :             // also update dynamic value
    1379           10 :             stop.initPars(pars);
    1380          118 :         } else if (param == toString(SUMO_ATTR_UNTIL)) {
    1381            5 :             pars.until = string2time(value);
    1382            5 :             pars.parametersSet |= STOP_UNTIL_SET;
    1383          113 :         } else if (param == toString(SUMO_ATTR_EXTENSION)) {
    1384           10 :             pars.extension = string2time(value);
    1385           10 :             pars.parametersSet |= STOP_EXTENSION_SET;
    1386          103 :         } else if (param == toString(SUMO_ATTR_INDEX)) {
    1387            0 :             throw TraCIException("Changing stop index is not supported");
    1388          103 :         } else if (param == toString(SUMO_ATTR_PARKING)) {
    1389            5 :             pars.parking = SUMOVehicleParameter::parseParkingType(value);
    1390            5 :             pars.parametersSet |= STOP_PARKING_SET;
    1391           98 :         } else if (param == toString(SUMO_ATTR_TRIGGERED)) {
    1392           10 :             if (pars.speed > 0 && value != "") {
    1393            0 :                 throw ProcessError(TLF("Waypoint (speed = %) at index % does not support triggers", pars.speed, nextStopIndex));
    1394              :             }
    1395           10 :             SUMOVehicleParameter::parseStopTriggers(StringTokenizer(value).getVector(), false, pars);
    1396           10 :             pars.parametersSet |= STOP_TRIGGER_SET;
    1397              :             // also update dynamic value
    1398           10 :             stop.initPars(pars);
    1399           88 :         } else if (param == toString(SUMO_ATTR_EXPECTED)) {
    1400           30 :             pars.awaitedPersons = StringTokenizer(value).getSet();
    1401           15 :             pars.parametersSet |= STOP_EXPECTED_SET;
    1402              :             // also update dynamic value
    1403           15 :             stop.initPars(pars);
    1404           73 :         } else if (param == toString(SUMO_ATTR_EXPECTED_CONTAINERS)) {
    1405            0 :             pars.awaitedContainers = StringTokenizer(value).getSet();
    1406            0 :             pars.parametersSet |= STOP_EXPECTED_CONTAINERS_SET;
    1407              :             // also update dynamic value
    1408            0 :             stop.initPars(pars);
    1409           73 :         } else if (param == toString(SUMO_ATTR_PERMITTED)) {
    1410           10 :             pars.permitted = StringTokenizer(value).getSet();
    1411            5 :             pars.parametersSet |= STOP_PERMITTED_SET;
    1412           68 :         } else if (param == toString(SUMO_ATTR_ACTTYPE)) {
    1413            5 :             pars.actType = value;
    1414           63 :         } else if (param == toString(SUMO_ATTR_TRIP_ID)) {
    1415            5 :             pars.tripId = value;
    1416            5 :             pars.parametersSet |= STOP_TRIP_ID_SET;
    1417           58 :         } else if (param == toString(SUMO_ATTR_SPLIT)) {
    1418            5 :             pars.split = value;
    1419            5 :             pars.parametersSet |= STOP_SPLIT_SET;
    1420           53 :         } else if (param == toString(SUMO_ATTR_JOIN)) {
    1421            5 :             pars.join = value;
    1422            5 :             pars.parametersSet |= STOP_JOIN_SET;
    1423              :             // also update dynamic value
    1424            5 :             stop.initPars(pars);
    1425           48 :         } else if (param == toString(SUMO_ATTR_LINE)) {
    1426            5 :             pars.line = value;
    1427            5 :             pars.parametersSet |= STOP_LINE_SET;
    1428           43 :         } else if (param == toString(SUMO_ATTR_SPEED)) {
    1429           10 :             const double speed = StringUtils::toDouble(value);
    1430           15 :             if (speed > 0 && pars.getTriggers().size() > 0) {
    1431           10 :                 throw ProcessError(TLF("Triggered stop at index % cannot be changed into a waypoint by setting speed to %", nextStopIndex, speed));
    1432              :             }
    1433            5 :             pars.speed = speed;
    1434            5 :             pars.parametersSet |= STOP_SPEED_SET;
    1435           33 :         } else if (param == toString(SUMO_ATTR_STARTED)) {
    1436            5 :             pars.started = string2time(value);
    1437            5 :             pars.parametersSet |= STOP_STARTED_SET;
    1438           28 :         } else if (param == toString(SUMO_ATTR_ENDED)) {
    1439            5 :             pars.ended = string2time(value);
    1440            5 :             pars.parametersSet |= STOP_ENDED_SET;
    1441           23 :         } else if (param == toString(SUMO_ATTR_ONDEMAND)) {
    1442            5 :             pars.onDemand = StringUtils::toBool(value);
    1443            5 :             pars.parametersSet |= STOP_ONDEMAND_SET;
    1444           18 :         } else if (param == toString(SUMO_ATTR_JUMP)) {
    1445           18 :             pars.jump = string2time(value);
    1446           18 :             pars.parametersSet |= STOP_JUMP_SET;
    1447            5 :         } else if (param == toString(SUMO_ATTR_JUMP_UNTIL)) {
    1448            0 :             pars.jumpUntil = string2time(value);
    1449            0 :             pars.parametersSet |= STOP_JUMP_UNTIL_SET;
    1450              :         } else {
    1451            0 :             throw ProcessError(TLF("Unsupported parameter '%'", param));
    1452              :         }
    1453            5 :     } catch (ProcessError& e) {
    1454           10 :         throw TraCIException("Could not set stop parameter for vehicle '" + vehID + "' (" + e.what() + ")");
    1455            5 :     }
    1456              : }
    1457              : 
    1458              : 
    1459              : void
    1460           20 : Vehicle::rerouteParkingArea(const std::string& vehID, const std::string& parkingAreaID) {
    1461           20 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1462           20 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1463           20 :     if (veh == nullptr) {
    1464            4 :         WRITE_WARNING("rerouteParkingArea not yet implemented for meso");
    1465            4 :         return;
    1466              :     }
    1467              :     std::string error;
    1468              :     // Forward command to vehicle
    1469           16 :     if (!veh->rerouteParkingArea(parkingAreaID, error)) {
    1470            0 :         throw TraCIException(error);
    1471              :     }
    1472              : }
    1473              : 
    1474              : void
    1475           12 : Vehicle::resume(const std::string& vehID) {
    1476           12 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1477           12 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1478           12 :     if (veh == nullptr) {
    1479            2 :         WRITE_WARNING("resume not yet implemented for meso");
    1480            2 :         return;
    1481              :     }
    1482           10 :     if (!veh->hasStops()) {
    1483            0 :         throw TraCIException("Failed to resume vehicle '" + veh->getID() + "', it has no stops.");
    1484              :     }
    1485           10 :     if (!veh->resumeFromStopping()) {
    1486            0 :         const MSStop& sto = veh->getNextStop();
    1487            0 :         std::ostringstream strs;
    1488            0 :         strs << "reached: " << sto.reached;
    1489            0 :         strs << ", duration:" << sto.duration;
    1490            0 :         strs << ", edge:" << (*sto.edge)->getID();
    1491            0 :         strs << ", startPos: " << sto.pars.startPos;
    1492              :         std::string posStr = strs.str();
    1493            0 :         throw TraCIException("Failed to resume from stopping for vehicle '" + veh->getID() + "', " + posStr);
    1494            0 :     }
    1495              : }
    1496              : 
    1497              : 
    1498              : void
    1499        23131 : Vehicle::changeTarget(const std::string& vehID, const std::string& edgeID) {
    1500        23131 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    1501        23131 :     const MSEdge* destEdge = MSEdge::dictionary(edgeID);
    1502        23131 :     const bool onInit = isOnInit(vehID);
    1503        23131 :     if (destEdge == nullptr) {
    1504            2 :         throw TraCIException("Destination edge '" + edgeID + "' is not known.");
    1505              :     }
    1506              :     // change the final edge of the route and reroute
    1507              :     try {
    1508        23130 :         const bool success = veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:changeTarget",
    1509              :                                           veh->getRouterTT(), onInit, false, false, destEdge);
    1510        23130 :         if (!success) {
    1511           20 :             throw TraCIException("ChangeTarget failed for vehicle '" + veh->getID() + "', destination edge '" + edgeID + "' unreachable.");
    1512              :         }
    1513            0 :     } catch (ProcessError& e) {
    1514            0 :         throw TraCIException(e.what());
    1515            0 :     }
    1516        23120 : }
    1517              : 
    1518              : 
    1519              : void
    1520         7767 : Vehicle::changeLane(const std::string& vehID, int laneIndex, double duration) {
    1521              :     try {
    1522         7767 :         checkTimeBounds(duration);
    1523            0 :     } catch (ProcessError&) {
    1524            0 :         throw TraCIException("Duration parameter exceeds the time value range.");
    1525            0 :     }
    1526         7767 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1527         7767 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1528         7767 :     if (veh == nullptr) {
    1529          399 :         WRITE_ERROR("changeLane not applicable for meso");
    1530          399 :         return;
    1531              :     }
    1532              : 
    1533            0 :     std::vector<std::pair<SUMOTime, int> > laneTimeLine;
    1534         7368 :     laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
    1535        14736 :     laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
    1536         7368 :     veh->getInfluencer().setLaneTimeLine(laneTimeLine);
    1537         7368 : }
    1538              : 
    1539              : void
    1540          247 : Vehicle::changeLaneRelative(const std::string& vehID, int indexOffset, double duration) {
    1541              :     try {
    1542          247 :         checkTimeBounds(duration);
    1543            0 :     } catch (ProcessError&) {
    1544            0 :         throw TraCIException("Duration parameter exceeds the time value range.");
    1545            0 :     }
    1546          247 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1547          247 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1548          247 :     if (veh == nullptr) {
    1549           25 :         WRITE_ERROR("changeLaneRelative not applicable for meso");
    1550           25 :         return;
    1551              :     }
    1552              : 
    1553            0 :     std::vector<std::pair<SUMOTime, int> > laneTimeLine;
    1554          222 :     int laneIndex = veh->getLaneIndex() + indexOffset;
    1555          222 :     if (laneIndex < 0 && !veh->getLaneChangeModel().isOpposite()) {
    1556           16 :         if (veh->getLaneIndex() == -1) {
    1557            0 :             WRITE_WARNINGF(TL("Ignoring changeLaneRelative for vehicle '%' that isn't on the road"), vehID);
    1558              :         } else {
    1559           48 :             WRITE_WARNINGF(TL("Ignoring indexOffset % for vehicle '%' on laneIndex %."), indexOffset, vehID, veh->getLaneIndex());
    1560              :         }
    1561              :     } else {
    1562          206 :         laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
    1563          412 :         laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
    1564          206 :         veh->getInfluencer().setLaneTimeLine(laneTimeLine);
    1565              :     }
    1566          222 : }
    1567              : 
    1568              : 
    1569              : void
    1570          301 : Vehicle::changeSublane(const std::string& vehID, double latDist) {
    1571          301 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1572          301 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1573          301 :     if (veh == nullptr) {
    1574            1 :         WRITE_ERROR("changeSublane not applicable for meso");
    1575            1 :         return;
    1576              :     }
    1577              : 
    1578          300 :     veh->getInfluencer().setSublaneChange(latDist);
    1579              : }
    1580              : 
    1581              : 
    1582              : void
    1583        22960 : Vehicle::add(const std::string& vehID,
    1584              :              const std::string& routeID,
    1585              :              const std::string& typeID,
    1586              :              const std::string& depart,
    1587              :              const std::string& departLane,
    1588              :              const std::string& departPos,
    1589              :              const std::string& departSpeed,
    1590              :              const std::string& arrivalLane,
    1591              :              const std::string& arrivalPos,
    1592              :              const std::string& arrivalSpeed,
    1593              :              const std::string& fromTaz,
    1594              :              const std::string& toTaz,
    1595              :              const std::string& line,
    1596              :              int /*personCapacity*/,
    1597              :              int personNumber) {
    1598        22960 :     SUMOVehicle* veh = MSNet::getInstance()->getVehicleControl().getVehicle(vehID);
    1599        22960 :     if (veh != nullptr) {
    1600            2 :         throw TraCIException("The vehicle '" + vehID + "' to add already exists.");
    1601              :     }
    1602              : 
    1603        22959 :     SUMOVehicleParameter vehicleParams;
    1604              :     vehicleParams.id = vehID;
    1605        22959 :     MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
    1606        22959 :     if (!vehicleType) {
    1607            4 :         throw TraCIException("Invalid type '" + typeID + "' for vehicle '" + vehID + "'.");
    1608              :     }
    1609        22957 :     if (typeID != "DEFAULT_VEHTYPE") {
    1610              :         vehicleParams.vtypeid = typeID;
    1611        21842 :         vehicleParams.parametersSet |= VEHPARS_VTYPE_SET;
    1612              :     }
    1613        22957 :     if (SUMOVehicleParserHelper::isInternalRouteID(routeID)) {
    1614            0 :         WRITE_WARNINGF(TL("Internal routes receive an ID starting with '!' and must not be referenced in other vehicle or flow definitions. Please remove all references to route '%' in case it is internal."), routeID);
    1615              :     }
    1616        22957 :     ConstMSRoutePtr route = MSRoute::dictionary(routeID);
    1617        22957 :     if (!route) {
    1618           45 :         if (routeID == "") {
    1619              :             // assume, route was intentionally left blank because the caller
    1620              :             // intends to control the vehicle remotely
    1621              :             SUMOVehicleClass vclass = vehicleType->getVehicleClass();
    1622           44 :             const std::string dummyRouteID = "DUMMY_ROUTE_" + SumoVehicleClassStrings.getString(vclass);
    1623           88 :             route = MSRoute::dictionary(dummyRouteID);
    1624           44 :             if (route == nullptr) {
    1625         4624 :                 for (MSEdge* e : MSEdge::getAllEdges()) {
    1626         4624 :                     if (e->getFunction() == SumoXMLEdgeFunc::NORMAL && (e->getPermissions() & vclass) == vclass) {
    1627            0 :                         std::vector<std::string>  edges;
    1628           44 :                         edges.push_back(e->getID());
    1629           44 :                         libsumo::Route::add(dummyRouteID, edges);
    1630              :                         break;
    1631           44 :                     }
    1632              :                 }
    1633              :             }
    1634           88 :             route = MSRoute::dictionary(dummyRouteID);
    1635           44 :             if (!route) {
    1636            0 :                 throw TraCIException("Could not build dummy route for vehicle class: '" + SumoVehicleClassStrings.getString(vehicleType->getVehicleClass()) + "'");
    1637              :             }
    1638              :         } else {
    1639            2 :             throw TraCIException("Invalid route '" + routeID + "' for vehicle '" + vehID + "'.");
    1640              :         }
    1641              :     }
    1642              :     // check if the route implies a trip
    1643        22956 :     if (route->getEdges().size() == 2) {
    1644        22457 :         const MSEdgeVector& succ = route->getEdges().front()->getSuccessors();
    1645        22457 :         if (std::find(succ.begin(), succ.end(), route->getEdges().back()) == succ.end()) {
    1646           64 :             vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
    1647              :         }
    1648              :     }
    1649        22956 :     if (fromTaz != "" || toTaz != "") {
    1650           15 :         vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
    1651              :     }
    1652              :     std::string error;
    1653        45912 :     if (!SUMOVehicleParameter::parseDepart(depart, "vehicle", vehID, vehicleParams.depart, vehicleParams.departProcedure, error)) {
    1654            0 :         throw TraCIException(error);
    1655              :     }
    1656        22956 :     if (vehicleParams.departProcedure == DepartDefinition::GIVEN && vehicleParams.depart < MSNet::getInstance()->getCurrentTimeStep()) {
    1657            9 :         vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
    1658           27 :         WRITE_WARNINGF(TL("Departure time for vehicle '%' is in the past; using current time instead."), vehID);
    1659        22947 :     } else if (vehicleParams.departProcedure == DepartDefinition::NOW) {
    1660        22904 :         vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
    1661              :     }
    1662        45912 :     if (!SUMOVehicleParameter::parseDepartLane(departLane, "vehicle", vehID, vehicleParams.departLane, vehicleParams.departLaneProcedure, error)) {
    1663            0 :         throw TraCIException(error);
    1664              :     }
    1665        45912 :     if (!SUMOVehicleParameter::parseDepartPos(departPos, "vehicle", vehID, vehicleParams.departPos, vehicleParams.departPosProcedure, error)) {
    1666            0 :         throw TraCIException(error);
    1667              :     }
    1668        45912 :     if (!SUMOVehicleParameter::parseDepartSpeed(departSpeed, "vehicle", vehID, vehicleParams.departSpeed, vehicleParams.departSpeedProcedure, error)) {
    1669            0 :         throw TraCIException(error);
    1670              :     }
    1671        45912 :     if (!SUMOVehicleParameter::parseArrivalLane(arrivalLane, "vehicle", vehID, vehicleParams.arrivalLane, vehicleParams.arrivalLaneProcedure, error)) {
    1672            0 :         throw TraCIException(error);
    1673              :     }
    1674        45912 :     if (!SUMOVehicleParameter::parseArrivalPos(arrivalPos, "vehicle", vehID, vehicleParams.arrivalPos, vehicleParams.arrivalPosProcedure, error)) {
    1675            0 :         throw TraCIException(error);
    1676              :     }
    1677        45929 :     if (!SUMOVehicleParameter::parseArrivalSpeed(arrivalSpeed, "vehicle", vehID, vehicleParams.arrivalSpeed, vehicleParams.arrivalSpeedProcedure, error)) {
    1678            0 :         throw TraCIException(error);
    1679              :     }
    1680              :     // mark non-default attributes
    1681        22956 :     if (departLane != "first") {
    1682        21869 :         vehicleParams.parametersSet |= VEHPARS_DEPARTLANE_SET;
    1683              :     }
    1684        22956 :     if (departPos != "base") {
    1685        22071 :         vehicleParams.parametersSet |= VEHPARS_DEPARTPOS_SET;
    1686              :     }
    1687        22956 :     if (departSpeed != "0") {
    1688        21834 :         vehicleParams.parametersSet |= VEHPARS_DEPARTSPEED_SET;
    1689              :     }
    1690        22956 :     if (arrivalLane != "current") {
    1691           14 :         vehicleParams.parametersSet |= VEHPARS_ARRIVALLANE_SET;
    1692              :     }
    1693        22956 :     if (arrivalPos != "max") {
    1694            9 :         vehicleParams.parametersSet |= VEHPARS_ARRIVALPOS_SET;
    1695              :     }
    1696        22956 :     if (arrivalSpeed != "current") {
    1697            5 :         vehicleParams.parametersSet |= VEHPARS_ARRIVALSPEED_SET;
    1698              :     }
    1699        22956 :     if (fromTaz != "") {
    1700           10 :         vehicleParams.parametersSet |= VEHPARS_FROM_TAZ_SET;
    1701              :     }
    1702        22956 :     if (toTaz != "") {
    1703           10 :         vehicleParams.parametersSet |= VEHPARS_TO_TAZ_SET;
    1704              :     }
    1705        22956 :     if (line != "") {
    1706           18 :         vehicleParams.parametersSet |= VEHPARS_LINE_SET;
    1707              :     }
    1708        22956 :     if (personNumber != 0) {
    1709            0 :         vehicleParams.parametersSet |= VEHPARS_PERSON_NUMBER_SET;
    1710              :     }
    1711              :     // build vehicle
    1712              :     vehicleParams.fromTaz = fromTaz;
    1713              :     vehicleParams.toTaz = toTaz;
    1714              :     vehicleParams.line = line;
    1715              :     //vehicleParams.personCapacity = personCapacity;
    1716        22956 :     vehicleParams.personNumber = personNumber;
    1717              : 
    1718        22956 :     SUMOVehicleParameter* params = new SUMOVehicleParameter(vehicleParams);
    1719              :     SUMOVehicle* vehicle = nullptr;
    1720              :     try {
    1721        22973 :         vehicle = MSNet::getInstance()->getVehicleControl().buildVehicle(params, route, vehicleType, true, MSVehicleControl::VehicleDefinitionSource::LIBSUMO);
    1722        22956 :         if (fromTaz == "" && !route->getEdges().front()->validateDepartSpeed(*vehicle)) {
    1723            5 :             MSNet::getInstance()->getVehicleControl().deleteVehicle(vehicle, true);
    1724           10 :             throw TraCIException("Departure speed for vehicle '" + vehID + "' is too high for the departure edge '" + route->getEdges().front()->getID() + "'.");
    1725              :         }
    1726              :         std::string msg;
    1727        22951 :         if (vehicle->getRouteValidity(true, true, &msg) != MSBaseVehicle::ROUTE_VALID) {
    1728            5 :             MSNet::getInstance()->getVehicleControl().deleteVehicle(vehicle, true);
    1729           10 :             throw TraCIException("Vehicle '" + vehID + "' has no valid route (" + msg + "). ");
    1730              :         }
    1731        22939 :         MSNet::getInstance()->getVehicleControl().addVehicle(vehicleParams.id, vehicle);
    1732        22939 :         if (vehicleParams.departProcedure != DepartDefinition::TRIGGERED && vehicleParams.departProcedure != DepartDefinition::CONTAINER_TRIGGERED) {
    1733        22918 :             MSNet::getInstance()->getInsertionControl().add(vehicle);
    1734              :         }
    1735           17 :     } catch (ProcessError& e) {
    1736            7 :         if (vehicle != nullptr) {
    1737            7 :             MSNet::getInstance()->getVehicleControl().deleteVehicle(vehicle, true);
    1738              :         }
    1739           14 :         throw TraCIException(e.what());
    1740            7 :     }
    1741        22959 : }
    1742              : 
    1743              : 
    1744              : void
    1745         9975 : Vehicle::moveToXY(const std::string& vehID, const std::string& edgeID, const int laneIndex,
    1746              :                   const double x, const double y, double angle, const int keepRoute, double matchThreshold) {
    1747         9975 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1748         9974 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1749         9974 :     if (veh == nullptr) {
    1750         2610 :         WRITE_WARNING("moveToXY not yet implemented for meso");
    1751         2610 :         return;
    1752              :     }
    1753         7364 :     const bool doKeepRoute = (keepRoute & 1) != 0 && veh->getID() != "VTD_EGO";
    1754         7364 :     const bool mayLeaveNetwork = (keepRoute & 2) != 0;
    1755         7364 :     const bool ignorePermissions = (keepRoute & 4) != 0;
    1756         7364 :     const bool setLateralPos = (MSGlobals::gLateralResolution > 0 || mayLeaveNetwork);
    1757         7364 :     SUMOVehicleClass vClass = ignorePermissions ? SVC_IGNORING : veh->getVClass();
    1758              :     // process
    1759        14728 :     const std::string origID = edgeID + "_" + toString(laneIndex);
    1760              :     // @todo add an interpretation layer for OSM derived origID values (without lane index)
    1761              :     Position pos(x, y);
    1762              : #ifdef DEBUG_MOVEXY
    1763              :     const double origAngle = angle;
    1764              : #endif
    1765              :     // angle must be in [0,360] because it will be compared against those returned by naviDegree()
    1766              :     // angle set to INVALID_DOUBLE_VALUE is ignored in the evaluated and later set to the angle of the matched lane
    1767         7364 :     if (angle != INVALID_DOUBLE_VALUE) {
    1768         2828 :         while (angle >= 360.) {
    1769            0 :             angle -= 360.;
    1770              :         }
    1771         2837 :         while (angle < 0.) {
    1772            9 :             angle += 360.;
    1773              :         }
    1774              :     }
    1775              : 
    1776              : #ifdef DEBUG_MOVEXY
    1777              :     std::cout << std::endl << SIMTIME << " moveToXY veh=" << veh->getID() << " vehPos=" << veh->getPosition()
    1778              :               << " lane=" << Named::getIDSecure(veh->getLane()) << " lanePos=" << vehicle->getPositionOnLane() << std::endl;
    1779              :     std::cout << " wantedPos=" << pos << " origID=" << origID << " laneIndex=" << laneIndex << " origAngle=" << origAngle << " angle=" << angle << " keepRoute=" << keepRoute << std::endl;
    1780              : #endif
    1781              : 
    1782            0 :     ConstMSEdgeVector edges;
    1783         7364 :     MSLane* lane = nullptr;
    1784              :     double lanePos;
    1785              :     double lanePosLat = 0;
    1786         7364 :     double bestDistance = std::numeric_limits<double>::max();
    1787         7364 :     int routeOffset = 0;
    1788              :     bool found;
    1789         7364 :     double maxRouteDistance = matchThreshold;
    1790              :     /* EGO vehicle is known to have a fixed route. @todo make this into a parameter of the TraCI call */
    1791         7364 :     if (doKeepRoute) {
    1792              :         // case a): vehicle is on its earlier route
    1793              :         //  we additionally assume it is moving forward (SUMO-limit);
    1794              :         //  note that the route ("edges") is not changed in this case
    1795              : 
    1796         4661 :         found = Helper::moveToXYMap_matchingRoutePosition(pos, origID,
    1797         4661 :                 veh->getRoute().getEdges(), veh->getRoutePosition(),
    1798              :                 vClass, setLateralPos,
    1799              :                 bestDistance, &lane, lanePos, routeOffset);
    1800              :         // @note silenty ignoring mapping failure
    1801              :     } else {
    1802         2703 :         const double speed = pos.distanceTo2D(veh->getPosition()); // !!!veh->getSpeed();
    1803         5406 :         found = Helper::moveToXYMap(pos, maxRouteDistance, mayLeaveNetwork, origID, angle,
    1804         2703 :                                     speed, veh->getRoute().getEdges(), veh->getRoutePosition(), veh->getLane(), veh->getPositionOnLane(), veh->isOnRoad(),
    1805         2703 :                                     vClass, GeomHelper::naviDegree(veh->getAngle()), setLateralPos,
    1806              :                                     bestDistance, &lane, lanePos, routeOffset, edges);
    1807              :     }
    1808         7364 :     if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
    1809              :         // optionally compute lateral offset
    1810         7358 :         pos.setz(veh->getPosition().z());
    1811         7358 :         if (found && setLateralPos) {
    1812         4790 :             const double perpDist = lane->getShape().distance2D(pos, false);
    1813         4790 :             if (perpDist != GeomHelper::INVALID_OFFSET) {
    1814              :                 lanePosLat = perpDist;
    1815         4790 :                 if (!mayLeaveNetwork) {
    1816          189 :                     lanePosLat = MIN2(lanePosLat, 0.5 * (lane->getWidth() + veh->getVehicleType().getWidth() - MSGlobals::gLateralResolution));
    1817              :                 }
    1818              :                 // figure out whether the offset is to the left or to the right
    1819         4790 :                 PositionVector tmp = lane->getShape();
    1820              :                 try {
    1821         4790 :                     tmp.move2side(-lanePosLat); // moved to left
    1822            0 :                 } catch (ProcessError&) {
    1823            0 :                     WRITE_WARNINGF(TL("Could not determine position on lane '%' at lateral position %."), lane->getID(), toString(-lanePosLat));
    1824            0 :                 }
    1825              :                 //std::cout << " lane=" << lane->getID() << " posLat=" << lanePosLat << " shape=" << lane->getShape() << " tmp=" << tmp << " tmpDist=" << tmp.distance2D(pos) << "\n";
    1826         4790 :                 if (tmp.distance2D(pos) > perpDist) {
    1827              :                     lanePosLat = -lanePosLat;
    1828              :                 }
    1829         4790 :             }
    1830         4790 :             pos.setz(lane->geometryPositionAtOffset(lanePos).z());
    1831              :         }
    1832         7358 :         if (found && !mayLeaveNetwork && MSGlobals::gLateralResolution < 0) {
    1833              :             // mapped position may differ from pos
    1834         2455 :             pos = lane->geometryPositionAtOffset(lanePos, -lanePosLat);
    1835              :         }
    1836              :         assert((found && lane != 0) || (!found && lane == 0));
    1837              :         assert(!std::isnan(lanePos));
    1838         7358 :         if (angle == INVALID_DOUBLE_VALUE) {
    1839         4532 :             if (lane != nullptr) {
    1840         4420 :                 angle = GeomHelper::naviDegree(lane->getShape().rotationAtOffset(lanePos));
    1841              :             } else {
    1842              :                 // compute angle outside road network from old and new position
    1843          112 :                 angle = GeomHelper::naviDegree(veh->getPosition().angleTo2D(pos));
    1844              :             }
    1845              :         }
    1846              :         // use the best we have
    1847              : #ifdef DEBUG_MOVEXY
    1848              :         std::cout << SIMTIME << " veh=" << vehID + " moveToXYResult lane='" << Named::getIDSecure(lane) << "' lanePos=" << lanePos << " lanePosLat=" << lanePosLat << "\n";
    1849              : #endif
    1850         7358 :         Helper::setRemoteControlled(veh, pos, lane, lanePos, lanePosLat, angle, routeOffset, edges, MSNet::getInstance()->getCurrentTimeStep());
    1851         7358 :         if (!veh->isOnRoad()) {
    1852          165 :             MSNet::getInstance()->getInsertionControl().alreadyDeparted(veh);
    1853              :         }
    1854              :     } else {
    1855            6 :         if (lane == nullptr) {
    1856            3 :             throw TraCIException("Could not map vehicle '" + vehID + "', no road found within " + toString(maxRouteDistance) + "m.");
    1857              :         } else {
    1858           15 :             throw TraCIException("Could not map vehicle '" + vehID + "', distance to road is " + toString(bestDistance) + ".");
    1859              :         }
    1860              :     }
    1861         7364 : }
    1862              : 
    1863              : void
    1864           50 : Vehicle::slowDown(const std::string& vehID, double speed, double duration) {
    1865              :     try {
    1866           50 :         checkTimeBounds(duration);
    1867            0 :     } catch (ProcessError&) {
    1868            0 :         throw TraCIException("Duration parameter exceeds the time value range.");
    1869            0 :     }
    1870           50 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1871           50 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1872           50 :     if (veh == nullptr) {
    1873            8 :         WRITE_ERROR("slowDown not applicable for meso");
    1874            8 :         return;
    1875              :     }
    1876              : 
    1877            0 :     std::vector<std::pair<SUMOTime, double> > speedTimeLine;
    1878           42 :     speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
    1879           84 :     speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), speed));
    1880           42 :     veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
    1881           42 : }
    1882              : 
    1883              : void
    1884           63 : Vehicle::openGap(const std::string& vehID, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel, const std::string& referenceVehID) {
    1885              :     try {
    1886           63 :         checkTimeBounds(duration);
    1887            0 :     } catch (ProcessError&) {
    1888            0 :         throw TraCIException("Duration parameter exceeds the time value range.");
    1889            0 :     }
    1890           63 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1891           63 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1892           63 :     if (veh == nullptr) {
    1893            3 :         WRITE_ERROR("openGap not applicable for meso");
    1894            3 :         return;
    1895              :     }
    1896              : 
    1897              :     MSVehicle* refVeh = nullptr;
    1898           60 :     if (referenceVehID != "") {
    1899           12 :         refVeh = dynamic_cast<MSVehicle*>(Helper::getVehicle(referenceVehID));
    1900              :     }
    1901           60 :     const double originalTau = veh->getVehicleType().getCarFollowModel().getHeadwayTime();
    1902           60 :     if (newTimeHeadway == -1) {
    1903              :         newTimeHeadway = originalTau;
    1904              :     }
    1905           60 :     if (originalTau > newTimeHeadway) {
    1906            4 :         WRITE_WARNING("Ignoring openGap(). New time headway must not be smaller than the original.");
    1907            4 :         return;
    1908              :     }
    1909           56 :     veh->getInfluencer().activateGapController(originalTau, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVeh);
    1910              : }
    1911              : 
    1912              : void
    1913            8 : Vehicle::deactivateGapControl(const std::string& vehID) {
    1914            8 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1915            8 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1916            8 :     if (veh == nullptr) {
    1917            0 :         WRITE_ERROR("deactivateGapControl not applicable for meso");
    1918            0 :         return;
    1919              :     }
    1920              : 
    1921            8 :     if (veh->hasInfluencer()) {
    1922            8 :         veh->getInfluencer().deactivateGapController();
    1923              :     }
    1924              : }
    1925              : 
    1926              : void
    1927            0 : Vehicle::requestToC(const std::string& vehID, double leadTime) {
    1928            0 :     setParameter(vehID, "device.toc.requestToC", toString(leadTime));
    1929            0 : }
    1930              : 
    1931              : void
    1932         6714 : Vehicle::setSpeed(const std::string& vehID, double speed) {
    1933         6714 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1934         6713 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1935         6713 :     if (veh == nullptr) {
    1936          451 :         WRITE_WARNING("setSpeed not yet implemented for meso");
    1937          451 :         return;
    1938              :     }
    1939              : 
    1940            0 :     std::vector<std::pair<SUMOTime, double> > speedTimeLine;
    1941         6262 :     if (speed >= 0) {
    1942         5671 :         speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), speed));
    1943         5671 :         speedTimeLine.push_back(std::make_pair(SUMOTime_MAX - DELTA_T, speed));
    1944              :     }
    1945         6262 :     veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
    1946         6262 : }
    1947              : 
    1948              : void
    1949           12 : Vehicle::setAcceleration(const std::string& vehID, double acceleration, double duration) {
    1950              :     try {
    1951           12 :         checkTimeBounds(duration);
    1952            0 :     } catch (ProcessError&) {
    1953            0 :         throw TraCIException("Duration parameter exceeds the time value range.");
    1954            0 :     }
    1955           12 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1956           12 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1957           12 :     if (veh == nullptr) {
    1958            3 :         WRITE_WARNING("setAcceleration not yet implemented for meso");
    1959            3 :         return;
    1960              :     }
    1961              : 
    1962           12 :     double targetSpeed = std::max(veh->getSpeed() + acceleration * duration, 0.0);
    1963            0 :     std::vector<std::pair<SUMOTime, double>> speedTimeLine;
    1964            9 :     speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
    1965           18 :     speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), targetSpeed));
    1966            9 :     veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
    1967            9 : }
    1968              : 
    1969              : void
    1970          238 : Vehicle::setPreviousSpeed(const std::string& vehID, double prevSpeed, double prevAcceleration) {
    1971          238 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1972          238 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1973          238 :     if (veh == nullptr) {
    1974           42 :         WRITE_WARNING("setPreviousSpeed not yet implemented for meso");
    1975           42 :         return;
    1976              :     }
    1977          196 :     if (prevAcceleration == INVALID_DOUBLE_VALUE) {
    1978              :         prevAcceleration = std::numeric_limits<double>::min();
    1979              :     }
    1980          196 :     veh->setPreviousSpeed(prevSpeed, prevAcceleration);
    1981              : }
    1982              : 
    1983              : void
    1984         2037 : Vehicle::setSpeedMode(const std::string& vehID, int speedMode) {
    1985         2037 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1986         2037 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1987         2037 :     if (veh == nullptr) {
    1988          443 :         WRITE_WARNING("setSpeedMode not yet implemented for meso");
    1989          443 :         return;
    1990              :     }
    1991              : 
    1992         1594 :     veh->getInfluencer().setSpeedMode(speedMode);
    1993              : }
    1994              : 
    1995              : void
    1996          427 : Vehicle::setLaneChangeMode(const std::string& vehID, int laneChangeMode) {
    1997          427 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    1998          427 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    1999          427 :     if (veh == nullptr) {
    2000           18 :         WRITE_ERROR("setLaneChangeMode not applicable for meso");
    2001           18 :         return;
    2002              :     }
    2003              : 
    2004          409 :     veh->getInfluencer().setLaneChangeMode(laneChangeMode);
    2005              : }
    2006              : 
    2007              : void
    2008          225 : Vehicle::setRoutingMode(const std::string& vehID, int routingMode) {
    2009          225 :     Helper::getVehicle(vehID)->setRoutingMode(routingMode);
    2010          225 : }
    2011              : 
    2012              : void
    2013          245 : Vehicle::setType(const std::string& vehID, const std::string& typeID) {
    2014          245 :     MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
    2015          245 :     if (vehicleType == nullptr) {
    2016            0 :         throw TraCIException("Vehicle type '" + typeID + "' is not known");
    2017              :     }
    2018          245 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2019          245 :     veh->replaceVehicleType(vehicleType);
    2020          245 :     MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
    2021          245 :     if (microVeh != nullptr && microVeh->isOnRoad()) {
    2022          224 :         microVeh->updateBestLanes(true);
    2023          224 :         microVeh->updateLaneBruttoSum();
    2024              :     }
    2025          245 : }
    2026              : 
    2027              : void
    2028           27 : Vehicle::setRouteID(const std::string& vehID, const std::string& routeID) {
    2029           27 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2030           27 :     ConstMSRoutePtr r = MSRoute::dictionary(routeID);
    2031           27 :     if (r == nullptr) {
    2032            2 :         throw TraCIException("The route '" + routeID + "' is not known.");
    2033              :     }
    2034           26 :     if (SUMOVehicleParserHelper::isInternalRouteID(routeID)) {
    2035            3 :         WRITE_WARNINGF(TL("Internal routes receive an ID starting with '!' and must not be referenced in other vehicle or flow definitions. Please remove all references to route '%' in case it is internal."), routeID);
    2036              :     }
    2037              :     std::string msg;
    2038           52 :     if (!veh->hasValidRoute(msg, r)) {
    2039            5 :         WRITE_WARNINGF(TL("Invalid route replacement for vehicle '%'. %"), veh->getID(), msg);
    2040            1 :         if (MSGlobals::gCheckRoutes) {
    2041            2 :             throw TraCIException("Route replacement failed for " + veh->getID());
    2042              :         }
    2043              :     }
    2044              : 
    2045              :     std::string errorMsg;
    2046           76 :     if (!veh->replaceRoute(r, "traci:setRouteID", veh->getLane() == nullptr, 0, true, true, &errorMsg)) {
    2047            2 :         throw TraCIException("Route replacement failed for vehicle '" + veh->getID() + "' (" + errorMsg + ").");
    2048              :     }
    2049           24 : }
    2050              : 
    2051              : void
    2052            1 : Vehicle::setRoute(const std::string& vehID, const std::string& edgeID) {
    2053            3 :     setRoute(vehID, std::vector<std::string>({edgeID}));
    2054            0 : }
    2055              : 
    2056              : 
    2057              : void
    2058           38 : Vehicle::setRoute(const std::string& vehID, const std::vector<std::string>& edgeIDs) {
    2059           38 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2060            0 :     ConstMSEdgeVector edges;
    2061           38 :     const bool onInit = veh->getLane() == nullptr;
    2062              :     try {
    2063           71 :         MSEdge::parseEdgesList(edgeIDs, edges, "<unknown>");
    2064           33 :         if (edges.size() > 0 && edges.front()->isInternal()) {
    2065            9 :             if (edges.size() == 1) {
    2066              :                 // avoid crashing due to lack of normal edges in route (#5390)
    2067            5 :                 edges.push_back(edges.back()->getLanes()[0]->getNextNormal());
    2068              :             } else {
    2069              :                 // avoid internal edge in final route
    2070            4 :                 if (edges.front() == &veh->getLane()->getEdge()) {
    2071              :                     edges.erase(edges.begin());
    2072              :                 }
    2073              :             }
    2074              :         }
    2075            5 :     } catch (ProcessError& e) {
    2076           10 :         throw TraCIException("Invalid edge list for vehicle '" + veh->getID() + "' (" + e.what() + ")");
    2077            5 :     }
    2078              :     std::string errorMsg;
    2079           69 :     if (!veh->replaceRouteEdges(edges, -1, 0, "traci:setRoute", onInit, true, true, &errorMsg)) {
    2080            6 :         throw TraCIException("Route replacement failed for vehicle '" + veh->getID() + "' (" + errorMsg + ").");
    2081              :     }
    2082           38 : }
    2083              : 
    2084              : 
    2085              : void
    2086            9 : Vehicle::setLateralLanePosition(const std::string& vehID, double posLat) {
    2087            9 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    2088            9 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    2089            9 :     if (veh != nullptr) {
    2090              :         veh->setLateralPositionOnLane(posLat);
    2091              :     } else {
    2092            2 :         WRITE_ERROR("setLateralLanePosition not applicable for meso");
    2093              :     }
    2094            9 : }
    2095              : 
    2096              : 
    2097              : void
    2098          269 : Vehicle::updateBestLanes(const std::string& vehID) {
    2099          269 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    2100          269 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    2101          269 :     if (veh == nullptr) {
    2102            1 :         WRITE_ERROR("updateBestLanes not applicable for meso");
    2103            1 :         return;
    2104              :     }
    2105          268 :     if (veh->isOnRoad()) {
    2106          260 :         veh->updateBestLanes(true);
    2107              :     }
    2108              : }
    2109              : 
    2110              : 
    2111              : void
    2112          196 : Vehicle::setAdaptedTraveltime(const std::string& vehID, const std::string& edgeID,
    2113              :                               double time, double begSeconds, double endSeconds) {
    2114          196 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2115          196 :     MSEdge* edge = MSEdge::dictionary(edgeID);
    2116          196 :     if (edge == nullptr) {
    2117            0 :         throw TraCIException("Edge '" + edgeID + "' is not known.");
    2118              :     }
    2119          196 :     if (time != INVALID_DOUBLE_VALUE) {
    2120              :         // add time
    2121          187 :         if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
    2122              :             // clean up old values before setting whole range
    2123          159 :             while (veh->getWeightsStorage().knowsTravelTime(edge)) {
    2124            0 :                 veh->getWeightsStorage().removeTravelTime(edge);
    2125              :             }
    2126              :         }
    2127          187 :         veh->getWeightsStorage().addTravelTime(edge, begSeconds, endSeconds, time);
    2128              :     } else {
    2129              :         // remove time
    2130           18 :         while (veh->getWeightsStorage().knowsTravelTime(edge)) {
    2131            9 :             veh->getWeightsStorage().removeTravelTime(edge);
    2132              :         }
    2133              :     }
    2134          196 : }
    2135              : 
    2136              : 
    2137              : void
    2138           32 : Vehicle::setEffort(const std::string& vehID, const std::string& edgeID,
    2139              :                    double effort, double begSeconds, double endSeconds) {
    2140           32 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2141           32 :     MSEdge* edge = MSEdge::dictionary(edgeID);
    2142           32 :     if (edge == nullptr) {
    2143            0 :         throw TraCIException("Edge '" + edgeID + "' is not known.");
    2144              :     }
    2145           32 :     if (effort != INVALID_DOUBLE_VALUE) {
    2146              :         // add effort
    2147           23 :         if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
    2148              :             // clean up old values before setting whole range
    2149            9 :             while (veh->getWeightsStorage().knowsEffort(edge)) {
    2150            0 :                 veh->getWeightsStorage().removeEffort(edge);
    2151              :             }
    2152              :         }
    2153           23 :         veh->getWeightsStorage().addEffort(edge, begSeconds, endSeconds, effort);
    2154              :     } else {
    2155              :         // remove effort
    2156           18 :         while (veh->getWeightsStorage().knowsEffort(edge)) {
    2157            9 :             veh->getWeightsStorage().removeEffort(edge);
    2158              :         }
    2159              :     }
    2160           32 : }
    2161              : 
    2162              : 
    2163              : void
    2164          374 : Vehicle::rerouteTraveltime(const std::string& vehID, const bool currentTravelTimes) {
    2165          374 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2166          374 :     const int routingMode = veh->getRoutingMode();
    2167          374 :     if (currentTravelTimes && routingMode == ROUTING_MODE_DEFAULT) {
    2168           57 :         veh->setRoutingMode(ROUTING_MODE_AGGREGATED_CUSTOM);
    2169              :     }
    2170          374 :     veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteTraveltime",
    2171          374 :                  veh->getRouterTT(), isOnInit(vehID));
    2172          374 :     if (currentTravelTimes && routingMode == ROUTING_MODE_DEFAULT) {
    2173           57 :         veh->setRoutingMode(routingMode);
    2174              :     }
    2175          374 : }
    2176              : 
    2177              : 
    2178              : void
    2179           11 : Vehicle::rerouteEffort(const std::string& vehID) {
    2180           11 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2181           22 :     veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteEffort",
    2182           11 :                  MSNet::getInstance()->getRouterEffort(veh->getRNGIndex()), isOnInit(vehID));
    2183           11 : }
    2184              : 
    2185              : 
    2186              : void
    2187           22 : Vehicle::setSignals(const std::string& vehID, int signals) {
    2188           22 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    2189           22 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    2190           22 :     if (veh == nullptr) {
    2191            3 :         WRITE_ERROR("setSignals not applicable for meso");
    2192            3 :         return;
    2193              :     }
    2194              : 
    2195              :     // set influencer to make the change persistent
    2196           19 :     veh->getInfluencer().setSignals(signals);
    2197              :     // set them now so that getSignals returns the correct value
    2198              :     veh->switchOffSignal(0x0fffffff);
    2199           19 :     if (signals >= 0) {
    2200              :         veh->switchOnSignal(signals);
    2201              :     }
    2202              : }
    2203              : 
    2204              : 
    2205              : void
    2206          502 : Vehicle::moveTo(const std::string& vehID, const std::string& laneID, double pos, int reason) {
    2207          502 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    2208          502 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    2209          502 :     if (veh == nullptr) {
    2210           90 :         WRITE_WARNING("moveTo not yet implemented for meso");
    2211          382 :         return;
    2212              :     }
    2213              : 
    2214          412 :     MSLane* l = MSLane::dictionary(laneID);
    2215          412 :     if (l == nullptr) {
    2216            2 :         throw TraCIException("Unknown lane '" + laneID + "'.");
    2217              :     }
    2218          411 :     if (veh->getLane() == l) {
    2219          292 :         veh->setTentativeLaneAndPosition(l, pos, veh->getLateralPositionOnLane());
    2220          292 :         return;
    2221              :     }
    2222              :     MSEdge* destinationEdge = &l->getEdge();
    2223          119 :     const MSEdge* destinationRouteEdge = destinationEdge->getNormalBefore();
    2224          119 :     if (!veh->isOnRoad() && veh->getParameter().wasSet(VEHPARS_FORCE_REROUTE) && veh->getRoute().getEdges().size() == 2) {
    2225              :         // it's a trip that wasn't routeted yet (likely because the vehicle was added in this step. Find a route now
    2226            8 :         veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:moveTo-tripInsertion",
    2227              :                      veh->getRouterTT(), true);
    2228              :     }
    2229              :     // find edge in the remaining route
    2230          119 :     MSRouteIterator it = std::find(veh->getCurrentRouteEdge(), veh->getRoute().end(), destinationRouteEdge);
    2231          119 :     if (it == veh->getRoute().end()) {
    2232              :         // find edge in the edges that were already passed
    2233           30 :         it = std::find(veh->getRoute().begin(), veh->getRoute().end(), destinationRouteEdge);
    2234              :     }
    2235          119 :     if (it == veh->getRoute().end() ||
    2236              :             // internal edge must continue the route
    2237            8 :             (destinationEdge->isInternal() &&
    2238            8 :              ((it + 1) == veh->getRoute().end()
    2239            8 :               || l->getNextNormal() != *(it + 1)))) {
    2240           26 :         throw TraCIException("Lane '" + laneID + "' is not on the route of vehicle '" + vehID + "'.");
    2241              :     }
    2242          106 :     Position oldPos = vehicle->getPosition();
    2243          106 :     veh->onRemovalFromNet(MSMoveReminder::NOTIFICATION_TELEPORT);
    2244          106 :     if (veh->getLane() != nullptr) {
    2245              :         // correct odometer which gets incremented via onRemovalFromNet->leaveLane
    2246           77 :         veh->addToOdometer(-veh->getLane()->getLength());
    2247           77 :         veh->getMutableLane()->removeVehicle(veh, MSMoveReminder::NOTIFICATION_TELEPORT, false);
    2248              :     } else {
    2249           29 :         veh->setTentativeLaneAndPosition(l, pos);
    2250              :     }
    2251          106 :     const int oldRouteIndex = veh->getRoutePosition();
    2252          106 :     const int newRouteIndex = (int)(it - veh->getRoute().begin());
    2253          106 :     if (oldRouteIndex > newRouteIndex) {
    2254              :         // more odometer correction needed
    2255              :         veh->addToOdometer(-l->getLength());
    2256              :     }
    2257          106 :     veh->resetRoutePosition(newRouteIndex, veh->getParameter().departLaneProcedure);
    2258          106 :     if (!veh->isOnRoad()) {
    2259          106 :         MSNet::getInstance()->getInsertionControl().alreadyDeparted(veh);
    2260          106 :         MSVehicleTransfer::getInstance()->remove(veh);
    2261              :     }
    2262              :     MSMoveReminder::Notification moveReminderReason;
    2263          106 :     if (veh->hasDeparted()) {
    2264           77 :         if (reason == MOVE_TELEPORT) {
    2265              :             moveReminderReason = MSMoveReminder::NOTIFICATION_TELEPORT;
    2266           74 :         } else if (reason == MOVE_NORMAL) {
    2267              :             moveReminderReason = MSMoveReminder::NOTIFICATION_JUNCTION;
    2268           71 :         } else if (reason == MOVE_AUTOMATIC) {
    2269              :             Position newPos = l->geometryPositionAtOffset(pos);
    2270              :             const double dist = newPos.distanceTo2D(oldPos);
    2271           71 :             if (dist < SPEED2DIST(veh->getMaxSpeed())) {
    2272              :                 moveReminderReason = MSMoveReminder::NOTIFICATION_JUNCTION;
    2273              :             } else {
    2274              :                 moveReminderReason = MSMoveReminder::NOTIFICATION_TELEPORT;
    2275              :             }
    2276              :         } else {
    2277            0 :             throw TraCIException("Invalid moveTo reason '" + toString(reason) + "' for vehicle '" + vehID + "'.");
    2278              :         }
    2279              :     } else {
    2280              :         moveReminderReason = MSMoveReminder::NOTIFICATION_DEPARTED;
    2281              :     }
    2282          106 :     l->forceVehicleInsertion(veh, pos, moveReminderReason);
    2283          106 :     if (veh->getLaneChangeModel().isOpposite()) {
    2284            4 :         veh->getLaneChangeModel().changedToOpposite();
    2285              :     }
    2286              : }
    2287              : 
    2288              : 
    2289              : void
    2290           17 : Vehicle::setActionStepLength(const std::string& vehID, double actionStepLength, bool resetActionOffset) {
    2291           17 :     if (actionStepLength < 0.0) {
    2292            0 :         WRITE_ERROR("Invalid action step length (<0). Ignoring command setActionStepLength().");
    2293            0 :         return;
    2294              :     }
    2295           17 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    2296           17 :     MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
    2297           17 :     if (veh == nullptr) {
    2298            3 :         WRITE_ERROR("setActionStepLength not applicable for meso");
    2299            3 :         return;
    2300              :     }
    2301              : 
    2302           14 :     if (actionStepLength == 0.) {
    2303            0 :         veh->resetActionOffset();
    2304              :     } else {
    2305           14 :         veh->setActionStepLength(actionStepLength, resetActionOffset);
    2306              :     }
    2307              : }
    2308              : 
    2309              : 
    2310              : void
    2311            4 : Vehicle::setBoardingDuration(const std::string& vehID, double boardingDuration)  {
    2312              :     try {
    2313            4 :         checkTimeBounds(boardingDuration);
    2314            0 :     } catch (ProcessError&) {
    2315            0 :         throw TraCIException("BoardingDuration parameter exceeds the time value range.");
    2316            0 :     }
    2317            8 :     Helper::getVehicle(vehID)->getSingularType().setBoardingDuration(TIME2STEPS(boardingDuration));
    2318            4 : }
    2319              : 
    2320              : 
    2321              : void
    2322           27 : Vehicle::setImpatience(const std::string& vehID, double impatience)  {
    2323           27 :     MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
    2324           27 :     const double normalImpatience = vehicle->getImpatience();
    2325           27 :     vehicle->getBaseInfluencer().setExtraImpatience(impatience - normalImpatience);
    2326           27 : }
    2327              : 
    2328              : 
    2329              : void
    2330           30 : Vehicle::remove(const std::string& vehID, char reason) {
    2331           30 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2332              :     MSMoveReminder::Notification n = MSMoveReminder::NOTIFICATION_ARRIVED;
    2333              :     switch (reason) {
    2334              :         case REMOVE_TELEPORT:
    2335              :             // XXX semantics unclear
    2336              :             // n = MSMoveReminder::NOTIFICATION_TELEPORT;
    2337              :             n = MSMoveReminder::NOTIFICATION_TELEPORT_ARRIVED;
    2338              :             break;
    2339              :         case REMOVE_PARKING:
    2340              :             // XXX semantics unclear
    2341              :             // n = MSMoveReminder::NOTIFICATION_PARKING;
    2342              :             n = MSMoveReminder::NOTIFICATION_ARRIVED;
    2343              :             break;
    2344              :         case REMOVE_ARRIVED:
    2345              :             n = MSMoveReminder::NOTIFICATION_ARRIVED;
    2346              :             break;
    2347              :         case REMOVE_VAPORIZED:
    2348              :             n = MSMoveReminder::NOTIFICATION_VAPORIZED_TRACI;
    2349              :             break;
    2350              :         case REMOVE_TELEPORT_ARRIVED:
    2351              :             n = MSMoveReminder::NOTIFICATION_TELEPORT_ARRIVED;
    2352              :             break;
    2353            0 :         default:
    2354            0 :             throw TraCIException("Unknown removal status.");
    2355              :     }
    2356           30 :     if (veh->hasDeparted()) {
    2357           26 :         veh->onRemovalFromNet(n);
    2358           26 :         MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
    2359           26 :         if (microVeh != nullptr) {
    2360           24 :             if (veh->getLane() != nullptr) {
    2361           24 :                 microVeh->getMutableLane()->removeVehicle(dynamic_cast<MSVehicle*>(veh), n);
    2362              :             }
    2363           24 :             MSNet::getInstance()->getVehicleControl().scheduleVehicleRemoval(veh);
    2364              :         }
    2365           26 :         MSNet::getInstance()->getVehicleControl().removePending();
    2366              :     } else {
    2367            4 :         MSNet::getInstance()->getInsertionControl().alreadyDeparted(veh);
    2368            4 :         MSNet::getInstance()->getVehicleControl().deleteVehicle(veh, true);
    2369              :     }
    2370           30 : }
    2371              : 
    2372              : 
    2373              : void
    2374          179 : Vehicle::setColor(const std::string& vehID, const TraCIColor& col) {
    2375          179 :     const SUMOVehicleParameter& p = Helper::getVehicle(vehID)->getParameter();
    2376          179 :     p.color.set((unsigned char)col.r, (unsigned char)col.g, (unsigned char)col.b, (unsigned char)col.a);
    2377          179 :     p.parametersSet |= VEHPARS_COLOR_SET;
    2378          179 : }
    2379              : 
    2380              : 
    2381              : void
    2382         6321 : Vehicle::setSpeedFactor(const std::string& vehID, double factor) {
    2383         6321 :     Helper::getVehicle(vehID)->setChosenSpeedFactor(factor);
    2384         6321 : }
    2385              : 
    2386              : 
    2387              : void
    2388           15 : Vehicle::setLine(const std::string& vehID, const std::string& line) {
    2389           15 :     Helper::getVehicle(vehID)->getParameter().line = line;
    2390           15 : }
    2391              : 
    2392              : 
    2393              : void
    2394           19 : Vehicle::setVia(const std::string& vehID, const std::vector<std::string>& edgeList) {
    2395           19 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2396              :     try {
    2397              :         // ensure edges exist
    2398            0 :         ConstMSEdgeVector edges;
    2399           19 :         MSEdge::parseEdgesList(edgeList, edges, "<via-edges>");
    2400           19 :     } catch (ProcessError& e) {
    2401            0 :         throw TraCIException(e.what());
    2402            0 :     }
    2403           19 :     veh->getParameter().via = edgeList;
    2404           19 : }
    2405              : 
    2406              : 
    2407              : void
    2408           45 : Vehicle::setLength(const std::string& vehID, double length) {
    2409           45 :     Helper::getVehicle(vehID)->getSingularType().setLength(length);
    2410           45 : }
    2411              : 
    2412              : 
    2413              : void
    2414           17 : Vehicle::setMaxSpeed(const std::string& vehID, double speed) {
    2415           17 :     Helper::getVehicle(vehID)->getSingularType().setMaxSpeed(speed);
    2416           17 : }
    2417              : 
    2418              : 
    2419              : void
    2420            4 : Vehicle::setVehicleClass(const std::string& vehID, const std::string& clazz) {
    2421            4 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2422            4 :     veh->getSingularType().setVClass(getVehicleClassID(clazz));
    2423            4 :     MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
    2424            4 :     if (microVeh != nullptr && microVeh->isOnRoad()) {
    2425            4 :         microVeh->updateBestLanes(true);
    2426              :     }
    2427            4 : }
    2428              : 
    2429              : 
    2430              : void
    2431            4 : Vehicle::setShapeClass(const std::string& vehID, const std::string& clazz) {
    2432            4 :     Helper::getVehicle(vehID)->getSingularType().setShape(getVehicleShapeID(clazz));
    2433            4 : }
    2434              : 
    2435              : 
    2436              : void
    2437           10 : Vehicle::setEmissionClass(const std::string& vehID, const std::string& clazz) {
    2438           10 :     Helper::getVehicle(vehID)->getSingularType().setEmissionClass(PollutantsInterface::getClassByName(clazz));
    2439            9 : }
    2440              : 
    2441              : 
    2442              : void
    2443            5 : Vehicle::setWidth(const std::string& vehID, double width) {
    2444            5 :     Helper::getVehicle(vehID)->getSingularType().setWidth(width);
    2445            5 : }
    2446              : 
    2447              : 
    2448              : void
    2449            4 : Vehicle::setHeight(const std::string& vehID, double height) {
    2450            4 :     Helper::getVehicle(vehID)->getSingularType().setHeight(height);
    2451            4 : }
    2452              : 
    2453              : 
    2454              : void
    2455            4 : Vehicle::setMass(const std::string& vehID, double mass) {
    2456            4 :     Helper::getVehicle(vehID)->getSingularType().setMass(mass);
    2457            4 : }
    2458              : 
    2459              : 
    2460              : void
    2461           14 : Vehicle::setMinGap(const std::string& vehID, double minGap) {
    2462           14 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2463           14 :     veh->getSingularType().setMinGap(minGap);
    2464           14 :     MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
    2465           14 :     if (microVeh != nullptr && microVeh->isOnRoad()) {
    2466           12 :         microVeh->updateLaneBruttoSum();
    2467              :     }
    2468           14 : }
    2469              : 
    2470              : 
    2471              : void
    2472            9 : Vehicle::setAccel(const std::string& vehID, double accel) {
    2473            9 :     Helper::getVehicle(vehID)->getSingularType().setAccel(accel);
    2474            7 : }
    2475              : 
    2476              : 
    2477              : void
    2478            5 : Vehicle::setDecel(const std::string& vehID, double decel) {
    2479            5 :     VehicleType::setDecel(Helper::getVehicle(vehID)->getSingularType().getID(), decel);
    2480            5 : }
    2481              : 
    2482              : 
    2483              : void
    2484            9 : Vehicle::setEmergencyDecel(const std::string& vehID, double decel) {
    2485            9 :     VehicleType::setEmergencyDecel(Helper::getVehicle(vehID)->getSingularType().getID(), decel);
    2486            9 : }
    2487              : 
    2488              : 
    2489              : void
    2490            5 : Vehicle::setApparentDecel(const std::string& vehID, double decel) {
    2491            5 :     Helper::getVehicle(vehID)->getSingularType().setApparentDecel(decel);
    2492            5 : }
    2493              : 
    2494              : 
    2495              : void
    2496            9 : Vehicle::setImperfection(const std::string& vehID, double imperfection) {
    2497            9 :     Helper::getVehicle(vehID)->getSingularType().setImperfection(imperfection);
    2498            9 : }
    2499              : 
    2500              : 
    2501              : void
    2502            5 : Vehicle::setTau(const std::string& vehID, double tau) {
    2503            5 :     Helper::getVehicle(vehID)->getSingularType().setTau(tau);
    2504            5 : }
    2505              : 
    2506              : 
    2507              : void
    2508            9 : Vehicle::setMinGapLat(const std::string& vehID, double minGapLat) {
    2509              :     try {
    2510           18 :         setParameter(vehID, "laneChangeModel.minGapLat", toString(minGapLat));
    2511            5 :     } catch (TraCIException&) {
    2512              :         // legacy behavior
    2513            5 :         Helper::getVehicle(vehID)->getSingularType().setMinGapLat(minGapLat);
    2514            5 :     }
    2515            9 : }
    2516              : 
    2517              : 
    2518              : void
    2519            4 : Vehicle::setMaxSpeedLat(const std::string& vehID, double speed) {
    2520            4 :     Helper::getVehicle(vehID)->getSingularType().setMaxSpeedLat(speed);
    2521            4 : }
    2522              : 
    2523              : 
    2524              : void
    2525            4 : Vehicle::setLateralAlignment(const std::string& vehID, const std::string& latAlignment) {
    2526              :     double lao;
    2527              :     LatAlignmentDefinition lad;
    2528            4 :     if (SUMOVTypeParameter::parseLatAlignment(latAlignment, lao, lad)) {
    2529            4 :         Helper::getVehicle(vehID)->getSingularType().setPreferredLateralAlignment(lad, lao);
    2530              :     } else {
    2531            0 :         throw TraCIException("Unknown value '" + latAlignment + "' when setting latAlignment for vehID '" + vehID + "';\n must be one of (\"right\", \"center\", \"arbitrary\", \"nice\", \"compact\", \"left\" or a float)");
    2532              :     }
    2533            4 : }
    2534              : 
    2535              : 
    2536              : void
    2537          545 : Vehicle::setParameter(const std::string& vehID, const std::string& key, const std::string& value) {
    2538          545 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2539          543 :     MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
    2540         1086 :     if (StringUtils::startsWith(key, "device.")) {
    2541          624 :         StringTokenizer tok(key, ".");
    2542          208 :         if (tok.size() < 3) {
    2543            0 :             throw TraCIException("Invalid device parameter '" + key + "' for vehicle '" + vehID + "'");
    2544              :         }
    2545              :         try {
    2546          624 :             veh->setDeviceParameter(tok.get(1), key.substr(tok.get(0).size() + tok.get(1).size() + 2), value);
    2547            0 :         } catch (InvalidArgument& e) {
    2548            0 :             throw TraCIException("Vehicle '" + vehID + "' does not support device parameter '" + key + "' (" + e.what() + ").");
    2549            0 :         }
    2550          878 :     } else if (StringUtils::startsWith(key, "laneChangeModel.")) {
    2551          107 :         if (microVeh == nullptr) {
    2552           24 :             throw TraCIException("Meso Vehicle '" + vehID + "' does not support laneChangeModel parameters.");
    2553              :         }
    2554           95 :         const std::string attrName = key.substr(16);
    2555           99 :         if (attrName == toString(SUMO_ATTR_LCA_CONTRIGHT)) {
    2556              :             // special case: not used within lcModel
    2557            3 :             veh->getSingularType().setLcContRight(value);
    2558              :         } else {
    2559              :             try {
    2560           92 :                 microVeh->getLaneChangeModel().setParameter(attrName, value);
    2561            4 :             } catch (InvalidArgument& e) {
    2562            8 :                 throw TraCIException("Vehicle '" + vehID + "' does not support laneChangeModel parameter '" + key + "' (" + e.what() + ").");
    2563            4 :             }
    2564              :         }
    2565          456 :     } else if (StringUtils::startsWith(key, "carFollowModel.")) {
    2566           18 :         if (microVeh == nullptr) {
    2567            4 :             throw TraCIException("Meso Vehicle '" + vehID + "' does not support carFollowModel parameters.");
    2568              :         }
    2569              :         try {
    2570           16 :             veh->setCarFollowModelParameter(key, value);
    2571            4 :         } catch (InvalidArgument& e) {
    2572            8 :             throw TraCIException("Vehicle '" + vehID + "' does not support carFollowModel parameter '" + key + "' (" + e.what() + ").");
    2573            4 :         }
    2574          420 :     } else if (StringUtils::startsWith(key, "junctionModel.")) {
    2575              :         try {
    2576              :             // use the whole key (including junctionModel prefix)
    2577           10 :             veh->setJunctionModelParameter(key, value);
    2578            5 :         } catch (InvalidArgument& e) {
    2579              :             // error message includes id since it is also used for xml input
    2580           10 :             throw TraCIException(e.what());
    2581            5 :         }
    2582          209 :     } else if (StringUtils::startsWith(key, "has.") && StringUtils::endsWith(key, ".device")) {
    2583           27 :         StringTokenizer tok(key, ".");
    2584            9 :         if (tok.size() != 3) {
    2585            0 :             throw TraCIException("Invalid request for device status change. Expected format is 'has.DEVICENAME.device'");
    2586              :         }
    2587            9 :         const std::string deviceName = tok.get(1);
    2588              :         bool create;
    2589              :         try {
    2590            9 :             create = StringUtils::toBool(value);
    2591            0 :         } catch (BoolFormatException&) {
    2592            0 :             throw TraCIException("Changing device status requires a 'true' or 'false'");
    2593            0 :         }
    2594            9 :         if (!create) {
    2595            0 :             throw TraCIException("Device removal is not supported for device of type '" + deviceName + "'");
    2596              :         }
    2597              :         try {
    2598            9 :             veh->createDevice(deviceName);
    2599            0 :         } catch (InvalidArgument& e) {
    2600            0 :             throw TraCIException("Cannot create vehicle device (" + std::string(e.what()) + ").");
    2601            0 :         }
    2602            9 :     } else {
    2603          191 :         ((SUMOVehicleParameter&)veh->getParameter()).setParameter(key, value);
    2604              :     }
    2605          516 : }
    2606              : 
    2607              : 
    2608              : void
    2609           38 : Vehicle::highlight(const std::string& vehID, const TraCIColor& col, double size, const int alphaMax, const double duration, const int type) {
    2610              : 
    2611              :     // NOTE: Code is duplicated in large parts in POI.cpp
    2612           38 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2613              : 
    2614              :     // Center of the highlight circle
    2615           38 :     Position center = veh->getPosition();
    2616           38 :     const double l2 = veh->getLength() * 0.5;
    2617           38 :     center.sub(cos(veh->getAngle())*l2, sin(veh->getAngle())*l2);
    2618              :     // Size of the highlight circle
    2619           38 :     if (size <= 0) {
    2620           38 :         size = veh->getLength() * 0.7;
    2621              :     }
    2622              :     // Make polygon shape
    2623              :     const unsigned int nPoints = 34;
    2624           38 :     const PositionVector circlePV = GeomHelper::makeRing(size, size + 1., center, nPoints);
    2625           38 :     TraCIPositionVector circle = Helper::makeTraCIPositionVector(circlePV);
    2626              : 
    2627              : #ifdef DEBUG_DYNAMIC_SHAPES
    2628              :     std::cout << SIMTIME << " Vehicle::highlight() for vehicle '" << vehID << "'\n"
    2629              :               << " circle: " << circlePV << std::endl;
    2630              : #endif
    2631              : 
    2632              :     // Find a free polygon id
    2633           38 :     int i = 0;
    2634           76 :     std::string polyID = veh->getID() + "_hl" + toString(i);
    2635          130 :     while (Polygon::exists(polyID)) {
    2636           16 :         polyID = veh->getID() + "_hl" + toString(++i);
    2637              :     }
    2638              :     // Line width
    2639              :     double lw = 0.;
    2640              :     // Layer
    2641              :     double lyr = 0.;
    2642           38 :     if (MSNet::getInstance()->isGUINet()) {
    2643              :         lyr = (double)GLO_VEHICLE + 0.01;
    2644           15 :         lyr += (type + 1) / 257.;
    2645              :     }
    2646              :     // Make Polygon
    2647           76 :     Polygon::addHighlightPolygon(vehID, type, polyID, circle, col, true, "highlight", (int)lyr, lw);
    2648              : 
    2649              :     // Animation time line
    2650              :     double maxAttack = 1.0; // maximal fade-in time
    2651            0 :     std::vector<double> timeSpan;
    2652           38 :     if (duration > 0.) {
    2653           60 :         timeSpan = {0, MIN2(maxAttack, duration / 3.), 2.*duration / 3., duration};
    2654              :     }
    2655              :     // Alpha time line
    2656            0 :     std::vector<double> alphaSpan;
    2657           38 :     if (alphaMax > 0.) {
    2658           44 :         alphaSpan = {0., (double) alphaMax, (double)(alphaMax) / 3., 0.};
    2659              :     }
    2660              :     // Attach dynamics
    2661           38 :     Polygon::addDynamics(polyID, vehID, timeSpan, alphaSpan, false, true);
    2662           76 : }
    2663              : 
    2664              : void
    2665          232 : Vehicle::dispatchTaxi(const std::string& vehID,  const std::vector<std::string>& reservations) {
    2666          232 :     MSBaseVehicle* veh = Helper::getVehicle(vehID);
    2667          232 :     MSDevice_Taxi* taxi = static_cast<MSDevice_Taxi*>(veh->getDevice(typeid(MSDevice_Taxi)));
    2668          232 :     if (!veh->hasDeparted()) {
    2669           10 :         throw TraCIException("Vehicle '" + vehID + "' has not yet departed");
    2670              :     }
    2671          227 :     if (taxi == nullptr) {
    2672            0 :         throw TraCIException("Vehicle '" + vehID + "' is not a taxi");
    2673              :     }
    2674              :     MSDispatch* dispatcher = MSDevice_Taxi::getDispatchAlgorithm();
    2675          227 :     if (dispatcher == nullptr) {
    2676            0 :         throw TraCIException("Cannot dispatch taxi because no reservations have been made");
    2677              :     }
    2678          227 :     MSDispatch_TraCI* traciDispatcher = dynamic_cast<MSDispatch_TraCI*>(dispatcher);
    2679          227 :     if (traciDispatcher == nullptr) {
    2680           30 :         throw TraCIException("device.taxi.dispatch-algorithm 'traci' has not been loaded");
    2681              :     }
    2682          212 :     if (reservations.size() == 0) {
    2683            0 :         throw TraCIException("No reservations have been specified for vehicle '" + vehID + "'");
    2684              :     }
    2685              :     try {
    2686          212 :         traciDispatcher->interpretDispatch(taxi, reservations);
    2687            4 :     } catch (InvalidArgument& e) {
    2688            8 :         throw TraCIException("Could not interpret reservations for vehicle '" + vehID + "' (" + e.what() + ").");
    2689            4 :     }
    2690          208 : }
    2691              : 
    2692        30909 : LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(Vehicle, VEHICLE)
    2693              : 
    2694              : 
    2695              : void
    2696           34 : Vehicle::subscribeLeader(const std::string& vehID, double dist, double begin, double end) {
    2697           34 :     subscribe(vehID, std::vector<int>({ libsumo::VAR_LEADER }), begin, end,
    2698          102 :     libsumo::TraCIResults({ {libsumo::VAR_LEADER, std::make_shared<libsumo::TraCIDouble>(dist)} }));
    2699           34 : }
    2700              : 
    2701              : 
    2702              : void
    2703           86 : Vehicle::addSubscriptionFilterLanes(const std::vector<int>& lanes, bool noOpposite, double downstreamDist, double upstreamDist) {
    2704           86 :     Subscription* s = Helper::addSubscriptionFilter(SUBS_FILTER_LANES);
    2705           86 :     if (s != nullptr) {
    2706           86 :         s->filterLanes = lanes;
    2707              :     }
    2708           86 :     if (noOpposite) {
    2709            2 :         addSubscriptionFilterNoOpposite();
    2710              :     }
    2711           86 :     if (downstreamDist != INVALID_DOUBLE_VALUE) {
    2712            4 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    2713              :     }
    2714           86 :     if (upstreamDist != INVALID_DOUBLE_VALUE) {
    2715            4 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    2716              :     }
    2717           86 : }
    2718              : 
    2719              : 
    2720              : void
    2721           28 : Vehicle::addSubscriptionFilterNoOpposite() {
    2722           28 :     Helper::addSubscriptionFilter(SUBS_FILTER_NOOPPOSITE);
    2723           28 : }
    2724              : 
    2725              : 
    2726              : void
    2727          102 : Vehicle::addSubscriptionFilterDownstreamDistance(double dist) {
    2728          102 :     Subscription* s = Helper::addSubscriptionFilter(SUBS_FILTER_DOWNSTREAM_DIST);
    2729          102 :     if (s != nullptr) {
    2730          102 :         s->filterDownstreamDist = dist;
    2731              :     }
    2732          102 : }
    2733              : 
    2734              : 
    2735              : void
    2736           86 : Vehicle::addSubscriptionFilterUpstreamDistance(double dist) {
    2737           86 :     Subscription* s = Helper::addSubscriptionFilter(SUBS_FILTER_UPSTREAM_DIST);
    2738           86 :     if (s != nullptr) {
    2739           86 :         s->filterUpstreamDist = dist;
    2740              :     }
    2741           86 : }
    2742              : 
    2743              : 
    2744              : void
    2745            2 : Vehicle::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) {
    2746            2 :     addSubscriptionFilterLeadFollow(std::vector<int>({0}));
    2747            2 :     if (downstreamDist != INVALID_DOUBLE_VALUE) {
    2748            0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    2749              :     }
    2750            2 :     if (upstreamDist != INVALID_DOUBLE_VALUE) {
    2751            0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    2752              :     }
    2753              : 
    2754            2 : }
    2755              : 
    2756              : 
    2757              : void
    2758            8 : Vehicle::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) {
    2759            0 :     std::vector<int> lanes;
    2760            8 :     if (direction == INVALID_INT_VALUE) {
    2761              :         // Using default: both directions
    2762            2 :         lanes = std::vector<int>({-1, 0, 1});
    2763            6 :     } else if (direction != -1 && direction != 1) {
    2764            0 :         WRITE_WARNINGF(TL("Ignoring lane change subscription filter with non-neighboring lane offset direction=%."), direction);
    2765              :     } else {
    2766            6 :         lanes = std::vector<int>({0, direction});
    2767              :     }
    2768            8 :     addSubscriptionFilterLeadFollow(lanes);
    2769            8 :     if (noOpposite) {
    2770            0 :         addSubscriptionFilterNoOpposite();
    2771              :     }
    2772            8 :     if (downstreamDist != INVALID_DOUBLE_VALUE) {
    2773            0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    2774              :     }
    2775            8 :     if (upstreamDist != INVALID_DOUBLE_VALUE) {
    2776            0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    2777              :     }
    2778            8 : }
    2779              : 
    2780              : 
    2781              : void
    2782           10 : Vehicle::addSubscriptionFilterLeadFollow(const std::vector<int>& lanes) {
    2783           10 :     Helper::addSubscriptionFilter(SUBS_FILTER_LEAD_FOLLOW);
    2784           10 :     addSubscriptionFilterLanes(lanes);
    2785           10 : }
    2786              : 
    2787              : 
    2788              : void
    2789           16 : Vehicle::addSubscriptionFilterTurn(double downstreamDist, double foeDistToJunction) {
    2790           16 :     Subscription* s = Helper::addSubscriptionFilter(SUBS_FILTER_TURN);
    2791           16 :     if (downstreamDist != INVALID_DOUBLE_VALUE) {
    2792           16 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    2793              :     }
    2794           16 :     if (foeDistToJunction != INVALID_DOUBLE_VALUE) {
    2795           16 :         s->filterFoeDistToJunction = foeDistToJunction;
    2796              :     }
    2797           16 : }
    2798              : 
    2799              : 
    2800              : void
    2801            6 : Vehicle::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) {
    2802            6 :     Subscription* s = Helper::addSubscriptionFilter(SUBS_FILTER_VCLASS);
    2803            6 :     if (s != nullptr) {
    2804            6 :         s->filterVClasses = parseVehicleClasses(vClasses);
    2805              :     }
    2806            6 : }
    2807              : 
    2808              : 
    2809              : void
    2810            6 : Vehicle::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) {
    2811            6 :     Subscription* s = Helper::addSubscriptionFilter(SUBS_FILTER_VTYPE);
    2812            6 :     if (s != nullptr) {
    2813              :         s->filterVTypes.insert(vTypes.begin(), vTypes.end());
    2814              :     }
    2815            6 : }
    2816              : 
    2817              : 
    2818              : void
    2819           16 : Vehicle::addSubscriptionFilterFieldOfVision(double openingAngle) {
    2820           16 :     Subscription* s = Helper::addSubscriptionFilter(SUBS_FILTER_FIELD_OF_VISION);
    2821           16 :     if (s != nullptr) {
    2822           16 :         s->filterFieldOfVisionOpeningAngle = openingAngle;
    2823              :     }
    2824           16 : }
    2825              : 
    2826              : 
    2827              : void
    2828           15 : Vehicle::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) {
    2829           15 :     Subscription* s = Helper::addSubscriptionFilter(SUBS_FILTER_LATERAL_DIST);
    2830           14 :     if (s != nullptr) {
    2831           14 :         s->filterLateralDist = lateralDist;
    2832              :     }
    2833           14 :     if (downstreamDist != INVALID_DOUBLE_VALUE) {
    2834           14 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    2835              :     }
    2836           14 :     if (upstreamDist != INVALID_DOUBLE_VALUE) {
    2837           14 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    2838              :     }
    2839           14 : }
    2840              : 
    2841              : 
    2842              : void
    2843        21195 : Vehicle::storeShape(const std::string& id, PositionVector& shape) {
    2844        21195 :     shape.push_back(Helper::getVehicle(id)->getPosition());
    2845        21195 : }
    2846              : 
    2847              : 
    2848              : std::shared_ptr<VariableWrapper>
    2849          273 : Vehicle::makeWrapper() {
    2850          273 :     return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
    2851              : }
    2852              : 
    2853              : 
    2854              : bool
    2855     10061191 : Vehicle::handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData) {
    2856     10061191 :     switch (variable) {
    2857       166051 :         case TRACI_ID_LIST:
    2858       166051 :             return wrapper->wrapStringList(objID, variable, getIDList());
    2859           89 :         case ID_COUNT:
    2860           89 :             return wrapper->wrapInt(objID, variable, getIDCount());
    2861      1312747 :         case VAR_POSITION:
    2862      1312747 :             return wrapper->wrapPosition(objID, variable, getPosition(objID));
    2863         1284 :         case VAR_POSITION3D:
    2864         1284 :             return wrapper->wrapPosition(objID, variable, getPosition(objID, true));
    2865          264 :         case VAR_ANGLE:
    2866          264 :             return wrapper->wrapDouble(objID, variable, getAngle(objID));
    2867       170327 :         case VAR_SPEED:
    2868       170327 :             return wrapper->wrapDouble(objID, variable, getSpeed(objID));
    2869           54 :         case VAR_SPEED_LAT:
    2870           54 :             return wrapper->wrapDouble(objID, variable, getLateralSpeed(objID));
    2871      4121715 :         case VAR_ROAD_ID:
    2872      8243428 :             return wrapper->wrapString(objID, variable, getRoadID(objID));
    2873         2079 :         case VAR_SPEED_WITHOUT_TRACI:
    2874         2079 :             return wrapper->wrapDouble(objID, variable, getSpeedWithoutTraCI(objID));
    2875           14 :         case VAR_SLOPE:
    2876           14 :             return wrapper->wrapDouble(objID, variable, getSlope(objID));
    2877        33492 :         case VAR_LANE_ID:
    2878        66978 :             return wrapper->wrapString(objID, variable, getLaneID(objID));
    2879           34 :         case VAR_SHADOW_LANE_ID:
    2880           68 :             return wrapper->wrapString(objID, variable, getShadowLaneID(objID));
    2881        29094 :         case VAR_LANE_INDEX:
    2882        29094 :             return wrapper->wrapInt(objID, variable, getLaneIndex(objID));
    2883           75 :         case VAR_SEGMENT_ID:
    2884          147 :             return wrapper->wrapString(objID, variable, getSegmentID(objID));
    2885           72 :         case VAR_SEGMENT_INDEX:
    2886           72 :             return wrapper->wrapInt(objID, variable, getSegmentIndex(objID));
    2887          219 :         case VAR_TYPE:
    2888          433 :             return wrapper->wrapString(objID, variable, getTypeID(objID));
    2889           83 :         case VAR_ROUTE_ID:
    2890          161 :             return wrapper->wrapString(objID, variable, getRouteID(objID));
    2891           53 :         case VAR_DEPARTURE:
    2892           53 :             return wrapper->wrapDouble(objID, variable, getDeparture(objID));
    2893           53 :         case VAR_DEPART_DELAY:
    2894           53 :             return wrapper->wrapDouble(objID, variable, getDepartDelay(objID));
    2895         2021 :         case VAR_ROUTE_INDEX:
    2896         2021 :             return wrapper->wrapInt(objID, variable, getRouteIndex(objID));
    2897          603 :         case VAR_COLOR:
    2898          603 :             return wrapper->wrapColor(objID, variable, getColor(objID));
    2899      4102628 :         case VAR_LANEPOSITION:
    2900      4102628 :             return wrapper->wrapDouble(objID, variable, getLanePosition(objID));
    2901         1704 :         case VAR_LANEPOSITION_LAT:
    2902         1704 :             return wrapper->wrapDouble(objID, variable, getLateralLanePosition(objID));
    2903          255 :         case VAR_CO2EMISSION:
    2904          255 :             return wrapper->wrapDouble(objID, variable, getCO2Emission(objID));
    2905           55 :         case VAR_COEMISSION:
    2906           55 :             return wrapper->wrapDouble(objID, variable, getCOEmission(objID));
    2907           55 :         case VAR_HCEMISSION:
    2908           55 :             return wrapper->wrapDouble(objID, variable, getHCEmission(objID));
    2909           55 :         case VAR_PMXEMISSION:
    2910           55 :             return wrapper->wrapDouble(objID, variable, getPMxEmission(objID));
    2911           55 :         case VAR_NOXEMISSION:
    2912           55 :             return wrapper->wrapDouble(objID, variable, getNOxEmission(objID));
    2913          265 :         case VAR_FUELCONSUMPTION:
    2914          265 :             return wrapper->wrapDouble(objID, variable, getFuelConsumption(objID));
    2915           55 :         case VAR_NOISEEMISSION:
    2916           55 :             return wrapper->wrapDouble(objID, variable, getNoiseEmission(objID));
    2917          103 :         case VAR_ELECTRICITYCONSUMPTION:
    2918          103 :             return wrapper->wrapDouble(objID, variable, getElectricityConsumption(objID));
    2919          302 :         case VAR_PERSON_NUMBER:
    2920          302 :             return wrapper->wrapInt(objID, variable, getPersonNumber(objID));
    2921          315 :         case VAR_PERSON_CAPACITY:
    2922          315 :             return wrapper->wrapInt(objID, variable, getPersonCapacity(objID));
    2923           53 :         case VAR_BOARDING_DURATION:
    2924           53 :             return wrapper->wrapDouble(objID, variable, getBoardingDuration(objID));
    2925          114 :         case LAST_STEP_PERSON_ID_LIST:
    2926          114 :             return wrapper->wrapStringList(objID, variable, getPersonIDList(objID));
    2927          136 :         case VAR_WAITING_TIME:
    2928          136 :             return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
    2929           70 :         case VAR_ACCUMULATED_WAITING_TIME:
    2930           70 :             return wrapper->wrapDouble(objID, variable, getAccumulatedWaitingTime(objID));
    2931              :         case VAR_EDGE_TRAVELTIME: {
    2932           73 :             StoHelp::readCompound(*paramData);
    2933           73 :             const double time = StoHelp::readTypedDouble(*paramData);
    2934          146 :             return wrapper->wrapDouble(objID, variable, getAdaptedTraveltime(objID, time, StoHelp::readTypedString(*paramData)));
    2935              :         }
    2936              :         case VAR_EDGE_EFFORT: {
    2937           71 :             StoHelp::readCompound(*paramData);
    2938           71 :             const double time = StoHelp::readTypedDouble(*paramData);
    2939          142 :             return wrapper->wrapDouble(objID, variable, getEffort(objID, time, StoHelp::readTypedString(*paramData)));
    2940              :         }
    2941           54 :         case VAR_ROUTE_VALID:
    2942           54 :             return wrapper->wrapInt(objID, variable, isRouteValid(objID));
    2943         2197 :         case VAR_EDGES:
    2944         2197 :             return wrapper->wrapStringList(objID, variable, getRoute(objID));
    2945           56 :         case VAR_SIGNALS:
    2946           56 :             return wrapper->wrapInt(objID, variable, getSignals(objID));
    2947           58 :         case VAR_BEST_LANES:
    2948           58 :             return wrapper->wrapBestLanesDataVector(objID, variable, getBestLanes(objID));
    2949           35 :         case VAR_NEXT_LINKS:
    2950           35 :             return wrapper->wrapConnectionVector(objID, variable, getNextLinks(objID));
    2951         1145 :         case VAR_STOPSTATE:
    2952         1145 :             return wrapper->wrapInt(objID, variable, getStopState(objID));
    2953          368 :         case VAR_DISTANCE:
    2954          368 :             return wrapper->wrapDouble(objID, variable, getDistance(objID));
    2955           53 :         case VAR_REFERENCE_DISTANCE:
    2956           53 :             return wrapper->wrapDouble(objID, variable, getReferenceDistance(objID));
    2957           53 :         case VAR_ALLOWED_SPEED:
    2958           53 :             return wrapper->wrapDouble(objID, variable, getAllowedSpeed(objID));
    2959          118 :         case VAR_SPEED_FACTOR:
    2960          118 :             return wrapper->wrapDouble(objID, variable, getSpeedFactor(objID));
    2961           46 :         case VAR_SPEEDSETMODE:
    2962           46 :             return wrapper->wrapInt(objID, variable, getSpeedMode(objID));
    2963          148 :         case VAR_LANECHANGE_MODE:
    2964          148 :             return wrapper->wrapInt(objID, variable, getLaneChangeMode(objID));
    2965          151 :         case VAR_ROUTING_MODE:
    2966          151 :             return wrapper->wrapInt(objID, variable, getRoutingMode(objID));
    2967           54 :         case VAR_LINE:
    2968          108 :             return wrapper->wrapString(objID, variable, getLine(objID));
    2969           54 :         case VAR_VIA:
    2970           54 :             return wrapper->wrapStringList(objID, variable, getVia(objID));
    2971         2665 :         case VAR_ACCELERATION:
    2972         2665 :             return wrapper->wrapDouble(objID, variable, getAcceleration(objID));
    2973           53 :         case VAR_LASTACTIONTIME:
    2974           53 :             return wrapper->wrapDouble(objID, variable, getLastActionTime(objID));
    2975         1616 :         case VAR_STOP_DELAY:
    2976         1616 :             return wrapper->wrapDouble(objID, variable, getStopDelay(objID));
    2977           68 :         case VAR_IMPATIENCE:
    2978           68 :             return wrapper->wrapDouble(objID, variable, getImpatience(objID));
    2979         1615 :         case VAR_STOP_ARRIVALDELAY:
    2980         1615 :             return wrapper->wrapDouble(objID, variable, getStopArrivalDelay(objID));
    2981           53 :         case VAR_TIMELOSS:
    2982           53 :             return wrapper->wrapDouble(objID, variable, getTimeLoss(objID));
    2983           53 :         case VAR_MINGAP_LAT:
    2984           53 :             return wrapper->wrapDouble(objID, variable, getMinGapLat(objID));
    2985        31496 :         case VAR_LEADER:
    2986        62992 :             return wrapper->wrapStringDoublePair(objID, variable, getLeader(objID, StoHelp::readTypedDouble(*paramData)));
    2987          184 :         case VAR_FOLLOWER:
    2988          365 :             return wrapper->wrapStringDoublePair(objID, variable, getFollower(objID, StoHelp::readTypedDouble(*paramData)));
    2989          130 :         case VAR_LOADED_LIST:
    2990          130 :             return wrapper->wrapStringList(objID, variable, getLoadedIDList());
    2991          105 :         case VAR_TELEPORTING_LIST:
    2992          105 :             return wrapper->wrapStringList(objID, variable, getTeleportingIDList());
    2993              :         case VAR_FOLLOW_SPEED: {
    2994          363 :             StoHelp::readCompound(*paramData);
    2995          363 :             const double speed = StoHelp::readTypedDouble(*paramData);
    2996          363 :             const double gap = StoHelp::readTypedDouble(*paramData);
    2997          363 :             const double leaderSpeed = StoHelp::readTypedDouble(*paramData);
    2998          363 :             const double leaderMaxDecel = StoHelp::readTypedDouble(*paramData);
    2999          726 :             return wrapper->wrapDouble(objID, variable, getFollowSpeed(objID, speed, gap, leaderSpeed, leaderMaxDecel, StoHelp::readTypedString(*paramData)));
    3000              :         }
    3001              :         case VAR_SECURE_GAP: {
    3002           13 :             StoHelp::readCompound(*paramData);
    3003           13 :             const double speed = StoHelp::readTypedDouble(*paramData);
    3004           13 :             const double leaderSpeed = StoHelp::readTypedDouble(*paramData);
    3005           13 :             const double leaderMaxDecel = StoHelp::readTypedDouble(*paramData);
    3006           26 :             return wrapper->wrapDouble(objID, variable, getSecureGap(objID, speed, leaderSpeed, leaderMaxDecel, StoHelp::readTypedString(*paramData)));
    3007              :         }
    3008              :         case VAR_STOP_SPEED: {
    3009           13 :             StoHelp::readCompound(*paramData);
    3010           13 :             const double speed = StoHelp::readTypedDouble(*paramData);
    3011           26 :             return wrapper->wrapDouble(objID, variable, getStopSpeed(objID, speed, StoHelp::readTypedDouble(*paramData)));
    3012              :         }
    3013           98 :         case VAR_FOES:
    3014          196 :             return wrapper->wrapJunctionFoeVector(objID, variable, getJunctionFoes(objID, StoHelp::readTypedDouble(*paramData)));
    3015         2928 :         case VAR_NEIGHBORS:
    3016         5856 :             return wrapper->wrapStringDoublePairList(objID, variable, getNeighbors(objID, StoHelp::readTypedByte(*paramData)));
    3017         7115 :         case CMD_CHANGELANE:
    3018        14230 :             return wrapper->wrapIntPair(objID, variable, getLaneChangeState(objID, StoHelp::readTypedInt(*paramData)));
    3019              :         case VAR_STOP_PARAMETER: {
    3020          259 :             const int count = StoHelp::readCompound(*paramData);
    3021          259 :             const int nextStopIndex = StoHelp::readTypedInt(*paramData);
    3022          259 :             const std::string param = StoHelp::readTypedString(*paramData);
    3023          512 :             const bool customParam = count == 3 && StoHelp::readTypedByte(*paramData) != 0;
    3024          518 :             return wrapper->wrapString(objID, variable, getStopParameter(objID, nextStopIndex, param, customParam));
    3025              :         }
    3026          804 :         case VAR_NEXT_TLS:
    3027          804 :             return wrapper->wrapNextTLSDataVector(objID, variable, getNextTLS(objID));
    3028           41 :         case VAR_NEXT_STOPS:
    3029           41 :             return wrapper->wrapNextStopDataVector(objID, variable, getNextStops(objID));
    3030         2440 :         case VAR_NEXT_STOPS2:
    3031         4877 :             return wrapper->wrapNextStopDataVector(objID, variable, getStops(objID, StoHelp::readTypedInt(*paramData)));
    3032              :         case DISTANCE_REQUEST: {
    3033         3930 :             TraCIRoadPosition roadPos;
    3034              :             Position pos;
    3035         1965 :             if (Helper::readDistanceRequest(*paramData, roadPos, pos) == libsumo::POSITION_ROADMAP) {
    3036         1908 :                 return wrapper->wrapDouble(objID, variable, getDrivingDistance(objID, roadPos.edgeID, roadPos.pos, roadPos.laneIndex));
    3037              :             }
    3038           55 :             return wrapper->wrapDouble(objID, variable, getDrivingDistance2D(objID, pos.x(), pos.y()));
    3039              :         }
    3040         5502 :         case VAR_TAXI_FLEET:
    3041        11004 :             return wrapper->wrapStringList(objID, variable, getTaxiFleet(StoHelp::readTypedInt(*paramData)));
    3042        47609 :         case VAR_PARAMETER:
    3043        95206 :             return wrapper->wrapString(objID, variable, getParameter(objID, StoHelp::readTypedString(*paramData)));
    3044           48 :         case VAR_PARAMETER_WITH_KEY:
    3045           96 :             return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, StoHelp::readTypedString(*paramData)));
    3046         2578 :         default:
    3047         5156 :             return VehicleType::handleVariableWithID(objID, getTypeID(objID), variable, wrapper, paramData);
    3048              :     }
    3049              : }
    3050              : 
    3051              : 
    3052              : }
    3053              : 
    3054              : 
    3055              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1