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 /****************************************************************************/
PedestrianEdge::PedestrianEdge
PedestrianEdge(int numericalID, const E *edge, const L *lane, bool forward, const double pos=-1.)
Definition: PedestrianEdge.h:40
IntermodalTrip::speed
const double speed
Definition: IntermodalTrip.h:82
NUMERICAL_EPS
#define NUMERICAL_EPS
Definition: config.h:145
TL_RED_PENALTY
#define TL_RED_PENALTY
Definition: PedestrianEdge.h:28
IntermodalEdge::getLength
double getLength() const
Definition: IntermodalEdge.h:132
PedestrianEdge::includeInRoute
bool includeInRoute(bool allEdges) const
Definition: PedestrianEdge.h:46
FareToken::L
IntermodalEdge
the base edge type that is given to the internal router (SUMOAbstractRouter)
Definition: IntermodalEdge.h:40
IntermodalTrip::departPos
const double departPos
Definition: IntermodalTrip.h:80
IntermodalTrip::departTime
const SUMOTime departTime
Definition: IntermodalTrip.h:83
PedestrianEdge
the pedestrian edge type that is given to the internal router (SUMOAbstractRouter)
Definition: PedestrianEdge.h:38
PedestrianEdge::getStartPos
double getStartPos() const
Definition: PedestrianEdge.h:89
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:80
PedestrianEdge::getEndPos
double getEndPos() const
Definition: PedestrianEdge.h:93
PedestrianEdge::getTravelTime
virtual double getTravelTime(const IntermodalTrip< E, N, V > *const trip, double time) const
Definition: PedestrianEdge.h:61
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:57
IntermodalTrip::arrivalPos
const double arrivalPos
Definition: IntermodalTrip.h:81
IntermodalTrip::to
const E *const to
Definition: IntermodalTrip.h:79
IntermodalEdge::getEdge
const E * getEdge() const
Definition: IntermodalEdge.h:60
PedestrianEdge::myForward
const bool myForward
the direction of this edge
Definition: PedestrianEdge.h:102
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
IntermodalTrip::node
const N *const node
Definition: IntermodalTrip.h:84
IntermodalTrip::from
const E *const from
Definition: IntermodalTrip.h:78
IntermodalTrip::getID
std::string getID() const
Definition: IntermodalTrip.h:59
config.h
LINKSTATE_TL_RED
The link has red light (must brake)
Definition: SUMOXMLDefinitions.h:1138
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:77
IntermodalTrip
the "vehicle" type that is given to the internal router (SUMOAbstractRouter)
Definition: IntermodalTrip.h:39
PedestrianEdge::myStartPos
const double myStartPos
the starting position for split edges
Definition: PedestrianEdge.h:105
PedestrianEdge::prohibits
bool prohibits(const IntermodalTrip< E, N, V > *const trip) const
Definition: PedestrianEdge.h:50
PedestrianEdge::myLane
const L * myLane
the original edge
Definition: PedestrianEdge.h:99