AnyLogic
Expand
Font size

Stop line

The space markup Stop Line element is used to control road traffic which can either stop before a stop line or pass through it, depending on the option set in the CarMoveTo block (which is used to direct traffic to a stop line).

The stop line element can add the following road signs to the spots where it is located: Speed limit, End of speed limit, and Yield. The road signs will affect traffic at this stop line. Description of road signs is available below in the Road signs section of the element’s properties.

Stop line may be used by the TrafficLight block to control conflicting flows of traffic.

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

To draw a stop line

  1. Drag the  Stop Line element from the Space Markup section of the  Road Traffic Library palette to the agent diagram containing a road.
    A stop line 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 over the road just where you want to place it and release the mouse button. You will see that the element is put onto the specified place. You may change its location by dragging it along the road.
  3. Set road signs if needed by selecting the corresponding option in the Road signs section of the element’s properties. Additionally you may use TrafficLight block at this stop line. The road signs as well as the traffic light will specify the traffic behavior at this stop line.
  4. You can now specify this stop line as destination in the CarMoveTo block properties.

To adjust a stop line’s position on a road

  1. Click the stop line you need to edit.
  2. Drag stop line to the desired position. 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.

Road signs can be added to a certain stop line in the road network to modify traffic behavior. You can combine road signs if needed, e.g. Speed limit Yield.

To add a road sign to a stop line

  1. Draw a stop line on the road if your model does not contain any stop lines yet or select the stop line if it is already located on the road.
  2. Select the road sign you need to add to this stop line from the Road Signs section of the element’s properties. If you add the speed limit sign, the field for maximum speed value and drop down list with speed units will appear to the right of it.
  3. Additionally you can select the yield sign if needed to combine it with the previously selected speed limit or end of speed limit signs.

Properties

General

Name — The name of this stop line. The name is used to identify and access the position from code and flowchart blocks properties.

Ignore — If selected, the stop line is excluded from the model.

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

Lock — If selected, the stop line 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.

Car type - Here you can specify a custom car type.

Road signs

Speed limit — If selected, this stop line starts the area with speed limit. The field for maximum speed value and drop down list with speed units will appear to the right of this option if you select it.

End of speed limit — If selected, this stop line ends the area with speed limit.

Yield — If selected, sets a yield sign to the current stop line, making the traffic stop if necessary and let a driver on another approach proceed.

Actions

On car passed — Here you can specify code that will be executed for each car passing through this stop line. You can refer to a car using the local variable car. The lane the car is located on can be referred to as laneIndex. Lanes are numbered from outmost (that has index 0) to inmost.

Position and size

Offset from road start — The distance from the start point of the road to the stop line.

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 stop line’s name is displayed on the graphical diagram.

Functions

Signs
Function Description
addSpeedLimitSign(double speedLimit, SpeedUnits units) Adds “speed limit” sign to this stop line. For example, addSpeedLimitSign(90, KPH) adds the “90 kilometers per hour speed limit” sign.

speedLimit — speed limit value, measured in the given speed units
units — speed unit constant
double getSpeedLimit(SpeedUnits units) If this stop line has the “speed limit” sign, the function returns the actual speed limit value, measured in the given speed units. For example, getSpeedLimit(KPH) returns the speed limit value in kilometers per hour.

units — speed unit constant
addEndOfSpeedLimitSign() Adds “end of speed limit” sign to this stop line.
boolean isSpeedLimitSign() Returns true if this stop line has “speed limit” sign, false otherwise.
boolean isEndOfSpeedLimitSign() Returns true if this stop line has “end of speed limit” sign, false otherwise.
addYieldSign() Adds “yield” sign to this stop line.
boolean isYieldSign() Returns true if this stop line has “yield” sign, false otherwise.
Traffic light
Function Description
TrafficLightSignal getSignal() Returns current signal of the traffic light on road (SIGNAL_REDSIGNAL_YELLOWSIGNAL_GREEN), or SIGNAL_NONE if no signal is set.
setSignal(TrafficLightSignal signal) Changes the current signal of the traffic light to newSignal. Applies if this position is not controlled by a traffic light.

signal — New signal that is set to the position on road.
Valid values:
SIGNAL_RED
SIGNAL_YELLOW
SIGNAL_GREEN
SIGNAL_NONE
Speed
Function Description
double averageSpeed() Returns the actual average speed (in meters per second) in the position defined by the stop line.
double averageSpeed(SpeedUnits units) Returns the actual average speed (in the given speed units) in the position defined by the stop line.

units — Speed units constant
Position
Function Description
int getLaneIndexFrom() Returns the index of the starting lane covered by the stop line. Lane with index 0 is the lane at the road side.
int getLaneIndexTo() Returns the index of the ending lane covered by the stop line. Lane with index 0 is the lane at the road side.
setLaneIndexFrom(int laneIndexFrom) Sets the starting lane covered by stop line.

laneIndexFrom — Lane index. Lane with index 0 is the lane at the road side.
setLaneIndexTo(int laneIndexTo) Sets the ending lane covered by stop line.

laneIndexTo — Lane index. Lane with index 0 is the lane at the road side.
Visibility
Function Description
void setVisible(boolean v) Sets the visibility of the stop line.

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

units — length unit constant
boolean isOnForwardSide() Returns true if the stop-line is located on the forward lane, false if it is located on the backward lane.
Road getRoad() Returns road on which the stop-line is located.
RoadNetwork getRoadNetwork() Returns road network the stop-line belongs to.
Level
Function Description
Level getLevel() Returns the level where this stopline is located.
Removal
Function Description
void remove() Removes the stopline from the presentation. If the stopline is not a part of presentation, the function does nothing.
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?