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 
std::map< const SUMOVehicle *, std::pair< double, double > > myEndPositions
A map from objects (vehicles) to the areas they acquire after entering the stop.
int getPersonsAbreast() const
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
double getBeginLanePosition() const
Returns the begin position of this stop.
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.
A lane area vehicles can halt at.
const double myEndPos
The end position this bus stop is located at.
void enter(SUMOVehicle *what, double beg, double end)
Called if a vehicle enters this stop.
int getStoppedVehicleNumber() const
Returns the number of stopped vehicles waiting on this stop.
double getWaitingPositionOnLane(MSTransportable *t) const
Returns the lane position corresponding to getWaitPosition()
std::set< int > myWaitingSpots
int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
const std::string & getMyName() const
virtual ~MSStoppingPlace()
Destructor.
bool hasSpaceForTransportable() const
whether there is still capacity for more transportables
A road/street connecting two junctions.
Definition: MSEdge.h:76
const MSLane & myLane
The lane this bus stop is located at.
double getEndLanePosition() const
Returns the end position of this stop.
MSStoppingPlace & operator=(const MSStoppingPlace &)
Invalidated assignment operator.
bool fits(double pos, const SUMOVehicle &veh) const
return whether the given vehicle fits at the given position
Representation of a vehicle.
Definition: SUMOVehicle.h:61
double myLastFreePos
The last free position at this stop (variable)
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
std::vector< MSTransportable * > getTransportables() const
Returns the tranportables waiting on this stop.
void removeTransportable(MSTransportable *p)
Removes a transportable from this stop.
virtual Position getWaitPosition(MSTransportable *person) const
Returns the next free waiting place for pedestrians / containers.
An upper class for objects with additional parameters.
Definition: Parameterised.h:43
Base class for objects which have an id.
Definition: Named.h:57
bool addTransportable(MSTransportable *p)
adds a transportable to this stop
virtual bool addAccess(MSLane *lane, const double pos, const double length)
adds an access point to this stop
double getAccessDistance(const MSEdge *edge) const
the distance from the access on the given edge to the stop, -1 on failure
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
const std::string myName
The name of the stopping place.
const double myBegPos
The begin position this bus stop is located at.
std::map< MSTransportable *, int > myWaitingTransportables
Persons waiting at this stop (mapped to waiting position)
const std::vector< std::tuple< MSLane *, double, double > > & getAllAccessPos() const
lanes and positions connected to this stop
std::vector< std::tuple< MSLane *, double, double > > myAccessPos
lanes and positions connected to this stop
void computeLastFreePos()
Computes the last free position on this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
double getLastFreePos() const
const int myTransportableCapacity
The number of transportables that can wait here.
std::vector< std::string > myLines
The list of lines that are assigned to this stop.
double getStoppingPosition(const SUMOVehicle *veh) const
For vehicles at the stop this gives the the actual stopping position of the vehicle. For all others the last free stopping position.
Representation of a lane in the micro simulation.
Definition: MSLane.h:83