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 /****************************************************************************/
16 // A lane area vehicles can halt at
17 /****************************************************************************/
18 #ifndef MSStoppingPlace_h
19 #define MSStoppingPlace_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <vector>
28 #include <algorithm>
29 #include <map>
30 #include <string>
31 #include <utils/common/Named.h>
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class MSLane;
39 class MSEdge;
40 class SUMOVehicle;
41 class MSTransportable;
42 class Position;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
60 class MSStoppingPlace : public Named, public Parameterised {
61 public:
71  MSStoppingPlace(const std::string& id,
72  const std::vector<std::string>& lines, MSLane& lane,
73  double begPos, double endPos, const std::string name = "",
74  int capacity = 0);
75 
76 
77 
79  virtual ~MSStoppingPlace();
80 
81 
86  const MSLane& getLane() const;
87 
88 
93  double getBeginLanePosition() const;
94 
95 
100  double getEndLanePosition() const;
101 
102 
114  void enter(SUMOVehicle* what, double beg, double end);
115 
116 
126  void leaveFrom(SUMOVehicle* what);
127 
128 
133  double getLastFreePos(const SUMOVehicle& forVehicle) const;
134 
136  bool fits(double pos, const SUMOVehicle& veh) const;
137 
142  virtual Position getWaitPosition(MSTransportable* person) const;
143 
148  double getWaitingPositionOnLane(MSTransportable* t) const;
149 
150 
155  double getStoppingPosition(const SUMOVehicle* veh) const;
156 
160  return (int)myWaitingTransportables.size();
161  }
162 
165  std::vector<MSTransportable*> getTransportables() const;
166 
170  return (int)myEndPositions.size();
171  }
172 
173  double getLastFreePos() const {
174  return myLastFreePos;
175  }
176 
178  bool hasSpaceForTransportable() const;
179 
182 
185 
187  virtual bool addAccess(MSLane* lane, const double pos, const double length);
188 
190  const std::vector<std::tuple<MSLane*, double, double> >& getAllAccessPos() const {
191  return myAccessPos;
192  }
193 
195  double getAccessPos(const MSEdge* edge) const;
196 
198  double getAccessDistance(const MSEdge* edge) const;
199 
200  const std::string& getMyName() const;
201 
202  static int getPersonsAbreast(double length);
203 
204 protected:
211  void computeLastFreePos();
212 
213  int getPersonsAbreast() const;
214 
215 protected:
217  std::vector<std::string> myLines;
218 
220  std::map<const SUMOVehicle*, std::pair<double, double> > myEndPositions;
221 
223  const MSLane& myLane;
224 
226  const double myBegPos;
227 
229  const double myEndPos;
230 
233 
235  const std::string myName;
236 
239 
240 protected:
241 
243  std::map<MSTransportable*, int> myWaitingTransportables;
244  std::set<int> myWaitingSpots;
245 
247  std::vector<std::tuple<MSLane*, double, double> > myAccessPos;
248 
249 private:
252 
255 
256 
257 };
258 
259 
260 #endif
261 
262 /****************************************************************************/
263 
MSStoppingPlace::getLane
const MSLane & getLane() const
Returns the lane this stop is located at.
Definition: MSStoppingPlace.cpp:58
MSStoppingPlace::hasSpaceForTransportable
bool hasSpaceForTransportable() const
whether there is still capacity for more transportables
Definition: MSStoppingPlace.cpp:181
MSStoppingPlace
A lane area vehicles can halt at.
Definition: MSStoppingPlace.h:60
MSStoppingPlace::myLines
std::vector< std::string > myLines
The list of lines that are assigned to this stop.
Definition: MSStoppingPlace.h:217
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:43
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
Named
Base class for objects which have an id.
Definition: Named.h:57
MSStoppingPlace::addTransportable
bool addTransportable(MSTransportable *p)
adds a transportable to this stop
Definition: MSStoppingPlace.cpp:186
MSStoppingPlace::getEndLanePosition
double getEndLanePosition() const
Returns the end position of this stop.
Definition: MSStoppingPlace.cpp:70
MSStoppingPlace::getBeginLanePosition
double getBeginLanePosition() const
Returns the begin position of this stop.
Definition: MSStoppingPlace.cpp:64
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:61
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:38
MSStoppingPlace::addAccess
virtual bool addAccess(MSLane *lane, const double pos, const double length)
adds an access point to this stop
Definition: MSStoppingPlace.cpp:272
MSStoppingPlace::removeTransportable
void removeTransportable(MSTransportable *p)
Removes a transportable from this stop.
Definition: MSStoppingPlace.cpp:199
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:220
MSTransportable
Definition: MSTransportable.h:59
MSStoppingPlace::myBegPos
const double myBegPos
The begin position this bus stop is located at.
Definition: MSStoppingPlace.h:226
MSStoppingPlace::operator=
MSStoppingPlace & operator=(const MSStoppingPlace &)
Invalidated assignment operator.
MSStoppingPlace::myName
const std::string myName
The name of the stopping place.
Definition: MSStoppingPlace.h:235
MSStoppingPlace::myEndPos
const double myEndPos
The end position this bus stop is located at.
Definition: MSStoppingPlace.h:229
MSStoppingPlace::getTransportables
std::vector< MSTransportable * > getTransportables() const
Returns the tranportables waiting on this stop.
Definition: MSStoppingPlace.cpp:172
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:162
Named.h
MSStoppingPlace::getStoppedVehicleNumber
int getStoppedVehicleNumber() const
Returns the number of stopped vehicles waiting on this stop.
Definition: MSStoppingPlace.h:169
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
MSStoppingPlace::myAccessPos
std::vector< std::tuple< MSLane *, double, double > > myAccessPos
lanes and positions connected to this stop
Definition: MSStoppingPlace.h:247
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
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:245
MSStoppingPlace::computeLastFreePos
void computeLastFreePos()
Computes the last free position on this stop.
Definition: MSStoppingPlace.cpp:219
MSStoppingPlace::enter
void enter(SUMOVehicle *what, double beg, double end)
Called if a vehicle enters this stop.
Definition: MSStoppingPlace.cpp:76
MSStoppingPlace::getMyName
const std::string & getMyName() const
Definition: MSStoppingPlace.cpp:266
MSStoppingPlace::myTransportableCapacity
const int myTransportableCapacity
The number of transportables that can wait here.
Definition: MSStoppingPlace.h:238
MSStoppingPlace::~MSStoppingPlace
virtual ~MSStoppingPlace()
Destructor.
Definition: MSStoppingPlace.cpp:54
MSStoppingPlace::myWaitingSpots
std::set< int > myWaitingSpots
Definition: MSStoppingPlace.h:244
MSStoppingPlace::myWaitingTransportables
std::map< MSTransportable *, int > myWaitingTransportables
Persons waiting at this stop (mapped to waiting position)
Definition: MSStoppingPlace.h:243
MSStoppingPlace::leaveFrom
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
Definition: MSStoppingPlace.cpp:211
MSStoppingPlace::getAllAccessPos
const std::vector< std::tuple< MSLane *, double, double > > & getAllAccessPos() const
lanes and positions connected to this stop
Definition: MSStoppingPlace.h:190
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:231
MSStoppingPlace::myLastFreePos
double myLastFreePos
The last free position at this stop (variable)
Definition: MSStoppingPlace.h:232
MSStoppingPlace::getLastFreePos
double getLastFreePos() const
Definition: MSStoppingPlace.h:173
MSStoppingPlace::getWaitingPositionOnLane
double getWaitingPositionOnLane(MSTransportable *t) const
Returns the lane position corresponding to getWaitPosition()
Definition: MSStoppingPlace.cpp:123
MSStoppingPlace::getTransportableNumber
int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
Definition: MSStoppingPlace.h:159
config.h
MSStoppingPlace::getWaitPosition
virtual Position getWaitPosition(MSTransportable *person) const
Returns the next free waiting place for pedestrians / containers.
Definition: MSStoppingPlace.cpp:144
MSStoppingPlace::getPersonsAbreast
int getPersonsAbreast() const
Definition: MSStoppingPlace.cpp:139
MSStoppingPlace::fits
bool fits(double pos, const SUMOVehicle &veh) const
return whether the given vehicle fits at the given position
Definition: MSStoppingPlace.cpp:116
MSStoppingPlace::myLane
const MSLane & myLane
The lane this bus stop is located at.
Definition: MSStoppingPlace.h:223