Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2023 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// ===========================================================================
36class OutputDevice;
37
38
39// ===========================================================================
40// class definitions
41// ===========================================================================
53
54public:
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
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
118
121
124
126 bool oneWay;
127
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
435protected:
438
441
442private:
444 NBTypeCont(const NBTypeCont& s) = delete;
445
447 NBTypeCont& operator=(const NBTypeCont& s) = delete;
448};
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.
bool markEdgeTypeAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a edgeType as set.
void removeEdgeType(const std::string &id)
Remove a edgeType from the list.
std::map< std::string, EdgeTypeDefinition * > TypesCont
A container of edgeTypes, accessed by the string id.
Definition NBTypeCont.h:162
NBTypeCont()
Constructor.
bool addLaneTypeRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to last laneType.
~NBTypeCont()
Destructor.
bool wasSetEdgeTypeAttribute(const std::string &edgeType, const SumoXMLAttr attr) const
Returns whether an attribute of a edgeType was set.
int size() const
Returns the number of known edgeTypes.
bool markEdgeTypeAsToDiscard(const std::string &id)
Marks a edgeType as to be discarded.
double getEdgeTypeFriction(const std::string &edgeType) const
Returns the default friction for the given edgeType [-].
NBTypeCont & operator=(const NBTypeCont &s)=delete
invalid assignment operator
void writeEdgeTypes(OutputDevice &into, const std::set< std::string > &typeIDs=std::set< std::string >()) const
writes all EdgeTypes (and their lanes) as XML
double getEdgeTypeMinWidth(const std::string &edgeType) const
Returns the minimum edge/lane widths of the given edgeType.
bool getEdgeTypeShallBeDiscarded(const std::string &edgeType) const
Returns the information whether edges of this edgeType shall be discarded.
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.
bool copyEdgeTypeRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a edgeType.
double getEdgeTypeSpeed(const std::string &edgeType) const
Returns the maximal velocity for the given edgeType [m/s].
int getEdgeTypePriority(const std::string &edgeType) const
Returns the priority for the given edgeType.
TypesCont::const_iterator begin() const
return begin iterator
int getEdgeTypeNumLanes(const std::string &edgeType) const
Returns the number of lanes for the given edgeType.
double getEdgeTypeWidth(const std::string &edgeType) const
Returns the lane width for the given edgeType [m].
SVCPermissions getEdgeTypePermissions(const std::string &edgeType) const
Returns allowed vehicle classes for the given edgeType.
double getEdgeTypeWidthResolution(const std::string &edgeType) const
Returns the resolution for interpreting edge/lane widths of the given edgeType.
bool knows(const std::string &edgeType) const
Returns whether the named edgeType is in the container.
bool addEdgeTypeRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction to a edgeType.
TypesCont::const_iterator end() const
return end iterator
double getEdgeTypeSidewalkWidth(const std::string &edgeType) const
Returns the lane width for a sidewalk to be added [m].
LaneSpreadFunction getEdgeTypeSpreadType(const std::string &edgeType) const
Returns spreadType for the given edgeType.
double getEdgeTypeBikeLaneWidth(const std::string &edgeType) const
Returns the lane width for a bike lane to be added [m].
void clearTypes()
clear types
const EdgeTypeDefinition * getEdgeType(const std::string &name) const
Retrieve the name or the default edgeType.
bool getEdgeTypeIsOneWay(const std::string &edgeType) const
Returns whether edges are one-way per default for the given edgeType.
void updateEdgeTypeID(const std::string &oldId, const std::string &newId)
change edge type ID
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.
bool markLaneTypeAsSet(const std::string &id, int index, const SumoXMLAttr attr)
Marks an attribute of last laneType as set.
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.
Static storage of an output device and its base (abstract) implementation.
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
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
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