AnyLogic
Expand
Font size
All Implemented Interfaces:
AggregatableAnimationElement, HasLevel, SVGElement, UsdElement, Serializable

public class Road
extends AbstractRoadConnectableElement
Class representing a road segment with several forward and backward lanes. Road segment should have at least 1 forward or backward lane. Road segment can have a median strip of the specified width that separates forward and backward directions. Road segment has incoming and outgoing connection points at ends. Each lane has 1 incoming connection point, 1 outgoing connection point and a guideline connecting them. Lanes of each direction are numbered starting from 0 from outmost to inmost, so the lane closest to the central line has the greatest index.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Field Summary

Modifier and TypeFieldDescription
static final float[]DOUBLE_DASH 
static final float[]SINGLE_DASH 

Fields inherited from interface com.anylogic.engine.presentation.UsdElement

ID_NOT_SET

Constructor Summary

ConstructorDescription
Road()
Creates a new road segments.
Road(Agent owner, ShapeDrawMode drawMode, boolean isPublic, int forwardLanesCount, int backwardLanesCount, double medianStripWidthInMeters, Paint medianStripColor, MarkupSegment... axisSegments)
Deprecated.
deprecated in version 8.4, will be removed in the future releases

Method Summary

Modifier and TypeMethodDescription
voidaddSegment(MarkupSegment segment)
Adds segment to this markup element
doubleaverageSpeed(boolean isOnForwardSide, double offset)
Returns the average speed (in meters per second) on the given road direction near the specified offset
doubleaverageSpeed(boolean isOnForwardSide, double offset, SpeedUnits units)
Returns the average speed (in the given units) on the given road direction near the specified offset
List<MarkupSegment>getAxisMarkupSegments()
Returns list of markup segments representing road axis (the middle of median strip).
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
RoadConnectionPointgetBackwardIncomingConnectionPoint(int backwardLaneIndex)
Returns incoming connection point located at the beginning of backward lane with the specified index.
List<MarkupSegment>getBackwardLaneMarkupSegments(int backwardLaneIndex)
Returns list of markup segments representing guideline of backward lane with the specified lane index.
intgetBackwardLanesCount()
Returns count of backward lanes.
RoadConnectionPointgetBackwardOutgoingConnectionPoint(int backwardLaneIndex)
Returns outgoing connection point located at the end of backward lane with the specified index.
List<RoadConnectionPoint>getBeginConnectionPoints()
Returns list of all connection points located at the beginning of road segment.
BoundingRectanglegetBoundingRectangle() 
List<BusStop>getBusStops()
Returns all bus stops contained in this road
List<Agent>getCars(boolean isOnForwardSide)
Returns ordered list of cars located on the given direction.
List<RoadConnectionPoint>getConnectionPoints()
Returns a list of connection points of the road element.
List<RoadConnectionPoint>getEndConnectionPoints()
Returns list of all connection points located at end of road segment.
RoadConnectionPointgetForwardIncomingConnectionPoint(int forwardLaneIndex)
Returns incoming connection point located at the beginning of forward lane with the specified index.
List<MarkupSegment>getForwardLaneMarkupSegments(int forwardLaneIndex)
Returns list of markup segments representing guideline of forward lane with the specified lane index.
intgetForwardLanesCount()
Returns count of forward lanes.
RoadConnectionPointgetForwardOutgoingConnectionPoint(int forwardLaneIndex)
Returns outgoing connection point located at the end of forward lane with the specified index.
List<RoadConnectionPoint>getIncomingConnectionPoints(PathEndType type)
Returns list of incoming connection points located at the beginning of road segment.
intgetLaneIndex(RoadConnectionPoint connectionPoint)
Returns zero-based index of lane to which the specified connection point belongs to.
ColorgetMedianStripColor()
Returns the color of the median strip, or null if median strip has no fill or has texture (in this case getMedianStripTexture() should be used instead)
TexturegetMedianStripTexture()
Returns the texture of the median strip color, if the median strip has texture
doublegetMedianStripWidth()
Returns median strip width, in pixels.
doublegetMedianStripWidth(LengthUnits units)
Returns median strip width measured in the given units.
List<RoadConnectionPoint>getOutgoingConnectionPoints(PathEndType type)
Returns list of outgoing connection points located at the beginning of road segment.
List<ParkingLot>getParkingLots()
Returns all parking lots contained in this road
MarkupSegmentgetSegment(int index)
Returns the segment by its index
intgetSegmentCount()
Returns the number of segments
List<StopLine>getStopLines()
Returns all stop lines contained in this road
doublegetWidth()
Returns the total width of road segment which consists of width of all forward lanes, width of all backward lanes and width of median strip.
doublegetWidth(LengthUnits units)
Returns the total width of road segment which consists of width of all forward lanes, width of all backward lanes and width of median strip.
booleanisConnectionPointOnForwardDirection(RoadConnectionPoint connectionPoint)
Checks if the specified road connection point is located on forward direction of the road segment.
Iterator<MarkupSegment>iterator()
Creates and returns read-only iterator over segments
intnCars(boolean isOnForwardSide)
Returns number of cars located on the given direction.
intnCarsOnLane(boolean isOnForwardSide, int laneIndex)
Returns number of cars located on located in the specified lane.
voidpostInitialize()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
voidsetBackwardLanesCount(int backwardLanesCount)
Sets number of backward lanes
voidsetDataSource(RoadDataSource dataSource) 
voidsetForwardLanesCount(int forwardLanesCount)
Sets number of forward lanes
voidsetMedianStripColor(Color color)
Sets the color of the median strip color.
voidsetMedianStripColor(Paint color)
Sets the color (or Texture) of the median strip color.
voidsetMedianStripWidth(double medianStripWidthInPixels)
Deprecated.
this method is deprecated and may be removed in the next release.
voidsetMedianStripWidth(double medianStripWidth, LengthUnits units)
Sets median strip width measured in the given units

