Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netimport/NIXMLConnectionsHandler.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 NIXMLConnectionsHandler.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @date Tue, 20 Nov 2001
19
///
20
// Importer for edge connections stored in XML
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <utils/xml/SUMOSAXHandler.h>
26
#include <netbuild/NBConnection.h>
27
28
29
// ===========================================================================
30
// class declarations
31
// ===========================================================================
32
class NBEdge;
33
class NBEdgeCont;
34
class NBNodeCont;
35
class NBTrafficLightLogicCont;
36
class MsgHandler;
37
class GeoConvHelper;
38
39
40
// ===========================================================================
41
// class definitions
42
// ===========================================================================
43
/**
44
* @class NIXMLConnectionsHandler
45
* @brief Importer for edge connections stored in XML
46
*
47
* This importer parses connections, and prohibitions, and is able
48
* to reset connections between edges.
49
*/
50
class NIXMLConnectionsHandler : public SUMOSAXHandler {
51
public:
52
/** @brief Constructor
53
* @param[in] ec The edge container which includes the edges to change connections of
54
*/
55
NIXMLConnectionsHandler(NBEdgeCont& ec, NBNodeCont& nc, NBTrafficLightLogicCont& tlc);
56
57
58
/// @brief Destructor
59
~NIXMLConnectionsHandler();
60
61
62
protected:
63
/// @name inherited from GenericSAXHandler
64
//@{
65
66
/** @brief Called on the opening of a tag;
67
*
68
* @param[in] element ID of the currently opened element
69
* @param[in] attrs Attributes within the currently opened element
70
* @exception ProcessError If something fails
71
* @see GenericSAXHandler::myStartElement
72
*/
73
void myStartElement(int element,
74
const SUMOSAXAttributes& attrs);
75
76
/** @brief Called when a closing tag occurs
77
*
78
* @param[in] element ID of the currently opened element
79
* @exception ProcessError If something fails
80
* @see GenericSAXHandler::myEndElement
81
*/
82
void myEndElement(int element);
83
//@}
84
85
private:
86
/** @brief Returns the connection described by def
87
*
88
* def should have the following format <FROM_EDGE_ID>[_<FROM_LANE_NO>]-><TO_EDGE_ID>[_<TO_LANE_NO>].
89
*
90
* @param[in] defRole "prohibitor" or "prohibited" - used for error reporting
91
* @param[in] def The definition of the connection
92
* @return The parsed connection
93
*/
94
NBConnection parseConnectionDef(const std::string& defRole, const std::string& def);
95
96
97
/** @brief Parses a connection when it describes a lane-2-lane relationship
98
* @param[in] attrs The attributes to get further information about the connection from
99
* @param[in] from The edge at which the connection starts (the on incoming into a node)
100
* @param[in] to The edge at which the connection ends (the on outgoing from a node)
101
*/
102
void parseLaneBound(const SUMOSAXAttributes& attrs, NBEdge* from, NBEdge* to);
103
104
105
/** @brief Parses information about lane-2-lane connection when it describes a lane-2-lane relationship
106
* @param[in] attrs The attributes to get further information about the connection from
107
* @param[in] fromEdge The edge at which the connection starts (the on incoming into a node)
108
* @param[in] toEdge The edge at which the connection ends (the on outgoing from a node)
109
* @param[out] fromLane The lane at which connection starts
110
* @param[out] toLane The lane at which connection ends
111
*/
112
bool parseLaneInfo(const SUMOSAXAttributes& attributes, NBEdge* fromEdge, NBEdge* toEdge, int* fromLane, int* toLane);
113
114
115
/** @brief Parses information about lane-2-lane connection in deprecated format.
116
* @param[in] attrs The attributes to get further information about the connection from
117
* @param[in] fromEdge The edge at which the connection starts (the on incoming into a node)
118
* @param[in] toEdge The edge at which the connection ends (the on outgoing from a node)
119
* @param[out] fromLane The lane at which connection starts
120
* @param[out] toLane The lane at which connection ends
121
*/
122
inline bool parseDeprecatedLaneDefinition(const SUMOSAXAttributes& attributes,
123
NBEdge* fromEdge, NBEdge* toEdge,
124
int* fromLane, int* toLane);
125
126
127
/** @brief Parses information about lane-2-lane connection.
128
* @param[in] attrs The attributes to get further information about the connection from
129
* @param[out] fromLane The lane at which connection starts
130
* @param[out] toLane The lane at which connection ends
131
*/
132
inline bool parseLaneDefinition(const SUMOSAXAttributes& attributes, int* fromLane, int* toLane);
133
134
/** @brief Parses a delete element that specifies a connection to delete
135
* @param[in] attrs The attributes to get the deleted connections values from
136
*/
137
void delConnection(const SUMOSAXAttributes& attrs);
138
139
/** @brief Parses a connection and adds it to the referenced edge
140
* @param[in] attrs The attributes to get the connections's values from
141
*/
142
void parseConnection(const SUMOSAXAttributes& attrs);
143
144
/** @brief Parses a crossing and updates the referenced node
145
* @param[in] attrs The attributes to get the crossings's values from
146
*/
147
void addCrossing(const SUMOSAXAttributes& attrs);
148
149
/** @brief Parses a walkingArea and updates the referenced node
150
* @param[in] attrs The attributes to get the crossings's values from
151
*/
152
void addWalkingArea(const SUMOSAXAttributes& attrs);
153
154
/** @brief Parses a prohibition and updates the referenced node
155
* @param[in] attrs The attributes to get the prohibition's values from
156
*/
157
void addProhibition(const SUMOSAXAttributes& attrs);
158
private:
159
/// @brief The edge container to fill
160
NBEdgeCont& myEdgeCont;
161
162
/// @brief The edge container to fill
163
NBNodeCont& myNodeCont;
164
165
/** @brief The traffic lights container to add built tls to (when
166
* invalidating tls) */
167
NBTrafficLightLogicCont& myTLLogicCont;
168
169
/// @brief Information whether we have a deprecated attribute
170
bool myHaveWarnedAboutDeprecatedLanes;
171
172
/// @brief the handler for loading errors
173
MsgHandler* const myErrorMsgHandler;
174
175
/// @brief The coordinate transformation which was used compute the custom shape coordinates for connections and crossings
176
GeoConvHelper* myLocation;
177
178
/// @brief last item the could receive parameters
179
Parameterised* myLastParameterised;
180
181
private:
182
/// @brief invalidated copy constructor
183
NIXMLConnectionsHandler(const NIXMLConnectionsHandler& s);
184
185
/// @brief invalidated assignment operator
186
NIXMLConnectionsHandler& operator=(const NIXMLConnectionsHandler& s);
187
188
189
};
190
191