SUMO - Simulation of Urban MObility
NIVissimEdge.h
Go to the documentation of this file.
00001 /****************************************************************************/
00008 // A temporary storage for edges imported from Vissim
00009 /****************************************************************************/
00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00012 /****************************************************************************/
00013 //
00014 //   This file is part of SUMO.
00015 //   SUMO is free software: you can redistribute it and/or modify
00016 //   it under the terms of the GNU General Public License as published by
00017 //   the Free Software Foundation, either version 3 of the License, or
00018 //   (at your option) any later version.
00019 //
00020 /****************************************************************************/
00021 #ifndef NIVissimEdge_h
00022 #define NIVissimEdge_h
00023 
00024 
00025 // ===========================================================================
00026 // included modules
00027 // ===========================================================================
00028 #ifdef _MSC_VER
00029 #include <windows_config.h>
00030 #else
00031 #include <config.h>
00032 #endif
00033 
00034 #include "NIVissimConnectionCluster.h"
00035 #include <vector>
00036 #include <string>
00037 #include <map>
00038 #include <netbuild/NBEdge.h>
00039 #include <utils/geom/PositionVector.h>
00040 #include <utils/common/UtilExceptions.h>
00041 #include "NIVissimAbstractEdge.h"
00042 #include "NIVissimClosedLanesVector.h"
00043 
00044 
00045 // ===========================================================================
00046 // class declarations
00047 // ===========================================================================
00048 class NBNode;
00049 class NIVissimDistrictConnection;
00050 class NBDistribution;
00051 class NBDistrictCont;
00052 
00053 
00054 // ===========================================================================
00055 // class definitions
00056 // ===========================================================================
00061 class NIVissimEdge
00062         : public NIVissimAbstractEdge {
00063 public:
00065     NIVissimEdge(int id, const std::string& name,
00066                  const std::string& type, int noLanes, SUMOReal zuschlag1,
00067                  SUMOReal zuschlag2, SUMOReal length,
00068                  const PositionVector& geom,
00069                  const NIVissimClosedLanesVector& clv);
00070 
00072     ~NIVissimEdge();
00073 
00074     void setNodeCluster(int nodeid);
00075     void buildGeom();
00076 
00078     void addIncomingConnection(int id);
00079 
00081     void addOutgoingConnection(int id);
00082 
00085     NBNode* getNodeAt(const Position& p, NBNode* other = 0);
00086 
00088     Position getBegin2D() const;
00089 
00091     Position getEnd2D() const;
00092 
00094     SUMOReal getLength() const;
00095 
00096     void checkDistrictConnectionExistanceAt(SUMOReal pos);
00097 
00098     void mergedInto(NIVissimConnectionCluster* old,
00099                     NIVissimConnectionCluster* act);
00100 
00101     void removeFromConnectionCluster(NIVissimConnectionCluster* c);
00102     void addToConnectionCluster(NIVissimConnectionCluster* c);
00103     void setSpeed(size_t lane, int speedDist);
00104     bool addToTreatAsSame(NIVissimEdge* e);
00105 
00106     NIVissimConnection* getConnectionTo(NIVissimEdge* e);
00107     const std::vector<NIVissimEdge*> &getToTreatAsSame() const;
00108 
00109 
00113     bool wasWithinAJunction() const {
00114         return myAmWithinJunction;
00115     }
00116 
00117     NIVissimEdge* getBestIncoming() const ;
00118     NIVissimEdge* getBestOutgoing() const ;
00119 
00120     friend class NIVissimNodeDef_Edges;
00121     friend class NIVissimNodeDef_Poly;
00122 
00123 public:
00126     static bool dictionary(int id, const std::string& name,
00127                            const std::string& type, int noLanes, SUMOReal zuschlag1,
00128                            SUMOReal zuschlag2, SUMOReal length,
00129                            const PositionVector& geom,
00130                            const NIVissimClosedLanesVector& clv);
00131 
00133     static bool dictionary(int id, NIVissimEdge* o);
00134 
00136     static NIVissimEdge* dictionary(int id);
00137 
00146     static void buildConnectionClusters() ;
00147 
00149     static void dict_buildNBEdges(NBDistrictCont& dc, NBNodeCont& nc,
00150                                   NBEdgeCont& ec, SUMOReal offset);
00151 
00152     static void dict_propagateSpeeds(/* NBDistribution &dc */);
00153 
00154     static void dict_checkEdges2Join();
00155 
00156 
00165     static void reportUnsetSpeeds() ;
00166 
00167 
00168 private:
00170     typedef std::vector<NIVissimConnectionCluster*> ConnectionClusters;
00171 
00172 private:
00181     void buildNBEdge(NBDistrictCont& dc, NBNodeCont& nc,
00182                      NBEdgeCont& ec, SUMOReal sameNodesOffset) ;
00183 
00185     std::pair<NIVissimConnectionCluster*, NBNode*>
00186     getFromNode(NBNodeCont& nc, ConnectionClusters& clusters);
00187 
00189     std::pair<NIVissimConnectionCluster*, NBNode*>
00190     getToNode(NBNodeCont& nc, ConnectionClusters& clusters);
00191 
00193     std::pair<NBNode*, NBNode*> resolveSameNode(NBNodeCont& nc,
00194             SUMOReal offset, NBNode* prevFrom, NBNode* prevTo);
00195 
00196 //    SUMOReal recheckSpeedPatches();
00197 
00198     std::vector<NIVissimConnection*> getOutgoingConnected(int lane) const;
00199 
00200     void propagateSpeed(/* NBDistribution &dc */SUMOReal speed, std::vector<int> forLanes);
00201 
00202 
00203     void setDistrictSpeed(/* NBDistribution &dc */);
00204     SUMOReal getRealSpeed(/* NBDistribution &dc */int distNo);
00205     void checkUnconnectedLaneSpeeds(/* NBDistribution &dc */);
00206     void propagateOwn(/* NBDistribution &dc */);
00207 
00208 
00209 
00210 private:
00211     static NBNode* getNodeSecure(int nodeid, const Position& pos,
00212                                  const std::string& possibleName);
00213 
00214     std::pair<NBNode*, NBNode*>
00215     remapOneOfNodes(NBNodeCont& nc,
00216                     NIVissimDistrictConnection* d,
00217                     NBNode* fromNode, NBNode* toNode);
00218 
00219 private:
00224     class connection_position_sorter {
00225     public:
00227         explicit connection_position_sorter(int edgeid);
00228 
00230         int operator()(int c1id, int c2id) const;
00231 
00232     private:
00234         int myEdgeID;
00235 
00236     };
00237 
00238 
00243     class connection_cluster_position_sorter {
00244     public:
00246         explicit connection_cluster_position_sorter(int edgeid);
00247 
00249         int operator()(NIVissimConnectionCluster* cc1,
00250                        NIVissimConnectionCluster* cc2) const;
00251 
00252     private:
00254         int myEdgeID;
00255 
00256     };
00257 
00258 private:
00260     std::string myName;
00261 
00263     std::string myType;
00264 
00266     unsigned int myNoLanes;
00267 
00269     SUMOReal myZuschlag1, myZuschlag2;
00270 
00272     NIVissimClosedLanesVector myClosedLanes;
00273 
00275     ConnectionClusters myConnectionClusters;
00276 
00278     std::vector<int> myIncomingConnections;
00279 
00281     std::vector<int> myOutgoingConnections;
00282 
00283     std::vector<SUMOReal> myDistrictConnections;
00284 
00285     std::vector<int> myPatchedSpeeds;
00286 
00287     std::vector<SUMOReal> myLaneSpeeds;
00288 
00289     std::vector<NIVissimEdge*> myToTreatAsSame;
00290 
00292     bool myAmWithinJunction;
00293 
00294 private:
00296     typedef std::map<int, NIVissimEdge*> DictType;
00297 
00299     static DictType myDict;
00300 
00302     static int myMaxID;
00303 
00304     static std::vector<std::string> myLanesWithMissingSpeeds;
00305 
00306 };
00307 
00308 
00309 #endif
00310 
00311 /****************************************************************************/
00312 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines