SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // A reader of pois and polygons stored in OSM-format 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 #ifndef PCLoaderOSM_h 00023 #define PCLoaderOSM_h 00024 00025 00026 // =========================================================================== 00027 // included modules 00028 // =========================================================================== 00029 #ifdef _MSC_VER 00030 #include <windows_config.h> 00031 #else 00032 #include <config.h> 00033 #endif 00034 00035 #include <string> 00036 #include "PCPolyContainer.h" 00037 #include "PCTypeMap.h" 00038 #include <utils/xml/SUMOSAXHandler.h> 00039 00040 00041 // =========================================================================== 00042 // class definitions 00043 // =========================================================================== 00044 class OptionsCont; 00045 00046 00047 // =========================================================================== 00048 // class declarations 00049 // =========================================================================== 00056 class PCLoaderOSM : public SUMOSAXHandler { 00057 public: 00069 static void loadIfSet(OptionsCont& oc, PCPolyContainer& toFill, 00070 PCTypeMap& tm) ; 00071 00072 00073 protected: 00076 struct PCOSMNode { 00078 long id; 00080 SUMOReal lon; 00082 SUMOReal lat; 00084 std::string myType; 00086 bool myIsAdditional; 00087 }; 00088 00089 00092 struct PCOSMEdge { 00094 std::string id; 00096 std::string name; 00098 std::string myType; 00100 bool myIsClosed; 00102 std::vector<long> myCurrentNodes; 00104 bool myIsAdditional; 00105 }; 00106 00107 00108 protected: 00113 class NodesHandler : public SUMOSAXHandler { 00114 public: 00118 NodesHandler(std::map<long, PCOSMNode*> &toFill) ; 00119 00120 00122 ~NodesHandler() ; 00123 00124 00125 protected: 00127 00128 00136 void myStartElement(int element, const SUMOSAXAttributes& attrs) ; 00137 00138 00145 void myEndElement(int element) ; 00147 00148 00149 private: 00151 std::map<long, PCOSMNode*> &myToFill; 00152 00154 std::vector<int> myParentElements; 00155 00157 long myLastNodeID; 00158 00159 00160 private: 00162 NodesHandler(const NodesHandler& s); 00163 00165 NodesHandler& operator=(const NodesHandler& s); 00166 00167 }; 00168 00169 00170 00175 class EdgesHandler : public SUMOSAXHandler { 00176 public: 00182 EdgesHandler(const std::map<long, PCOSMNode*> &osmNodes, 00183 std::map<std::string, PCOSMEdge*> &toFill) ; 00184 00185 00187 ~EdgesHandler() ; 00188 00189 00190 protected: 00192 00193 00201 void myStartElement(int element, const SUMOSAXAttributes& attrs) ; 00202 00203 00210 void myEndElement(int element) ; 00212 00213 00214 private: 00216 const std::map<long, PCOSMNode*> &myOSMNodes; 00217 00219 std::map<std::string, PCOSMEdge*> &myEdgeMap; 00220 00222 PCOSMEdge* myCurrentEdge; 00223 00225 std::vector<int> myParentElements; 00226 00227 00228 private: 00230 EdgesHandler(const EdgesHandler& s); 00231 00233 EdgesHandler& operator=(const EdgesHandler& s); 00234 00235 }; 00236 00237 00238 }; 00239 00240 00241 #endif 00242 00243 /****************************************************************************/ 00244