Class CrossSectionLink
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.opentrafficsim.core.network.OTSLink
-
- org.opentrafficsim.road.network.lane.CrossSectionLink
-
- All Implemented Interfaces:
Serializable
,Locatable
,EventProducerInterface
,Identifiable
,Drawable
,Link
public class CrossSectionLink extends OTSLink implements 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 TimedEventType
LANE_ADD_EVENT
The (regular, not timed) event type for pub/sub indicating the addition of a Lane to a CrossSectionLink.static TimedEventType
LANE_REMOVE_EVENT
The (regular, not timed) event type for pub/sub indicating the removal of a Lane from a CrossSectionLink.-
Fields inherited from class org.djutils.event.EventProducer
eventProducerImpl
-
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(OTSRoadNetwork network, String id, OTSRoadNode startNode, OTSRoadNode endNode, LinkType linkType, OTSLine3D designLine, LaneKeepingPolicy laneKeepingPolicy)
Construction of a cross section link.protected
CrossSectionLink(OTSRoadNetwork newNetwork, CrossSectionLink link)
Clone a CrossSectionLink for a new network.
-
Method Summary
All Methods Instance Methods Concrete Methods 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(OTSNetwork newNetwork)
CrossSectionElement
getCrossSectionElement(String id)
Find a cross section element with a specified id.List<CrossSectionElement>
getCrossSectionElementList()
Retrieve a safe copy of the cross section element list.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.List<Lane>
getLanes()
Return a safe copy of the list of lanes of this CrossSectionLink.OTSRoadNetwork
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)
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, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
-
-
-
Field Detail
-
LANE_ADD_EVENT
public static final TimedEventType 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, int laneNumber }
TODO work in a different way with lane numbers to align to standard lane numbering.
-
LANE_REMOVE_EVENT
public static final TimedEventType 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 Detail
-
CrossSectionLink
public CrossSectionLink(OTSRoadNetwork network, String id, OTSRoadNode startNode, OTSRoadNode endNode, LinkType linkType, OTSLine3D designLine, LaneKeepingPolicy laneKeepingPolicy) throws NetworkException
Construction of a cross section link.- Parameters:
network
- OTSRoadNetwork; 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 LinklaneKeepingPolicy
- 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(OTSRoadNetwork newNetwork, CrossSectionLink link) throws NetworkException
Clone a CrossSectionLink for a new network.- Parameters:
newNetwork
- Network; the new network to which the clone belongslink
- 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 Detail
-
getNetwork
public OTSRoadNetwork getNetwork()
- Specified by:
getNetwork
in interfaceLink
- Overrides:
getNetwork
in classOTSLink
-
addCrossSectionElement
protected final void addCrossSectionElement(CrossSectionElement cse)
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
public final List<CrossSectionElement> getCrossSectionElementList()
Retrieve a safe copy of the cross section element list.- Returns:
- List<CrossSectionElement>; the cross section element list.
-
getLaneKeepingPolicy
public final LaneKeepingPolicy getLaneKeepingPolicy()
Retrieve the lane keeping policy.- Returns:
- LaneKeepingPolicy; the lane keeping policy on this CrossSectionLink
-
getCrossSectionElement
public final CrossSectionElement getCrossSectionElement(String id)
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
public final List<Lane> getLanes()
Return a safe copy of the list of lanes of this CrossSectionLink.- Returns:
- List<Lane>; the list of lanes.
-
getPriority
public final CrossSectionLink.Priority getPriority()
- Returns:
- priority.
-
setPriority
public final void setPriority(CrossSectionLink.Priority priority)
- 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 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
public OTSLine3D 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
public OTSLine3D 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
-
clone
public CrossSectionLink clone(OTSNetwork newNetwork) throws NetworkException
- Overrides:
clone
in classOTSLink
- Throws:
NetworkException
-
-