Eclipse SUMO - Simulation of Urban MObility
ROLane.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 /****************************************************************************/
19 // A single lane the router may use
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
24 #include <vector>
26 #include <utils/common/Named.h>
28 
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class ROEdge;
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
48 class ROLane : public Named {
49 public:
57  ROLane(const std::string& id, ROEdge* edge, double length, double maxSpeed, SVCPermissions permissions, const PositionVector& shape) :
58  Named(id), myEdge(edge), myLength(length), myMaxSpeed(maxSpeed), myPermissions(permissions), myShape(shape),
59  myLengthGeometryFactor(MAX2(NUMERICAL_EPS, myShape.length() / myLength)) // factor should not be 0
60  { }
61 
62 
64  ~ROLane() { }
65 
66 
70  double getLength() const {
71  return myLength;
72  }
73 
74 
78  double getSpeed() const {
79  return myMaxSpeed;
80  }
81 
82 
86  inline SVCPermissions getPermissions() const {
87  return myPermissions;
88  }
89 
93  ROEdge& getEdge() const {
94  return *myEdge;
95  }
96 
98  const std::vector<std::pair<const ROLane*, const ROEdge*> >& getOutgoingViaLanes() const {
99  return myOutgoingLanes;
100  }
101 
102  void addOutgoingLane(ROLane* lane, ROEdge* via = nullptr) {
103  myOutgoingLanes.push_back(std::make_pair(lane, via));
104  }
105 
108  return LINKSTATE_MAJOR;
109  }
110 
111  inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
112  return (myPermissions & vclass) == vclass;
113  }
114 
115  const PositionVector& getShape() const {
116  return myShape;
117  }
118 
119  /* @brief fit the given lane position to a visibly suitable geometry position
120  * (lane length might differ from geometry length) */
121  inline double interpolateLanePosToGeometryPos(double lanePos) const {
122  return lanePos * myLengthGeometryFactor;
123  }
124 
125  /* @brief fit the given lane position to a visibly suitable geometry position
126  * and return the coordinates */
127  inline const Position geometryPositionAtOffset(double offset, double lateralOffset = 0) const {
128  return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
129  }
130 
131 private:
134 
136  double myLength;
137 
139  double myMaxSpeed;
140 
143 
144  std::vector<std::pair<const ROLane*, const ROEdge*> > myOutgoingLanes;
145 
148 
151 
152 
153 private:
155  ROLane(const ROLane& src);
156 
158  ROLane& operator=(const ROLane& src);
159 
160 };
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.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_MAJOR
This is an uncontrolled, major link, may pass.
T MAX2(T a, T b)
Definition: StdDefs.h:82
Base class for objects which have an id.
Definition: Named.h:54
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
A basic edge for routing applications.
Definition: ROEdge.h:70
A single lane the router may use.
Definition: ROLane.h:48
double myLength
The length of the lane.
Definition: ROLane.h:136
ROLane(const std::string &id, ROEdge *edge, double length, double maxSpeed, SVCPermissions permissions, const PositionVector &shape)
Constructor.
Definition: ROLane.h:57
ROEdge * myEdge
The parent edge of this lane.
Definition: ROLane.h:133
~ROLane()
Destructor.
Definition: ROLane.h:64
ROLane & operator=(const ROLane &src)
Invalidated assignment operator.
ROEdge & getEdge() const
Returns the lane's edge.
Definition: ROLane.h:93
double myMaxSpeed
The maximum speed allowed on the lane.
Definition: ROLane.h:139
const PositionVector & getShape() const
Definition: ROLane.h:115
double getLength() const
Returns the length of the lane.
Definition: ROLane.h:70
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: ROLane.h:111
SVCPermissions getPermissions() const
Returns the list of allowed vehicle classes.
Definition: ROLane.h:86
const PositionVector myShape
shape for this lane
Definition: ROLane.h:147
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: ROLane.h:127
const std::vector< std::pair< const ROLane *, const ROEdge * > > & getOutgoingViaLanes() const
get the map of outgoing lanes to via edges
Definition: ROLane.h:98
std::vector< std::pair< const ROLane *, const ROEdge * > > myOutgoingLanes
Definition: ROLane.h:144
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: ROLane.h:121
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: ROLane.h:150
void addOutgoingLane(ROLane *lane, ROEdge *via=nullptr)
Definition: ROLane.h:102
ROLane(const ROLane &src)
Invalidated copy constructor.
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane (ignored for routing)
Definition: ROLane.h:107
double getSpeed() const
Returns the maximum speed allowed on this lane.
Definition: ROLane.h:78
SVCPermissions myPermissions
The encoding of allowed vehicle classes.
Definition: ROLane.h:142