Methods inherited from class com.anylogic.engine.markup.AbstractRoadMarkup

contains, getLevel, getRoadNetwork, setDebugInfoVisible, setRoadNetwork

Methods inherited from class com.anylogic.engine.markup.MarkupShape

error, getDrawMode, getFullName, getOutsideLevelZ, getPresentable, getSpace, initialize, isClickHandled, isPublic, onClick, remove, setDrawMode, setOwner

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

DOUBLE_DASH

public static final float[] DOUBLE_DASH

SINGLE_DASH

public static final float[] SINGLE_DASH

Constructor Details

Road

public Road()
Creates a new road segments.

Road

@Deprecated
public Road(Agent owner,
 ShapeDrawMode drawMode,
 boolean isPublic,
 int forwardLanesCount,
 int backwardLanesCount,
 double medianStripWidthInMeters,
 Paint medianStripColor,
 MarkupSegment... axisSegments)
Deprecated.
deprecated in version 8.4, will be removed in the future releases
Creates a new road segments along the specified path with specified count of forward and backward lanes and specified width of median strip between driving directions. Axis path specifies the middle line of delimiter. If the road network uses right-hand driving, all forward lanes will be created to the right of axis path and all backward lanes will be created to the left of the axis path. Vice versa for left-hand driving.
Parameters:
owner - Agent to which the created road intersection belongs to.
drawMode - Where to draw this space markup shape: 2D, 3D or 2D+3D.
ispublic - If true, the markup shape is visible on container's presentation.
forwardLanesCount - Count of forward lanes.
backwardLanesCount - Count of backward lanes.
medianStripWidthInMeters - Width of median strip in meters.
axisSegments - Path specifying the line delimiting driving directions.

Method Details

setDataSource

@AnyLogicInternalAPI
public void setDataSource(RoadDataSource dataSource)

averageSpeed

public double averageSpeed(boolean isOnForwardSide,
 double offset,
 SpeedUnits units)
Returns the average speed (in the given units) on the given road direction near the specified offset
Parameters:
isOnForwardSide - true if direction is along road axis line, false otherwise
offset - offset from the beginning of road axis line
units - speed units
Returns:
average speed value

averageSpeed

public double averageSpeed(boolean isOnForwardSide,
 double offset)
Returns the average speed (in meters per second) on the given road direction near the specified offset
Parameters:
isOnForwardSide - true if direction is along road axis line, false otherwise
offset - offset from the beginning of road axis line
Returns:
average speed value, meters per second

nCars

public int nCars(boolean isOnForwardSide)
Returns number of cars located on the given direction.
Parameters:
isOnForwardSide - true if direction is along road axis line, false otherwise
Returns:
number of cars

nCarsOnLane

public int nCarsOnLane(boolean isOnForwardSide,
 int laneIndex)
Returns number of cars located on located in the specified lane.
Parameters:
isOnForwardSide - true if direction is along road axis line, false otherwise
laneIndex - zero-based index of lane. Lanes are numbered from outmost (that has index 0) to inmost
Returns:
number of cars located in the specified lane

getCars

public List<Agent> getCars(boolean isOnForwardSide)
Returns ordered list of cars located on the given direction. The first car in the list is the nearest one to the exit point from road (seems to be the first one to exit the road, if there is no acceleration)
Parameters:
isOnForwardSide - true if direction is along road axis line, false otherwise
Returns:
ordered list of cars

