AnyLogic
Expand
Font size
All Implemented Interfaces:
AggregatableAnimationElement, HasLevel, SVGElement, java.io.Serializable

public class Intersection
extends AbstractRoadConnectableElement
Class representing area of intersection of several (2 or more) road segments. Contains 1 or more incoming road connection points, 1 or more outgoing connection points and guidelines connecting pairs of incoming and outgoing connection points. Each pair of incoming and outgoing connection points cannot have more than 1 guideline. Provides functionality for automatic generation of intersection area border.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Constructor Summary

Constructors 
Intersection()
Creates a new instance of road intersection.
Intersection​(Agent owner, ShapeDrawMode drawMode, boolean isPublic, boolean showLaneConnectors, PathEnd<Road>[] roadEnds, RoadLanesConnector... lanes)
Deprecated.
deprecated in version 8.4, will be removed in the future releases
Intersection​(Agent owner, ShapeDrawMode drawMode, boolean isPublic, boolean showLaneConnectors, Road road1, PathEndType type1, Road road2, PathEndType type2, RoadLanesConnector... connectors)
Deprecated.
deprecated in version 8.4, will be removed in the future releases
Constructor Description

Method Summary

All Methods Static Methods Instance Methods Concrete Methods 
void addConnection​(Road startRoad, int startRoadLane, Road endRoad, int endRoadLane)
Adds roads connection
void addConnection​(Road startRoad, int startRoadLane, Road endRoad, int endRoadLane, MarkupSegment... guideLine)
Adds roads connection
void addConnection​(Road startRoad, int startRoadLane, Road endRoad, int endRoadLane, java.util.List<MarkupSegment> guideLine)
Adds roads connection
void addRoad​(Road road, PathEndType type)
Adds road to this intersection
int countCars​(Road from, Road to)
Returns the total number of cars that moved through the intersection from one specified road to another specified road.
static java.util.List<MarkupSegment> generateDefaultGuideline​(RoadConnectionPoint inRoadConnectionPoint, RoadConnectionPoint outRoadConnectionPoint)  
java.util.List<Agent> getCars()
Returns unordered list of cars located on this intersection / connection
RoadConnectionPoint getConnectionPoint​(boolean isIncoming, Road connectedWithRoadSegment, int roadSegmentLaneIndex)
Returns connection point that is directed at the specified direction, connected with the specified road segment and corresponds to the specified lane index in this road segment.
RoadConnectionPoint getConnectionPoint​(RoadConnectionPoint connectedPoint)
Returns connection point that is connected to the specified point, or null if such connection point does not exist.
java.util.List<RoadConnectionPoint> getConnectionPoints()
Returns a list of connection points of the road element.
java.util.Map<Pair<RoadConnectionPoint,​RoadConnectionPoint>,​java.util.List<MarkupSegment>> getGuidelines()
Returns map from pairs (incoming and outgoing) of road connection points to guidelines connecting the specified incoming and outgoing connection points.
java.util.List<RoadConnectionPoint> getIncomingConnectionPoints()
Returns list of all incoming connection points of the element.
java.util.List<RoadLanesConnector> getLanesConnectors()
Returns the list of lane connectors inside this intersection
java.util.List<RoadConnectionPoint> getOutgoingConnectionPoints()
Returns list of all outgoing connection points of the element.
int nCars()
Returns number of cars located on this intersection / connection
void postInitialize()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
void resetStats()
Resets counters of cars for all lane connectors on this intersection
void setDataSource​(RoadBasicDataSource dataSource)  
void setGuideline​(RoadConnectionPoint inRoadConnectionPoint, RoadConnectionPoint outRoadConnectionPoint)
Sets a guideline between the specified connection points.
void setGuideline​(RoadConnectionPoint inRoadConnectionPoint, RoadConnectionPoint outRoadConnectionPoint, java.util.List<MarkupSegment> guideline)  
void setRoads​(Road road1, PathEndType type1, Road road2, PathEndType type2)
Adds 2 roads to this markup element.
void showLaneConnectors​(boolean showLaneConnectors)
Shows or hides lane connectors
int traffic​(Road from, Road to)
Returns the traffic of car flow from one specified road to another specified road, measured in cars per hour.
void updateDynamicProperties()
Updates dynamic properties of this shape only (without structural contents, if any) in a given context.
Method should be overridden for shapes with dynamic properties.
Modifier and Type Method Description

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 com.anylogic.engine.markup.AbstractMarkup

