AnyLogic
Expand
Font size

Parking lot

Space markup element Parking Lot allows you to draw a parking lot at the side of a road.

Parking lot can be parallel (cars are parked in one line) or perpendicular. The type of parking lot is set in the Type option of the element.

You can currently draw a parking lot with a single row only. To draw a parking lot with two rows you should draw another road with a parking lot beside it.

You should use CarMoveTo block to model car movement to the parking lot. To model the presence of a car on a parking lot for a certain period of time, the CarMoveTo block should be followed by the Delay block from the Process Modeling Library. As parking lots may accept a number of cars at the same time, you should check the Maximum capacity option in the parameters of the Delay block.

Demo model: Parking Lot Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).

To draw a parking lot

  1. Drag the  Parking Lot element from the Space Markup section of the  Road Traffic Library palette to the agent diagram.
    A parking lot can be drawn only if the road has been previously drawn.
    When moving the mouse over the agent diagram, you will see that all other elements but the roads are temporarily hidden.
  2. Place the mouse cursor beside the road just where you want to place the parking lot. You will see that the parking lot connects to the road. Move your mouse to properly locate the element (the parking lot will adjust its shape to the road’s shape) and release the mouse button when done. The element will be put onto the specified place.
  3. Switch to the Properties view and set the Type of the parking lot: Parallel or Perpendicular.
  4. You can change the size of the parking lot by dragging a rectangle point located on the element’s end with the mouse. If you do it this way, the parking lot will automatically increase or decrease the number of parking spaces (you can also specify the quantity in the Number of parking spaces property).
  5. The length of a parking space can be modified in the Length of parking space property. Apart from the length, the width is defined in the Lane width property of the road network (and applies to all road network elements: roads, intersections, etc.).
  6. You can now specify this parking lot as a destination in the CarMoveTo block simulating car movement to the parking lot.

To adjust position of a parking lot

  1. Click on the parking lot you need to edit.
  2. Drag the parking lot to the desired position on the current road.
    You cannot drag the parking lot to another road.
    Alternatively, you can move it by modifying the Offset from road start parameter in the element’s properties, which will define the exact position of the element.

Properties

General

Name — The name of this parking lot. The name is used to identify and access the element from code and Road Traffic Library blocks' properties.

Ignore — If selected, the parking lot is excluded from the model.

Visible on upper agent — If selected, the parking lot is also visible on the upper agent where this agent lives.

Lock — If selected, the parking lot is locked. Locked shapes do not react to mouse clicks — it is impossible to select them in the graphical editor until you unlock them.

Visible — Here you specify whether the shape is visible on animation at model runtime, or not. Using the control, choose yes or no.

Type — Here you can define the parking lot layout scheme. There are two alternative options:

  • Parallel — the parking spaces will be put in line with the road.
  • Perpendicular — cars will be parked side to side, perpendicular to road.

Number of parking spaces — Defines the quantity of parking spaces (one slot per car). The default quantity is 5 spaces.

Length of parking space — Defines the length of the parking space in the length units that you choose from the drop-down list to the right of this field. The default length of the parking space is 6 meters.

Position and size

Offset from road start — The distance from the starting point of the road to the starting point of the parking lot, in pixels.

Advanced

Show in — Here you can choose whether you want the shape to be shown both in 2D and 3D animation, or in 2D only, or in 3D only.

Show name — If selected, the element’s name is displayed on the graphical diagram.

Functions

Parking spaces
Function Description
int nSpaces() Returns the total number of spaces in this parking lot.
int nFree() Returns the number of free parking spaces in this parking lot.
int randomFreeSpaceIndex() Returns the index of randomly chosen free parking space.
int[] getFreeSpaceIndexes() Returns an array of indexes of free parking spaces (0-based).
void setNSpaces(int parkingSpacesCount) Sets number of parking spaces in parking lot with parkingSpacesCount defining the number of parking spaces in the parking lot.

parkingSpacesCount — Number of parking spaces in the parking lot.
Cars
Function Description
int nCars() Returns the number of cars located on this parking lot.
Agent getCarOnSpace(int spaceIndex) Returns car located in the parking space with the given index, or null if this space is free.

spaceIndex — Index of parking space.
List<Agent> getCars() Returns ordered list of cars located on this parking lot. The first car in the list is the nearest one to the exit point from parking lot (is the first one to exit the parking lot).
Parking type
Function Description
ParkingLotType getParkingType() Returns the type of the parking lot. If it returns PARKING_LOT_PARALLEL, the parking lot is parallel, if the function returns PARKING_LOT_PERPENDICULAR the parking lot is perpendicular.
void setParkingType(ParkingLotType parkingType) Sets type of the parking lot: parallel or perpendicular, depending on the function’s argument value.

parkingType — Defines the type of the parking lot: pass PARKING_LOT_PARALLEL value to make it parallel, or PARKING_LOT_PERPENDICULAR to make it perpendicular.
Parking space dimensions
Function Description
double getParkingSpaceLength() Returns the length of parking space, measured in pixels.
double getParkingSpaceLength(LengthUnits units) Returns the length of parking space, measured in the given length units. For example, getParkingSpaceLength(METER) returns the length of parking space measured in meters.

units — length unit constant
double getParkingSpaceWidth() Returns the width of parking space, measured in pixels.
double getParkingSpaceWidth(LengthUnits units) Returns the width of parking space, measured in the given length units. For example, getParkingSpaceWidth(FOOT) returns the width of parking space measured in feet.

units — length unit constant
void setParkingSpaceLength(double parkingSpaceLengthInPixels) Sets the length of parking space measured in pixels.

parkingSpaceLengthInPixels — The length of parking space, measured in pixels.
void setParkingSpaceLength(double parkingSpaceLength, LengthUnits units) Sets the length of parking space measured in the given length units.

parkingSpaceLength — The length of parking space, measured in the given length units.
units — length unit constant
void setParkingSpaceWidth(double parkingSpaceWidthInPixels) Sets the width of parking space measured in pixels.

parkingSpaceWidthInPixels — The width of parking space, measured in pixels.
void setParkingSpaceWidth(double parkingSpaceWidth, LengthUnits units) Sets the width of parking space measured in the given length units.

parkingSpaceWidth — The width of parking space, measured in the given length units.
units — length unit constant
Visibility
Function Description
void setVisible(boolean v) Sets the visibility of the parking lot.

v — visibility of the parking lot. If true, parking lot is visible, if false — not visible.
boolean isVisible() Returns the visibility of the parking lot. If it returns true, the parking lot is visible, if false — not visible.
Location
Function Description
double getOffset() Returns distance (in pixels) from the road start to the start of the parking lot.
double getOffset(LengthUnits units) Returns distance (in the given units) from the road start to the start of the parking lot.

units — length unit constant
boolean isOnForwardSide() Returns true if the parking lot is adjacent to the forward lane, false if it is adjacent to the backward lane.
Road getRoad() Returns the road this parking lot is adjacent to.
RoadNetwork getRoadNetwork() Returns the road network this parking lot belongs to.
Level
Function Description
Level getLevel() Returns the level, where this parking lot is located.
Removal
Function Description
void remove() Removes the parking lot from the presentation. If the parking lot is not a part of presentation, the function does nothing. Note, that removal from the presentation does not necessarily mean removing from the model logic, since logical networks and routes may have been created before the removal and survive it.
How can we improve this article?