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-2020 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>
29 #include "NLDiscreteEventBuilder.h"
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class NLContainer;
36 class NLDetectorBuilder;
39 class NLTriggerBuilder;
41 class MSRailSignal;
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
47 
48 
55 class NLShapeHandler : public ShapeHandler {
56 public:
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, double lanePosLat);
64 
65  virtual bool addLanePosParams() {
66  return true;
67  }
68 };
69 
70 
79 class NLHandler : public MSRouteHandler {
80 public:
82  typedef std::vector<MSLane*> LaneVector;
83 
84 public:
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 {
104  return myHaveSeenInternalEdge;
105  }
106 
107  bool haveSeenDefaultLength() const {
109  }
110 
111  bool haveSeenNeighs() const {
112  return myHaveSeenNeighs;
113  }
114 
117  }
118 
119  bool haveSeenMesoEdgeType() const {
120  return myHaveSeenMesoEdgeType;
121  }
122 
123  double networkVersion() const {
124  return myNetworkVersion;
125  }
126 
127 protected:
129 
130 
139  virtual void myStartElement(int element,
140  const SUMOSAXAttributes& attrs);
141 
142 
150  virtual void myEndElement(int element);
152 
153 
154 protected:
155  void addParam(const SUMOSAXAttributes& attrs);
156 
160  virtual void addE1Detector(const SUMOSAXAttributes& attrs);
161 
165  virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs);
166 
170  virtual void addE2Detector(const SUMOSAXAttributes& attrs);
171 
175  void beginE3Detector(const SUMOSAXAttributes& attrs);
176 
180  void addE3Entry(const SUMOSAXAttributes& attrs);
181 
185  void addE3Exit(const SUMOSAXAttributes& attrs);
186 
188  virtual void endE3Detector();
189 
193  virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs);
194 
198  virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs);
199 
204  virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype);
205 
209  virtual void addMesoEdgeType(const SUMOSAXAttributes& attrs);
210 
212  virtual void closeEdge();
213 
214 
215 protected:
218 
219 
220 private:
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 
239 
241  virtual void openJunction(const SUMOSAXAttributes& attrs);
242 
243  void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*>& into, bool& ok);
244 
246  void addConnection(const SUMOSAXAttributes& attrs);
247 
248  virtual void openWAUT(const SUMOSAXAttributes& attrs);
249  void addWAUTSwitch(const SUMOSAXAttributes& attrs);
250  void addWAUTJunction(const SUMOSAXAttributes& attrs);
251  void addPredecessorConstraint(const SUMOSAXAttributes& attrs);
253 
255  void setLocation(const SUMOSAXAttributes& attrs);
256 
266  void addDistrict(const SUMOSAXAttributes& attrs);
267 
268 
279  void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
280 
284  void addRoundabout(const SUMOSAXAttributes& attrs);
285 
286 
287  void closeWAUT();
288 
290  LinkDirection parseLinkDir(const std::string& dir);
291 
293  LinkState parseLinkState(const std::string& state);
294 
295 protected:
298 
301 
302 
305 
308 
311 
314 
316  std::string myCurrentDistrictID;
317 
320 
322  std::string myCurrentWAUTID;
323 
325  std::string myCurrentTypeID;
326 
329 
332 
334 
336 
338  std::vector<Parameterised*> myLastParameterised;
339 
342 
345 
348 
351 
354 
357 
360 
363 
365  typedef std::map<std::string, std::pair<std::string, std::string> > JunctionGraph;
367 
368 private:
370  NLHandler(const NLHandler& s);
371 
374 
375 };
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:89
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:115
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:678
bool myHaveSeenMesoEdgeType
whether edge type specific meso paramters were loaded
Definition: NLHandler.h:353
std::vector< Parameterised * > myLastParameterised
Definition: NLHandler.h:338
void addInsertionPredecessorConstraint(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1567
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:950
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1456
void addWAUTSwitch(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:638
virtual void addMesoEdgeType(const SUMOSAXAttributes &attrs)
Loads edge type specific meso parameters.
Definition: NLHandler.cpp:1474
bool myCurrentIsBroken
Definition: NLHandler.h:333
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
Definition: NLHandler.cpp:1158
void beginEdgeParsing(const SUMOSAXAttributes &attrs)
begins the processing of an edge
Definition: NLHandler.cpp:376
Position myNetworkOffset
The network offset.
Definition: NLHandler.h:328
Boundary myConvBoundary
Definition: NLHandler.h:331
bool myHaveSeenAdditionalSpeedRestrictions
whether additional files contained type-specific speed limits
Definition: NLHandler.h:350
bool haveSeenInternalEdge() const
Definition: NLHandler.h:103
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:316
void addPhase(const SUMOSAXAttributes &attrs)
adds a phase to the traffic lights logic currently build
Definition: NLHandler.cpp:758
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:325
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:905
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1434
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:322
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane * > &into, bool &ok)
Definition: NLHandler.cpp:572
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
Definition: NLHandler.cpp:470
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:703
Parameterised myLastEdgeParameters
Definition: NLHandler.h:337
virtual void myEndElement(int element)
Called when a closing tag occurs.
Definition: NLHandler.cpp:291
bool myHaveSeenDefaultLength
whether the loaded network contains edges with default lengths
Definition: NLHandler.h:344
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:307
virtual void addInstantE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:879
virtual void openJunction(const SUMOSAXAttributes &attrs)
opens a junction for processing
Definition: NLHandler.cpp:522
virtual void endE3Detector()
Builds of an e3 detector using collected values.
Definition: NLHandler.cpp:1498
bool myAmParsingTLLogicOrJunction
internal information whether a tls-logic is currently read
Definition: NLHandler.h:319
JunctionGraph myJunctionGraph
Definition: NLHandler.h:366
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:356
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1378
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:300
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:310
void initTrafficLightLogic(const SUMOSAXAttributes &attrs)
begins the reading of a traffic lights logic
Definition: NLHandler.cpp:718
void closeWAUT()
Definition: NLHandler.cpp:1508
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:341
NLHandler(const std::string &file, MSNet &net, NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder, NLEdgeControlBuilder &edgeBuilder, NLJunctionControlBuilder &junctionBuilder)
Constructor.
Definition: NLHandler.cpp:60
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1357
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: NLHandler.cpp:86
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition: NLHandler.h:347
NLHandler(const NLHandler &s)
double networkVersion() const
Definition: NLHandler.h:123
virtual void openWAUT(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:610
LinkState parseLinkState(const std::string &state)
Parses the given character into an enumeration typed link state.
Definition: NLHandler.cpp:1341
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:297
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:304
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:313
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:850
virtual ~NLHandler()
Destructor.
Definition: NLHandler.cpp:82
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:365
bool haveSeenDefaultLength() const
Definition: NLHandler.h:107
void addE3Exit(const SUMOSAXAttributes &attrs)
Adds an exit to the currently processed e3 detector.
Definition: NLHandler.cpp:1171
void beginE3Detector(const SUMOSAXAttributes &attrs)
Starts building of an e3 detector using the given specification.
Definition: NLHandler.cpp:1133
virtual void closeEdge()
Closes the process of building an edge.
Definition: NLHandler.cpp:452
NLHandler & operator=(const NLHandler &s)
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:217
bool haveSeenNeighs() const
Definition: NLHandler.h:111
void addPredecessorConstraint(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1539
MSRailSignal * myConstrainedSignal
rail signal for which constraints are being loaded
Definition: NLHandler.h:362
Boundary myOrigBoundary
The network's boundaries.
Definition: NLHandler.h:331
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:1331
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:359
void addWAUTJunction(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:657
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
Definition: NLHandler.cpp:926
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
Definition: NLHandler.cpp:1184
bool myHaveWarnedAboutInvalidTLType
Definition: NLHandler.h:335
void addParam(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:592
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:1230
bool haveSeenMesoEdgeType() const
Definition: NLHandler.h:119
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
NLShapeHandler(const std::string &file, ShapeContainer &sc)
Definition: NLHandler.h:57
virtual ~NLShapeHandler()
Destructor.
Definition: NLHandler.h:61
Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, double lanePosLat)
get position for a given laneID (Has to be implemented in all child)
Definition: NLHandler.cpp:1522
Builds trigger objects for microsim.
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
Encapsulated SAX-Attributes.
Storage for geometrical objects.
The XML-Handler for network loading.
Definition: ShapeHandler.h:47