Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netload/NLEdgeControlBuilder.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 NLEdgeControlBuilder.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @author Leonhard Luecken
19
/// @date Mon, 9 Jul 2001
20
///
21
// Interface for building edges
22
/****************************************************************************/
23
#pragma once
24
#include <config.h>
25
26
#include <string>
27
#include <vector>
28
#include <microsim/MSEdge.h>
29
#include <utils/geom/PositionVector.h>
30
31
32
// ===========================================================================
33
// class declarations
34
// ===========================================================================
35
class MSEdgeControl;
36
class MSLane;
37
class MSNet;
38
class OutputDevice;
39
40
41
// ===========================================================================
42
// class definitions
43
// ===========================================================================
44
/**
45
* @class NLEdgeControlBuilder
46
* @brief Interface for building edges
47
*
48
* This class is the container for MSEdge-instances while they are build.
49
*
50
* While building instances of MSEdge, these are stored in a list. The list of
51
* edges is later split into two lists, one containing single-lane-edges and
52
* one containing multi-lane-edges.
53
* @todo Assignment of lanes is not really well. Should be reworked after shapes are given as params.
54
*/
55
class NLEdgeControlBuilder {
56
57
public:
58
/// @brief Constructor
59
NLEdgeControlBuilder();
60
61
62
/// @brief Destructor
63
virtual ~NLEdgeControlBuilder();
64
65
66
/** @brief Begins building of an MSEdge
67
*
68
* Builds an instance of MSEdge using "buildEdge". Stores it
69
* as the current edge in "myActiveEdge" and appends it to the list
70
* of built edges ("myEdges").
71
*
72
* The given information is used to build the edge.
73
* @param[in] id The id of the edge
74
* @param[in] function The function of the edge
75
* @param[in] streetName The street name of the edge
76
* @exception InvalidArgument If an edge with the same name was already built
77
*/
78
void beginEdgeParsing(const std::string& id, const SumoXMLEdgeFunc function,
79
const std::string& streetName, const std::string& edgeType,
80
int priority,
81
const std::string& bidi,
82
double distance);
83
84
85
/** @brief Adds a lane to the current edge
86
*
87
* @param[in] id The lane's id
88
* @param[in] maxSpeed The speed allowed on this lane
89
* @param[in] length The lane's length
90
* @param[in] shape The shape of the lane
91
* @param[in] width The width of the lane
92
* @param[in] permissions Encoding of vehicle classes that may drive on this lane
93
* @param[in] index The index of this lane within its parent edge
94
* @see SUMOVehicleClass
95
* @see MSLane
96
* @todo Definitely not a good way
97
*/
98
virtual MSLane* addLane(const std::string& id, double maxSpeed, double friction,
99
double length, const PositionVector& shape,
100
double width,
101
SVCPermissions permissions,
102
SVCPermissions changeLeft, SVCPermissions changeRight,
103
int index, bool isRampAccel,
104
const std::string& type,
105
const PositionVector& outlineShape);
106
107
/** @brief process a stopOffset element (originates either from the active edge or lane).
108
*/
109
void addStopOffsets(const StopOffset& stopOffsets);
110
111
/** @brief Return info about currently processed edge or lane
112
*/
113
std::string reportCurrentEdgeOrLane() const;
114
115
/** @brief Adds a neighbor to the current lane
116
*
117
* @param[in] id The lane's id
118
* @see MSLane
119
*/
120
virtual void addNeigh(const std::string id);
121
122
/** @brief Closes the building of an edge;
123
The edge is completely described by now and may not be opened again */
124
virtual MSEdge* closeEdge();
125
126
/** @brief Closes the building of a lane;
127
The edge is completely described by now and may not be opened again */
128
void closeLane();
129
130
/// builds the MSEdgeControl-class which holds all edges
131
MSEdgeControl* build(const MMVersion& networkVersion);
132
133
134
/** @brief Builds an edge instance (MSEdge in this case)
135
*
136
* Builds an MSEdge-instance using the given name and the current index
137
* "myCurrentNumericalEdgeID". Post-increments the index, returns
138
* the built edge.
139
*
140
* @param[in] id The id of the edge to build
141
* @param[in] streetName The street name of the edge to build
142
*/
143
virtual MSEdge* buildEdge(const std::string& id, const SumoXMLEdgeFunc function,
144
const std::string& streetName, const std::string& edgeType, const int priority, const double distance);
145
146
/** @brief add the crossingEdges in a crossing edge if present
147
*
148
* @param[in] the vector of crossed edges id
149
*/
150
virtual void addCrossingEdges(const std::vector<std::string>&);
151
152
protected:
153
/// @brief A running number for lane numbering
154
int myCurrentNumericalLaneID;
155
156
/// @brief A running number for edge numbering
157
int myCurrentNumericalEdgeID;
158
159
/// @brief Temporary, internal storage for built edges
160
MSEdgeVector myEdges;
161
162
/// @brief pointer to the currently chosen edge
163
MSEdge* myActiveEdge;
164
165
/// @brief The default stop offset for all lanes belonging to the active edge (this is set if the edge was given a stopOffset child)
166
StopOffset myCurrentDefaultStopOffset;
167
168
/// @brief The index of the currently active lane (-1 if none is active)
169
int myCurrentLaneIndex;
170
171
/// @brief pointer to a temporary lane storage
172
std::vector<MSLane*>* myLaneStorage;
173
174
/// @brief temporary storage for bidi attributes (to be resolved after loading all edges)
175
std::map<MSEdge*, std::string, ComparatorNumericalIdLess> myBidiEdges;
176
177
std::vector<std::pair<MSLane*, std::string> > myOppositeLanes;
178
179
/** @brief set the stopOffset for the last added lane.
180
*/
181
void updateCurrentLaneStopOffset(const StopOffset& stopOffset);
182
183
/** @brief set the stopOffset for the last added lane.
184
*/
185
void setDefaultStopOffset(const StopOffset& stopOffset);
186
187
/** @brief
188
*/
189
void applyDefaultStopOffsetsToLanes();
190
191
private:
192
/// @brief invalidated copy constructor
193
NLEdgeControlBuilder(const NLEdgeControlBuilder& s);
194
195
/// @brief invalidated assignment operator
196
NLEdgeControlBuilder& operator=(const NLEdgeControlBuilder& s);
197
198
};
199
200