Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NLHandler.h
Go to the documentation of this file.
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/****************************************************************************/
21// The XML-Handler for network loading
22/****************************************************************************/
23#pragma once
24#include <config.h>
25
26#include <utils/geom/Boundary.h>
30
31
32// ===========================================================================
33// class declarations
34// ===========================================================================
35class NLContainer;
41class MSRailSignal;
42
43
44// ===========================================================================
45// class definitions
46// ===========================================================================
47
48
56public:
57 NLShapeHandler(const std::string& file, ShapeContainer& sc) :
58 ShapeHandler(file, sc) {}
59
61 virtual ~NLShapeHandler() {}
62
63 Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, bool friendlyPos, double lanePosLat);
64
65 virtual bool addLanePosParams() {
66 return true;
67 }
68};
69
70
79class NLHandler : public MSRouteHandler {
80public:
82 typedef std::vector<MSLane*> LaneVector;
83
84public:
94 NLHandler(const std::string& file, MSNet& net,
95 NLDetectorBuilder& detBuilder, NLTriggerBuilder& triggerBuilder,
96 NLEdgeControlBuilder& edgeBuilder,
97 NLJunctionControlBuilder& junctionBuilder);
98
99
101 virtual ~NLHandler();
102
103 bool haveSeenInternalEdge() const {
105 }
106
109 }
110
113 }
114
115 bool haveSeenNeighs() const {
116 return myHaveSeenNeighs;
117 }
118
122
123 bool haveSeenTLSParams() const {
124 return myHaveSeenTLSParams;
125 }
126
128 return myNetworkVersion;
129 }
130
131 static Parameterised* addPredecessorConstraint(int element, const SUMOSAXAttributes& attrs, MSRailSignal* rs);
132
133protected:
135
136
145 virtual void myStartElement(int element,
146 const SUMOSAXAttributes& attrs);
147
148
156 virtual void myEndElement(int element);
158
159
160protected:
161 void addParam(const SUMOSAXAttributes& attrs);
162
166 virtual void addE1Detector(const SUMOSAXAttributes& attrs);
167
171 virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs);
172
176 virtual void addE2Detector(const SUMOSAXAttributes& attrs);
177
181 void beginE3Detector(const SUMOSAXAttributes& attrs);
182
186 void addE3Entry(const SUMOSAXAttributes& attrs);
187
191 void addE3Exit(const SUMOSAXAttributes& attrs);
192
194 virtual void endE3Detector();
195
199 virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs);
200
204 virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs);
205
210 virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype);
211
215 virtual void addDeadlock(const SUMOSAXAttributes& attrs);
216 virtual void addDeadlockRoute(const SUMOSAXAttributes& attrs);
217
219 virtual void closeEdge();
220
221private:
223 void beginEdgeParsing(const SUMOSAXAttributes& attrs);
224
226 void addLane(const SUMOSAXAttributes& attrs);
227
229 void addRequest(const SUMOSAXAttributes& attrs);
230
232 void initJunctionLogic(const SUMOSAXAttributes& attrs);
233
235 void initTrafficLightLogic(const SUMOSAXAttributes& attrs);
236
238 void addPhase(const SUMOSAXAttributes& attrs);
239
241 void addCondition(const SUMOSAXAttributes& attrs);
242
244 void addAssignment(const SUMOSAXAttributes& attrs);
245
247 void addFunction(const SUMOSAXAttributes& attrs);
248
250 void closeFunction();
251
253 virtual void openJunction(const SUMOSAXAttributes& attrs);
254
255 void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*>& into, bool& ok);
256
258 void addConnection(const SUMOSAXAttributes& attrs);
259
260 void addConflict(const SUMOSAXAttributes& attrs);
261
262 virtual void openWAUT(const SUMOSAXAttributes& attrs);
263 void addWAUTSwitch(const SUMOSAXAttributes& attrs);
264 void addWAUTJunction(const SUMOSAXAttributes& attrs);
265
267 void setLocation(const SUMOSAXAttributes& attrs);
268
278 void addDistrict(const SUMOSAXAttributes& attrs);
279
280
291 void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
292
296 void addRoundabout(const SUMOSAXAttributes& attrs);
297
298
299 void closeWAUT();
300
302 LinkDirection parseLinkDir(const std::string& dir);
303
305 LinkState parseLinkState(const std::string& state);
306
307 int parseDetectPersons(const std::string& detectPersonsString, const std::string& id, bool& ok);
308
309protected:
312
315
318
319
322
325
328
331
334
337
339 std::string myCurrentWAUTID;
340
342 std::string myCurrentTypeID;
343
346
349
351
353
355 std::vector<Parameterised*> myLastParameterised;
356
359
362
365
368
371
374
377
380
383
386
388 typedef std::map<std::string, std::pair<std::string, std::string> > JunctionGraph;
390
392
393private:
396
399
400};
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
std::pair< int, double > MMVersion
(M)ajor/(M)inor version for written networks and default version for loading
Definition StdDefs.h:71
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
The simulated network and simulation perfomer.
Definition MSNet.h:89
A signal for rails.
Parser and container for routes during their loading.
The parent class for traffic light logics.
Builds detectors for microsim.
Interface for building edges.
The XML-Handler for network loading.
Definition NLHandler.h:79
bool haveSeenAdditionalSpeedRestrictions() const
Definition NLHandler.h:119
std::vector< MSLane * > LaneVector
Definition of a lane vector.
Definition NLHandler.h:82
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
std::vector< Parameterised * > myLastParameterised
Definition NLHandler.h:355
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
MSLink * myCurrentLink
the link element for the connection currently being parsed
Definition NLHandler.h:385
void addRoundabout(const SUMOSAXAttributes &attrs)
bool myHaveSeenTLSParams
whether tls params were loaded
Definition NLHandler.h:373
void addWAUTSwitch(const SUMOSAXAttributes &attrs)
bool myCurrentIsBroken
Definition NLHandler.h:350
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
void beginEdgeParsing(const SUMOSAXAttributes &attrs)
begins the processing of an edge
Position myNetworkOffset
The network offset.
Definition NLHandler.h:345
Boundary myConvBoundary
Definition NLHandler.h:348
bool myHaveSeenAdditionalSpeedRestrictions
whether additional files contained type-specific speed limits
Definition NLHandler.h:370
bool haveSeenInternalEdge() const
Definition NLHandler.h:103
std::string myCurrentDistrictID
The id of the current district.
Definition NLHandler.h:333
void addPhase(const SUMOSAXAttributes &attrs)
adds a phase to the traffic lights logic currently build
MMVersion myNetworkVersion
the loaded network version
Definition NLHandler.h:376
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition NLHandler.h:342
void addAssignment(const SUMOSAXAttributes &attrs)
adds a switching condition assignment to the traffic lights logic currently build
static Parameterised * addPredecessorConstraint(int element, const SUMOSAXAttributes &attrs, MSRailSignal *rs)
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
bool hasJunctionHigherSpeeds() const
Definition NLHandler.h:107
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition NLHandler.h:339
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane * > &into, bool &ok)
void addFunction(const SUMOSAXAttributes &attrs)
adds a switching condition function to the traffic lights logic currently build
int myPreviousEdgeIdx
Definition NLHandler.h:391
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
int parseDetectPersons(const std::string &detectPersonsString, const std::string &id, bool &ok)
Parameterised myLastEdgeParameters
Definition NLHandler.h:354
virtual void myEndElement(int element)
Called when a closing tag occurs.
bool myHaveSeenDefaultLength
whether the loaded network contains edges with default lengths
Definition NLHandler.h:364
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition NLHandler.h:324
virtual void addInstantE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
virtual void openJunction(const SUMOSAXAttributes &attrs)
opens a junction for processing
virtual void endE3Detector()
Builds of an e3 detector using collected values.
bool myAmParsingTLLogicOrJunction
internal information whether a tls-logic is currently read
Definition NLHandler.h:336
JunctionGraph myJunctionGraph
Definition NLHandler.h:389
void addDistrict(const SUMOSAXAttributes &attrs)
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition NLHandler.h:317
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition NLHandler.h:327
void initTrafficLightLogic(const SUMOSAXAttributes &attrs)
begins the reading of a traffic lights logic
void closeWAUT()
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition NLHandler.h:358
void addCondition(const SUMOSAXAttributes &attrs)
adds a switching condition to the traffic lights logic currently build
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition NLHandler.cpp:88
bool haveSeenTLSParams() const
Definition NLHandler.h:123
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition NLHandler.h:367
NLHandler(const NLHandler &s)
virtual void openWAUT(const SUMOSAXAttributes &attrs)
LinkState parseLinkState(const std::string &state)
Parses the given character into an enumeration typed link state.
MMVersion networkVersion() const
Definition NLHandler.h:127
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition NLHandler.h:314
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition NLHandler.h:321
void addConflict(const SUMOSAXAttributes &attrs)
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition NLHandler.h:330
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
virtual ~NLHandler()
Destructor.
Definition NLHandler.cpp:84
std::map< std::string, std::pair< std::string, std::string > > JunctionGraph
temporary data for building the junction graph after network parsing is finished
Definition NLHandler.h:388
bool haveSeenDefaultLength() const
Definition NLHandler.h:111
void addE3Exit(const SUMOSAXAttributes &attrs)
Adds an exit to the currently processed e3 detector.
void beginE3Detector(const SUMOSAXAttributes &attrs)
Starts building of an e3 detector using the given specification.
virtual void closeEdge()
Closes the process of building an edge.
NLHandler & operator=(const NLHandler &s)
void closeFunction()
adds a switching condition function to the traffic lights logic currently build
bool myHaveJunctionHigherSpeeds
Whether the network was built with higher speed on junctions.
Definition NLHandler.h:361
MSNet & myNet
The net to fill (preinitialised)
Definition NLHandler.h:311
bool haveSeenNeighs() const
Definition NLHandler.h:115
virtual void addDeadlock(const SUMOSAXAttributes &attrs)
Loads deadlock information for preparing additional rail signal checks.
MSRailSignal * myConstrainedSignal
rail signal for which constraints are being loaded
Definition NLHandler.h:382
Boundary myOrigBoundary
The network's boundaries.
Definition NLHandler.h:348
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
bool myNetIsLoaded
whether the location element was already loadee
Definition NLHandler.h:379
virtual void addDeadlockRoute(const SUMOSAXAttributes &attrs)
void addWAUTJunction(const SUMOSAXAttributes &attrs)
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
bool myHaveWarnedAboutInvalidTLType
Definition NLHandler.h:352
void addParam(const SUMOSAXAttributes &attrs)
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Builder of microsim-junctions and tls.
The XML-Handler for shapes loading network loading.
Definition NLHandler.h:55
virtual bool addLanePosParams()
Whether some input attributes shall be automatically added as params (Can be implemented in all child...
Definition NLHandler.h:65
Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, bool friendlyPos, double lanePosLat)
get position for a given laneID (Has to be implemented in all child)
NLShapeHandler(const std::string &file, ShapeContainer &sc)
Definition NLHandler.h:57
virtual ~NLShapeHandler()
Destructor.
Definition NLHandler.h:61
Builds trigger objects for microsim.
An upper class for objects with additional parameters.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
Encapsulated SAX-Attributes.
Storage for geometrical objects.
The XML-Handler for network loading.