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 
122  void myEndElement(int element);
124 
125 
126 private:
128  void _loadNetwork(const OptionsCont& oc);
129 
131 
132 
136  void addEdge(const SUMOSAXAttributes& attrs);
137 
138 
142  void addLane(const SUMOSAXAttributes& attrs);
143 
144 
148  void addJunction(const SUMOSAXAttributes& attrs);
149 
150 
155  void addConnection(const SUMOSAXAttributes& attrs);
156 
160  void addProhibition(const SUMOSAXAttributes& attrs);
161 
163 
164 
165 
166 private:
171  struct Connection {
173  std::string toEdgeID;
175  unsigned int toLaneIdx;
177  std::string tlID;
179  unsigned int tlLinkNo;
182  };
183 
184 
188  struct LaneAttrs {
194  std::vector<Connection> connections;
196  std::string allow;
198  std::string disallow;
203  };
204 
205 
209  struct EdgeAttrs {
211  std::string id;
213  std::string streetName;
215  std::string type;
219  std::string fromNode;
221  std::string toNode;
227  int priority;
231  std::vector<LaneAttrs*> lanes;
236  };
237 
238 
242  struct Prohibition {
243  std::string prohibitorFrom;
244  std::string prohibitorTo;
245  std::string prohibitedFrom;
246  std::string prohibitedTo;
247  };
248 
249 
251  std::map<std::string, EdgeAttrs*> myEdges;
252 
254  std::vector<Prohibition> myProhibitions;
255 
258 
261 
264 
267 
270 
273 
276 
279 
280 
285  LaneAttrs* getLaneAttrsFromID(EdgeAttrs* edge, std::string lane_id);
286 
292  static void interpretLaneID(const std::string& lane_id, std::string& edge_id, unsigned int& index);
293 
299  static PositionVector reconstructEdgeShape(const EdgeAttrs* edge, const Position& from, const Position& to);
300 
302  static Position readPosition(const SUMOSAXAttributes& attrs, const std::string& id, bool& ok);
303 
310  void parseProhibitionConnection(const std::string& attr, std::string& from, std::string& to, bool& ok);
311 };
312 
313 
314 #endif
315 
316 /****************************************************************************/
317