Road network


Road Network is created by connecting the following Road Traffic Library markup elements:

          Road

          Intersection

          Stop Line

          Bus Stop

          Parking Lot

Road network is created even if you add just one single road to the graphical editor. It is accounted for by the fact that setting the following road properties for each road: lane width, right-hand or left-hand traffic direction, road background color, etc. will be time consuming in case of a complex road network including numerous roads. Instead of this AnyLogic offers to once set these parameters in the road network properties for all the roads of the current network. Now we will describe how to do it.

 To change road network parameters

  1. Click on any element of the road network (e.g. click on a road) in the graphical editor. The first click selects the element itself. 
  2. Click on this element again to select the entire road network the element belongs to.
  3. Now you may proceed to the Properties view and modify the network's parameters (e.g. modify Lane width). Note that the changes you make in the road network properties will affect all elements of the current network. By modifying the lane width, you change the width of all parking spaces, bus stops and lanes of all roads respectively. 

Properties

General

Name – The name of the road network.

Ignore – If selected, the network is excluded from the model.

Visible on upper level – If selected, the network is also visible on the upper level where this agent lives.

Lock – If selected, the network 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 network shapes are visible on animation at model runtime, or not. Using the control, choose yes or no.

Traffic – Specifies the side of the road bidirectional traffic should keep to. There are two options:

    Right-hand - traffic is required to keep to the right side of the road
    Left-hand - traffic is required to keep to the left side of the road

Lane width – Defines the width of network lanes in the length units that you choose in the drop down menu to the right of this field. The default width of the lane is 3.5 meters.

Appearance

Road color – Here you can define the color of the road.

Lanes delimiting line style – Here you can choose the style of the lane delimiting line from the drop-down menu (single, single broken, double, double broken).

Lanes delimiting line color – Here you can define the color of the lane delimiting line.

Directions delimiting line style – Here you can choose the style of the direction delimiting line from the drop-down menu (single, single broken, double, double broken).

Directions delimiting line color – Here you can define the color of the direction delimiting 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 element's name is displayed on the graphical diagram.

Show lane connectors of intersections – If selected, lane connectors of intersections will be shown in 2D animation at the model runtime. 

Animate signal states of stop lines and lanes connectors –  If selected, animation of stop lines and lane connectors of intersections is shown in 2D animation at model runtime. The color of each stop line and lane connector controlled by a traffic light will correspond to the color of the current traffic light signal (red, yellow, or green). 

A model can contain several independent (not interconnected) road networks. A car can move (sent by the CarMoveTo block) only to the destination point located within the same network. A car, however, can switch its network (e.g. to model part of the car movement on a higher abstraction level and not on the detailed physical level) with the help of the CarExit and CarEnter blocks.

AnyLogic does not support dynamic construction and adding new elements to the road network when the model is running. You can construct a network with the help of the corresponding Java functions only before running your model. Network will be created on running the model and you won't be able to add new elements to it anymore.

Functions

Road lane width

double getLaneWidth() - Returns lane width, measured in pixels.

double getLaneWidth(LengthUnits units) - Returns lane width, measured in the given length units.
Parameter: units - length unit constant

void setLaneWidth(double laneWidthInPixels) - Sets new lane width.

Parameter: laneWidthInPixels - Lane width, measured in pixels.

void setLaneWidth(double laneWidth, LengthUnits units) - Sets lane width in the given length units.
Parameters:
laneWidth - Lane width, measured in the given length units
units - length unit constant
Road color

void setRoadBackgroundColor(Color roadBackgroundColor) - Sets the road surface color.

Parameter: roadBackgroundColor - The new color, if null surface color is not drawn
void setRoadBackgroundColor(Paint roadBackgroundColor) - Sets the road surface color (or Texture).
Parameter: roadBackgroundColor - The new texture, if null road background is not drawn

Color getRoadBackgroundColor() - Returns the road surface color, or null if the road has no color or if it has texture (in this case getFillTexture() should be used instead).

Texture getRoadBackgroundTexture() - Returns the road surface texture, if the road has texture.

Road network elements

List<Road> getRoads() - Returns all roads belonging to this road network.

List<TrafficLight> getTrafficLights() - Returns all traffic lights belonging to this road network.

List<StopLine> getStopLines() - Returns all stop lines belonging to this road network.

List<ParkingLot> getParkingLots() - Returns all parking lots belonging to this road network.

List<BusStop> getBusStops() - Returns all bus stops belonging to this road network.

