|
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 "RONode.h" 00043 00044 00045 // =========================================================================== 00046 // class declarations 00047 // =========================================================================== 00048 class ROLane; 00049 class ROVehicle; 00050 00051 00052 // =========================================================================== 00053 // class definitions 00054 // =========================================================================== 00064 class ROEdge { 00065 public: 00070 enum EdgeType { 00072 ET_NORMAL, 00074 ET_DISTRICT, 00076 ET_SOURCE, 00078 ET_SINK 00079 }; 00080 00081 00092 ROEdge(const std::string& id, RONode* from, RONode* to, unsigned int index, 00093 bool useBoundariesOnOverride, bool interpolate = false) ; 00094 00095 00097 virtual ~ROEdge() ; 00098 00099 00101 00102 00111 virtual void addLane(ROLane* lane) ; 00112 00113 00121 virtual void addFollower(ROEdge* s) ; 00122 00123 00127 void setType(EdgeType type) ; 00128 00129 00139 void buildTimeLines(const std::string& measure) ; 00141 00142 00143 00145 00146 00150 const std::string& getID() const { 00151 return myID; 00152 } 00153 00154 00159 EdgeType getType() const { 00160 return myType; 00161 } 00162 00163 00167 SUMOReal getLength() const { 00168 return myLength; 00169 } 00170 00174 unsigned int getNumericalID() const { 00175 return myIndex; 00176 } 00177 00178 00182 SUMOReal getSpeed() const { 00183 return mySpeed; 00184 } 00185 00186 00190 unsigned int getLaneNo() const { 00191 return (unsigned int) myLanes.size(); 00192 } 00193 00194 00198 RONode* getFromNode() const { 00199 return myFromNode; 00200 } 00201 00202 00206 RONode* getToNode() const { 00207 return myToNode; 00208 } 00209 00210 00216 bool isConnectedTo(const ROEdge* const e) const { 00217 return std::find(myFollowingEdges.begin(), myFollowingEdges.end(), e) != myFollowingEdges.end(); 00218 } 00219 00220 00225 bool prohibits(const ROVehicle* const vehicle) const ; 00226 00227 00232 bool allFollowersProhibit(const ROVehicle* const vehicle) const ; 00234 00235 00236 00238 00239 00246 void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd) ; 00247 00248 00255 void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd) ; 00256 00257 00265 unsigned int getNoFollowing() const ; 00266 00267 00272 ROEdge* getFollower(unsigned int pos) const { 00273 return myFollowingEdges[pos]; 00274 } 00275 00276 00284 SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const ; 00285 00286 00294 SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const ; 00295 00296 00297 SUMOReal getCOEffort(const ROVehicle* const veh, SUMOReal time) const ; 00298 SUMOReal getCO2Effort(const ROVehicle* const veh, SUMOReal time) const ; 00299 SUMOReal getPMxEffort(const ROVehicle* const veh, SUMOReal time) const ; 00300 SUMOReal getHCEffort(const ROVehicle* const veh, SUMOReal time) const ; 00301 SUMOReal getNOxEffort(const ROVehicle* const veh, SUMOReal time) const ; 00302 SUMOReal getFuelEffort(const ROVehicle* const veh, SUMOReal time) const ; 00303 SUMOReal getNoiseEffort(const ROVehicle* const veh, SUMOReal time) const ; 00305 00307 static ROEdge* dictionary(size_t index) ; 00308 00309 00310 protected: 00317 bool getStoredEffort(SUMOReal time, SUMOReal& ret) const ; 00318 00319 00320 00321 protected: 00323 std::string myID; 00324 00326 SUMOReal mySpeed; 00327 00329 unsigned int myIndex; 00330 00332 SUMOReal myLength; 00333 00334 00336 mutable ValueTimeLine<SUMOReal> myTravelTimes; 00338 bool myUsingTTTimeLine; 00340 bool myUseBoundariesOnOverrideTT; 00342 static bool myHaveTTWarned; 00343 00345 mutable ValueTimeLine<SUMOReal> myEfforts; 00347 bool myUsingETimeLine; 00349 bool myUseBoundariesOnOverrideE; 00351 static bool myHaveEWarned; 00352 00354 bool myInterpolate; 00355 00356 00358 std::vector<ROEdge*> myFollowingEdges; 00359 00361 EdgeType myType; 00362 00364 std::vector<ROLane*> myLanes; 00365 00367 SUMOVehicleClasses myAllowedClasses; 00368 00370 SUMOVehicleClasses myNotAllowedClasses; 00371 00373 RONode* myFromNode, *myToNode; 00374 00375 static std::vector<ROEdge*> myEdges; 00376 00377 private: 00379 ROEdge(const ROEdge& src); 00380 00382 ROEdge& operator=(const ROEdge& src); 00383 00384 }; 00385 00386 00387 #endif 00388 00389 /****************************************************************************/ 00390