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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // The XML-Handler for network loading
19 /****************************************************************************/
20 #ifndef NLHandler_h
21 #define NLHandler_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <utils/geom/Boundary.h>
32 #include "NLDiscreteEventBuilder.h"
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class NLContainer;
39 class NLDetectorBuilder;
42 class NLTriggerBuilder;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
49 
50 
57 class NLShapeHandler : public ShapeHandler {
58 public:
59  NLShapeHandler(const std::string& file, ShapeContainer& sc) :
60  ShapeHandler(file, sc) {}
61 
63  virtual ~NLShapeHandler() {}
64 
65  Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat);
66 
67  virtual bool addLanePosParams() {
68  return true;
69  }
70 };
71 
72 
81 class NLHandler : public MSRouteHandler {
82 public:
84  typedef std::vector<MSLane*> LaneVector;
85 
86 public:
96  NLHandler(const std::string& file, MSNet& net,
97  NLDetectorBuilder& detBuilder, NLTriggerBuilder& triggerBuilder,
98  NLEdgeControlBuilder& edgeBuilder,
99  NLJunctionControlBuilder& junctionBuilder);
100 
101 
103  virtual ~NLHandler();
104 
105  bool haveSeenInternalEdge() const {
106  return myHaveSeenInternalEdge;
107  }
108 
109  bool haveSeenNeighs() const {
110  return myHaveSeenNeighs;
111  }
112 
115  }
116 
117  bool lefthand() const {
118  return myLefthand;
119  }
120 
121  double networkVersion() const {
122  return myNetworkVersion;
123  }
124 
125 protected:
127 
128 
137  virtual void myStartElement(int element,
138  const SUMOSAXAttributes& attrs);
139 
140 
148  virtual void myEndElement(int element);
150 
151 
152 protected:
153  void addParam(const SUMOSAXAttributes& attrs);
154 
158  virtual void addE1Detector(const SUMOSAXAttributes& attrs);
159 
163  virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs);
164 
168  virtual void addE2Detector(const SUMOSAXAttributes& attrs);
169 
173  void beginE3Detector(const SUMOSAXAttributes& attrs);
174 
178  void addE3Entry(const SUMOSAXAttributes& attrs);
179 
183  void addE3Exit(const SUMOSAXAttributes& attrs);
184 
186  virtual void endE3Detector();
187 
191  virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs);
192 
196  virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs);
197 
202  virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype);
203 
205  virtual void closeEdge();
206 
207 
208 protected:
211 
212 
213 private:
215  void beginEdgeParsing(const SUMOSAXAttributes& attrs);
216 
218  void addLane(const SUMOSAXAttributes& attrs);
219 
221  void addPOI(const SUMOSAXAttributes& attrs);
222 
224  void addPoly(const SUMOSAXAttributes& attrs);
225 
227  void addRequest(const SUMOSAXAttributes& attrs);
228 
230  void initJunctionLogic(const SUMOSAXAttributes& attrs);
231 
233  void initTrafficLightLogic(const SUMOSAXAttributes& attrs);
234 
236  void addPhase(const SUMOSAXAttributes& attrs);
237 
238 
240  virtual void openJunction(const SUMOSAXAttributes& attrs);
241 
242  void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*>& into, bool& ok);
243 
245  void addConnection(const SUMOSAXAttributes& attrs);
246 
247  virtual void openWAUT(const SUMOSAXAttributes& attrs);
248  void addWAUTSwitch(const SUMOSAXAttributes& attrs);
249  void addWAUTJunction(const SUMOSAXAttributes& attrs);
250 
252  void setLocation(const SUMOSAXAttributes& attrs);
253 
263  void addDistrict(const SUMOSAXAttributes& attrs);
264 
265 
276  void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
277 
281  void addRoundabout(const SUMOSAXAttributes& attrs);
282 
283 
284  void closeWAUT();
285 
287  LinkDirection parseLinkDir(const std::string& dir);
288 
290  LinkState parseLinkState(const std::string& state);
291 
292 protected:
295 
298 
299 
302 
305 
308 
311 
313  std::string myCurrentDistrictID;
314 
317 
319  std::string myCurrentWAUTID;
320 
322  std::string myCurrentTypeID;
323 
326 
329 
331 
333 
335  std::vector<Parameterised*> myLastParameterised;
336 
339 
342 
345 
348 
351 
354 
356  typedef std::map<std::string, std::pair<std::string, std::string> > JunctionGraph;
358 
359 private:
361  NLHandler(const NLHandler& s);
362 
364  NLHandler& operator=(const NLHandler& s);
365 
366 };
367 
368 
369 
370 
371 #endif
372 
373 /****************************************************************************/
374 
NLHandler::openJunction
virtual void openJunction(const SUMOSAXAttributes &attrs)
opens a junction for processing
Definition: NLHandler.cpp:478
NLHandler::myHaveSeenInternalEdge
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:338
Boundary.h
NLHandler::myLastEdgeParameters
Parameterised myLastEdgeParameters
Definition: NLHandler.h:334
NLHandler::LaneVector
std::vector< MSLane * > LaneVector
Definition of a lane vector.
Definition: NLHandler.h:84
NLShapeHandler
The XML-Handler for shapes loading network loading.
Definition: NLHandler.h:57
NLHandler::addRequest
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
Definition: NLHandler.cpp:632
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:43
NLEdgeControlBuilder
Interface for building edges.
Definition: NLEdgeControlBuilder.h:58
NLHandler::myLefthand
bool myLefthand
whether the loaded network was built for left hand traffic
Definition: NLHandler.h:347
NLHandler::networkVersion
double networkVersion() const
Definition: NLHandler.h:121
NLHandler::myCurrentDistrictID
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:313
NLHandler::myHaveSeenNeighs
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition: NLHandler.h:341
NLHandler::JunctionGraph
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:356
NLHandler::haveSeenAdditionalSpeedRestrictions
bool haveSeenAdditionalSpeedRestrictions() const
Definition: NLHandler.h:113
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:92
NLHandler::myTriggerBuilder
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:304
NLHandler::addInstantE1Detector
virtual void addInstantE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:835
NLHandler::addRouteProbeDetector
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
Definition: NLHandler.cpp:882
NLHandler::beginE3Detector
void beginE3Detector(const SUMOSAXAttributes &attrs)
Starts building of an e3 detector using the given specification.
Definition: NLHandler.cpp:1089
NLHandler::addPOI
void addPOI(const SUMOSAXAttributes &attrs)
adds a polygon
NLHandler::setLocation
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1311
NLHandler::addE2Detector
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:906
ShapeContainer
Storage for geometrical objects.
Definition: ShapeContainer.h:50
NLHandler::addDistrictEdge
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1386
NLHandler::addParam
void addParam(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:547
NLHandler::addDistrict
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1332
NLTriggerBuilder
Builds trigger objects for microsim.
Definition: NLTriggerBuilder.h:62
NLHandler::openWAUT
virtual void openWAUT(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:565
NLHandler::myNetIsLoaded
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:353
NLHandler::addPhase
void addPhase(const SUMOSAXAttributes &attrs)
adds a phase to the traffic lights logic currently build
Definition: NLHandler.cpp:712
LinkDirection
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
Definition: SUMOXMLDefinitions.h:1171
NLHandler::myLastParameterised
std::vector< Parameterised * > myLastParameterised
Definition: NLHandler.h:335
NLHandler::closeEdge
virtual void closeEdge()
Closes the process of building an edge.
Definition: NLHandler.cpp:408
NLHandler::myCurrentIsBroken
bool myCurrentIsBroken
Definition: NLHandler.h:330
NLHandler::parseLinkState
LinkState parseLinkState(const std::string &state)
Parses the given character into an enumeration typed link state.
Definition: NLHandler.cpp:1295
NLHandler::myEdgeControlBuilder
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:307
NLHandler::haveSeenInternalEdge
bool haveSeenInternalEdge() const
Definition: NLHandler.h:105
NLHandler::myJunctionGraph
JunctionGraph myJunctionGraph
Definition: NLHandler.h:357
NLHandler::myEndElement
virtual void myEndElement(int element)
Called when a closing tag occurs.
Definition: NLHandler.cpp:251
NLHandler::myHaveWarnedAboutInvalidTLType
bool myHaveWarnedAboutInvalidTLType
Definition: NLHandler.h:332
NLHandler::addConnection
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:1185
NLHandler::myNetworkOffset
Position myNetworkOffset
The network offset.
Definition: NLHandler.h:325
NLJunctionControlBuilder
Builder of microsim-junctions and tls.
Definition: NLJunctionControlBuilder.h:63
NLHandler::myConvBoundary
Boundary myConvBoundary
Definition: NLHandler.h:328
NLDiscreteEventBuilder
Definition: NLDiscreteEventBuilder.h:46
NLHandler::myActionBuilder
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:294
NLHandler::addEdgeLaneMeanData
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
Definition: NLHandler.cpp:1140
LinkState
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
Definition: SUMOXMLDefinitions.h:1132
NLHandler::parseLinkDir
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:1285
NLHandler::myCurrentWAUTID
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:319
NLHandler::addE1Detector
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:806
NLHandler::myJunctionControlBuilder
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:310
NLHandler::haveSeenNeighs
bool haveSeenNeighs() const
Definition: NLHandler.h:109
NLHandler::NLHandler
NLHandler(const std::string &file, MSNet &net, NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder, NLEdgeControlBuilder &edgeBuilder, NLJunctionControlBuilder &junctionBuilder)
Constructor.
Definition: NLHandler.cpp:57
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
NLHandler::addLane
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
Definition: NLHandler.cpp:426
NLHandler::addPoly
void addPoly(const SUMOSAXAttributes &attrs)
adds a polygon
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
NLHandler::~NLHandler
virtual ~NLHandler()
Destructor.
Definition: NLHandler.cpp:78
NLHandler::addWAUTJunction
void addWAUTJunction(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:611
MSTrafficLightLogic
The parent class for traffic light logics.
Definition: MSTrafficLightLogic.h:56
NLHandler::lefthand
bool lefthand() const
Definition: NLHandler.h:117
NLHandler::myCurrentIsInternalToSkip
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:297
NLHandler::myOrigBoundary
Boundary myOrigBoundary
The network's boundaries.
Definition: NLHandler.h:328
NLHandler::myNet
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:210
NLHandler::addE3Entry
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
Definition: NLHandler.cpp:1114
NLHandler::myDetectorBuilder
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:301
NLHandler::myCurrentTypeID
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:322
NLHandler::initJunctionLogic
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:657
NLHandler::addVTypeProbeDetector
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:861
NLShapeHandler::getLanePos
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:1451
NLShapeHandler::addLanePosParams
virtual bool addLanePosParams()
Whether some input attributes shall be automatically added as params (Can be implemented in all child...
Definition: NLHandler.h:67
NLHandler::myStartElement
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: NLHandler.cpp:82
MSRouteHandler
Parser and container for routes during their loading.
Definition: MSRouteHandler.h:54
NLHandler::beginEdgeParsing
void beginEdgeParsing(const SUMOSAXAttributes &attrs)
begins the processing of an edge
Definition: NLHandler.cpp:333
NLHandler::endE3Detector
virtual void endE3Detector()
Builds of an e3 detector using collected values.
Definition: NLHandler.cpp:1427
NLHandler::closeWAUT
void closeWAUT()
Definition: NLHandler.cpp:1437
NLHandler
The XML-Handler for network loading.
Definition: NLHandler.h:81
config.h
NLHandler::initTrafficLightLogic
void initTrafficLightLogic(const SUMOSAXAttributes &attrs)
begins the reading of a traffic lights logic
Definition: NLHandler.cpp:672
ShapeHandler
The XML-Handler for network loading.
Definition: ShapeHandler.h:50
NLShapeHandler::~NLShapeHandler
virtual ~NLShapeHandler()
Destructor.
Definition: NLHandler.h:63
ShapeHandler.h
NLShapeHandler::NLShapeHandler
NLShapeHandler(const std::string &file, ShapeContainer &sc)
Definition: NLHandler.h:59
NLHandler::myAmParsingTLLogicOrJunction
bool myAmParsingTLLogicOrJunction
internal information whether a tls-logic is currently read
Definition: NLHandler.h:316
NLDiscreteEventBuilder.h
NLHandler::operator=
NLHandler & operator=(const NLHandler &s)
MSRouteHandler.h
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:57
NLHandler::addWAUTSwitch
void addWAUTSwitch(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:592
NLHandler::myHaveSeenAdditionalSpeedRestrictions
bool myHaveSeenAdditionalSpeedRestrictions
whether additional files contained type-specific speed limits
Definition: NLHandler.h:344
NLHandler::myNetworkVersion
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:350
NLDetectorBuilder
Builds detectors for microsim.
Definition: NLDetectorBuilder.h:56
NLHandler::parseLanes
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane * > &into, bool &ok)
Definition: NLHandler.cpp:527
NLHandler::addRoundabout
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1408
NLHandler::addE3Exit
void addE3Exit(const SUMOSAXAttributes &attrs)
Adds an exit to the currently processed e3 detector.
Definition: NLHandler.cpp:1127