LCOV - code coverage report
Current view: top level - src/netbuild - NBTypeCont.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 73.7 % 251 185
Test Date: 2025-12-06 15:35:27 Functions: 79.5 % 44 35

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    NBTypeCont.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Michael Behrisch
      18              : /// @author  Walter Bamberger
      19              : /// @date    Tue, 20 Nov 2001
      20              : ///
      21              : // A storage for the available types of an edge
      22              : /****************************************************************************/
      23              : #include <config.h>
      24              : 
      25              : #include <string>
      26              : #include <map>
      27              : #include <iostream>
      28              : #include <utils/common/MsgHandler.h>
      29              : #include <utils/common/ToString.h>
      30              : #include <utils/iodevices/OutputDevice.h>
      31              : 
      32              : #include "NBTypeCont.h"
      33              : 
      34              : 
      35              : // ===========================================================================
      36              : // method definitions
      37              : // ===========================================================================
      38              : 
      39              : // ---------------------------------------------------------------------------
      40              : // NBTypeCont::EdgeTypeDefinition - methods
      41              : // ---------------------------------------------------------------------------
      42              : 
      43        52469 : NBTypeCont::LaneTypeDefinition::LaneTypeDefinition() :
      44        52469 :     speed(NBEdge::UNSPECIFIED_SPEED),
      45        52469 :     friction(NBEdge::UNSPECIFIED_FRICTION),
      46        52469 :     permissions(SVC_UNSPECIFIED),
      47        52469 :     width(NBEdge::UNSPECIFIED_WIDTH) {
      48        52469 : }
      49              : 
      50              : 
      51            0 : NBTypeCont::LaneTypeDefinition::LaneTypeDefinition(const EdgeTypeDefinition* edgeTypeDefinition) :
      52            0 :     speed(edgeTypeDefinition->speed),
      53            0 :     friction(edgeTypeDefinition->friction),
      54            0 :     permissions(edgeTypeDefinition->permissions),
      55            0 :     width(edgeTypeDefinition->width) {
      56            0 : }
      57              : 
      58              : 
      59           59 : NBTypeCont::LaneTypeDefinition::LaneTypeDefinition(const double _speed, const double _friction, const double _width, SVCPermissions _permissions, const std::set<SumoXMLAttr>& _attrs) :
      60           59 :     speed(_speed),
      61           59 :     friction(_friction),
      62           59 :     permissions(_permissions),
      63           59 :     width(_width),
      64              :     attrs(_attrs) {
      65           59 : }
      66              : 
      67              : 
      68            0 : NBTypeCont::LaneTypeDefinition::LaneTypeDefinition(const LaneTypeDefinition* laneTypeDefinition) :
      69            0 :     speed(laneTypeDefinition->speed),
      70            0 :     friction(laneTypeDefinition->friction),
      71            0 :     permissions(laneTypeDefinition->permissions),
      72            0 :     width(laneTypeDefinition->width),
      73              :     restrictions(laneTypeDefinition->restrictions),
      74              :     attrs(laneTypeDefinition->attrs) {
      75            0 : }
      76              : 
      77              : // ---------------------------------------------------------------------------
      78              : // NBTypeCont::EdgeTypeDefinition - methods
      79              : // ---------------------------------------------------------------------------
      80              : 
      81         2113 : NBTypeCont::EdgeTypeDefinition::EdgeTypeDefinition() :
      82         2113 :     speed(13.89), friction(NBEdge::UNSPECIFIED_FRICTION), priority(-1),
      83         2113 :     permissions(SVC_UNSPECIFIED),
      84         2113 :     spreadType(LaneSpreadFunction::RIGHT),
      85         2113 :     oneWay(true), discard(false),
      86         2113 :     width(NBEdge::UNSPECIFIED_WIDTH),
      87         2113 :     widthResolution(0),
      88         2113 :     maxWidth(0),
      89         2113 :     minWidth(0),
      90         2113 :     sidewalkWidth(NBEdge::UNSPECIFIED_WIDTH),
      91         2113 :     bikeLaneWidth(NBEdge::UNSPECIFIED_WIDTH) {
      92              :     // set laneTypes
      93         2113 :     laneTypeDefinitions.resize(1);
      94         2113 : }
      95              : 
      96              : 
      97            0 : NBTypeCont::EdgeTypeDefinition::EdgeTypeDefinition(const EdgeTypeDefinition* edgeType) :
      98            0 :     speed(edgeType->speed),
      99            0 :     friction(edgeType->friction),
     100            0 :     priority(edgeType->priority),
     101            0 :     permissions(edgeType->permissions),
     102            0 :     spreadType(edgeType->spreadType),
     103            0 :     oneWay(edgeType->oneWay),
     104            0 :     discard(edgeType->discard),
     105            0 :     width(edgeType->width),
     106            0 :     widthResolution(edgeType->widthResolution),
     107            0 :     maxWidth(edgeType->maxWidth),
     108            0 :     minWidth(edgeType->minWidth),
     109            0 :     sidewalkWidth(edgeType->sidewalkWidth),
     110            0 :     bikeLaneWidth(edgeType->bikeLaneWidth),
     111              :     restrictions(edgeType->restrictions),
     112              :     attrs(edgeType->attrs),
     113            0 :     laneTypeDefinitions(edgeType->laneTypeDefinitions) {
     114            0 : }
     115              : 
     116              : 
     117        10613 : NBTypeCont::EdgeTypeDefinition::EdgeTypeDefinition(int numLanes, double _speed, double _friction, int _priority,
     118              :         double _width, SVCPermissions _permissions, LaneSpreadFunction _spreadType, bool _oneWay, double _sideWalkWidth,
     119        10613 :         double _bikeLaneWidth, double _widthResolution, double _maxWidth, double _minWidth) :
     120        10613 :     speed(_speed), friction(_friction), priority(_priority), //TODO
     121        10613 :     permissions(_permissions),
     122        10613 :     spreadType(_spreadType),
     123        10613 :     oneWay(_oneWay),
     124        10613 :     discard(false),
     125        10613 :     width(_width),
     126        10613 :     widthResolution(_widthResolution),
     127        10613 :     maxWidth(_maxWidth),
     128        10613 :     minWidth(_minWidth),
     129        10613 :     sidewalkWidth(_sideWalkWidth),
     130        10613 :     bikeLaneWidth(_bikeLaneWidth) {
     131              :     // set laneTypes
     132        10613 :     laneTypeDefinitions.resize(numLanes);
     133        10613 : }
     134              : 
     135              : 
     136              : bool
     137         1839 : NBTypeCont::EdgeTypeDefinition::needsLaneType() const {
     138         4670 :     for (const LaneTypeDefinition& laneType : laneTypeDefinitions) {
     139          112 :         if (laneType.attrs.count(SUMO_ATTR_SPEED) > 0 && laneType.speed != NBEdge::UNSPECIFIED_SPEED && laneType.speed != speed) {
     140              :             return true;
     141              :         }
     142            0 :         if (laneType.attrs.count(SUMO_ATTR_FRICTION) > 0 && laneType.friction != NBEdge::UNSPECIFIED_FRICTION && laneType.friction != friction) {
     143              :             return true;
     144              :         }
     145              :         if ((laneType.attrs.count(SUMO_ATTR_DISALLOW) > 0 || laneType.attrs.count(SUMO_ATTR_ALLOW) > 0)
     146            0 :                 && laneType.permissions != permissions) {
     147              :             return true;
     148              :         }
     149           15 :         if (laneType.attrs.count(SUMO_ATTR_WIDTH) > 0 && laneType.width != width && laneType.width != NBEdge::UNSPECIFIED_WIDTH) {
     150              :             return true;
     151              :         }
     152         2831 :         if (laneType.restrictions.size() > 0) {
     153              :             return true;
     154              :         }
     155              :     }
     156              :     return false;
     157              : }
     158              : 
     159              : // ---------------------------------------------------------------------------
     160              : // NBTypeCont - methods
     161              : // ---------------------------------------------------------------------------
     162              : 
     163         2113 : NBTypeCont::NBTypeCont() :
     164         2113 :     myDefaultType(new EdgeTypeDefinition()) {}
     165              : 
     166              : 
     167         2113 : NBTypeCont::~NBTypeCont() {
     168         2113 :     clearTypes();
     169         2113 :     delete myDefaultType;
     170         2113 : }
     171              : 
     172              : 
     173              : void
     174         2113 : NBTypeCont::clearTypes() {
     175              :     // remove edge types
     176        12255 :     for (const auto& edgeType : myEdgeTypes) {
     177        10142 :         delete edgeType.second;
     178              :     }
     179              :     // clear edge types
     180              :     myEdgeTypes.clear();
     181         2113 : }
     182              : 
     183              : 
     184              : void
     185         2113 : NBTypeCont::setEdgeTypeDefaults(int defaultNumLanes,
     186              :                                 double defaultLaneWidth,
     187              :                                 double defaultSpeed,
     188              :                                 double defaultFriction,
     189              :                                 int defaultPriority,
     190              :                                 SVCPermissions defaultPermissions,
     191              :                                 LaneSpreadFunction defaultSpreadType) {
     192         2113 :     myDefaultType->laneTypeDefinitions.clear();
     193         2113 :     myDefaultType->laneTypeDefinitions.resize(defaultNumLanes);
     194         2113 :     myDefaultType->width = defaultLaneWidth;
     195         2113 :     myDefaultType->speed = defaultSpeed;
     196         2113 :     myDefaultType->friction = defaultFriction;
     197         2113 :     myDefaultType->priority = defaultPriority;
     198         2113 :     myDefaultType->permissions = defaultPermissions;
     199         2113 :     myDefaultType->spreadType = defaultSpreadType;
     200         2113 : }
     201              : 
     202              : 
     203              : void
     204        10613 : NBTypeCont::insertEdgeType(const std::string& id, int numLanes, double maxSpeed, int prio,
     205              :                            SVCPermissions permissions, LaneSpreadFunction spreadType, double width,
     206              :                            bool oneWayIsDefault, double sidewalkWidth, double bikeLaneWidth,
     207              :                            double widthResolution, double maxWidth, double minWidth) {
     208              :     // Create edge type definition
     209              :     EdgeTypeDefinition* newType = new EdgeTypeDefinition(numLanes, maxSpeed, NBEdge::UNSPECIFIED_FRICTION, prio,
     210              :             width, permissions, spreadType, oneWayIsDefault, sidewalkWidth,
     211        10613 :             bikeLaneWidth, widthResolution, maxWidth, minWidth);
     212              :     // check if edgeType already exist in types
     213              :     TypesCont::iterator old = myEdgeTypes.find(id);
     214              :     // if exists, then update restrictions and attributes
     215        10613 :     if (old != myEdgeTypes.end()) {
     216          471 :         newType->restrictions.insert(old->second->restrictions.begin(), old->second->restrictions.end());
     217          471 :         newType->attrs.insert(old->second->attrs.begin(), old->second->attrs.end());
     218          471 :         delete old->second;
     219              :     }
     220              :     // insert it in types
     221        10613 :     myEdgeTypes[id] = newType;
     222        10613 : }
     223              : 
     224              : 
     225              : void
     226            0 : NBTypeCont::insertEdgeType(const std::string& id, const EdgeTypeDefinition* edgeType) {
     227              :     // Create edge type definition
     228            0 :     EdgeTypeDefinition* newType = new EdgeTypeDefinition(edgeType);
     229              :     // check if edgeType already exist in types
     230              :     TypesCont::iterator old = myEdgeTypes.find(id);
     231              :     // if exists, then update restrictions and attributes
     232            0 :     if (old != myEdgeTypes.end()) {
     233            0 :         newType->restrictions.insert(old->second->restrictions.begin(), old->second->restrictions.end());
     234            0 :         newType->attrs.insert(old->second->attrs.begin(), old->second->attrs.end());
     235            0 :         delete old->second;
     236              :     }
     237              :     // insert it in types
     238            0 :     myEdgeTypes[id] = newType;
     239            0 : }
     240              : 
     241              : 
     242              : void
     243           59 : NBTypeCont::insertLaneType(const std::string& edgeTypeID, int index, double maxSpeed, SVCPermissions permissions,
     244              :                            double width, const std::set<SumoXMLAttr>& attrs) {
     245           59 :     EdgeTypeDefinition* et = myEdgeTypes.at(edgeTypeID);
     246           59 :     while ((int)et->laneTypeDefinitions.size() <= index) {
     247            0 :         et->laneTypeDefinitions.push_back(et);
     248              :     }
     249              :     // add LaneTypeDefinition with the given attributes
     250           59 :     et->laneTypeDefinitions[index] = LaneTypeDefinition(maxSpeed, NBEdge::UNSPECIFIED_FRICTION, width, permissions, attrs);
     251           59 : }
     252              : 
     253              : 
     254              : int
     255         2393 : NBTypeCont::size() const {
     256         2393 :     return (int)myEdgeTypes.size();
     257              : }
     258              : 
     259              : 
     260              : void
     261            0 : NBTypeCont::removeEdgeType(const std::string& id) {
     262              :     // check if edgeType already exist in types
     263              :     const auto it = myEdgeTypes.find(id);
     264              :     // if exists, then remove it
     265            0 :     if (it != myEdgeTypes.end()) {
     266              :         // remove it from map
     267            0 :         delete it->second;
     268              :         myEdgeTypes.erase(it);
     269              :     }
     270            0 : }
     271              : 
     272              : 
     273              : void
     274            0 : NBTypeCont::updateEdgeTypeID(const std::string& oldId, const std::string& newId) {
     275              :     // check if edgeType already exist in types
     276              :     const auto oldIt = myEdgeTypes.find(oldId);
     277              :     const auto newIt = myEdgeTypes.find(newId);
     278              :     // if exists, then remove it
     279            0 :     if ((oldIt != myEdgeTypes.end()) && (newIt == myEdgeTypes.end())) {
     280              :         // obtain pointer
     281            0 :         auto edgeType = oldIt->second;
     282              :         // remove it from map
     283              :         myEdgeTypes.erase(oldIt);
     284              :         // add it again
     285            0 :         myEdgeTypes[newId] = edgeType;
     286              :     }
     287            0 : }
     288              : 
     289              : 
     290              : NBTypeCont::TypesCont::const_iterator
     291           24 : NBTypeCont::begin() const {
     292           24 :     return myEdgeTypes.cbegin();
     293              : }
     294              : 
     295              : 
     296              : NBTypeCont::TypesCont::const_iterator
     297            0 : NBTypeCont::end() const {
     298            0 :     return myEdgeTypes.cend();
     299              : }
     300              : 
     301              : 
     302              : bool
     303       243878 : NBTypeCont::knows(const std::string& type) const {
     304       243878 :     return myEdgeTypes.find(type) != myEdgeTypes.end();
     305              : }
     306              : 
     307              : 
     308              : bool
     309          523 : NBTypeCont::markEdgeTypeAsToDiscard(const std::string& id) {
     310              :     TypesCont::iterator i = myEdgeTypes.find(id);
     311          523 :     if (i == myEdgeTypes.end()) {
     312              :         return false;
     313              :     }
     314          523 :     i->second->discard = true;
     315          523 :     return true;
     316              : }
     317              : 
     318              : 
     319              : bool
     320        53961 : NBTypeCont::markEdgeTypeAsSet(const std::string& id, const SumoXMLAttr attr) {
     321              :     TypesCont::iterator i = myEdgeTypes.find(id);
     322        53961 :     if (i == myEdgeTypes.end()) {
     323              :         return false;
     324              :     }
     325        53961 :     i->second->attrs.insert(attr);
     326        53961 :     return true;
     327              : }
     328              : 
     329              : 
     330              : bool
     331            2 : NBTypeCont::addEdgeTypeRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
     332              :     TypesCont::iterator i = myEdgeTypes.find(id);
     333            2 :     if (i == myEdgeTypes.end()) {
     334              :         return false;
     335              :     }
     336            2 :     i->second->restrictions[svc] = speed;
     337            2 :     return true;
     338              : }
     339              : 
     340              : 
     341              : bool
     342           84 : NBTypeCont::copyEdgeTypeRestrictionsAndAttrs(const std::string& fromId, const std::string& toId) {
     343              :     TypesCont::iterator from = myEdgeTypes.find(fromId);
     344              :     TypesCont::iterator to = myEdgeTypes.find(toId);
     345           84 :     if (from == myEdgeTypes.end() || to == myEdgeTypes.end()) {
     346              :         return false;
     347              :     }
     348           84 :     to->second->restrictions.insert(from->second->restrictions.begin(), from->second->restrictions.end());
     349           84 :     to->second->attrs.insert(from->second->attrs.begin(), from->second->attrs.end());
     350           84 :     return true;
     351              : }
     352              : 
     353              : 
     354              : bool
     355          100 : NBTypeCont::markLaneTypeAsSet(const std::string& id, int index, const SumoXMLAttr attr) {
     356              :     TypesCont::iterator i = myEdgeTypes.find(id);
     357          100 :     if (i == myEdgeTypes.end()) {
     358              :         return false;
     359              :     }
     360          100 :     i->second->laneTypeDefinitions[index].attrs.insert(attr);
     361          100 :     return true;
     362              : }
     363              : 
     364              : 
     365              : bool
     366            0 : NBTypeCont::addLaneTypeRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
     367              :     TypesCont::iterator i = myEdgeTypes.find(id);
     368            0 :     if (i == myEdgeTypes.end()) {
     369              :         return false;
     370              :     }
     371            0 :     i->second->laneTypeDefinitions.back().restrictions[svc] = speed;
     372            0 :     return true;
     373              : }
     374              : 
     375              : 
     376              : void
     377         1742 : NBTypeCont::writeEdgeTypes(OutputDevice& into,  const std::set<std::string>& typeIDs) const {
     378              :     // iterate over edge types
     379        11799 :     for (const auto& edgeType : myEdgeTypes) {
     380        10057 :         if (typeIDs.size() > 0 && typeIDs.count(edgeType.first) == 0) {
     381         8650 :             continue;
     382              :         }
     383              :         // open edge type tag
     384         1407 :         into.openTag(SUMO_TAG_TYPE);
     385              :         // write ID
     386         1407 :         into.writeAttr(SUMO_ATTR_ID, edgeType.first);
     387              :         // write priority
     388         1407 :         if (edgeType.second->attrs.count(SUMO_ATTR_PRIORITY) > 0) {
     389         1389 :             into.writeAttr(SUMO_ATTR_PRIORITY, edgeType.second->priority);
     390              :         }
     391              :         // write numLanes
     392         1448 :         if (edgeType.second->attrs.count(SUMO_ATTR_NUMLANES) > 0 || edgeType.second->laneTypeDefinitions.size() > 1) {
     393         1366 :             into.writeAttr(SUMO_ATTR_NUMLANES, edgeType.second->laneTypeDefinitions.size());
     394              :         }
     395              :         // write speed
     396         1407 :         if (edgeType.second->attrs.count(SUMO_ATTR_SPEED) > 0) {
     397         1389 :             into.writeAttr(SUMO_ATTR_SPEED, edgeType.second->speed);
     398              :         }
     399              :         // write friction
     400         1407 :         if (edgeType.second->attrs.count(SUMO_ATTR_FRICTION) > 0) {
     401              :             // only write if its not the default value
     402            0 :             if (edgeType.second->friction != NBEdge::UNSPECIFIED_FRICTION) {
     403            0 :                 into.writeAttr(SUMO_ATTR_FRICTION, edgeType.second->friction);
     404              :             }
     405              :         }
     406              :         // write permissions
     407         1407 :         if ((edgeType.second->attrs.count(SUMO_ATTR_DISALLOW) > 0) || (edgeType.second->attrs.count(SUMO_ATTR_ALLOW) > 0)) {
     408         1341 :             writePermissions(into, edgeType.second->permissions);
     409              :         }
     410              :         // write spreadType (unless default)
     411         1443 :         if ((edgeType.second->attrs.count(SUMO_ATTR_SPREADTYPE) > 0) && edgeType.second->spreadType != LaneSpreadFunction::RIGHT) {
     412            7 :             into.writeAttr(SUMO_ATTR_SPREADTYPE, SUMOXMLDefinitions::LaneSpreadFunctions.getString(edgeType.second->spreadType));
     413              :         }
     414              :         // write oneWay
     415         1407 :         if (edgeType.second->attrs.count(SUMO_ATTR_ONEWAY) > 0) {
     416         1292 :             into.writeAttr(SUMO_ATTR_ONEWAY, edgeType.second->oneWay);
     417              :         }
     418              :         // write discard
     419         1407 :         if (edgeType.second->attrs.count(SUMO_ATTR_DISCARD) > 0) {
     420            0 :             into.writeAttr(SUMO_ATTR_DISCARD, edgeType.second->discard);
     421              :         }
     422              :         // write width
     423         1407 :         if (edgeType.second->attrs.count(SUMO_ATTR_WIDTH) > 0) {
     424          275 :             into.writeAttr(SUMO_ATTR_WIDTH, edgeType.second->width);
     425              :         }
     426              :         // write sidewalkwidth
     427         1407 :         if (edgeType.second->attrs.count(SUMO_ATTR_SIDEWALKWIDTH) > 0) {
     428           89 :             into.writeAttr(SUMO_ATTR_SIDEWALKWIDTH, edgeType.second->sidewalkWidth);
     429              :         }
     430              :         // write bikelanewidth
     431         1407 :         if (edgeType.second->attrs.count(SUMO_ATTR_BIKELANEWIDTH) > 0) {
     432           29 :             into.writeAttr(SUMO_ATTR_BIKELANEWIDTH, edgeType.second->bikeLaneWidth);
     433              :         }
     434              :         // write restrictions
     435         1409 :         for (const auto& restriction : edgeType.second->restrictions) {
     436              :             // open restriction tag
     437            2 :             into.openTag(SUMO_TAG_RESTRICTION);
     438              :             // write vclass
     439            2 :             into.writeAttr(SUMO_ATTR_VCLASS, getVehicleClassNames(restriction.first));
     440              :             // write speed
     441            2 :             into.writeAttr(SUMO_ATTR_SPEED, restriction.second);
     442              :             // close restriction tag
     443            4 :             into.closeTag();
     444              :         }
     445              :         // iterate over lanes
     446         1407 :         if (edgeType.second->needsLaneType()) {
     447              :             int index = 0;
     448           68 :             for (const auto& laneType : edgeType.second->laneTypeDefinitions) {
     449              :                 // open lane type taG
     450           45 :                 into.openTag(SUMO_TAG_LANETYPE);
     451           45 :                 into.writeAttr(SUMO_ATTR_INDEX, index++);
     452              :                 // write speed
     453           34 :                 if (laneType.attrs.count(SUMO_ATTR_SPEED) > 0 && laneType.speed != NBEdge::UNSPECIFIED_SPEED
     454           34 :                         && laneType.speed != edgeType.second->speed) {
     455           34 :                     into.writeAttr(SUMO_ATTR_SPEED, laneType.speed);
     456              :                 }
     457              :                 // write friction
     458            0 :                 if (laneType.attrs.count(SUMO_ATTR_FRICTION) > 0 && laneType.friction != NBEdge::UNSPECIFIED_FRICTION
     459            0 :                         && laneType.friction != edgeType.second->friction) {
     460            0 :                     into.writeAttr(SUMO_ATTR_FRICTION, laneType.friction);
     461              :                 }
     462              :                 // write permissions
     463              :                 if (laneType.attrs.count(SUMO_ATTR_DISALLOW) > 0 || laneType.attrs.count(SUMO_ATTR_ALLOW) > 0) {
     464           11 :                     writePermissions(into, laneType.permissions);
     465              :                 }
     466              :                 // write width
     467           29 :                 if (laneType.attrs.count(SUMO_ATTR_WIDTH) > 0 && laneType.width != edgeType.second->width
     468           29 :                         && laneType.width != NBEdge::UNSPECIFIED_WIDTH) {
     469           29 :                     into.writeAttr(SUMO_ATTR_WIDTH, laneType.width);
     470              :                 }
     471              :                 // write restrictions
     472           45 :                 for (const auto& restriction : laneType.restrictions) {
     473              :                     // open restriction tag
     474            0 :                     into.openTag(SUMO_TAG_RESTRICTION);
     475              :                     // write vclass
     476            0 :                     into.writeAttr(SUMO_ATTR_VCLASS, getVehicleClassNames(restriction.first));
     477              :                     // write speed
     478            0 :                     into.writeAttr(SUMO_ATTR_SPEED, restriction.second);
     479              :                     // close restriction tag
     480            0 :                     into.closeTag();
     481              :                 }
     482              :                 // close lane type tag
     483           90 :                 into.closeTag();
     484              :             }
     485              :         }
     486              :         // close edge type tag
     487         2814 :         into.closeTag();
     488              :     }
     489              :     //write endlype
     490         1742 :     if (!myEdgeTypes.empty()) {
     491          330 :         into.lf();
     492              :     }
     493         1742 : }
     494              : 
     495              : 
     496              : int
     497       122475 : NBTypeCont::getEdgeTypeNumLanes(const std::string& type) const {
     498       122475 :     return (int)getEdgeType(type)->laneTypeDefinitions.size();
     499              : }
     500              : 
     501              : 
     502              : double
     503        84123 : NBTypeCont::getEdgeTypeSpeed(const std::string& type) const {
     504        84123 :     return getEdgeType(type)->speed;
     505              : }
     506              : 
     507              : double
     508        16854 : NBTypeCont::getEdgeTypeFriction(const std::string& type) const {
     509        16854 :     return getEdgeType(type)->friction;
     510              : }
     511              : 
     512              : 
     513              : int
     514        96019 : NBTypeCont::getEdgeTypePriority(const std::string& type) const {
     515        96019 :     return getEdgeType(type)->priority;
     516              : }
     517              : 
     518              : 
     519              : bool
     520        47246 : NBTypeCont::getEdgeTypeIsOneWay(const std::string& type) const {
     521        47246 :     return getEdgeType(type)->oneWay;
     522              : }
     523              : 
     524              : 
     525              : bool
     526       101316 : NBTypeCont::getEdgeTypeShallBeDiscarded(const std::string& type) const {
     527       101316 :     return getEdgeType(type)->discard;
     528              : }
     529              : 
     530              : double
     531        10293 : NBTypeCont::getEdgeTypeWidthResolution(const std::string& type) const {
     532        10293 :     return getEdgeType(type)->widthResolution;
     533              : }
     534              : 
     535              : double
     536        10293 : NBTypeCont::getEdgeTypeMaxWidth(const std::string& type) const {
     537        10293 :     return getEdgeType(type)->maxWidth;
     538              : }
     539              : 
     540              : double
     541         9773 : NBTypeCont::getEdgeTypeMinWidth(const std::string& type) const {
     542         9773 :     return getEdgeType(type)->minWidth;
     543              : }
     544              : 
     545              : bool
     546            0 : NBTypeCont::wasSetEdgeTypeAttribute(const std::string& type, const SumoXMLAttr attr) const {
     547            0 :     return getEdgeType(type)->attrs.count(attr) > 0;
     548              : }
     549              : 
     550              : 
     551              : SVCPermissions
     552       106188 : NBTypeCont::getEdgeTypePermissions(const std::string& type) const {
     553       106188 :     return getEdgeType(type)->permissions;
     554              : }
     555              : 
     556              : 
     557              : LaneSpreadFunction
     558        72628 : NBTypeCont::getEdgeTypeSpreadType(const std::string& type) const {
     559        72628 :     return getEdgeType(type)->spreadType;
     560              : }
     561              : 
     562              : 
     563              : double
     564       129189 : NBTypeCont::getEdgeTypeWidth(const std::string& type) const {
     565       129189 :     return getEdgeType(type)->width;
     566              : }
     567              : 
     568              : 
     569              : double
     570        50459 : NBTypeCont::getEdgeTypeSidewalkWidth(const std::string& type) const {
     571        50459 :     return getEdgeType(type)->sidewalkWidth;
     572              : }
     573              : 
     574              : 
     575              : double
     576        50358 : NBTypeCont::getEdgeTypeBikeLaneWidth(const std::string& type) const {
     577        50358 :     return getEdgeType(type)->bikeLaneWidth;
     578              : }
     579              : 
     580              : 
     581              : const NBTypeCont::EdgeTypeDefinition*
     582       907646 : NBTypeCont::getEdgeType(const std::string& name) const {
     583              :     // try to find name in edge types
     584              :     TypesCont::const_iterator i = myEdgeTypes.find(name);
     585              :     // check if return edge types, or default edge types
     586       907646 :     if (i == myEdgeTypes.end()) {
     587       339397 :         return myDefaultType;
     588              :     } else {
     589       568249 :         return i->second;
     590              :     }
     591              : }
     592              : 
     593              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1