setForwardLanesCount

public void setForwardLanesCount(int forwardLanesCount)
Sets number of forward lanes
Parameters:
forwardLanesCount -

setBackwardLanesCount

public void setBackwardLanesCount(int backwardLanesCount)
Sets number of backward lanes
Parameters:
backwardLanesCount -

setMedianStripWidth

@Deprecated
public void setMedianStripWidth(double medianStripWidthInPixels)
Deprecated.
this method is deprecated and may be removed in the next release. Please use method with units argument instead.
Sets median strip width
Parameters:
medianStripWidthInPixels - median strip width measured in pixels

setMedianStripWidth

public void setMedianStripWidth(double medianStripWidth,
 LengthUnits units)
Sets median strip width measured in the given units
Parameters:
medianStripWidth - median strip width
units - length units

addSegment

public void addSegment(MarkupSegment segment)
Adds segment to this markup element
Parameters:
segment - the segment, should be initialized if was created using no-argument constructor

getSegmentCount

public int getSegmentCount()
Returns the number of segments
Returns:
the number of segments

getSegment

public MarkupSegment getSegment(int index)
Returns the segment by its index
Parameters:
index - the segment index, [0 .. getSegmentCount() - 1]
Returns:
the segment

iterator

public Iterator<MarkupSegment> iterator()
Creates and returns read-only iterator over segments

postInitialize

@AnyLogicInternalAPI
public void postInitialize()
Description copied from interface: AggregatableAnimationElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
postInitialize in interface AggregatableAnimationElement

getWidth

public double getWidth()
Returns the total width of road segment which consists of width of all forward lanes, width of all backward lanes and width of median strip.
Returns:
Total width of road segment in pixels.

getWidth

public double getWidth(LengthUnits units)
Returns the total width of road segment which consists of width of all forward lanes, width of all backward lanes and width of median strip.
Returns:
Total width of road segment, measured in the given units.

getIncomingConnectionPoints

@AnyLogicInternalLibraryAPI
public List<RoadConnectionPoint> getIncomingConnectionPoints(PathEndType type)
Returns list of incoming connection points located at the beginning of road segment. Connection points are ordered the same way as lanes: from outmost to inmost.
Parameters:
type - one of RoadEnd.Type.BEGIN or RoadEnd.Type.END
Returns:
List of incoming connection points located at the beginning of road segment.

getOutgoingConnectionPoints

@AnyLogicInternalLibraryAPI
public List<RoadConnectionPoint> getOutgoingConnectionPoints(PathEndType type)
Returns list of outgoing connection points located at the beginning of road segment. Connection points are ordered the same way as lanes: from outmost to inmost.
Parameters:
type - one of RoadEnd.Type.BEGIN or RoadEnd.Type.END
Returns:
List of outgoing connection points located at the beginning of road segment.

getBeginConnectionPoints

@AnyLogicInternalLibraryAPI
public List<RoadConnectionPoint> getBeginConnectionPoints()
Returns list of all connection points located at the beginning of road segment. Connection points are ordered in the following way: - First, outgoing connection points from outmost to inmost, - Second, incoming connection points from inmost to outmost.
Returns:
List of all connection points located at the beginning of road segment.

getEndConnectionPoints

@AnyLogicInternalLibraryAPI
public List<RoadConnectionPoint> getEndConnectionPoints()
Returns list of all connection points located at end of road segment. Connection points are ordered in the following way: - First, outgoing connection points from outmost to inmost, - Second, incoming connection points from inmost to outmost.
Returns:
List of all connection points located at end of road segment.

getLaneIndex

@AnyLogicInternalLibraryAPI
public int getLaneIndex(RoadConnectionPoint connectionPoint)
Returns zero-based index of lane to which the specified connection point belongs to.
Parameters:
connectionPoint - Specified connection point.
Returns:
zero-based index of lane to which the specified connection point belongs or -1 if specified connection point does not belong to the road segment.

getForwardIncomingConnectionPoint

@AnyLogicInternalLibraryAPI
public RoadConnectionPoint getForwardIncomingConnectionPoint(int forwardLaneIndex)
Returns incoming connection point located at the beginning of forward lane with the specified index.
Parameters:
forwardLaneIndex - Specified index of forward lane.
Returns:
Incoming connection point located at the beginning of forward lane with the specified index or null if no lane with the specified index exists.

isConnectionPointOnForwardDirection

@AnyLogicInternalLibraryAPI
public boolean isConnectionPointOnForwardDirection(RoadConnectionPoint connectionPoint)
Checks if the specified road connection point is located on forward direction of the road segment.
Parameters:
connectionPoint - Specified connection point.
Returns:
True if the specified road connection point is located on forward direction, false otherwise.

