Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netimport/NIXMLNodesHandler.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 NIXMLNodesHandler.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @date Tue, 20 Nov 2001
19
///
20
// Importer for network nodes stored in XML
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <utils/xml/SUMOSAXHandler.h>
26
#include <utils/geom/Position.h>
27
28
29
// ===========================================================================
30
// class declarations
31
// ===========================================================================
32
class OptionsCont;
33
class GeoConvHelper;
34
class NBNode;
35
class NBNodeCont;
36
class NBTrafficLightLogicCont;
37
38
39
// ===========================================================================
40
// class definitions
41
// ===========================================================================
42
/**
43
* @class NIXMLNodesHandler
44
* @brief Importer for network nodes stored in XML
45
*
46
* This SAX-handler parses node information and stores it in the given node
47
* container. Additionally, the given tls-container may be filled with
48
* additional information.
49
*/
50
class NIXMLNodesHandler : public SUMOSAXHandler {
51
52
public:
53
/** @brief Constructor
54
*
55
* @param[in, filled] nc The node container to fill
56
* @param[in, filled] tlc The traffic lights container to fill
57
* @param[in] options The options to use
58
* @todo Options are only given to determine whether "flip-y" is set; maybe this should be done by giving a bool
59
* @todo Why are options not const?
60
*/
61
NIXMLNodesHandler(NBNodeCont& nc, NBEdgeCont& ec, NBTrafficLightLogicCont& tlc,
62
OptionsCont& options);
63
64
65
/// @brief Destructor
66
~NIXMLNodesHandler();
67
68
/** @brief parses node attributes (not related to positioning)
69
*/
70
static NBNode* processNodeType(const SUMOSAXAttributes& attrs, NBNode* node, const std::string& nodeID, const Position& position,
71
bool updateEdgeGeometries,
72
NBNodeCont& nc, NBEdgeCont& ec,
73
NBTrafficLightLogicCont& tlc,
74
GeoConvHelper* from_srs = nullptr);
75
76
protected:
77
/// @name inherited from GenericSAXHandler
78
//@{
79
80
/** @brief Called on the opening of a tag;
81
*
82
* In dependence to the obtained type, an appropriate parsing method is called.
83
*
84
* @param[in] element ID of the currently opened element
85
* @param[in] attrs Attributes within the currently opened element
86
* @exception ProcessError If something fails (not used herein)
87
* @note policy is to throw no exception in order to allow further processing
88
* @todo ProcessErrors are thrown when parsing traffic lights!?
89
*/
90
void myStartElement(int element,
91
const SUMOSAXAttributes& attrs);
92
/** @brief Called when a closing tag occurs
93
*
94
* @param[in] element ID of the currently opened element
95
* @exception ProcessError If something fails
96
* @see GenericSAXHandler::myEndElement
97
*/
98
void myEndElement(int element);
99
//@}
100
101
102
private:
103
/*
104
* @brief Parses node information
105
* Tries to parse a node. If the node can be parsed, it is stored within
106
* "myNodeCont". Otherwise an error is generated. Then, if given
107
* the tls information is parsed and inserted into "myTLLogicCont".
108
*/
109
void addNode(const SUMOSAXAttributes& attrs);
110
111
/*
112
* @brief Parses node deletion information
113
*/
114
void deleteNode(const SUMOSAXAttributes& attrs);
115
116
/*
117
* @brief Parses a cluster of nodes to be joined
118
*/
119
void addJoinCluster(const SUMOSAXAttributes& attrs);
120
121
/*
122
* @brief Parses a list of nodes to be excluded from joining
123
*/
124
void addJoinExclusion(const SUMOSAXAttributes& attrs);
125
126
127
/** @brief Builds the defined traffic light or adds a node to it
128
*
129
* @param[in] attrs Attributes within the currently opened node
130
* @param[in] currentNode The built node to add the tls information to
131
*/
132
static void processTrafficLightDefinitions(const SUMOSAXAttributes& attrs,
133
NBNode* currentNode, NBTrafficLightLogicCont& tlc);
134
135
136
private:
137
/// @brief A reference to the program's options
138
OptionsCont& myOptions;
139
140
/// @brief The id of the currently parsed node
141
std::string myID;
142
143
/// @brief The position of the currently parsed node
144
Position myPosition;
145
146
/// @brief The node container to add built nodes to
147
NBNodeCont& myNodeCont;
148
149
/// @brief The node container to add built nodes to
150
NBEdgeCont& myEdgeCont;
151
152
/// @brief The traffic lights container to add built tls to
153
NBTrafficLightLogicCont& myTLLogicCont;
154
155
/// @brief The coordinate transformation which was used compute the node coordinates
156
GeoConvHelper* myLocation;
157
158
/// @brief last item the could receive parameters
159
Parameterised* myLastParameterised;
160
161
private:
162
/** @brief invalid copy constructor */
163
NIXMLNodesHandler(const NIXMLNodesHandler& s);
164
165
/** @brief invalid assignment operator */
166
NIXMLNodesHandler& operator=(const NIXMLNodesHandler& s);
167
168
};
169
170