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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // The pedestrian accessible edges for the Intermodal Router
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #define TL_RED_PENALTY 20
26 
27 //#define IntermodalRouter_DEBUG_EFFORTS
28 
29 
30 // ===========================================================================
31 // class definitions
32 // ===========================================================================
34 template<class E, class L, class N, class V>
35 class PedestrianEdge : public IntermodalEdge<E, L, N, V> {
36 public:
37  PedestrianEdge(int numericalID, const E* edge, const L* lane, bool forward, const double pos = -1.) :
38  IntermodalEdge<E, L, N, V>(edge->getID() + (edge->isWalkingArea() ? "" : (forward ? "_fwd" : "_bwd")) + toString(pos), numericalID, edge, "!ped"),
39  myLane(lane),
40  myForward(forward),
41  myStartPos(pos >= 0 ? pos : (forward ? 0. : edge->getLength())) { }
42 
43  bool includeInRoute(bool allEdges) const {
44  return allEdges || (!this->getEdge()->isCrossing() && !this->getEdge()->isWalkingArea() && !this->getEdge()->isInternal());
45  }
46 
47  bool prohibits(const IntermodalTrip<E, N, V>* const trip) const {
48  if (trip->node == 0) {
49  // network only includes IntermodalEdges
50  return false;
51  } else {
52  // limit routing to the surroundings of the specified node
53  return (this->getEdge()->getFromJunction() != trip->node
54  && this->getEdge()->getToJunction() != trip->node);
55  }
56  }
57 
58  double getPartialLength(const IntermodalTrip<E, N, V>* const trip) const {
59  double length = this->getLength();
60  if (this->getEdge() == trip->from && !myForward && trip->departPos < myStartPos) {
61  length = trip->departPos - (myStartPos - this->getLength());
62  }
63  if (this->getEdge() == trip->to && myForward && trip->arrivalPos < myStartPos + this->getLength()) {
64  length = trip->arrivalPos - myStartPos;
65  }
66  if (this->getEdge() == trip->from && myForward && trip->departPos > myStartPos) {
67  length -= (trip->departPos - myStartPos);
68  }
69  if (this->getEdge() == trip->to && !myForward && trip->arrivalPos > myStartPos - this->getLength()) {
70  length -= (trip->arrivalPos - (myStartPos - this->getLength()));
71  }
72  // ensure that 'normal' edges always have a higher weight than connector edges
73  length = MAX2(length, NUMERICAL_EPS);
74  return length;
75  }
76 
77  double getTravelTime(const IntermodalTrip<E, N, V>* const trip, double time) const {
78  const double length = getPartialLength(trip);
79  double tlsDelay = 0;
80  // @note pedestrian traffic lights should never have LINKSTATE_TL_REDYELLOW
81  if (this->getEdge()->isCrossing() && myLane->getIncomingLinkState() == LINKSTATE_TL_RED) {
82  // red traffic lights occurring later in the route may be green by the time we arrive
83  tlsDelay += MAX2(double(0), TL_RED_PENALTY - (time - STEPS2TIME(trip->departTime)));
84  }
85 #ifdef IntermodalRouter_DEBUG_EFFORTS
86  std::cout << " effort for " << trip->getID() << " at " << time << " edge=" << this->getID() << " effort=" << length / trip->speed + tlsDelay << " l=" << length << " fullLength=" << this->getLength() << " s=" << trip->speed << " tlsDelay=" << tlsDelay << "\n";
87 #endif
88  return length / trip->speed + tlsDelay;
89  }
90 
91  double getStartPos() const {
92  return myStartPos;
93  }
94 
95  double getEndPos() const {
96  return myForward ? myStartPos + this->getLength() : myStartPos - this->getLength();
97  }
98 
99 private:
101  const L* myLane;
102 
104  const bool myForward;
105 
107  const double myStartPos;
108 
109 };
#define TL_RED_PENALTY
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
@ LINKSTATE_TL_RED
The link has red light (must brake)
T MAX2(T a, T b)
Definition: StdDefs.h:79
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
the base edge type that is given to the internal router (SUMOAbstractRouter)
const E * getEdge() const
double getLength() const
required by DijkstraRouter et al for external effort computation
the "vehicle" type that is given to the internal router (SUMOAbstractRouter)
std::string getID() const
const E *const to
const double departPos
const E *const from
const double arrivalPos
const SUMOTime departTime
const double speed
const N *const node
const std::string & getID() const
Returns the id.
Definition: Named.h:73
the pedestrian edge type that is given to the internal router (SUMOAbstractRouter)
PedestrianEdge(int numericalID, const E *edge, const L *lane, bool forward, const double pos=-1.)
double getEndPos() const
const bool myForward
the direction of this edge
const L * myLane
the original edge
double getPartialLength(const IntermodalTrip< E, N, V > *const trip) const
const double myStartPos
the starting position for split edges
bool includeInRoute(bool allEdges) const
double getStartPos() const
double getTravelTime(const IntermodalTrip< E, N, V > *const trip, double time) const
bool prohibits(const IntermodalTrip< E, N, V > *const trip) const