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);
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 haveSeenNeighs() const {
113  return myHaveSeenNeighs;
114  }
115 
117  return myHaveSeenAdditionalSpeedRestrictions;
118  }
119 
120  bool lefthand() const {
121  return myLefthand;
122  }
123 
124  double networkVersion() const {
125  return myNetworkVersion;
126  }
127 
128 protected:
130 
131 
140  virtual void myStartElement(int element,
141  const SUMOSAXAttributes& attrs);
142 
143 
151  virtual void myEndElement(int element);
153 
154 
155 protected:
156  void addParam(const SUMOSAXAttributes& attrs);
157 
161  virtual void addE1Detector(const SUMOSAXAttributes& attrs);
162 
166  virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs);
167 
171  virtual void addE2Detector(const SUMOSAXAttributes& attrs);
172 
176  void beginE3Detector(const SUMOSAXAttributes& attrs);
177 
181  void addE3Entry(const SUMOSAXAttributes& attrs);
182 
186  void addE3Exit(const SUMOSAXAttributes& attrs);
187 
189  virtual void endE3Detector();
190 
194  virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs);
195 
199  virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs);
200 
205  virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype);
206 
208  virtual void closeEdge();
209 
210 
211 protected:
214 
215 
216 private:
218  void beginEdgeParsing(const SUMOSAXAttributes& attrs);
219 
221  void addLane(const SUMOSAXAttributes& attrs);
222 
224  void addPOI(const SUMOSAXAttributes& attrs);
225 
227  void addPoly(const SUMOSAXAttributes& attrs);
228 
230  void addRequest(const SUMOSAXAttributes& attrs);
231 
233  void initJunctionLogic(const SUMOSAXAttributes& attrs);
234 
236  void initTrafficLightLogic(const SUMOSAXAttributes& attrs);
237 
239  void addPhase(const SUMOSAXAttributes& attrs);
240 
241 
243  virtual void openJunction(const SUMOSAXAttributes& attrs);
244 
245  void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*>& into, bool& ok);
246 
248  void addConnection(const SUMOSAXAttributes& attrs);
249 
250  virtual void openWAUT(const SUMOSAXAttributes& attrs);
251  void addWAUTSwitch(const SUMOSAXAttributes& attrs);
252  void addWAUTJunction(const SUMOSAXAttributes& attrs);
253 
255  void setLocation(const SUMOSAXAttributes& attrs);
256 
266  void addDistrict(const SUMOSAXAttributes& attrs);
267 
268 
279  void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
280 
284  void addRoundabout(const SUMOSAXAttributes& attrs);
285 
286 
287  void closeWAUT();
288 
290  LinkDirection parseLinkDir(const std::string& dir);
291 
293  LinkState parseLinkState(const std::string& state);
294 
295 
296 protected:
299 
302 
303 
306 
309 
312 
315 
317  std::string myCurrentDistrictID;
318 
321 
323  std::string myCurrentWAUTID;
324 
326  std::string myCurrentTypeID;
327 
330 
332  Boundary myOrigBoundary, myConvBoundary;
333 
335 
337 
339 
342 
345 
348 
351 
354 
357 
359  typedef std::map<std::string, std::pair<std::string, std::string> > JunctionGraph;
360  JunctionGraph myJunctionGraph;
361 
362 private:
364  NLHandler(const NLHandler& s);
365 
367  NLHandler& operator=(const NLHandler& s);
368 
369 };
370 
371 
372 
373 
374 #endif
375 
376 /****************************************************************************/
377 
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:301
virtual ~NLShapeHandler()
Destructor.
Definition: NLHandler.h:70
bool myHaveWarnedAboutDeprecatedLanes
Definition: NLHandler.h:336
ShapeHandler & operator=(const ShapeHandler &s)
bool myCurrentIsBroken
Definition: NLHandler.h:334
Position myNetworkOffset
The network offset.
Definition: NLHandler.h:329
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:305
Storage for geometrical objects.
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:317
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:320
The XML-Handler for network loading.
Definition: ShapeHandler.h:56
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:347
Boundary myOrigBoundary
The network&#39;s boundaries.
Definition: NLHandler.h:332
bool lefthand() const
Definition: NLHandler.h:120
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:311
std::vector< MSLane * > LaneVector
Definition of a lane vector.
Definition: NLHandler.h:87
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:360
void addPOI(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a POI
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:326
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:341
An upper class for objects with additional parameters.
Definition: Parameterised.h:51
double networkVersion() const
Definition: NLHandler.h:124
The XML-Handler for network loading.
Definition: NLHandler.h:84
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:359
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:323
bool haveSeenAdditionalSpeedRestrictions() const
Definition: NLHandler.h:116
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:344
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:308
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:353
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:356
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:213
bool haveSeenInternalEdge() const
Definition: NLHandler.h:108
The parent class for traffic light logics.
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:298
Builds trigger objects for microsim.
bool haveSeenNeighs() const
Definition: NLHandler.h:112
bool myLefthand
whether the loaded network was built for left hand traffic
Definition: NLHandler.h:350
Parameterised * myLastParameterised
Definition: NLHandler.h:338
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:314
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.
Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos)
get position for a given laneID
Definition: NLHandler.cpp:1403