|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Importer for network edges stored in XML 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 NIXMLEdgesHandler_h 00020 #define NIXMLEdgesHandler_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 <utils/common/SUMOVehicleClass.h> 00033 #include <utils/geom/PositionVector.h> 00034 #include <utils/xml/SUMOSAXHandler.h> 00035 #include <netbuild/NBEdge.h> 00036 00037 00038 // =========================================================================== 00039 // class declarations 00040 // =========================================================================== 00041 class OptionsCont; 00042 class NBNode; 00043 class NBEdge; 00044 class NBNodeCont; 00045 class NBEdgeCont; 00046 class NBTypeCont; 00047 class NBDistrictCont; 00048 00049 00050 // =========================================================================== 00051 // class definitions 00052 // =========================================================================== 00068 class NIXMLEdgesHandler : public SUMOSAXHandler { 00069 public: 00077 NIXMLEdgesHandler(NBNodeCont& nc, NBEdgeCont& ec, 00078 NBTypeCont& tc, NBDistrictCont& dc, OptionsCont& options) throw(); 00079 00080 00082 ~NIXMLEdgesHandler() throw(); 00083 00084 00085 protected: 00087 00088 00096 void myStartElement(int element, 00097 const SUMOSAXAttributes& attrs) throw(ProcessError); 00098 00099 00106 void myEndElement(int element) throw(ProcessError); 00108 00109 00110 private: 00118 PositionVector tryGetShape(const SUMOSAXAttributes& attrs) throw(); 00119 00120 00123 LaneSpreadFunction tryGetLaneSpread(const SUMOSAXAttributes& attrs); 00124 00125 00133 bool setNodes(const SUMOSAXAttributes& attrs) throw(); 00134 00135 00138 SUMOReal tryGetPosition(const SUMOSAXAttributes& attrs, SumoXMLAttr attrID, 00139 const std::string& attrName); 00140 00141 00142 NBNode* insertNodeChecking(const Position& pos, 00143 const std::string& name, const std::string& dir); 00144 00145 00146 private: 00148 OptionsCont& myOptions; 00149 00150 00153 00155 std::string myCurrentID; 00156 00158 SUMOReal myCurrentSpeed; 00159 00161 int myCurrentPriority; 00162 00164 int myCurrentLaneNo; 00165 00167 SUMOReal myCurrentWidth; 00168 00170 SUMOReal myCurrentOffset; 00171 00173 std::string myCurrentStreetName; 00174 00176 std::string myCurrentType; 00177 00179 NBNode* myFromNode, *myToNode; 00180 00182 SUMOReal myLength; 00183 00185 PositionVector myShape; 00186 00188 LaneSpreadFunction myLanesSpread; 00189 00191 SUMOVehicleClasses myAllowed; 00192 00194 SUMOVehicleClasses myNotAllowed; 00196 00197 00199 bool myIsUpdate; 00200 00202 NBEdge* myCurrentEdge; 00203 00204 00207 00209 NBNodeCont& myNodeCont; 00210 00212 NBEdgeCont& myEdgeCont; 00213 00215 NBTypeCont& myTypeCont; 00216 00218 NBDistrictCont& myDistrictCont; 00220 00221 00225 struct Split { 00227 std::vector<int> lanes; 00229 SUMOReal pos; 00231 int nameid; 00233 Position gpos; 00234 }; 00235 00237 std::vector<Split> mySplits; 00238 00239 00243 class split_sorter { 00244 public: 00246 explicit split_sorter() { } 00247 00249 int operator()(const Split& e1, const Split& e2) const { 00250 return e1.pos < e2.pos; 00251 } 00252 }; 00253 00254 00258 class split_by_pos_finder { 00259 public: 00261 explicit split_by_pos_finder(SUMOReal pos) 00262 : myPosition(pos) { } 00263 00265 bool operator()(const Split& e) { 00266 return e.pos==myPosition; 00267 } 00268 00269 private: 00271 SUMOReal myPosition; 00272 00273 }; 00274 00275 00277 bool myHaveReportedAboutOverwriting; 00278 00279 bool myHaveWarnedAboutDeprecatedSpreadType, myHaveWarnedAboutDeprecatedFromTo, 00280 myHaveWarnedAboutDeprecatedNoLanes, myHaveWarnedAboutDeprecatedLaneId; 00281 00282 00283 private: 00284 00288 void addEdge(const SUMOSAXAttributes& attrs); 00289 00293 void deleteEdge(const SUMOSAXAttributes& attrs); 00294 00299 void addLane(const SUMOSAXAttributes& attrs); 00300 00305 void addSplit(const SUMOSAXAttributes& attrs); 00306 00307 private: 00309 NIXMLEdgesHandler(const NIXMLEdgesHandler& s); 00310 00312 NIXMLEdgesHandler& operator=(const NIXMLEdgesHandler& s); 00313 00314 }; 00315 00316 00317 #endif 00318 00319 /****************************************************************************/ 00320