00001 /****************************************************************************/ 00007 // Importer for networks stored in SUMO format 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright 2001-2010 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 NIImporter_SUMO_h 00020 #define NIImporter_SUMO_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 <map> 00034 #include <utils/xml/SUMOSAXHandler.h> 00035 00036 00037 // =========================================================================== 00038 // class declarations 00039 // =========================================================================== 00040 class NBNetBuilder; 00041 class NBEdge; 00042 class OptionsCont; 00043 00044 00045 // =========================================================================== 00046 // class definitions 00047 // =========================================================================== 00053 class NIImporter_SUMO : public SUMOSAXHandler { 00054 public: 00070 static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb); 00071 00072 00073 protected: 00077 NIImporter_SUMO(NBNodeCont &nc); 00078 00079 00081 ~NIImporter_SUMO() throw(); 00082 00083 00084 00086 00087 00098 void myStartElement(SumoXMLTag element, 00099 const SUMOSAXAttributes &attrs) throw(ProcessError); 00100 00101 00109 void myCharacters(SumoXMLTag element, 00110 const std::string &chars) throw(ProcessError); 00111 00112 00119 void myEndElement(SumoXMLTag element) throw(ProcessError); 00121 00122 00123 private: 00125 00126 00130 void addEdge(const SUMOSAXAttributes &attrs); 00131 00132 00136 void addLane(const SUMOSAXAttributes &attrs); 00137 00138 00142 void addJunction(const SUMOSAXAttributes &attrs); 00143 00144 00149 void addSuccEdge(const SUMOSAXAttributes &attrs); 00150 00151 00155 void addSuccLane(const SUMOSAXAttributes &attrs); 00157 00158 00159 private: 00164 struct EdgeLane { 00166 std::string lane; 00167 }; 00168 00169 00173 struct LaneAttrs { 00175 bool depart; 00177 SUMOReal maxSpeed; 00179 Position2DVector shape; 00181 std::vector<EdgeLane> connections; 00182 }; 00183 00184 00188 struct EdgeAttrs { 00190 std::string id; 00192 std::string type; 00194 std::string fromNode; 00196 std::string toNode; 00198 int priority; 00200 SUMOReal maxSpeed; 00202 std::vector<LaneAttrs*> lanes; 00204 NBEdge *builtEdge; 00205 }; 00206 00207 00209 std::map<std::string, EdgeAttrs*> myEdges; 00210 00212 NBNodeCont &myNodeCont; 00213 00215 EdgeAttrs *myCurrentEdge; 00216 00218 LaneAttrs *myCurrentLane; 00219 00220 }; 00221 00222 00223 #endif 00224 00225 /****************************************************************************/ 00226
1.5.6