Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2026 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>
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class MSLane;
38class MSEdge;
39class SUMOVehicle;
40class MSTransportable;
41class Position;
42
43
44// ===========================================================================
45// class definitions
46// ===========================================================================
59class MSStoppingPlace : public Named, public Parameterised {
60public:
61 enum class AccessExit {
63 DOORS,
65 };
66
67 struct Access {
68 MSLane* const lane;
69 const double startPos;
70 const double endPos;
71 const double length;
73 };
74
84 MSStoppingPlace(const std::string& id,
85 SumoXMLTag element,
86 const std::vector<std::string>& lines, MSLane& lane,
87 double begPos, double endPos,
88 const std::string name = "",
89 int capacity = 0,
90 double parkingLength = 0,
91 const RGBColor& color = RGBColor::INVISIBLE,
92 double angle = 90);
93
94
95
97 virtual ~MSStoppingPlace();
98
99
104 const MSLane& getLane() const;
105
106
111 double getBeginLanePosition() const;
112
113
118 double getEndLanePosition() const;
119
120 double getAngle() const {
121 return myAngle;
122 }
123
125 Position getCenterPos() const;
126
137 virtual void enter(SUMOVehicle* veh, const bool parking);
138
139
149 virtual void leaveFrom(SUMOVehicle* what);
150
151
158 virtual double getLastFreePos(const SUMOVehicle& forVehicle, double brakePos = 0) const;
159
160 virtual bool accepts(SUMOVehicle* /*veh*/) const {
161 return true;
162 }
163
165 bool fits(double pos, const SUMOVehicle& veh) const;
166
172
178
179
184 double getStoppingPosition(const SUMOVehicle* veh) const;
185
189 return (int)myWaitingTransportables.size();
190 }
191
194 std::vector<const MSTransportable*> getTransportables() const;
195
199 return (int)myEndPositions.size();
200 }
201
202 double getLastFreePos() const {
203 return myLastFreePos;
204 }
205
207 bool hasSpaceForTransportable() const;
208
210 bool addTransportable(const MSTransportable* p, int spot = -1);
211
214
215 int checkWaitingSpot(const MSTransportable* p) const;
216
218 virtual bool addAccess(MSLane* const lane, const double startPos, const double endPos, double length, const MSStoppingPlace::AccessExit exit);
219
221 const std::vector<Access>& getAllAccessPos() const {
222 return myAccessPos;
223 }
224
226 double getAccessPos(const MSEdge* edge, SumoRNG* rng = nullptr) const;
227
229 const Access* getAccess(const MSEdge* edge) const;
230
231 const std::string& getMyName() const;
232
235 return myElement;
236 }
237
238 const RGBColor& getColor() const;
239
240 static int getDefaultTransportablesAbreast(double length, SumoXMLTag element);
241
243 std::vector<const SUMOVehicle*> getStoppedVehicles() const;
244
246 inline int getNumWaitingPersons() const {
247 return (int)myWaitingTransportables.size();
248 }
249
251 inline int getWaitingCapacity() const {
253 }
254
255 inline double getParkingLength() const {
256 return (myEndPos - myBegPos) / myParkingFactor;
257 }
258
260 void getWaitingPersonIDs(std::vector<std::string>& into) const;
261
265
267 virtual void finishedLoading();
268
270 void clearState();
271
272protected:
279 void computeLastFreePos();
280
281 int getTransportablesAbreast() const;
282
283 static double getDefaultTransportableWidth(SumoXMLTag element);
284
285protected:
288
290 std::vector<std::string> myLines;
291
293 std::map<const SUMOVehicle*, std::pair<double, double>, ComparatorNumericalIdLess> myEndPositions;
294
297
299 const double myBegPos;
300
302 const double myEndPos;
303
308
310 const std::string myName;
311
314
316 const double myParkingFactor;
317
320
322 double myAngle;
323
328
330 std::map<const MSTransportable*, int> myWaitingTransportables;
331 std::set<int> myWaitingSpots;
332
334 std::vector<Access> myAccessPos;
335
336private:
339
342
343
344};
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
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)
int checkWaitingSpot(const MSTransportable *p) const
const SumoXMLTag myElement
the type of stopping place
double getWaitingPositionOnLane(MSTransportable *t) const
Returns the lane position corresponding to getWaitPosition()
double myTransportableWidth
the with of waiting transportables
virtual bool accepts(SUMOVehicle *) const
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 double myBegPos
The begin position this bus stop is located at.
MSStoppingPlace & operator=(const MSStoppingPlace &)
Invalidated assignment operator.
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 transportables waiting on this stop.
void clearState()
Remove all vehicles before quick-loading state.
virtual void finishedLoading()
perform extra processing after element has been loaded
double getParkingLength() const
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
virtual void enter(SUMOVehicle *veh, const bool parking)
Called if a vehicle enters this stop.
bool fits(double pos, const SUMOVehicle &veh) const
return whether the given vehicle fits at the given position
double myTransportableDepth
row depth of waiting transportables
static double getDefaultTransportableWidth(SumoXMLTag element)
double getAngle() const
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
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.
bool addTransportable(const MSTransportable *p, int spot=-1)
adds a transportable to this stop
double getStoppingPosition(const SUMOVehicle *veh) const
For vehicles at the stop this gives the actual stopping position of the vehicle. For all others the l...
void removeTransportable(const MSTransportable *p)
Removes a transportable from this stop.
virtual ~MSStoppingPlace()
Destructor.
void computeLastFreePos()
Computes the last free position on this stop.
double myAngle
The angle offset for waiting transportables.
const RGBColor & getColor() const
void getWaitingPersonIDs(std::vector< std::string > &into) const
get IDs of persons waiting at this stop
const std::vector< Access > & getAllAccessPos() const
lanes and positions connected to 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
virtual bool addAccess(MSLane *const lane, const double startPos, const double endPos, double length, const MSStoppingPlace::AccessExit exit)
adds an access point to this stop
static int getDefaultTransportablesAbreast(double length, SumoXMLTag element)
double myLastFreePos
The last free position at this stop (variable)
double getLastFreePos() const
virtual void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
bool checkPersonCapacity() const
Base class for objects which have an id.
Definition Named.h:54
An upper class for objects with additional parameters.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static const RGBColor INVISIBLE
Definition RGBColor.h:198
Representation of a vehicle.
Definition SUMOVehicle.h:63
Function-object for stable sorting of objects with numerical ids.
Definition Named.h:39