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 /****************************************************************************/
9 // A reader of pois and polygons stored in OSM-format
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2013 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 PCLoaderOSM_h
23 #define PCLoaderOSM_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 "PCPolyContainer.h"
37 #include "PCTypeMap.h"
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
44 class OptionsCont;
45 
46 
47 // ===========================================================================
48 // class declarations
49 // ===========================================================================
56 class PCLoaderOSM : public SUMOSAXHandler {
57 public:
69  static void loadIfSet(OptionsCont& oc, PCPolyContainer& toFill,
70  PCTypeMap& tm);
71 
72 
73 protected:
76  struct PCOSMNode {
84  std::map<std::string, std::string> myAttributes;
85  };
86 
87 
90  struct PCOSMEdge {
92  std::string id;
94  std::string name;
96  bool myIsClosed;
98  std::vector<SUMOLong> myCurrentNodes;
100  std::map<std::string, std::string> myAttributes;
101  };
102 
103 protected:
105  static int addPolygon(const PCOSMEdge* edge, const PositionVector& vec, const PCTypeMap::TypeDef& def,
106  const std::string& fullType, int index, bool useName, PCPolyContainer& toFill, bool ignorePruning, bool withAttributes);
107 
109  static int addPOI(const PCOSMNode* node, const Position& pos, const PCTypeMap::TypeDef& def,
110  const std::string& fullType, int index, PCPolyContainer& toFill, bool ignorePruning, bool withAttributes);
111 
112 
113 protected:
114  static const std::set<std::string> MyKeysToInclude;
115 
116 private:
117  static std::set<std::string> initMyKeysToInclude();
118 
119 
120 protected:
125  class NodesHandler : public SUMOSAXHandler {
126  public:
132  NodesHandler(std::map<SUMOLong, PCOSMNode*>& toFill, bool withAttributes,
133  MsgHandler& errorHandler);
134 
135 
137  ~NodesHandler();
138 
139 
140  protected:
142 
143 
151  void myStartElement(int element, const SUMOSAXAttributes& attrs);
152 
153 
160  void myEndElement(int element);
162 
163 
164  private:
167 
170 
172  std::map<SUMOLong, PCOSMNode*>& myToFill;
173 
175  std::vector<int> myParentElements;
176 
179 
180  private:
182  NodesHandler(const NodesHandler& s);
183 
186 
187  };
188 
189 
190 
195  class EdgesHandler : public SUMOSAXHandler {
196  public:
204  EdgesHandler(const std::map<SUMOLong, PCOSMNode*>& osmNodes,
205  std::map<std::string, PCOSMEdge*>& toFill, bool withAttributes,
206  MsgHandler& errorHandler);
207 
208 
210  ~EdgesHandler();
211 
212 
213  protected:
215 
216 
224  void myStartElement(int element, const SUMOSAXAttributes& attrs);
225 
226 
233  void myEndElement(int element);
235 
236 
237  private:
240 
243 
245  const std::map<SUMOLong, PCOSMNode*>& myOSMNodes;
246 
248  std::map<std::string, PCOSMEdge*>& myEdgeMap;
249 
252 
254  std::vector<int> myParentElements;
255 
257  bool myKeep;
258 
259  private:
261  EdgesHandler(const EdgesHandler& s);
262 
265 
266  };
267 
268 };
269 
270 
271 #endif
272 
273 /****************************************************************************/
274