Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2025 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(originalEdge->getToJunction()->getFlippedRoutingNode()),
54 myToJunction(originalEdge->getFromJunction()->getFlippedRoutingNode())
55 {}
56
59
61 void init();
62
65 return myFromJunction;
66 }
67
70 return myToJunction;
71 }
72
79 static double getTravelTimeStatic(const FlippedEdge<E, N, V>* const edge, const V* const veh, double time) {
80 return edge->getOriginalEdge()->getTravelTime(veh, time);
81 }
82
89 static double getTravelTimeStaticRandomized(const FlippedEdge<E, N, V>* const edge, const V* const veh, double time) {
90 return edge->getOriginalEdge()->getTravelTimeStaticRandomized(edge->getOriginalEdge(), veh, time);
91 }
92
98 const ConstFlippedEdgePairVector& getViaSuccessors(SUMOVehicleClass vClass = SVC_IGNORING, bool ignoreTransientPermissions = false) const {
99 UNUSED_PARAMETER(ignoreTransientPermissions); // @todo this should be changed (somewhat hidden by #14756)
100 if (vClass == SVC_IGNORING || this->getOriginalEdge()->isTazConnector()) { // || !MSNet::getInstance()->hasPermissions()) {
101 return myViaSuccessors;
102 }
103#ifdef HAVE_FOX
104 FXMutexLock lock(mySuccessorMutex);
105#endif
106 auto i = myClassesViaSuccessorMap.find(vClass);
107 if (i != myClassesViaSuccessorMap.end()) {
108 // can use cached value
109 return i->second;
110 }
111 // instantiate vector
113 // this vClass is requested for the first time. rebuild all successors
114 for (const auto& viaPair : myViaSuccessors) {
115 if (viaPair.first->getOriginalEdge()->isTazConnector()
116 || viaPair.first->getOriginalEdge()->isConnectedTo(*(this->getOriginalEdge()), vClass)) {
117 result.push_back(viaPair);
118 }
119 }
120 return result;
121 }
122
127 return this->getOriginalEdge()->getBidiEdge()->getFlippedRoutingEdge();
128 }
129
135 double getDistanceTo(const FlippedEdge<E, N, V>* other, const bool doBoundaryEstimate = false) const {
136 return this->getOriginalEdge()->getDistanceTo(other->getOriginalEdge(), doBoundaryEstimate);
137 }
138
143 double getMinimumTravelTime(const V* const veh) const {
144 return this->getOriginalEdge()->getMinimumTravelTime(veh);
145 }
146
150 double getTimePenalty() const {
151 return this->getOriginalEdge()->getTimePenalty();
152 }
153
157 bool hasLoadedTravelTimes() const {
158 return this->getOriginalEdge()->hasLoadedTravelTimes();
159 }
160
164 double getSpeedLimit() const {
165 return this->getOriginalEdge()->getSpeedLimit();
166 }
167
172 double getLengthGeometryFactor() const {
173 return this->getOriginalEdge()->getLengthGeometryFactor();
174 }
175
179 int getPriority() const {
180 return this->getOriginalEdge()->getPriority();
181 }
182
183protected:
187
188private:
190 mutable std::map<SUMOVehicleClass, ConstFlippedEdgePairVector> myClassesViaSuccessorMap;
192
193#ifdef HAVE_FOX
195 mutable FXMutex mySuccessorMutex;
196#endif
197};
198
199// ===========================================================================
200// method definitions
201// ===========================================================================
202
203template<class E, class N, class V>
205 if (!this->getOriginalEdge()->isInternal()) {
206 for (const auto& viaPair : this->getOriginalEdge()->getViaSuccessors()) {
207 const FlippedEdge<E, N, V>* revSource = viaPair.first->getFlippedRoutingEdge();
208 const E* via = viaPair.second;
209 const FlippedEdge<E, N, V>* preVia = nullptr;
210 while (via != nullptr && via->isInternal()) {
211 via->getFlippedRoutingEdge()->myViaSuccessors.push_back(std::make_pair(this, preVia));
212 preVia = via->getFlippedRoutingEdge();
213 via = via->getViaSuccessors().front().second;
214 }
215 revSource->myViaSuccessors.push_back(std::make_pair(this, preVia));
216 }
217 }
218}
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
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:89
~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:79
FlippedNode< E, N, V > * myToJunction
const FlippedNode< E, N, V > * getFromJunction() const
Returns the from-junction.
Definition FlippedEdge.h:64
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:69
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:98
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.
#define UNUSED_PARAMETER(x)