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.dlr.de/
15 // Copyright (C) 2002-2017 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 <utils/geom/Boundary.h>
48 #ifdef HAVE_FOX
49 #include <fx.h>
50 #endif
52 #include "RONode.h"
53 #include "ROVehicle.h"
54 
55 
56 // ===========================================================================
57 // class declarations
58 // ===========================================================================
59 class ROLane;
60 class ROEdge;
61 
62 typedef std::vector<ROEdge*> ROEdgeVector;
63 typedef std::vector<const ROEdge*> ConstROEdgeVector;
64 
65 
66 // ===========================================================================
67 // class definitions
68 // ===========================================================================
78 class ROEdge : public Named {
79 public:
87  ROEdge(const std::string& id, RONode* from, RONode* to, int index, const int priority);
88 
89 
91  virtual ~ROEdge();
92 
93 
95 
96 
105  virtual void addLane(ROLane* lane);
106 
107 
114  virtual void addSuccessor(ROEdge* s, std::string dir = "");
115 
116 
120  inline void setFunction(SumoXMLEdgeFunc func) {
121  myFunction = func;
122  }
123 
124 
128  inline void setSource(const bool isSource = true) {
129  myAmSource = isSource;
130  }
131 
132 
136  inline void setSink(const bool isSink = true) {
137  myAmSink = isSink;
138  }
139 
140 
144  inline void setRestrictions(const std::map<SUMOVehicleClass, double>* restrictions) {
145  myRestrictions = restrictions;
146  }
147 
148 
150  inline bool isInternal() const {
151  return myFunction == EDGEFUNC_INTERNAL;
152  }
153 
155  inline bool isCrossing() const {
156  return myFunction == EDGEFUNC_CROSSING;
157  }
158 
160  inline bool isWalkingArea() const {
162  }
163 
164  inline bool isTazConnector() const {
165  return myFunction == EDGEFUNC_CONNECTOR;
166  }
167 
177  void buildTimeLines(const std::string& measure, const bool boundariesOverride);
179 
180 
181 
183 
184 
189  inline SumoXMLEdgeFunc getFunction() const {
190  return myFunction;
191  }
192 
193 
197  inline bool isSink() const {
198  return myAmSink;
199  }
200 
201 
205  double getLength() const {
206  return myLength;
207  }
208 
212  int getNumericalID() const {
213  return myIndex;
214  }
215 
216 
220  double getSpeedLimit() const {
221  return mySpeed;
222  }
223 
225  // sufficient for the astar air-distance heuristic
226  double getLengthGeometryFactor() const {
227  if (myFromJunction != 0 && myToJunction != 0) {
229  } else {
230  return 1.0;
231  }
232  }
233 
238  inline double getVClassMaxSpeed(SUMOVehicleClass vclass) const {
239  if (myRestrictions != 0) {
240  std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(vclass);
241  if (r != myRestrictions->end()) {
242  return r->second;
243  }
244  }
245  return mySpeed;
246  }
247 
248 
252  int getNumLanes() const {
253  return (int) myLanes.size();
254  }
255 
256 
263  bool isConnectedTo(const ROEdge* const e, const ROVehicle* const vehicle) const;
264 
265 
270  inline bool prohibits(const ROVehicle* const vehicle) const {
271  const SUMOVehicleClass vclass = vehicle->getVClass();
272  return (myCombinedPermissions & vclass) != vclass;
273  }
274 
276  return myCombinedPermissions;
277  }
278 
279 
284  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
286 
287 
288 
290 
291 
298  void addEffort(double value, double timeBegin, double timeEnd);
299 
300 
307  void addTravelTime(double value, double timeBegin, double timeEnd);
308 
309 
317  int getNumSuccessors() const;
318 
319 
322  const ROEdgeVector& getSuccessors() const {
323  return myFollowingEdges;
324  }
325 
326 
331  const ROEdgeVector& getSuccessors(SUMOVehicleClass vClass) const;
332 
333 
341  int getNumPredecessors() const;
342 
343 
348  const ROEdgeVector& getPredecessors() const {
349  return myApproachingEdges;
350  }
351 
353  const ROEdge* getNormalBefore() const;
354 
356  const ROEdge* getNormalAfter() const;
357 
365  double getEffort(const ROVehicle* const veh, double time) const;
366 
367 
373  bool hasLoadedTravelTime(double time) const;
374 
375 
382  double getTravelTime(const ROVehicle* const veh, double time) const;
383 
384 
393  static inline double getEffortStatic(const ROEdge* const edge, const ROVehicle* const veh, double time) {
394  return edge->getEffort(veh, time);
395  }
396 
397 
405  static inline double getTravelTimeStatic(const ROEdge* const edge, const ROVehicle* const veh, double time) {
406  return edge->getTravelTime(veh, time);
407  }
408 
409 
415  inline double getMinimumTravelTime(const ROVehicle* const veh) const {
416  if (isTazConnector()) {
417  return 0;
418  } else if (veh != 0) {
419  return myLength / MIN2(veh->getType()->maxSpeed, veh->getChosenSpeedFactor() * mySpeed);
420  } else {
421  return myLength / mySpeed;
422  }
423  }
424 
425 
426  template<PollutantsInterface::EmissionType ET>
427  static double getEmissionEffort(const ROEdge* const edge, const ROVehicle* const veh, double time) {
428  double ret = 0;
429  if (!edge->getStoredEffort(time, ret)) {
430  const SUMOVTypeParameter* const type = veh->getType();
431  const double vMax = MIN2(type->maxSpeed, edge->mySpeed);
433  ret = PollutantsInterface::computeDefault(type->emissionClass, ET, vMax, accel, 0, edge->getTravelTime(veh, time)); // @todo: give correct slope
434  }
435  return ret;
436  }
437 
438 
439  static double getNoiseEffort(const ROEdge* const edge, const ROVehicle* const veh, double time);
441 
442 
444  double getDistanceTo(const ROEdge* other) const;
445 
446 
448  static const ROEdgeVector& getAllEdges();
449 
451  static int dictSize() {
452  return (int)myEdges.size();
453  };
454 
455  static void setGlobalOptions(const bool interpolate) {
456  myInterpolate = interpolate;
457  }
458 
460  int getPriority() const {
461  return myPriority;
462  }
463 
464  const RONode* getFromJunction() const {
465  return myFromJunction;
466  }
467 
468  const RONode* getToJunction() const {
469  return myToJunction;
470  }
471 
472 
477  const std::vector<ROLane*>& getLanes() const {
478  return myLanes;
479  }
480 protected:
487  bool getStoredEffort(double time, double& ret) const;
488 
489 
490 
491 protected:
495 
497  const int myIndex;
498 
500  const int myPriority;
501 
503  double mySpeed;
504 
506  double myLength;
507 
514 
519 
521  static bool myInterpolate;
522 
524  static bool myHaveEWarned;
526  static bool myHaveTTWarned;
527 
530 
533 
536 
538  const std::map<SUMOVehicleClass, double>* myRestrictions;
539 
541  std::vector<ROLane*> myLanes;
542 
545 
548 
550 
551 
553  mutable std::map<SUMOVehicleClass, ROEdgeVector> myClassesSuccessorMap;
554 
555 #ifdef HAVE_FOX
556  mutable FXMutex myLock;
558 #endif
559 
560 private:
562  ROEdge(const ROEdge& src);
563 
565  ROEdge& operator=(const ROEdge& src);
566 
567 };
568 
569 
570 #endif
571 
572 /****************************************************************************/
573 
static ROEdgeVector myEdges
Definition: ROEdge.h:549
std::map< SUMOVehicleClass, ROEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
Definition: ROEdge.h:553
static double getEffortStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the effort for the given edge.
Definition: ROEdge.h:393
double getSpeedLimit() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:220
double myLength
The length of the edge.
Definition: ROEdge.h:506
void addTravelTime(double value, double timeBegin, double timeEnd)
Adds a travel time value.
Definition: ROEdge.cpp:137
A single lane the router may use.
Definition: ROLane.h:57
double getVClassMaxSpeed(SUMOVehicleClass vclass) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: ROEdge.h:238
double mySpeed
The maximum speed allowed on this edge.
Definition: ROEdge.h:503
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this edge.
Definition: ROEdge.h:538
double getLength() const
Returns the length of the edge.
Definition: ROEdge.h:205
static bool myInterpolate
Information whether to interpolate at interval boundaries.
Definition: ROEdge.h:521
Structure representing possible vehicle parameter.
Boundary myTazBoundary
The bounding rectangle of incoming or outgoing edges for taz connectors.
Definition: ROEdge.h:547
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
void setSource(const bool isSource=true)
Sets whether the edge is a source.
Definition: ROEdge.h:128
virtual void addLane(ROLane *lane)
Adds a lane to the edge while loading.
Definition: ROEdge.cpp:94
SUMOVehicleClass vehicleClass
The vehicle&#39;s class.
void setSink(const bool isSink=true)
Sets whether the edge is a sink.
Definition: ROEdge.h:136
T MAX2(T a, T b)
Definition: StdDefs.h:74
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:235
bool isTazConnector() const
Definition: ROEdge.h:164
double getTravelTime(const ROVehicle *const veh, double time) const
Returns the travel time for this edge.
Definition: ROEdge.cpp:175
bool myAmSource
Definition: ROEdge.h:509
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:63
SVCPermissions myCombinedPermissions
The list of allowed vehicle classes combined across lanes.
Definition: ROEdge.h:544
double getEffort(const ROVehicle *const veh, double time) const
Returns the effort for this edge.
Definition: ROEdge.cpp:144
const std::vector< ROLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: ROEdge.h:477
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
static double getDefaultAccel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default acceleration for the given vehicle class This needs to be a function because the ...
ROEdgeVector myFollowingEdges
List of edges that may be approached from this edge.
Definition: ROEdge.h:529
bool isWalkingArea() const
return whether this edge is walking area
Definition: ROEdge.h:160
static double getDefaultImperfection(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default driver&#39;s imperfection (sigma or epsilon in Krauss&#39; model) for the given vehicle c...
SumoXMLEdgeFunc myFunction
The function of the edge.
Definition: ROEdge.h:535
std::vector< ROEdge * > ROEdgeVector
Definition: ROEdge.h:60
A vehicle as used by router.
Definition: ROVehicle.h:60
const RONode * getToJunction() const
Definition: ROEdge.h:468
bool allFollowersProhibit(const ROVehicle *const vehicle) const
Returns whether this edge succeeding edges prohibit the given vehicle to pass them.
Definition: ROEdge.cpp:309
bool getStoredEffort(double time, double &ret) const
Retrieves the stored effort.
Definition: ROEdge.cpp:210
static double getEmissionEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
Definition: ROEdge.h:427
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:150
static double getTravelTimeStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the travel time for the given edge.
Definition: ROEdge.h:405
double maxSpeed
The vehicle type&#39;s maximum speed [m/s].
RONode * myFromJunction
the junctions for this edge
Definition: ROEdge.h:493
const SUMOVTypeParameter * getType() const
Returns the type of the vehicle.
Definition: RORoutable.h:83
void buildTimeLines(const std::string &measure, const bool boundariesOverride)
Builds the internal representation of the travel time/effort.
Definition: ROEdge.cpp:275
bool myUsingTTTimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:513
bool isConnectedTo(const ROEdge *const e, const ROVehicle *const vehicle) const
returns the information whether this edge is directly connected to the given
Definition: ROEdge.cpp:367
static bool myHaveEWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:524
int getNumLanes() const
Returns the number of lanes this edge has.
Definition: ROEdge.h:252
bool myUsingETimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:518
std::vector< ROEdge * > ROEdgeVector
Definition: RODFRouteDesc.h:43
void addEffort(double value, double timeBegin, double timeEnd)
Adds a weight value.
Definition: ROEdge.cpp:130
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
Definition: ROEdge.h:348
bool myAmSink
whether the edge is a source or a sink
Definition: ROEdge.h:509
T MIN2(T a, T b)
Definition: StdDefs.h:68
SumoXMLEdgeFunc getFunction() const
Returns the function of the edge.
Definition: ROEdge.h:189
static int dictSize()
Returns the number of edges.
Definition: ROEdge.h:451
std::vector< ROLane * > myLanes
This edge&#39;s lanes.
Definition: ROEdge.h:541
double 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:415
ValueTimeLine< double > myEfforts
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:516
virtual ~ROEdge()
Destructor.
Definition: ROEdge.cpp:86
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:240
A basic edge for routing applications.
Definition: ROEdge.h:78
Base class for objects which have an id.
Definition: Named.h:46
bool hasLoadedTravelTime(double time) const
Returns whether a travel time for this edge was loaded.
Definition: ROEdge.cpp:169
double getCFParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
double getDistanceTo(const ROEdge *other) const
optimistic distance heuristic for use in routing
Definition: ROEdge.cpp:154
const RONode * getFromJunction() const
Definition: ROEdge.h:464
double getChosenSpeedFactor() const
Returns an upper bound for the speed factor of this vehicle.
Definition: ROVehicle.h:124
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:107
RONode * myToJunction
Definition: ROEdge.h:494
int getPriority() const
get edge priority (road class)
Definition: ROEdge.h:460
ROEdge(const std::string &id, RONode *from, RONode *to, int index, const int priority)
Constructor.
Definition: ROEdge.cpp:62
ROEdgeVector myApproachingEdges
List of edges that approached this edge.
Definition: ROEdge.h:532
bool prohibits(const ROVehicle *const vehicle) const
Returns whether this edge prohibits the given vehicle to pass it.
Definition: ROEdge.h:270
int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition: ROEdge.cpp:244
bool isSink() const
Returns whether the edge acts as a sink.
Definition: ROEdge.h:197
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
Definition: ROEdge.cpp:320
const ROEdgeVector & getSuccessors() const
Returns the following edges.
Definition: ROEdge.h:322
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
static double getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
Definition: ROEdge.cpp:199
const ROEdge * getNormalAfter() const
if this edge is an internal edge, return its first normal successor, otherwise the edge itself ...
Definition: ROEdge.cpp:264
double getLengthGeometryFactor() const
return a lower bound on shape.length() / myLength that is
Definition: ROEdge.h:226
ValueTimeLine< double > myTravelTimes
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:511
static void setGlobalOptions(const bool interpolate)
Definition: ROEdge.h:455
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself ...
Definition: ROEdge.cpp:253
Base class for nodes used by the router.
Definition: RONode.h:53
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: ROEdge.h:155
static bool myHaveTTWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:526
SVCPermissions getPermissions() const
Definition: ROEdge.h:275
void setRestrictions(const std::map< SUMOVehicleClass, double > *restrictions)
Sets the vehicle class specific speed limits of the edge.
Definition: ROEdge.h:144
static double computeDefault(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const double tt, const std::map< int, double > *param=0)
Returns the amount of emitted pollutant given the vehicle type and default values for the state (in m...
SUMOVehicleClass getVClass() const
Definition: RORoutable.h:106
const Position & getPosition() const
Returns the position of the node.
Definition: RONode.h:74
const int myIndex
The index (numeric id) of the edge.
Definition: ROEdge.h:497
ROEdge & operator=(const ROEdge &src)
Invalidated assignment operator.
const int myPriority
The edge priority (road class)
Definition: ROEdge.h:500
SUMOEmissionClass emissionClass
The emission class of this vehicle.
int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:212
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.
Definition: ROEdge.h:120