SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ROEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // A basic edge for routing applications
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef ROEdge_h
24 #define ROEdge_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <map>
38 #include <vector>
39 #include <algorithm>
43 #include "RONode.h"
44 #include "ROVehicle.h"
45 
46 
47 // ===========================================================================
48 // class declarations
49 // ===========================================================================
50 class ROLane;
51 class ROVehicle;
52 
53 
54 // ===========================================================================
55 // class definitions
56 // ===========================================================================
66 class ROEdge {
67 public:
72  enum EdgeType {
81  };
82 
83 
91  ROEdge(const std::string& id, RONode* from, RONode* to, unsigned int index);
92 
93 
95  virtual ~ROEdge();
96 
97 
99 
100 
109  virtual void addLane(ROLane* lane);
110 
111 
119  virtual void addFollower(ROEdge* s, std::string dir = "");
120 
121 
125  void setType(EdgeType type);
126 
127 
137  void buildTimeLines(const std::string& measure);
139 
140 
141 
143 
144 
148  const std::string& getID() const {
149  return myID;
150  }
151 
152 
157  EdgeType getType() const {
158  return myType;
159  }
160 
161 
165  SUMOReal getLength() const {
166  return myLength;
167  }
168 
172  unsigned int getNumericalID() const {
173  return myIndex;
174  }
175 
176 
180  SUMOReal getSpeed() const {
181  return mySpeed;
182  }
183 
184 
188  unsigned int getLaneNo() const {
189  return (unsigned int) myLanes.size();
190  }
191 
192 
196  RONode* getFromNode() const {
197  return myFromNode;
198  }
199 
200 
204  RONode* getToNode() const {
205  return myToNode;
206  }
207 
208 
214  bool isConnectedTo(const ROEdge* const e) const {
215  return std::find(myFollowingEdges.begin(), myFollowingEdges.end(), e) != myFollowingEdges.end();
216  }
217 
218 
223  inline bool prohibits(const ROVehicle* const vehicle) const {
224  const SUMOVehicleClass vclass = vehicle->getVClass();
225  return (myCombinedPermissions & vclass) != vclass;
226  }
227 
229  return myCombinedPermissions;
230  }
231 
232 
237  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
239 
240 
241 
243 
244 
251  void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
252 
253 
260  void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
261 
262 
270  unsigned int getNoFollowing() const;
271 
272 
277  ROEdge* getFollower(unsigned int pos) const {
278  return myFollowingEdges[pos];
279  }
280 
281 
282 #ifdef HAVE_INTERNAL // catchall for internal stuff
283 
290  unsigned int getNumApproaching() const;
291 
292 
297  ROEdge* getApproaching(unsigned int pos) const {
298  return myApproachingEdges[pos];
299  }
300 #endif
301 
302 
310  SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const;
311 
312 
319  SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const;
320 
321 
328  SUMOReal getTravelTime(const SUMOReal maxSpeed, SUMOReal time) const;
329 
330 
336  SUMOReal getMinimumTravelTime(const ROVehicle* const veh) const;
337 
338 
339  SUMOReal getCOEffort(const ROVehicle* const veh, SUMOReal time) const;
340  SUMOReal getCO2Effort(const ROVehicle* const veh, SUMOReal time) const;
341  SUMOReal getPMxEffort(const ROVehicle* const veh, SUMOReal time) const;
342  SUMOReal getHCEffort(const ROVehicle* const veh, SUMOReal time) const;
343  SUMOReal getNOxEffort(const ROVehicle* const veh, SUMOReal time) const;
344  SUMOReal getFuelEffort(const ROVehicle* const veh, SUMOReal time) const;
345  SUMOReal getNoiseEffort(const ROVehicle* const veh, SUMOReal time) const;
347 
348 
350  SUMOReal getDistanceTo(const ROEdge* other) const;
351 
352 
354  static ROEdge* dictionary(size_t index);
355 
357  static size_t dictSize() {
358  return myEdges.size();
359  };
360 
361  static void setTimeLineOptions(
362  bool useBoundariesOnOverrideTT,
363  bool useBoundariesOnOverrideE,
364  bool interpolate) {
365  myUseBoundariesOnOverrideTT = useBoundariesOnOverrideTT;
366  myUseBoundariesOnOverrideE = useBoundariesOnOverrideE;
367  myInterpolate = interpolate;
368  }
369 
370 
371 protected:
378  bool getStoredEffort(SUMOReal time, SUMOReal& ret) const;
379 
380 
381 
382 protected:
384  std::string myID;
385 
388 
390  unsigned int myIndex;
391 
394 
395 
402 
409 
411  static bool myInterpolate;
412 
414  static bool myHaveEWarned;
416  static bool myHaveTTWarned;
417 
419  std::vector<ROEdge*> myFollowingEdges;
420 
421 #ifdef HAVE_INTERNAL // catchall for internal stuff
422 
423  std::vector<ROEdge*> myApproachingEdges;
424 #endif
425 
428 
430  std::vector<ROLane*> myLanes;
431 
434 
437 
438  static std::vector<ROEdge*> myEdges;
439 
440 
441 private:
448  SUMOReal getTravelTime(SUMOReal time) const;
449 
450 private:
452  ROEdge(const ROEdge& src);
453 
455  ROEdge& operator=(const ROEdge& src);
456 
457 };
458 
459 
460 #endif
461 
462 /****************************************************************************/
463