Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/router/RONetHandler.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 RONetHandler.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @date Sept 2002
19
///
20
// The handler that parses a SUMO-network for its usage in a router
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <string>
26
#include <utils/xml/SUMOSAXHandler.h>
27
#include <utils/common/SUMOVehicleClass.h>
28
#include <utils/common/UtilExceptions.h>
29
30
31
// ===========================================================================
32
// class declarations
33
// ===========================================================================
34
class RONet;
35
class OptionsCont;
36
class ROEdge;
37
class ROAbstractEdgeBuilder;
38
39
40
// ===========================================================================
41
// class definitions
42
// ===========================================================================
43
/**
44
* @class RONetHandler
45
* @brief The handler that parses a SUMO-network for its usage in a router
46
*
47
* SAX2-Handler for SUMO-network loading. As this class is used for both
48
* the dua- and the jtrrouter, a reference to the edge builder is given.
49
*/
50
class RONetHandler : public SUMOSAXHandler {
51
public:
52
/** @brief Constructor
53
*
54
* @param[in] net The network instance to fill
55
* @param[in] eb The abstract edge builder to use
56
*/
57
RONetHandler(RONet& net, ROAbstractEdgeBuilder& eb, const bool ignoreInternal, const double minorPenalty, double tlsPenalty, double turnaroundPenalty);
58
59
60
/// @brief Destructor
61
virtual ~RONetHandler();
62
63
/// @brief retrieve mapping of edges to bidi edges (must be resolved after loading network)
64
const std::map<ROEdge*, std::string>& getBidiMap() const {
65
return myBidiEdges;
66
}
67
68
protected:
69
/// @name inherited from GenericSAXHandler
70
//@{
71
72
/** @brief Called on the opening of a tag;
73
*
74
* @param[in] element ID of the currently opened element
75
* @param[in] attrs Attributes within the currently opened element
76
* @exception ProcessError If something fails
77
* @see GenericSAXHandler::myStartElement
78
*/
79
virtual void myStartElement(int element, const SUMOSAXAttributes& attrs);
80
81
/** @brief Called when a closing tag occurs
82
*
83
* @param[in] element ID of the currently opened element
84
* @exception ProcessError If something fails
85
* @see GenericSAXHandler::myEndElement
86
*/
87
virtual void myEndElement(int element);
88
//@}
89
90
protected:
91
/// @name called from myStartElement
92
//@{
93
94
/// @brief assign arbitrary vehicle parameters
95
void addParam(const SUMOSAXAttributes& attrs);
96
97
/** @brief Parses and builds an edge
98
*
99
* Parses attributes from an "edge"-element (id, from/to-nodes, function, etc.).
100
* If the given nodes are not yet known, they are added to the network.
101
* Uses the internal edge builder to build the edge and adds the edge
102
* to the network.
103
*
104
* @param[in] attrs The attributes (of the "edge"-element) to parse
105
* @todo The edge is "built" first, then the nodes are added; should be done while constructing, probably a legacy issue
106
* @todo No exception?
107
*/
108
void parseEdge(const SUMOSAXAttributes& attrs);
109
110
111
/** @brief Parses and builds a lane
112
*
113
* Parses attributes from an "lane"-element (speed, length, vehicle classes, etc.).
114
* Builds a ROLane using these attributes (if they are valid) and adds it to the edge.
115
*
116
* @param[in] attrs The attributes (of the "lane"-element) to parse
117
* @todo No exception?
118
*/
119
virtual void parseLane(const SUMOSAXAttributes& attrs);
120
121
122
/** @brief Parses a junction's position
123
*
124
* Parses the position of the junction. Sets it to the junction.
125
*
126
* @param[in] attrs The attributes (of the "lane"-element) to parse
127
* @todo In fact, the junction should be built given its position.
128
* @todo No exception?
129
*/
130
void parseJunction(const SUMOSAXAttributes& attrs);
131
132
133
/** @begin Parses a connection
134
* Called on the occurrence of a "connection" element
135
* @param[in] attrs The attributes (of the "connection"-element) to parse
136
*/
137
void parseConnection(const SUMOSAXAttributes& attrs);
138
139
140
/** @begin Parses a stopping place
141
* Called on the occurrence of a "busStop", "trainStop" or "containerStop" element
142
* @param[in] attrs The attributes to parse
143
* @param[in] element which kind of stop is to be parsed
144
*/
145
void parseStoppingPlace(const SUMOSAXAttributes& attrs, const SumoXMLTag element);
146
147
148
/** @begin Parses an access point to a train stop
149
* Called on the occurrence of an "access" element
150
* @param[in] attrs The attributes to parse
151
*/
152
void parseAccess(const SUMOSAXAttributes& attrs);
153
154
155
/** @begin Parses a district and creates a pseudo edge for it
156
*
157
* Called on the occurrence of a "district" element, this method
158
* retrieves the id of the district and creates a district type
159
* edge with this id.
160
*
161
* @param[in] attrs The attributes (of the "district"-element) to parse
162
* @exception ProcessError If an edge given in district@edges is not known
163
*/
164
void parseDistrict(const SUMOSAXAttributes& attrs);
165
166
167
/** @begin Parses a district edge and connects it to the district
168
*
169
* Called on the occurrence of a "dsource" or "dsink" element, this method
170
* retrieves the id of the approachable edge. If this edge is known
171
* and valid, the approaching edge is informed about it (by calling
172
* "ROEdge::addFollower").
173
*
174
* @param[in] attrs The attributes to parse
175
* @param[in] isSource whether a "dsource or a "dsink" was given
176
* @todo No exception?
177
*/
178
void parseDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
179
180
//@}
181
182
/// Parses network location description
183
void setLocation(const SUMOSAXAttributes& attrs);
184
185
protected:
186
/// @brief The net to store the information into
187
RONet& myNet;
188
189
/// @brief the loaded network version
190
MMVersion myNetworkVersion;
191
192
/// @brief The object used to build of edges of the desired type
193
ROAbstractEdgeBuilder& myEdgeBuilder;
194
195
/// @brief whether to ignore junction internal edges
196
const bool myIgnoreInternal;
197
198
/// @brief The name of the edge/node that is currently processed
199
std::string myCurrentName;
200
201
/// The id of the currently processed edge type
202
std::string myCurrentTypeID;
203
204
/// @brief The currently built edge
205
ROEdge* myCurrentEdge;
206
207
/// @brief The currently built stopping place
208
SUMOVehicleParameter::Stop* myCurrentStoppingPlace;
209
210
/// @brief temporary data for checking node initialisation after network parsing is finished
211
std::set<std::string> myUnseenNodeIDs;
212
213
/// @brief time penalty for passing a minor link
214
const double myMinorPenalty;
215
const double myTLSPenalty;
216
const double myTurnaroundPenalty;
217
218
/// @brief temporary storage for bidi attributes (to be resolved after loading all edges)
219
std::map<ROEdge*, std::string> myBidiEdges;
220
221
private:
222
/// @brief Invalidated copy constructor
223
RONetHandler(const RONetHandler& src);
224
225
/// @brief Invalidated assignment operator
226
RONetHandler& operator=(const RONetHandler& src);
227
228
};
229
230