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.org/sumo
3 // Copyright (C) 2001-2022 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 width, SVCPermissions permissions, const std::set<SumoXMLAttr>& attrs);
69 
71  LaneTypeDefinition(const LaneTypeDefinition* laneTypeDefinition);
72 
74  double speed;
75 
78 
80  double width;
81 
83  std::map<SUMOVehicleClass, double> restrictions;
84 
86  std::set<SumoXMLAttr> attrs;
87  };
88 
91 
94 
96  EdgeTypeDefinition(const EdgeTypeDefinition* edgeType);
97 
99  EdgeTypeDefinition(int numLanes, double speed, int priority,
101  bool oneWay, double sideWalkWidth, double bikeLaneWidth,
102  double widthResolution, double maxWidth, double minWidth);
103 
105  bool needsLaneType() const;
106 
108  double speed;
109 
111  int priority;
112 
115 
118 
120  bool oneWay;
121 
123  bool discard;
124 
126  double width;
127 
130 
132  double maxWidth;
133 
135  double minWidth;
136 
137  /* @brief The width of the sidewalk that should be added as an additional lane
138  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no sidewalk should be added */
140 
141  /* @brief The width of the bike lane that should be added as an additional lane
142  * a value of NBEdge::UNSPECIFIED_WIDTH indicates that no bike lane should be added */
144 
146  std::map<SUMOVehicleClass, double> restrictions;
147 
149  std::set<SumoXMLAttr> attrs;
150 
152  std::vector<LaneTypeDefinition> laneTypeDefinitions;
153  };
154 
156  typedef std::map<std::string, EdgeTypeDefinition*> TypesCont;
157 
159  NBTypeCont();
160 
162  ~NBTypeCont();
163 
165  void clearTypes();
166 
175  void setEdgeTypeDefaults(int defaultNumLanes, double defaultLaneWidth,
176  double defaultSpeed, int defaultPriority,
177  SVCPermissions defaultPermissions,
178  LaneSpreadFunction defaultSpreadType);
179 
191  void insertEdgeType(const std::string& id, int numLanes,
192  double maxSpeed, int prio,
193  SVCPermissions permissions,
194  LaneSpreadFunction spreadType,
195  double width,
196  bool oneWayIsDefault,
197  double sidewalkWidth,
198  double bikeLaneWidth,
199  double widthResolution,
200  double maxWidth,
201  double minWidth);
202 
207  void insertEdgeType(const std::string& id, const EdgeTypeDefinition* edgeType);
208 
216  void insertLaneType(const std::string& edgeTypeID,
217  int index,
218  double maxSpeed,
219  SVCPermissions permissions,
220  double width,
221  const std::set<SumoXMLAttr>& attrs);
222 
226  int size() const;
227 
232  void removeEdgeType(const std::string& id);
233 
238  void updateEdgeTypeID(const std::string& oldId, const std::string& newId);
239 
241  TypesCont::const_iterator begin() const;
242 
244  TypesCont::const_iterator end() const;
245 
249  bool knows(const std::string& edgeType) const;
250 
257  const EdgeTypeDefinition* getEdgeType(const std::string& name) const;
258 
259 
263  bool markEdgeTypeAsToDiscard(const std::string& id);
264 
269  bool markEdgeTypeAsSet(const std::string& id, const SumoXMLAttr attr);
270 
276  bool addEdgeTypeRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
277 
282  bool copyEdgeTypeRestrictionsAndAttrs(const std::string& fromId, const std::string& toId);
283 
288  bool markLaneTypeAsSet(const std::string& id, int index, const SumoXMLAttr attr);
289 
295  bool addLaneTypeRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
296 
298  void writeEdgeTypes(OutputDevice& into) const;
299 
302 
309  int getEdgeTypeNumLanes(const std::string& edgeType) const;
310 
317  double getEdgeTypeSpeed(const std::string& edgeType) const;
318 
325  int getEdgeTypePriority(const std::string& edgeType) const;
326 
334  bool getEdgeTypeIsOneWay(const std::string& edgeType) const;
335 
342  bool getEdgeTypeShallBeDiscarded(const std::string& edgeType) const;
343 
351  double getEdgeTypeWidthResolution(const std::string& edgeType) const;
352 
360  double getEdgeTypeMaxWidth(const std::string& edgeType) const;
361 
369  double getEdgeTypeMinWidth(const std::string& edgeType) const;
370 
376  bool wasSetEdgeTypeAttribute(const std::string& edgeType, const SumoXMLAttr attr) const;
377 
384  SVCPermissions getEdgeTypePermissions(const std::string& edgeType) const;
385 
392  LaneSpreadFunction getEdgeTypeSpreadType(const std::string& edgeType) const;
393 
400  double getEdgeTypeWidth(const std::string& edgeType) const;
401 
408  double getEdgeTypeSidewalkWidth(const std::string& edgeType) const;
409 
416  double getEdgeTypeBikeLaneWidth(const std::string& edgeType) const;
417 
419 
420 protected:
423 
426 
427 private:
429  NBTypeCont(const NBTypeCont& s) = delete;
430 
432  NBTypeCont& operator=(const NBTypeCont& s) = delete;
433 };
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
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:504
bool markEdgeTypeAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a edgeType as set.
Definition: NBTypeCont.cpp:308
void removeEdgeType(const std::string &id)
Remove a edgeType from the list.
Definition: NBTypeCont.cpp:249
std::map< std::string, EdgeTypeDefinition * > TypesCont
A container of edgeTypes, accessed by the string id.
Definition: NBTypeCont.h:156
NBTypeCont()
Constructor.
Definition: NBTypeCont.cpp:155
void setEdgeTypeDefaults(int defaultNumLanes, double defaultLaneWidth, double defaultSpeed, int defaultPriority, SVCPermissions defaultPermissions, LaneSpreadFunction defaultSpreadType)
Sets the default values.
Definition: NBTypeCont.cpp:177
bool addLaneTypeRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to last laneType.
Definition: NBTypeCont.cpp:354
~NBTypeCont()
Destructor.
Definition: NBTypeCont.cpp:159
void writeEdgeTypes(OutputDevice &into) const
writes all EdgeTypes (and their lanes) as XML
Definition: NBTypeCont.cpp:365
bool wasSetEdgeTypeAttribute(const std::string &edgeType, const SumoXMLAttr attr) const
Returns whether an attribute of a edgeType was set.
Definition: NBTypeCont.cpp:514
int size() const
Returns the number of known edgeTypes.
Definition: NBTypeCont.cpp:243
bool markEdgeTypeAsToDiscard(const std::string &id)
Marks a edgeType as to be discarded.
Definition: NBTypeCont.cpp:297
NBTypeCont & operator=(const NBTypeCont &s)=delete
invalid assignment operator
double getEdgeTypeMinWidth(const std::string &edgeType) const
Returns the minimum edge/lane widths of the given edgeType.
Definition: NBTypeCont.cpp:509
bool getEdgeTypeShallBeDiscarded(const std::string &edgeType) const
Returns the information whether edges of this edgeType shall be discarded.
Definition: NBTypeCont.cpp:494
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:194
bool copyEdgeTypeRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a edgeType.
Definition: NBTypeCont.cpp:330
double getEdgeTypeSpeed(const std::string &edgeType) const
Returns the maximal velocity for the given edgeType [m/s].
Definition: NBTypeCont.cpp:476
int getEdgeTypePriority(const std::string &edgeType) const
Returns the priority for the given edgeType.
Definition: NBTypeCont.cpp:482
TypesCont::const_iterator begin() const
return begin iterator
Definition: NBTypeCont.cpp:279
int getEdgeTypeNumLanes(const std::string &edgeType) const
Returns the number of lanes for the given edgeType.
Definition: NBTypeCont.cpp:470
double getEdgeTypeWidth(const std::string &edgeType) const
Returns the lane width for the given edgeType [m].
Definition: NBTypeCont.cpp:532
SVCPermissions getEdgeTypePermissions(const std::string &edgeType) const
Returns allowed vehicle classes for the given edgeType.
Definition: NBTypeCont.cpp:520
double getEdgeTypeWidthResolution(const std::string &edgeType) const
Returns the resolution for interpreting edge/lane widths of the given edgeType.
Definition: NBTypeCont.cpp:499
bool knows(const std::string &edgeType) const
Returns whether the named edgeType is in the container.
Definition: NBTypeCont.cpp:291
bool addEdgeTypeRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to a edgeType.
Definition: NBTypeCont.cpp:319
TypesCont::const_iterator end() const
return end iterator
Definition: NBTypeCont.cpp:285
double getEdgeTypeSidewalkWidth(const std::string &edgeType) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:538
LaneSpreadFunction getEdgeTypeSpreadType(const std::string &edgeType) const
Returns spreadType for the given edgeType.
Definition: NBTypeCont.cpp:526
double getEdgeTypeBikeLaneWidth(const std::string &edgeType) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:544
void clearTypes()
clear types
Definition: NBTypeCont.cpp:166
const EdgeTypeDefinition * getEdgeType(const std::string &name) const
Retrieve the name or the default edgeType.
Definition: NBTypeCont.cpp:550
bool getEdgeTypeIsOneWay(const std::string &edgeType) const
Returns whether edges are one-way per default for the given edgeType.
Definition: NBTypeCont.cpp:488
void updateEdgeTypeID(const std::string &oldId, const std::string &newId)
change edge type ID
Definition: NBTypeCont.cpp:262
TypesCont myEdgeTypes
The container of edgeTypes.
Definition: NBTypeCont.h:425
bool markLaneTypeAsSet(const std::string &id, int index, const SumoXMLAttr attr)
Marks an attribute of last laneType as set.
Definition: NBTypeCont.cpp:343
EdgeTypeDefinition * myDefaultType
The default edgeType.
Definition: NBTypeCont.h:422
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:231
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
edgeType definition
Definition: NBTypeCont.h:90
int priority
The priority of an edge.
Definition: NBTypeCont.h:111
double width
The width of lanes of edges of this edgeType [m].
Definition: NBTypeCont.h:126
double minWidth
The minimum width for lanes of this edgeType [m].
Definition: NBTypeCont.h:135
double speed
The maximal velocity on an edge in m/s.
Definition: NBTypeCont.h:108
LaneSpreadFunction spreadType
lane spread type
Definition: NBTypeCont.h:117
SVCPermissions permissions
List of vehicle edgeTypes that are allowed on this edge.
Definition: NBTypeCont.h:114
double maxWidth
The maximum width for lanes of this edgeType [m].
Definition: NBTypeCont.h:132
double widthResolution
The resolution for interpreting custom (noisy) lane widths of this edgeType [m].
Definition: NBTypeCont.h:129
bool oneWay
Whether one-way traffic is mostly common for this edgeType (mostly unused)
Definition: NBTypeCont.h:120
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:149
std::map< SUMOVehicleClass, double > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:146
bool needsLaneType() const
whether any lane attributes deviate from the edge attributes
Definition: NBTypeCont.cpp:132
std::vector< LaneTypeDefinition > laneTypeDefinitions
vector with LaneTypeDefinitions
Definition: NBTypeCont.h:152
bool discard
Whether edges of this edgeType shall be discarded.
Definition: NBTypeCont.h:123
laneType definition
Definition: NBTypeCont.h:59
std::map< SUMOVehicleClass, double > restrictions
The vehicle class specific speed restrictions.
Definition: NBTypeCont.h:83
double speed
The maximal velocity on a lane in m/s.
Definition: NBTypeCont.h:74
LaneTypeDefinition()
default Constructor
Definition: NBTypeCont.cpp:43
SVCPermissions permissions
List of vehicle edgeTypes that are allowed on this lane.
Definition: NBTypeCont.h:77
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition: NBTypeCont.h:86
double width
lane width [m]
Definition: NBTypeCont.h:80