Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2026 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// ===========================================================================
33class ROEdge;
34
35
36// ===========================================================================
37// class definitions
38// ===========================================================================
48class ROLane : public Named {
49public:
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
87 return myPermissions;
88 }
89
90 void setPermissions(SVCPermissions permissions) {
91 myPermissions = permissions;
92 }
93
97 ROEdge& getEdge() const {
98 return *myEdge;
99 }
100
102 const std::vector<std::pair<const ROLane*, const ROEdge*> >& getOutgoingViaLanes() const {
103 return myOutgoingLanes;
104 }
105
106 void addOutgoingLane(ROLane* lane, ROEdge* via = nullptr) {
107 myOutgoingLanes.push_back(std::make_pair(lane, via));
108 }
109
112 return LINKSTATE_MAJOR;
113 }
114
115 inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
116 return (myPermissions & vclass) == vclass;
117 }
118
119 const PositionVector& getShape() const {
120 return myShape;
121 }
122
123 /* @brief fit the given lane position to a visibly suitable geometry position
124 * (lane length might differ from geometry length) */
125 inline double interpolateLanePosToGeometryPos(double lanePos) const {
126 return lanePos * myLengthGeometryFactor;
127 }
128
129 /* @brief fit the given lane position to a visibly suitable geometry position
130 * and return the coordinates */
131 inline const Position geometryPositionAtOffset(double offset, double lateralOffset = 0) const {
132 return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
133 }
134
135private:
138
140 double myLength;
141
144
147
148 std::vector<std::pair<const ROLane*, const ROEdge*> > myOutgoingLanes;
149
152
155
156
157private:
159 ROLane(const ROLane& src);
160
162 ROLane& operator=(const ROLane& src);
163
164};
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:86
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:73
A single lane the router may use.
Definition ROLane.h:48
const std::vector< std::pair< const ROLane *, const ROEdge * > > & getOutgoingViaLanes() const
get the map of outgoing lanes to via edges
Definition ROLane.h:102
double myLength
The length of the lane.
Definition ROLane.h:140
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:137
const PositionVector & getShape() const
Definition ROLane.h:119
~ROLane()
Destructor.
Definition ROLane.h:64
double myMaxSpeed
The maximum speed allowed on the lane.
Definition ROLane.h:143
ROLane & operator=(const ROLane &src)
Invalidated assignment operator.
double getLength() const
Returns the length of the lane.
Definition ROLane.h:70
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition ROLane.h:115
SVCPermissions getPermissions() const
Returns the list of allowed vehicle classes.
Definition ROLane.h:86
const PositionVector myShape
shape for this lane
Definition ROLane.h:151
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition ROLane.h:131
void setPermissions(SVCPermissions permissions)
Definition ROLane.h:90
std::vector< std::pair< const ROLane *, const ROEdge * > > myOutgoingLanes
Definition ROLane.h:148
double interpolateLanePosToGeometryPos(double lanePos) const
Definition ROLane.h:125
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition ROLane.h:154
void addOutgoingLane(ROLane *lane, ROEdge *via=nullptr)
Definition ROLane.h:106
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:111
double getSpeed() const
Returns the maximum speed allowed on this lane.
Definition ROLane.h:78
ROEdge & getEdge() const
Returns the lane's edge.
Definition ROLane.h:97
SVCPermissions myPermissions
The encoding of allowed vehicle classes.
Definition ROLane.h:146