SUMO - Simulation of Urban MObility
NIXMLEdgesHandler.h
Go to the documentation of this file.
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     SVCPermissions myPermissions;
00195 
00197 
00198 
00200     bool myIsUpdate;
00201 
00203     NBEdge* myCurrentEdge;
00204 
00205 
00208 
00210     NBNodeCont& myNodeCont;
00211 
00213     NBEdgeCont& myEdgeCont;
00214 
00216     NBTypeCont& myTypeCont;
00217 
00219     NBDistrictCont& myDistrictCont;
00221 
00222 
00226     struct Split {
00228         std::vector<int> lanes;
00230         SUMOReal pos;
00232         int nameid;
00234         Position gpos;
00235     };
00236 
00238     std::vector<Split> mySplits;
00239 
00240 
00244     class split_sorter {
00245     public:
00247         explicit split_sorter() { }
00248 
00250         int operator()(const Split& e1, const Split& e2) const {
00251             return e1.pos < e2.pos;
00252         }
00253     };
00254 
00255 
00259     class split_by_pos_finder {
00260     public:
00262         explicit split_by_pos_finder(SUMOReal pos)
00263             : myPosition(pos) { }
00264 
00266         bool operator()(const Split& e) {
00267             return e.pos == myPosition;
00268         }
00269 
00270     private:
00272         SUMOReal myPosition;
00273 
00274     };
00275 
00276 
00278     bool myHaveReportedAboutOverwriting;
00279 
00280     bool myHaveWarnedAboutDeprecatedSpreadType, myHaveWarnedAboutDeprecatedFromTo,
00281          myHaveWarnedAboutDeprecatedNoLanes, myHaveWarnedAboutDeprecatedLaneId;
00282 
00283 
00284 private:
00285 
00289     void addEdge(const SUMOSAXAttributes& attrs);
00290 
00294     void deleteEdge(const SUMOSAXAttributes& attrs);
00295 
00300     void addLane(const SUMOSAXAttributes& attrs);
00301 
00306     void addSplit(const SUMOSAXAttributes& attrs);
00307 
00308 private:
00310     NIXMLEdgesHandler(const NIXMLEdgesHandler& s);
00311 
00313     NIXMLEdgesHandler& operator=(const NIXMLEdgesHandler& s);
00314 
00315 };
00316 
00317 
00318 #endif
00319 
00320 /****************************************************************************/
00321 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines