SUMO - Simulation of Urban MObility

NIImporter_SUMO.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Importer for networks stored in SUMO 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_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 #include <utils/geom/GeoConvHelper.h>
00036 #include <netbuild/NBLoadedSUMOTLDef.h>
00037 
00038 
00039 // ===========================================================================
00040 // class declarations
00041 // ===========================================================================
00042 class NBNetBuilder;
00043 class NBEdge;
00044 class OptionsCont;
00045 
00046 
00047 // ===========================================================================
00048 // class definitions
00049 // ===========================================================================
00055 class NIImporter_SUMO : public SUMOSAXHandler {
00056 public:
00072     static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
00073 
00075     static NBLoadedSUMOTLDef* initTrafficLightLogic(const SUMOSAXAttributes& attrs, NBLoadedSUMOTLDef* currentTL);
00076 
00078     static void addPhase(const SUMOSAXAttributes& attrs, NBLoadedSUMOTLDef* currentTL);
00079 
00080 
00081 protected:
00085     NIImporter_SUMO(NBNetBuilder& nb);
00086 
00087 
00089     ~NIImporter_SUMO() throw();
00090 
00091 
00092 
00094 
00095 
00106     void myStartElement(int element,
00107                         const SUMOSAXAttributes& attrs) throw(ProcessError);
00108 
00109 
00117     void myCharacters(int element,
00118                       const std::string& chars) throw(ProcessError);
00119 
00120 
00127     void myEndElement(int element) throw(ProcessError);
00129 
00130 
00131 private:
00133     void _loadNetwork(const OptionsCont& oc);
00134 
00136 
00137 
00141     void addEdge(const SUMOSAXAttributes& attrs);
00142 
00143 
00147     void addLane(const SUMOSAXAttributes& attrs);
00148 
00149 
00153     void addJunction(const SUMOSAXAttributes& attrs);
00154 
00155 
00160     void addSuccEdge(const SUMOSAXAttributes& attrs);
00161 
00162 
00167     void addSuccLane(const SUMOSAXAttributes& attrs);
00168 
00173     void addConnection(const SUMOSAXAttributes& attrs);
00174 
00178     void addProhibition(const SUMOSAXAttributes& attrs);
00179 
00181     void setLocation(const SUMOSAXAttributes& attrs);
00183 
00184 
00185 
00186 private:
00191     struct Connection {
00193         std::string toEdgeID;
00195         unsigned int toLaneIdx;
00197         std::string tlID;
00199         unsigned int tlLinkNo;
00201         bool mayDefinitelyPass;
00202     };
00203 
00204 
00208     struct LaneAttrs {
00210         SUMOReal maxSpeed;
00212         PositionVector shape;
00214         std::vector<Connection> connections;
00216         std::string allow;
00218         std::string disallow;
00220         SUMOReal width;
00222         SUMOReal offset;
00223     };
00224 
00225 
00229     struct EdgeAttrs {
00231         std::string id;
00233         std::string streetName;
00235         std::string type;
00237         std::string func;
00239         std::string fromNode;
00241         std::string toNode;
00243         PositionVector shape;
00245         int priority;
00247         SUMOReal maxSpeed;
00249         std::vector<LaneAttrs*> lanes;
00251         NBEdge* builtEdge;
00253         LaneSpreadFunction lsf;
00254     };
00255 
00256 
00260     struct Prohibition {
00261         std::string prohibitorFrom;
00262         std::string prohibitorTo;
00263         std::string prohibitedFrom;
00264         std::string prohibitedTo;
00265     };
00266 
00267 
00269     std::map<std::string, EdgeAttrs*> myEdges;
00270 
00272     std::vector<Prohibition> myProhibitions;
00273 
00275     NBNetBuilder& myNetBuilder;
00276 
00278     NBNodeCont& myNodeCont;
00279 
00281     NBTrafficLightLogicCont& myTLLCont;
00282 
00284     EdgeAttrs* myCurrentEdge;
00285 
00287     LaneAttrs* myCurrentLane;
00288 
00290     NBLoadedSUMOTLDef* myCurrentTL;
00291 
00293     GeoConvHelper* myLocation;
00294 
00296     bool mySuspectKeepShape;
00297 
00298     bool myHaveWarnedAboutDeprecatedSpreadType;
00299     bool myHaveWarnedAboutDeprecatedMaxSpeed;
00300 
00305     LaneAttrs* getLaneAttrsFromID(EdgeAttrs* edge, std::string lane_id);
00306 
00312     static void interpretLaneID(const std::string& lane_id, std::string& edge_id, unsigned int& index);
00313 
00319     static PositionVector reconstructEdgeShape(const EdgeAttrs* edge, const Position& from, const Position& to);
00320 
00322     static Position readPosition(const SUMOSAXAttributes& attrs, const std::string& id, bool& ok);
00323 
00330     void parseProhibitionConnection(const std::string& attr, std::string& from, std::string& to, bool& ok);
00331 };
00332 
00333 
00334 #endif
00335 
00336 /****************************************************************************/
00337 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines