LCOV - code coverage report
Current view: top level - src/netload - NLBuilder.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 88.3 % 231 204
Test Date: 2025-11-13 15:38:19 Functions: 83.3 % 12 10

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2025 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    NLBuilder.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Michael Behrisch
      18              : /// @date    Mon, 9 Jul 2001
      19              : ///
      20              : // The main interface for loading a microsim
      21              : /****************************************************************************/
      22              : #include <config.h>
      23              : 
      24              : #include <iostream>
      25              : #include <vector>
      26              : #include <string>
      27              : #include <map>
      28              : 
      29              : #include <utils/common/MsgHandler.h>
      30              : #include <utils/common/StringTokenizer.h>
      31              : #include <utils/common/SystemFrame.h>
      32              : #include <utils/options/Option.h>
      33              : #include <utils/options/OptionsCont.h>
      34              : #include <utils/options/OptionsIO.h>
      35              : #include <utils/common/StringUtils.h>
      36              : #include <utils/common/FileHelpers.h>
      37              : #include <utils/common/SysUtils.h>
      38              : #include <utils/common/ToString.h>
      39              : #include <utils/vehicle/SUMORouteLoaderControl.h>
      40              : #include <utils/vehicle/SUMORouteLoader.h>
      41              : #include <utils/xml/XMLSubSys.h>
      42              : #ifdef HAVE_FOX
      43              : #include <utils/foxtools/MsgHandlerSynchronized.h>
      44              : #endif
      45              : #include <libsumo/Helper.h>
      46              : #include <mesosim/MEVehicleControl.h>
      47              : #include <microsim/MSVehicleControl.h>
      48              : #include <microsim/MSVehicleTransfer.h>
      49              : #include <microsim/MSNet.h>
      50              : #include <microsim/devices/MSDevice.h>
      51              : #include <microsim/devices/MSDevice_ToC.h>
      52              : #include <microsim/devices/MSDevice_BTreceiver.h>
      53              : #include <microsim/devices/MSDevice_FCDReplay.h>
      54              : #include <microsim/MSEdgeControl.h>
      55              : #include <microsim/MSGlobals.h>
      56              : #include <microsim/output/MSDetectorControl.h>
      57              : #include <microsim/MSFrame.h>
      58              : #include <microsim/MSEdgeWeightsStorage.h>
      59              : #include <microsim/MSStateHandler.h>
      60              : #include <microsim/MSDriverState.h>
      61              : #include <microsim/trigger/MSTriggeredRerouter.h>
      62              : #include <traci-server/TraCIServer.h>
      63              : 
      64              : #include "NLHandler.h"
      65              : #include "NLNetShapeHandler.h"
      66              : #include "NLEdgeControlBuilder.h"
      67              : #include "NLJunctionControlBuilder.h"
      68              : #include "NLDetectorBuilder.h"
      69              : #include "NLTriggerBuilder.h"
      70              : #include "NLBuilder.h"
      71              : 
      72              : 
      73              : // ===========================================================================
      74              : // method definitions
      75              : // ===========================================================================
      76              : // ---------------------------------------------------------------------------
      77              : // NLBuilder::EdgeFloatTimeLineRetriever_EdgeWeight - methods
      78              : // ---------------------------------------------------------------------------
      79              : void
      80            0 : NLBuilder::EdgeFloatTimeLineRetriever_EdgeEffort::addEdgeWeight(const std::string& id,
      81              :         double value, double begTime, double endTime) const {
      82            0 :     MSEdge* edge = MSEdge::dictionary(id);
      83            0 :     if (edge != nullptr) {
      84            0 :         myNet.getWeightsStorage().addEffort(edge, begTime, endTime, value);
      85              :     } else {
      86            0 :         WRITE_ERRORF(TL("Trying to set the effort for the unknown edge '%'."), id);
      87              :     }
      88            0 : }
      89              : 
      90              : 
      91              : // ---------------------------------------------------------------------------
      92              : // NLBuilder::EdgeFloatTimeLineRetriever_EdgeTravelTime - methods
      93              : // ---------------------------------------------------------------------------
      94              : void
      95           18 : NLBuilder::EdgeFloatTimeLineRetriever_EdgeTravelTime::addEdgeWeight(const std::string& id,
      96              :         double value, double begTime, double endTime) const {
      97           18 :     MSEdge* edge = MSEdge::dictionary(id);
      98           18 :     if (edge != nullptr) {
      99           18 :         myNet.getWeightsStorage().addTravelTime(edge, begTime, endTime, value);
     100              :     } else {
     101            0 :         WRITE_ERRORF(TL("Trying to set the travel time for the unknown edge '%'."), id);
     102              :     }
     103           18 : }
     104              : 
     105              : 
     106              : // ---------------------------------------------------------------------------
     107              : // NLBuilder - methods
     108              : // ---------------------------------------------------------------------------
     109        39017 : NLBuilder::NLBuilder(OptionsCont& oc,
     110              :                      MSNet& net,
     111              :                      NLEdgeControlBuilder& eb,
     112              :                      NLJunctionControlBuilder& jb,
     113              :                      NLDetectorBuilder& db,
     114        39017 :                      NLHandler& xmlHandler)
     115        39017 :     : myOptions(oc), myEdgeBuilder(eb), myJunctionBuilder(jb),
     116        39017 :       myDetectorBuilder(db),
     117        39017 :       myNet(net), myXMLHandler(xmlHandler) {}
     118              : 
     119              : 
     120        39017 : NLBuilder::~NLBuilder() {}
     121              : 
     122              : 
     123              : bool
     124        39017 : NLBuilder::build() {
     125              :     // try to build the net
     126        78034 :     if (!load("net-file", true)) {
     127              :         return false;
     128              :     }
     129        38638 :     if (myXMLHandler.networkVersion() == MMVersion(0, 0)) {
     130            0 :         throw ProcessError(TL("Invalid network, no network version declared."));
     131              :     }
     132              :     // check whether the loaded net agrees with the simulation options
     133        80318 :     if ((myOptions.getBool("no-internal-links") || myOptions.getBool("mesosim")) && myXMLHandler.haveSeenInternalEdge() && myXMLHandler.haveSeenDefaultLength()) {
     134         6150 :         WRITE_WARNING(TL("Network contains internal links which are ignored. Vehicles will 'jump' across junctions and thus underestimate route lengths and travel times."));
     135              :     }
     136        38638 :     buildNet();
     137        76882 :     if (myOptions.isSet("alternative-net-file")) {
     138            0 :         for (std::string fname : myOptions.getStringVector("alternative-net-file")) {
     139            0 :             const long before = PROGRESS_BEGIN_TIME_MESSAGE("Loading alternative net from '" + fname + "'");
     140            0 :             NLNetShapeHandler nsh(fname, myNet);
     141            0 :             if (!XMLSubSys::runParser(nsh, fname, true)) {
     142            0 :                 WRITE_MESSAGE("Loading of alternative net failed.");
     143              :                 return false;
     144              :             }
     145            0 :             nsh.sortInternalShapes();
     146            0 :             PROGRESS_TIME_MESSAGE(before);
     147            0 :         }
     148              :     }
     149              :     // @note on loading order constraints:
     150              :     // - additional-files before route-files and state-files due to referencing
     151              :     // - additional-files before weight-files since the latter might contain intermodal edge data and the intermodal net depends on the stops and public transport from the additionals
     152              : 
     153              :     bool stateBeginMismatch = false;
     154        76882 :     if (myOptions.isSet("load-state")) {
     155              :         // first, load only the time
     156          254 :         const SUMOTime stateTime = MSStateHandler::MSStateTimeHandler::getTime(myOptions.getString("load-state"));
     157          496 :         if (myOptions.isDefault("begin")) {
     158          370 :             myOptions.set("begin", time2string(stateTime));
     159          185 :             if (TraCIServer::getInstance() != nullptr) {
     160           18 :                 TraCIServer::getInstance()->stateLoaded(stateTime);
     161              :             }
     162              :         } else {
     163          126 :             if (stateTime != string2time(myOptions.getString("begin"))) {
     164           45 :                 WRITE_WARNINGF(TL("State was written at a different time=% than the begin time %!"), time2string(stateTime), myOptions.getString("begin"));
     165              :                 stateBeginMismatch = true;
     166              :             }
     167              :         }
     168              :     }
     169              : 
     170        76870 :     if (myOptions.getBool("junction-taz")) {
     171              :         // create a TAZ for every junction
     172         8102 :         const MSJunctionControl& junctions = myNet.getJunctionControl();
     173        87997 :         for (auto it = junctions.begin(); it != junctions.end(); it++) {
     174        79895 :             const std::string sinkID = it->first + "-sink";
     175        79895 :             const std::string sourceID = it->first + "-source";
     176        79895 :             if (MSEdge::dictionary(sinkID) == nullptr && MSEdge::dictionary(sourceID) == nullptr) {
     177              :                 // sink must be built and added before source
     178       159790 :                 MSEdge* sink = myEdgeBuilder.buildEdge(sinkID, SumoXMLEdgeFunc::CONNECTOR, "", "", "", -1, 0);
     179       159790 :                 MSEdge* source = myEdgeBuilder.buildEdge(sourceID, SumoXMLEdgeFunc::CONNECTOR, "", "", "", -1, 0);
     180              :                 sink->setOtherTazConnector(source);
     181              :                 source->setOtherTazConnector(sink);
     182        79895 :                 MSEdge::dictionary(sinkID, sink);
     183        79895 :                 MSEdge::dictionary(sourceID, source);
     184        79895 :                 sink->initialize(new std::vector<MSLane*>());
     185        79895 :                 source->initialize(new std::vector<MSLane*>());
     186        79895 :                 const MSJunction* junction = it->second;
     187       391394 :                 for (const MSEdge* edge : junction->getIncoming()) {
     188       311499 :                     if (!edge->isInternal()) {
     189       179026 :                         const_cast<MSEdge*>(edge)->addSuccessor(sink);
     190              :                     }
     191              :                 }
     192       391394 :                 for (const MSEdge* edge : junction->getOutgoing()) {
     193       311499 :                     if (!edge->isInternal()) {
     194       179026 :                         source->addSuccessor(const_cast<MSEdge*>(edge));
     195              :                     }
     196              :                 }
     197              :             } else {
     198            0 :                 WRITE_WARNINGF(TL("A TAZ with id '%' already exists. Not building junction TAZ."), it->first)
     199              :             }
     200              :         }
     201              :     }
     202              : 
     203              :     // load additional net elements (sources, detectors, ...)
     204        76870 :     if (myOptions.isSet("additional-files")) {
     205        48442 :         if (!load("additional-files")) {
     206          767 :             return false;
     207              :         }
     208              :         // load shapes with separate handler
     209        23454 :         NLShapeHandler sh("", myNet.getShapeContainer());
     210        46908 :         if (!ShapeHandler::loadFiles(myOptions.getStringVector("additional-files"), sh)) {
     211              :             return false;
     212              :         }
     213        23454 :         if (myXMLHandler.haveSeenAdditionalSpeedRestrictions()) {
     214           65 :             myNet.getEdgeControl().setAdditionalRestrictions();
     215              :         }
     216        23454 :         if (MSGlobals::gUseMesoSim && (myXMLHandler.haveSeenMesoEdgeType() || myXMLHandler.haveSeenTLSParams())) {
     217           41 :             myNet.getEdgeControl().setMesoTypes();
     218           77 :             for (MSTrafficLightLogic* tll : myNet.getTLSControl().getAllLogics()) {
     219           36 :                 tll->initMesoTLSPenalties();
     220           41 :             }
     221              :         }
     222        23454 :         MSTriggeredRerouter::checkParkingRerouteConsistency();
     223              :     }
     224              :     // init tls after all detectors have been loaded
     225        37668 :     myJunctionBuilder.postLoadInitialization();
     226              :     // declare meandata set by options
     227        75314 :     buildDefaultMeanData("edgedata-output", "DEFAULT_EDGEDATA", false);
     228        75314 :     buildDefaultMeanData("lanedata-output", "DEFAULT_LANEDATA", true);
     229              : 
     230        37657 :     if (stateBeginMismatch && myNet.getVehicleControl().getLoadedVehicleNo() > 0) {
     231            4 :         throw ProcessError(TL("Loading vehicles ahead of a state file is not supported. Correct --begin option or load vehicles with option --route-files"));
     232              :     }
     233              : 
     234              :     // load weights if wished
     235        75310 :     if (myOptions.isSet("weight-files")) {
     236           22 :         if (!myOptions.isUsableFileList("weight-files")) {
     237            0 :             return false;
     238              :         }
     239              :         // build and prepare the weights handler
     240              :         std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
     241              :         //  travel time, first (always used)
     242           11 :         EdgeFloatTimeLineRetriever_EdgeTravelTime ttRetriever(myNet);
     243           11 :         retrieverDefs.push_back(new SAXWeightsHandler::ToRetrieveDefinition("traveltime", true, ttRetriever));
     244              :         //  the measure to use, then
     245           11 :         EdgeFloatTimeLineRetriever_EdgeEffort eRetriever(myNet);
     246           11 :         std::string measure = myOptions.getString("weight-attribute");
     247           22 :         if (!myOptions.isDefault("weight-attribute")) {
     248            0 :             if (measure == "CO" || measure == "CO2" || measure == "HC" || measure == "PMx" || measure == "NOx" || measure == "fuel" || measure == "electricity") {
     249              :                 measure += "_perVeh";
     250              :             }
     251            0 :             retrieverDefs.push_back(new SAXWeightsHandler::ToRetrieveDefinition(measure, true, eRetriever));
     252              :         }
     253              :         //  set up handler
     254           11 :         SAXWeightsHandler handler(retrieverDefs, "");
     255              :         // start parsing; for each file in the list
     256           22 :         std::vector<std::string> files = myOptions.getStringVector("weight-files");
     257           22 :         for (std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i) {
     258              :             // report about loading when wished
     259           33 :             WRITE_MESSAGEF(TL("Loading weights from '%'..."), *i);
     260              :             // parse the file
     261           11 :             if (!XMLSubSys::runParser(handler, *i)) {
     262              :                 return false;
     263              :             }
     264              :         }
     265           22 :     }
     266              :     // load the previous state if wished
     267        75310 :     if (myOptions.isSet("load-state")) {
     268          246 :         myNet.setCurrentTimeStep(string2time(myOptions.getString("begin")));
     269          246 :         const std::string& f = myOptions.getString("load-state");
     270          738 :         long before = PROGRESS_BEGIN_TIME_MESSAGE(TLF("Loading state from '%'", f));
     271          246 :         MSStateHandler h(f, string2time(myOptions.getString("load-state.offset")));
     272          246 :         XMLSubSys::runParser(h, f);
     273          246 :         if (MsgHandler::getErrorInstance()->wasInformed()) {
     274              :             return false;
     275              :         }
     276          241 :         PROGRESS_TIME_MESSAGE(before);
     277          246 :     }
     278              :     // routes from FCD files
     279        37650 :     MSDevice_FCDReplay::init();
     280              :     // load routes
     281        75300 :     if (myOptions.isSet("route-files")) {
     282        60612 :         if (string2time(myOptions.getString("route-steps")) <= 0) {
     283              :             // incremental loading is disabled. Load route files fully
     284            0 :             if (!load("route-files")) {
     285              :                 return false;
     286              :             }
     287              :         } else {
     288              :             // message must come after additional-files have been loaded (but buildRouteLoaderControl was called earlier)
     289        91141 :             for (std::string file : myOptions.getStringVector("route-files")) {
     290        91587 :                 WRITE_MESSAGE(TLF("Loading route-files incrementally from '%'", file));
     291              :             }
     292              :         }
     293              :     }
     294              :     // optionally switch off traffic lights
     295        75300 :     if (myOptions.getBool("tls.all-off")) {
     296          100 :         myNet.getTLSControl().switchOffAll();
     297              :     }
     298        37650 :     WRITE_MESSAGE(TL("Loading done."));
     299        37650 :     return true;
     300              : }
     301              : 
     302              : 
     303              : MSNet*
     304        31774 : NLBuilder::init(const bool isLibsumo) {
     305        31774 :     OptionsCont& oc = OptionsCont::getOptions();
     306        31774 :     oc.clear();
     307        31774 :     MSFrame::fillOptions();
     308        31774 :     OptionsIO::getOptions();
     309        31728 :     if (oc.processMetaOptions(OptionsIO::getArgC() < 2)) {
     310          387 :         SystemFrame::close();
     311          387 :         return nullptr;
     312              :     }
     313        31341 :     SystemFrame::checkOptions(oc);
     314        31341 :     std::string validation = oc.getString("xml-validation");
     315        33142 :     std::string routeValidation = oc.getString("xml-validation.routes");
     316        31341 :     if (isLibsumo) {
     317         1182 :         if (oc.isDefault("xml-validation")) {
     318              :             validation = "never";
     319              :         }
     320         1182 :         if (oc.isDefault("xml-validation.routes")) {
     321              :             routeValidation = "never";
     322              :         }
     323              :     }
     324        31341 :     XMLSubSys::setValidation(validation, oc.getString("xml-validation.net"), routeValidation);
     325        31341 :     if (!MSFrame::checkOptions()) {
     326          279 :         throw ProcessError();
     327              :     }
     328              : #ifdef HAVE_FOX
     329        62108 :     if (oc.getInt("threads") > 1) {
     330              :         // make the output aware of threading
     331              :         MsgHandler::setFactory(&MsgHandlerSynchronized::create);
     332              :     }
     333              : #endif
     334        31054 :     MsgHandler::initOutputOptions();
     335        31054 :     initRandomness();
     336        31054 :     MSFrame::setMSGlobals(oc);
     337              :     MSVehicleControl* vc = nullptr;
     338        31054 :     if (MSGlobals::gUseMesoSim) {
     339         3196 :         vc = new MEVehicleControl();
     340              :     } else {
     341        27858 :         vc = new MSVehicleControl();
     342              :     }
     343        31054 :     MSNet* net = new MSNet(vc, new MSEventControl(), new MSEventControl(), new MSEventControl());
     344              :     // need to init TraCI-Server before loading routes to catch VehicleState::BUILT
     345        32855 :     TraCIServer::openSocket(std::map<int, TraCIServer::CmdExecutor>());
     346        31048 :     if (isLibsumo) {
     347          591 :         libsumo::Helper::registerStateListener();
     348              :     }
     349              : 
     350        31048 :     NLEdgeControlBuilder eb;
     351        31048 :     NLDetectorBuilder db(*net);
     352        31048 :     NLJunctionControlBuilder jb(*net, db);
     353        31048 :     NLTriggerBuilder tb;
     354        31048 :     NLHandler handler("", *net, db, tb, eb, jb);
     355        31048 :     tb.setHandler(&handler);
     356        31048 :     NLBuilder builder(oc, *net, eb, jb, db, handler);
     357        31048 :     MsgHandler::getErrorInstance()->clear();
     358        31048 :     MsgHandler::getWarningInstance()->clear();
     359        31048 :     MsgHandler::getMessageInstance()->clear();
     360        31048 :     if (builder.build()) {
     361              :         // preload the routes especially for TraCI
     362        29934 :         net->loadRoutes();
     363              :         return net;
     364              :     }
     365          921 :     delete net;
     366          921 :     throw ProcessError();
     367        38588 : }
     368              : 
     369              : 
     370              : void
     371        39025 : NLBuilder::initRandomness() {
     372        39025 :     RandHelper::initRandGlobal();
     373        39025 :     RandHelper::initRandGlobal(MSRouteHandler::getParsingRNG());
     374        39025 :     RandHelper::initRandGlobal(MSDevice::getEquipmentRNG());
     375        39025 :     RandHelper::initRandGlobal(OUProcess::getRNG());
     376        39025 :     RandHelper::initRandGlobal(MSDevice_ToC::getResponseTimeRNG());
     377        39025 :     RandHelper::initRandGlobal(MSDevice_BTreceiver::getRecognitionRNG());
     378        39025 :     MSLane::initRNGs(OptionsCont::getOptions());
     379        39025 : }
     380              : 
     381              : 
     382              : void
     383        38638 : NLBuilder::buildNet() {
     384              :     MSEdgeControl* edges = nullptr;
     385              :     MSJunctionControl* junctions = nullptr;
     386              :     SUMORouteLoaderControl* routeLoaders = nullptr;
     387              :     MSTLLogicControl* tlc = nullptr;
     388              :     std::vector<SUMOTime> stateDumpTimes;
     389              :     std::vector<std::string> stateDumpFiles;
     390              :     try {
     391        38638 :         MSFrame::buildStreams(); // ensure streams are ready for output during building
     392        38596 :         edges = myEdgeBuilder.build(myXMLHandler.networkVersion());
     393        38586 :         junctions = myJunctionBuilder.build();
     394        38586 :         junctions->postloadInitContainer();
     395        38582 :         routeLoaders = buildRouteLoaderControl(myOptions);
     396        38451 :         tlc = myJunctionBuilder.buildTLLogics();
     397        77237 :         for (std::string timeStr : myOptions.getStringVector("save-state.times")) {
     398          335 :             stateDumpTimes.push_back(string2time(timeStr));
     399              :         }
     400        76902 :         if (myOptions.isSet("save-state.files")) {
     401          546 :             stateDumpFiles = myOptions.getStringVector("save-state.files");
     402          273 :             if (stateDumpFiles.size() != stateDumpTimes.size()) {
     403            0 :                 throw ProcessError(TL("Wrong number of state file names!"));
     404              :             }
     405              :         } else {
     406        38178 :             const std::string prefix = myOptions.getString("save-state.prefix");
     407        76356 :             const std::string suffix = myOptions.getString("save-state.suffix");
     408        38194 :             for (std::vector<SUMOTime>::iterator i = stateDumpTimes.begin(); i != stateDumpTimes.end(); ++i) {
     409           16 :                 std::string timeStamp = time2string(*i);
     410              :                 std::replace(timeStamp.begin(), timeStamp.end(), ':', '-');
     411           32 :                 stateDumpFiles.push_back(prefix + "_" + timeStamp + suffix);
     412              :             }
     413              :         }
     414          187 :     } catch (ProcessError&) {
     415          187 :         MSEdge::clear();
     416          187 :         MSLane::clear();
     417          187 :         delete edges;
     418          187 :         delete junctions;
     419          187 :         delete routeLoaders;
     420          187 :         delete tlc;
     421          187 :         throw;
     422          187 :     }
     423              :     // if anthing goes wrong after this point, the net is responsible for cleaning up
     424        38461 :     myNet.closeBuilding(myOptions, edges, junctions, routeLoaders, tlc, stateDumpTimes, stateDumpFiles,
     425              :                         myXMLHandler.haveSeenInternalEdge(),
     426              :                         myXMLHandler.hasJunctionHigherSpeeds(),
     427        38451 :                         myXMLHandler.networkVersion());
     428        38835 : }
     429              : 
     430              : 
     431              : bool
     432        63238 : NLBuilder::load(const std::string& mmlWhat, const bool isNet) {
     433        63238 :     if (!myOptions.isUsableFileList(mmlWhat)) {
     434              :         return false;
     435              :     }
     436        63108 :     std::vector<std::string> files = myOptions.getStringVector(mmlWhat);
     437       140585 :     for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     438       235479 :         const long before = PROGRESS_BEGIN_TIME_MESSAGE(TLF("Loading % from '%'", mmlWhat, *fileIt));
     439        78493 :         if (!XMLSubSys::runParser(myXMLHandler, *fileIt, isNet)) {
     440         3048 :             WRITE_MESSAGEF(TL("Loading of % failed."), mmlWhat);
     441              :             return false;
     442              :         }
     443        77477 :         PROGRESS_TIME_MESSAGE(before);
     444              :     }
     445              :     return true;
     446        63108 : }
     447              : 
     448              : 
     449              : SUMORouteLoaderControl*
     450        38769 : NLBuilder::buildRouteLoaderControl(const OptionsCont& oc) {
     451              :     // build the loaders
     452        38769 :     SUMORouteLoaderControl* loaders =  new SUMORouteLoaderControl(string2time(oc.getString("route-steps")));
     453              :     // check whether a list is existing
     454       100797 :     if (oc.isSet("route-files") && string2time(oc.getString("route-steps")) > 0) {
     455        62028 :         std::vector<std::string> files = oc.getStringVector("route-files");
     456        62120 :         for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     457        62474 :             if (!FileHelpers::isReadable(*fileIt)) {
     458          393 :                 throw ProcessError(TLF("The route file '%' is not accessible.", *fileIt));
     459              :             }
     460              :         }
     461              :         // open files for reading
     462        61989 :         for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     463        31106 :             loaders->add(new SUMORouteLoader(new MSRouteHandler(*fileIt, false)));
     464              :         }
     465        31014 :     }
     466        38638 :     return loaders;
     467              : }
     468              : 
     469              : 
     470              : void
     471        75314 : NLBuilder::buildDefaultMeanData(const std::string& optionName, const std::string& id, bool useLanes) {
     472        75314 :     if (OptionsCont::getOptions().isSet(optionName)) {
     473           81 :         if (useLanes && MSGlobals::gUseMesoSim && !OptionsCont::getOptions().getBool("meso-lane-queue")) {
     474            4 :             WRITE_WARNING(TL("LaneData requested for mesoscopic simulation but --meso-lane-queue is not active. Falling back to edgeData."));
     475              :             useLanes = false;
     476              :         }
     477              :         try {
     478           69 :             SUMOTime begin = string2time(OptionsCont::getOptions().getString("begin"));
     479          138 :             myDetectorBuilder.createEdgeLaneMeanData(id, -1, begin, -1, "traffic", useLanes, false, false,
     480           69 :                     false, false, false, 100000, 0, SUMO_const_haltingSpeed, "", "", std::vector<MSEdge*>(), false,
     481          138 :                     OptionsCont::getOptions().getString(optionName));
     482            0 :         } catch (InvalidArgument& e) {
     483            0 :             WRITE_ERROR(e.what());
     484            0 :         } catch (IOError& e) {
     485            0 :             WRITE_ERROR(e.what());
     486            0 :         }
     487              :     }
     488        75314 : }
     489              : 
     490              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1