LCOV - code coverage report
Current view: top level - src/router - RONetHandler.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 96.3 % 271 261
Test Date: 2025-11-13 15:38:19 Functions: 93.3 % 15 14

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2002-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    RONetHandler.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Christian Roessel
      18              : /// @author  Michael Behrisch
      19              : /// @author  Yun-Pang Floetteroed
      20              : /// @date    Sept 2002
      21              : ///
      22              : // The handler for SUMO-Networks
      23              : /****************************************************************************/
      24              : #include <config.h>
      25              : 
      26              : #include <string>
      27              : #include <utils/common/MsgHandler.h>
      28              : #include <utils/common/StringTokenizer.h>
      29              : #include <utils/common/UtilExceptions.h>
      30              : #include <utils/common/ToString.h>
      31              : #include <utils/common/StringUtils.h>
      32              : #include <utils/geom/PositionVector.h>
      33              : #include <utils/geom/GeoConvHelper.h>
      34              : #include <utils/vehicle/SUMORouteHandler.h>
      35              : #include <utils/xml/SUMOSAXHandler.h>
      36              : #include <utils/xml/SUMOXMLDefinitions.h>
      37              : #include "ROEdge.h"
      38              : #include "ROLane.h"
      39              : #include "RONode.h"
      40              : #include "RONet.h"
      41              : #include "RONetHandler.h"
      42              : #include "ROAbstractEdgeBuilder.h"
      43              : 
      44              : 
      45              : // ===========================================================================
      46              : // method definitions
      47              : // ===========================================================================
      48         4226 : RONetHandler::RONetHandler(RONet& net, ROAbstractEdgeBuilder& eb, const bool ignoreInternal, const double minorPenalty, double tlsPenalty, double turnaroundPenalty) :
      49              :     SUMOSAXHandler("sumo-network"),
      50         4226 :     myNet(net),
      51              :     myNetworkVersion(0, 0),
      52         4226 :     myEdgeBuilder(eb), myIgnoreInternal(ignoreInternal),
      53         4226 :     myCurrentName(), myCurrentEdge(nullptr), myCurrentStoppingPlace(nullptr),
      54         4226 :     myMinorPenalty(minorPenalty),
      55         4226 :     myTLSPenalty(tlsPenalty),
      56         8452 :     myTurnaroundPenalty(turnaroundPenalty)
      57         4226 : {}
      58              : 
      59              : 
      60         8452 : RONetHandler::~RONetHandler() {}
      61              : 
      62              : 
      63              : void
      64      1602071 : RONetHandler::myStartElement(int element,
      65              :                              const SUMOSAXAttributes& attrs) {
      66      1602071 :     switch (element) {
      67         4226 :         case SUMO_TAG_LOCATION:
      68         4226 :             setLocation(attrs);
      69         4226 :             break;
      70         4226 :         case SUMO_TAG_NET: {
      71              :             bool ok;
      72         8452 :             myNetworkVersion = StringUtils::toVersion(attrs.get<std::string>(SUMO_ATTR_VERSION, nullptr, ok, false));
      73              :             break;
      74              :         }
      75       323550 :         case SUMO_TAG_EDGE:
      76              :             // in the first step, we do need the name to allocate the edge
      77              :             // in the second, we need it to know to which edge we have to add
      78              :             //  the following edges to
      79       323550 :             parseEdge(attrs);
      80       323538 :             break;
      81       366324 :         case SUMO_TAG_LANE:
      82       366324 :             parseLane(attrs);
      83       366324 :             break;
      84        99632 :         case SUMO_TAG_JUNCTION:
      85        99632 :             parseJunction(attrs);
      86        99632 :             break;
      87       476608 :         case SUMO_TAG_CONNECTION:
      88       476608 :             parseConnection(attrs);
      89       476290 :             break;
      90         1968 :         case SUMO_TAG_BUS_STOP:
      91              :         case SUMO_TAG_TRAIN_STOP:
      92              :         case SUMO_TAG_CONTAINER_STOP:
      93              :         case SUMO_TAG_PARKING_AREA:
      94              :         case SUMO_TAG_CHARGING_STATION:
      95              :         case SUMO_TAG_OVERHEAD_WIRE_SEGMENT:
      96         1968 :             parseStoppingPlace(attrs, (SumoXMLTag)element);
      97         1968 :             break;
      98         2076 :         case SUMO_TAG_ACCESS:
      99         2076 :             parseAccess(attrs);
     100         2076 :             break;
     101          381 :         case SUMO_TAG_TAZ:
     102          381 :             parseDistrict(attrs);
     103          381 :             break;
     104          124 :         case SUMO_TAG_TAZSOURCE:
     105          124 :             parseDistrictEdge(attrs, true);
     106          124 :             break;
     107          125 :         case SUMO_TAG_TAZSINK:
     108          125 :             parseDistrictEdge(attrs, false);
     109          125 :             break;
     110         2205 :         case SUMO_TAG_TYPE: {
     111         2205 :             bool ok = true;
     112         4410 :             myCurrentTypeID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
     113              :             break;
     114              :         }
     115           17 :         case SUMO_TAG_RESTRICTION: {
     116           17 :             bool ok = true;
     117           34 :             const SUMOVehicleClass svc = getVehicleClassID(attrs.get<std::string>(SUMO_ATTR_VCLASS, myCurrentTypeID.c_str(), ok));
     118           17 :             const double speed = attrs.get<double>(SUMO_ATTR_SPEED, myCurrentTypeID.c_str(), ok);
     119           17 :             if (ok) {
     120           17 :                 myNet.addRestriction(myCurrentTypeID, svc, speed);
     121              :             }
     122              :             break;
     123              :         }
     124           40 :         case SUMO_TAG_PREFERENCE: {
     125           40 :             bool ok = true;
     126           40 :             const std::string routingType = attrs.get<std::string>(SUMO_ATTR_ROUTINGTYPE, nullptr, ok);
     127           40 :             const double prio = attrs.get<double>(SUMO_ATTR_PRIORITY, routingType.c_str(), ok);
     128           40 :             if (prio <= 0) {
     129            0 :                 throw InvalidArgument("In preference for routingType '" + routingType + "', priority must be positve");
     130              :             }
     131           40 :             if (attrs.hasAttribute(SUMO_ATTR_VCLASSES)) {
     132            8 :                 StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_VCLASSES, routingType.c_str(), ok));
     133           32 :                 for (std::string className : st.getVector()) {
     134           24 :                     myNet.addPreference(routingType, getVehicleClassID(className), prio);
     135            8 :                 }
     136           40 :             } else if (!attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
     137              :                 // general preferenze applying to all types and vClasses
     138           48 :                 myNet.addPreference(routingType, "", prio);
     139              :             }
     140           40 :             if (attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
     141            8 :                 StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_VTYPES, routingType.c_str(), ok));
     142           16 :                 for (std::string typeName : st.getVector()) {
     143           24 :                     myNet.addPreference(routingType, typeName, prio);
     144            8 :                 }
     145            8 :             }
     146              :             break;
     147              :         }
     148       104448 :         case SUMO_TAG_PARAM:
     149       104448 :             addParam(attrs);
     150       104448 :             break;
     151              :         default:
     152              :             break;
     153              :     }
     154      1601741 : }
     155              : 
     156              : 
     157              : void
     158      1600976 : RONetHandler::myEndElement(int element) {
     159      1600976 :     switch (element) {
     160         3641 :         case SUMO_TAG_NET:
     161              :             // build junction graph
     162         3719 :             for (std::set<std::string>::const_iterator it = myUnseenNodeIDs.begin(); it != myUnseenNodeIDs.end(); ++it) {
     163          234 :                 WRITE_ERRORF(TL("Unknown node '%'."), *it);
     164              :             }
     165              :             break;
     166              :         default:
     167              :             break;
     168              :     }
     169      1600976 : }
     170              : 
     171              : 
     172              : void
     173       104448 : RONetHandler::addParam(const SUMOSAXAttributes& attrs) {
     174       104448 :     bool ok = true;
     175       104448 :     const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
     176              :     // circumventing empty string test
     177       104448 :     const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
     178              :     // add parameter in current created element, or in myLoadedParameterised
     179       104448 :     if (myCurrentEdge != nullptr) {
     180       104448 :         myCurrentEdge->setParameter(key, val);
     181              :     }
     182       104448 : }
     183              : 
     184              : 
     185              : void
     186       323550 : RONetHandler::parseEdge(const SUMOSAXAttributes& attrs) {
     187              :     // get the id, report an error if not given or empty...
     188       323550 :     bool ok = true;
     189       323550 :     myCurrentName = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
     190       323550 :     if (!ok) {
     191           12 :         throw ProcessError();
     192              :     }
     193       323538 :     const SumoXMLEdgeFunc func = attrs.getOpt<SumoXMLEdgeFunc>(SUMO_ATTR_FUNCTION, myCurrentName.c_str(), ok, SumoXMLEdgeFunc::NORMAL);
     194       323538 :     if (!ok) {
     195           54 :         return;
     196              :     }
     197              :     // get the edge
     198              :     std::string from;
     199              :     std::string to;
     200              :     int priority;
     201       323532 :     myCurrentEdge = nullptr;
     202       323532 :     if (func == SumoXMLEdgeFunc::INTERNAL || func == SumoXMLEdgeFunc::CROSSING || func == SumoXMLEdgeFunc::WALKINGAREA) {
     203              :         assert(myCurrentName[0] == ':');
     204       415744 :         const std::string junctionID = SUMOXMLDefinitions::getJunctionIDFromInternalEdge(myCurrentName);
     205              :         from = junctionID;
     206              :         to = junctionID;
     207              :         priority = -1;
     208       207872 :     } else {
     209       231320 :         from = attrs.get<std::string>(SUMO_ATTR_FROM, myCurrentName.c_str(), ok);
     210       231320 :         to = attrs.get<std::string>(SUMO_ATTR_TO, myCurrentName.c_str(), ok);
     211       115660 :         priority = attrs.get<int>(SUMO_ATTR_PRIORITY, myCurrentName.c_str(), ok);
     212       115660 :         if (!ok) {
     213              :             return;
     214              :         }
     215              :     }
     216       323484 :     RONode* fromNode = myNet.getNode(from);
     217       272168 :     if (fromNode == nullptr) {
     218              :         myUnseenNodeIDs.insert(from);
     219        51316 :         fromNode = new RONode(from);
     220        51316 :         myNet.addNode(fromNode);
     221              :     }
     222       323484 :     RONode* toNode = myNet.getNode(to);
     223       301656 :     if (toNode == nullptr) {
     224              :         myUnseenNodeIDs.insert(to);
     225        21828 :         toNode = new RONode(to);
     226        21828 :         myNet.addNode(toNode);
     227              :     }
     228       323484 :     const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, myCurrentName.c_str(), ok, "");
     229       323484 :     const std::string routingType = attrs.getOpt<std::string>(SUMO_ATTR_ROUTINGTYPE, myCurrentName.c_str(), ok, "");
     230              :     // build the edge
     231       323484 :     myCurrentEdge = myEdgeBuilder.buildEdge(myCurrentName, fromNode, toNode, priority, type, routingType);
     232              :     myCurrentEdge->setFunction(func);
     233              : 
     234       323484 :     if (myNet.addEdge(myCurrentEdge)) {
     235       323472 :         fromNode->addOutgoing(myCurrentEdge);
     236       323472 :         toNode->addIncoming(myCurrentEdge);
     237       646944 :         const std::string bidi = attrs.getOpt<std::string>(SUMO_ATTR_BIDI, myCurrentName.c_str(), ok, "");
     238       323472 :         if (bidi != "") {
     239        12084 :             myBidiEdges[myCurrentEdge] = bidi;
     240              :         }
     241              :     } else {
     242           12 :         myCurrentEdge = nullptr;
     243              :     }
     244              : }
     245              : 
     246              : 
     247              : void
     248       366324 : RONetHandler::parseLane(const SUMOSAXAttributes& attrs) {
     249       366324 :     if (myCurrentEdge == nullptr) {
     250              :         // was an internal edge to skip or an error occurred
     251          282 :         return;
     252              :     }
     253       366198 :     bool ok = true;
     254              :     // get the id, report an error if not given or empty...
     255       366198 :     std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
     256       366198 :     if (!ok) {
     257              :         return;
     258              :     }
     259              :     // get the speed
     260       366174 :     double maxSpeed = attrs.get<double>(SUMO_ATTR_SPEED, id.c_str(), ok);
     261       366174 :     double length = attrs.get<double>(SUMO_ATTR_LENGTH, id.c_str(), ok);
     262       366174 :     std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), ok, "");
     263       732348 :     std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
     264       366174 :     const PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
     265       366174 :     if (!ok) {
     266              :         return;
     267              :     }
     268       366066 :     if (shape.size() < 2) {
     269           72 :         WRITE_ERRORF(TL("Ignoring lane '%' with broken shape."), id);
     270           24 :         return;
     271              :     }
     272              :     // get the length
     273              :     // get the vehicle classes
     274       366042 :     SVCPermissions permissions = parseVehicleClasses(allow, disallow, myNetworkVersion);
     275       366042 :     if (permissions != SVCAll) {
     276       252809 :         myNet.setPermissionsFound();
     277              :     }
     278              :     // add when both values are valid
     279       366042 :     if (maxSpeed > 0 && length > 0 && id.length() > 0) {
     280       366042 :         myCurrentEdge->addLane(new ROLane(id, myCurrentEdge, length, maxSpeed, permissions, shape));
     281              :     } else {
     282            0 :         WRITE_WARNING("Ignoring lane '" + id + "' with speed " + toString(maxSpeed) + " and length " + toString(length));
     283              :     }
     284       366174 : }
     285              : 
     286              : 
     287              : void
     288        99632 : RONetHandler::parseJunction(const SUMOSAXAttributes& attrs) {
     289        99632 :     bool ok = true;
     290              :     // get the id, report an error if not given or empty...
     291        99632 :     std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
     292        99632 :     const SumoXMLNodeType type = attrs.get<SumoXMLNodeType>(SUMO_ATTR_TYPE, id.c_str(), ok);
     293        99632 :     if (type == SumoXMLNodeType::INTERNAL) {
     294              :         return;
     295              :     }
     296              :     myUnseenNodeIDs.erase(id);
     297              :     // get the position of the node
     298        72636 :     const double x = attrs.get<double>(SUMO_ATTR_X, id.c_str(), ok);
     299        72636 :     const double y = attrs.get<double>(SUMO_ATTR_Y, id.c_str(), ok);
     300        72636 :     const double z = attrs.getOpt<double>(SUMO_ATTR_Z, id.c_str(), ok, 0.);
     301        72636 :     if (!ok) {
     302              :         return;
     303              :     }
     304        72591 :     RONode* n = myNet.getNode(id);
     305        72487 :     if (n == nullptr) {
     306          312 :         WRITE_WARNINGF(TL("Skipping isolated junction '%'."), id);
     307              :     } else {
     308        72487 :         n->setPosition(Position(x, y, z));
     309              :     }
     310              : }
     311              : 
     312              : 
     313              : void
     314       476608 : RONetHandler::parseConnection(const SUMOSAXAttributes& attrs) {
     315       476608 :     bool ok = true;
     316       476608 :     std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, nullptr, ok);
     317       476608 :     std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, nullptr, ok);
     318       476608 :     const int fromLane = attrs.get<int>(SUMO_ATTR_FROM_LANE, nullptr, ok);
     319       476608 :     const int toLane = attrs.get<int>(SUMO_ATTR_TO_LANE, nullptr, ok);
     320       476608 :     std::string dir = attrs.get<std::string>(SUMO_ATTR_DIR, nullptr, ok);
     321       476926 :     std::string viaID = attrs.getOpt<std::string>(SUMO_ATTR_VIA, nullptr, ok, "");
     322       476926 :     std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, nullptr, ok, "");
     323       476608 :     ROEdge* from = myNet.getEdge(fromID);
     324              :     ROEdge* to = myNet.getEdge(toID);
     325       476608 :     if (from == nullptr) {
     326          207 :         throw ProcessError(TLF("unknown from-edge '%' in connection", fromID));
     327              :     }
     328       476539 :     if (to == nullptr) {
     329          207 :         throw ProcessError(TLF("unknown to-edge '%' in connection", toID));
     330              :     }
     331       476470 :     if ((int)from->getLanes().size() <= fromLane) {
     332          270 :         throw ProcessError("invalid fromLane '" + toString(fromLane) + "' in connection from '" + fromID + "'.");
     333              :     }
     334       476380 :     if ((int)to->getLanes().size() <= toLane) {
     335          270 :         throw ProcessError("invalid toLane '" + toString(toLane) + "' in connection to '" + toID + "'.");
     336              :     }
     337       476290 :     if (myIgnoreInternal || viaID == "") {
     338       313944 :         std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, nullptr, ok, "");
     339       313944 :         std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, nullptr, ok, "");
     340              :         ROEdge* dummyVia = nullptr;
     341              :         SVCPermissions permissions;
     342       313944 :         if (allow == "" && disallow == "") {
     343              :             permissions = SVC_UNSPECIFIED;
     344              :         } else {
     345           13 :             myNet.setPermissionsFound();
     346              :             // dummyVia is only needed to hold permissions
     347           13 :             permissions = parseVehicleClasses(allow, disallow);
     348           13 :             dummyVia = new ROEdge("dummyVia_" + from->getLanes()[fromLane]->getID() + "->" + to->getLanes()[toLane]->getID(),
     349           26 :                                   from->getToJunction(), from->getToJunction(), permissions);
     350           13 :             myNet.addEdge(dummyVia);
     351              :         }
     352       313944 :         from->getLanes()[fromLane]->addOutgoingLane(to->getLanes()[toLane], dummyVia);
     353       941832 :         from->addSuccessor(to, nullptr, dir);
     354              :     } else {
     355       162346 :         ROEdge* const via = myNet.getEdge(SUMOXMLDefinitions::getEdgeIDFromLane(viaID));
     356       162346 :         if (via == nullptr) {
     357            0 :             throw ProcessError(TLF("unknown via-edge '%' in connection", viaID));
     358              :         }
     359       162346 :         from->getLanes()[fromLane]->addOutgoingLane(to->getLanes()[toLane], via);
     360       324692 :         from->addSuccessor(to, via, dir);
     361       324692 :         via->addSuccessor(to, nullptr, dir);
     362       162346 :         LinkState state = SUMOXMLDefinitions::LinkStates.get(attrs.get<std::string>(SUMO_ATTR_STATE, nullptr, ok));
     363       162346 :         if (state == LINKSTATE_MINOR || state == LINKSTATE_EQUAL || state == LINKSTATE_STOP || state == LINKSTATE_ALLWAY_STOP) {
     364        94273 :             via->setTimePenalty(myMinorPenalty);
     365              :         }
     366       288446 :         if (dir == toString(LinkDirection::TURN) || dir == toString(LinkDirection::TURN_LEFTHAND)) {
     367        36568 :             via->setTimePenalty(myTurnaroundPenalty);
     368              :         }
     369       162346 :         if (tlID != "") {
     370        14332 :             via->setTimePenalty(myTLSPenalty);
     371              :         }
     372              :     }
     373       476290 :     if (to->isCrossing()) {
     374        12202 :         to->setTimePenalty(myTLSPenalty);
     375              :     }
     376       476290 : }
     377              : 
     378              : 
     379              : void
     380         1968 : RONetHandler::parseStoppingPlace(const SUMOSAXAttributes& attrs, const SumoXMLTag element) {
     381         1968 :     bool ok = true;
     382         1968 :     myCurrentStoppingPlace = new SUMOVehicleParameter::Stop();
     383              :     // get the id, throw if not given or empty...
     384         1968 :     std::string id = attrs.get<std::string>(SUMO_ATTR_ID, toString(element).c_str(), ok);
     385              :     // get the lane
     386         1968 :     myCurrentStoppingPlace->lane = attrs.get<std::string>(SUMO_ATTR_LANE, toString(element).c_str(), ok);
     387         1968 :     if (!ok) {
     388            0 :         throw ProcessError();
     389              :     }
     390         1968 :     const ROEdge* edge = myNet.getEdgeForLaneID(myCurrentStoppingPlace->lane);
     391         1968 :     if (edge == nullptr) {
     392            0 :         throw InvalidArgument("Unknown lane '" + myCurrentStoppingPlace->lane + "' for " + toString(element) + " '" + id + "'.");
     393              :     }
     394              :     // get the positions
     395         1968 :     myCurrentStoppingPlace->startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0.);
     396         1968 :     myCurrentStoppingPlace->endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, edge->getLength());
     397         1968 :     const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
     398         1968 :     if (!ok || (SUMORouteHandler::checkStopPos(myCurrentStoppingPlace->startPos, myCurrentStoppingPlace->endPos, edge->getLength(), POSITION_EPS, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
     399            0 :         throw InvalidArgument("Invalid position for " + toString(element) + " '" + id + "'.");
     400              :     }
     401              :     // this is a hack: the busstop attribute is meant to hold the id within the simulation context but this is not used within the router context
     402         1968 :     myCurrentStoppingPlace->busstop = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
     403              :     // this is a hack: the actType is not used when using this to encode a stopping place
     404         1968 :     myCurrentStoppingPlace->actType = toString(element);
     405         1968 :     myNet.addStoppingPlace(id, element, myCurrentStoppingPlace);
     406         1968 : }
     407              : 
     408              : 
     409              : void
     410         2076 : RONetHandler::parseAccess(const SUMOSAXAttributes& attrs) {
     411         2076 :     bool ok = true;
     412         2076 :     const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, "access", ok);
     413         2076 :     const ROEdge* edge = myNet.getEdgeForLaneID(lane);
     414         2076 :     if (edge == nullptr) {
     415            0 :         throw InvalidArgument("Unknown lane '" + lane + "' for access.");
     416              :     }
     417         2076 :     if ((edge->getPermissions() & SVC_PEDESTRIAN) == 0) {
     418            0 :         WRITE_WARNINGF(TL("Ignoring invalid access from non-pedestrian edge '%'."), edge->getID());
     419              :         return;
     420              :     }
     421         2076 :     const bool random = attrs.getOpt<std::string>(SUMO_ATTR_POSITION, "access", ok) == "random";
     422         2076 :     double pos = random ? edge->getLength() / 2. : attrs.getOpt<double>(SUMO_ATTR_POSITION, "access", ok, 0.);
     423         2076 :     double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "access", ok, -1);
     424         2076 :     const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "access", ok, false);
     425         2076 :     if (!ok || (SUMORouteHandler::checkStopPos(pos, pos, edge->getLength(), 0., friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
     426            0 :         throw InvalidArgument("Invalid position " + toString(pos) + " for access on lane '" + lane + "'.");
     427              :     }
     428              :     if (!ok) {
     429              :         throw ProcessError();
     430              :     }
     431         2076 :     if (length < 0) {
     432          568 :         const Position accPos = myNet.getLane(lane)->geometryPositionAtOffset(pos);
     433          568 :         const double stopCenter = (myCurrentStoppingPlace->startPos + myCurrentStoppingPlace->endPos) / 2;
     434          568 :         const Position stopPos = myNet.getLane(myCurrentStoppingPlace->lane)->geometryPositionAtOffset(stopCenter);
     435          568 :         length  = accPos.distanceTo(stopPos);
     436              :     }
     437         4152 :     myCurrentStoppingPlace->accessPos.push_back(std::make_tuple(lane, pos, length));
     438              : }
     439              : 
     440              : 
     441              : void
     442          381 : RONetHandler::parseDistrict(const SUMOSAXAttributes& attrs) {
     443          381 :     myCurrentEdge = nullptr;
     444          381 :     bool ok = true;
     445          381 :     myCurrentName = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
     446          381 :     if (!ok) {
     447            0 :         return;
     448              :     }
     449          762 :     ROEdge* const sink = myEdgeBuilder.buildEdge(myCurrentName + "-sink", nullptr, nullptr, 0, "", "");
     450          762 :     ROEdge* const source = myEdgeBuilder.buildEdge(myCurrentName + "-source", nullptr, nullptr, 0, "", "");
     451          381 :     myNet.addDistrict(myCurrentName, source, sink);
     452          381 :     if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
     453          244 :         const std::vector<std::string>& desc = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, myCurrentName.c_str(), ok);
     454          809 :         for (const std::string& eID : desc) {
     455         1695 :             myNet.addDistrictEdge(myCurrentName, eID, true);
     456         1695 :             myNet.addDistrictEdge(myCurrentName, eID, false);
     457              :         }
     458          244 :     }
     459              : }
     460              : 
     461              : 
     462              : void
     463          249 : RONetHandler::parseDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource) {
     464          249 :     bool ok = true;
     465          249 :     std::string id = attrs.get<std::string>(SUMO_ATTR_ID, myCurrentName.c_str(), ok);
     466          747 :     myNet.addDistrictEdge(myCurrentName, id, isSource);
     467          249 : }
     468              : 
     469              : void
     470         4226 : RONetHandler::setLocation(const SUMOSAXAttributes& attrs) {
     471         4226 :     bool ok = true;
     472         4226 :     PositionVector s = attrs.get<PositionVector>(SUMO_ATTR_NET_OFFSET, nullptr, ok);
     473         4226 :     Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, nullptr, ok);
     474         4226 :     Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, nullptr, ok);
     475         4226 :     std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, nullptr, ok);
     476         4226 :     if (ok) {
     477         4226 :         Position networkOffset = s[0];
     478         4226 :         GeoConvHelper::init(proj, networkOffset, origBoundary, convBoundary);
     479              :     }
     480         4226 : }
     481              : 
     482              : 
     483              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1