SUMO - Simulation of Urban MObility
NIImporter_SUMO.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 /****************************************************************************/
17 // Importer for networks stored in SUMO format
18 /****************************************************************************/
19 #ifndef NIImporter_SUMO_h
20 #define NIImporter_SUMO_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <map>
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class NBNetBuilder;
40 class NBEdge;
41 class OptionsCont;
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
53 public:
69  static void loadNetwork(OptionsCont& oc, NBNetBuilder& nb);
70 
73 
75  static void addPhase(const SUMOSAXAttributes& attrs, NBLoadedSUMOTLDef* currentTL);
76 
78  static GeoConvHelper* loadLocation(const SUMOSAXAttributes& attrs);
79 
80 protected:
85 
86 
89 
90 
91 
93 
94 
105  void myStartElement(int element,
106  const SUMOSAXAttributes& attrs);
107 
108 
115  void myEndElement(int element);
117 
118 
119 private:
121  void _loadNetwork(OptionsCont& oc);
122 
124 
125 
129  void addEdge(const SUMOSAXAttributes& attrs);
130 
131 
135  void addLane(const SUMOSAXAttributes& attrs);
136 
140  void addStopOffsets(const SUMOSAXAttributes& attrs, bool& ok);
141 
145  void addJunction(const SUMOSAXAttributes& attrs);
146 
147 
151  void addRequest(const SUMOSAXAttributes& attrs);
152 
153 
158  void addConnection(const SUMOSAXAttributes& attrs);
159 
163  void addProhibition(const SUMOSAXAttributes& attrs);
164 
168  void addRoundabout(const SUMOSAXAttributes& attrs);
169 
171 
172 
173 
174 private:
179  struct Connection : public Parameterised {
181  std::string toEdgeID;
185  std::string tlID;
191  bool keepClear;
193  double contPos;
195  double visibility;
197  double speed;
202  };
203 
204 
208  struct LaneAttrs : public Parameterised {
210  double maxSpeed;
214  std::vector<Connection> connections;
216  std::string allow;
218  std::string disallow;
220  double width;
222  double endOffset;
224  std::map<SVCPermissions, double> stopOffsets;
226  bool accelRamp;
228  std::string oppositeID;
231  };
232 
233 
237  struct EdgeAttrs : public Parameterised {
239  std::string id;
241  std::string streetName;
243  std::string type;
247  std::string fromNode;
249  std::string toNode;
253  double length;
255  int priority;
257  double maxSpeed;
259  std::vector<LaneAttrs*> lanes;
265  std::map<SVCPermissions, double> stopOffsets;
266  };
267 
268 
272  struct Prohibition {
273  std::string prohibitorFrom;
274  std::string prohibitorTo;
275  std::string prohibitedFrom;
276  std::string prohibitedTo;
277  };
278 
282  struct Crossing {
283  Crossing(const std::string& _edgeID) :
284  edgeID(_edgeID), customTLIndex(-1), customTLIndex2(-1) {}
285 
286  std::string edgeID;
287  std::vector<std::string> crossingEdges;
288  double width;
289  bool priority;
293  };
294 
300  std::vector<std::string> fromEdges;
301  std::vector<std::string> toEdges;
302  std::vector<std::string> fromCrossed;
303  std::vector<std::string> toCrossed;
304  };
305 
309  struct JunctionAttrs {
311  // @the list of internal lanes corresponding to each link
312  std::vector<std::string> intLanes;
313  // @brief the complete response definition for all links
314  std::vector<std::string> response;
315  };
316 
318  std::map<std::string, EdgeAttrs*> myEdges;
319 
321  std::vector<Prohibition> myProhibitions;
322 
325 
328 
331 
334 
337 
340 
343 
346 
348  std::map<std::string, std::vector<Crossing> > myPedestrianCrossings;
349 
351  std::map<std::string, WalkingAreaParsedCustomShape> myWACustomShapes;
352 
354  std::vector<Parameterised*> myLastParameterised;
355 
358 
361 
364 
367 
370 
373 
376 
380 
382  std::vector<std::vector<std::string> > myRoundabouts;
383 
385  std::set<std::string> myRailSignals;
386 
391  LaneAttrs* getLaneAttrsFromID(EdgeAttrs* edge, std::string lane_id);
392 
398  static PositionVector reconstructEdgeShape(const EdgeAttrs* edge, const Position& from, const Position& to);
399 
401  static Position readPosition(const SUMOSAXAttributes& attrs, const std::string& id, bool& ok);
402 
409  void parseProhibitionConnection(const std::string& attr, std::string& from, std::string& to, bool& ok);
410 };
411 
412 
413 #endif
414 
415 /****************************************************************************/
416 
PositionVector customShape
custom shape connection
std::map< std::string, EdgeAttrs * > myEdges
Loaded edge definitions.
LaneAttrs * myCurrentLane
The currently parsed lanes&#39;s definition (to add the shape to)
PositionVector shape
This edges&#39;s shape.
std::vector< Prohibition > myProhibitions
Loaded prohibitions.
static void addPhase(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
adds a phase to the traffic lights logic currently build
bool accelRamp
Whether this lane is an acceleration lane.
bool uncontrolled
if set to true, This connection will not be TLS-controlled despite its node being controlled...
NBNodeCont & myNodeCont
The node container to fill.
void addEdge(const SUMOSAXAttributes &attrs)
Parses an edge and stores the values in "myCurrentEdge".
void addRoundabout(const SUMOSAXAttributes &attrs)
Parses a roundabout and stores it in myEdgeCont.
A loaded (complete) traffic light logic.
std::vector< LaneAttrs * > lanes
This edge&#39;s lanes.
A container for traffic light definitions and built programs.
Describes a pedestrian crossing.
double maxSpeed
The maximum velocity allowed on this lane.
The representation of a single edge during network building.
Definition: NBEdge.h:65
A connection description.
int tlLinkIndex
The index of this connection within the controlling traffic light.
bool myCheckLaneFoesRoundabout
std::vector< std::string > response
double myLimitTurnSpeed
whether turning speed was limited in the network
double width
The width of this lane.
bool myAmLefthand
whether the loaded network was built for lefthand traffic
static NBLoadedSUMOTLDef * initTrafficLightLogic(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
begins the reading of a traffic lights logic
SAX-handler base for SUMO-files.
NIImporter_SUMO(NBNetBuilder &nb)
Constructor.
Describes custom shape for a walking area during parsing.
Describes the values found in a lane&#39;s definition.
LaneAttrs * getLaneAttrsFromID(EdgeAttrs *edge, std::string lane_id)
Parses lane index from lane ID an retrieve lane from EdgeAttrs.
std::string toEdgeID
The id of the target edge.
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
double maxSpeed
The maximum velocity allowed on this edge (!!!)
void addStopOffsets(const SUMOSAXAttributes &attrs, bool &ok)
parses stop offsets for the current lane or edge
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and stores the values in "myCurrentLane".
NBNetBuilder & myNetBuilder
The network builder to fill.
std::vector< std::vector< std::string > > myRoundabouts
loaded roundabout edges
void addConnection(const SUMOSAXAttributes &attrs)
Parses a connection and saves it into the lane&#39;s definition stored in "myCurrentLane".
std::string toNode
The node this edge ends at.
Describes the values found in an edge&#39;s definition and this edge&#39;s lanes.
int myLinkDetail
the level of geometry detail for internal lanes in the loaded network
JunctionAttrs myCurrentJunction
The currently parsed junction definition to help in reconstructing crossings.
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:53
std::vector< std::string > crossingEdges
std::string allow
This lane&#39;s allowed vehicle classes.
Describes the values found in a junction.
std::vector< Parameterised * > myLastParameterised
element to receive parameters
Encapsulated SAX-Attributes.
static GeoConvHelper * loadLocation(const SUMOSAXAttributes &attrs)
Parses network location description and registers it with GeoConveHelper::setLoaded.
Describes the values found in a prohibition.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
Importer for networks stored in SUMO format.
std::string tlID
The id of the traffic light that controls this connection.
EdgeAttrs * myCurrentEdge
The currently parsed edge&#39;s definition (to add loaded lanes to)
A list of positions.
void parseProhibitionConnection(const std::string &attr, std::string &from, std::string &to, bool &ok)
parses connection string of a prohibition (very old school)
bool myRectLaneCut
whether all lanes of an edge should have the same stop line
double visibility
custom foe visibility for connection
LaneSpreadFunction lsf
The lane spread function.
bool customShape
Whether this lane has a custom shape.
double length
The length of the edge if set explicitly.
std::string disallow
This lane&#39;s disallowed vehicle classes.
double speed
custom speed for connection
NBEdge * builtEdge
The built edge.
static PositionVector reconstructEdgeShape(const EdgeAttrs *edge, const Position &from, const Position &to)
reconstructs the edge shape from the node positions and the given lane shapes since we do not know th...
SumoXMLEdgeFunc func
This edge&#39;s function.
An upper class for objects with additional parameters.
Definition: Parameterised.h:44
std::map< SVCPermissions, double > stopOffsets
This edge&#39;s vehicle specific stop offsets (used for lanes, that do not have a specified stopOffset) ...
std::string oppositeID
This lane&#39;s opposite lane.
void _loadNetwork(OptionsCont &oc)
load the network
Crossing(const std::string &_edgeID)
bool keepClear
Whether the junction must be kept clear coming from this connection.
std::vector< std::string > intLanes
double endOffset
This lane&#39;s offset from the intersection.
std::string streetName
This edge&#39;s street name.
static void loadNetwork(OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given SUMO file.
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
std::vector< Connection > connections
This lane&#39;s connections.
void addJunction(const SUMOSAXAttributes &attrs)
Parses a junction and saves it in the node control.
bool myCheckLaneFoesAll
whether foe-relationships where checked at lane-level
std::string type
This edge&#39;s type.
double contPos
custom position for internal junction on this connection
Instance responsible for building networks.
Definition: NBNetBuilder.h:109
int myCornerDetail
the level of corner detail in the loaded network
static Position readPosition(const SUMOSAXAttributes &attrs, const std::string &id, bool &ok)
read position from the given attributes, attribute errors to id
std::map< std::string, std::vector< Crossing > > myPedestrianCrossings
The pedestrian crossings found in the network.
A storage for options typed value containers)
Definition: OptionsCont.h:92
int priority
This edge&#39;s priority.
std::string id
This edge&#39;s id.
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
void myEndElement(int element)
Called when a closing tag occurs.
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge&#39;s lateral offset shal...
std::string fromNode
The node this edge starts at.
Represents a single node (junction) during network building.
Definition: NBNode.h:68
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
~NIImporter_SUMO()
Destructor.
void addRequest(const SUMOSAXAttributes &attrs)
Parses a reques and saves selected attributes in myCurrentJunction.
GeoConvHelper * myLocation
The coordinate transformation which was used to build the loaded network.
PositionVector shape
This lane&#39;s shape (needed to reconstruct edge shape for legacy networks)
NBTrafficLightLogicCont & myTLLCont
The node container to fill.
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:60
std::map< std::string, WalkingAreaParsedCustomShape > myWACustomShapes
Map from walkingArea edge IDs to custom shapes.
void addProhibition(const SUMOSAXAttributes &attrs)
Parses a prohibition and saves it.
NBLoadedSUMOTLDef * myCurrentTL
The currently parsed traffic light.
bool myWalkingAreas
whether walkingareas must be built
std::set< std::string > myRailSignals
list of node id with rail signals (no NBTrafficLightDefinition exists)
int toLaneIdx
The index of the target lane.
std::map< SVCPermissions, double > stopOffsets
This lane&#39;s vehicle specific stop offsets.