List<Intersection> getIntersections() - Returns all intersections and lane mergings belonging to this road network.

Driving direction
RoadDrivingDirection getDrivingDirection() -  Returns driving direction (ROAD_RIGHT_HAND or ROAD_LEFT_HAND).

setDrivingDirection(RoadDrivingDirection drivingDirection) - Sets right hand, or left hand driving direction.

Parameter: drivingDirection - Driving direction, ROAD_RIGHT_HAND or ROAD_LEFT_HAND.
Visibility

void setVisible(boolean v) - Sets the visibility of the road network.

Parameterv - visibility of the road network. If true, road network is visible, if false - not visible.

boolean isVisible() - Returns the visibility of the road network. If it returns true, the road network is visible, if false - not visible.

boolean isSignalStateAnimationVisible() - Returns true, if configured to animate signal states of stop lines and lane connectors.

public void setSignalStateAnimationVisible(boolean visible) - Sets debug animation visibility

Parameter: visible - to animate (true) or not (false) signal states of stop lines and lane connectors.
Direction delimiters

setDirectionsDelimitingLineColor(Color directionsDelimitingLineColor) - Sets the color of the directions delimiting line.

ParameterdirectionsDelimitingLineColor - The new color, if null the line is not drawn. 
setDirectionsDelimitingLineColor(Paint directionsDelimitingLineColor) - Sets the color (or texture) of the directions delimiting line color.
ParameterdirectionsDelimitingLineColor - The new texture, if null the line is not drawn.

Color getDirectionsDelimitingLineColor() -  Returns the color of the directions delimiting line, or null if the line has no color or has texture (in this case getFillTexture() should be used instead).

Texture getDirectionsDelimitingLineTexture() -  Returns the texture of the directions delimiting line color, if the line color has texture.

RoadLineStyle getDirectionsDelimitingLineStyle() - Returns style of the directions delimiting line, one of the following constants: 

RoadLineStyle.ROAD_LINE_SINGLE;
RoadLineStyle.ROAD_LINE_SINGLE_DASHED; 
RoadLineStyle.ROAD_LINE_DOUBLE;
RoadLineStyle.ROAD_LINE_DOUBLE_DASHED

setDirectionsDelimitingLineStyle(RoadLineStyle directionsDelimitingLineStyle) - Sets style of the directions delimiting line.

ParameterdirectionsDelimitingLineStyle - Line style, one of the following constants:
RoadLineStyle.ROAD_LINE_SINGLE
RoadLineStyle.ROAD_LINE_SINGLE_DASHED
RoadLineStyle.ROAD_LINE_DOUBLE
RoadLineStyle.ROAD_LINE_DOUBLE_DASHED
Lane delimiters
setLanesDelimitingLineColor(Color lanesDelimitingLineColor) - Sets the color of the road lanes delimiting line.
ParameterlanesDelimitingLineColor - The new color, if null the line is not drawn
setLanesDelimitingLineColor(Paint lanesDelimitingLineColor) - Sets the color (or Texture) of the road lanes delimiting line.
ParameterlanesDelimitingLineColor - The new texture, if null the line is not drawn

Color getLanesDelimitingLineColor() - Returns the color of the road lanes delimiting line, or null if the line has no color or has texture (in this case getFillTexture() should be used instead).

Texture getLanesDelimitingLineTexture() - Returns the texture of the road lanes delimiting line, if the line has texture.

RoadLineStyle getLanesDelimitingLineStyle() - Returns style of the road lanes delimiting line, one of the following constants: 

RoadLineStyle.ROAD_LINE_SINGLE;
RoadLineStyle.ROAD_LINE_SINGLE_DASHED;
RoadLineStyle.ROAD_LINE_DOUBLE;
RoadLineStyle.ROAD_LINE_DOUBLE_DASHED

setLanesDelimitingLineStyle(RoadLineStyle lanesDelimitingLineStyle) - Sets style of the road lanes delimiting line.

Parameter: lanesDelimitingLineStyle - Line style, one of the following constants:
RoadLineStyle.ROAD_LINE_SINGLE
RoadLineStyle.ROAD_LINE_SINGLE_DASHED
RoadLineStyle.ROAD_LINE_DOUBLE
RoadLineStyle.ROAD_LINE_DOUBLE_DASHED

Related topics

 Road Traffic Library tutorial

Road Traffic Library blocks

 Space markup for road traffic models