Eclipse SUMO - Simulation of Urban MObility
NLHandler.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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
121 }
122
123 bool haveSeenMesoEdgeType() const {
125 }
126
127 double networkVersion() const {
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 addMesoEdgeType(const SUMOSAXAttributes& attrs);
216
218 virtual void closeEdge();
219
220private:
222 void beginEdgeParsing(const SUMOSAXAttributes& attrs);
223
225 void addLane(const SUMOSAXAttributes& attrs);
226
228 void addRequest(const SUMOSAXAttributes& attrs);
229
231 void initJunctionLogic(const SUMOSAXAttributes& attrs);
232
234 void initTrafficLightLogic(const SUMOSAXAttributes& attrs);
235
237 void addPhase(const SUMOSAXAttributes& attrs);
238
240 void addCondition(const SUMOSAXAttributes& attrs);
241
243 void addAssignment(const SUMOSAXAttributes& attrs);
244
246 void addFunction(const SUMOSAXAttributes& attrs);
247
249 void closeFunction();
250
252 virtual void openJunction(const SUMOSAXAttributes& attrs);
253
254 void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*>& into, bool& ok);
255
257 void addConnection(const SUMOSAXAttributes& attrs);
258
259 virtual void openWAUT(const SUMOSAXAttributes& attrs);
260 void addWAUTSwitch(const SUMOSAXAttributes& attrs);
261 void addWAUTJunction(const SUMOSAXAttributes& attrs);
262
264 void setLocation(const SUMOSAXAttributes& attrs);
265
275 void addDistrict(const SUMOSAXAttributes& attrs);
276
277
288 void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
289
293 void addRoundabout(const SUMOSAXAttributes& attrs);
294
295
296 void closeWAUT();
297
299 LinkDirection parseLinkDir(const std::string& dir);
300
302 LinkState parseLinkState(const std::string& state);
303
304protected:
307
310
313
314
317
320
323
326
329
332
334 std::string myCurrentWAUTID;
335
337 std::string myCurrentTypeID;
338
341
344
346
348
350 std::vector<Parameterised*> myLastParameterised;
351
354
357
360
363
366
369
372
375
378
380 typedef std::map<std::string, std::pair<std::string, std::string> > JunctionGraph;
382
384
385private:
388
391
392};
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,...
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
The simulated network and simulation perfomer.
Definition: MSNet.h:88
A signal for rails.
Definition: MSRailSignal.h:46
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
Definition: NLHandler.cpp:717
bool myHaveSeenMesoEdgeType
whether edge type specific meso paramters were loaded
Definition: NLHandler.h:368
std::vector< Parameterised * > myLastParameterised
Definition: NLHandler.h:350
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:1040
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1633
void addWAUTSwitch(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:677
virtual void addMesoEdgeType(const SUMOSAXAttributes &attrs)
Loads edge type specific meso parameters.
Definition: NLHandler.cpp:1650
bool myCurrentIsBroken
Definition: NLHandler.h:345
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
Definition: NLHandler.cpp:1282
void beginEdgeParsing(const SUMOSAXAttributes &attrs)
begins the processing of an edge
Definition: NLHandler.cpp:411
Position myNetworkOffset
The network offset.
Definition: NLHandler.h:340
Boundary myConvBoundary
Definition: NLHandler.h:343
bool myHaveSeenAdditionalSpeedRestrictions
whether additional files contained type-specific speed limits
Definition: NLHandler.h:365
bool haveSeenInternalEdge() const
Definition: NLHandler.h:103
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:328
void addPhase(const SUMOSAXAttributes &attrs)
adds a phase to the traffic lights logic currently build
Definition: NLHandler.cpp:797
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:337
void addAssignment(const SUMOSAXAttributes &attrs)
adds a switching condition assignment to the traffic lights logic currently build
Definition: NLHandler.cpp:890
static Parameterised * addPredecessorConstraint(int element, const SUMOSAXAttributes &attrs, MSRailSignal *rs)
Definition: NLHandler.cpp:1721
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:995
bool hasJunctionHigherSpeeds() const
Definition: NLHandler.h:107
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1611
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:334
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane * > &into, bool &ok)
Definition: NLHandler.cpp:612
void addFunction(const SUMOSAXAttributes &attrs)
adds a switching condition function to the traffic lights logic currently build
Definition: NLHandler.cpp:900
int myPreviousEdgeIdx
Definition: NLHandler.h:383
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
Definition: NLHandler.cpp:505
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:742
Parameterised myLastEdgeParameters
Definition: NLHandler.h:349
virtual void myEndElement(int element)
Called when a closing tag occurs.
Definition: NLHandler.cpp:304
bool myHaveSeenDefaultLength
whether the loaded network contains edges with default lengths
Definition: NLHandler.h:359
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:319
virtual void addInstantE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:962
virtual void openJunction(const SUMOSAXAttributes &attrs)
opens a junction for processing
Definition: NLHandler.cpp:567
virtual void endE3Detector()
Builds of an e3 detector using collected values.
Definition: NLHandler.cpp:1674
bool myAmParsingTLLogicOrJunction
internal information whether a tls-logic is currently read
Definition: NLHandler.h:331
JunctionGraph myJunctionGraph
Definition: NLHandler.h:381
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:371
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1532
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:312
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:322
void initTrafficLightLogic(const SUMOSAXAttributes &attrs)
begins the reading of a traffic lights logic
Definition: NLHandler.cpp:757
void closeWAUT()
Definition: NLHandler.cpp:1684
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:353
NLHandler(const std::string &file, MSNet &net, NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder, NLEdgeControlBuilder &edgeBuilder, NLJunctionControlBuilder &junctionBuilder)
Constructor.
Definition: NLHandler.cpp:60
void addCondition(const SUMOSAXAttributes &attrs)
adds a switching condition to the traffic lights logic currently build
Definition: NLHandler.cpp:879
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1511
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: NLHandler.cpp:87
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition: NLHandler.h:362
NLHandler(const NLHandler &s)
double networkVersion() const
Definition: NLHandler.h:127
virtual void openWAUT(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:649
LinkState parseLinkState(const std::string &state)
Parses the given character into an enumeration typed link state.
Definition: NLHandler.cpp:1495
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:309
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:316
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:325
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:913
virtual ~NLHandler()
Destructor.
Definition: NLHandler.cpp:83
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:380
bool haveSeenDefaultLength() const
Definition: NLHandler.h:111
void addE3Exit(const SUMOSAXAttributes &attrs)
Adds an exit to the currently processed e3 detector.
Definition: NLHandler.cpp:1295
void beginE3Detector(const SUMOSAXAttributes &attrs)
Starts building of an e3 detector using the given specification.
Definition: NLHandler.cpp:1239
virtual void closeEdge()
Closes the process of building an edge.
Definition: NLHandler.cpp:487
NLHandler & operator=(const NLHandler &s)
void closeFunction()
adds a switching condition function to the traffic lights logic currently build
Definition: NLHandler.cpp:908
bool myHaveJunctionHigherSpeeds
Whether the network was built with higher speed on junctions.
Definition: NLHandler.h:356
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:306
bool haveSeenNeighs() const
Definition: NLHandler.h:115
MSRailSignal * myConstrainedSignal
rail signal for which constraints are being loaded
Definition: NLHandler.h:377
Boundary myOrigBoundary
The network's boundaries.
Definition: NLHandler.h:343
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:1485
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:374
void addWAUTJunction(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:696
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
Definition: NLHandler.cpp:1016
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
Definition: NLHandler.cpp:1308
bool myHaveWarnedAboutInvalidTLType
Definition: NLHandler.h:347
void addParam(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:632
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:1382
bool haveSeenMesoEdgeType() const
Definition: NLHandler.h:123
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)
Definition: NLHandler.cpp:1698
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.
Definition: Parameterised.h:41
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.
Definition: ShapeHandler.h:47