|
SUMO - Simulation of Urban MObility
|
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/VectorHelper.h> 00041 #include <utils/common/UtilExceptions.h> 00042 #include "NIVissimAbstractEdge.h" 00043 #include "NIVissimClosedLanesVector.h" 00044 00045 00046 // =========================================================================== 00047 // class declarations 00048 // =========================================================================== 00049 class NBNode; 00050 class NIVissimDistrictConnection; 00051 class NBDistribution; 00052 class NBDistrictCont; 00053 00054 00055 // =========================================================================== 00056 // class definitions 00057 // =========================================================================== 00062 class NIVissimEdge 00063 : public NIVissimAbstractEdge { 00064 public: 00066 NIVissimEdge(int id, const std::string& name, 00067 const std::string& type, int noLanes, SUMOReal zuschlag1, 00068 SUMOReal zuschlag2, SUMOReal length, 00069 const PositionVector& geom, 00070 const NIVissimClosedLanesVector& clv); 00071 00073 ~NIVissimEdge(); 00074 00075 void setNodeCluster(int nodeid); 00076 void buildGeom(); 00077 00079 void addIncomingConnection(int id); 00080 00082 void addOutgoingConnection(int id); 00083 00086 NBNode* getNodeAt(const Position& p, NBNode* other = 0); 00087 00089 Position getBegin2D() const; 00090 00092 Position getEnd2D() const; 00093 00095 SUMOReal getLength() const; 00096 00097 void checkDistrictConnectionExistanceAt(SUMOReal pos); 00098 00099 void mergedInto(NIVissimConnectionCluster* old, 00100 NIVissimConnectionCluster* act); 00101 00102 void removeFromConnectionCluster(NIVissimConnectionCluster* c); 00103 void addToConnectionCluster(NIVissimConnectionCluster* c); 00104 void setSpeed(size_t lane, int speedDist); 00105 bool addToTreatAsSame(NIVissimEdge* e); 00106 00107 NIVissimConnection* getConnectionTo(NIVissimEdge* e); 00108 const std::vector<NIVissimEdge*> &getToTreatAsSame() const; 00109 00110 00114 bool wasWithinAJunction() const { 00115 return myAmWithinJunction; 00116 } 00117 00118 NIVissimEdge* getBestIncoming() const ; 00119 NIVissimEdge* getBestOutgoing() const ; 00120 00121 friend class NIVissimNodeDef_Edges; 00122 friend class NIVissimNodeDef_Poly; 00123 00124 public: 00127 static bool dictionary(int id, const std::string& name, 00128 const std::string& type, int noLanes, SUMOReal zuschlag1, 00129 SUMOReal zuschlag2, SUMOReal length, 00130 const PositionVector& geom, 00131 const NIVissimClosedLanesVector& clv); 00132 00134 static bool dictionary(int id, NIVissimEdge* o); 00135 00137 static NIVissimEdge* dictionary(int id); 00138 00147 static void buildConnectionClusters() ; 00148 00150 static void dict_buildNBEdges(NBDistrictCont& dc, NBNodeCont& nc, 00151 NBEdgeCont& ec, SUMOReal offset); 00152 00153 static void dict_propagateSpeeds(/* NBDistribution &dc */); 00154 00155 static void dict_checkEdges2Join(); 00156 00157 00166 static void reportUnsetSpeeds() ; 00167 00168 00169 private: 00171 typedef std::vector<NIVissimConnectionCluster*> ConnectionClusters; 00172 00173 private: 00182 void buildNBEdge(NBDistrictCont& dc, NBNodeCont& nc, 00183 NBEdgeCont& ec, SUMOReal sameNodesOffset) ; 00184 00186 std::pair<NIVissimConnectionCluster*, NBNode*> 00187 getFromNode(NBNodeCont& nc, ConnectionClusters& clusters); 00188 00190 std::pair<NIVissimConnectionCluster*, NBNode*> 00191 getToNode(NBNodeCont& nc, ConnectionClusters& clusters); 00192 00194 std::pair<NBNode*, NBNode*> resolveSameNode(NBNodeCont& nc, 00195 SUMOReal offset, NBNode* prevFrom, NBNode* prevTo); 00196 00197 // SUMOReal recheckSpeedPatches(); 00198 00199 std::vector<NIVissimConnection*> getOutgoingConnected(int lane) const; 00200 00201 void propagateSpeed(/* NBDistribution &dc */SUMOReal speed, IntVector forLanes); 00202 00203 00204 void setDistrictSpeed(/* NBDistribution &dc */); 00205 SUMOReal getRealSpeed(/* NBDistribution &dc */int distNo); 00206 void checkUnconnectedLaneSpeeds(/* NBDistribution &dc */); 00207 void propagateOwn(/* NBDistribution &dc */); 00208 00209 00210 00211 private: 00212 static NBNode* getNodeSecure(int nodeid, const Position& pos, 00213 const std::string& possibleName); 00214 00215 std::pair<NBNode*, NBNode*> 00216 remapOneOfNodes(NBNodeCont& nc, 00217 NIVissimDistrictConnection* d, 00218 NBNode* fromNode, NBNode* toNode); 00219 00220 private: 00225 class connection_position_sorter { 00226 public: 00228 explicit connection_position_sorter(int edgeid); 00229 00231 int operator()(int c1id, int c2id) const; 00232 00233 private: 00235 int myEdgeID; 00236 00237 }; 00238 00239 00244 class connection_cluster_position_sorter { 00245 public: 00247 explicit connection_cluster_position_sorter(int edgeid); 00248 00250 int operator()(NIVissimConnectionCluster* cc1, 00251 NIVissimConnectionCluster* cc2) const; 00252 00253 private: 00255 int myEdgeID; 00256 00257 }; 00258 00259 private: 00261 std::string myName; 00262 00264 std::string myType; 00265 00267 unsigned int myNoLanes; 00268 00270 SUMOReal myZuschlag1, myZuschlag2; 00271 00273 NIVissimClosedLanesVector myClosedLanes; 00274 00276 ConnectionClusters myConnectionClusters; 00277 00279 IntVector myIncomingConnections; 00280 00282 IntVector myOutgoingConnections; 00283 00284 DoubleVector myDistrictConnections; 00285 00286 IntVector myPatchedSpeeds; 00287 00288 std::vector<SUMOReal> myLaneSpeeds; 00289 00290 std::vector<NIVissimEdge*> myToTreatAsSame; 00291 00293 bool myAmWithinJunction; 00294 00295 private: 00297 typedef std::map<int, NIVissimEdge*> DictType; 00298 00300 static DictType myDict; 00301 00303 static int myMaxID; 00304 00305 static std::vector<std::string> myLanesWithMissingSpeeds; 00306 00307 }; 00308 00309 00310 #endif 00311 00312 /****************************************************************************/ 00313