|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Importer for networks stored in ITSUMO 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 NIImporter_ITSUMO_h 00020 #define NIImporter_ITSUMO_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 <netbuild/NBCapacity2Lanes.h> 00035 #include <utils/xml/SUMOSAXHandler.h> 00036 #include <utils/common/UtilExceptions.h> 00037 00038 00039 // =========================================================================== 00040 // class declarations 00041 // =========================================================================== 00042 class NBEdge; 00043 class NBEdgeCont; 00044 class NBNetBuilder; 00045 class NBNode; 00046 class NBNodeCont; 00047 class NBTrafficLightLogicCont; 00048 class NBTypeCont; 00049 class OptionsCont; 00050 00051 00052 // =========================================================================== 00053 // class definitions 00054 // =========================================================================== 00060 class NIImporter_ITSUMO { 00061 public: 00073 static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb); 00074 00075 00076 private: 00081 class Handler : public GenericSAXHandler { 00082 public: 00086 Handler(NBNetBuilder& toFill) throw(); 00087 00088 00090 ~Handler() throw(); 00091 00092 00093 protected: 00095 00096 00104 void myStartElement(int element, const SUMOSAXAttributes& attrs) throw(ProcessError); 00105 00106 00115 void myCharacters(int element, const std::string& chars); 00116 00117 00124 void myEndElement(int element); 00126 00127 00128 private: 00130 NBNetBuilder& myNetBuilder; 00131 00133 std::map<std::string, std::string> myParameter; 00134 00135 00136 struct Lane { 00137 public: 00138 Lane(const std::string& id, unsigned int idx, SUMOReal v) 00139 : myID(id), myIndex(idx), myV(v) {} 00140 std::string myID; 00141 unsigned int myIndex; 00142 SUMOReal myV; 00143 }; 00144 00145 std::vector<Lane> myCurrentLanes; 00146 00147 struct LaneSet { 00148 public: 00149 LaneSet(const std::string& id, const std::vector<Lane> &lanes, SUMOReal v, int pos, NBNode* from, NBNode* to) 00150 : myID(id), myLanes(lanes), myV(v), myPosition(pos), myFrom(from), myTo(to) {} 00151 std::string myID; 00152 std::vector<Lane> myLanes; 00153 SUMOReal myV; 00154 int myPosition; 00155 NBNode* myFrom; 00156 NBNode* myTo; 00157 }; 00158 00159 std::map<std::string, LaneSet*> myLaneSets; 00160 std::vector<LaneSet*> myCurrentLaneSets; 00161 00162 struct Section { 00163 public: 00164 Section(const std::string& id, const std::vector<LaneSet*> &laneSets) 00165 : myID(id), myLaneSets(laneSets) {} 00166 std::string myID; 00167 std::vector<LaneSet*> myLaneSets; 00168 }; 00169 00170 std::vector<Section*> mySections; 00171 00172 00173 private: 00175 Handler(const Handler& s); 00176 00178 Handler& operator=(const Handler& s); 00179 00180 }; 00181 00182 00183 00189 enum ItsumoXMLTag { 00190 ITSUMO_TAG_NOTHING = 0, 00191 ITSUMO_TAG_SIMULATION, 00192 ITSUMO_TAG_NETWORK_ID, 00193 ITSUMO_TAG_NETWORK_NAME, 00194 ITSUMO_TAG_NODES, 00195 ITSUMO_TAG_NODE, 00196 ITSUMO_TAG_NODE_ID, 00197 ITSUMO_TAG_NODE_NAME, 00198 ITSUMO_TAG_X_COORD, 00199 ITSUMO_TAG_Y_COORD, 00200 ITSUMO_TAG_SOURCES, 00201 ITSUMO_TAG_SINKS, 00202 ITSUMO_TAG_TRAFFIC_LIGHTS, 00203 ITSUMO_TAG_STREETS, 00204 ITSUMO_TAG_STREET, 00205 ITSUMO_TAG_STREET_ID, 00206 ITSUMO_TAG_STREET_NAME, 00207 ITSUMO_TAG_SECTIONS, 00208 ITSUMO_TAG_SECTION, 00209 ITSUMO_TAG_SECTION_ID, 00210 ITSUMO_TAG_SECTION_NAME, 00211 ITSUMO_TAG_IS_PREFERENCIAL, 00212 ITSUMO_TAG_DELIMITING_NODE, 00213 ITSUMO_TAG_LANESETS, 00214 ITSUMO_TAG_LANESET, 00215 ITSUMO_TAG_LANESET_ID, 00216 ITSUMO_TAG_LANESET_POSITION, 00217 ITSUMO_TAG_START_NODE, 00218 ITSUMO_TAG_END_NODE, 00219 ITSUMO_TAG_TURNING_PROBABILITIES, 00220 ITSUMO_TAG_DIRECTION, 00221 ITSUMO_TAG_DESTINATION_LANESET, 00222 ITSUMO_TAG_PROBABILITY, 00223 ITSUMO_TAG_LANES, 00224 ITSUMO_TAG_LANE, 00225 ITSUMO_TAG_LANE_ID, 00226 ITSUMO_TAG_LANE_POSITION, 00227 ITSUMO_TAG_MAXIMUM_SPEED, 00228 ITSUMO_TAG_DECELERATION_PROB 00229 }; 00230 00231 00237 enum ItsumoXMLAttr { 00238 ITSUMO_ATTR_NOTHING = 0 00239 }; 00240 00242 static StringBijection<int>::Entry itsumoTags[]; 00243 00245 static StringBijection<int>::Entry itsumoAttrs[]; 00246 00247 00248 }; 00249 00250 00251 #endif 00252 00253 /****************************************************************************/ 00254