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-2016 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, SUMOReal lanePos);
73 };
74 
75 
84 class NLHandler : public MSRouteHandler {
85 public:
87  typedef std::vector<MSLane*> LaneVector;
88 
89 public:
99  NLHandler(const std::string& file, MSNet& net,
100  NLDetectorBuilder& detBuilder, NLTriggerBuilder& triggerBuilder,
101  NLEdgeControlBuilder& edgeBuilder,
102  NLJunctionControlBuilder& junctionBuilder);
103 
104 
106  virtual ~NLHandler();
107 
108  bool haveSeenInternalEdge() const {
109  return myHaveSeenInternalEdge;
110  }
111 
112  bool lefthand() const {
113  return myLefthand;
114  }
115 
117  return myNetworkVersion;
118  }
119 
120 protected:
122 
123 
132  virtual void myStartElement(int element,
133  const SUMOSAXAttributes& attrs);
134 
135 
143  virtual void myEndElement(int element);
145 
146 
147 protected:
148  void addParam(const SUMOSAXAttributes& attrs);
149 
153  virtual void addE1Detector(const SUMOSAXAttributes& attrs);
154 
158  virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs);
159 
163  virtual void addE2Detector(const SUMOSAXAttributes& attrs);
164 
168  void beginE3Detector(const SUMOSAXAttributes& attrs);
169 
173  void addE3Entry(const SUMOSAXAttributes& attrs);
174 
178  void addE3Exit(const SUMOSAXAttributes& attrs);
179 
181  virtual void endE3Detector();
182 
186  virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs);
187 
191  virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs);
192 
197  virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype);
198 
200  virtual void closeEdge();
201 
202 
203 protected:
206 
207 
208 private:
210  void beginEdgeParsing(const SUMOSAXAttributes& attrs);
211 
213  void addLane(const SUMOSAXAttributes& attrs);
214 
216  void addPOI(const SUMOSAXAttributes& attrs);
217 
219  void addPoly(const SUMOSAXAttributes& attrs);
220 
222  void addRequest(const SUMOSAXAttributes& attrs);
223 
225  void initJunctionLogic(const SUMOSAXAttributes& attrs);
226 
228  void initTrafficLightLogic(const SUMOSAXAttributes& attrs);
229 
231  void addPhase(const SUMOSAXAttributes& attrs);
232 
233 
235  virtual void openJunction(const SUMOSAXAttributes& attrs);
236 
237  void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*>& into, bool& ok);
238 
240  void addConnection(const SUMOSAXAttributes& attrs);
241 
242  virtual void openWAUT(const SUMOSAXAttributes& attrs);
243  void addWAUTSwitch(const SUMOSAXAttributes& attrs);
244  void addWAUTJunction(const SUMOSAXAttributes& attrs);
245 
247  void setLocation(const SUMOSAXAttributes& attrs);
248 
258  void addDistrict(const SUMOSAXAttributes& attrs);
259 
260 
271  void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
272 
276  void addRoundabout(const SUMOSAXAttributes& attrs);
277 
278 
279  void closeWAUT();
280 
282  LinkDirection parseLinkDir(const std::string& dir);
283 
285  LinkState parseLinkState(const std::string& state);
286 
287 
288 protected:
291 
294 
295 
298 
301 
304 
307 
309  std::string myCurrentDistrictID;
310 
313 
315  std::string myCurrentWAUTID;
316 
318  std::string myCurrentTypeID;
319 
322 
324  Boundary myOrigBoundary, myConvBoundary;
325 
327 
329 
331 
334 
337 
340 
343 
345  typedef std::map<std::string, std::pair<std::string, std::string> > JunctionGraph;
346  JunctionGraph myJunctionGraph;
347 
348 private:
350  NLHandler(const NLHandler& s);
351 
353  NLHandler& operator=(const NLHandler& s);
354 
355 };
356 
357 
358 
359 
360 #endif
361 
362 /****************************************************************************/
363 
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:293
SUMOReal networkVersion() const
Definition: NLHandler.h:116
virtual ~NLShapeHandler()
Destructor.
Definition: NLHandler.h:70
void addPoly(const SUMOSAXAttributes &attrs)
adds a polygon
bool myHaveWarnedAboutDeprecatedLanes
Definition: NLHandler.h:328
ShapeHandler & operator=(const ShapeHandler &s)
bool myCurrentIsBroken
Definition: NLHandler.h:326
Position myNetworkOffset
The network offset.
Definition: NLHandler.h:321
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:297
SUMOReal myNetworkVersion
the loaded network version
Definition: NLHandler.h:339
Storage for geometrical objects.
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:309
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
The simulated network and simulation perfomer.
Definition: MSNet.h:94
bool myAmInTLLogicMode
internal information whether a tls-logic is currently read
Definition: NLHandler.h:312
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)...
Boundary myOrigBoundary
The network&#39;s boundaries.
Definition: NLHandler.h:324
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:303
std::vector< MSLane * > LaneVector
Definition of a lane vector.
Definition: NLHandler.h:87
Encapsulated SAX-Attributes.
Builder of microsim-junctions and tls.
Position getLanePos(const std::string &poiID, const std::string &laneID, SUMOReal lanePos)
get position for a given laneID
Definition: NLHandler.cpp:1252
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
JunctionGraph myJunctionGraph
Definition: NLHandler.h:346
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:318
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:333
An upper class for objects with additional parameters.
Definition: Parameterised.h:47
bool lefthand() const
Definition: NLHandler.h:112
The XML-Handler for network loading.
Definition: NLHandler.h:84
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:345
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:315
The XML-Handler for shapes loading network loading.
Definition: NLHandler.h:64
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:300
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:342
bool haveSeenInternalEdge() const
Definition: NLHandler.h:108
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:205
The parent class for traffic light logics.
#define SUMOReal
Definition: config.h:213
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:290
Builds trigger objects for microsim.
bool myLefthand
whether the loaded network was built for left hand traffic
Definition: NLHandler.h:336
Parameterised * myLastParameterised
Definition: NLHandler.h:330
void addPOI(const SUMOSAXAttributes &attrs)
adds a polygon
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:306
Parser and container for routes during their loading.
Interface for building edges.
virtual void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.