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 /****************************************************************************/ 10 /// @file PedestrianEdge.h 11 /// @author Jakob Erdmann 12 /// @author Michael Behrisch 13 /// @author Robert Hilbrich 14 /// @date Mon, 03 March 2014 15 /// @version $Id$ 16 /// 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 // =========================================================================== 36 /// @brief the pedestrian edge type that is given to the internal router (SUMOAbstractRouter) 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 includeInRoute(bool allEdges)46 bool includeInRoute(bool allEdges) const { 47 return allEdges || (!this->getEdge()->isCrossing() && !this->getEdge()->isWalkingArea() && !this->getEdge()->isInternal()); 48 } 49 prohibits(const IntermodalTrip<E,N,V> * const trip)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 getTravelTime(const IntermodalTrip<E,N,V> * const trip,double time)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 getStartPos()89 double getStartPos() const { 90 return myStartPos; 91 } 92 getEndPos()93 double getEndPos() const { 94 return myForward ? myStartPos + this->getLength() : myStartPos - this->getLength(); 95 } 96 97 private: 98 /// @brief the original edge 99 const L* myLane; 100 101 /// @brief the direction of this edge 102 const bool myForward; 103 104 /// @brief the starting position for split edges 105 const double myStartPos; 106 107 }; 108 109 110 #endif 111 112 /****************************************************************************/ 113