Eclipse SUMO - Simulation of Urban MObility
MSParkingArea.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2015-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 /****************************************************************************/
18 // A area where vehicles can park next to the road
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <vector>
24 #include <algorithm>
25 #include <map>
26 #include <string>
28 #include <utils/common/Named.h>
29 #include "MSStoppingPlace.h"
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class MSLane;
36 class SUMOVehicle;
37 class MSTransportable;
38 class Position;
39 class Command;
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
58 public:
59 
73  MSParkingArea(const std::string& id,
74  const std::vector<std::string>& lines, MSLane& lane,
75  double begPos, double endPos, int capacity,
76  double width, double length, double angle, const std::string& name,
77  bool onRoad);
78 
80  virtual ~MSParkingArea();
81 
82 
87  int getCapacity() const;
88 
90  bool parkOnRoad() const {
91  return myOnRoad;
92  }
93 
94 
101  int getOccupancy() const;
102 
107  int getOccupancyIncludingBlocked() const;
108 
113  int getLastStepOccupancy() const {
114  return myLastStepOccupancy;
115  }
116 
117 
127  void enter(SUMOVehicle* veh);
128 
129 
139  void leaveFrom(SUMOVehicle* what);
140 
141 
149  SUMOTime updateOccupancy(SUMOTime currentTime);
150 
151 
156  double getLastFreePos(const SUMOVehicle& forVehicle) const;
157 
158 
164  double getLastFreePosWithReservation(SUMOTime t, const SUMOVehicle& forVehicle);
165 
166 
171  Position getVehiclePosition(const SUMOVehicle& forVehicle) const;
172 
177  double getInsertionPosition(const SUMOVehicle& forVehicle) const;
178 
179 
184  double getVehicleAngle(const SUMOVehicle& forVehicle) const;
185 
191  int getLastFreeLotAngle() const;
192 
198  double getLastFreeLotGUIAngle() const;
199 
204  int getManoeuverAngle(const SUMOVehicle& forVehicle) const;
205 
210  double getGUIAngle(const SUMOVehicle& forVehicle) const;
211 
222  virtual void addLotEntry(double x, double y, double z,
223  double width, double length, double angle);
224 
225 
230  double getWidth() const;
231 
232 
237  double getLength() const;
238 
239 
244  double getAngle() const;
245 
246 
248  void notifyEgressBlocked();
249 
250  void setNumAlternatives(int alternatives) {
251  myNumAlternatives = MAX2(myNumAlternatives, alternatives);
252  }
253 
254  int getNumAlternatives() const {
255  return myNumAlternatives;
256  }
257 
258 protected:
259 
265  int index;
271  double myRotation;
273  double myWidth;
275  double myLength;
277  double myEndPos;
282  };
283 
284 
291  void computeLastFreePos();
292 
295 
298 
300  bool myOnRoad;
301 
303  double myWidth;
304 
306  double myLength;
307 
309  double myAngle;
310 
311 
313  std::vector<LotSpaceDefinition> mySpaceOccupancies;
314 
317 
320 
325 
328 
331 
334 
335 private:
336 
339 
342 
343 };
long long int SUMOTime
Definition: SUMOTime.h:31
T MAX2(T a, T b)
Definition: StdDefs.h:79
Base (microsim) event class.
Definition: Command.h:49
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
A lane area vehicles can halt at.
Definition: MSParkingArea.h:57
void notifyEgressBlocked()
update state so that vehicles wishing to enter cooperate with exiting vehicles
double getAngle() const
Returns the lot rectangle angle.
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
int getNumAlternatives() const
int myCapacity
Stop area capacity.
int getCapacity() const
Returns the area capacity.
void enter(SUMOVehicle *veh)
Called if a vehicle enters this stop.
MSParkingArea & operator=(const MSParkingArea &)
Invalidated assignment operator.
int myLastStepOccupancy
Changes to the occupancy in the current time step.
bool myOnRoad
Whether vehicles stay on the road.
int myLastFreeLot
Last free lot number (-1 no free lot)
void setNumAlternatives(int alternatives)
PositionVector myShape
The roadside shape of this parkingArea.
double getLength() const
Returns the lot rectangle length.
SUMOTime myReservationTime
track parking reservations from the lane for the current time step
double getWidth() const
Returns the lot rectangle width.
virtual ~MSParkingArea()
Destructor.
SUMOTime updateOccupancy(SUMOTime currentTime)
Called at the end of the time step.
int getLastFreeLotAngle() const
Return the angle of myLastFreeLot - the next parking lot only expected to be called after we have est...
double myAngle
The default angle of each parking space.
bool parkOnRoad() const
whether vehicles park on the road
Definition: MSParkingArea.h:90
double myReservationMaxLength
int myNumAlternatives
the number of alternative parkingAreas that are assigned to parkingAreaRerouter
double myWidth
The default width of each parking space.
double myLength
The default length of each parking space.
void computeLastFreePos()
Computes the last free position on this stop.
int getOccupancyIncludingBlocked() const
Returns the area occupancy.
double getLastFreeLotGUIAngle() const
Return the GUI angle of myLastFreeLot - the angle the GUI uses to rotate into the next parking lot as...
int getManoeuverAngle(const SUMOVehicle &forVehicle) const
Return the manoeuver angle of the lot where the vehicle is parked.
int getLastStepOccupancy() const
Returns the area occupancy at the end of the last simulation step.
int getOccupancy() const
Returns the area occupancy.
virtual void addLotEntry(double x, double y, double z, double width, double length, double angle)
Add a lot entry to parking area.
double getVehicleAngle(const SUMOVehicle &forVehicle) const
Returns the angle of parked vehicle.
double getLastFreePosWithReservation(SUMOTime t, const SUMOVehicle &forVehicle)
Returns the last free position on this stop including reservatiosn from the current lane and time ste...
Command * myUpdateEvent
Event for updating the occupancy.
std::vector< LotSpaceDefinition > mySpaceOccupancies
All the spaces in this parking area.
double getInsertionPosition(const SUMOVehicle &forVehicle) const
Returns the insertion position of a parked vehicle.
MSParkingArea(const std::string &id, const std::vector< std::string > &lines, MSLane &lane, double begPos, double endPos, int capacity, double width, double length, double angle, const std::string &name, bool onRoad)
Constructor.
Position getVehiclePosition(const SUMOVehicle &forVehicle) const
Returns the position of parked vehicle.
double getGUIAngle(const SUMOVehicle &forVehicle) const
Return the GUI angle of the lot where the vehicle is parked.
bool myEgressBlocked
whether a vehicle wants to exit but is blocked
MSParkingArea(const MSParkingArea &)
Invalidated copy constructor.
A lane area vehicles can halt at.
double getLastFreePos() const
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
A list of positions.
Representation of a vehicle.
Definition: SUMOVehicle.h:58
Representation of a single lot space.
Position myPosition
The position of the vehicle when parking in this space.
bool mySideIsLHS
Whether the lot is on the LHS of the lane relative to the lane direction.
SUMOVehicle * vehicle
The last parked vehicle or 0.
double myEndPos
The position along the lane that the vehicle needs to reach for entering this lot.
double myManoeuverAngle
The angle between lane and lot through which a vehicle must manoeuver to enter the lot.