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-2015 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 <xercesc/sax/HandlerBase.hpp>
37 #include <xercesc/sax/SAXException.hpp>
38 #include <xercesc/sax/AttributeList.hpp>
39 #include <utils/common/SUMOTime.h>
43 #include <microsim/MSLink.h>
47 #include <microsim/MSBitSetLogic.h>
48 #include "NLBuilder.h"
49 #include "NLDiscreteEventBuilder.h"
50 
51 
52 
53 // ===========================================================================
54 // class declarations
55 // ===========================================================================
56 class NLContainer;
57 class NLDetectorBuilder;
58 class NLTriggerBuilder;
60 
61 
62 // ===========================================================================
63 // class definitions
64 // ===========================================================================
65 
66 
73 class NLShapeHandler : public ShapeHandler {
74 public:
75  NLShapeHandler(const std::string& file, ShapeContainer& sc) :
76  ShapeHandler(file, sc) {}
77 
79  virtual ~NLShapeHandler() {}
80 
81  Position getLanePos(const std::string& poiID, const std::string& laneID, SUMOReal lanePos);
82 };
83 
84 
93 class NLHandler : public MSRouteHandler {
94 public:
96  typedef std::vector<MSLane*> LaneVector;
97 
98 public:
108  NLHandler(const std::string& file, MSNet& net,
109  NLDetectorBuilder& detBuilder, NLTriggerBuilder& triggerBuilder,
110  NLEdgeControlBuilder& edgeBuilder,
111  NLJunctionControlBuilder& junctionBuilder);
112 
113 
115  virtual ~NLHandler();
116 
117  bool haveSeenInternalEdge() const {
118  return myHaveSeenInternalEdge;
119  }
120 
121 protected:
123 
124 
133  virtual void myStartElement(int element,
134  const SUMOSAXAttributes& attrs);
135 
136 
144  virtual void myEndElement(int element);
146 
147 
148 protected:
149  void addParam(const SUMOSAXAttributes& attrs);
150 
154  virtual void addE1Detector(const SUMOSAXAttributes& attrs);
155 
159  virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs);
160 
164  virtual void addE2Detector(const SUMOSAXAttributes& attrs);
165 
169  void beginE3Detector(const SUMOSAXAttributes& attrs);
170 
174  void addE3Entry(const SUMOSAXAttributes& attrs);
175 
179  void addE3Exit(const SUMOSAXAttributes& attrs);
180 
182  virtual void endE3Detector();
183 
187  virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs);
188 
192  virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs);
193 
198  virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype);
199 
201  virtual void closeEdge();
202 
203 
204 protected:
207 
208 
209 private:
211  void beginEdgeParsing(const SUMOSAXAttributes& attrs);
212 
214  void addLane(const SUMOSAXAttributes& attrs);
215 
217  void addPOI(const SUMOSAXAttributes& attrs);
218 
220  void addPoly(const SUMOSAXAttributes& attrs);
221 
223  void addRequest(const SUMOSAXAttributes& attrs);
224 
226  void initJunctionLogic(const SUMOSAXAttributes& attrs);
227 
229  void initTrafficLightLogic(const SUMOSAXAttributes& attrs);
230 
232  void addPhase(const SUMOSAXAttributes& attrs);
233 
234 
236  virtual void openJunction(const SUMOSAXAttributes& attrs);
237 
238  void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*>& into, bool& ok);
239 
241  void addConnection(const SUMOSAXAttributes& attrs);
242 
243  virtual void openWAUT(const SUMOSAXAttributes& attrs);
244  void addWAUTSwitch(const SUMOSAXAttributes& attrs);
245  void addWAUTJunction(const SUMOSAXAttributes& attrs);
246 
248  void setLocation(const SUMOSAXAttributes& attrs);
249 
259  void addDistrict(const SUMOSAXAttributes& attrs);
260 
261 
272  void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
273 
277  void addRoundabout(const SUMOSAXAttributes& attrs);
278 
279 
280  void closeWAUT();
281 
283  LinkDirection parseLinkDir(const std::string& dir);
284 
286  LinkState parseLinkState(const std::string& state);
287 
288 
289 protected:
292 
295 
296 
299 
302 
305 
308 
310  std::string myCurrentDistrictID;
311 
314 
316  std::string myCurrentWAUTID;
317 
320 
323 
325 
327 
329 
332 
335 
337  typedef std::map<std::string, std::pair<std::string, std::string> > JunctionGraph;
338  JunctionGraph myJunctionGraph;
339 
340 private:
342  NLHandler(const NLHandler& s);
343 
345  NLHandler& operator=(const NLHandler& s);
346 
347 };
348 
349 
350 
351 
352 #endif
353 
354 /****************************************************************************/
355 
void beginE3Detector(const SUMOSAXAttributes &attrs)
Starts building of an e3 detector using the given specification.
Definition: NLHandler.cpp:800
void addPoly(const SUMOSAXAttributes &attrs)
adds a polygon
void addWAUTJunction(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:539
Builds detectors for microsim.
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:747
NLShapeHandler(const std::string &file, ShapeContainer &sc)
Definition: NLHandler.h:75
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:294
virtual ~NLShapeHandler()
Destructor.
Definition: NLHandler.h:79
bool myHaveWarnedAboutDeprecatedLanes
Definition: NLHandler.h:326
virtual void openWAUT(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:493
bool myCurrentIsBroken
Definition: NLHandler.h:324
Position myNetworkOffset
The network offset.
Definition: NLHandler.h:319
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane * > &into, bool &ok)
Definition: NLHandler.cpp:456
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:704
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1099
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:298
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:650
Storage for geometrical objects.
NLHandler(const std::string &file, MSNet &net, NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder, NLEdgeControlBuilder &edgeBuilder, NLJunctionControlBuilder &junctionBuilder)
Constructor.
Definition: NLHandler.cpp:68
void beginEdgeParsing(const SUMOSAXAttributes &attrs)
begins the processing of an edge
Definition: NLHandler.cpp:267
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:310
virtual void endE3Detector()
Builds of an e3 detector using collected values.
Definition: NLHandler.cpp:1118
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:313
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)...
void closeWAUT()
Definition: NLHandler.cpp:1128
void addParam(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:476
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1027
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1006
Boundary myOrigBoundary
The network's boundaries.
Definition: NLHandler.h:322
virtual void openJunction(const SUMOSAXAttributes &attrs)
opens a junction for processing
Definition: NLHandler.cpp:406
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:304
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
Definition: NLHandler.cpp:823
std::vector< MSLane * > LaneVector
Definition of a lane vector.
Definition: NLHandler.h:96
Encapsulated SAX-Attributes.
void addE3Exit(const SUMOSAXAttributes &attrs)
Adds an exit to the currently processed e3 detector.
Definition: NLHandler.cpp:836
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:1142
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void addWAUTSwitch(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:520
JunctionGraph myJunctionGraph
Definition: NLHandler.h:338
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
Definition: NLHandler.cpp:560
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:884
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: NLHandler.cpp:90
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:331
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:980
An upper class for objects with additional parameters.
Definition: Parameterised.h:47
The XML-Handler for network loading.
Definition: NLHandler.h:93
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:337
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:316
virtual void addInstantE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:679
virtual void closeEdge()
Closes the process of building an edge.
Definition: NLHandler.cpp:343
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
Definition: NLHandler.cpp:724
The XML-Handler for shapes loading network loading.
Definition: NLHandler.h:73
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
Definition: NLHandler.cpp:359
virtual ~NLHandler()
Destructor.
Definition: NLHandler.cpp:86
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:301
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:334
bool haveSeenInternalEdge() const
Definition: NLHandler.h:117
NLHandler & operator=(const NLHandler &s)
Boundary myConvBoundary
Definition: NLHandler.h:322
void addPhase(const SUMOSAXAttributes &attrs)
adds a phase to the traffic lights logic currently build
Definition: NLHandler.cpp:624
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1077
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:206
LinkState parseLinkState(const std::string &state)
Parses the given character into an enumeration typed link state.
Definition: NLHandler.cpp:990
The parent class for traffic light logics.
#define SUMOReal
Definition: config.h:218
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:291
virtual void myEndElement(int element)
Called when a closing tag occurs.
Definition: NLHandler.cpp:208
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
Definition: NLHandler.cpp:849
Builds trigger objects for microsim.
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:587
Parameterised * myLastParameterised
Definition: NLHandler.h:328
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:307
Parser and container for routes during their loading.
void initTrafficLightLogic(const SUMOSAXAttributes &attrs)
begins the reading of a traffic lights logic
Definition: NLHandler.cpp:601
Interface for building edges.
void addPOI(const SUMOSAXAttributes &attrs)
adds a polygon