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

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2001-2024 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       52148 : NBTypeCont::LaneTypeDefinition::LaneTypeDefinition() :
      44       52148 :     speed(NBEdge::UNSPECIFIED_SPEED),
      45       52148 :     friction(NBEdge::UNSPECIFIED_FRICTION),
      46       52148 :     permissions(SVC_UNSPECIFIED),
      47       52148 :     width(NBEdge::UNSPECIFIED_WIDTH) {
      48       52148 : }
      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        2337 : NBTypeCont::EdgeTypeDefinition::EdgeTypeDefinition() :
      82        2337 :     speed(13.89), friction(NBEdge::UNSPECIFIED_FRICTION), priority(-1),
      83        2337 :     permissions(SVC_UNSPECIFIED),
      84        2337 :     spreadType(LaneSpreadFunction::RIGHT),
      85        2337 :     oneWay(true), discard(false),
      86        2337 :     width(NBEdge::UNSPECIFIED_WIDTH),
      87        2337 :     widthResolution(0),
      88        2337 :     maxWidth(0),
      89        2337 :     minWidth(0),
      90        2337 :     sidewalkWidth(NBEdge::UNSPECIFIED_WIDTH),
      91        2337 :     bikeLaneWidth(NBEdge::UNSPECIFIED_WIDTH) {
      92             :     // set laneTypes
      93        2337 :     laneTypeDefinitions.resize(1);
      94        2337 : }
      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        9861 : NBTypeCont::EdgeTypeDefinition::EdgeTypeDefinition(int numLanes, double _speed, double _friction, int _priority,
     118             :         double _width, SVCPermissions _permissions, LaneSpreadFunction _spreadType, bool _oneWay, double _sideWalkWidth,
     119        9861 :         double _bikeLaneWidth, double _widthResolution, double _maxWidth, double _minWidth) :
     120        9861 :     speed(_speed), friction(_friction), priority(_priority), //TODO
     121        9861 :     permissions(_permissions),
     122        9861 :     spreadType(_spreadType),
     123        9861 :     oneWay(_oneWay),
     124        9861 :     discard(false),
     125        9861 :     width(_width),
     126        9861 :     widthResolution(_widthResolution),
     127        9861 :     maxWidth(_maxWidth),
     128        9861 :     minWidth(_minWidth),
     129        9861 :     sidewalkWidth(_sideWalkWidth),
     130        9861 :     bikeLaneWidth(_bikeLaneWidth) {
     131             :     // set laneTypes
     132        9861 :     laneTypeDefinitions.resize(numLanes);
     133        9861 : }
     134             : 
     135             : 
     136             : bool
     137        1948 : NBTypeCont::EdgeTypeDefinition::needsLaneType() const {
     138        4948 :     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        3000 :         if (laneType.restrictions.size() > 0) {
     153             :             return true;
     154             :         }
     155             :     }
     156             :     return false;
     157             : }
     158             : 
     159             : // ---------------------------------------------------------------------------
     160             : // NBTypeCont - methods
     161             : // ---------------------------------------------------------------------------
     162             : 
     163        2337 : NBTypeCont::NBTypeCont() :
     164        4674 :     myDefaultType(new EdgeTypeDefinition()) {}
     165             : 
     166             : 
     167        2337 : NBTypeCont::~NBTypeCont() {
     168        2337 :     clearTypes();
     169        2337 :     delete myDefaultType;
     170        2337 : }
     171             : 
     172             : 
     173             : void
     174        2337 : NBTypeCont::clearTypes() {
     175             :     // remove edge types
     176       11727 :     for (const auto& edgeType : myEdgeTypes) {
     177        9390 :         delete edgeType.second;
     178             :     }
     179             :     // clear edge types
     180             :     myEdgeTypes.clear();
     181        2337 : }
     182             : 
     183             : 
     184             : void
     185        2337 : NBTypeCont::setEdgeTypeDefaults(int defaultNumLanes,
     186             :                                 double defaultLaneWidth,
     187             :                                 double defaultSpeed,
     188             :                                 double defaultFriction,
     189             :                                 int defaultPriority,
     190             :                                 SVCPermissions defaultPermissions,
     191             :                                 LaneSpreadFunction defaultSpreadType) {
     192        2337 :     myDefaultType->laneTypeDefinitions.clear();
     193        2337 :     myDefaultType->laneTypeDefinitions.resize(defaultNumLanes);
     194        2337 :     myDefaultType->width = defaultLaneWidth;
     195        2337 :     myDefaultType->speed = defaultSpeed;
     196        2337 :     myDefaultType->friction = defaultFriction;
     197        2337 :     myDefaultType->priority = defaultPriority;
     198        2337 :     myDefaultType->permissions = defaultPermissions;
     199        2337 :     myDefaultType->spreadType = defaultSpreadType;
     200        2337 : }
     201             : 
     202             : 
     203             : void
     204        9861 : 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        9861 :             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        9861 :     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        9861 :     myEdgeTypes[id] = newType;
     222        9861 : }
     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        2530 : NBTypeCont::size() const {
     256        2530 :     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      289129 : NBTypeCont::knows(const std::string& type) const {
     304      289129 :     return myEdgeTypes.find(type) != myEdgeTypes.end();
     305             : }
     306             : 
     307             : 
     308             : bool
     309         480 : NBTypeCont::markEdgeTypeAsToDiscard(const std::string& id) {
     310             :     TypesCont::iterator i = myEdgeTypes.find(id);
     311         480 :     if (i == myEdgeTypes.end()) {
     312             :         return false;
     313             :     }
     314         480 :     i->second->discard = true;
     315         480 :     return true;
     316             : }
     317             : 
     318             : 
     319             : bool
     320       50080 : NBTypeCont::markEdgeTypeAsSet(const std::string& id, const SumoXMLAttr attr) {
     321             :     TypesCont::iterator i = myEdgeTypes.find(id);
     322       50080 :     if (i == myEdgeTypes.end()) {
     323             :         return false;
     324             :     }
     325       50080 :     i->second->attrs.insert(attr);
     326       50080 :     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         108 : 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         108 :     if (from == myEdgeTypes.end() || to == myEdgeTypes.end()) {
     346             :         return false;
     347             :     }
     348         108 :     to->second->restrictions.insert(from->second->restrictions.begin(), from->second->restrictions.end());
     349         108 :     to->second->attrs.insert(from->second->attrs.begin(), from->second->attrs.end());
     350         108 :     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        1744 : NBTypeCont::writeEdgeTypes(OutputDevice& into,  const std::set<std::string>& typeIDs) const {
     378             :     // iterate over edge types
     379       11134 :     for (const auto& edgeType : myEdgeTypes) {
     380        9390 :         if (typeIDs.size() > 0 && typeIDs.count(edgeType.first) == 0) {
     381        7894 :             continue;
     382             :         }
     383             :         // open edge type tag
     384        1496 :         into.openTag(SUMO_TAG_TYPE);
     385             :         // write ID
     386        1496 :         into.writeAttr(SUMO_ATTR_ID, edgeType.first);
     387             :         // write priority
     388        1496 :         if (edgeType.second->attrs.count(SUMO_ATTR_PRIORITY) > 0) {
     389        1478 :             into.writeAttr(SUMO_ATTR_PRIORITY, edgeType.second->priority);
     390             :         }
     391             :         // write numLanes
     392        1538 :         if (edgeType.second->attrs.count(SUMO_ATTR_NUMLANES) > 0 || edgeType.second->laneTypeDefinitions.size() > 1) {
     393        2908 :             into.writeAttr(SUMO_ATTR_NUMLANES, edgeType.second->laneTypeDefinitions.size());
     394             :         }
     395             :         // write speed
     396        1496 :         if (edgeType.second->attrs.count(SUMO_ATTR_SPEED) > 0) {
     397        1479 :             into.writeAttr(SUMO_ATTR_SPEED, edgeType.second->speed);
     398             :         }
     399             :         // write friction
     400        1496 :         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        1496 :         if ((edgeType.second->attrs.count(SUMO_ATTR_DISALLOW) > 0) || (edgeType.second->attrs.count(SUMO_ATTR_ALLOW) > 0)) {
     408        1427 :             writePermissions(into, edgeType.second->permissions);
     409             :         }
     410             :         // write spreadType (unless default)
     411        1532 :         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        1496 :         if (edgeType.second->attrs.count(SUMO_ATTR_ONEWAY) > 0) {
     416        1376 :             into.writeAttr(SUMO_ATTR_ONEWAY, edgeType.second->oneWay);
     417             :         }
     418             :         // write discard
     419        1496 :         if (edgeType.second->attrs.count(SUMO_ATTR_DISCARD) > 0) {
     420           0 :             into.writeAttr(SUMO_ATTR_DISCARD, edgeType.second->discard);
     421             :         }
     422             :         // write width
     423        1496 :         if (edgeType.second->attrs.count(SUMO_ATTR_WIDTH) > 0) {
     424         309 :             into.writeAttr(SUMO_ATTR_WIDTH, edgeType.second->width);
     425             :         }
     426             :         // write sidewalkwidth
     427        1496 :         if (edgeType.second->attrs.count(SUMO_ATTR_SIDEWALKWIDTH) > 0) {
     428          99 :             into.writeAttr(SUMO_ATTR_SIDEWALKWIDTH, edgeType.second->sidewalkWidth);
     429             :         }
     430             :         // write bikelanewidth
     431        1496 :         if (edgeType.second->attrs.count(SUMO_ATTR_BIKELANEWIDTH) > 0) {
     432          38 :             into.writeAttr(SUMO_ATTR_BIKELANEWIDTH, edgeType.second->bikeLaneWidth);
     433             :         }
     434             :         // write restrictions
     435        1498 :         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        1496 :         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          90 :                 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        2992 :         into.closeTag();
     488             :     }
     489             :     //write endlype
     490        1744 :     if (!myEdgeTypes.empty()) {
     491         312 :         into.lf();
     492             :     }
     493        1744 : }
     494             : 
     495             : 
     496             : int
     497      159781 : NBTypeCont::getEdgeTypeNumLanes(const std::string& type) const {
     498      159781 :     return (int)getEdgeType(type)->laneTypeDefinitions.size();
     499             : }
     500             : 
     501             : 
     502             : double
     503      105548 : NBTypeCont::getEdgeTypeSpeed(const std::string& type) const {
     504      105548 :     return getEdgeType(type)->speed;
     505             : }
     506             : 
     507             : double
     508       21090 : NBTypeCont::getEdgeTypeFriction(const std::string& type) const {
     509       21090 :     return getEdgeType(type)->friction;
     510             : }
     511             : 
     512             : 
     513             : int
     514      120966 : NBTypeCont::getEdgeTypePriority(const std::string& type) const {
     515      120966 :     return getEdgeType(type)->priority;
     516             : }
     517             : 
     518             : 
     519             : bool
     520       63295 : NBTypeCont::getEdgeTypeIsOneWay(const std::string& type) const {
     521       63295 :     return getEdgeType(type)->oneWay;
     522             : }
     523             : 
     524             : 
     525             : bool
     526      131346 : NBTypeCont::getEdgeTypeShallBeDiscarded(const std::string& type) const {
     527      131346 :     return getEdgeType(type)->discard;
     528             : }
     529             : 
     530             : double
     531        9636 : NBTypeCont::getEdgeTypeWidthResolution(const std::string& type) const {
     532        9636 :     return getEdgeType(type)->widthResolution;
     533             : }
     534             : 
     535             : double
     536        9636 : NBTypeCont::getEdgeTypeMaxWidth(const std::string& type) const {
     537        9636 :     return getEdgeType(type)->maxWidth;
     538             : }
     539             : 
     540             : double
     541        9009 : NBTypeCont::getEdgeTypeMinWidth(const std::string& type) const {
     542        9009 :     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      137734 : NBTypeCont::getEdgeTypePermissions(const std::string& type) const {
     553      137734 :     return getEdgeType(type)->permissions;
     554             : }
     555             : 
     556             : 
     557             : LaneSpreadFunction
     558       94125 : NBTypeCont::getEdgeTypeSpreadType(const std::string& type) const {
     559       94125 :     return getEdgeType(type)->spreadType;
     560             : }
     561             : 
     562             : 
     563             : double
     564      168545 : NBTypeCont::getEdgeTypeWidth(const std::string& type) const {
     565      168545 :     return getEdgeType(type)->width;
     566             : }
     567             : 
     568             : 
     569             : double
     570       66472 : NBTypeCont::getEdgeTypeSidewalkWidth(const std::string& type) const {
     571       66472 :     return getEdgeType(type)->sidewalkWidth;
     572             : }
     573             : 
     574             : 
     575             : double
     576       66292 : NBTypeCont::getEdgeTypeBikeLaneWidth(const std::string& type) const {
     577       66292 :     return getEdgeType(type)->bikeLaneWidth;
     578             : }
     579             : 
     580             : 
     581             : const NBTypeCont::EdgeTypeDefinition*
     582     1163927 : 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     1163927 :     if (i == myEdgeTypes.end()) {
     587      364332 :         return myDefaultType;
     588             :     } else {
     589      799595 :         return i->second;
     590             :     }
     591             : }
     592             : 
     593             : /****************************************************************************/

Generated by: LCOV version 1.14