Eclipse SUMO - Simulation of Urban MObility
PedestrianEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // The pedestrian accessible edges for the Intermodal Router
18 /****************************************************************************/
19 #ifndef PedestrianEdge_h
20 #define PedestrianEdge_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #define TL_RED_PENALTY 20
29 
30 //#define IntermodalRouter_DEBUG_EFFORTS
31 
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
37 template<class E, class L, class N, class V>
38 class PedestrianEdge : public IntermodalEdge<E, L, N, V> {
39 public:
40  PedestrianEdge(int numericalID, const E* edge, const L* lane, bool forward, const double pos = -1.) :
41  IntermodalEdge<E, L, N, V>(edge->getID() + (edge->isWalkingArea() ? "" : (forward ? "_fwd" : "_bwd")) + toString(pos), numericalID, edge, "!ped"),
42  myLane(lane),
43  myForward(forward),
44  myStartPos(pos >= 0 ? pos : (forward ? 0. : edge->getLength())) { }
45 
46  bool includeInRoute(bool allEdges) const {
47  return allEdges || (!this->getEdge()->isCrossing() && !this->getEdge()->isWalkingArea() && !this->getEdge()->isInternal());
48  }
49 
50  bool prohibits(const IntermodalTrip<E, N, V>* const trip) const {
51  if (trip->node == 0) {
52  // network only includes IntermodalEdges
53  return false;
54  } else {
55  // limit routing to the surroundings of the specified node
56  return (this->getEdge()->getFromJunction() != trip->node
57  && this->getEdge()->getToJunction() != trip->node);
58  }
59  }
60 
61  virtual double getTravelTime(const IntermodalTrip<E, N, V>* const trip, double time) const {
62  double length = this->getLength();
63  if (this->getEdge() == trip->from && !myForward && trip->departPos < myStartPos) {
64  length = trip->departPos - (myStartPos - this->getLength());
65  }
66  if (this->getEdge() == trip->to && myForward && trip->arrivalPos < myStartPos + this->getLength()) {
67  length = trip->arrivalPos - myStartPos;
68  }
69  if (this->getEdge() == trip->from && myForward && trip->departPos > myStartPos) {
70  length -= (trip->departPos - myStartPos);
71  }
72  if (this->getEdge() == trip->to && !myForward && trip->arrivalPos > myStartPos - this->getLength()) {
73  length -= (trip->arrivalPos - (myStartPos - this->getLength()));
74  }
75  // ensure that 'normal' edges always have a higher weight than connector edges
76  length = MAX2(length, NUMERICAL_EPS);
77  double tlsDelay = 0;
78  // @note pedestrian traffic lights should never have LINKSTATE_TL_REDYELLOW
79  if (this->getEdge()->isCrossing() && myLane->getIncomingLinkState() == LINKSTATE_TL_RED) {
80  // red traffic lights occurring later in the route may be green by the time we arrive
81  tlsDelay += MAX2(double(0), TL_RED_PENALTY - (time - STEPS2TIME(trip->departTime)));
82  }
83 #ifdef IntermodalRouter_DEBUG_EFFORTS
84  std::cout << " effort for " << trip->getID() << " at " << time << " edge=" << edge->getID() << " effort=" << length / trip->speed + tlsDelay << " l=" << length << " s=" << trip->speed << " tlsDelay=" << tlsDelay << "\n";
85 #endif
86  return length / trip->speed + tlsDelay;
87  }
88 
89  double getStartPos() const {
90  return myStartPos;
91  }
92 
93  double getEndPos() const {
94  return myForward ? myStartPos + this->getLength() : myStartPos - this->getLength();
95  }
96 
97 private:
99  const L* myLane;
100 
102  const bool myForward;
103 
105  const double myStartPos;
106 
107 };
108 
109 
110 #endif
111 
112 /****************************************************************************/
virtual double getTravelTime(const IntermodalTrip< E, N, V > *const trip, double time) const
std::string getID() const
T MAX2(T a, T b)
Definition: StdDefs.h:80
const std::string & getID() const
Returns the id.
Definition: Named.h:77
const double myStartPos
the starting position for split edges
const N *const node
const E * getEdge() const
const E *const to
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
const bool myForward
the direction of this edge
#define TL_RED_PENALTY
#define STEPS2TIME(x)
Definition: SUMOTime.h:57
const L * myLane
the original edge
const double departPos
const double speed
const SUMOTime departTime
bool prohibits(const IntermodalTrip< E, N, V > *const trip) const
const double arrivalPos
the base edge type that is given to the internal router (SUMOAbstractRouter)
The link has red light (must brake)
double getStartPos() const
double getLength() const
the pedestrian edge type that is given to the internal router (SUMOAbstractRouter) ...
#define NUMERICAL_EPS
Definition: config.h:145
PedestrianEdge(int numericalID, const E *edge, const L *lane, bool forward, const double pos=-1.)
double getEndPos() const
the "vehicle" type that is given to the internal router (SUMOAbstractRouter)
bool includeInRoute(bool allEdges) const
const E *const from