discardOwner, executeUserAction, findSVGElement, getName, getSVGId, initializeInternal, isVisible, onAggregatorInitialized, onAggregatorVisibilityChanged, removeSVGFromOwner, resetSVGState, setVisible, updateDynamicPropertiesStructural, updateSVGProperties

Methods inherited from class java.lang.Object

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

Constructor Detail

Intersection

public Intersection()
Creates a new instance of road intersection. Should not be directly called by user.

Intersection

@Deprecated
public Intersection​(Agent owner,
                    ShapeDrawMode drawMode,
                    boolean isPublic,
                    boolean showLaneConnectors,
                    PathEnd<Road>[] roadEnds,
                    RoadLanesConnector... lanes)
Deprecated.
deprecated in version 8.4, will be removed in the future releases
Creates a new instance of road intersection. Should not be directly called by user.
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.
showLaneConnectors - display or not lane connector lines on 2D animation
roadEnds - array of road ends coming to this intersection
lanes - connectors between road ends

Intersection

@Deprecated
public Intersection​(Agent owner,
                    ShapeDrawMode drawMode,
                    boolean isPublic,
                    boolean showLaneConnectors,
                    Road road1,
                    PathEndType type1,
                    Road road2,
                    PathEndType type2,
                    RoadLanesConnector... connectors)
Deprecated.
deprecated in version 8.4, will be removed in the future releases
Creates a new road connector that connects the specified sets of connection points of the two roads.
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.
showLaneConnectors - display or not lane connector lines on 2D animation
road1 - road 1
type1 - either Type#BEGIN or Type#END of road 1
road2 - road 2
type2 - either Type#BEGIN or Type#END of road 2
lanes - connectors between road ends

Method Detail

showLaneConnectors

public void showLaneConnectors​(boolean showLaneConnectors)
Shows or hides lane connectors
Parameters:
showLaneConnectors - display or not lane connector lines on 2D animation

setRoads

public void setRoads​(Road road1,
                     PathEndType type1,
                     Road road2,
                     PathEndType type2)
Adds 2 roads to this markup element.
Parameters:
road1 - road 1
type1 - either Type#BEGIN or Type#END of road 1
road2 - road 2
type2 - either Type#BEGIN or Type#END of road 2

setDataSource

@AnyLogicInternalAPI
public void setDataSource​(RoadBasicDataSource dataSource)

nCars

public int nCars()
Returns number of cars located on this intersection / connection
Returns:
number of cars

getCars

public java.util.List<Agent> getCars()
Returns unordered list of cars located on this intersection / connection
Returns:
list of cars, order is not guaranteed

traffic

public int traffic​(Road from,
                   Road to)
Returns the traffic of car flow from one specified road to another specified road, measured in cars per hour.
Note: the value is calculated for last five-minute interval If this intersection doesn't connect specified roads an error will occur.
Returns:
the traffic from one specified road to another specified road, cars per hour
See Also:
RoadLanesConnector.traffic()

countCars

public int countCars​(Road from,
                     Road to)
Returns the total number of cars that moved through the intersection from one specified road to another specified road.
Note: the from road and the to road may be the same road, if you want to count the U-turns. If this intersection doesn't connect specified roads an error will occur.
Parameters:
from - - the road by which the cars arrive at the intersection
to - - the road by which the cars leave the intersection
Returns:
the total number of cars that moved through the intersection from one specified road to another specified road
See Also:
RoadLanesConnector.countCars()

resetStats

public void resetStats()
Resets counters of cars for all lane connectors on this intersection
See Also:
RoadLanesConnector#resetCarsCounter()

generateDefaultGuideline

@AnyLogicInternalLibraryAPI
public static java.util.List<MarkupSegment> generateDefaultGuideline​(RoadConnectionPoint inRoadConnectionPoint,
                                                                     RoadConnectionPoint outRoadConnectionPoint)

setGuideline

@AnyLogicInternalLibraryAPI
public void setGuideline​(RoadConnectionPoint inRoadConnectionPoint,
                         RoadConnectionPoint outRoadConnectionPoint,
                         java.util.List<MarkupSegment> guideline)

