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 /****************************************************************************/
16 // The pedestrian accessible edges for the Intermodal Router
17 /****************************************************************************/
18 #ifndef PedestrianEdge_h
19 #define PedestrianEdge_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #define TL_RED_PENALTY 20
28 
29 //#define IntermodalRouter_DEBUG_EFFORTS
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
36 template<class E, class L, class N, class V>
37 class PedestrianEdge : public IntermodalEdge<E, L, N, V> {
38 public:
39  PedestrianEdge(int numericalID, const E* edge, const L* lane, bool forward, const double pos = -1.) :
40  IntermodalEdge<E, L, N, V>(edge->getID() + (edge->isWalkingArea() ? "" : (forward ? "_fwd" : "_bwd")) + toString(pos), numericalID, edge, "!ped"),
41  myLane(lane),
42  myForward(forward),
43  myStartPos(pos >= 0 ? pos : (forward ? 0. : edge->getLength())) { }
44 
45  bool includeInRoute(bool allEdges) const {
46  return allEdges || (!this->getEdge()->isCrossing() && !this->getEdge()->isWalkingArea() && !this->getEdge()->isInternal());
47  }
48 
49  bool prohibits(const IntermodalTrip<E, N, V>* const trip) const {
50  if (trip->node == 0) {
51  // network only includes IntermodalEdges
52  return false;
53  } else {
54  // limit routing to the surroundings of the specified node
55  return (this->getEdge()->getFromJunction() != trip->node
56  && this->getEdge()->getToJunction() != trip->node);
57  }
58  }
59 
60  virtual double getTravelTime(const IntermodalTrip<E, N, V>* const trip, double time) const {
61  double length = this->getLength();
62  if (this->getEdge() == trip->from && !myForward && trip->departPos < myStartPos) {
63  length = trip->departPos - (myStartPos - this->getLength());
64  }
65  if (this->getEdge() == trip->to && myForward && trip->arrivalPos < myStartPos + this->getLength()) {
66  length = trip->arrivalPos - myStartPos;
67  }
68  if (this->getEdge() == trip->from && myForward && trip->departPos > myStartPos) {
69  length -= (trip->departPos - myStartPos);
70  }
71  if (this->getEdge() == trip->to && !myForward && trip->arrivalPos > myStartPos - this->getLength()) {
72  length -= (trip->arrivalPos - (myStartPos - this->getLength()));
73  }
74  // ensure that 'normal' edges always have a higher weight than connector edges
75  length = MAX2(length, NUMERICAL_EPS);
76  double tlsDelay = 0;
77  // @note pedestrian traffic lights should never have LINKSTATE_TL_REDYELLOW
78  if (this->getEdge()->isCrossing() && myLane->getIncomingLinkState() == LINKSTATE_TL_RED) {
79  // red traffic lights occurring later in the route may be green by the time we arrive
80  tlsDelay += MAX2(double(0), TL_RED_PENALTY - (time - STEPS2TIME(trip->departTime)));
81  }
82 #ifdef IntermodalRouter_DEBUG_EFFORTS
83  std::cout << " effort for " << trip->getID() << " at " << time << " edge=" << edge->getID() << " effort=" << length / trip->speed + tlsDelay << " l=" << length << " s=" << trip->speed << " tlsDelay=" << tlsDelay << "\n";
84 #endif
85  return length / trip->speed + tlsDelay;
86  }
87 
88  double getStartPos() const {
89  return myStartPos;
90  }
91 
92  double getEndPos() const {
93  return myForward ? myStartPos + this->getLength() : myStartPos - this->getLength();
94  }
95 
96 private:
98  const L* myLane;
99 
101  const bool myForward;
102 
104  const double myStartPos;
105 
106 };
107 
108 
109 #endif
110 
111 /****************************************************************************/
PedestrianEdge::PedestrianEdge
PedestrianEdge(int numericalID, const E *edge, const L *lane, bool forward, const double pos=-1.)
Definition: PedestrianEdge.h:39
IntermodalTrip::speed
const double speed
Definition: IntermodalTrip.h:81
NUMERICAL_EPS
#define NUMERICAL_EPS
Definition: config.h:148
TL_RED_PENALTY
#define TL_RED_PENALTY
Definition: PedestrianEdge.h:27
IntermodalEdge::getLength
double getLength() const
Definition: IntermodalEdge.h:135
PedestrianEdge::includeInRoute
bool includeInRoute(bool allEdges) const
Definition: PedestrianEdge.h:45
FareToken::L
@ L
IntermodalEdge
the base edge type that is given to the internal router (SUMOAbstractRouter)
Definition: IntermodalEdge.h:39
IntermodalTrip::departPos
const double departPos
Definition: IntermodalTrip.h:79
IntermodalTrip::departTime
const SUMOTime departTime
Definition: IntermodalTrip.h:82
PedestrianEdge
the pedestrian edge type that is given to the internal router (SUMOAbstractRouter)
Definition: PedestrianEdge.h:37
PedestrianEdge::getStartPos
double getStartPos() const
Definition: PedestrianEdge.h:88
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
PedestrianEdge::getEndPos
double getEndPos() const
Definition: PedestrianEdge.h:92
PedestrianEdge::getTravelTime
virtual double getTravelTime(const IntermodalTrip< E, N, V > *const trip, double time) const
Definition: PedestrianEdge.h:60
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:56
IntermodalTrip::arrivalPos
const double arrivalPos
Definition: IntermodalTrip.h:80
IntermodalTrip::to
const E *const to
Definition: IntermodalTrip.h:78
IntermodalEdge::getEdge
const E * getEdge() const
Definition: IntermodalEdge.h:59
PedestrianEdge::myForward
const bool myForward
the direction of this edge
Definition: PedestrianEdge.h:101
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
IntermodalTrip::node
const N *const node
Definition: IntermodalTrip.h:83
IntermodalTrip::from
const E *const from
Definition: IntermodalTrip.h:77
IntermodalTrip::getID
std::string getID() const
Definition: IntermodalTrip.h:58
config.h
LINKSTATE_TL_RED
@ LINKSTATE_TL_RED
The link has red light (must brake)
Definition: SUMOXMLDefinitions.h:1143
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
IntermodalTrip
the "vehicle" type that is given to the internal router (SUMOAbstractRouter)
Definition: IntermodalTrip.h:38
PedestrianEdge::myStartPos
const double myStartPos
the starting position for split edges
Definition: PedestrianEdge.h:104
PedestrianEdge::prohibits
bool prohibits(const IntermodalTrip< E, N, V > *const trip) const
Definition: PedestrianEdge.h:49
PedestrianEdge::myLane
const L * myLane
the original edge
Definition: PedestrianEdge.h:98