Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/router/ROLane.h
193863 views
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
/****************************************************************************/
14
/// @file ROLane.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @date Sept 2002
18
///
19
// A single lane the router may use
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#include <vector>
25
#include <utils/geom/PositionVector.h>
26
#include <utils/common/Named.h>
27
#include <utils/common/SUMOVehicleClass.h>
28
29
30
// ===========================================================================
31
// class declarations
32
// ===========================================================================
33
class ROEdge;
34
35
36
// ===========================================================================
37
// class definitions
38
// ===========================================================================
39
/**
40
* @class ROLane
41
* @brief A single lane the router may use
42
*
43
* Currently, the lane has no other purpose then storing the allowed vehicle
44
* classes. They are even only stored herein and used by computing the vehicle
45
* classes allowed on the according edge.
46
* @see ROEdge
47
*/
48
class ROLane : public Named {
49
public:
50
/** @brief Constructor
51
*
52
* @param[in] id The id of the lane
53
* @param[in] length The length of the lane
54
* @param[in] maxSpeed The maximum speed allowed on the lane
55
* @param[in] permissions Vehicle classes that may pass this lane
56
*/
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
63
/// @brief Destructor
64
~ROLane() { }
65
66
67
/** @brief Returns the length of the lane
68
* @return The length of this lane
69
*/
70
double getLength() const {
71
return myLength;
72
}
73
74
75
/** @brief Returns the maximum speed allowed on this lane
76
* @return The maximum speed allowed on this lane
77
*/
78
double getSpeed() const {
79
return myMaxSpeed;
80
}
81
82
83
/** @brief Returns the list of allowed vehicle classes
84
* @return The list of vehicle classes allowed on this lane
85
*/
86
inline SVCPermissions getPermissions() const {
87
return myPermissions;
88
}
89
90
void setPermissions(SVCPermissions permissions) {
91
myPermissions = permissions;
92
}
93
94
/** @brief Returns the lane's edge
95
* @return This lane's edge
96
*/
97
ROEdge& getEdge() const {
98
return *myEdge;
99
}
100
101
/// @brief get the map of outgoing lanes to via edges
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
110
/// @brief get the state of the link from the logical predecessor to this lane (ignored for routing)
111
inline LinkState getIncomingLinkState() const {
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
135
private:
136
/// @brief The parent edge of this lane
137
ROEdge* myEdge;
138
139
/// @brief The length of the lane
140
double myLength;
141
142
/// @brief The maximum speed allowed on the lane
143
double myMaxSpeed;
144
145
/// @brief The encoding of allowed vehicle classes
146
SVCPermissions myPermissions;
147
148
std::vector<std::pair<const ROLane*, const ROEdge*> > myOutgoingLanes;
149
150
/// @brief shape for this lane
151
const PositionVector myShape;
152
153
/// @brief precomputed myShape.length / myLength
154
const double myLengthGeometryFactor;
155
156
157
private:
158
/// @brief Invalidated copy constructor
159
ROLane(const ROLane& src);
160
161
/// @brief Invalidated assignment operator
162
ROLane& operator=(const ROLane& src);
163
164
};
165
166