getIncomingConnectionPoints

@AnyLogicInternalLibraryAPI
public java.util.List<RoadConnectionPoint> getIncomingConnectionPoints()
Returns list of all incoming connection points of the element. The order of elements in the list is not determined, but this order is always the same.
Returns:
List of all incoming connection points.

getOutgoingConnectionPoints

@AnyLogicInternalLibraryAPI
public java.util.List<RoadConnectionPoint> getOutgoingConnectionPoints()
Returns list of all outgoing connection points of the element. The order of elements in the list is not determined, but this order is always the same.
Returns:
List of all outgoing connection points.

getConnectionPoint

@AnyLogicInternalLibraryAPI
public RoadConnectionPoint getConnectionPoint​(RoadConnectionPoint connectedPoint)
Returns connection point that is connected to the specified point, or null if such connection point does not exist.
Parameters:
connectedPoint - Specified connection point.
Returns:
Connection point that is connected to the specified point, or null if such connection point does not exist.

getConnectionPoint

@AnyLogicInternalLibraryAPI
public RoadConnectionPoint getConnectionPoint​(boolean isIncoming,
                                              Road connectedWithRoadSegment,
                                              int roadSegmentLaneIndex)
Returns connection point that is directed at the specified direction, connected with the specified road segment and corresponds to the specified lane index in this road segment. If no such connection point exists, returns null.
Parameters:
isIncoming - true for incoming direction, false for outgoing
connectedWithRoadSegment - Specified specified road segment.
roadSegmentLaneIndex - Specified 0-based lane index. The lane with index 0 is the outmost lane.
Returns:
Connection point satisfying the specified criteria, or null if no such connection point exists.

setGuideline

@AnyLogicInternalLibraryAPI
public void setGuideline​(RoadConnectionPoint inRoadConnectionPoint,
                         RoadConnectionPoint outRoadConnectionPoint)
Sets a guideline between the specified connection points. The guideline is automatically generated based on incoming and outgoing directions according to Hermite rule. Incoming and outgoing connection points should belong to the element. If the guideline already exists, overwrites the existing guideline.
Parameters:
inRoadConnectionPoint - Specified incoming road connection point.
outRoadConnectionPoint - Specified outgoing road connection point.

getGuidelines

@AnyLogicInternalLibraryAPI
public java.util.Map<Pair<RoadConnectionPoint,​RoadConnectionPoint>,​java.util.List<MarkupSegment>> getGuidelines()
Returns map from pairs (incoming and outgoing) of road connection points to guidelines connecting the specified incoming and outgoing connection points.
Returns:
Map from pairs (incoming and outgoing) of road connection points to guidelines connecting the specified incoming and outgoing connection points.

getConnectionPoints

@AnyLogicInternalLibraryAPI
public java.util.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.

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.

addRoad

public void addRoad​(Road road,
                    PathEndType type)
Adds road to this intersection
Parameters:
road - the road
type - either Type#BEGIN or Type#END of road

addConnection

public void addConnection​(Road startRoad,
                          int startRoadLane,
                          Road endRoad,
                          int endRoadLane)
Adds roads connection

addConnection

public void addConnection​(Road startRoad,
                          int startRoadLane,
                          Road endRoad,
                          int endRoadLane,
                          MarkupSegment... guideLine)
Adds roads connection

addConnection

public void addConnection​(Road startRoad,
                          int startRoadLane,
                          Road endRoad,
                          int endRoadLane,
                          java.util.List<MarkupSegment> guideLine)
Adds roads connection

getLanesConnectors

public java.util.List<RoadLanesConnector> getLanesConnectors()
Returns the list of lane connectors inside this intersection
Returns:
the unmodifiable list of RoadLanesConnectors

updateDynamicProperties

@AnyLogicInternalCodegenAPI
public void updateDynamicProperties()
Description copied from class: AbstractMarkup
Updates dynamic properties of this shape only (without structural contents, if any) in a given context.
Method should be overridden for shapes with dynamic properties. Note that you should call super.updateDynamicProperties() at the end of overridden method
Overrides:
updateDynamicProperties in class AbstractMarkup
How can we improve this article?