SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIImporter_SUMO.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Importer for networks stored in SUMO format
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef NIImporter_SUMO_h
23 #define NIImporter_SUMO_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <map>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class NBNetBuilder;
46 class NBEdge;
47 class OptionsCont;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
59 public:
75  static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
76 
79 
81  static void addPhase(const SUMOSAXAttributes& attrs, NBLoadedSUMOTLDef* currentTL);
82 
84  static GeoConvHelper* loadLocation(const SUMOSAXAttributes& attrs);
85 
86 
87 protected:
92 
93 
96 
97 
98 
100 
101 
112  void myStartElement(int element,
113  const SUMOSAXAttributes& attrs) ;
114 
115 
123  void myCharacters(int element,
124  const std::string& chars) ;
125 
126 
133  void myEndElement(int element) ;
135 
136 
137 private:
139  void _loadNetwork(const OptionsCont& oc);
140 
142 
143 
147  void addEdge(const SUMOSAXAttributes& attrs);
148 
149 
153  void addLane(const SUMOSAXAttributes& attrs);
154 
155 
159  void addJunction(const SUMOSAXAttributes& attrs);
160 
161 
166  void addSuccEdge(const SUMOSAXAttributes& attrs);
167 
168 
173  void addSuccLane(const SUMOSAXAttributes& attrs);
174 
179  void addConnection(const SUMOSAXAttributes& attrs);
180 
184  void addProhibition(const SUMOSAXAttributes& attrs);
185 
187 
188 
189 
190 private:
195  struct Connection {
197  std::string toEdgeID;
199  unsigned int toLaneIdx;
201  std::string tlID;
203  unsigned int tlLinkNo;
206  };
207 
208 
212  struct LaneAttrs {
218  std::vector<Connection> connections;
220  std::string allow;
222  std::string disallow;
227  };
228 
229 
233  struct EdgeAttrs {
235  std::string id;
237  std::string streetName;
239  std::string type;
241  std::string func;
243  std::string fromNode;
245  std::string toNode;
251  int priority;
255  std::vector<LaneAttrs*> lanes;
260  };
261 
262 
266  struct Prohibition {
267  std::string prohibitorFrom;
268  std::string prohibitorTo;
269  std::string prohibitedFrom;
270  std::string prohibitedTo;
271  };
272 
273 
275  std::map<std::string, EdgeAttrs*> myEdges;
276 
278  std::vector<Prohibition> myProhibitions;
279 
282 
285 
288 
291 
294 
297 
300 
303 
306 
311  LaneAttrs* getLaneAttrsFromID(EdgeAttrs* edge, std::string lane_id);
312 
318  static void interpretLaneID(const std::string& lane_id, std::string& edge_id, unsigned int& index);
319 
325  static PositionVector reconstructEdgeShape(const EdgeAttrs* edge, const Position& from, const Position& to);
326 
328  static Position readPosition(const SUMOSAXAttributes& attrs, const std::string& id, bool& ok);
329 
336  void parseProhibitionConnection(const std::string& attr, std::string& from, std::string& to, bool& ok);
337 };
338 
339 
340 #endif
341 
342 /****************************************************************************/
343