Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/router/ROLane.h
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/** @brief Returns the lane's edge
91
* @return This lane's edge
92
*/
93
ROEdge& getEdge() const {
94
return *myEdge;
95
}
96
97
/// @brief get the map of outgoing lanes to via edges
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
106
/// @brief get the state of the link from the logical predecessor to this lane (ignored for routing)
107
inline LinkState getIncomingLinkState() const {
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:
132
/// @brief The parent edge of this lane
133
ROEdge* myEdge;
134
135
/// @brief The length of the lane
136
double myLength;
137
138
/// @brief The maximum speed allowed on the lane
139
double myMaxSpeed;
140
141
/// @brief The encoding of allowed vehicle classes
142
SVCPermissions myPermissions;
143
144
std::vector<std::pair<const ROLane*, const ROEdge*> > myOutgoingLanes;
145
146
/// @brief shape for this lane
147
const PositionVector myShape;
148
149
/// @brief precomputed myShape.length / myLength
150
const double myLengthGeometryFactor;
151
152
153
private:
154
/// @brief Invalidated copy constructor
155
ROLane(const ROLane& src);
156
157
/// @brief Invalidated assignment operator
158
ROLane& operator=(const ROLane& src);
159
160
};
161
162