Eclipse 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-2019 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 /****************************************************************************/
17 // The XML-Handler for network loading
18 /****************************************************************************/
19 #ifndef NLHandler_h
20 #define NLHandler_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <utils/geom/Boundary.h>
31 #include "NLDiscreteEventBuilder.h"
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class NLContainer;
38 class NLDetectorBuilder;
41 class NLTriggerBuilder;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
48 
49 
56 class NLShapeHandler : public ShapeHandler {
57 public:
58  NLShapeHandler(const std::string& file, ShapeContainer& sc) :
59  ShapeHandler(file, sc) {}
60 
62  virtual ~NLShapeHandler() {}
63 
64  Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat);
65 
66  virtual bool addLanePosParams() {
67  return true;
68  }
69 };
70 
71 
80 class NLHandler : public MSRouteHandler {
81 public:
83  typedef std::vector<MSLane*> LaneVector;
84 
85 public:
95  NLHandler(const std::string& file, MSNet& net,
96  NLDetectorBuilder& detBuilder, NLTriggerBuilder& triggerBuilder,
97  NLEdgeControlBuilder& edgeBuilder,
98  NLJunctionControlBuilder& junctionBuilder);
99 
100 
102  virtual ~NLHandler();
103 
104  bool haveSeenInternalEdge() const {
105  return myHaveSeenInternalEdge;
106  }
107 
108  bool haveSeenNeighs() const {
109  return myHaveSeenNeighs;
110  }
111 
114  }
115 
116  bool lefthand() const {
117  return myLefthand;
118  }
119 
120  double networkVersion() const {
121  return myNetworkVersion;
122  }
123 
124 protected:
126 
127 
136  virtual void myStartElement(int element,
137  const SUMOSAXAttributes& attrs);
138 
139 
147  virtual void myEndElement(int element);
149 
150 
151 protected:
152  void addParam(const SUMOSAXAttributes& attrs);
153 
157  virtual void addE1Detector(const SUMOSAXAttributes& attrs);
158 
162  virtual void addInstantE1Detector(const SUMOSAXAttributes& attrs);
163 
167  virtual void addE2Detector(const SUMOSAXAttributes& attrs);
168 
172  void beginE3Detector(const SUMOSAXAttributes& attrs);
173 
177  void addE3Entry(const SUMOSAXAttributes& attrs);
178 
182  void addE3Exit(const SUMOSAXAttributes& attrs);
183 
185  virtual void endE3Detector();
186 
190  virtual void addVTypeProbeDetector(const SUMOSAXAttributes& attrs);
191 
195  virtual void addRouteProbeDetector(const SUMOSAXAttributes& attrs);
196 
201  virtual void addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype);
202 
204  virtual void closeEdge();
205 
206 
207 protected:
210 
211 
212 private:
214  void beginEdgeParsing(const SUMOSAXAttributes& attrs);
215 
217  void addLane(const SUMOSAXAttributes& attrs);
218 
220  void addRequest(const SUMOSAXAttributes& attrs);
221 
223  void initJunctionLogic(const SUMOSAXAttributes& attrs);
224 
226  void initTrafficLightLogic(const SUMOSAXAttributes& attrs);
227 
229  void addPhase(const SUMOSAXAttributes& attrs);
230 
231 
233  virtual void openJunction(const SUMOSAXAttributes& attrs);
234 
235  void parseLanes(const std::string& junctionID, const std::string& def, std::vector<MSLane*>& into, bool& ok);
236 
238  void addConnection(const SUMOSAXAttributes& attrs);
239 
240  virtual void openWAUT(const SUMOSAXAttributes& attrs);
241  void addWAUTSwitch(const SUMOSAXAttributes& attrs);
242  void addWAUTJunction(const SUMOSAXAttributes& attrs);
243 
245  void setLocation(const SUMOSAXAttributes& attrs);
246 
256  void addDistrict(const SUMOSAXAttributes& attrs);
257 
258 
269  void addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);
270 
274  void addRoundabout(const SUMOSAXAttributes& attrs);
275 
276 
277  void closeWAUT();
278 
280  LinkDirection parseLinkDir(const std::string& dir);
281 
283  LinkState parseLinkState(const std::string& state);
284 
285 protected:
288 
291 
292 
295 
298 
301 
304 
306  std::string myCurrentDistrictID;
307 
310 
312  std::string myCurrentWAUTID;
313 
315  std::string myCurrentTypeID;
316 
319 
322 
324 
326 
328  std::vector<Parameterised*> myLastParameterised;
329 
332 
335 
338 
341 
344 
347 
349  typedef std::map<std::string, std::pair<std::string, std::string> > JunctionGraph;
351 
352 private:
354  NLHandler(const NLHandler& s);
355 
358 
359 };
360 
361 
362 
363 
364 #endif
365 
366 /****************************************************************************/
367 
NLHandler::openJunction
virtual void openJunction(const SUMOSAXAttributes &attrs)
opens a junction for processing
Definition: NLHandler.cpp:479
NLHandler::myHaveSeenInternalEdge
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:331
Boundary.h
NLHandler::myLastEdgeParameters
Parameterised myLastEdgeParameters
Definition: NLHandler.h:327
NLHandler::LaneVector
std::vector< MSLane * > LaneVector
Definition of a lane vector.
Definition: NLHandler.h:83
NLShapeHandler
The XML-Handler for shapes loading network loading.
Definition: NLHandler.h:56
NLHandler::addRequest
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
Definition: NLHandler.cpp:633
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:42
NLEdgeControlBuilder
Interface for building edges.
Definition: NLEdgeControlBuilder.h:57
NLHandler::myLefthand
bool myLefthand
whether the loaded network was built for left hand traffic
Definition: NLHandler.h:340
NLHandler::networkVersion
double networkVersion() const
Definition: NLHandler.h:120
NLHandler::myCurrentDistrictID
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:306
NLHandler::myHaveSeenNeighs
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition: NLHandler.h:334
NLHandler::JunctionGraph
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:349
NLHandler::haveSeenAdditionalSpeedRestrictions
bool haveSeenAdditionalSpeedRestrictions() const
Definition: NLHandler.h:112
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:91
NLHandler::myTriggerBuilder
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:297
NLHandler::addInstantE1Detector
virtual void addInstantE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:834
NLHandler::addRouteProbeDetector
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
Definition: NLHandler.cpp:881
NLHandler::beginE3Detector
void beginE3Detector(const SUMOSAXAttributes &attrs)
Starts building of an e3 detector using the given specification.
Definition: NLHandler.cpp:1088
NLHandler::setLocation
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1309
NLHandler::addE2Detector
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:905
ShapeContainer
Storage for geometrical objects.
Definition: ShapeContainer.h:49
NLHandler::addDistrictEdge
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1384
NLHandler::addParam
void addParam(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:548
NLHandler::addDistrict
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1330
NLTriggerBuilder
Builds trigger objects for microsim.
Definition: NLTriggerBuilder.h:61
NLHandler::openWAUT
virtual void openWAUT(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:566
NLHandler::myNetIsLoaded
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:346
NLHandler::addPhase
void addPhase(const SUMOSAXAttributes &attrs)
adds a phase to the traffic lights logic currently build
Definition: NLHandler.cpp:713
LinkDirection
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
Definition: SUMOXMLDefinitions.h:1176
NLHandler::myLastParameterised
std::vector< Parameterised * > myLastParameterised
Definition: NLHandler.h:328
NLHandler::closeEdge
virtual void closeEdge()
Closes the process of building an edge.
Definition: NLHandler.cpp:409
NLHandler::myCurrentIsBroken
bool myCurrentIsBroken
Definition: NLHandler.h:323
NLHandler::parseLinkState
LinkState parseLinkState(const std::string &state)
Parses the given character into an enumeration typed link state.
Definition: NLHandler.cpp:1293
NLHandler::myEdgeControlBuilder
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:300
NLHandler::haveSeenInternalEdge
bool haveSeenInternalEdge() const
Definition: NLHandler.h:104
NLHandler::myJunctionGraph
JunctionGraph myJunctionGraph
Definition: NLHandler.h:350
NLHandler::myEndElement
virtual void myEndElement(int element)
Called when a closing tag occurs.
Definition: NLHandler.cpp:252
NLHandler::myHaveWarnedAboutInvalidTLType
bool myHaveWarnedAboutInvalidTLType
Definition: NLHandler.h:325
NLHandler::addConnection
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:1184
NLHandler::myNetworkOffset
Position myNetworkOffset
The network offset.
Definition: NLHandler.h:318
NLJunctionControlBuilder
Builder of microsim-junctions and tls.
Definition: NLJunctionControlBuilder.h:62
NLHandler::myConvBoundary
Boundary myConvBoundary
Definition: NLHandler.h:321
NLDiscreteEventBuilder
Definition: NLDiscreteEventBuilder.h:45
NLHandler::myActionBuilder
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:287
NLHandler::addEdgeLaneMeanData
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
Definition: NLHandler.cpp:1139
LinkState
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
Definition: SUMOXMLDefinitions.h:1137
NLHandler::parseLinkDir
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:1283
NLHandler::myCurrentWAUTID
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:312
NLHandler::addE1Detector
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:805
NLHandler::myJunctionControlBuilder
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:303
NLHandler::haveSeenNeighs
bool haveSeenNeighs() const
Definition: NLHandler.h:108
NLHandler::NLHandler
NLHandler(const std::string &file, MSNet &net, NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder, NLEdgeControlBuilder &edgeBuilder, NLJunctionControlBuilder &junctionBuilder)
Constructor.
Definition: NLHandler.cpp:56
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
NLHandler::addLane
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
Definition: NLHandler.cpp:427
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
NLHandler::~NLHandler
virtual ~NLHandler()
Destructor.
Definition: NLHandler.cpp:77
NLHandler::addWAUTJunction
void addWAUTJunction(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:612
MSTrafficLightLogic
The parent class for traffic light logics.
Definition: MSTrafficLightLogic.h:55
NLHandler::lefthand
bool lefthand() const
Definition: NLHandler.h:116
NLHandler::myCurrentIsInternalToSkip
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:290
NLHandler::myOrigBoundary
Boundary myOrigBoundary
The network's boundaries.
Definition: NLHandler.h:321
NLHandler::myNet
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:209
NLHandler::addE3Entry
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
Definition: NLHandler.cpp:1113
NLHandler::myDetectorBuilder
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:294
NLHandler::myCurrentTypeID
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:315
NLHandler::initJunctionLogic
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:658
NLHandler::addVTypeProbeDetector
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:860
NLShapeHandler::getLanePos
Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, double lanePosLat)
get position for a given laneID (Has to be implemented in all child)
Definition: NLHandler.cpp:1449
NLShapeHandler::addLanePosParams
virtual bool addLanePosParams()
Whether some input attributes shall be automatically added as params (Can be implemented in all child...
Definition: NLHandler.h:66
NLHandler::myStartElement
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: NLHandler.cpp:81
MSRouteHandler
Parser and container for routes during their loading.
Definition: MSRouteHandler.h:53
NLHandler::beginEdgeParsing
void beginEdgeParsing(const SUMOSAXAttributes &attrs)
begins the processing of an edge
Definition: NLHandler.cpp:334
NLHandler::endE3Detector
virtual void endE3Detector()
Builds of an e3 detector using collected values.
Definition: NLHandler.cpp:1425
NLHandler::closeWAUT
void closeWAUT()
Definition: NLHandler.cpp:1435
NLHandler::NLHandler
NLHandler(const NLHandler &s)
NLHandler
The XML-Handler for network loading.
Definition: NLHandler.h:80
config.h
NLHandler::initTrafficLightLogic
void initTrafficLightLogic(const SUMOSAXAttributes &attrs)
begins the reading of a traffic lights logic
Definition: NLHandler.cpp:673
ShapeHandler
The XML-Handler for network loading.
Definition: ShapeHandler.h:49
NLShapeHandler::~NLShapeHandler
virtual ~NLShapeHandler()
Destructor.
Definition: NLHandler.h:62
ShapeHandler.h
NLShapeHandler::NLShapeHandler
NLShapeHandler(const std::string &file, ShapeContainer &sc)
Definition: NLHandler.h:58
NLHandler::myAmParsingTLLogicOrJunction
bool myAmParsingTLLogicOrJunction
internal information whether a tls-logic is currently read
Definition: NLHandler.h:309
NLDiscreteEventBuilder.h
NLHandler::operator=
NLHandler & operator=(const NLHandler &s)
MSRouteHandler.h
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56
NLHandler::addWAUTSwitch
void addWAUTSwitch(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:593
NLHandler::myHaveSeenAdditionalSpeedRestrictions
bool myHaveSeenAdditionalSpeedRestrictions
whether additional files contained type-specific speed limits
Definition: NLHandler.h:337
NLHandler::myNetworkVersion
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:343
NLDetectorBuilder
Builds detectors for microsim.
Definition: NLDetectorBuilder.h:55
NLHandler::parseLanes
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane * > &into, bool &ok)
Definition: NLHandler.cpp:528
NLHandler::addRoundabout
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1406
NLHandler::addE3Exit
void addE3Exit(const SUMOSAXAttributes &attrs)
Adds an exit to the currently processed e3 detector.
Definition: NLHandler.cpp:1126