Class CrossSectionLink
java.lang.Object
org.djutils.event.EventProducer
org.opentrafficsim.core.network.OTSLink
org.opentrafficsim.road.network.lane.CrossSectionLink
- All Implemented Interfaces:
java.io.Serializable
,Locatable
,EventProducerInterface
,Identifiable
,Drawable
,Link
public class CrossSectionLink extends OTSLink implements java.io.Serializable
A CrossSectionLink is a link with lanes where GTUs can possibly switch between lanes.
Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2015-09-16 19:20:07 +0200 (Wed, 16 Sep 2015) $, @version $Revision: 1405 $, by $Author: averbraeck $,
initial version Aug 19, 2014
- Author:
- Alexander Verbraeck, Peter Knoppers, Guus Tamminga
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CrossSectionLink.Priority
Priority of a link. -
Field Summary
Fields Modifier and Type Field Description static EventType
LANE_ADD_EVENT
The (regular, not timed) event type for pub/sub indicating the addition of a Lane to a CrossSectionLink.static EventType
LANE_REMOVE_EVENT
The (regular, not timed) event type for pub/sub indicating the removal of a Lane from a CrossSectionLink.Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
Fields inherited from interface org.opentrafficsim.core.network.Link
GTU_ADD_EVENT, GTU_REMOVE_EVENT
-
Constructor Summary
Constructors Modifier Constructor Description CrossSectionLink(RoadNetwork network, java.lang.String id, OTSRoadNode startNode, OTSRoadNode endNode, LinkType linkType, OTSLine3D designLine, OTSSimulatorInterface simulator, LaneKeepingPolicy laneKeepingPolicy)
Construction of a cross section link.protected
CrossSectionLink(RoadNetwork newNetwork, OTSSimulatorInterface newSimulator, CrossSectionLink link)
Clone a CrossSectionLink for a new network. -
Method Summary
Modifier and Type Method Description protected void
addCrossSectionElement(CrossSectionElement cse)
Add a cross section element at the end of the list.void
clearDemandWeight()
Clears the demand weight.CrossSectionLink
clone(Network newNetwork, OTSSimulatorInterface newSimulator)
CrossSectionElement
getCrossSectionElement(java.lang.String id)
Find a cross section element with a specified id.java.util.List<CrossSectionElement>
getCrossSectionElementList()
Retrieve a safe copy of the cross section element list.java.lang.Double
getDemandWeight()
Returns the demand weight.OTSLine3D
getEndLine()
Returns the line over which GTUs enter and leave the link at the end node.LaneKeepingPolicy
getLaneKeepingPolicy()
Retrieve the lane keeping policy.java.util.List<Lane>
getLanes()
Return a safe copy of the list of lanes of this CrossSectionLink.RoadNetwork
getNetwork()
CrossSectionLink.Priority
getPriority()
OTSLine3D
getStartLine()
Returns the line over which GTUs enter and leave the link at the start node.void
setDemandWeight(double demandWeight)
Sets the demand weight.void
setPriority(CrossSectionLink.Priority priority)
java.lang.String
toString()
Methods inherited from class org.opentrafficsim.core.network.OTSLink
addGTU, equals, getBounds, getDesignLine, getDirectionality, getEndNode, getGTUCount, getGTUs, getId, getLength, getLinkType, getLocation, getSimulator, getSourceId, getStartNode, hashCode, removeGTU
Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, getEventTypesWithListeners, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
Field Details
-
LANE_ADD_EVENT
The (regular, not timed) event type for pub/sub indicating the addition of a Lane to a CrossSectionLink.
Payload: Object[] { String networkId, String linkId, String LaneId, Lane lane, int laneNumber }
TODO work in a different way with lane numbers to align to standard lane numbering. -
LANE_REMOVE_EVENT
The (regular, not timed) event type for pub/sub indicating the removal of a Lane from a CrossSectionLink.
Payload: Object[] { String networkId, String linkId, String LaneId }
TODO allow for the removal of a Lane; currently this is not possible.
-
-
Constructor Details
-
CrossSectionLink
public CrossSectionLink(RoadNetwork network, java.lang.String id, OTSRoadNode startNode, OTSRoadNode endNode, LinkType linkType, OTSLine3D designLine, OTSSimulatorInterface simulator, LaneKeepingPolicy laneKeepingPolicy) throws NetworkExceptionConstruction of a cross section link.- Parameters:
network
- RoadNetwork; the networkid
- String; the link id.startNode
- OTSRoadNode; the start node (directional).endNode
- OTSRoadNode; the end node (directional).linkType
- LinkType; the link typedesignLine
- OTSLine3D; the design line of the Linksimulator
- OTSSimulatorInterface; the simulator on which events can be scheduledlaneKeepingPolicy
- LaneKeepingPolicy; the policy to generally keep left, keep right, or keep lane- Throws:
NetworkException
- if link already exists in the network, if name of the link is not unique, or if the start node or the end node of the link are not registered in the network.
-
CrossSectionLink
protected CrossSectionLink(RoadNetwork newNetwork, OTSSimulatorInterface newSimulator, CrossSectionLink link) throws NetworkExceptionClone a CrossSectionLink for a new network.- Parameters:
newNetwork
- Network; the new network to which the clone belongsnewSimulator
- OTSSimulatorInterface; the new simulator for this networklink
- CrossSectionLink; the link to clone from- Throws:
NetworkException
- if link already exists in the network, if name of the link is not unique, or if the start node or the end node of the link are not registered in the network.
-
-
Method Details
-
getNetwork
- Specified by:
getNetwork
in interfaceLink
- Overrides:
getNetwork
in classOTSLink
-
addCrossSectionElement
Add a cross section element at the end of the list.
Note: LEFT is seen as a positive lateral direction, RIGHT as a negative lateral direction.- Parameters:
cse
- CrossSectionElement; the cross section element to add.
-
getCrossSectionElementList
Retrieve a safe copy of the cross section element list.- Returns:
- List<CrossSectionElement>; the cross section element list.
-
getLaneKeepingPolicy
Retrieve the lane keeping policy.- Returns:
- LaneKeepingPolicy; the lane keeping policy on this CrossSectionLink
-
getCrossSectionElement
Find a cross section element with a specified id.- Parameters:
id
- String; the id to search for- Returns:
- CrossSectionElement; the cross section element with the given id, or null if not found
-
getLanes
Return a safe copy of the list of lanes of this CrossSectionLink.- Returns:
- List<Lane>; the list of lanes.
-
getPriority
- Returns:
- priority.
-
setPriority
- Parameters:
priority
- Priority; set priority.
-
setDemandWeight
public final void setDemandWeight(double demandWeight)Sets the demand weight. This is only applicable to links of type CONNECTOR.- Parameters:
demandWeight
- double; demand weight, which is any positive value
-
clearDemandWeight
public final void clearDemandWeight()Clears the demand weight. This is only applicable to links of type CONNECTOR. -
getDemandWeight
public final java.lang.Double getDemandWeight()Returns the demand weight. This is only applicable to links of type CONNECTOR.- Returns:
- Double; demand weight, any positive value, or
null
-
getStartLine
Returns the line over which GTUs enter and leave the link at the start node.- Returns:
- OTSLine3D; line over which GTUs enter and leave the link at the start node
-
getEndLine
Returns the line over which GTUs enter and leave the link at the end node.- Returns:
- OTSLine3D; line over which GTUs enter and leave the link at the end node
-
toString
public final java.lang.String toString() -
clone
public CrossSectionLink clone(Network newNetwork, OTSSimulatorInterface newSimulator) throws NetworkException- Overrides:
clone
in classOTSLink
- Throws:
NetworkException
-