SUMO - Simulation of Urban MObility
NIImporter_ITSUMO.h
Go to the documentation of this file.
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-2012 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This file is part of SUMO.
00014 //   SUMO is free software: you can redistribute it and/or modify
00015 //   it under the terms of the GNU General Public License as published by
00016 //   the Free Software Foundation, either version 3 of the License, or
00017 //   (at your option) any later version.
00018 //
00019 /****************************************************************************/
00020 #ifndef NIImporter_ITSUMO_h
00021 #define NIImporter_ITSUMO_h
00022 
00023 
00024 // ===========================================================================
00025 // included modules
00026 // ===========================================================================
00027 #ifdef _MSC_VER
00028 #include <windows_config.h>
00029 #else
00030 #include <config.h>
00031 #endif
00032 
00033 #include <string>
00034 #include <map>
00035 #include <netbuild/NBCapacity2Lanes.h>
00036 #include <utils/xml/SUMOSAXHandler.h>
00037 #include <utils/common/UtilExceptions.h>
00038 
00039 
00040 // ===========================================================================
00041 // class declarations
00042 // ===========================================================================
00043 class NBEdge;
00044 class NBEdgeCont;
00045 class NBNetBuilder;
00046 class NBNode;
00047 class NBNodeCont;
00048 class NBTrafficLightLogicCont;
00049 class NBTypeCont;
00050 class OptionsCont;
00051 
00052 
00053 // ===========================================================================
00054 // class definitions
00055 // ===========================================================================
00061 class NIImporter_ITSUMO {
00062 public:
00074     static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
00075 
00076 
00077 private:
00082     class Handler : public GenericSAXHandler {
00083     public:
00087         Handler(NBNetBuilder& toFill) ;
00088 
00089 
00091         ~Handler() ;
00092 
00093 
00094     protected:
00096 
00097 
00105         void myStartElement(int element, const SUMOSAXAttributes& attrs) ;
00106 
00107 
00116         void myCharacters(int element, const std::string& chars);
00117 
00118 
00125         void myEndElement(int element);
00127 
00128 
00129     private:
00131         NBNetBuilder& myNetBuilder;
00132 
00134         std::map<std::string, std::string> myParameter;
00135 
00136 
00137         struct Lane {
00138         public:
00139             Lane(const std::string& id, unsigned int idx, SUMOReal v)
00140                 : myID(id), myIndex(idx), myV(v) {}
00141             std::string myID;
00142             unsigned int myIndex;
00143             SUMOReal myV;
00144         };
00145 
00146         std::vector<Lane> myCurrentLanes;
00147 
00148         struct LaneSet {
00149         public:
00150             LaneSet(const std::string& id, const std::vector<Lane> &lanes, SUMOReal v, int pos, NBNode* from, NBNode* to)
00151                 : myID(id), myLanes(lanes), myV(v), myPosition(pos), myFrom(from), myTo(to) {}
00152             std::string myID;
00153             std::vector<Lane> myLanes;
00154             SUMOReal myV;
00155             int myPosition;
00156             NBNode* myFrom;
00157             NBNode* myTo;
00158         };
00159 
00160         std::map<std::string, LaneSet*> myLaneSets;
00161         std::vector<LaneSet*> myCurrentLaneSets;
00162 
00163         struct Section {
00164         public:
00165             Section(const std::string& id, const std::vector<LaneSet*> &laneSets)
00166                 : myID(id), myLaneSets(laneSets) {}
00167             std::string myID;
00168             std::vector<LaneSet*> myLaneSets;
00169         };
00170 
00171         std::vector<Section*> mySections;
00172 
00173 
00174     private:
00176         Handler(const Handler& s);
00177 
00179         Handler& operator=(const Handler& s);
00180 
00181     };
00182 
00183 
00184 
00190     enum ItsumoXMLTag {
00191         ITSUMO_TAG_NOTHING = 0,
00192         ITSUMO_TAG_SIMULATION,
00193         ITSUMO_TAG_NETWORK_ID,
00194         ITSUMO_TAG_NETWORK_NAME,
00195         ITSUMO_TAG_NODES,
00196         ITSUMO_TAG_NODE,
00197         ITSUMO_TAG_NODE_ID,
00198         ITSUMO_TAG_NODE_NAME,
00199         ITSUMO_TAG_X_COORD,
00200         ITSUMO_TAG_Y_COORD,
00201         ITSUMO_TAG_SOURCES,
00202         ITSUMO_TAG_SINKS,
00203         ITSUMO_TAG_TRAFFIC_LIGHTS,
00204         ITSUMO_TAG_STREETS,
00205         ITSUMO_TAG_STREET,
00206         ITSUMO_TAG_STREET_ID,
00207         ITSUMO_TAG_STREET_NAME,
00208         ITSUMO_TAG_SECTIONS,
00209         ITSUMO_TAG_SECTION,
00210         ITSUMO_TAG_SECTION_ID,
00211         ITSUMO_TAG_SECTION_NAME,
00212         ITSUMO_TAG_IS_PREFERENCIAL,
00213         ITSUMO_TAG_DELIMITING_NODE,
00214         ITSUMO_TAG_LANESETS,
00215         ITSUMO_TAG_LANESET,
00216         ITSUMO_TAG_LANESET_ID,
00217         ITSUMO_TAG_LANESET_POSITION,
00218         ITSUMO_TAG_START_NODE,
00219         ITSUMO_TAG_END_NODE,
00220         ITSUMO_TAG_TURNING_PROBABILITIES,
00221         ITSUMO_TAG_DIRECTION,
00222         ITSUMO_TAG_DESTINATION_LANESET,
00223         ITSUMO_TAG_PROBABILITY,
00224         ITSUMO_TAG_LANES,
00225         ITSUMO_TAG_LANE,
00226         ITSUMO_TAG_LANE_ID,
00227         ITSUMO_TAG_LANE_POSITION,
00228         ITSUMO_TAG_MAXIMUM_SPEED,
00229         ITSUMO_TAG_DECELERATION_PROB
00230     };
00231 
00232 
00238     enum ItsumoXMLAttr {
00239         ITSUMO_ATTR_NOTHING = 0
00240     };
00241 
00243     static StringBijection<int>::Entry itsumoTags[];
00244 
00246     static StringBijection<int>::Entry itsumoAttrs[];
00247 
00248 
00249 };
00250 
00251 
00252 #endif
00253 
00254 /****************************************************************************/
00255 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines