|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // Importer for network edges stored in XML 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 NIXMLEdgesHandler_h 00023 #define NIXMLEdgesHandler_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 <utils/common/SUMOVehicleClass.h> 00036 #include <utils/geom/PositionVector.h> 00037 #include <utils/xml/SUMOSAXHandler.h> 00038 #include <netbuild/NBEdge.h> 00039 00040 00041 // =========================================================================== 00042 // class declarations 00043 // =========================================================================== 00044 class OptionsCont; 00045 class NBNode; 00046 class NBEdge; 00047 class NBNodeCont; 00048 class NBEdgeCont; 00049 class NBTypeCont; 00050 class NBDistrictCont; 00051 00052 00053 // =========================================================================== 00054 // class definitions 00055 // =========================================================================== 00071 class NIXMLEdgesHandler : public SUMOSAXHandler { 00072 public: 00080 NIXMLEdgesHandler(NBNodeCont& nc, NBEdgeCont& ec, 00081 NBTypeCont& tc, NBDistrictCont& dc, OptionsCont& options) ; 00082 00083 00085 ~NIXMLEdgesHandler() ; 00086 00087 00088 protected: 00090 00091 00099 void myStartElement(int element, 00100 const SUMOSAXAttributes& attrs) ; 00101 00102 00109 void myEndElement(int element) ; 00111 00112 00113 private: 00121 PositionVector tryGetShape(const SUMOSAXAttributes& attrs) ; 00122 00123 00126 LaneSpreadFunction tryGetLaneSpread(const SUMOSAXAttributes& attrs); 00127 00128 00136 bool setNodes(const SUMOSAXAttributes& attrs) ; 00137 00138 00141 SUMOReal tryGetPosition(const SUMOSAXAttributes& attrs, SumoXMLAttr attrID, 00142 const std::string& attrName); 00143 00144 00145 NBNode* insertNodeChecking(const Position& pos, 00146 const std::string& name, const std::string& dir); 00147 00148 00149 private: 00151 OptionsCont& myOptions; 00152 00153 00156 00158 std::string myCurrentID; 00159 00161 SUMOReal myCurrentSpeed; 00162 00164 int myCurrentPriority; 00165 00167 int myCurrentLaneNo; 00168 00170 SUMOReal myCurrentWidth; 00171 00173 SUMOReal myCurrentOffset; 00174 00176 std::string myCurrentStreetName; 00177 00179 std::string myCurrentType; 00180 00182 NBNode* myFromNode, *myToNode; 00183 00185 SUMOReal myLength; 00186 00188 PositionVector myShape; 00189 00191 LaneSpreadFunction myLanesSpread; 00192 00194 SUMOVehicleClasses myAllowed; 00195 00197 SUMOVehicleClasses myNotAllowed; 00198 00200 00201 00203 bool myIsUpdate; 00204 00206 NBEdge* myCurrentEdge; 00207 00208 00211 00213 NBNodeCont& myNodeCont; 00214 00216 NBEdgeCont& myEdgeCont; 00217 00219 NBTypeCont& myTypeCont; 00220 00222 NBDistrictCont& myDistrictCont; 00224 00225 00229 struct Split { 00231 std::vector<int> lanes; 00233 SUMOReal pos; 00235 int nameid; 00237 Position gpos; 00238 }; 00239 00241 std::vector<Split> mySplits; 00242 00243 00247 class split_sorter { 00248 public: 00250 explicit split_sorter() { } 00251 00253 int operator()(const Split& e1, const Split& e2) const { 00254 return e1.pos < e2.pos; 00255 } 00256 }; 00257 00258 00262 class split_by_pos_finder { 00263 public: 00265 explicit split_by_pos_finder(SUMOReal pos) 00266 : myPosition(pos) { } 00267 00269 bool operator()(const Split& e) { 00270 return e.pos == myPosition; 00271 } 00272 00273 private: 00275 SUMOReal myPosition; 00276 00277 }; 00278 00279 00281 bool myHaveReportedAboutOverwriting; 00282 00283 bool myHaveWarnedAboutDeprecatedSpreadType, myHaveWarnedAboutDeprecatedFromTo, 00284 myHaveWarnedAboutDeprecatedNoLanes, myHaveWarnedAboutDeprecatedLaneId; 00285 00286 00287 private: 00288 00292 void addEdge(const SUMOSAXAttributes& attrs); 00293 00297 void deleteEdge(const SUMOSAXAttributes& attrs); 00298 00303 void addLane(const SUMOSAXAttributes& attrs); 00304 00309 void addSplit(const SUMOSAXAttributes& attrs); 00310 00311 private: 00313 NIXMLEdgesHandler(const NIXMLEdgesHandler& s); 00314 00316 NIXMLEdgesHandler& operator=(const NIXMLEdgesHandler& s); 00317 00318 }; 00319 00320 00321 #endif 00322 00323 /****************************************************************************/ 00324