LCOV - code coverage report
Current view: top level - src/netload - NLBuilder.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 89.0 % 246 219
Test Date: 2026-04-16 16:39:47 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        41777 : NLBuilder::NLBuilder(OptionsCont& oc,
     112              :                      MSNet& net,
     113              :                      NLEdgeControlBuilder& eb,
     114              :                      NLJunctionControlBuilder& jb,
     115              :                      NLDetectorBuilder& db,
     116        41777 :                      NLHandler& xmlHandler)
     117        41777 :     : myOptions(oc), myEdgeBuilder(eb), myJunctionBuilder(jb),
     118        41777 :       myDetectorBuilder(db),
     119        41777 :       myNet(net), myXMLHandler(xmlHandler) {}
     120              : 
     121              : 
     122        41777 : NLBuilder::~NLBuilder() {}
     123              : 
     124              : 
     125              : bool
     126        41777 : NLBuilder::build() {
     127              :     // try to build the net
     128        83554 :     if (!load("net-file", true)) {
     129              :         return false;
     130              :     }
     131        41488 :     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        82976 :     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        55983 :     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         3022 :         MSGlobals::gUsingInternalLanes = false;
     141              :     }
     142        41488 :     buildNet();
     143        82622 :     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        82622 :     if (myOptions.isSet("load-state")) {
     161              :         // first, load only the time
     162          272 :         const SUMOTime stateTime = MSStateHandler::MSStateTimeHandler::getTime(myOptions.getString("load-state"));
     163          532 :         if (myOptions.isDefault("begin")) {
     164          408 :             myOptions.set("begin", time2string(stateTime));
     165          204 :             if (TraCIServer::getInstance() != nullptr) {
     166           18 :                 TraCIServer::getInstance()->stateLoaded(stateTime);
     167              :             }
     168              :         } else {
     169          124 :             if (stateTime != string2time(myOptions.getString("begin"))) {
     170           45 :                 WRITE_WARNINGF(TL("State was written at a different time=% than the begin time %!"), time2string(stateTime), myOptions.getString("begin"));
     171              :                 stateBeginMismatch = true;
     172              :             }
     173              :         }
     174          532 :         myNet.setCurrentTimeStep(string2time(myOptions.getString("begin")));
     175              :     }
     176              : 
     177        82610 :     if (myOptions.getBool("junction-taz")) {
     178              :         // create a TAZ for every junction
     179         1039 :         const MSJunctionControl& junctions = myNet.getJunctionControl();
     180        21459 :         for (auto it = junctions.begin(); it != junctions.end(); it++) {
     181        20420 :             const std::string sinkID = it->first + "-sink";
     182        20420 :             const std::string sourceID = it->first + "-source";
     183        20420 :             if (MSEdge::dictionary(sinkID) == nullptr && MSEdge::dictionary(sourceID) == nullptr) {
     184              :                 // sink must be built and added before source
     185        40840 :                 MSEdge* sink = myEdgeBuilder.buildEdge(sinkID, SumoXMLEdgeFunc::CONNECTOR, "", "", "", -1, 0);
     186        40840 :                 MSEdge* source = myEdgeBuilder.buildEdge(sourceID, SumoXMLEdgeFunc::CONNECTOR, "", "", "", -1, 0);
     187              :                 sink->setOtherTazConnector(source);
     188              :                 source->setOtherTazConnector(sink);
     189        20420 :                 MSEdge::dictionary(sinkID, sink);
     190        20420 :                 MSEdge::dictionary(sourceID, source);
     191        20420 :                 sink->initialize(new std::vector<MSLane*>());
     192        20420 :                 source->initialize(new std::vector<MSLane*>());
     193        20420 :                 const MSJunction* junction = it->second;
     194       100801 :                 for (const MSEdge* edge : junction->getIncoming()) {
     195        80381 :                     if (!edge->isInternal()) {
     196        33496 :                         const_cast<MSEdge*>(edge)->addSuccessor(sink);
     197              :                     }
     198              :                 }
     199       100801 :                 for (const MSEdge* edge : junction->getOutgoing()) {
     200        80381 :                     if (!edge->isInternal()) {
     201        33496 :                         source->addSuccessor(const_cast<MSEdge*>(edge));
     202              :                     }
     203              :                 }
     204              :             } else {
     205            0 :                 WRITE_WARNINGF(TL("A TAZ with id '%' already exists. Not building junction TAZ."), it->first)
     206              :             }
     207              :         }
     208              :     }
     209              :     // load meso edge types
     210              :     bool haveSeenMesoEdgeType = false;
     211        41305 :     if (MSGlobals::gUseMesoSim) {
     212        12854 :         if (myOptions.isSet("additional-files")) {
     213         6952 :             haveSeenMesoEdgeType = loadMesoEdgeTypes("additional-files");
     214              :         }
     215              :         // meso segment building must be delayed until meso edge types have been read from additional files
     216         6427 :         myNet.getEdgeControl().buildMesoSegments();
     217              :     }
     218              :     // load additional net elements (sources, detectors, ...)
     219        82610 :     if (myOptions.isSet("additional-files")) {
     220        53114 :         if (!load("additional-files")) {
     221          754 :             return false;
     222              :         }
     223              :         // load shapes with separate handler
     224        25803 :         NLShapeHandler sh("", myNet.getShapeContainer());
     225        51606 :         if (!ShapeHandler::loadFiles(myOptions.getStringVector("additional-files"), sh)) {
     226              :             return false;
     227              :         }
     228        25803 :         if (myXMLHandler.haveSeenAdditionalSpeedRestrictions()) {
     229           65 :             myNet.getEdgeControl().setAdditionalRestrictions();
     230              :         }
     231        25803 :         MSTriggeredRerouter::checkParkingRerouteConsistency();
     232              :     }
     233        40551 :     if (MSGlobals::gUseMesoSim) {
     234         6255 :         if (haveSeenMesoEdgeType || myXMLHandler.haveSeenTLSParams()) {
     235           79 :             for (MSTrafficLightLogic* tll : myNet.getTLSControl().getAllLogics()) {
     236           36 :                 tll->initMesoTLSPenalties();
     237           43 :             }
     238              :         }
     239              :     }
     240              :     // init after preferences have been loaded from additional-files
     241        40551 :     MSRoutingEngine::initWeightConstants(myOptions);
     242              :     // init tls after all detectors have been loaded
     243        40551 :     myJunctionBuilder.postLoadInitialization();
     244              :     // declare meandata set by options
     245        81062 :     buildDefaultMeanData("edgedata-output", "DEFAULT_EDGEDATA", false);
     246        81062 :     buildDefaultMeanData("lanedata-output", "DEFAULT_LANEDATA", true);
     247              : 
     248        40531 :     if (stateBeginMismatch && myNet.getVehicleControl().getLoadedVehicleNo() > 0) {
     249            4 :         throw ProcessError(TL("Loading vehicles ahead of a state file is not supported. Correct --begin option or load vehicles with option --route-files"));
     250              :     }
     251              : 
     252              :     // load weights if wished
     253        81058 :     if (myOptions.isSet("weight-files")) {
     254           22 :         if (!myOptions.isUsableFileList("weight-files")) {
     255            0 :             return false;
     256              :         }
     257              :         // build and prepare the weights handler
     258              :         std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
     259              :         //  travel time, first (always used)
     260           11 :         EdgeFloatTimeLineRetriever_EdgeTravelTime ttRetriever(myNet);
     261           11 :         retrieverDefs.push_back(new SAXWeightsHandler::ToRetrieveDefinition("traveltime", true, ttRetriever));
     262              :         //  the measure to use, then
     263           11 :         EdgeFloatTimeLineRetriever_EdgeEffort eRetriever(myNet);
     264           11 :         std::string measure = myOptions.getString("weight-attribute");
     265           22 :         if (!myOptions.isDefault("weight-attribute")) {
     266            0 :             if (measure == "CO" || measure == "CO2" || measure == "HC" || measure == "PMx" || measure == "NOx" || measure == "fuel" || measure == "electricity") {
     267              :                 measure += "_perVeh";
     268              :             }
     269            0 :             retrieverDefs.push_back(new SAXWeightsHandler::ToRetrieveDefinition(measure, true, eRetriever));
     270              :         }
     271              :         //  set up handler
     272           11 :         SAXWeightsHandler handler(retrieverDefs, "");
     273              :         // start parsing; for each file in the list
     274           22 :         std::vector<std::string> files = myOptions.getStringVector("weight-files");
     275           22 :         for (std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i) {
     276              :             // report about loading when wished
     277           33 :             WRITE_MESSAGEF(TL("Loading weights from '%'..."), *i);
     278              :             // parse the file
     279           11 :             if (!XMLSubSys::runParser(handler, *i)) {
     280              :                 return false;
     281              :             }
     282              :         }
     283           22 :     }
     284              :     // load the previous state if wished
     285        81058 :     if (myOptions.isSet("load-state")) {
     286          264 :         const std::string& f = myOptions.getString("load-state");
     287          792 :         long before = PROGRESS_BEGIN_TIME_MESSAGE(TLF("Loading state from '%'", f));
     288          264 :         MSStateHandler h(f, string2time(myOptions.getString("load-state.offset")));
     289          264 :         XMLSubSys::runParser(h, f);
     290          264 :         if (MsgHandler::getErrorInstance()->wasInformed()) {
     291              :             return false;
     292              :         }
     293          258 :         PROGRESS_TIME_MESSAGE(before);
     294          264 :     }
     295              :     // routes from FCD files
     296        40523 :     MSDevice_FCDReplay::init();
     297              :     // load routes
     298        81046 :     if (myOptions.isSet("route-files")) {
     299        65866 :         if (string2time(myOptions.getString("route-steps")) <= 0) {
     300              :             // incremental loading is disabled. Load route files fully
     301            0 :             if (!load("route-files")) {
     302              :                 return false;
     303              :             }
     304              :         } else {
     305              :             // message must come after additional-files have been loaded (but buildRouteLoaderControl was called earlier)
     306        99753 :             for (std::string file : myOptions.getStringVector("route-files")) {
     307       101661 :                 WRITE_MESSAGE(TLF("Loading route-files incrementally from '%'", file));
     308              :             }
     309              :         }
     310              :     }
     311              :     // optionally switch off traffic lights
     312        81046 :     if (myOptions.getBool("tls.all-off")) {
     313          114 :         myNet.getTLSControl().switchOffAll();
     314              :     }
     315        40523 :     WRITE_MESSAGE(TL("Loading done."));
     316        40523 :     return true;
     317              : }
     318              : 
     319              : 
     320              : MSNet*
     321        36011 : NLBuilder::init(const bool isLibsumo) {
     322        36011 :     OptionsCont& oc = OptionsCont::getOptions();
     323        36011 :     oc.clear();
     324        36011 :     MSFrame::fillOptions();
     325        36011 :     OptionsIO::getOptions();
     326        35727 :     if (oc.processMetaOptions(OptionsIO::getArgC() < 2)) {
     327          387 :         SystemFrame::close();
     328          387 :         return nullptr;
     329              :     }
     330        35340 :     SystemFrame::checkOptions(oc);
     331        35340 :     std::string validation = oc.getString("xml-validation");
     332        38833 :     std::string routeValidation = oc.getString("xml-validation.routes");
     333        35340 :     if (isLibsumo) {
     334         1210 :         if (oc.isDefault("xml-validation")) {
     335              :             validation = "never";
     336              :         }
     337         1210 :         if (oc.isDefault("xml-validation.routes")) {
     338              :             routeValidation = "never";
     339              :         }
     340              :     }
     341        35340 :     XMLSubSys::setValidation(validation, oc.getString("xml-validation.net"), routeValidation);
     342        35340 :     if (!MSFrame::checkOptions()) {
     343         2095 :         throw ProcessError();
     344              :     }
     345              : #ifdef HAVE_FOX
     346        66474 :     if (oc.getInt("threads") > 1) {
     347              :         // make the output aware of threading
     348              :         MsgHandler::setFactory(&MsgHandlerSynchronized::create);
     349              :     }
     350              : #endif
     351        33237 :     MsgHandler::initOutputOptions();
     352        33237 :     initRandomness();
     353        33237 :     MSFrame::setMSGlobals(oc);
     354              :     MSVehicleControl* vc = nullptr;
     355        33237 :     if (MSGlobals::gUseMesoSim) {
     356         3677 :         vc = new MEVehicleControl();
     357              :     } else {
     358        29560 :         vc = new MSVehicleControl();
     359              :     }
     360        33237 :     MSNet* net = new MSNet(vc, new MSEventControl(), new MSEventControl(), new MSEventControl());
     361              :     // need to init TraCI-Server before loading routes to catch VehicleState::BUILT
     362        36730 :     TraCIServer::openSocket(std::map<int, TraCIServer::CmdExecutor>());
     363        33227 :     if (isLibsumo) {
     364          605 :         libsumo::Helper::registerStateListener();
     365              :     }
     366              : 
     367        33227 :     NLEdgeControlBuilder eb;
     368        33227 :     NLDetectorBuilder db(*net);
     369        33227 :     NLJunctionControlBuilder jb(*net, db);
     370        33227 :     NLTriggerBuilder tb;
     371        33227 :     NLHandler handler("", *net, db, tb, eb, jb);
     372        33227 :     tb.setHandler(&handler);
     373        33227 :     NLBuilder builder(oc, *net, eb, jb, db, handler);
     374        33227 :     MsgHandler::getErrorInstance()->clear();
     375        33227 :     MsgHandler::getWarningInstance()->clear();
     376        33227 :     MsgHandler::getMessageInstance()->clear();
     377        33227 :     if (builder.build()) {
     378              :         // preload the routes especially for TraCI
     379        32242 :         net->loadRoutes();
     380              :         return net;
     381              :     }
     382          806 :     delete net;
     383          806 :     throw ProcessError();
     384        40127 : }
     385              : 
     386              : 
     387              : void
     388        41790 : NLBuilder::initRandomness() {
     389        41790 :     RandHelper::initRandGlobal();
     390        41790 :     RandHelper::initRandGlobal(MSRouteHandler::getParsingRNG());
     391        41790 :     RandHelper::initRandGlobal(MSDevice::getEquipmentRNG());
     392        41790 :     RandHelper::initRandGlobal(OUProcess::getRNG());
     393        41790 :     RandHelper::initRandGlobal(MSDevice_ToC::getResponseTimeRNG());
     394        41790 :     RandHelper::initRandGlobal(MSDevice_BTreceiver::getRecognitionRNG());
     395        41790 :     MSLane::initRNGs(OptionsCont::getOptions());
     396        41790 : }
     397              : 
     398              : 
     399              : void
     400        41488 : NLBuilder::buildNet() {
     401              :     MSEdgeControl* edges = nullptr;
     402              :     MSJunctionControl* junctions = nullptr;
     403              :     SUMORouteLoaderControl* routeLoaders = nullptr;
     404              :     MSTLLogicControl* tlc = nullptr;
     405              :     std::vector<SUMOTime> stateDumpTimes;
     406              :     std::vector<std::string> stateDumpFiles;
     407              :     try {
     408        41488 :         MSFrame::buildStreams(); // ensure streams are ready for output during building
     409        41446 :         edges = myEdgeBuilder.build(myXMLHandler.networkVersion());
     410        41436 :         junctions = myJunctionBuilder.build();
     411        41436 :         junctions->postloadInitContainer();
     412      1788408 :         for (MSEdge* e : edges->getEdges()) {
     413      1746976 :             e->postLoadInitLaneChanger();
     414              :         }
     415        41432 :         routeLoaders = buildRouteLoaderControl(myOptions);
     416        41311 :         tlc = myJunctionBuilder.buildTLLogics();
     417        82978 :         for (std::string timeStr : myOptions.getStringVector("save-state.times")) {
     418          356 :             stateDumpTimes.push_back(string2time(timeStr));
     419              :         }
     420        82622 :         if (myOptions.isSet("save-state.files")) {
     421          588 :             stateDumpFiles = myOptions.getStringVector("save-state.files");
     422          294 :             if (stateDumpFiles.size() != stateDumpTimes.size()) {
     423            0 :                 throw ProcessError(TL("Wrong number of state file names!"));
     424              :             }
     425              :         } else {
     426        41017 :             const std::string prefix = myOptions.getString("save-state.prefix");
     427        82034 :             const std::string suffix = myOptions.getString("save-state.suffix");
     428        41033 :             for (std::vector<SUMOTime>::iterator i = stateDumpTimes.begin(); i != stateDumpTimes.end(); ++i) {
     429           16 :                 std::string timeStamp = time2string(*i);
     430              :                 std::replace(timeStamp.begin(), timeStamp.end(), ':', '-');
     431           32 :                 stateDumpFiles.push_back(prefix + "_" + timeStamp + suffix);
     432              :             }
     433              :         }
     434          177 :     } catch (ProcessError&) {
     435          177 :         MSEdge::clear();
     436          177 :         MSLane::clear();
     437          177 :         delete edges;
     438          177 :         delete junctions;
     439          177 :         delete routeLoaders;
     440          177 :         delete tlc;
     441          177 :         throw;
     442          177 :     }
     443              :     // if anthing goes wrong after this point, the net is responsible for cleaning up
     444        41311 :     myNet.closeBuilding(myOptions, edges, junctions, routeLoaders, tlc, stateDumpTimes, stateDumpFiles,
     445              :                         myXMLHandler.haveSeenInternalEdge(),
     446              :                         myXMLHandler.hasJunctionHigherSpeeds(),
     447        41311 :                         myXMLHandler.networkVersion());
     448        41665 : }
     449              : 
     450              : 
     451              : bool
     452        68334 : NLBuilder::load(const std::string& mmlWhat, const bool isNet) {
     453        68334 :     if (!myOptions.isUsableFileList(mmlWhat)) {
     454              :         return false;
     455              :     }
     456        68322 :     std::vector<std::string> files = myOptions.getStringVector(mmlWhat);
     457       153008 :     for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     458       257151 :         const long before = PROGRESS_BEGIN_TIME_MESSAGE(TLF("Loading % from '%'", mmlWhat, *fileIt));
     459        85717 :         if (!XMLSubSys::runParser(myXMLHandler, *fileIt, isNet)) {
     460         3093 :             WRITE_MESSAGEF(TL("Loading of % failed."), mmlWhat);
     461              :             return false;
     462              :         }
     463        84686 :         PROGRESS_TIME_MESSAGE(before);
     464              :     }
     465              :     return true;
     466        68322 : }
     467              : 
     468              : 
     469              : bool
     470         3476 : NLBuilder::loadMesoEdgeTypes(const std::string& mmlWhat) {
     471         3476 :     if (!myOptions.isUsableFileList(mmlWhat)) {
     472              :         return false;
     473              :     }
     474         3476 :     METypeHandler meTypeHandler("", myNet);
     475         8661 :     for (const std::string& file : myOptions.getStringVector(mmlWhat)) {
     476         5185 :         if (!XMLSubSys::runParser(meTypeHandler, file)) {
     477              :             continue;
     478              :         }
     479              :     }
     480              :     return meTypeHandler.haveSeenMesoEdgeType();
     481         3476 : }
     482              : 
     483              : 
     484              : SUMORouteLoaderControl*
     485        41596 : NLBuilder::buildRouteLoaderControl(const OptionsCont& oc) {
     486              :     // build the loaders
     487        41596 :     SUMORouteLoaderControl* loaders =  new SUMORouteLoaderControl(string2time(oc.getString("route-steps")));
     488              :     // check whether a list is existing
     489       108806 :     if (oc.isSet("route-files") && string2time(oc.getString("route-steps")) > 0) {
     490        67210 :         std::vector<std::string> files = oc.getStringVector("route-files");
     491        68043 :         for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     492        69118 :             if (!FileHelpers::isReadable(*fileIt)) {
     493          363 :                 throw ProcessError(TLF("The route file '%' is not accessible.", *fileIt));
     494              :             }
     495              :         }
     496              :         // open files for reading
     497        67922 :         for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     498        34438 :             loaders->add(new SUMORouteLoader(new MSRouteHandler(*fileIt, false)));
     499              :         }
     500        33605 :     }
     501        41475 :     return loaders;
     502              : }
     503              : 
     504              : 
     505              : void
     506        81062 : NLBuilder::buildDefaultMeanData(const std::string& optionName, const std::string& id, bool useLanes) {
     507        81062 :     if (OptionsCont::getOptions().isSet(optionName)) {
     508           87 :         if (useLanes && MSGlobals::gUseMesoSim && !OptionsCont::getOptions().getBool("meso-lane-queue")) {
     509            4 :             WRITE_WARNING(TL("LaneData requested for mesoscopic simulation but --meso-lane-queue is not active. Falling back to edgeData."));
     510              :             useLanes = false;
     511              :         }
     512              :         try {
     513           75 :             SUMOTime begin = string2time(OptionsCont::getOptions().getString("begin"));
     514          150 :             myDetectorBuilder.createEdgeLaneMeanData(id, -1, begin, -1, "traffic", useLanes, "true",
     515           75 :                     false, false, 0, 100000, 0, SUMO_const_haltingSpeed, "", "", std::vector<MSEdge*>(), AggregateType::NO,
     516          150 :                     OptionsCont::getOptions().getString(optionName));
     517            0 :         } catch (InvalidArgument& e) {
     518            0 :             WRITE_ERROR(e.what());
     519            0 :         } catch (IOError& e) {
     520            0 :             WRITE_ERROR(e.what());
     521            0 :         }
     522              :     }
     523        81062 : }
     524              : 
     525              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1