Eclipse SUMO - Simulation of Urban MObility
MSStoppingPlace.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2005-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 /****************************************************************************/
15 // A lane area vehicles can halt at
16 /****************************************************************************/
17 #ifndef MSStoppingPlace_h
18 #define MSStoppingPlace_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <vector>
27 #include <algorithm>
28 #include <map>
29 #include <string>
30 #include <utils/common/Named.h>
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class MSLane;
38 class MSEdge;
39 class SUMOVehicle;
40 class MSTransportable;
41 class Position;
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
59 class MSStoppingPlace : public Named, public Parameterised {
60 public:
70  MSStoppingPlace(const std::string& id,
71  const std::vector<std::string>& lines, MSLane& lane,
72  double begPos, double endPos, const std::string name = "",
73  int capacity = 0);
74 
75 
76 
78  virtual ~MSStoppingPlace();
79 
80 
85  const MSLane& getLane() const;
86 
87 
92  double getBeginLanePosition() const;
93 
94 
99  double getEndLanePosition() const;
100 
101 
113  void enter(SUMOVehicle* what, double beg, double end);
114 
115 
125  void leaveFrom(SUMOVehicle* what);
126 
127 
132  double getLastFreePos(const SUMOVehicle& forVehicle) const;
133 
135  bool fits(double pos, const SUMOVehicle& veh) const;
136 
141  virtual Position getWaitPosition(MSTransportable* person) const;
142 
147  double getWaitingPositionOnLane(MSTransportable* t) const;
148 
149 
154  double getStoppingPosition(const SUMOVehicle* veh) const;
155 
159  return (int)myWaitingTransportables.size();
160  }
161 
164  std::vector<MSTransportable*> getTransportables() const;
165 
169  return (int)myEndPositions.size();
170  }
171 
172  double getLastFreePos() const {
173  return myLastFreePos;
174  }
175 
177  bool hasSpaceForTransportable() const;
178 
181 
184 
186  virtual bool addAccess(MSLane* lane, const double pos, const double length);
187 
189  const std::vector<std::tuple<MSLane*, double, double> >& getAllAccessPos() const {
190  return myAccessPos;
191  }
192 
194  double getAccessPos(const MSEdge* edge) const;
195 
197  double getAccessDistance(const MSEdge* edge) const;
198 
199  const std::string& getMyName() const;
200 
201  static int getPersonsAbreast(double length);
202 
203 protected:
210  void computeLastFreePos();
211 
212  int getPersonsAbreast() const;
213 
214 protected:
216  std::vector<std::string> myLines;
217 
219  std::map<const SUMOVehicle*, std::pair<double, double> > myEndPositions;
220 
222  const MSLane& myLane;
223 
225  const double myBegPos;
226 
228  const double myEndPos;
229 
232 
234  const std::string myName;
235 
238 
239 protected:
240 
242  std::map<MSTransportable*, int> myWaitingTransportables;
243  std::set<int> myWaitingSpots;
244 
246  std::vector<std::tuple<MSLane*, double, double> > myAccessPos;
247 
248 private:
251 
254 
255 
256 };
257 
258 
259 #endif
260 
261 /****************************************************************************/
262 
MSStoppingPlace::getLane
const MSLane & getLane() const
Returns the lane this stop is located at.
Definition: MSStoppingPlace.cpp:57
MSStoppingPlace::hasSpaceForTransportable
bool hasSpaceForTransportable() const
whether there is still capacity for more transportables
Definition: MSStoppingPlace.cpp:180
MSStoppingPlace
A lane area vehicles can halt at.
Definition: MSStoppingPlace.h:59
MSStoppingPlace::myLines
std::vector< std::string > myLines
The list of lines that are assigned to this stop.
Definition: MSStoppingPlace.h:216
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:42
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Named
Base class for objects which have an id.
Definition: Named.h:56
MSStoppingPlace::addTransportable
bool addTransportable(MSTransportable *p)
adds a transportable to this stop
Definition: MSStoppingPlace.cpp:185
MSStoppingPlace::getEndLanePosition
double getEndLanePosition() const
Returns the end position of this stop.
Definition: MSStoppingPlace.cpp:69
MSStoppingPlace::getBeginLanePosition
double getBeginLanePosition() const
Returns the begin position of this stop.
Definition: MSStoppingPlace.cpp:63
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
MSStoppingPlace::MSStoppingPlace
MSStoppingPlace(const std::string &id, const std::vector< std::string > &lines, MSLane &lane, double begPos, double endPos, const std::string name="", int capacity=0)
Constructor.
Definition: MSStoppingPlace.cpp:37
MSStoppingPlace::addAccess
virtual bool addAccess(MSLane *lane, const double pos, const double length)
adds an access point to this stop
Definition: MSStoppingPlace.cpp:271
MSStoppingPlace::removeTransportable
void removeTransportable(MSTransportable *p)
Removes a transportable from this stop.
Definition: MSStoppingPlace.cpp:198
MSStoppingPlace::myEndPositions
std::map< const SUMOVehicle *, std::pair< double, double > > myEndPositions
A map from objects (vehicles) to the areas they acquire after entering the stop.
Definition: MSStoppingPlace.h:219
MSTransportable
Definition: MSTransportable.h:58
MSStoppingPlace::myBegPos
const double myBegPos
The begin position this bus stop is located at.
Definition: MSStoppingPlace.h:225
MSStoppingPlace::operator=
MSStoppingPlace & operator=(const MSStoppingPlace &)
Invalidated assignment operator.
MSStoppingPlace::myName
const std::string myName
The name of the stopping place.
Definition: MSStoppingPlace.h:234
MSStoppingPlace::myEndPos
const double myEndPos
The end position this bus stop is located at.
Definition: MSStoppingPlace.h:228
MSStoppingPlace::getTransportables
std::vector< MSTransportable * > getTransportables() const
Returns the tranportables waiting on this stop.
Definition: MSStoppingPlace.cpp:171
Parameterised.h
MSStoppingPlace::getStoppingPosition
double getStoppingPosition(const SUMOVehicle *veh) const
For vehicles at the stop this gives the the actual stopping position of the vehicle....
Definition: MSStoppingPlace.cpp:161
Named.h
MSStoppingPlace::getStoppedVehicleNumber
int getStoppedVehicleNumber() const
Returns the number of stopped vehicles waiting on this stop.
Definition: MSStoppingPlace.h:168
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
MSStoppingPlace::myAccessPos
std::vector< std::tuple< MSLane *, double, double > > myAccessPos
lanes and positions connected to this stop
Definition: MSStoppingPlace.h:246
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
MSStoppingPlace::getAccessDistance
double getAccessDistance(const MSEdge *edge) const
the distance from the access on the given edge to the stop, -1 on failure
Definition: MSStoppingPlace.cpp:244
MSStoppingPlace::computeLastFreePos
void computeLastFreePos()
Computes the last free position on this stop.
Definition: MSStoppingPlace.cpp:218
MSStoppingPlace::enter
void enter(SUMOVehicle *what, double beg, double end)
Called if a vehicle enters this stop.
Definition: MSStoppingPlace.cpp:75
MSStoppingPlace::getMyName
const std::string & getMyName() const
Definition: MSStoppingPlace.cpp:265
MSStoppingPlace::myTransportableCapacity
const int myTransportableCapacity
The number of transportables that can wait here.
Definition: MSStoppingPlace.h:237
MSStoppingPlace::~MSStoppingPlace
virtual ~MSStoppingPlace()
Destructor.
Definition: MSStoppingPlace.cpp:53
MSStoppingPlace::myWaitingSpots
std::set< int > myWaitingSpots
Definition: MSStoppingPlace.h:243
MSStoppingPlace::myWaitingTransportables
std::map< MSTransportable *, int > myWaitingTransportables
Persons waiting at this stop (mapped to waiting position)
Definition: MSStoppingPlace.h:242
MSStoppingPlace::leaveFrom
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
Definition: MSStoppingPlace.cpp:210
MSStoppingPlace::getAllAccessPos
const std::vector< std::tuple< MSLane *, double, double > > & getAllAccessPos() const
lanes and positions connected to this stop
Definition: MSStoppingPlace.h:189
MSStoppingPlace::getAccessPos
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
Definition: MSStoppingPlace.cpp:230
MSStoppingPlace::myLastFreePos
double myLastFreePos
The last free position at this stop (variable)
Definition: MSStoppingPlace.h:231
MSStoppingPlace::getLastFreePos
double getLastFreePos() const
Definition: MSStoppingPlace.h:172
MSStoppingPlace::getWaitingPositionOnLane
double getWaitingPositionOnLane(MSTransportable *t) const
Returns the lane position corresponding to getWaitPosition()
Definition: MSStoppingPlace.cpp:122
MSStoppingPlace::getTransportableNumber
int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
Definition: MSStoppingPlace.h:158
config.h
MSStoppingPlace::MSStoppingPlace
MSStoppingPlace(const MSStoppingPlace &)
Invalidated copy constructor.
MSStoppingPlace::getWaitPosition
virtual Position getWaitPosition(MSTransportable *person) const
Returns the next free waiting place for pedestrians / containers.
Definition: MSStoppingPlace.cpp:143
MSStoppingPlace::getPersonsAbreast
int getPersonsAbreast() const
Definition: MSStoppingPlace.cpp:138
MSStoppingPlace::fits
bool fits(double pos, const SUMOVehicle &veh) const
return whether the given vehicle fits at the given position
Definition: MSStoppingPlace.cpp:115
MSStoppingPlace::myLane
const MSLane & myLane
The lane this bus stop is located at.
Definition: MSStoppingPlace.h:222