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-2018 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>
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 {
60 public:
70  MSStoppingPlace(const std::string& id,
71  const std::vector<std::string>& lines, MSLane& lane,
72  double begPos, double endPos, const std::string name = "");
73 
74 
76  virtual ~MSStoppingPlace();
77 
78 
83  const MSLane& getLane() const;
84 
85 
90  double getBeginLanePosition() const;
91 
92 
97  double getEndLanePosition() const;
98 
99 
111  void enter(SUMOVehicle* what, double beg, double end);
112 
113 
123  void leaveFrom(SUMOVehicle* what);
124 
125 
130  double getLastFreePos(const SUMOVehicle& forVehicle) const;
131 
133  bool fits(double pos, const SUMOVehicle& veh) const;
134 
139  Position getWaitPosition() const;
140 
145  double getWaitingPositionOnLane() const {
146  return myWaitingPos;
147  }
148 
149 
154  double getStoppingPosition(const SUMOVehicle* veh) const;
155 
159  return (int)myWaitingTransportables.size();
160  }
161 
165  return (int)myEndPositions.size();
166  }
167 
168  double getLastFreePos() const {
169  return myLastFreePos;
170  }
171 
174 
177 
179  virtual bool addAccess(MSLane* lane, const double pos, const double length);
180 
182  const std::vector<std::tuple<MSLane*, double, double> >& getAllAccessPos() const {
183  return myAccessPos;
184  }
185 
187  double getAccessPos(const MSEdge* edge) const;
188 
190  double getAccessDistance(const MSEdge* edge) const;
191 
192 protected:
199  void computeLastFreePos();
200 
201 
202 protected:
204  std::vector<std::string> myLines;
205 
207  std::map<const SUMOVehicle*, std::pair<double, double> > myEndPositions;
208 
210  const MSLane& myLane;
211 
213  const double myBegPos;
214 
216  const double myEndPos;
217 
220 
222  double myWaitingPos;
223 
225  const std::string myName;
226 public:
227  const std::string& getMyName() const;
228 protected:
229 
231  std::vector<MSTransportable*> myWaitingTransportables;
232 
234  std::vector<std::tuple<MSLane*, double, double> > myAccessPos;
235 
236 private:
239 
242 
243 
244 };
245 
246 
247 #endif
248 
249 /****************************************************************************/
250 
Position getWaitPosition() const
Returns the next free waiting place for pedestrians / containers.
std::map< const SUMOVehicle *, std::pair< double, double > > myEndPositions
A map from objects (vehicles) to the areas they acquire after entering the stop.
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
MSStoppingPlace(const std::string &id, const std::vector< std::string > &lines, MSLane &lane, double begPos, double endPos, const std::string name="")
Constructor.
double getBeginLanePosition() const
Returns the begin position of this stop.
std::vector< MSTransportable * > myWaitingTransportables
Persons waiting at this stop.
double getWaitingPositionOnLane() const
Returns the lane position corresponding to getWaitPosition()
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.
int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
const std::string & getMyName() const
void addTransportable(MSTransportable *p)
adds a transportable to this stop
virtual ~MSStoppingPlace()
Destructor.
A road/street connecting two junctions.
Definition: MSEdge.h:75
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:60
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
void removeTransportable(MSTransportable *p)
Removes a transportable from this stop.
Base class for objects which have an id.
Definition: Named.h:58
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.
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.
double myWaitingPos
The next free position for persons / containers.
const MSLane & getLane() const
Returns the lane this stop is located at.
double getLastFreePos() const
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:78