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-sim.org/
13 // Copyright (C) 2001-2013 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>
40 #include <utils/common/Named.h>
44 #include "RONode.h"
45 #include "ROVehicle.h"
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class ROLane;
52 class ROVehicle;
53 
54 
55 // ===========================================================================
56 // class definitions
57 // ===========================================================================
67 class ROEdge : public Named {
68 public:
73  enum EdgeType {
84  };
85 
86 
94  ROEdge(const std::string& id, RONode* from, RONode* to, unsigned int index, const int priority);
95 
96 
98  virtual ~ROEdge();
99 
100 
102 
103 
112  virtual void addLane(ROLane* lane);
113 
114 
122  virtual void addFollower(ROEdge* s, std::string dir = "");
123 
124 
128  void setType(EdgeType type);
129 
130 
140  void buildTimeLines(const std::string& measure);
142 
143 
144 
146 
147 
152  EdgeType getType() const {
153  return myType;
154  }
155 
156 
160  SUMOReal getLength() const {
161  return myLength;
162  }
163 
167  unsigned int getNumericalID() const {
168  return myIndex;
169  }
170 
171 
175  SUMOReal getSpeed() const {
176  return mySpeed;
177  }
178 
179 
183  unsigned int getLaneNo() const {
184  return (unsigned int) myLanes.size();
185  }
186 
187 
191  RONode* getFromNode() const {
192  return myFromNode;
193  }
194 
195 
199  RONode* getToNode() const {
200  return myToNode;
201  }
202 
203 
209  bool isConnectedTo(const ROEdge* const e) const {
210  return std::find(myFollowingEdges.begin(), myFollowingEdges.end(), e) != myFollowingEdges.end();
211  }
212 
213 
218  inline bool prohibits(const ROVehicle* const vehicle) const {
219  const SUMOVehicleClass vclass = vehicle->getVClass();
220  return (myCombinedPermissions & vclass) != vclass;
221  }
222 
224  return myCombinedPermissions;
225  }
226 
227 
232  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
234 
235 
236 
238 
239 
246  void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
247 
248 
255  void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
256 
257 
265  unsigned int getNoFollowing() const;
266 
267 
272  ROEdge* getFollower(unsigned int pos) const {
273  return myFollowingEdges[pos];
274  }
275 
276 
284  unsigned int getNumApproaching() const;
285 
286 
291  ROEdge* getApproaching(unsigned int pos) const {
292  return myApproachingEdges[pos];
293  }
294 
295 
303  SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const;
304 
305 
312  SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const;
313 
314 
321  SUMOReal getTravelTime(const SUMOReal maxSpeed, SUMOReal time) const;
322 
323 
329  SUMOReal getMinimumTravelTime(const ROVehicle* const veh) const;
330 
331 
332  SUMOReal getCOEffort(const ROVehicle* const veh, SUMOReal time) const;
333  SUMOReal getCO2Effort(const ROVehicle* const veh, SUMOReal time) const;
334  SUMOReal getPMxEffort(const ROVehicle* const veh, SUMOReal time) const;
335  SUMOReal getHCEffort(const ROVehicle* const veh, SUMOReal time) const;
336  SUMOReal getNOxEffort(const ROVehicle* const veh, SUMOReal time) const;
337  SUMOReal getFuelEffort(const ROVehicle* const veh, SUMOReal time) const;
338  SUMOReal getNoiseEffort(const ROVehicle* const veh, SUMOReal time) const;
340 
341 
343  SUMOReal getDistanceTo(const ROEdge* other) const;
344 
345 
347  static ROEdge* dictionary(size_t index);
348 
350  static size_t dictSize() {
351  return myEdges.size();
352  };
353 
354  static void setTimeLineOptions(
355  bool useBoundariesOnOverrideTT,
356  bool useBoundariesOnOverrideE,
357  bool interpolate) {
358  myUseBoundariesOnOverrideTT = useBoundariesOnOverrideTT;
359  myUseBoundariesOnOverrideE = useBoundariesOnOverrideE;
360  myInterpolate = interpolate;
361  }
362 
364  int getPriority() const {
365  return myPriority;
366  }
367 
368 protected:
375  bool getStoredEffort(SUMOReal time, SUMOReal& ret) const;
376 
377 
378 
379 protected:
381  RONode* const myFromNode, * const myToNode;
382 
384  const unsigned int myIndex;
385 
387  const int myPriority;
388 
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 
422  std::vector<ROEdge*> myApproachingEdges;
423 
426 
428  std::vector<ROLane*> myLanes;
429 
432 
433  static std::vector<ROEdge*> myEdges;
434 
435 
436 private:
443  SUMOReal getTravelTime(SUMOReal time) const;
444 
445 private:
447  ROEdge(const ROEdge& src);
448 
450  ROEdge& operator=(const ROEdge& src);
451 
452 };
453 
454 
455 #endif
456 
457 /****************************************************************************/
458