SUMO - Simulation of Urban MObility
ROEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
12 // A basic edge for routing applications
13 /****************************************************************************/
14 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
15 // Copyright (C) 2002-2014 DLR (http://www.dlr.de/) and contributors
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 #ifndef ROEdge_h
26 #define ROEdge_h
27 
28 
29 // ===========================================================================
30 // included modules
31 // ===========================================================================
32 #ifdef _MSC_VER
33 #include <windows_config.h>
34 #else
35 #include <config.h>
36 #endif
37 
38 #include <string>
39 #include <map>
40 #include <vector>
41 #include <algorithm>
42 #include <utils/common/Named.h>
43 #include <utils/common/StdDefs.h>
47 #include "RONode.h"
48 #include "ROVehicle.h"
49 
50 
51 // ===========================================================================
52 // class declarations
53 // ===========================================================================
54 class ROLane;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
69 class ROEdge : public Named {
70 public:
75  enum EdgeType {
90  };
91 
92 
100  ROEdge(const std::string& id, RONode* from, RONode* to, unsigned int index, const int priority);
101 
102 
104  virtual ~ROEdge();
105 
106 
108 
109 
118  virtual void addLane(ROLane* lane);
119 
120 
128  virtual void addFollower(ROEdge* s, std::string dir = "");
129 
130 
134  void setType(EdgeType type);
135 
137  inline bool isInternal() const {
138  return myType == ET_INTERNAL;
139  }
140 
142  inline bool isCrossing() const {
143  return myType == ET_CROSSING;
144  }
145 
147  inline bool isWalkingArea() const {
148  return myType == ET_WALKINGAREA;
149  }
150 
160  void buildTimeLines(const std::string& measure);
162 
163 
164 
166 
167 
172  EdgeType getType() const {
173  return myType;
174  }
175 
176 
180  SUMOReal getLength() const {
181  return myLength;
182  }
183 
187  unsigned int getNumericalID() const {
188  return myIndex;
189  }
190 
191 
195  SUMOReal getSpeed() const {
196  return mySpeed;
197  }
198 
199 
203  unsigned int getLaneNo() const {
204  return (unsigned int) myLanes.size();
205  }
206 
207 
211  RONode* getFromNode() const {
212  return myFromNode;
213  }
214 
215 
219  RONode* getToNode() const {
220  return myToNode;
221  }
222 
223 
229  bool isConnectedTo(const ROEdge* const e) const {
230  return std::find(myFollowingEdges.begin(), myFollowingEdges.end(), e) != myFollowingEdges.end();
231  }
232 
233 
238  inline bool prohibits(const ROVehicle* const vehicle) const {
239  const SUMOVehicleClass vclass = vehicle->getVClass();
240  return (myCombinedPermissions & vclass) != vclass;
241  }
242 
244  return myCombinedPermissions;
245  }
246 
247 
252  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
254 
255 
256 
258 
259 
266  void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
267 
268 
275  void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
276 
277 
285  unsigned int getNoFollowing() const;
286 
287 
292  ROEdge* getFollower(unsigned int pos) const {
293  return myFollowingEdges[pos];
294  }
295 
296 
304  unsigned int getNumApproaching() const;
305 
306 
311  ROEdge* getApproaching(unsigned int pos) const {
312  return myApproachingEdges[pos];
313  }
314 
315 
323  SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const;
324 
325 
332  SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const;
333 
334 
340  inline SUMOReal getMinimumTravelTime(const ROVehicle* const veh) const {
341  return myLength / MIN2(veh->getType()->maxSpeed, SUMOReal(2. * veh->getType()->speedDev + 1.) * veh->getType()->speedFactor * mySpeed);
342  }
343 
344 
345  SUMOReal getCOEffort(const ROVehicle* const veh, SUMOReal time) const;
346  SUMOReal getCO2Effort(const ROVehicle* const veh, SUMOReal time) const;
347  SUMOReal getPMxEffort(const ROVehicle* const veh, SUMOReal time) const;
348  SUMOReal getHCEffort(const ROVehicle* const veh, SUMOReal time) const;
349  SUMOReal getNOxEffort(const ROVehicle* const veh, SUMOReal time) const;
350  SUMOReal getFuelEffort(const ROVehicle* const veh, SUMOReal time) const;
351  SUMOReal getNoiseEffort(const ROVehicle* const veh, SUMOReal time) const;
353 
354 
356  SUMOReal getDistanceTo(const ROEdge* other) const;
357 
358 
360  static ROEdge* dictionary(size_t index);
361 
363  static size_t dictSize() {
364  return myEdges.size();
365  };
366 
367  static void setTimeLineOptions(
368  bool useBoundariesOnOverrideTT,
369  bool useBoundariesOnOverrideE,
370  bool interpolate) {
371  myUseBoundariesOnOverrideTT = useBoundariesOnOverrideTT;
372  myUseBoundariesOnOverrideE = useBoundariesOnOverrideE;
373  myInterpolate = interpolate;
374  }
375 
377  int getPriority() const {
378  return myPriority;
379  }
380 
381  const RONode* getFromJunction() const {
382  return myFromJunction;
383  }
384 
385  const RONode* getToJunction() const {
386  return myToJunction;
387  }
388 
389 
390  void setJunctions(RONode* from, RONode* to) {
391  myFromJunction = from;
392  myToJunction = to;
393  }
394 
399  const std::vector<ROLane*>& getLanes() const {
400  return myLanes;
401  }
402 protected:
409  bool getStoredEffort(SUMOReal time, SUMOReal& ret) const;
410 
411 
412 
413 protected:
415  RONode* const myFromNode, * const myToNode;
416 
418  const unsigned int myIndex;
419 
421  const int myPriority;
422 
425 
428 
429 
436 
443 
445  static bool myInterpolate;
446 
448  static bool myHaveEWarned;
450  static bool myHaveTTWarned;
451 
453  std::vector<ROEdge*> myFollowingEdges;
454 
456  std::vector<ROEdge*> myApproachingEdges;
457 
460 
462  std::vector<ROLane*> myLanes;
463 
466 
467  static std::vector<ROEdge*> myEdges;
468 
472 
473 
474 private:
476  ROEdge(const ROEdge& src);
477 
479  ROEdge& operator=(const ROEdge& src);
480 
481 };
482 
483 
484 #endif
485 
486 /****************************************************************************/
487 
RONode * getToNode() const
Returns the node this edge ends at.
Definition: ROEdge.h:219
EdgeType getType() const
Returns the type of the edge.
Definition: ROEdge.h:172
static bool myUseBoundariesOnOverrideTT
Whether overriding weight boundaries shall be reported.
Definition: ROEdge.h:435
ROEdge * getFollower(unsigned int pos) const
Returns the edge at the given position from the list of reachable edges.
Definition: ROEdge.h:292
A single lane the router may use.
Definition: ROLane.h:52
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
SUMOReal getDistanceTo(const ROEdge *other) const
optimistic distance heuristic for use in routing
Definition: ROEdge.cpp:136
static std::vector< ROEdge * > myEdges
Definition: ROEdge.h:467
void setJunctions(RONode *from, RONode *to)
Definition: ROEdge.h:390
SUMOVehicleClass getVClass() const
Definition: ROVehicle.h:123
static bool myInterpolate
Information whether to interpolate at interval boundaries.
Definition: ROEdge.h:445
EdgeType
Possible types of edges.
Definition: ROEdge.h:75
SUMOReal speedDev
The standard deviation for speed variations.
static ROEdge * dictionary(size_t index)
Returns the ROEdge at the index.
Definition: ROEdge.cpp:351
ValueTimeLine< SUMOReal > myTravelTimes
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:431
virtual void addLane(ROLane *lane)
Adds a lane to the edge while loading.
Definition: ROEdge.cpp:90
SUMOReal getPMxEffort(const ROVehicle *const veh, SUMOReal time) const
Definition: ROEdge.cpp:197
const SUMOVTypeParameter * getType() const
Returns the type of the vehicle.
Definition: ROVehicle.h:93
SUMOReal getCO2Effort(const ROVehicle *const veh, SUMOReal time) const
Definition: ROEdge.cpp:184
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
Definition: ROEdge.h:89
std::vector< ROEdge * > myApproachingEdges
List of edges that approached this edge.
Definition: ROEdge.h:456
bool isConnectedTo(const ROEdge *const e) const
returns the information whether this edge is directly connected to the given
Definition: ROEdge.h:229
unsigned int getLaneNo() const
Returns the number of lanes this edge has.
Definition: ROEdge.h:203
static bool myUseBoundariesOnOverrideE
Whether overriding weight boundaries shall be reported.
Definition: ROEdge.h:442
SVCPermissions myCombinedPermissions
The list of allowed vehicle classes combined across lanes.
Definition: ROEdge.h:465
const std::vector< ROLane * > & getLanes() const
Returns this edge's lanes.
Definition: ROEdge.h:399
void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a travel time value.
Definition: ROEdge.cpp:119
An internal edge which models walking areas for pedestrians.
Definition: ROEdge.h:85
RONode * getFromNode() const
Returns the node this edge starts at.
Definition: ROEdge.h:211
bool isWalkingArea() const
return whether this edge is walking area
Definition: ROEdge.h:147
An edge where vehicles are inserted at (no vehicle may come from back)
Definition: ROEdge.h:81
A vehicle as used by router.
Definition: ROVehicle.h:59
SUMOReal speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street...
void setType(EdgeType type)
Sets the type of te edge.
Definition: ROEdge.cpp:303
const RONode * getToJunction() const
Definition: ROEdge.h:385
bool allFollowersProhibit(const ROVehicle *const vehicle) const
Returns whether this edge succeding edges prohibit the given vehicle to pass them.
Definition: ROEdge.cpp:340
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:137
RONode * myFromJunction
the junctions for this edge
Definition: ROEdge.h:470
ValueTimeLine< SUMOReal > myEfforts
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:438
bool myUsingTTTimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:433
static bool myHaveEWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:448
SUMOReal myLength
The length of the edge.
Definition: ROEdge.h:427
bool myUsingETimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:440
SUMOReal getHCEffort(const ROVehicle *const veh, SUMOReal time) const
Definition: ROEdge.cpp:210
SUMOReal getNOxEffort(const ROVehicle *const veh, SUMOReal time) const
Definition: ROEdge.cpp:223
T MIN2(T a, T b)
Definition: StdDefs.h:66
static void setTimeLineOptions(bool useBoundariesOnOverrideTT, bool useBoundariesOnOverrideE, bool interpolate)
Definition: ROEdge.h:367
unsigned int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:187
An edge representing a whole district.
Definition: ROEdge.h:79
std::vector< ROLane * > myLanes
This edge's lanes.
Definition: ROEdge.h:462
ROEdge(const std::string &id, RONode *from, RONode *to, unsigned int index, const int priority)
Constructor.
Definition: ROEdge.cpp:67
const unsigned int myIndex
The index (numeric id) of the edge.
Definition: ROEdge.h:418
virtual ~ROEdge()
Destructor.
Definition: ROEdge.cpp:82
A basic edge for routing applications.
Definition: ROEdge.h:69
Base class for objects which have an id.
Definition: Named.h:45
RONode *const *const myToNode
Definition: ROEdge.h:415
ROEdge * getApproaching(unsigned int pos) const
Returns the edge at the given position from the list of reachable edges.
Definition: ROEdge.h:311
SUMOReal mySpeed
The maximum speed allowed on this edge.
Definition: ROEdge.h:424
SUMOReal maxSpeed
The vehicle type's maximum speed [m/s].
std::vector< ROEdge * > myFollowingEdges
List of edges that may be approached from this edge.
Definition: ROEdge.h:453
unsigned int getNoFollowing() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:285
const RONode * getFromJunction() const
Definition: ROEdge.h:381
void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a weight value.
Definition: ROEdge.cpp:112
RONode * myToJunction
Definition: ROEdge.h:471
int getPriority() const
get edge priority (road class)
Definition: ROEdge.h:377
SUMOReal getFuelEffort(const ROVehicle *const veh, SUMOReal time) const
Definition: ROEdge.cpp:236
SUMOReal getLength() const
Returns the length of the edge.
Definition: ROEdge.h:180
unsigned int getNumApproaching() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:294
bool prohibits(const ROVehicle *const vehicle) const
Returns whether this edge prohibits the given vehicle to pass it.
Definition: ROEdge.h:238
A normal edge.
Definition: ROEdge.h:77
SUMOReal getEffort(const ROVehicle *const veh, SUMOReal time) const
Returns the effort for this edge.
Definition: ROEdge.cpp:126
An internal edge which models pedestrian crossings.
Definition: ROEdge.h:87
void buildTimeLines(const std::string &measure)
Builds the internal representation of the travel time/effort.
Definition: ROEdge.cpp:309
bool getStoredEffort(SUMOReal time, SUMOReal &ret) const
Retrieves the stored effort.
Definition: ROEdge.cpp:260
RONode *const myFromNode
The nodes this edge is connecting.
Definition: ROEdge.h:415
static size_t dictSize()
Returns the number of edges.
Definition: ROEdge.h:363
SUMOReal getNoiseEffort(const ROVehicle *const veh, SUMOReal time) const
Definition: ROEdge.cpp:249
#define SUMOReal
Definition: config.h:215
SUMOReal getCOEffort(const ROVehicle *const veh, SUMOReal time) const
Definition: ROEdge.cpp:171
Base class for nodes used by the router.
Definition: RONode.h:51
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: ROEdge.h:142
SUMOReal getTravelTime(const ROVehicle *const veh, SUMOReal time) const
Returns the travel time for this edge.
Definition: ROEdge.cpp:147
An edge where vehicles disappear (no vehicle may leave this edge)
Definition: ROEdge.h:83
static bool myHaveTTWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:450
SVCPermissions getPermissions() const
Definition: ROEdge.h:243
virtual void addFollower(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:103
SUMOReal getMinimumTravelTime(const ROVehicle *const veh) const
Returns a lower bound for the travel time on this edge without using any stored timeLine.
Definition: ROEdge.h:340
EdgeType myType
The type of the edge.
Definition: ROEdge.h:459
ROEdge & operator=(const ROEdge &src)
Invalidated assignment operator.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:195
const int myPriority
The edge priority (road class)
Definition: ROEdge.h:421