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.dev/sumo
3 // Copyright (C) 2005-2024 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 /****************************************************************************/
20 // A lane area vehicles can halt at
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <vector>
26 #include <algorithm>
27 #include <map>
28 #include <string>
29 #include <utils/common/Named.h>
31 #include <utils/common/RGBColor.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:
61  struct Access {
62  MSLane* const lane;
63  const double startPos;
64  const double endPos;
65  const double length;
66  const bool useDoors;
67  };
68 
78  MSStoppingPlace(const std::string& id,
79  SumoXMLTag element,
80  const std::vector<std::string>& lines, MSLane& lane,
81  double begPos, double endPos,
82  const std::string name = "",
83  int capacity = 0,
84  double parkingLength = 0,
85  const RGBColor& color = RGBColor::INVISIBLE);
86 
87 
88 
90  virtual ~MSStoppingPlace();
91 
92 
97  const MSLane& getLane() const;
98 
99 
104  double getBeginLanePosition() const;
105 
106 
111  double getEndLanePosition() const;
112 
114  Position getCenterPos() const;
115 
127  void enter(SUMOVehicle* veh, bool parking);
128 
129 
139  void leaveFrom(SUMOVehicle* what);
140 
141 
148  double getLastFreePos(const SUMOVehicle& forVehicle, double brakePos = 0) const;
149 
151  bool fits(double pos, const SUMOVehicle& veh) const;
152 
158 
163  double getWaitingPositionOnLane(MSTransportable* t) const;
164 
165 
170  double getStoppingPosition(const SUMOVehicle* veh) const;
171 
175  return (int)myWaitingTransportables.size();
176  }
177 
180  std::vector<const MSTransportable*> getTransportables() const;
181 
185  return (int)myEndPositions.size();
186  }
187 
188  double getLastFreePos() const {
189  return myLastFreePos;
190  }
191 
193  bool hasSpaceForTransportable() const;
194 
196  bool addTransportable(const MSTransportable* p);
197 
199  void removeTransportable(const MSTransportable* p);
200 
202  virtual bool addAccess(MSLane* const lane, const double startPos, const double endPos, double length, const bool doors);
203 
205  const std::vector<Access>& getAllAccessPos() const {
206  return myAccessPos;
207  }
208 
210  double getAccessPos(const MSEdge* edge, SumoRNG* rng = nullptr) const;
211 
213  const Access* getAccess(const MSEdge* edge) const;
214 
215  const std::string& getMyName() const;
216 
219  return myElement;
220  }
221 
222  const RGBColor& getColor() const;
223 
224  static int getTransportablesAbreast(double length, SumoXMLTag element);
225 
227  std::vector<const SUMOVehicle*> getStoppedVehicles() const;
228 
230  inline int getNumWaitingPersons() const {
231  return (int)myWaitingTransportables.size();
232  }
233 
235  inline int getWaitingCapacity() const {
237  }
238 
240  void getWaitingPersonIDs(std::vector<std::string>& into) const;
241 
243  void clearState();
244 
245 protected:
252  void computeLastFreePos();
253 
254  int getTransportablesAbreast() const;
255 
256 protected:
259 
261  std::vector<std::string> myLines;
262 
264  std::map<const SUMOVehicle*, std::pair<double, double>, ComparatorNumericalIdLess> myEndPositions;
265 
267  const MSLane& myLane;
268 
270  const double myBegPos;
271 
273  const double myEndPos;
274 
279 
281  const std::string myName;
282 
285 
287  const double myParkingFactor;
288 
291 
293  const double myTransportableDepth;
294 
296  std::map<const MSTransportable*, int> myWaitingTransportables;
297  std::set<int> myWaitingSpots;
298 
300  std::vector<Access> myAccessPos;
301 
302 private:
305 
308 
309 
310 };
SumoXMLTag
Numbers representing SUMO-XML - element names.
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
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.
const SUMOVehicle * myLastParking
The length of the last parking vehicle (or 0 if there is none)
const SumoXMLTag myElement
the type of stopping place
double getWaitingPositionOnLane(MSTransportable *t) const
Returns the lane position corresponding to getWaitPosition()
const Access * getAccess(const MSEdge *edge) const
the access on the given edge to the stop, nullptr if there is none
std::map< const MSTransportable *, int > myWaitingTransportables
Persons waiting at this stop (mapped to waiting position)
const std::vector< Access > & getAllAccessPos() const
lanes and positions connected to this stop
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.
int getTransportablesAbreast() const
std::vector< const MSTransportable * > getTransportables() const
Returns the tranportables waiting on this stop.
void clearState()
Remove all vehicles before quick-loading state.
int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
std::set< int > myWaitingSpots
const double myParkingFactor
the scaled space capacity for parking vehicles
Position getCenterPos() const
the position in the middle of the stop shape
bool fits(double pos, const SUMOVehicle &veh) const
return whether the given vehicle fits at the given position
MSStoppingPlace(const MSStoppingPlace &)
Invalidated copy constructor.
const std::string myName
The name of the stopping place.
int getWaitingCapacity() const
get number of persons that can wait at this stop
MSStoppingPlace(const std::string &id, SumoXMLTag element, const std::vector< std::string > &lines, MSLane &lane, double begPos, double endPos, const std::string name="", int capacity=0, double parkingLength=0, const RGBColor &color=RGBColor::INVISIBLE)
Constructor.
SumoXMLTag getElement() const
return the type of this stopping place
std::vector< Access > myAccessPos
lanes and positions connected to this stop
const double myEndPos
The end position this bus stop is located at.
double getEndLanePosition() const
Returns the end position of this stop.
const RGBColor myColor
The color of the stopping place.
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.
double getStoppingPosition(const SUMOVehicle *veh) const
For vehicles at the stop this gives the the actual stopping position of the vehicle....
void removeTransportable(const MSTransportable *p)
Removes a transportable from this stop.
virtual ~MSStoppingPlace()
Destructor.
void computeLastFreePos()
Computes the last free position on this stop.
const RGBColor & getColor() const
virtual bool addAccess(MSLane *const lane, const double startPos, const double endPos, double length, const bool doors)
adds an access point to 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
Position getWaitPosition(MSTransportable *person) const
Returns the next free waiting place for pedestrians / containers.
double getAccessPos(const MSEdge *edge, SumoRNG *rng=nullptr) const
the position on the given edge which is connected to this stop, -1 on failure
MSStoppingPlace & operator=(const MSStoppingPlace &)
Invalidated assignment operator.
bool addTransportable(const MSTransportable *p)
adds a transportable to this stop
double myLastFreePos
The last free position at this stop (variable)
double getLastFreePos() const
const double myTransportableDepth
row depth of waiting transportables
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
Base class for objects which have an id.
Definition: Named.h:54
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const RGBColor INVISIBLE
Definition: RGBColor.h:195
Representation of a vehicle.
Definition: SUMOVehicle.h:60
Function-object for stable sorting of objects with numerical ids.
Definition: Named.h:39