SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PCLoaderOSM.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // A reader of pois and polygons stored in OSM-format
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2008-2014 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef PCLoaderOSM_h
24 #define PCLoaderOSM_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include "PCPolyContainer.h"
38 #include "PCTypeMap.h"
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
45 class OptionsCont;
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
57 class PCLoaderOSM : public SUMOSAXHandler {
58 public:
70  static void loadIfSet(OptionsCont& oc, PCPolyContainer& toFill,
71  PCTypeMap& tm);
72 
73 
74 protected:
77  struct PCOSMNode {
85  std::map<std::string, std::string> myAttributes;
86  };
87 
88 
91  struct PCOSMEdge {
93  std::string id;
95  std::string name;
97  bool myIsClosed;
99  std::vector<SUMOLong> myCurrentNodes;
101  std::map<std::string, std::string> myAttributes;
102  };
103 
104 protected:
106  static int addPolygon(const PCOSMEdge* edge, const PositionVector& vec, const PCTypeMap::TypeDef& def,
107  const std::string& fullType, int index, bool useName, PCPolyContainer& toFill, bool ignorePruning, bool withAttributes);
108 
110  static int addPOI(const PCOSMNode* node, const Position& pos, const PCTypeMap::TypeDef& def,
111  const std::string& fullType, int index, PCPolyContainer& toFill, bool ignorePruning, bool withAttributes);
112 
113 
114 protected:
115  static const std::set<std::string> MyKeysToInclude;
116 
117 private:
118  static std::set<std::string> initMyKeysToInclude();
119 
120 
121 protected:
126  class NodesHandler : public SUMOSAXHandler {
127  public:
133  NodesHandler(std::map<SUMOLong, PCOSMNode*>& toFill, bool withAttributes,
134  MsgHandler& errorHandler);
135 
136 
138  ~NodesHandler();
139 
140 
141  protected:
143 
144 
152  void myStartElement(int element, const SUMOSAXAttributes& attrs);
153 
154 
161  void myEndElement(int element);
163 
164 
165  private:
168 
171 
173  std::map<SUMOLong, PCOSMNode*>& myToFill;
174 
176  std::vector<int> myParentElements;
177 
180 
181  private:
183  NodesHandler(const NodesHandler& s);
184 
187 
188  };
189 
190 
191 
196  class EdgesHandler : public SUMOSAXHandler {
197  public:
205  EdgesHandler(const std::map<SUMOLong, PCOSMNode*>& osmNodes,
206  std::map<std::string, PCOSMEdge*>& toFill, bool withAttributes,
207  MsgHandler& errorHandler);
208 
209 
211  ~EdgesHandler();
212 
213 
214  protected:
216 
217 
225  void myStartElement(int element, const SUMOSAXAttributes& attrs);
226 
227 
234  void myEndElement(int element);
236 
237 
238  private:
241 
244 
246  const std::map<SUMOLong, PCOSMNode*>& myOSMNodes;
247 
249  std::map<std::string, PCOSMEdge*>& myEdgeMap;
250 
253 
255  std::vector<int> myParentElements;
256 
258  bool myKeep;
259 
260  private:
262  EdgesHandler(const EdgesHandler& s);
263 
266 
267  };
268 
269 };
270 
271 
272 #endif
273 
274 /****************************************************************************/
275