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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // The XML-Handler for network loading
21 /****************************************************************************/
22 #ifndef NLHandler_h
23 #define NLHandler_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <utils/geom/Boundary.h>
38 #include "NLDiscreteEventBuilder.h"
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class NLContainer;
45 class NLDetectorBuilder;
48 class NLTriggerBuilder;
50 
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
55 
56 
63 class NLShapeHandler : public ShapeHandler {
64 public:
65  NLShapeHandler(const std::string& file, ShapeContainer& sc) :
66  ShapeHandler(file, sc) {}
67 
69  virtual ~NLShapeHandler() {}
70 
71  Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat);
72 
73  virtual bool addLanePosParams() {
74  return true;
75  }
76 };
77 
78 
87 class NLHandler : public MSRouteHandler {
88 public:
90  typedef std::vector<MSLane*> LaneVector;
91 
92 public:
102  NLHandler(const std::string& file, MSNet& net,
103  NLDetectorBuilder& detBuilder, NLTriggerBuilder& triggerBuilder,
104  NLEdgeControlBuilder& edgeBuilder,
105  NLJunctionControlBuilder& junctionBuilder);
106 
107 
109  virtual ~NLHandler();
110 
111  bool haveSeenInternalEdge() const {
112  return myHaveSeenInternalEdge;
113  }
114 
115  bool haveSeenNeighs() const {
116  return myHaveSeenNeighs;
117  }
118 
120  return myHaveSeenAdditionalSpeedRestrictions;
121  }
122 
123  bool lefthand() const {
124  return myLefthand;
125  }
126 
127  double networkVersion() const {
128  return myNetworkVersion;
129  }
130 
131 protected:
133 
134 
143  virtual void myStartElement(int element,
144  const SUMOSAXAttributes& attrs);
145 
146 
154  virtual void myEndElement(int element);
156 
157 
158 protected:
159  void addParam(const SUMOSAXAttributes& attrs);
160 
164  virtual void addE1Detector(const SUMOSAXAttributes& attrs);
165 
169  virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs);
170 
174  virtual void addE2Detector(const SUMOSAXAttributes& attrs);
175 
179  void beginE3Detector(const SUMOSAXAttributes& attrs);
180 
184  void addE3Entry(const SUMOSAXAttributes& attrs);
185 
189  void addE3Exit(const SUMOSAXAttributes& attrs);
190 
192  virtual void endE3Detector();
193 
197  virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs);
198 
202  virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs);
203 
208  virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype);
209 
211  virtual void closeEdge();
212 
213 
214 protected:
217 
218 
219 private:
221  void beginEdgeParsing(const SUMOSAXAttributes& attrs);
222 
224  void addLane(const SUMOSAXAttributes& attrs);
225 
227  void addPOI(const SUMOSAXAttributes& attrs);
228 
230  void addPoly(const SUMOSAXAttributes& attrs);
231 
233  void addRequest(const SUMOSAXAttributes& attrs);
234 
236  void initJunctionLogic(const SUMOSAXAttributes& attrs);
237 
239  void initTrafficLightLogic(const SUMOSAXAttributes& attrs);
240 
242  void addPhase(const SUMOSAXAttributes& attrs);
243 
244 
246  virtual void openJunction(const SUMOSAXAttributes& attrs);
247 
248  void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*>& into, bool& ok);
249 
251  void addConnection(const SUMOSAXAttributes& attrs);
252 
253  virtual void openWAUT(const SUMOSAXAttributes& attrs);
254  void addWAUTSwitch(const SUMOSAXAttributes& attrs);
255  void addWAUTJunction(const SUMOSAXAttributes& attrs);
256 
258  void setLocation(const SUMOSAXAttributes& attrs);
259 
269  void addDistrict(const SUMOSAXAttributes& attrs);
270 
271 
282  void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
283 
287  void addRoundabout(const SUMOSAXAttributes& attrs);
288 
289 
290  void closeWAUT();
291 
293  LinkDirection parseLinkDir(const std::string& dir);
294 
296  LinkState parseLinkState(const std::string& state);
297 
298 
299 protected:
302 
305 
306 
309 
312 
315 
318 
320  std::string myCurrentDistrictID;
321 
324 
326  std::string myCurrentWAUTID;
327 
329  std::string myCurrentTypeID;
330 
333 
335  Boundary myOrigBoundary, myConvBoundary;
336 
338 
340 
342 
345 
348 
351 
354 
357 
360 
362  typedef std::map<std::string, std::pair<std::string, std::string> > JunctionGraph;
363  JunctionGraph myJunctionGraph;
364 
365 private:
367  NLHandler(const NLHandler& s);
368 
370  NLHandler& operator=(const NLHandler& s);
371 
372 };
373 
374 
375 
376 
377 #endif
378 
379 /****************************************************************************/
380 
Builds detectors for microsim.
NLShapeHandler(const std::string &file, ShapeContainer &sc)
Definition: NLHandler.h:65
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:304
virtual ~NLShapeHandler()
Destructor.
Definition: NLHandler.h:69
bool myHaveWarnedAboutDeprecatedLanes
Definition: NLHandler.h:339
virtual void myEndElement(int element)
Called when a closing tag occurs.
bool myCurrentIsBroken
Definition: NLHandler.h:337
Position myNetworkOffset
The network offset.
Definition: NLHandler.h:332
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:308
Storage for geometrical objects.
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:320
bool myAmParsingTLLogicOrJunction
internal information whether a tls-logic is currently read
Definition: NLHandler.h:323
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
The simulated network and simulation perfomer.
Definition: MSNet.h:90
The XML-Handler for network loading.
Definition: ShapeHandler.h:55
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:350
Boundary myOrigBoundary
The network&#39;s boundaries.
Definition: NLHandler.h:335
bool lefthand() const
Definition: NLHandler.h:123
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:314
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:73
std::vector< MSLane * > LaneVector
Definition of a lane vector.
Definition: NLHandler.h:90
Encapsulated SAX-Attributes.
Builder of microsim-junctions and tls.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
JunctionGraph myJunctionGraph
Definition: NLHandler.h:363
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:1395
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:329
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:344
An upper class for objects with additional parameters.
Definition: Parameterised.h:50
double networkVersion() const
Definition: NLHandler.h:127
The XML-Handler for network loading.
Definition: NLHandler.h:87
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:362
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:326
bool haveSeenAdditionalSpeedRestrictions() const
Definition: NLHandler.h:119
The XML-Handler for shapes loading network loading.
Definition: NLHandler.h:63
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition: NLHandler.h:347
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:311
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:356
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:359
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:216
bool haveSeenInternalEdge() const
Definition: NLHandler.h:111
The parent class for traffic light logics.
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:301
Builds trigger objects for microsim.
bool haveSeenNeighs() const
Definition: NLHandler.h:115
bool myLefthand
whether the loaded network was built for left hand traffic
Definition: NLHandler.h:353
Parameterised * myLastParameterised
Definition: NLHandler.h:341
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:317
Parser and container for routes during their loading.
Interface for building edges.