38 #define DEBUG_COND2(obj) (obj.isSelected())
45 const std::vector<std::string>& lines,
47 double begPos,
double endPos,
49 double width,
double length,
double angle,
const std::string& name,
57 myEgressBlocked(false),
58 myReservationTime(-1),
60 myReservationMaxLength(0),
62 myLastStepOccupancy(0),
63 myUpdateEvent(nullptr) {
82 for (
int i = 0; i < capacity; ++i) {
92 double hlp_angle = fabs(((
double)atan2((s.
x() - f.
x()), (f.
y() - s.
y())) * (
double) 180.0 / (
double)
M_PI) - 180);
96 pos.
setz((f.
z() + s.
z()) / 2);
100 pos.
setz((f.
z() + s.
z()) / 2);
104 pos.
setz((f.
z() + s.
z()) / 2);
108 pos.
setz((f.
z() + s.
z()) / 2);
116 ((
double) atan2((s.
x() - f.
x()), (f.
y() - s.
y())) * (
double) 180.0 / (
double)
M_PI) +
myAngle);
126 double width,
double length,
double angle) {
151 if (relativeAngle < 0.) {
152 relativeAngle += 360.;
159 if (p2.
y() < (0. + POSITION_EPS)) {
218 if (lsd.vehicle == &forVehicle) {
219 return lsd.myPosition;
229 if (lsd.vehicle == &forVehicle) {
240 if (lsd.vehicle == &forVehicle) {
241 return (lsd.myRotation - 90.) * (double)
M_PI / (
double) 180.0;
250 if (lsd.vehicle == &forVehicle) {
251 if (lsd.myManoeuverAngle > 180.) {
252 return DEG2RAD(lsd.myManoeuverAngle - 360.);
254 return DEG2RAD(lsd.myManoeuverAngle);
264 if (lsd.vehicle == &forVehicle) {
265 if (lsd.mySideIsLHS) {
266 return abs(
int(lsd.myManoeuverAngle)) % 180;
268 return abs(abs(
int(lsd.myManoeuverAngle)) % 180 - 180) % 180;
300 if (lsd.vehicle == what) {
301 lsd.vehicle =
nullptr;
324 if (lsd.vehicle ==
nullptr
326 && lsd.vehicle->remainingStopDuration() <= 0
327 && !lsd.vehicle->isStoppedTriggered())) {
328 if (lsd.vehicle ==
nullptr) {
334 myLastFreePos = lsd.myEndPos - lsd.vehicle->getVehicleType().getLength() - POSITION_EPS;
340 lsd.myEndPos - lsd.vehicle->getVehicleType().getLength() - NUMERICAL_EPS);
351 #ifdef DEBUG_RESERVATIONS
353 std::cout <<
SIMTIME <<
" pa=" <<
getID() <<
" freePosRes veh=" << forVehicle.
getID() <<
" other lane\n";
364 #ifdef DEBUG_RESERVATIONS
366 std::cout <<
SIMTIME <<
" pa=" <<
getID() <<
" freePosRes veh=" << forVehicle.
getID() <<
" first reservation\n";
373 if (lsd.vehicle !=
nullptr) {
380 #ifdef DEBUG_RESERVATIONS
392 #ifdef DEBUG_RESERVATIONS
const double SUMO_const_laneWidth
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static bool gModelParkingManoeuver
whether parking simulation includes manoeuver time and any associated lane blocking
static bool gLefthand
Whether lefthand-drive is being simulated.
Representation of a lane in the micro simulation.
double getLength() const
Returns the lane's length.
const PositionVector & getShape() const
Returns this lane's shape.
double interpolateLanePosToGeometryPos(double lanePos) const
double getWidth() const
Returns the lane's width.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
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 myCapacity
Stop area capacity.
int getCapacity() const
Returns the area capacity.
void enter(SUMOVehicle *veh)
Called if a vehicle enters this stop.
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)
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.
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 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
A lane area vehicles can halt at.
const double myBegPos
The begin position this bus stop is located at.
double getBeginLanePosition() const
Returns the begin position of this stop.
const MSLane & myLane
The lane this bus stop is located at.
std::map< const SUMOVehicle *, std::pair< double, double >, ComparatorNumericalIdLess > myEndPositions
A map from objects (vehicles) to the areas they acquire after entering the stop.
const double myEndPos
The end position this bus stop is located at.
const MSLane & getLane() const
Returns the lane this stop is located at.
double myLastFreePos
The last free position at this stop (variable)
double getLastFreePos() const
double getMinGap() const
Get the free space in front of vehicles of this class.
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
A point in 2D or 3D with translation and scaling methods.
void setx(double x)
set position x
static const Position INVALID
used to indicate that a position is valid
double x() const
Returns the x-position.
void setz(double z)
set position z
double z() const
Returns the z-position.
void sety(double y)
set position y
double y() const
Returns the y-position.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
PositionVector getSubpart(double beginOffset, double endOffset) const
get subpart of a position vector
Position transformToVectorCoordinates(const Position &p, bool extend=false) const
return position p within the length-wise coordinate system defined by this position vector....
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
A wrapper for a Command function.
Representation of a single lot space.
double myRotation
The rotation.
Position myPosition
The position of the vehicle when parking in this space.
double myLength
The length.
int index
the running index
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.