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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // The XML-Handler for network loading
19 /****************************************************************************/
20 #ifndef NLHandler_h
21 #define NLHandler_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <utils/geom/Boundary.h>
32 #include "NLDiscreteEventBuilder.h"
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class NLContainer;
39 class NLDetectorBuilder;
42 class NLTriggerBuilder;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
49 
50 
57 class NLShapeHandler : public ShapeHandler {
58 public:
59  NLShapeHandler(const std::string& file, ShapeContainer& sc) :
60  ShapeHandler(file, sc) {}
61 
63  virtual ~NLShapeHandler() {}
64 
65  Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat);
66 
67  virtual bool addLanePosParams() {
68  return true;
69  }
70 };
71 
72 
81 class NLHandler : public MSRouteHandler {
82 public:
84  typedef std::vector<MSLane*> LaneVector;
85 
86 public:
96  NLHandler(const std::string& file, MSNet& net,
97  NLDetectorBuilder& detBuilder, NLTriggerBuilder& triggerBuilder,
98  NLEdgeControlBuilder& edgeBuilder,
99  NLJunctionControlBuilder& junctionBuilder);
100 
101 
103  virtual ~NLHandler();
104 
105  bool haveSeenInternalEdge() const {
106  return myHaveSeenInternalEdge;
107  }
108 
109  bool haveSeenNeighs() const {
110  return myHaveSeenNeighs;
111  }
112 
114  return myHaveSeenAdditionalSpeedRestrictions;
115  }
116 
117  bool lefthand() const {
118  return myLefthand;
119  }
120 
121  double networkVersion() const {
122  return myNetworkVersion;
123  }
124 
125 protected:
127 
128 
137  virtual void myStartElement(int element,
138  const SUMOSAXAttributes& attrs);
139 
140 
148  virtual void myEndElement(int element);
150 
151 
152 protected:
153  void addParam(const SUMOSAXAttributes& attrs);
154 
158  virtual void addE1Detector(const SUMOSAXAttributes& attrs);
159 
163  virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs);
164 
168  virtual void addE2Detector(const SUMOSAXAttributes& attrs);
169 
173  void beginE3Detector(const SUMOSAXAttributes& attrs);
174 
178  void addE3Entry(const SUMOSAXAttributes& attrs);
179 
183  void addE3Exit(const SUMOSAXAttributes& attrs);
184 
186  virtual void endE3Detector();
187 
191  virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs);
192 
196  virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs);
197 
202  virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype);
203 
205  virtual void closeEdge();
206 
207 
208 protected:
211 
212 
213 private:
215  void beginEdgeParsing(const SUMOSAXAttributes& attrs);
216 
218  void addLane(const SUMOSAXAttributes& attrs);
219 
221  void addPOI(const SUMOSAXAttributes& attrs);
222 
224  void addPoly(const SUMOSAXAttributes& attrs);
225 
227  void addRequest(const SUMOSAXAttributes& attrs);
228 
230  void initJunctionLogic(const SUMOSAXAttributes& attrs);
231 
233  void initTrafficLightLogic(const SUMOSAXAttributes& attrs);
234 
236  void addPhase(const SUMOSAXAttributes& attrs);
237 
238 
240  virtual void openJunction(const SUMOSAXAttributes& attrs);
241 
242  void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*>& into, bool& ok);
243 
245  void addConnection(const SUMOSAXAttributes& attrs);
246 
247  virtual void openWAUT(const SUMOSAXAttributes& attrs);
248  void addWAUTSwitch(const SUMOSAXAttributes& attrs);
249  void addWAUTJunction(const SUMOSAXAttributes& attrs);
250 
252  void setLocation(const SUMOSAXAttributes& attrs);
253 
263  void addDistrict(const SUMOSAXAttributes& attrs);
264 
265 
276  void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
277 
281  void addRoundabout(const SUMOSAXAttributes& attrs);
282 
283 
284  void closeWAUT();
285 
287  LinkDirection parseLinkDir(const std::string& dir);
288 
290  LinkState parseLinkState(const std::string& state);
291 
292 protected:
295 
298 
299 
302 
305 
308 
311 
313  std::string myCurrentDistrictID;
314 
317 
319  std::string myCurrentWAUTID;
320 
322  std::string myCurrentTypeID;
323 
326 
328  Boundary myOrigBoundary, myConvBoundary;
329 
331 
333 
335  std::vector<Parameterised*> myLastParameterised;
336 
339 
342 
345 
348 
351 
354 
356  typedef std::map<std::string, std::pair<std::string, std::string> > JunctionGraph;
357  JunctionGraph myJunctionGraph;
358 
359 private:
361  NLHandler(const NLHandler& s);
362 
364  NLHandler& operator=(const NLHandler& s);
365 
366 };
367 
368 
369 
370 
371 #endif
372 
373 /****************************************************************************/
374 
Builds detectors for microsim.
NLShapeHandler(const std::string &file, ShapeContainer &sc)
Definition: NLHandler.h:59
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:297
virtual ~NLShapeHandler()
Destructor.
Definition: NLHandler.h:63
bool myHaveWarnedAboutDeprecatedLanes
Definition: NLHandler.h:332
virtual void myEndElement(int element)
Called when a closing tag occurs.
bool myCurrentIsBroken
Definition: NLHandler.h:330
Position myNetworkOffset
The network offset.
Definition: NLHandler.h:325
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:301
Storage for geometrical objects.
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:313
bool myAmParsingTLLogicOrJunction
internal information whether a tls-logic is currently read
Definition: NLHandler.h:316
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
The simulated network and simulation perfomer.
Definition: MSNet.h:84
The XML-Handler for network loading.
Definition: ShapeHandler.h:49
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:344
Boundary myOrigBoundary
The network&#39;s boundaries.
Definition: NLHandler.h:328
bool lefthand() const
Definition: NLHandler.h:117
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:307
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:67
std::vector< MSLane * > LaneVector
Definition of a lane vector.
Definition: NLHandler.h:84
Encapsulated SAX-Attributes.
Builder of microsim-junctions and tls.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
JunctionGraph myJunctionGraph
Definition: NLHandler.h:357
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:1423
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:322
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:338
An upper class for objects with additional parameters.
Definition: Parameterised.h:44
double networkVersion() const
Definition: NLHandler.h:121
The XML-Handler for network loading.
Definition: NLHandler.h:81
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:356
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:319
bool haveSeenAdditionalSpeedRestrictions() const
Definition: NLHandler.h:113
The XML-Handler for shapes loading network loading.
Definition: NLHandler.h:57
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition: NLHandler.h:341
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:304
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:350
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:353
std::vector< Parameterised * > myLastParameterised
Definition: NLHandler.h:335
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:210
bool haveSeenInternalEdge() const
Definition: NLHandler.h:105
The parent class for traffic light logics.
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:294
Parameterised myLastEdgeParameters
Definition: NLHandler.h:334
Builds trigger objects for microsim.
bool haveSeenNeighs() const
Definition: NLHandler.h:109
bool myLefthand
whether the loaded network was built for left hand traffic
Definition: NLHandler.h:347
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:310
Parser and container for routes during their loading.
Interface for building edges.