Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netload/NLEdgeControlBuilder.h
193871 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 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
const std::string& routingType,
81
int priority,
82
const std::string& bidi,
83
double distance);
84
85
86
/** @brief Adds a lane to the current edge
87
*
88
* @param[in] id The lane's id
89
* @param[in] maxSpeed The speed allowed on this lane
90
* @param[in] length The lane's length
91
* @param[in] shape The shape of the lane
92
* @param[in] width The width of the lane
93
* @param[in] permissions Encoding of vehicle classes that may drive on this lane
94
* @param[in] index The index of this lane within its parent edge
95
* @see SUMOVehicleClass
96
* @see MSLane
97
* @todo Definitely not a good way
98
*/
99
virtual MSLane* addLane(const std::string& id, double maxSpeed, double friction,
100
double length, const PositionVector& shape,
101
double width,
102
SVCPermissions permissions,
103
SVCPermissions changeLeft, SVCPermissions changeRight,
104
int index, bool isRampAccel,
105
const std::string& type,
106
const PositionVector& outlineShape);
107
108
/** @brief process a stopOffset element (originates either from the active edge or lane).
109
*/
110
void addStopOffsets(const StopOffset& stopOffsets);
111
112
/** @brief Return info about currently processed edge or lane
113
*/
114
std::string reportCurrentEdgeOrLane() const;
115
116
/** @brief Adds a neighbor to the current lane
117
*
118
* @param[in] id The lane's id
119
* @see MSLane
120
*/
121
virtual void addNeigh(const std::string id);
122
123
/** @brief Closes the building of an edge;
124
The edge is completely described by now and may not be opened again */
125
virtual MSEdge* closeEdge();
126
127
/** @brief Closes the building of a lane;
128
The edge is completely described by now and may not be opened again */
129
void closeLane();
130
131
/// builds the MSEdgeControl-class which holds all edges
132
MSEdgeControl* build(const MMVersion& networkVersion);
133
134
135
/** @brief Builds an edge instance (MSEdge in this case)
136
*
137
* Builds an MSEdge-instance using the given name and the current index
138
* "myCurrentNumericalEdgeID". Post-increments the index, returns
139
* the built edge.
140
*
141
* @param[in] id The id of the edge to build
142
* @param[in] streetName The street name of the edge to build
143
*/
144
virtual MSEdge* buildEdge(const std::string& id, const SumoXMLEdgeFunc function,
145
const std::string& streetName, const std::string& edgeType,
146
const std::string& routingType, const int priority, const double distance);
147
148
/** @brief add the crossingEdges in a crossing edge if present
149
*
150
* @param[in] the vector of crossed edges id
151
*/
152
virtual void addCrossingEdges(const std::vector<std::string>&);
153
154
protected:
155
/// @brief A running number for lane numbering
156
int myCurrentNumericalLaneID;
157
158
/// @brief A running number for edge numbering
159
int myCurrentNumericalEdgeID;
160
161
/// @brief Temporary, internal storage for built edges
162
MSEdgeVector myEdges;
163
164
/// @brief pointer to the currently chosen edge
165
MSEdge* myActiveEdge;
166
167
/// @brief The default stop offset for all lanes belonging to the active edge (this is set if the edge was given a stopOffset child)
168
StopOffset myCurrentDefaultStopOffset;
169
170
/// @brief The index of the currently active lane (-1 if none is active)
171
int myCurrentLaneIndex;
172
173
/// @brief pointer to a temporary lane storage
174
std::vector<MSLane*>* myLaneStorage;
175
176
/// @brief temporary storage for bidi attributes (to be resolved after loading all edges)
177
std::map<MSEdge*, std::string, ComparatorNumericalIdLess> myBidiEdges;
178
179
std::vector<std::pair<MSLane*, std::string> > myOppositeLanes;
180
181
/** @brief set the stopOffset for the last added lane.
182
*/
183
void updateCurrentLaneStopOffset(const StopOffset& stopOffset);
184
185
/** @brief set the stopOffset for the last added lane.
186
*/
187
void setDefaultStopOffset(const StopOffset& stopOffset);
188
189
/** @brief
190
*/
191
void applyDefaultStopOffsetsToLanes();
192
193
private:
194
/// @brief invalidated copy constructor
195
NLEdgeControlBuilder(const NLEdgeControlBuilder& s);
196
197
/// @brief invalidated assignment operator
198
NLEdgeControlBuilder& operator=(const NLEdgeControlBuilder& s);
199
200
};
201
202