SUMO - Simulation of Urban MObility
IntermodalEdge.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-2018 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 Edge definition for the Intermodal Router
18 /****************************************************************************/
19 #ifndef IntermodalEdge_h
20 #define IntermodalEdge_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <vector>
31 #include "IntermodalTrip.h"
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
38 template<class E, class L, class N, class V>
39 class IntermodalEdge : public Named {
40 public:
41  IntermodalEdge(const std::string id, int numericalID, const E* edge, const std::string& line, const double length = 0.) :
42  Named(id),
43  myNumericalID(numericalID),
44  myEdge(edge),
45  myLine(line),
46  myLength(edge == nullptr || length > 0. ? length : edge->getLength()),
47  myEfforts(nullptr) { }
48 
49  virtual ~IntermodalEdge() {}
50 
51  virtual bool includeInRoute(bool /* allEdges */) const {
52  return false;
53  }
54 
55  inline const std::string& getLine() const {
56  return myLine;
57  }
58 
59  inline const E* getEdge() const {
60  return myEdge;
61  }
62 
63  int getNumericalID() const {
64  return myNumericalID;
65  }
66 
67  void addSuccessor(IntermodalEdge* const s, IntermodalEdge* const via = nullptr) {
68  myFollowingEdges.push_back(s);
69  myFollowingViaEdges.push_back(std::make_pair(s, via));
70  }
71 
75  myFollowingEdges.clear();
76  myFollowingViaEdges.clear();
77  }
78 
79  void removeSuccessor(const IntermodalEdge* const edge) {
80  myFollowingEdges.erase(std::find(myFollowingEdges.begin(), myFollowingEdges.end(), edge));
81  for (auto it = myFollowingViaEdges.begin(); it != myFollowingViaEdges.end();) {
82  if (it->first == edge) {
83  it = myFollowingViaEdges.erase(it);
84  } else {
85  ++it;
86  }
87  }
88  }
89 
90  virtual const std::vector<IntermodalEdge*>& getSuccessors(SUMOVehicleClass vClass = SVC_IGNORING) const {
91  UNUSED_PARAMETER(vClass);
92  // the network is already tailored. No need to check for permissions here
93  return myFollowingEdges;
94  }
95 
96  virtual const std::vector<std::pair<const IntermodalEdge*, const IntermodalEdge*> >& getViaSuccessors(SUMOVehicleClass vClass = SVC_IGNORING) const {
97  UNUSED_PARAMETER(vClass);
98  // the network is already tailored. No need to check for permissions here
99  return myFollowingViaEdges;
100  }
101 
102  virtual bool prohibits(const IntermodalTrip<E, N, V>* const /* trip */) const {
103  return false;
104  }
105 
106  virtual double getTravelTime(const IntermodalTrip<E, N, V>* const /* trip */, double /* time */) const {
107  return 0.;
108  }
109 
111  virtual double getIntended(const double /* time */, std::string& /* intended */) const {
112  return 0.;
113  }
114 
115  static inline double getTravelTimeStatic(const IntermodalEdge* const edge, const IntermodalTrip<E, N, V>* const trip, double time) {
116  return edge == nullptr ? 0. : edge->getTravelTime(trip, time);
117  }
118 
119  virtual double getEffort(const IntermodalTrip<E, N, V>* const /* trip */, double /* time */) const {
120  return 0.;
121  }
122 
123  static inline double getEffortStatic(const IntermodalEdge* const edge, const IntermodalTrip<E, N, V>* const trip, double time) {
124  return edge == nullptr || !edge->hasEffort() ? 0. : edge->getEffort(trip, time);
125  }
126 
127  inline double getLength() const {
128  return myLength;
129  }
130 
131  inline void setLength(const double length) {
132  myLength = length;
133  }
134 
135  inline bool isInternal() const {
136  return myEdge != nullptr && myEdge->isInternal();
137  }
138 
139  virtual bool hasEffort() const {
140  return myEfforts != nullptr;
141  }
142 
143  virtual double getStartPos() const {
144  return 0.;
145  }
146 
147  virtual double getEndPos() const {
148  return myLength;
149  }
150 
151  // only used by AStar
152  inline double getSpeedLimit() const {
153  return myEdge != nullptr ? myEdge->getSpeedLimit() : 200. / 3.6;
154  }
155 
156  // only used by AStar
157  inline double getLengthGeometryFactor() const {
158  return myEdge != nullptr ? myEdge->getLengthGeometryFactor() : 1;
159  }
160 
161  // only used by AStar
162  inline double getDistanceTo(const IntermodalEdge* other) const {
163  return myEdge != nullptr && other->myEdge != nullptr ? myEdge->getDistanceTo(other->myEdge, true) : 0.;
164  }
165 
166  // only used by AStar
167  inline double getMinimumTravelTime(const IntermodalTrip<E, N, V>* const trip) const {
168  return myLength / trip->getMaxSpeed();
169  }
170 
171 protected:
173  std::vector<IntermodalEdge*> myFollowingEdges;
174 
176  std::vector<std::pair<const IntermodalEdge*, const IntermodalEdge*> > myFollowingViaEdges;
177 
178 private:
180  const int myNumericalID;
181 
183  const E* const myEdge;
184 
186  const std::string myLine;
187 
189  double myLength;
190 
193 
194 private:
196  IntermodalEdge(const IntermodalEdge& src);
197 
200 
201 };
202 
203 
204 #endif
205 
206 /****************************************************************************/
virtual double getEndPos() const
static double getEffortStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
double getDistanceTo(const IntermodalEdge *other) const
std::vector< std::pair< const IntermodalEdge *, const IntermodalEdge * > > myFollowingViaEdges
List of edges that may be approached from this edge with optional internal vias.
const E *const myEdge
the original edge
const std::string & getLine() const
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
const std::string myLine
public transport line or ped vs car
virtual double getIntended(const double, std::string &) const
get intended vehicle id and departure time of next public transport ride
virtual const std::vector< std::pair< const IntermodalEdge *, const IntermodalEdge * > > & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
virtual bool includeInRoute(bool) const
static double getTravelTimeStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
IntermodalEdge & operator=(const IntermodalEdge &src)
Invalidated assignment operator.
int getNumericalID() const
double getMaxSpeed() const
std::vector< IntermodalEdge * > myFollowingEdges
List of edges that may be approached from this edge.
virtual const std::vector< IntermodalEdge * > & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
double getSpeedLimit() const
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:33
void removeSuccessor(const IntermodalEdge *const edge)
const E * getEdge() const
void transferSuccessors(IntermodalEdge *to)
bool isInternal() const
virtual bool prohibits(const IntermodalTrip< E, N, V > *const) const
virtual ~IntermodalEdge()
Base class for objects which have an id.
Definition: Named.h:58
the base edge type that is given to the internal router (SUMOAbstractRouter)
virtual double getEffort(const IntermodalTrip< E, N, V > *const, double) const
double getMinimumTravelTime(const IntermodalTrip< E, N, V > *const trip) const
double myLength
adaptable length (for splitted edges)
IntermodalEdge(const std::string id, int numericalID, const E *edge, const std::string &line, const double length=0.)
double getLength() const
double getLengthGeometryFactor() const
const int myNumericalID
the index in myEdges
virtual double getStartPos() const
ValueTimeLine< double > * myEfforts
Container for passing effort varying over time for the edge.
virtual bool hasEffort() const
void addSuccessor(IntermodalEdge *const s, IntermodalEdge *const via=nullptr)
the "vehicle" type that is given to the internal router (SUMOAbstractRouter)
vehicles ignoring classes
virtual double getTravelTime(const IntermodalTrip< E, N, V > *const, double) const
void setLength(const double length)