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
  • Field Details

    • LANE_ADD_EVENT

      public static final EventType 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

      public static final EventType 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 NetworkException
      Construction of a cross section link.
      Parameters:
      network - RoadNetwork; the network
      id - String; the link id.
      startNode - OTSRoadNode; the start node (directional).
      endNode - OTSRoadNode; the end node (directional).
      linkType - LinkType; the link type
      designLine - OTSLine3D; the design line of the Link
      simulator - OTSSimulatorInterface; the simulator on which events can be scheduled
      laneKeepingPolicy - 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 NetworkException
      Clone a CrossSectionLink for a new network.
      Parameters:
      newNetwork - Network; the new network to which the clone belongs
      newSimulator - OTSSimulatorInterface; the new simulator for this network
      link - 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

      public RoadNetwork getNetwork()
      Specified by:
      getNetwork in interface Link
      Overrides:
      getNetwork in class OTSLink
    • 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 java.util.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​(java.lang.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 java.util.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 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

      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
    • toString

      public final java.lang.String toString()
      Overrides:
      toString in class OTSLink
    • clone

      public CrossSectionLink clone​(Network newNetwork, OTSSimulatorInterface newSimulator) throws NetworkException
      Overrides:
      clone in class OTSLink
      Throws:
      NetworkException