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-2020 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 /****************************************************************************/
19 // A lane area vehicles can halt at
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
24 #include <vector>
25 #include <algorithm>
26 #include <map>
27 #include <string>
28 #include <utils/common/Named.h>
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class MSLane;
36 class MSEdge;
37 class SUMOVehicle;
38 class MSTransportable;
39 class Position;
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
57 class MSStoppingPlace : public Named, public Parameterised {
58 public:
68  MSStoppingPlace(const std::string& id,
69  const std::vector<std::string>& lines, MSLane& lane,
70  double begPos, double endPos, const std::string name = "",
71  int capacity = 0,
72  double parkingLength = 0);
73 
74 
75 
77  virtual ~MSStoppingPlace();
78 
79 
84  const MSLane& getLane() const;
85 
86 
91  double getBeginLanePosition() const;
92 
93 
98  double getEndLanePosition() const;
99 
100 
112  void enter(SUMOVehicle* veh, bool parking);
113 
114 
124  void leaveFrom(SUMOVehicle* what);
125 
126 
131  double getLastFreePos(const SUMOVehicle& forVehicle) const;
132 
134  bool fits(double pos, const SUMOVehicle& veh) const;
135 
140  virtual Position getWaitPosition(MSTransportable* person) const;
141 
146  double getWaitingPositionOnLane(MSTransportable* t) const;
147 
148 
153  double getStoppingPosition(const SUMOVehicle* veh) const;
154 
158  return (int)myWaitingTransportables.size();
159  }
160 
163  std::vector<MSTransportable*> getTransportables() const;
164 
168  return (int)myEndPositions.size();
169  }
170 
171  double getLastFreePos() const {
172  return myLastFreePos;
173  }
174 
176  bool hasSpaceForTransportable() const;
177 
180 
183 
185  virtual bool addAccess(MSLane* lane, const double pos, const double length);
186 
188  const std::vector<std::tuple<MSLane*, double, double> >& getAllAccessPos() const {
189  return myAccessPos;
190  }
191 
193  double getAccessPos(const MSEdge* edge) const;
194 
196  double getAccessDistance(const MSEdge* edge) const;
197 
198  const std::string& getMyName() const;
199 
200  static int getPersonsAbreast(double length);
201 
203  std::vector<const SUMOVehicle*> getStoppedVehicles() const;
204 
206  inline int getNumWaitingPersons() const {
207  return (int)myWaitingTransportables.size();
208  }
209 
211  void getWaitingPersonIDs(std::vector<std::string>& into) const;
212 
214  void clearState();
215 
216 protected:
223  void computeLastFreePos();
224 
225  int getPersonsAbreast() const;
226 
227 protected:
229  std::vector<std::string> myLines;
230 
232  std::map<const SUMOVehicle*, std::pair<double, double>, ComparatorNumericalIdLess> myEndPositions;
233 
235  const MSLane& myLane;
236 
238  const double myBegPos;
239 
241  const double myEndPos;
242 
245 
247  const std::string myName;
248 
251 
253  const double myParkingFactor;
254 
255 protected:
256 
258  std::map<MSTransportable*, int> myWaitingTransportables;
259  std::set<int> myWaitingSpots;
260 
262  std::vector<std::tuple<MSLane*, double, double> > myAccessPos;
263 
264 private:
267 
270 
271 
272 };
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
A lane area vehicles can halt at.
std::vector< const SUMOVehicle * > getStoppedVehicles() const
get list of vehicles waiting at this stop
int getStoppedVehicleNumber() const
Returns the number of stopped vehicles waiting on this stop.
std::vector< MSTransportable * > getTransportables() const
Returns the tranportables waiting on this stop.
double getWaitingPositionOnLane(MSTransportable *t) const
Returns the lane position corresponding to getWaitPosition()
const double myBegPos
The begin position this bus stop is located at.
double getBeginLanePosition() const
Returns the begin position of this stop.
int getNumWaitingPersons() const
get number of persons waiting at this stop
const MSLane & myLane
The lane this bus stop is located at.
bool hasSpaceForTransportable() const
whether there is still capacity for more transportables
std::map< const SUMOVehicle *, std::pair< double, double >, ComparatorNumericalIdLess > myEndPositions
A map from objects (vehicles) to the areas they acquire after entering the stop.
std::map< MSTransportable *, int > myWaitingTransportables
Persons waiting at this stop (mapped to waiting position)
void clearState()
Remove all vehicles before quick-loading state.
int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
const std::vector< std::tuple< MSLane *, double, double > > & getAllAccessPos() const
lanes and positions connected to this stop
std::set< int > myWaitingSpots
const double myParkingFactor
the scaled space capacity for parking vehicles
MSStoppingPlace(const std::string &id, const std::vector< std::string > &lines, MSLane &lane, double begPos, double endPos, const std::string name="", int capacity=0, double parkingLength=0)
Constructor.
bool fits(double pos, const SUMOVehicle &veh) const
return whether the given vehicle fits at the given position
bool addTransportable(MSTransportable *p)
adds a transportable to this stop
MSStoppingPlace(const MSStoppingPlace &)
Invalidated copy constructor.
const std::string myName
The name of the stopping place.
double getAccessDistance(const MSEdge *edge) const
the distance from the access on the given edge to the stop, -1 on failure
const double myEndPos
The end position this bus stop is located at.
int getPersonsAbreast() const
double getEndLanePosition() const
Returns the end position of this stop.
std::vector< std::tuple< MSLane *, double, double > > myAccessPos
lanes and positions connected to this stop
std::vector< std::string > myLines
The list of lines that are assigned to this stop.
void enter(SUMOVehicle *veh, bool parking)
Called if a vehicle enters this stop.
void removeTransportable(MSTransportable *p)
Removes a transportable from this stop.
double getStoppingPosition(const SUMOVehicle *veh) const
For vehicles at the stop this gives the the actual stopping position of the vehicle....
virtual ~MSStoppingPlace()
Destructor.
void computeLastFreePos()
Computes the last free position on this stop.
void getWaitingPersonIDs(std::vector< std::string > &into) const
get IDs of persons waiting at this stop
const MSLane & getLane() const
Returns the lane this stop is located at.
const int myTransportableCapacity
The number of transportables that can wait here.
const std::string & getMyName() const
virtual Position getWaitPosition(MSTransportable *person) const
Returns the next free waiting place for pedestrians / containers.
MSStoppingPlace & operator=(const MSStoppingPlace &)
Invalidated assignment operator.
double myLastFreePos
The last free position at this stop (variable)
double getLastFreePos() const
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
virtual bool addAccess(MSLane *lane, const double pos, const double length)
adds an access point to this stop
Base class for objects which have an id.
Definition: Named.h:53
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
Representation of a vehicle.
Definition: SUMOVehicle.h:58
Function-object for stable sorting of objects with numerical ids.
Definition: Named.h:38