Eclipse SUMO - Simulation of Urban MObility
NBTypeCont.h
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 /****************************************************************************/
22 // A storage for available edgeTypes of edges
23 /****************************************************************************/
24 #pragma once
25 #include <config.h>
26 
27 #include <string>
28 #include <map>
30 #include <netbuild/NBEdge.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class OutputDevice;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
52 class NBTypeCont {
53 
54 public:
56  struct EdgeTypeDefinition;
57 
60 
63 
65  LaneTypeDefinition(const EdgeTypeDefinition* edgeTypeDefinition);
66 
68  LaneTypeDefinition(const double speed, const double friction, const double width, SVCPermissions permissions, const std::set<SumoXMLAttr>& attrs);
69 
71  LaneTypeDefinition(const LaneTypeDefinition* laneTypeDefinition);
72 
74  double speed;
75 
77  double friction;
78 
81 
83  double width;
84 
86  std::map<SUMOVehicleClass, double> restrictions;
87 
89  std::set<SumoXMLAttr> attrs;
90  };
91 
94 
97 
99  EdgeTypeDefinition(const EdgeTypeDefinition* edgeType);
100 
102  EdgeTypeDefinition(int numLanes, double speed, double friction, int priority,
104  bool oneWay, double sideWalkWidth, double bikeLaneWidth,
105  double widthResolution, double maxWidth, double minWidth);
106 
108  bool needsLaneType() const;
109 
111  double speed;
112 
114  double friction;
115 
117  int priority;
118 
121 
124 
126  bool oneWay;
127 
129  bool discard;
130 
132  double width;
133 
136 
138  double maxWidth;
139 
141  double minWidth;
142 
143  /* @brief The width of the sidewalk that should be added as an additional lane
144  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no sidewalk should be added */
146 
147  /* @brief The width of the bike lane that should be added as an additional lane
148  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no bike lane should be added */
150 
152  std::map<SUMOVehicleClass, double> restrictions;
153 
155  std::set<SumoXMLAttr> attrs;
156 
158  std::vector<LaneTypeDefinition> laneTypeDefinitions;
159  };
160 
162  typedef std::map<std::string, EdgeTypeDefinition*> TypesCont;
163 
165  NBTypeCont();
166 
168  ~NBTypeCont();
169 
171  void clearTypes();
172 
182  void setEdgeTypeDefaults(int defaultNumLanes, double defaultLaneWidth,
183  double defaultSpeed, double defaultFriction, int defaultPriority,
184  SVCPermissions defaultPermissions,
185  LaneSpreadFunction defaultSpreadType);
186 
198  void insertEdgeType(const std::string& id, int numLanes,
199  double maxSpeed, int prio,
200  SVCPermissions permissions,
201  LaneSpreadFunction spreadType,
202  double width,
203  bool oneWayIsDefault,
204  double sidewalkWidth,
205  double bikeLaneWidth,
206  double widthResolution,
207  double maxWidth,
208  double minWidth);
209 
214  void insertEdgeType(const std::string& id, const EdgeTypeDefinition* edgeType);
215 
223  void insertLaneType(const std::string& edgeTypeID,
224  int index,
225  double maxSpeed,
226  SVCPermissions permissions,
227  double width,
228  const std::set<SumoXMLAttr>& attrs);
229 
233  int size() const;
234 
239  void removeEdgeType(const std::string& id);
240 
245  void updateEdgeTypeID(const std::string& oldId, const std::string& newId);
246 
248  TypesCont::const_iterator begin() const;
249 
251  TypesCont::const_iterator end() const;
252 
256  bool knows(const std::string& edgeType) const;
257 
264  const EdgeTypeDefinition* getEdgeType(const std::string& name) const;
265 
266 
270  bool markEdgeTypeAsToDiscard(const std::string& id);
271 
276  bool markEdgeTypeAsSet(const std::string& id, const SumoXMLAttr attr);
277 
283  bool addEdgeTypeRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
284 
289  bool copyEdgeTypeRestrictionsAndAttrs(const std::string& fromId, const std::string& toId);
290 
295  bool markLaneTypeAsSet(const std::string& id, int index, const SumoXMLAttr attr);
296 
302  bool addLaneTypeRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
303 
305  void writeEdgeTypes(OutputDevice& into, const std::set<std::string>& typeIDs = std::set<std::string>()) const;
306 
309 
316  int getEdgeTypeNumLanes(const std::string& edgeType) const;
317 
324  double getEdgeTypeSpeed(const std::string& edgeType) const;
325 
332  double getEdgeTypeFriction(const std::string& edgeType) const;
333 
340  int getEdgeTypePriority(const std::string& edgeType) const;
341 
349  bool getEdgeTypeIsOneWay(const std::string& edgeType) const;
350 
357  bool getEdgeTypeShallBeDiscarded(const std::string& edgeType) const;
358 
366  double getEdgeTypeWidthResolution(const std::string& edgeType) const;
367 
375  double getEdgeTypeMaxWidth(const std::string& edgeType) const;
376 
384  double getEdgeTypeMinWidth(const std::string& edgeType) const;
385 
391  bool wasSetEdgeTypeAttribute(const std::string& edgeType, const SumoXMLAttr attr) const;
392 
399  SVCPermissions getEdgeTypePermissions(const std::string& edgeType) const;
400 
407  LaneSpreadFunction getEdgeTypeSpreadType(const std::string& edgeType) const;
408 
415  double getEdgeTypeWidth(const std::string& edgeType) const;
416 
423  double getEdgeTypeSidewalkWidth(const std::string& edgeType) const;
424 
431  double getEdgeTypeBikeLaneWidth(const std::string& edgeType) const;
432 
434 
435 protected:
438 
441 
442 private:
444  NBTypeCont(const NBTypeCont& s) = delete;
445 
447  NBTypeCont& operator=(const NBTypeCont& s) = delete;
448 };
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.
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A storage for available edgeTypes of edges.
Definition: NBTypeCont.h:52
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
std::map< std::string, EdgeTypeDefinition * > TypesCont
A container of edgeTypes, accessed by the string id.
Definition: NBTypeCont.h:162
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
NBTypeCont & operator=(const NBTypeCont &s)=delete
invalid assignment operator
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
NBTypeCont(const NBTypeCont &s)=delete
invalid copy constructor
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
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
std::map< SUMOVehicleClass, double > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:86
double speed
The maximal velocity on a lane in m/s.
Definition: NBTypeCont.h:74
double friction
The default friction on a lane.
Definition: NBTypeCont.h:77
LaneTypeDefinition()
default Constructor
Definition: NBTypeCont.cpp:43
SVCPermissions permissions
List of vehicle edgeTypes that are allowed on this lane.
Definition: NBTypeCont.h:80
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:89
double width
lane width [m]
Definition: NBTypeCont.h:83