Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
FlippedEdge.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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/****************************************************************************/
18// Extension of ReversedEdge, which is a wrapper around a ROEdge
19// or an MSEdge used for backward search. In contrast to reversed
20// edges, flipped edges have flipped nodes instead of standard nodes.
21// Introduced for the arc flag router.
22/****************************************************************************/
23#pragma once
24#include <config.h>
26#ifdef HAVE_FOX
28#endif
29#include "ReversedEdge.h"
30
31
32// ===========================================================================
33// class declarations
34// ===========================================================================
35template<class E, class N, class V>
36class FlippedNode;
37
38// ===========================================================================
39// class definitions
40// ===========================================================================
42template<class E, class N, class V>
43class FlippedEdge : public ReversedEdge<E, V> {
44public:
45
46 typedef std::vector<std::pair<const FlippedEdge<E, N, V>*, const FlippedEdge<E, N, V>*> > ConstFlippedEdgePairVector;
47
51 FlippedEdge(const E* originalEdge) :
52 ReversedEdge<E, V>(originalEdge),
53 myFromJunction(this->getOriginalEdge()->getToJunction()->getFlippedRoutingNode()),
54 myToJunction(this->getOriginalEdge()->getFromJunction()->getFlippedRoutingNode())
55 {}
56
59
61 void init();
64 return myFromJunction;
65 }
68 return myToJunction;
69 }
76 static double getTravelTimeStatic(const FlippedEdge<E, N, V>* const edge, const V* const veh, double time) {
77 return edge->getOriginalEdge()->getTravelTime(veh, time);
78 }
85 static double getTravelTimeStaticRandomized(const FlippedEdge<E, N, V>* const edge, const V* const veh, double time) {
86 return edge->getOriginalEdge()->getTravelTimeStaticRandomized(edge->getOriginalEdge(), veh, time);
87 }
88
94 const ConstFlippedEdgePairVector& getViaSuccessors(SUMOVehicleClass vClass = SVC_IGNORING, bool ignoreTransientPermissions = false) const {
95 UNUSED_PARAMETER(ignoreTransientPermissions); // @todo this should be changed (somewhat hidden by #14756)
96 if (vClass == SVC_IGNORING || this->getOriginalEdge()->isTazConnector()) { // || !MSNet::getInstance()->hasPermissions()) {
97 return myViaSuccessors;
98 }
99#ifdef HAVE_FOX
100 FXMutexLock lock(mySuccessorMutex);
101#endif
102 auto i = myClassesViaSuccessorMap.find(vClass);
103 if (i != myClassesViaSuccessorMap.end()) {
104 // can use cached value
105 return i->second;
106 }
107 // instantiate vector
109 // this vClass is requested for the first time. rebuild all successors
110 for (const auto& viaPair : myViaSuccessors) {
111 if (viaPair.first->getOriginalEdge()->isTazConnector()
112 || viaPair.first->getOriginalEdge()->isConnectedTo(*(this->getOriginalEdge()), vClass)) {
113 result.push_back(viaPair);
114 }
115 }
116 return result;
117 }
118
123 return this->getOriginalEdge()->getBidiEdge()->getFlippedRoutingEdge();
124 }
130 double getDistanceTo(const FlippedEdge<E, N, V>* other, const bool doBoundaryEstimate = false) const {
131 return this->getOriginalEdge()->getDistanceTo(other->getOriginalEdge(), doBoundaryEstimate);
132 }
137 double getMinimumTravelTime(const V* const veh) const {
138 return this->getOriginalEdge()->getMinimumTravelTime(veh);
139 }
143 double getTimePenalty() const {
144 return this->getOriginalEdge()->getTimePenalty();
145 }
149 bool hasLoadedTravelTimes() const {
150 return this->getOriginalEdge()->hasLoadedTravelTimes();
151 }
155 double getSpeedLimit() const {
156 return this->getOriginalEdge()->getSpeedLimit();
157 }
162 double getLengthGeometryFactor() const {
163 return this->getOriginalEdge()->getLengthGeometryFactor();
164 }
168 int getPriority() const {
169 return this->getOriginalEdge()->getPriority();
170 }
171
172protected:
176
177private:
179 mutable std::map<SUMOVehicleClass, ConstFlippedEdgePairVector> myClassesViaSuccessorMap;
181
182#ifdef HAVE_FOX
184 mutable FXMutex mySuccessorMutex;
185#endif
186};
187
188// ===========================================================================
189// method definitions
190// ===========================================================================
191
192template<class E, class N, class V>
194 if (!this->getOriginalEdge()->isInternal()) {
195 for (const auto& viaPair : this->getOriginalEdge()->getViaSuccessors()) {
196 const FlippedEdge<E, N, V>* revSource = viaPair.first->getFlippedRoutingEdge();
197 const E* via = viaPair.second;
198 const FlippedEdge<E, N, V>* preVia = nullptr;
199 while (via != nullptr && via->isInternal()) {
200 via->getFlippedRoutingEdge()->myViaSuccessors.push_back(std::make_pair(this, preVia));
201 preVia = via->getFlippedRoutingEdge();
202 via = via->getViaSuccessors().front().second;
203 }
204 revSource->myViaSuccessors.push_back(std::make_pair(this, preVia));
205 }
206 }
207}
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
#define UNUSED_PARAMETER(x)
Definition StdDefs.h:30
The edge type representing backward edges with flipped nodes.
Definition FlippedEdge.h:43
double getLengthGeometryFactor() const
Returns a lower bound on shape.length() / myLength.
bool hasLoadedTravelTimes() const
Returns a boolean flag indicating whether this edge has loaded travel times or not.
static double getTravelTimeStaticRandomized(const FlippedEdge< E, N, V > *const edge, const V *const veh, double time)
Returns the randomized time for travelling on the given edge with the given vehicle at the given time...
Definition FlippedEdge.h:85
~FlippedEdge()
Destructor.
Definition FlippedEdge.h:58
void init()
Initialize the flipped edge.
double getDistanceTo(const FlippedEdge< E, N, V > *other, const bool doBoundaryEstimate=false) const
Returns the distance to another flipped edge param[in] other The other flipped edge param[in] doBound...
FlippedEdge(const E *originalEdge)
Constructor.
Definition FlippedEdge.h:51
const FlippedEdge< E, N, V > * getBidiEdge() const
Returns the bidirectional edge.
int getPriority() const
Returns the edge priority (road class)
double getTimePenalty() const
Returns the time penalty.
ConstFlippedEdgePairVector myViaSuccessors
FlippedNode< E, N, V > * myFromJunction
The junctions for this edge.
std::map< SUMOVehicleClass, ConstFlippedEdgePairVector > myClassesViaSuccessorMap
The successors available for a given vClass.
static double getTravelTimeStatic(const FlippedEdge< E, N, V > *const edge, const V *const veh, double time)
Returns the time for travelling on the given edge with the given vehicle at the given time.
Definition FlippedEdge.h:76
FlippedNode< E, N, V > * myToJunction
const FlippedNode< E, N, V > * getFromJunction() const
Returns the from-junction.
Definition FlippedEdge.h:63
double getMinimumTravelTime(const V *const veh) const
Returns the minimum travel time.
const FlippedNode< E, N, V > * getToJunction() const
Returns the to-junction.
Definition FlippedEdge.h:67
std::vector< std::pair< const FlippedEdge< E, N, V > *, const FlippedEdge< E, N, V > * > > ConstFlippedEdgePairVector
Definition FlippedEdge.h:46
double getSpeedLimit() const
Returns the speed allowed on this edge.
const ConstFlippedEdgePairVector & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING, bool ignoreTransientPermissions=false) const
Returns the via successors.
Definition FlippedEdge.h:94
the node type representing nodes used for backward search
Definition FlippedNode.h:32
the edge type representing backward edges
const E * getOriginalEdge() const
Returns the original edge.