SUMO - Simulation of Urban MObility
NLHandler.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // The XML-Handler for network loading
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef NLHandler_h
24 #define NLHandler_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <utils/geom/Boundary.h>
39 #include "NLDiscreteEventBuilder.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class NLContainer;
46 class NLDetectorBuilder;
49 class NLTriggerBuilder;
51 
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
56 
57 
64 class NLShapeHandler : public ShapeHandler {
65 public:
66  NLShapeHandler(const std::string& file, ShapeContainer& sc) :
67  ShapeHandler(file, sc) {}
68 
70  virtual ~NLShapeHandler() {}
71 
72  Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat);
73 
74  virtual bool addLanePosParams() {
75  return true;
76  }
77 };
78 
79 
88 class NLHandler : public MSRouteHandler {
89 public:
91  typedef std::vector<MSLane*> LaneVector;
92 
93 public:
103  NLHandler(const std::string& file, MSNet& net,
104  NLDetectorBuilder& detBuilder, NLTriggerBuilder& triggerBuilder,
105  NLEdgeControlBuilder& edgeBuilder,
106  NLJunctionControlBuilder& junctionBuilder);
107 
108 
110  virtual ~NLHandler();
111 
112  bool haveSeenInternalEdge() const {
113  return myHaveSeenInternalEdge;
114  }
115 
116  bool haveSeenNeighs() const {
117  return myHaveSeenNeighs;
118  }
119 
121  return myHaveSeenAdditionalSpeedRestrictions;
122  }
123 
124  bool lefthand() const {
125  return myLefthand;
126  }
127 
128  double networkVersion() const {
129  return myNetworkVersion;
130  }
131 
132 protected:
134 
135 
144  virtual void myStartElement(int element,
145  const SUMOSAXAttributes& attrs);
146 
147 
155  virtual void myEndElement(int element);
157 
158 
159 protected:
160  void addParam(const SUMOSAXAttributes& attrs);
161 
165  virtual void addE1Detector(const SUMOSAXAttributes& attrs);
166 
170  virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs);
171 
175  virtual void addE2Detector(const SUMOSAXAttributes& attrs);
176 
180  void beginE3Detector(const SUMOSAXAttributes& attrs);
181 
185  void addE3Entry(const SUMOSAXAttributes& attrs);
186 
190  void addE3Exit(const SUMOSAXAttributes& attrs);
191 
193  virtual void endE3Detector();
194 
198  virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs);
199 
203  virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs);
204 
209  virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype);
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 addPOI(const SUMOSAXAttributes& attrs);
229 
231  void addPoly(const SUMOSAXAttributes& attrs);
232 
234  void addRequest(const SUMOSAXAttributes& attrs);
235 
237  void initJunctionLogic(const SUMOSAXAttributes& attrs);
238 
240  void initTrafficLightLogic(const SUMOSAXAttributes& attrs);
241 
243  void addPhase(const SUMOSAXAttributes& attrs);
244 
245 
247  virtual void openJunction(const SUMOSAXAttributes& attrs);
248 
249  void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*>& into, bool& ok);
250 
252  void addConnection(const SUMOSAXAttributes& attrs);
253 
254  virtual void openWAUT(const SUMOSAXAttributes& attrs);
255  void addWAUTSwitch(const SUMOSAXAttributes& attrs);
256  void addWAUTJunction(const SUMOSAXAttributes& attrs);
257 
259  void setLocation(const SUMOSAXAttributes& attrs);
260 
270  void addDistrict(const SUMOSAXAttributes& attrs);
271 
272 
283  void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
284 
288  void addRoundabout(const SUMOSAXAttributes& attrs);
289 
290 
291  void closeWAUT();
292 
294  LinkDirection parseLinkDir(const std::string& dir);
295 
297  LinkState parseLinkState(const std::string& state);
298 
299 
300 protected:
303 
306 
307 
310 
313 
316 
319 
321  std::string myCurrentDistrictID;
322 
325 
327  std::string myCurrentWAUTID;
328 
330  std::string myCurrentTypeID;
331 
334 
336  Boundary myOrigBoundary, myConvBoundary;
337 
339 
341 
343 
346 
349 
352 
355 
358 
361 
363  typedef std::map<std::string, std::pair<std::string, std::string> > JunctionGraph;
364  JunctionGraph myJunctionGraph;
365 
366 private:
368  NLHandler(const NLHandler& s);
369 
371  NLHandler& operator=(const NLHandler& s);
372 
373 };
374 
375 
376 
377 
378 #endif
379 
380 /****************************************************************************/
381 
Builds detectors for microsim.
NLShapeHandler(const std::string &file, ShapeContainer &sc)
Definition: NLHandler.h:66
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:305
virtual ~NLShapeHandler()
Destructor.
Definition: NLHandler.h:70
bool myHaveWarnedAboutDeprecatedLanes
Definition: NLHandler.h:340
double networkVersion() const
Definition: NLHandler.h:128
virtual void myEndElement(int element)
Called when a closing tag occurs.
bool myCurrentIsBroken
Definition: NLHandler.h:338
Position myNetworkOffset
The network offset.
Definition: NLHandler.h:333
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:309
Storage for geometrical objects.
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:321
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
The simulated network and simulation perfomer.
Definition: MSNet.h:89
bool myAmInTLLogicMode
internal information whether a tls-logic is currently read
Definition: NLHandler.h:324
The XML-Handler for network loading.
Definition: ShapeHandler.h:56
bool haveSeenAdditionalSpeedRestrictions() const
Definition: NLHandler.h:120
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
bool myHaveSeenAdditionalSpeedRestrictions
whether additional files contained type-specific speed limits
Definition: NLHandler.h:351
Boundary myOrigBoundary
The network&#39;s boundaries.
Definition: NLHandler.h:336
bool haveSeenNeighs() const
Definition: NLHandler.h:116
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:315
ShapeHandler & operator=(const ShapeHandler &s)=delete
invalidate assignment operator
virtual bool addLanePosParams()
Whether some input attributes shall be automatically added as params.
Definition: NLHandler.h:74
std::vector< MSLane * > LaneVector
Definition of a lane vector.
Definition: NLHandler.h:91
Encapsulated SAX-Attributes.
Builder of microsim-junctions and tls.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
JunctionGraph myJunctionGraph
Definition: NLHandler.h:364
void addPOI(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a POI
Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, double lanePosLat)
get position for a given laneID
Definition: NLHandler.cpp:1393
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:330
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:345
An upper class for objects with additional parameters.
Definition: Parameterised.h:51
bool lefthand() const
Definition: NLHandler.h:124
The XML-Handler for network loading.
Definition: NLHandler.h:88
void addPoly(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a polygon
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:363
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:327
The XML-Handler for shapes loading network loading.
Definition: NLHandler.h:64
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition: NLHandler.h:348
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:312
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:357
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:360
bool haveSeenInternalEdge() const
Definition: NLHandler.h:112
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:217
The parent class for traffic light logics.
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:302
Builds trigger objects for microsim.
bool myLefthand
whether the loaded network was built for left hand traffic
Definition: NLHandler.h:354
Parameterised * myLastParameterised
Definition: NLHandler.h:342
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:318
Parser and container for routes during their loading.
Interface for building edges.