Eclipse SUMO - Simulation of Urban MObility
NBTypeCont.cpp
Go to the documentation of this file.
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 /****************************************************************************/
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>
29 #include <utils/common/ToString.h>
31 
32 #include "NBTypeCont.h"
33 
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
38 
39 // ---------------------------------------------------------------------------
40 // NBTypeCont::EdgeTypeDefinition - methods
41 // ---------------------------------------------------------------------------
42 
44  speed(NBEdge::UNSPECIFIED_SPEED),
45  friction(NBEdge::UNSPECIFIED_FRICTION),
46  permissions(SVC_UNSPECIFIED),
47  width(NBEdge::UNSPECIFIED_WIDTH) {
48 }
49 
50 
52  speed(edgeTypeDefinition->speed),
53  friction(edgeTypeDefinition->friction),
54  permissions(edgeTypeDefinition->permissions),
55  width(edgeTypeDefinition->width) {
56 }
57 
58 
59 NBTypeCont::LaneTypeDefinition::LaneTypeDefinition(const double _speed, const double _friction, const double _width, SVCPermissions _permissions, const std::set<SumoXMLAttr>& _attrs) :
60  speed(_speed),
61  friction(_friction),
62  permissions(_permissions),
63  width(_width),
64  attrs(_attrs) {
65 }
66 
67 
69  speed(laneTypeDefinition->speed),
70  friction(laneTypeDefinition->friction),
71  permissions(laneTypeDefinition->permissions),
72  width(laneTypeDefinition->width),
73  restrictions(laneTypeDefinition->restrictions),
74  attrs(laneTypeDefinition->attrs) {
75 }
76 
77 // ---------------------------------------------------------------------------
78 // NBTypeCont::EdgeTypeDefinition - methods
79 // ---------------------------------------------------------------------------
80 
82  speed(13.89), friction(NBEdge::UNSPECIFIED_FRICTION), priority(-1),
83  permissions(SVC_UNSPECIFIED),
84  spreadType(LaneSpreadFunction::RIGHT),
85  oneWay(true), discard(false),
86  width(NBEdge::UNSPECIFIED_WIDTH),
87  widthResolution(0),
88  maxWidth(0),
89  minWidth(0),
90  sidewalkWidth(NBEdge::UNSPECIFIED_WIDTH),
91  bikeLaneWidth(NBEdge::UNSPECIFIED_WIDTH) {
92  // set laneTypes
93  laneTypeDefinitions.resize(1);
94 }
95 
96 
98  speed(edgeType->speed),
99  friction(edgeType->friction),
100  priority(edgeType->priority),
101  permissions(edgeType->permissions),
102  spreadType(edgeType->spreadType),
103  oneWay(edgeType->oneWay),
104  discard(edgeType->discard),
105  width(edgeType->width),
106  widthResolution(edgeType->widthResolution),
107  maxWidth(edgeType->maxWidth),
108  minWidth(edgeType->minWidth),
109  sidewalkWidth(edgeType->sidewalkWidth),
110  bikeLaneWidth(edgeType->bikeLaneWidth),
111  restrictions(edgeType->restrictions),
112  attrs(edgeType->attrs),
113  laneTypeDefinitions(edgeType->laneTypeDefinitions) {
114 }
115 
116 
117 NBTypeCont::EdgeTypeDefinition::EdgeTypeDefinition(int numLanes, double _speed, double _friction, int _priority,
118  double _width, SVCPermissions _permissions, LaneSpreadFunction _spreadType, bool _oneWay, double _sideWalkWidth,
119  double _bikeLaneWidth, double _widthResolution, double _maxWidth, double _minWidth) :
120  speed(_speed), friction(_friction), priority(_priority), //TODO
121  permissions(_permissions),
122  spreadType(_spreadType),
123  oneWay(_oneWay),
124  discard(false),
125  width(_width),
126  widthResolution(_widthResolution),
127  maxWidth(_maxWidth),
128  minWidth(_minWidth),
129  sidewalkWidth(_sideWalkWidth),
130  bikeLaneWidth(_bikeLaneWidth) {
131  // set laneTypes
132  laneTypeDefinitions.resize(numLanes);
133 }
134 
135 
136 bool
138  for (const LaneTypeDefinition& laneType : laneTypeDefinitions) {
139  if (laneType.attrs.count(SUMO_ATTR_SPEED) > 0 && laneType.speed != NBEdge::UNSPECIFIED_SPEED && laneType.speed != speed) {
140  return true;
141  }
142  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  && laneType.permissions != permissions) {
147  return true;
148  }
149  if (laneType.attrs.count(SUMO_ATTR_WIDTH) > 0 && laneType.width != width && laneType.width != NBEdge::UNSPECIFIED_WIDTH) {
150  return true;
151  }
152  if (laneType.restrictions.size() > 0) {
153  return true;
154  }
155  }
156  return false;
157 }
158 
159 // ---------------------------------------------------------------------------
160 // NBTypeCont - methods
161 // ---------------------------------------------------------------------------
162 
165 
166 
168  clearTypes();
169  delete myDefaultType;
170 }
171 
172 
173 void
175  // remove edge types
176  for (const auto& edgeType : myEdgeTypes) {
177  delete edgeType.second;
178  }
179  // clear edge types
180  myEdgeTypes.clear();
181 }
182 
183 
184 void
186  double defaultLaneWidth,
187  double defaultSpeed,
188  double defaultFriction,
189  int defaultPriority,
190  SVCPermissions defaultPermissions,
191  LaneSpreadFunction defaultSpreadType) {
193  myDefaultType->laneTypeDefinitions.resize(defaultNumLanes);
194  myDefaultType->width = defaultLaneWidth;
195  myDefaultType->speed = defaultSpeed;
196  myDefaultType->friction = defaultFriction;
197  myDefaultType->priority = defaultPriority;
198  myDefaultType->permissions = defaultPermissions;
199  myDefaultType->spreadType = defaultSpreadType;
200 }
201 
202 
203 void
204 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  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  if (old != myEdgeTypes.end()) {
216  newType->restrictions.insert(old->second->restrictions.begin(), old->second->restrictions.end());
217  newType->attrs.insert(old->second->attrs.begin(), old->second->attrs.end());
218  delete old->second;
219  }
220  // insert it in types
221  myEdgeTypes[id] = newType;
222 }
223 
224 
225 void
226 NBTypeCont::insertEdgeType(const std::string& id, const EdgeTypeDefinition* edgeType) {
227  // Create edge type definition
228  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  if (old != myEdgeTypes.end()) {
233  newType->restrictions.insert(old->second->restrictions.begin(), old->second->restrictions.end());
234  newType->attrs.insert(old->second->attrs.begin(), old->second->attrs.end());
235  delete old->second;
236  }
237  // insert it in types
238  myEdgeTypes[id] = newType;
239 }
240 
241 
242 void
243 NBTypeCont::insertLaneType(const std::string& edgeTypeID, int index, double maxSpeed, SVCPermissions permissions,
244  double width, const std::set<SumoXMLAttr>& attrs) {
245  EdgeTypeDefinition* et = myEdgeTypes.at(edgeTypeID);
246  while ((int)et->laneTypeDefinitions.size() <= index) {
247  et->laneTypeDefinitions.push_back(et);
248  }
249  // add LaneTypeDefinition with the given attributes
250  et->laneTypeDefinitions[index] = LaneTypeDefinition(maxSpeed, NBEdge::UNSPECIFIED_FRICTION, width, permissions, attrs);
251 }
252 
253 
254 int
256  return (int)myEdgeTypes.size();
257 }
258 
259 
260 void
261 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  if (it != myEdgeTypes.end()) {
266  // remove it from map
267  delete it->second;
268  myEdgeTypes.erase(it);
269  }
270 }
271 
272 
273 void
274 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  if ((oldIt != myEdgeTypes.end()) && (newIt == myEdgeTypes.end())) {
280  // obtain pointer
281  auto edgeType = oldIt->second;
282  // remove it from map
283  myEdgeTypes.erase(oldIt);
284  // add it again
285  myEdgeTypes[newId] = edgeType;
286  }
287 }
288 
289 
290 NBTypeCont::TypesCont::const_iterator
292  return myEdgeTypes.cbegin();
293 }
294 
295 
296 NBTypeCont::TypesCont::const_iterator
298  return myEdgeTypes.cend();
299 }
300 
301 
302 bool
303 NBTypeCont::knows(const std::string& type) const {
304  return myEdgeTypes.find(type) != myEdgeTypes.end();
305 }
306 
307 
308 bool
309 NBTypeCont::markEdgeTypeAsToDiscard(const std::string& id) {
310  TypesCont::iterator i = myEdgeTypes.find(id);
311  if (i == myEdgeTypes.end()) {
312  return false;
313  }
314  i->second->discard = true;
315  return true;
316 }
317 
318 
319 bool
320 NBTypeCont::markEdgeTypeAsSet(const std::string& id, const SumoXMLAttr attr) {
321  TypesCont::iterator i = myEdgeTypes.find(id);
322  if (i == myEdgeTypes.end()) {
323  return false;
324  }
325  i->second->attrs.insert(attr);
326  return true;
327 }
328 
329 
330 bool
331 NBTypeCont::addEdgeTypeRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
332  TypesCont::iterator i = myEdgeTypes.find(id);
333  if (i == myEdgeTypes.end()) {
334  return false;
335  }
336  i->second->restrictions[svc] = speed;
337  return true;
338 }
339 
340 
341 bool
342 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  if (from == myEdgeTypes.end() || to == myEdgeTypes.end()) {
346  return false;
347  }
348  to->second->restrictions.insert(from->second->restrictions.begin(), from->second->restrictions.end());
349  to->second->attrs.insert(from->second->attrs.begin(), from->second->attrs.end());
350  return true;
351 }
352 
353 
354 bool
355 NBTypeCont::markLaneTypeAsSet(const std::string& id, int index, const SumoXMLAttr attr) {
356  TypesCont::iterator i = myEdgeTypes.find(id);
357  if (i == myEdgeTypes.end()) {
358  return false;
359  }
360  i->second->laneTypeDefinitions[index].attrs.insert(attr);
361  return true;
362 }
363 
364 
365 bool
366 NBTypeCont::addLaneTypeRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
367  TypesCont::iterator i = myEdgeTypes.find(id);
368  if (i == myEdgeTypes.end()) {
369  return false;
370  }
371  i->second->laneTypeDefinitions.back().restrictions[svc] = speed;
372  return true;
373 }
374 
375 
376 void
377 NBTypeCont::writeEdgeTypes(OutputDevice& into, const std::set<std::string>& typeIDs) const {
378  // iterate over edge types
379  for (const auto& edgeType : myEdgeTypes) {
380  if (typeIDs.size() > 0 && typeIDs.count(edgeType.first) == 0) {
381  continue;
382  }
383  // open edge type tag
384  into.openTag(SUMO_TAG_TYPE);
385  // write ID
386  into.writeAttr(SUMO_ATTR_ID, edgeType.first);
387  // write priority
388  if (edgeType.second->attrs.count(SUMO_ATTR_PRIORITY) > 0) {
389  into.writeAttr(SUMO_ATTR_PRIORITY, edgeType.second->priority);
390  }
391  // write numLanes
392  if (edgeType.second->attrs.count(SUMO_ATTR_NUMLANES) > 0 || edgeType.second->laneTypeDefinitions.size() > 1) {
393  into.writeAttr(SUMO_ATTR_NUMLANES, edgeType.second->laneTypeDefinitions.size());
394  }
395  // write speed
396  if (edgeType.second->attrs.count(SUMO_ATTR_SPEED) > 0) {
397  into.writeAttr(SUMO_ATTR_SPEED, edgeType.second->speed);
398  }
399  // write friction
400  if (edgeType.second->attrs.count(SUMO_ATTR_FRICTION) > 0) {
401  // only write if its not the default value
402  if (edgeType.second->friction != NBEdge::UNSPECIFIED_FRICTION) {
403  into.writeAttr(SUMO_ATTR_FRICTION, edgeType.second->friction);
404  }
405  }
406  // write permissions
407  if ((edgeType.second->attrs.count(SUMO_ATTR_DISALLOW) > 0) || (edgeType.second->attrs.count(SUMO_ATTR_ALLOW) > 0)) {
408  writePermissions(into, edgeType.second->permissions);
409  }
410  // write spreadType (unless default)
411  if ((edgeType.second->attrs.count(SUMO_ATTR_SPREADTYPE) > 0) && edgeType.second->spreadType != LaneSpreadFunction::RIGHT) {
412  into.writeAttr(SUMO_ATTR_SPREADTYPE, SUMOXMLDefinitions::LaneSpreadFunctions.getString(edgeType.second->spreadType));
413  }
414  // write oneWay
415  if (edgeType.second->attrs.count(SUMO_ATTR_ONEWAY) > 0) {
416  into.writeAttr(SUMO_ATTR_ONEWAY, edgeType.second->oneWay);
417  }
418  // write discard
419  if (edgeType.second->attrs.count(SUMO_ATTR_DISCARD) > 0) {
420  into.writeAttr(SUMO_ATTR_DISCARD, edgeType.second->discard);
421  }
422  // write width
423  if (edgeType.second->attrs.count(SUMO_ATTR_WIDTH) > 0) {
424  into.writeAttr(SUMO_ATTR_WIDTH, edgeType.second->width);
425  }
426  // write sidewalkwidth
427  if (edgeType.second->attrs.count(SUMO_ATTR_SIDEWALKWIDTH) > 0) {
428  into.writeAttr(SUMO_ATTR_SIDEWALKWIDTH, edgeType.second->sidewalkWidth);
429  }
430  // write bikelanewidth
431  if (edgeType.second->attrs.count(SUMO_ATTR_BIKELANEWIDTH) > 0) {
432  into.writeAttr(SUMO_ATTR_BIKELANEWIDTH, edgeType.second->bikeLaneWidth);
433  }
434  // write restrictions
435  for (const auto& restriction : edgeType.second->restrictions) {
436  // open restriction tag
438  // write vclass
439  into.writeAttr(SUMO_ATTR_VCLASS, getVehicleClassNames(restriction.first));
440  // write speed
441  into.writeAttr(SUMO_ATTR_SPEED, restriction.second);
442  // close restriction tag
443  into.closeTag();
444  }
445  // iterate over lanes
446  if (edgeType.second->needsLaneType()) {
447  int index = 0;
448  for (const auto& laneType : edgeType.second->laneTypeDefinitions) {
449  // open lane type taG
451  into.writeAttr(SUMO_ATTR_INDEX, index++);
452  // write speed
453  if (laneType.attrs.count(SUMO_ATTR_SPEED) > 0 && laneType.speed != NBEdge::UNSPECIFIED_SPEED
454  && laneType.speed != edgeType.second->speed) {
455  into.writeAttr(SUMO_ATTR_SPEED, laneType.speed);
456  }
457  // write friction
458  if (laneType.attrs.count(SUMO_ATTR_FRICTION) > 0 && laneType.friction != NBEdge::UNSPECIFIED_FRICTION
459  && laneType.friction != edgeType.second->friction) {
460  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  writePermissions(into, laneType.permissions);
465  }
466  // write width
467  if (laneType.attrs.count(SUMO_ATTR_WIDTH) > 0 && laneType.width != edgeType.second->width
468  && laneType.width != NBEdge::UNSPECIFIED_WIDTH) {
469  into.writeAttr(SUMO_ATTR_WIDTH, laneType.width);
470  }
471  // write restrictions
472  for (const auto& restriction : laneType.restrictions) {
473  // open restriction tag
475  // write vclass
476  into.writeAttr(SUMO_ATTR_VCLASS, getVehicleClassNames(restriction.first));
477  // write speed
478  into.writeAttr(SUMO_ATTR_SPEED, restriction.second);
479  // close restriction tag
480  into.closeTag();
481  }
482  // close lane type tag
483  into.closeTag();
484  }
485  }
486  // close edge type tag
487  into.closeTag();
488  }
489  //write endlype
490  if (!myEdgeTypes.empty()) {
491  into.lf();
492  }
493 }
494 
495 
496 int
497 NBTypeCont::getEdgeTypeNumLanes(const std::string& type) const {
498  return (int)getEdgeType(type)->laneTypeDefinitions.size();
499 }
500 
501 
502 double
503 NBTypeCont::getEdgeTypeSpeed(const std::string& type) const {
504  return getEdgeType(type)->speed;
505 }
506 
507 double
508 NBTypeCont::getEdgeTypeFriction(const std::string& type) const {
509  return getEdgeType(type)->friction;
510 }
511 
512 
513 int
514 NBTypeCont::getEdgeTypePriority(const std::string& type) const {
515  return getEdgeType(type)->priority;
516 }
517 
518 
519 bool
520 NBTypeCont::getEdgeTypeIsOneWay(const std::string& type) const {
521  return getEdgeType(type)->oneWay;
522 }
523 
524 
525 bool
526 NBTypeCont::getEdgeTypeShallBeDiscarded(const std::string& type) const {
527  return getEdgeType(type)->discard;
528 }
529 
530 double
531 NBTypeCont::getEdgeTypeWidthResolution(const std::string& type) const {
532  return getEdgeType(type)->widthResolution;
533 }
534 
535 double
536 NBTypeCont::getEdgeTypeMaxWidth(const std::string& type) const {
537  return getEdgeType(type)->maxWidth;
538 }
539 
540 double
541 NBTypeCont::getEdgeTypeMinWidth(const std::string& type) const {
542  return getEdgeType(type)->minWidth;
543 }
544 
545 bool
546 NBTypeCont::wasSetEdgeTypeAttribute(const std::string& type, const SumoXMLAttr attr) const {
547  return getEdgeType(type)->attrs.count(attr) > 0;
548 }
549 
550 
552 NBTypeCont::getEdgeTypePermissions(const std::string& type) const {
553  return getEdgeType(type)->permissions;
554 }
555 
556 
558 NBTypeCont::getEdgeTypeSpreadType(const std::string& type) const {
559  return getEdgeType(type)->spreadType;
560 }
561 
562 
563 double
564 NBTypeCont::getEdgeTypeWidth(const std::string& type) const {
565  return getEdgeType(type)->width;
566 }
567 
568 
569 double
570 NBTypeCont::getEdgeTypeSidewalkWidth(const std::string& type) const {
571  return getEdgeType(type)->sidewalkWidth;
572 }
573 
574 
575 double
576 NBTypeCont::getEdgeTypeBikeLaneWidth(const std::string& type) const {
577  return getEdgeType(type)->bikeLaneWidth;
578 }
579 
580 
582 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  if (i == myEdgeTypes.end()) {
587  return myDefaultType;
588  } else {
589  return i->second;
590  }
591 }
592 
593 /****************************************************************************/
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
void writePermissions(OutputDevice &into, SVCPermissions permissions)
writes allowed disallowed attributes if needed;
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ RIGHT
At the rightmost side of the lane.
@ SUMO_TAG_RESTRICTION
begin/end of the description of an edge restriction
@ SUMO_TAG_LANETYPE
lane type
@ SUMO_TAG_TYPE
type (edge)
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_ONEWAY
@ SUMO_ATTR_PRIORITY
@ SUMO_ATTR_NUMLANES
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_SPREADTYPE
The information about how to spread the lanes from the given position.
@ SUMO_ATTR_BIKELANEWIDTH
@ SUMO_ATTR_VCLASS
@ SUMO_ATTR_SIDEWALKWIDTH
@ SUMO_ATTR_ID
@ SUMO_ATTR_DISCARD
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_FRICTION
The representation of a single edge during network building.
Definition: NBEdge.h:92
static const double UNSPECIFIED_FRICTION
unspecified lane friction
Definition: NBEdge.h:351
static const double UNSPECIFIED_SPEED
unspecified lane speed
Definition: NBEdge.h:348
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:342
double getEdgeTypeMaxWidth(const std::string &edgeType) const
Returns the maximum edge/lane widths of the given edgeType.
Definition: NBTypeCont.cpp:536
bool markEdgeTypeAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a edgeType as set.
Definition: NBTypeCont.cpp:320
void removeEdgeType(const std::string &id)
Remove a edgeType from the list.
Definition: NBTypeCont.cpp:261
NBTypeCont()
Constructor.
Definition: NBTypeCont.cpp:163
bool addLaneTypeRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to last laneType.
Definition: NBTypeCont.cpp:366
~NBTypeCont()
Destructor.
Definition: NBTypeCont.cpp:167
bool wasSetEdgeTypeAttribute(const std::string &edgeType, const SumoXMLAttr attr) const
Returns whether an attribute of a edgeType was set.
Definition: NBTypeCont.cpp:546
int size() const
Returns the number of known edgeTypes.
Definition: NBTypeCont.cpp:255
bool markEdgeTypeAsToDiscard(const std::string &id)
Marks a edgeType as to be discarded.
Definition: NBTypeCont.cpp:309
double getEdgeTypeFriction(const std::string &edgeType) const
Returns the default friction for the given edgeType [-].
Definition: NBTypeCont.cpp:508
void writeEdgeTypes(OutputDevice &into, const std::set< std::string > &typeIDs=std::set< std::string >()) const
writes all EdgeTypes (and their lanes) as XML
Definition: NBTypeCont.cpp:377
double getEdgeTypeMinWidth(const std::string &edgeType) const
Returns the minimum edge/lane widths of the given edgeType.
Definition: NBTypeCont.cpp:541
bool getEdgeTypeShallBeDiscarded(const std::string &edgeType) const
Returns the information whether edges of this edgeType shall be discarded.
Definition: NBTypeCont.cpp:526
void insertEdgeType(const std::string &id, int numLanes, double maxSpeed, int prio, SVCPermissions permissions, LaneSpreadFunction spreadType, double width, bool oneWayIsDefault, double sidewalkWidth, double bikeLaneWidth, double widthResolution, double maxWidth, double minWidth)
Adds a edgeType into the list.
Definition: NBTypeCont.cpp:204
bool copyEdgeTypeRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a edgeType.
Definition: NBTypeCont.cpp:342
double getEdgeTypeSpeed(const std::string &edgeType) const
Returns the maximal velocity for the given edgeType [m/s].
Definition: NBTypeCont.cpp:503
int getEdgeTypePriority(const std::string &edgeType) const
Returns the priority for the given edgeType.
Definition: NBTypeCont.cpp:514
TypesCont::const_iterator begin() const
return begin iterator
Definition: NBTypeCont.cpp:291
int getEdgeTypeNumLanes(const std::string &edgeType) const
Returns the number of lanes for the given edgeType.
Definition: NBTypeCont.cpp:497
double getEdgeTypeWidth(const std::string &edgeType) const
Returns the lane width for the given edgeType [m].
Definition: NBTypeCont.cpp:564
SVCPermissions getEdgeTypePermissions(const std::string &edgeType) const
Returns allowed vehicle classes for the given edgeType.
Definition: NBTypeCont.cpp:552
double getEdgeTypeWidthResolution(const std::string &edgeType) const
Returns the resolution for interpreting edge/lane widths of the given edgeType.
Definition: NBTypeCont.cpp:531
bool knows(const std::string &edgeType) const
Returns whether the named edgeType is in the container.
Definition: NBTypeCont.cpp:303
bool addEdgeTypeRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to a edgeType.
Definition: NBTypeCont.cpp:331
TypesCont::const_iterator end() const
return end iterator
Definition: NBTypeCont.cpp:297
double getEdgeTypeSidewalkWidth(const std::string &edgeType) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:570
LaneSpreadFunction getEdgeTypeSpreadType(const std::string &edgeType) const
Returns spreadType for the given edgeType.
Definition: NBTypeCont.cpp:558
double getEdgeTypeBikeLaneWidth(const std::string &edgeType) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:576
void clearTypes()
clear types
Definition: NBTypeCont.cpp:174
const EdgeTypeDefinition * getEdgeType(const std::string &name) const
Retrieve the name or the default edgeType.
Definition: NBTypeCont.cpp:582
bool getEdgeTypeIsOneWay(const std::string &edgeType) const
Returns whether edges are one-way per default for the given edgeType.
Definition: NBTypeCont.cpp:520
void updateEdgeTypeID(const std::string &oldId, const std::string &newId)
change edge type ID
Definition: NBTypeCont.cpp:274
TypesCont myEdgeTypes
The container of edgeTypes.
Definition: NBTypeCont.h:440
void setEdgeTypeDefaults(int defaultNumLanes, double defaultLaneWidth, double defaultSpeed, double defaultFriction, int defaultPriority, SVCPermissions defaultPermissions, LaneSpreadFunction defaultSpreadType)
Sets the default values.
Definition: NBTypeCont.cpp:185
bool markLaneTypeAsSet(const std::string &id, int index, const SumoXMLAttr attr)
Marks an attribute of last laneType as set.
Definition: NBTypeCont.cpp:355
EdgeTypeDefinition * myDefaultType
The default edgeType.
Definition: NBTypeCont.h:437
void insertLaneType(const std::string &edgeTypeID, int index, double maxSpeed, SVCPermissions permissions, double width, const std::set< SumoXMLAttr > &attrs)
Adds a laneType into the list.
Definition: NBTypeCont.cpp:243
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
void lf()
writes a line feed if applicable
Definition: OutputDevice.h:242
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
lane spread functions
edgeType definition
Definition: NBTypeCont.h:93
int priority
The priority of an edge.
Definition: NBTypeCont.h:117
double width
The width of lanes of edges of this edgeType [m].
Definition: NBTypeCont.h:132
double minWidth
The minimum width for lanes of this edgeType [m].
Definition: NBTypeCont.h:141
double speed
The maximal velocity on an edge in m/s.
Definition: NBTypeCont.h:111
LaneSpreadFunction spreadType
lane spread type
Definition: NBTypeCont.h:123
SVCPermissions permissions
List of vehicle edgeTypes that are allowed on this edge.
Definition: NBTypeCont.h:120
double maxWidth
The maximum width for lanes of this edgeType [m].
Definition: NBTypeCont.h:138
double widthResolution
The resolution for interpreting custom (noisy) lane widths of this edgeType [m].
Definition: NBTypeCont.h:135
bool oneWay
Whether one-way traffic is mostly common for this edgeType (mostly unused)
Definition: NBTypeCont.h:126
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:155
double friction
The default friction on an edge.
Definition: NBTypeCont.h:114
std::map< SUMOVehicleClass, double > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:152
bool needsLaneType() const
whether any lane attributes deviate from the edge attributes
Definition: NBTypeCont.cpp:137
std::vector< LaneTypeDefinition > laneTypeDefinitions
vector with LaneTypeDefinitions
Definition: NBTypeCont.h:158
bool discard
Whether edges of this edgeType shall be discarded.
Definition: NBTypeCont.h:129
laneType definition
Definition: NBTypeCont.h:59
LaneTypeDefinition()
default Constructor
Definition: NBTypeCont.cpp:43