|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A reader of pois and polygons stored in OSM-format 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef PCLoaderOSM_h 00020 #define PCLoaderOSM_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <string> 00033 #include "PCPolyContainer.h" 00034 #include "PCTypeMap.h" 00035 #include <utils/xml/SUMOSAXHandler.h> 00036 00037 00038 // =========================================================================== 00039 // class definitions 00040 // =========================================================================== 00041 class OptionsCont; 00042 00043 00044 // =========================================================================== 00045 // class declarations 00046 // =========================================================================== 00053 class PCLoaderOSM : public SUMOSAXHandler { 00054 public: 00066 static void loadIfSet(OptionsCont& oc, PCPolyContainer& toFill, 00067 PCTypeMap& tm) throw(ProcessError); 00068 00069 00070 protected: 00073 struct PCOSMNode { 00075 int id; 00077 SUMOReal lon; 00079 SUMOReal lat; 00081 std::string myType; 00083 bool myIsAdditional; 00084 }; 00085 00086 00089 struct PCOSMEdge { 00091 std::string id; 00093 std::string name; 00095 std::string myType; 00097 bool myIsClosed; 00099 std::vector<int> myCurrentNodes; 00101 bool myIsAdditional; 00102 }; 00103 00104 00105 protected: 00110 class NodesHandler : public SUMOSAXHandler { 00111 public: 00115 NodesHandler(std::map<int, PCOSMNode*> &toFill) throw(); 00116 00117 00119 ~NodesHandler() throw(); 00120 00121 00122 protected: 00124 00125 00133 void myStartElement(int element, const SUMOSAXAttributes& attrs) throw(ProcessError); 00134 00135 00142 void myEndElement(int element) throw(ProcessError); 00144 00145 00146 private: 00148 std::map<int, PCOSMNode*> &myToFill; 00149 00151 std::vector<int> myParentElements; 00152 00154 int myLastNodeID; 00155 00156 00157 private: 00159 NodesHandler(const NodesHandler& s); 00160 00162 NodesHandler& operator=(const NodesHandler& s); 00163 00164 }; 00165 00166 00167 00172 class EdgesHandler : public SUMOSAXHandler { 00173 public: 00179 EdgesHandler(const std::map<int, PCOSMNode*> &osmNodes, 00180 std::map<std::string, PCOSMEdge*> &toFill) throw(); 00181 00182 00184 ~EdgesHandler() throw(); 00185 00186 00187 protected: 00189 00190 00198 void myStartElement(int element, const SUMOSAXAttributes& attrs) throw(ProcessError); 00199 00200 00207 void myEndElement(int element) throw(ProcessError); 00209 00210 00211 private: 00213 const std::map<int, PCOSMNode*> &myOSMNodes; 00214 00216 std::map<std::string, PCOSMEdge*> &myEdgeMap; 00217 00219 PCOSMEdge* myCurrentEdge; 00220 00222 std::vector<int> myParentElements; 00223 00224 00225 private: 00227 EdgesHandler(const EdgesHandler& s); 00228 00230 EdgesHandler& operator=(const EdgesHandler& s); 00231 00232 }; 00233 00234 00235 }; 00236 00237 00238 #endif 00239 00240 /****************************************************************************/ 00241