LCOV - code coverage report
Current view: top level - src/netload - NLBuilder.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 89.1 % 247 220
Test Date: 2026-05-24 16:29:35 Functions: 84.6 % 13 11

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-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    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 <mesosim/METypeHandler.h>
      48              : #include <microsim/MSVehicleControl.h>
      49              : #include <microsim/MSVehicleTransfer.h>
      50              : #include <microsim/MSNet.h>
      51              : #include <microsim/devices/MSDevice.h>
      52              : #include <microsim/devices/MSDevice_ToC.h>
      53              : #include <microsim/devices/MSDevice_BTreceiver.h>
      54              : #include <microsim/devices/MSDevice_FCDReplay.h>
      55              : #include <microsim/devices/MSRoutingEngine.h>
      56              : #include <microsim/MSEdgeControl.h>
      57              : #include <microsim/MSGlobals.h>
      58              : #include <microsim/output/MSDetectorControl.h>
      59              : #include <microsim/MSFrame.h>
      60              : #include <microsim/MSEdgeWeightsStorage.h>
      61              : #include <microsim/MSStateHandler.h>
      62              : #include <microsim/MSDriverState.h>
      63              : #include <microsim/trigger/MSTriggeredRerouter.h>
      64              : #include <traci-server/TraCIServer.h>
      65              : 
      66              : #include "NLHandler.h"
      67              : #include "NLNetShapeHandler.h"
      68              : #include "NLEdgeControlBuilder.h"
      69              : #include "NLJunctionControlBuilder.h"
      70              : #include "NLDetectorBuilder.h"
      71              : #include "NLTriggerBuilder.h"
      72              : #include "NLBuilder.h"
      73              : 
      74              : 
      75              : // ===========================================================================
      76              : // method definitions
      77              : // ===========================================================================
      78              : // ---------------------------------------------------------------------------
      79              : // NLBuilder::EdgeFloatTimeLineRetriever_EdgeWeight - methods
      80              : // ---------------------------------------------------------------------------
      81              : void
      82            0 : NLBuilder::EdgeFloatTimeLineRetriever_EdgeEffort::addEdgeWeight(const std::string& id,
      83              :         double value, double begTime, double endTime) const {
      84            0 :     MSEdge* edge = MSEdge::dictionary(id);
      85            0 :     if (edge != nullptr) {
      86            0 :         myNet.getWeightsStorage().addEffort(edge, begTime, endTime, value);
      87              :     } else {
      88            0 :         WRITE_ERRORF(TL("Trying to set the effort for the unknown edge '%'."), id);
      89              :     }
      90            0 : }
      91              : 
      92              : 
      93              : // ---------------------------------------------------------------------------
      94              : // NLBuilder::EdgeFloatTimeLineRetriever_EdgeTravelTime - methods
      95              : // ---------------------------------------------------------------------------
      96              : void
      97           18 : NLBuilder::EdgeFloatTimeLineRetriever_EdgeTravelTime::addEdgeWeight(const std::string& id,
      98              :         double value, double begTime, double endTime) const {
      99           18 :     MSEdge* edge = MSEdge::dictionary(id);
     100           18 :     if (edge != nullptr) {
     101           18 :         myNet.getWeightsStorage().addTravelTime(edge, begTime, endTime, value);
     102              :     } else {
     103            0 :         WRITE_ERRORF(TL("Trying to set the travel time for the unknown edge '%'."), id);
     104              :     }
     105           18 : }
     106              : 
     107              : 
     108              : // ---------------------------------------------------------------------------
     109              : // NLBuilder - methods
     110              : // ---------------------------------------------------------------------------
     111        42354 : NLBuilder::NLBuilder(OptionsCont& oc,
     112              :                      MSNet& net,
     113              :                      NLEdgeControlBuilder& eb,
     114              :                      NLJunctionControlBuilder& jb,
     115              :                      NLDetectorBuilder& db,
     116        42354 :                      NLHandler& xmlHandler)
     117        42354 :     : myOptions(oc), myEdgeBuilder(eb), myJunctionBuilder(jb),
     118        42354 :       myDetectorBuilder(db),
     119        42354 :       myNet(net), myXMLHandler(xmlHandler) {}
     120              : 
     121              : 
     122        42354 : NLBuilder::~NLBuilder() {}
     123              : 
     124              : 
     125              : bool
     126        42354 : NLBuilder::build() {
     127              :     // try to build the net
     128        84708 :     if (!load("net-file", true)) {
     129              :         return false;
     130              :     }
     131        42064 :     if (myXMLHandler.networkVersion() == MMVersion(0, 0)) {
     132            0 :         throw ProcessError(TL("Invalid network, no network version declared."));
     133              :     }
     134              :     // check whether the loaded net agrees with the simulation options
     135        84128 :     if ((myOptions.getBool("no-internal-links")) && myXMLHandler.haveSeenInternalEdge() && myXMLHandler.haveSeenDefaultLength()) {
     136          174 :         WRITE_WARNING(TL("Network contains internal links which are ignored. Vehicles will 'jump' across junctions and thus underestimate route lengths and travel times."));
     137              :     }
     138        56897 :     if (!myXMLHandler.haveSeenInternalEdge() && myOptions.getBool("mesosim")) {
     139              :         // @todo: setting this option has some side effect in microsim that manifest even in networks without internal lanes this should be checked
     140         3302 :         MSGlobals::gUsingInternalLanes = false;
     141              :     }
     142        42064 :     buildNet();
     143        83774 :     if (myOptions.isSet("alternative-net-file")) {
     144            0 :         for (std::string fname : myOptions.getStringVector("alternative-net-file")) {
     145            0 :             const long before = PROGRESS_BEGIN_TIME_MESSAGE("Loading alternative net from '" + fname + "'");
     146            0 :             NLNetShapeHandler nsh(fname, myNet);
     147            0 :             if (!XMLSubSys::runParser(nsh, fname, true)) {
     148            0 :                 WRITE_MESSAGE("Loading of alternative net failed.");
     149              :                 return false;
     150              :             }
     151            0 :             nsh.sortInternalShapes();
     152            0 :             PROGRESS_TIME_MESSAGE(before);
     153            0 :         }
     154              :     }
     155              :     // @note on loading order constraints:
     156              :     // - additional-files before route-files and state-files due to referencing
     157              :     // - 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
     158              : 
     159              :     bool stateBeginMismatch = false;
     160        83774 :     if (myOptions.isSet("load-state")) {
     161              :         // first, load only the time
     162          292 :         const SUMOTime stateTime = MSStateHandler::MSStateTimeHandler::getTime(myOptions.getString("load-state"));
     163          570 :         if (myOptions.isDefault("begin")) {
     164          444 :             myOptions.set("begin", time2string(stateTime));
     165          222 :             myNet.setLoaderTime(stateTime);
     166          222 :             if (TraCIServer::getInstance() != nullptr) {
     167           18 :                 TraCIServer::getInstance()->stateLoaded(stateTime);
     168              :             }
     169              :         } else {
     170          126 :             if (stateTime != string2time(myOptions.getString("begin"))) {
     171           45 :                 WRITE_WARNINGF(TL("State was written at a different time=% than the begin time %!"), time2string(stateTime), myOptions.getString("begin"));
     172              :                 stateBeginMismatch = true;
     173              :             }
     174              :         }
     175          570 :         myNet.setCurrentTimeStep(string2time(myOptions.getString("begin")));
     176              :     }
     177              : 
     178        83760 :     if (myOptions.getBool("junction-taz")) {
     179              :         // create a TAZ for every junction
     180         1039 :         const MSJunctionControl& junctions = myNet.getJunctionControl();
     181        21459 :         for (auto it = junctions.begin(); it != junctions.end(); it++) {
     182        20420 :             const std::string sinkID = it->first + "-sink";
     183        20420 :             const std::string sourceID = it->first + "-source";
     184        20420 :             if (MSEdge::dictionary(sinkID) == nullptr && MSEdge::dictionary(sourceID) == nullptr) {
     185              :                 // sink must be built and added before source
     186        40840 :                 MSEdge* sink = myEdgeBuilder.buildEdge(sinkID, SumoXMLEdgeFunc::CONNECTOR, "", "", "", -1, 0);
     187        40840 :                 MSEdge* source = myEdgeBuilder.buildEdge(sourceID, SumoXMLEdgeFunc::CONNECTOR, "", "", "", -1, 0);
     188              :                 sink->setOtherTazConnector(source);
     189              :                 source->setOtherTazConnector(sink);
     190        20420 :                 MSEdge::dictionary(sinkID, sink);
     191        20420 :                 MSEdge::dictionary(sourceID, source);
     192        20420 :                 sink->initialize(new std::vector<MSLane*>());
     193        20420 :                 source->initialize(new std::vector<MSLane*>());
     194        20420 :                 const MSJunction* junction = it->second;
     195       100801 :                 for (const MSEdge* edge : junction->getIncoming()) {
     196        80381 :                     if (!edge->isInternal()) {
     197        33496 :                         const_cast<MSEdge*>(edge)->addSuccessor(sink);
     198              :                     }
     199              :                 }
     200       100801 :                 for (const MSEdge* edge : junction->getOutgoing()) {
     201        80381 :                     if (!edge->isInternal()) {
     202        33496 :                         source->addSuccessor(const_cast<MSEdge*>(edge));
     203              :                     }
     204              :                 }
     205              :             } else {
     206            0 :                 WRITE_WARNINGF(TL("A TAZ with id '%' already exists. Not building junction TAZ."), it->first)
     207              :             }
     208              :         }
     209              :     }
     210              :     // load meso edge types
     211              :     bool haveSeenMesoEdgeType = false;
     212        41880 :     if (MSGlobals::gUseMesoSim) {
     213        13508 :         if (myOptions.isSet("additional-files")) {
     214         7546 :             haveSeenMesoEdgeType = loadMesoEdgeTypes("additional-files");
     215              :         }
     216              :         // meso segment building must be delayed until meso edge types have been read from additional files
     217         6754 :         myNet.getEdgeControl().buildMesoSegments();
     218              :     }
     219              :     // load additional net elements (sources, detectors, ...)
     220        83760 :     if (myOptions.isSet("additional-files")) {
     221        53792 :         if (!load("additional-files")) {
     222          776 :             return false;
     223              :         }
     224              :         // load shapes with separate handler
     225        26120 :         NLShapeHandler sh("", myNet.getShapeContainer());
     226        52240 :         if (!ShapeHandler::loadFiles(myOptions.getStringVector("additional-files"), sh)) {
     227              :             return false;
     228              :         }
     229        26120 :         if (myXMLHandler.haveSeenAdditionalSpeedRestrictions()) {
     230           65 :             myNet.getEdgeControl().setAdditionalRestrictions();
     231              :         }
     232        26120 :         MSTriggeredRerouter::checkParkingRerouteConsistency();
     233              :     }
     234        41104 :     if (MSGlobals::gUseMesoSim) {
     235         6560 :         if (haveSeenMesoEdgeType || myXMLHandler.haveSeenTLSParams()) {
     236          111 :             for (MSTrafficLightLogic* tll : myNet.getTLSControl().getAllLogics()) {
     237           58 :                 tll->initMesoTLSPenalties();
     238           53 :             }
     239              :         }
     240              :     }
     241              :     // init after preferences have been loaded from additional-files
     242        41104 :     MSRoutingEngine::initWeightConstants(myOptions);
     243              :     // init tls after all detectors have been loaded
     244        41104 :     myJunctionBuilder.postLoadInitialization();
     245              :     // declare meandata set by options
     246        82156 :     buildDefaultMeanData("edgedata-output", "DEFAULT_EDGEDATA", false);
     247        82156 :     buildDefaultMeanData("lanedata-output", "DEFAULT_LANEDATA", true);
     248              : 
     249        41078 :     if (stateBeginMismatch && myNet.getVehicleControl().getLoadedVehicleNo() > 0) {
     250            4 :         throw ProcessError(TL("Loading vehicles ahead of a state file is not supported. Correct --begin option or load vehicles with option --route-files"));
     251              :     }
     252              : 
     253              :     // load weights if wished
     254        82152 :     if (myOptions.isSet("weight-files")) {
     255           22 :         if (!myOptions.isUsableFileList("weight-files")) {
     256            0 :             return false;
     257              :         }
     258              :         // build and prepare the weights handler
     259              :         std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
     260              :         //  travel time, first (always used)
     261           11 :         EdgeFloatTimeLineRetriever_EdgeTravelTime ttRetriever(myNet);
     262           11 :         retrieverDefs.push_back(new SAXWeightsHandler::ToRetrieveDefinition("traveltime", true, ttRetriever));
     263              :         //  the measure to use, then
     264           11 :         EdgeFloatTimeLineRetriever_EdgeEffort eRetriever(myNet);
     265           11 :         std::string measure = myOptions.getString("weight-attribute");
     266           22 :         if (!myOptions.isDefault("weight-attribute")) {
     267            0 :             if (measure == "CO" || measure == "CO2" || measure == "HC" || measure == "PMx" || measure == "NOx" || measure == "fuel" || measure == "electricity") {
     268              :                 measure += "_perVeh";
     269              :             }
     270            0 :             retrieverDefs.push_back(new SAXWeightsHandler::ToRetrieveDefinition(measure, true, eRetriever));
     271              :         }
     272              :         //  set up handler
     273           11 :         SAXWeightsHandler handler(retrieverDefs, "");
     274              :         // start parsing; for each file in the list
     275           22 :         std::vector<std::string> files = myOptions.getStringVector("weight-files");
     276           22 :         for (std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i) {
     277              :             // report about loading when wished
     278           33 :             WRITE_MESSAGEF(TL("Loading weights from '%'..."), *i);
     279              :             // parse the file
     280           11 :             if (!XMLSubSys::runParser(handler, *i)) {
     281              :                 return false;
     282              :             }
     283              :         }
     284           22 :     }
     285              :     // load the previous state if wished
     286        82152 :     if (myOptions.isSet("load-state")) {
     287          283 :         const std::string& f = myOptions.getString("load-state");
     288          849 :         long before = PROGRESS_BEGIN_TIME_MESSAGE(TLF("Loading state from '%'", f));
     289          283 :         MSStateHandler h(f, string2time(myOptions.getString("load-state.offset")));
     290          283 :         XMLSubSys::runParser(h, f);
     291          283 :         if (MsgHandler::getErrorInstance()->wasInformed()) {
     292              :             return false;
     293              :         }
     294          277 :         PROGRESS_TIME_MESSAGE(before);
     295          283 :     }
     296              :     // routes from FCD files
     297        41070 :     MSDevice_FCDReplay::init();
     298              :     // load routes
     299        82140 :     if (myOptions.isSet("route-files")) {
     300        66914 :         if (string2time(myOptions.getString("route-steps")) <= 0) {
     301              :             // incremental loading is disabled. Load route files fully
     302            0 :             if (!load("route-files")) {
     303              :                 return false;
     304              :             }
     305              :         } else {
     306              :             // message must come after additional-files have been loaded (but buildRouteLoaderControl was called earlier)
     307       101329 :             for (std::string file : myOptions.getStringVector("route-files")) {
     308       103245 :                 WRITE_MESSAGE(TLF("Loading route-files incrementally from '%'", file));
     309              :             }
     310              :         }
     311              :     }
     312              :     // optionally switch off traffic lights
     313        82140 :     if (myOptions.getBool("tls.all-off")) {
     314          119 :         myNet.getTLSControl().switchOffAll();
     315              :     }
     316        41070 :     WRITE_MESSAGE(TL("Loading done."));
     317        41070 :     return true;
     318              : }
     319              : 
     320              : 
     321              : MSNet*
     322        36354 : NLBuilder::init(const bool isLibsumo) {
     323        36354 :     OptionsCont& oc = OptionsCont::getOptions();
     324        36354 :     oc.clear();
     325        36354 :     MSFrame::fillOptions();
     326        36354 :     OptionsIO::getOptions();
     327        36069 :     if (oc.processMetaOptions(OptionsIO::getArgC() < 2)) {
     328          387 :         SystemFrame::close();
     329          387 :         return nullptr;
     330              :     }
     331        35682 :     SystemFrame::checkOptions(oc);
     332        35682 :     std::string validation = oc.getString("xml-validation");
     333        39171 :     std::string routeValidation = oc.getString("xml-validation.routes");
     334        35682 :     if (isLibsumo) {
     335         1210 :         if (oc.isDefault("xml-validation")) {
     336              :             validation = "never";
     337              :         }
     338         1210 :         if (oc.isDefault("xml-validation.routes")) {
     339              :             routeValidation = "never";
     340              :         }
     341              :     }
     342        35682 :     XMLSubSys::setValidation(validation, oc.getString("xml-validation.net"), routeValidation);
     343        35682 :     if (!MSFrame::checkOptions()) {
     344         2071 :         throw ProcessError();
     345              :     }
     346              : #ifdef HAVE_FOX
     347        67206 :     if (oc.getInt("threads") > 1) {
     348              :         // make the output aware of threading
     349              :         MsgHandler::setFactory(&MsgHandlerSynchronized::create);
     350              :     }
     351              : #endif
     352        33603 :     MsgHandler::initOutputOptions();
     353        33603 :     initRandomness();
     354        33603 :     MSFrame::setMSGlobals(oc);
     355              :     MSVehicleControl* vc = nullptr;
     356        33603 :     if (MSGlobals::gUseMesoSim) {
     357         3852 :         vc = new MEVehicleControl();
     358              :     } else {
     359        29751 :         vc = new MSVehicleControl();
     360              :     }
     361        33603 :     MSNet* net = new MSNet(vc, new MSEventControl(), new MSEventControl(), new MSEventControl());
     362              :     // need to init TraCI-Server before loading routes to catch VehicleState::BUILT
     363        37092 :     TraCIServer::openSocket(std::map<int, TraCIServer::CmdExecutor>());
     364        33594 :     if (isLibsumo) {
     365          605 :         libsumo::Helper::registerStateListener();
     366              :     }
     367              : 
     368        33594 :     NLEdgeControlBuilder eb;
     369        33594 :     NLDetectorBuilder db(*net);
     370        33594 :     NLJunctionControlBuilder jb(*net, db);
     371        33594 :     NLTriggerBuilder tb;
     372        33594 :     NLHandler handler("", *net, db, tb, eb, jb);
     373        33594 :     tb.setHandler(&handler);
     374        33594 :     NLBuilder builder(oc, *net, eb, jb, db, handler);
     375        33594 :     MsgHandler::getErrorInstance()->clear();
     376        33594 :     MsgHandler::getWarningInstance()->clear();
     377        33594 :     MsgHandler::getMessageInstance()->clear();
     378        33594 :     if (builder.build()) {
     379              :         // preload the routes especially for TraCI
     380        32593 :         net->loadRoutes();
     381              :         return net;
     382              :     }
     383          818 :     delete net;
     384          818 :     throw ProcessError();
     385        40599 : }
     386              : 
     387              : 
     388              : void
     389        42366 : NLBuilder::initRandomness() {
     390        42366 :     RandHelper::initRandGlobal();
     391        42366 :     RandHelper::initRandGlobal(MSRouteHandler::getParsingRNG());
     392        42366 :     RandHelper::initRandGlobal(MSDevice::getEquipmentRNG());
     393        42366 :     RandHelper::initRandGlobal(OUProcess::getRNG());
     394        42366 :     RandHelper::initRandGlobal(MSDevice_ToC::getResponseTimeRNG());
     395        42366 :     RandHelper::initRandGlobal(MSDevice_BTreceiver::getRecognitionRNG());
     396        42366 :     MSLane::initRNGs(OptionsCont::getOptions());
     397        42366 : }
     398              : 
     399              : 
     400              : void
     401        42064 : NLBuilder::buildNet() {
     402              :     MSEdgeControl* edges = nullptr;
     403              :     MSJunctionControl* junctions = nullptr;
     404              :     SUMORouteLoaderControl* routeLoaders = nullptr;
     405              :     MSTLLogicControl* tlc = nullptr;
     406              :     std::vector<SUMOTime> stateDumpTimes;
     407              :     std::vector<std::string> stateDumpFiles;
     408              :     try {
     409        42064 :         MSFrame::buildStreams(); // ensure streams are ready for output during building
     410        42022 :         edges = myEdgeBuilder.build(myXMLHandler.networkVersion());
     411        42012 :         junctions = myJunctionBuilder.build();
     412        42012 :         junctions->postloadInitContainer();
     413      1808272 :         for (MSEdge* e : edges->getEdges()) {
     414      1766264 :             e->postLoadInitLaneChanger();
     415              :         }
     416        42008 :         routeLoaders = buildRouteLoaderControl(myOptions);
     417        41887 :         tlc = myJunctionBuilder.buildTLLogics();
     418        84148 :         for (std::string timeStr : myOptions.getStringVector("save-state.times")) {
     419          374 :             stateDumpTimes.push_back(string2time(timeStr));
     420              :         }
     421        83774 :         if (myOptions.isSet("save-state.files")) {
     422          624 :             stateDumpFiles = myOptions.getStringVector("save-state.files");
     423          312 :             if (stateDumpFiles.size() != stateDumpTimes.size()) {
     424            0 :                 throw ProcessError(TL("Wrong number of state file names!"));
     425              :             }
     426              :         } else {
     427        41575 :             const std::string prefix = myOptions.getString("save-state.prefix");
     428        83150 :             const std::string suffix = myOptions.getString("save-state.suffix");
     429        41591 :             for (std::vector<SUMOTime>::iterator i = stateDumpTimes.begin(); i != stateDumpTimes.end(); ++i) {
     430           16 :                 std::string timeStamp = time2string(*i);
     431              :                 std::replace(timeStamp.begin(), timeStamp.end(), ':', '-');
     432           32 :                 stateDumpFiles.push_back(prefix + "_" + timeStamp + suffix);
     433              :             }
     434              :         }
     435          177 :     } catch (ProcessError&) {
     436          177 :         MSEdge::clear();
     437          177 :         MSLane::clear();
     438          177 :         delete edges;
     439          177 :         delete junctions;
     440          177 :         delete routeLoaders;
     441          177 :         delete tlc;
     442          177 :         throw;
     443          177 :     }
     444              :     // if anthing goes wrong after this point, the net is responsible for cleaning up
     445        41887 :     myNet.closeBuilding(myOptions, edges, junctions, routeLoaders, tlc, stateDumpTimes, stateDumpFiles,
     446              :                         myXMLHandler.haveSeenInternalEdge(),
     447              :                         myXMLHandler.hasJunctionHigherSpeeds(),
     448        41887 :                         myXMLHandler.networkVersion());
     449        42241 : }
     450              : 
     451              : 
     452              : bool
     453        69250 : NLBuilder::load(const std::string& mmlWhat, const bool isNet) {
     454        69250 :     if (!myOptions.isUsableFileList(mmlWhat)) {
     455              :         return false;
     456              :     }
     457        69237 :     std::vector<std::string> files = myOptions.getStringVector(mmlWhat);
     458       154825 :     for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     459       259923 :         const long before = PROGRESS_BEGIN_TIME_MESSAGE(TLF("Loading % from '%'", mmlWhat, *fileIt));
     460        86641 :         if (!XMLSubSys::runParser(myXMLHandler, *fileIt, isNet)) {
     461         3159 :             WRITE_MESSAGEF(TL("Loading of % failed."), mmlWhat);
     462              :             return false;
     463              :         }
     464        85588 :         PROGRESS_TIME_MESSAGE(before);
     465              :     }
     466              :     return true;
     467        69237 : }
     468              : 
     469              : 
     470              : bool
     471         3773 : NLBuilder::loadMesoEdgeTypes(const std::string& mmlWhat) {
     472         3773 :     if (!myOptions.isUsableFileList(mmlWhat)) {
     473              :         return false;
     474              :     }
     475         3773 :     METypeHandler meTypeHandler("", myNet);
     476         9257 :     for (const std::string& file : myOptions.getStringVector(mmlWhat)) {
     477         5484 :         if (!XMLSubSys::runParser(meTypeHandler, file)) {
     478              :             continue;
     479              :         }
     480              :     }
     481              :     return meTypeHandler.haveSeenMesoEdgeType();
     482         3773 : }
     483              : 
     484              : 
     485              : SUMORouteLoaderControl*
     486        42172 : NLBuilder::buildRouteLoaderControl(const OptionsCont& oc) {
     487              :     // build the loaders
     488        42172 :     SUMORouteLoaderControl* loaders =  new SUMORouteLoaderControl(string2time(oc.getString("route-steps")));
     489              :     // check whether a list is existing
     490       110482 :     if (oc.isSet("route-files") && string2time(oc.getString("route-steps")) > 0) {
     491        68310 :         std::vector<std::string> files = oc.getStringVector("route-files");
     492        69147 :         for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     493        70226 :             if (!FileHelpers::isReadable(*fileIt)) {
     494          363 :                 throw ProcessError(TLF("The route file '%' is not accessible.", *fileIt));
     495              :             }
     496              :         }
     497              :         // open files for reading
     498        69026 :         for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     499        34992 :             loaders->add(new SUMORouteLoader(new MSRouteHandler(*fileIt, false)));
     500              :         }
     501        34155 :     }
     502        42051 :     return loaders;
     503              : }
     504              : 
     505              : 
     506              : void
     507        82156 : NLBuilder::buildDefaultMeanData(const std::string& optionName, const std::string& id, bool useLanes) {
     508        82156 :     if (OptionsCont::getOptions().isSet(optionName)) {
     509           87 :         if (useLanes && MSGlobals::gUseMesoSim && !OptionsCont::getOptions().getBool("meso-lane-queue")) {
     510            4 :             WRITE_WARNING(TL("LaneData requested for mesoscopic simulation but --meso-lane-queue is not active. Falling back to edgeData."));
     511              :             useLanes = false;
     512              :         }
     513              :         try {
     514           75 :             SUMOTime begin = string2time(OptionsCont::getOptions().getString("begin"));
     515          150 :             myDetectorBuilder.createEdgeLaneMeanData(id, -1, begin, -1, "traffic", useLanes, "true",
     516           75 :                     false, false, 0, 100000, 0, SUMO_const_haltingSpeed, "", "", std::vector<MSEdge*>(), AggregateType::NO,
     517          150 :                     OptionsCont::getOptions().getString(optionName));
     518            0 :         } catch (InvalidArgument& e) {
     519            0 :             WRITE_ERROR(e.what());
     520            0 :         } catch (IOError& e) {
     521            0 :             WRITE_ERROR(e.what());
     522            0 :         }
     523              :     }
     524        82156 : }
     525              : 
     526              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1