getForwardOutgoingConnectionPoint

@AnyLogicInternalLibraryAPI
public RoadConnectionPoint getForwardOutgoingConnectionPoint(int forwardLaneIndex)
Returns outgoing connection point located at the end of forward lane with the specified index.
Parameters:
forwardLaneIndex - Specified index of forward lane.
Returns:
Outgoing connection point located at the end of forward lane with the specified index or null if no lane with the specified index exists.

getBackwardIncomingConnectionPoint

@AnyLogicInternalLibraryAPI
public RoadConnectionPoint getBackwardIncomingConnectionPoint(int backwardLaneIndex)
Returns incoming connection point located at the beginning of backward lane with the specified index.
Parameters:
backwardLaneIndex - Specified index of backward lane.
Returns:
Incoming connection point located at the beginning of backward lane with the specified index or null if no lane with the specified index exists.

setMedianStripColor

public void setMedianStripColor(Color color)
Sets the color of the median strip color.
Parameters:
color - the new color, null = do not draw the median strip color

setMedianStripColor

public void setMedianStripColor(Paint color)
Sets the color (or Texture) of the median strip color.
Parameters:
color - the new color, null = do not draw the median strip color

getMedianStripColor

public Color getMedianStripColor()
Returns the color of the median strip, or null if median strip has no fill or has texture (in this case getMedianStripTexture() should be used instead)
Returns:
the color of the median strip color

getMedianStripTexture

public Texture getMedianStripTexture()
Returns the texture of the median strip color, if the median strip has texture
Returns:
the texture of the median strip color

getBackwardOutgoingConnectionPoint

@AnyLogicInternalLibraryAPI
public RoadConnectionPoint getBackwardOutgoingConnectionPoint(int backwardLaneIndex)
Returns outgoing connection point located at the end of backward lane with the specified index.
Parameters:
backwardLaneIndex - Specified index of backward lane.
Returns:
Outgoing connection point located at the end of backward lane with the specified index or null if no lane with the specified index exists.

getForwardLanesCount

public int getForwardLanesCount()
Returns count of forward lanes.
Returns:
Count of forward lanes.

getBackwardLanesCount

public int getBackwardLanesCount()
Returns count of backward lanes.
Returns:
Count of backward lanes.

getForwardLaneMarkupSegments

@AnyLogicInternalLibraryAPI
public List<MarkupSegment> getForwardLaneMarkupSegments(int forwardLaneIndex)
Returns list of markup segments representing guideline of forward lane with the specified lane index.
Parameters:
forwardLaneIndex - Specified index of forward lane.
Returns:
List of markup segments representing guideline of forward lane with the specified lane index, empty list if no forward lanes exist.

getBackwardLaneMarkupSegments

@AnyLogicInternalLibraryAPI
public List<MarkupSegment> getBackwardLaneMarkupSegments(int backwardLaneIndex)
Returns list of markup segments representing guideline of backward lane with the specified lane index.
Parameters:
backwardLaneIndex - Specified index of backward lane.
Returns:
List of markup segments representing guideline of backward lane with the specified lane index, empty list if no backward lanes exist.

getAxisMarkupSegments

@AnyLogicInternalLibraryAPI
public List<MarkupSegment> getAxisMarkupSegments()
Returns list of markup segments representing road axis (the middle of median strip).
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.

getMedianStripWidth

public double getMedianStripWidth()
Returns median strip width, in pixels.
Returns:
median strip width, in pixels.

getMedianStripWidth

public double getMedianStripWidth(LengthUnits units)
Returns median strip width measured in the given units.
Parameters:
units - length units
Returns:
median strip width, in the given units.

getConnectionPoints

@AnyLogicInternalLibraryAPI
public List<RoadConnectionPoint> getConnectionPoints()
Description copied from class: AbstractRoadConnectableElement
Returns a list of connection points of the road element. The elements of list can be sorted in any order, but this order is the same during lifetime of the element.
Specified by:
getConnectionPoints in class AbstractRoadConnectableElement
Returns:
List of connection points of the road element.

getBoundingRectangle

@AnyLogicInternalAPI
public BoundingRectangle getBoundingRectangle()

getStopLines

public List<StopLine> getStopLines()
Returns all stop lines contained in this road
Returns:
unmodifiable list of stop lines, ordered in 'forward' direction

getParkingLots

public List<ParkingLot> getParkingLots()
Returns all parking lots contained in this road
Returns:
unmodifiable list of parking lots, ordered in 'forward' direction

getBusStops

public List<BusStop> getBusStops()
Returns all bus stops contained in this road
Returns:
unmodifiable list of bus stops, ordered in 'forward' direction