SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // A basic edge for routing applications 00011 /****************************************************************************/ 00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00014 /****************************************************************************/ 00015 // 00016 // This file is part of SUMO. 00017 // SUMO is free software: you can redistribute it and/or modify 00018 // it under the terms of the GNU General Public License as published by 00019 // the Free Software Foundation, either version 3 of the License, or 00020 // (at your option) any later version. 00021 // 00022 /****************************************************************************/ 00023 #ifndef ROEdge_h 00024 #define ROEdge_h 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include <string> 00037 #include <map> 00038 #include <vector> 00039 #include <algorithm> 00040 #include <utils/common/ValueTimeLine.h> 00041 #include <utils/common/SUMOVehicleClass.h> 00042 #include <utils/common/SUMOVTypeParameter.h> 00043 #include "RONode.h" 00044 #include "ROVehicle.h" 00045 00046 00047 // =========================================================================== 00048 // class declarations 00049 // =========================================================================== 00050 class ROLane; 00051 class ROVehicle; 00052 00053 00054 // =========================================================================== 00055 // class definitions 00056 // =========================================================================== 00066 class ROEdge { 00067 public: 00072 enum EdgeType { 00074 ET_NORMAL, 00076 ET_DISTRICT, 00078 ET_SOURCE, 00080 ET_SINK 00081 }; 00082 00083 00091 ROEdge(const std::string& id, RONode* from, RONode* to, unsigned int index); 00092 00093 00095 virtual ~ROEdge() ; 00096 00097 00099 00100 00109 virtual void addLane(ROLane* lane) ; 00110 00111 00119 virtual void addFollower(ROEdge* s, std::string dir=""); 00120 00121 00125 void setType(EdgeType type) ; 00126 00127 00137 void buildTimeLines(const std::string& measure) ; 00139 00140 00141 00143 00144 00148 const std::string& getID() const { 00149 return myID; 00150 } 00151 00152 00157 EdgeType getType() const { 00158 return myType; 00159 } 00160 00161 00165 SUMOReal getLength() const { 00166 return myLength; 00167 } 00168 00172 unsigned int getNumericalID() const { 00173 return myIndex; 00174 } 00175 00176 00180 SUMOReal getSpeed() const { 00181 return mySpeed; 00182 } 00183 00184 00188 unsigned int getLaneNo() const { 00189 return (unsigned int) myLanes.size(); 00190 } 00191 00192 00196 RONode* getFromNode() const { 00197 return myFromNode; 00198 } 00199 00200 00204 RONode* getToNode() const { 00205 return myToNode; 00206 } 00207 00208 00214 bool isConnectedTo(const ROEdge* const e) const { 00215 return std::find(myFollowingEdges.begin(), myFollowingEdges.end(), e) != myFollowingEdges.end(); 00216 } 00217 00218 00223 inline bool prohibits(const ROVehicle* const vehicle) const { 00224 const SUMOVehicleClass vclass = vehicle->getVClass(); 00225 return (myCombinedPermissions & vclass) != vclass; 00226 } 00227 00228 inline SVCPermissions getPermissions() const { 00229 return myCombinedPermissions; 00230 } 00231 00232 00237 bool allFollowersProhibit(const ROVehicle* const vehicle) const ; 00239 00240 00241 00243 00244 00251 void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd) ; 00252 00253 00260 void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd) ; 00261 00262 00270 unsigned int getNoFollowing() const ; 00271 00272 00277 ROEdge* getFollower(unsigned int pos) const { 00278 return myFollowingEdges[pos]; 00279 } 00280 00281 00282 #ifdef HAVE_MESOSIM // catchall for internal stuff 00283 00290 unsigned int getNumApproaching() const ; 00291 00292 00297 ROEdge* getApproaching(unsigned int pos) const { 00298 return myApproachingEdges[pos]; 00299 } 00300 #endif 00301 00302 00310 SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const ; 00311 00312 00320 SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const ; 00321 00322 00328 SUMOReal getMinimumTravelTime(const ROVehicle* const veh) const ; 00329 00330 00331 SUMOReal getCOEffort(const ROVehicle* const veh, SUMOReal time) const ; 00332 SUMOReal getCO2Effort(const ROVehicle* const veh, SUMOReal time) const ; 00333 SUMOReal getPMxEffort(const ROVehicle* const veh, SUMOReal time) const ; 00334 SUMOReal getHCEffort(const ROVehicle* const veh, SUMOReal time) const ; 00335 SUMOReal getNOxEffort(const ROVehicle* const veh, SUMOReal time) const ; 00336 SUMOReal getFuelEffort(const ROVehicle* const veh, SUMOReal time) const ; 00337 SUMOReal getNoiseEffort(const ROVehicle* const veh, SUMOReal time) const ; 00339 00340 00342 SUMOReal getDistanceTo(const ROEdge* other) const; 00343 00344 00346 static ROEdge* dictionary(size_t index) ; 00347 00349 static size_t dictSize() { 00350 return myEdges.size(); 00351 }; 00352 00353 static void setTimeLineOptions( 00354 bool useBoundariesOnOverrideTT, 00355 bool useBoundariesOnOverrideE, 00356 bool interpolate) { 00357 myUseBoundariesOnOverrideTT = useBoundariesOnOverrideTT; 00358 myUseBoundariesOnOverrideE = useBoundariesOnOverrideE; 00359 myInterpolate = interpolate; 00360 } 00361 00362 00363 protected: 00370 bool getStoredEffort(SUMOReal time, SUMOReal& ret) const ; 00371 00372 00373 00374 protected: 00376 std::string myID; 00377 00379 SUMOReal mySpeed; 00380 00382 unsigned int myIndex; 00383 00385 SUMOReal myLength; 00386 00387 00389 mutable ValueTimeLine<SUMOReal> myTravelTimes; 00391 bool myUsingTTTimeLine; 00393 static bool myUseBoundariesOnOverrideTT; 00394 00396 mutable ValueTimeLine<SUMOReal> myEfforts; 00398 bool myUsingETimeLine; 00400 static bool myUseBoundariesOnOverrideE; 00401 00403 static bool myInterpolate; 00404 00406 static bool myHaveEWarned; 00408 static bool myHaveTTWarned; 00409 00411 std::vector<ROEdge*> myFollowingEdges; 00412 00413 #ifdef HAVE_MESOSIM // catchall for internal stuff 00414 00415 std::vector<ROEdge*> myApproachingEdges; 00416 #endif 00417 00419 EdgeType myType; 00420 00422 std::vector<ROLane*> myLanes; 00423 00425 SVCPermissions myCombinedPermissions; 00426 00428 RONode* myFromNode, *myToNode; 00429 00430 static std::vector<ROEdge*> myEdges; 00431 00432 private: 00434 ROEdge(const ROEdge& src); 00435 00437 ROEdge& operator=(const ROEdge& src); 00438 00439 }; 00440 00441 00442 #endif 00443 00444 /****************************************************************************/ 00445