Class RollingLaneStructureRecord

java.lang.Object
org.opentrafficsim.road.gtu.lane.perception.RollingLaneStructureRecord
All Implemented Interfaces:
Serializable, LaneRecord<LaneStructureRecord>, LaneStructureRecord

public class RollingLaneStructureRecord
extends Object
implements LaneStructureRecord, Serializable
A LaneStructureRecord contains information about the lanes that can be accessed from this lane by a GTUType. It tells whether there is a left and/or right lane by pointing to other LaneStructureRecords, and which successor LaneStructureRecord(s) there are at the end of the lane of this LaneStructureRecord. All information (left, right, next) is calculated relative to the driving direction of the GTU that owns this structure.

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-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Feb 21, 2016
Author:
Alexander Verbraeck, Peter Knoppers
See Also:
Serialized Form
  • Constructor Details

  • Method Details

    • getLength

      public Length getLength()
      Returns the length of the lane.
      Specified by:
      getLength in interface LaneRecord<LaneStructureRecord>
      Returns:
      Length; length of the lane.
    • getFromNode

      public final Node getFromNode()
      Returns the the 'from' node of the link belonging to this lane, in the driving direction.
      Specified by:
      getFromNode in interface LaneStructureRecord
      Returns:
      Node; the 'from' node of the link belonging to this lane, in the driving direction
    • getToNode

      public final Node getToNode()
      Returns the the 'to' node of the link belonging to this lane, in the driving direction.
      Specified by:
      getToNode in interface LaneStructureRecord
      Returns:
      Node; the 'to' node of the link belonging to this lane, in the driving direction
    • isLinkSplit

      @Deprecated public final boolean isLinkSplit()
      Deprecated.
      Returns:
      whether the link to which this lane belongs splits, i.e. some of the parallel, connected lanes lead to a different destination than others
    • isLinkMerge

      public final boolean isLinkMerge()
      Returns:
      whether the link to which this lane belongs merges, i.e. some of the parallel, connected lanes follow from a different origin than others
    • allowsRoute

      public final boolean allowsRoute​(Route route, GTUType gtuType) throws NetworkException
      Returns whether this lane allows the route to be followed.
      Specified by:
      allowsRoute in interface LaneStructureRecord
      Parameters:
      route - Route; the route to follow
      gtuType - GTUType; gtu type
      Returns:
      whether this lane allows the route to be followed
      Throws:
      NetworkException - if no destination node
    • allowsRouteAtEnd

      public final boolean allowsRouteAtEnd​(Route route, GTUType gtuType) throws NetworkException
      Returns whether the end of this lane allows the route to be followed.
      Specified by:
      allowsRouteAtEnd in interface LaneStructureRecord
      Parameters:
      route - Route; the route to follow
      gtuType - GTUType; gtu type
      Returns:
      whether the end of this lane allows the route to be followed
      Throws:
      NetworkException - if no destination node
    • getLeft

      public final RollingLaneStructureRecord getLeft()
      Returns the left LSR or null if not available. Left and right are relative to the driving direction.
      Specified by:
      getLeft in interface LaneStructureRecord
      Returns:
      LaneStructureRecord; the left LSR or null if not available
    • setLeft

      public final void setLeft​(RollingLaneStructureRecord leftRecord, GTUType gtuType)
      Parameters:
      leftRecord - RollingLaneStructureRecord; set the left LSR or null if not available. Left and right are relative to the <b>driving</b> direction.
      gtuType - GTUType; GTU type
    • legalLeft

      public final boolean legalLeft()
      Returns whether a left lane change is legal.
      Specified by:
      legalLeft in interface LaneStructureRecord
      Returns:
      whether a left lane change is legal
    • physicalLeft

      public final boolean physicalLeft()
      Returns whether a left lane change is physically possible.
      Specified by:
      physicalLeft in interface LaneStructureRecord
      Returns:
      whether a left lane change is physically possible
    • getRight

      public final RollingLaneStructureRecord getRight()
      Returns the right LSR or null if not available. Left and right are relative to the driving direction.
      Specified by:
      getRight in interface LaneStructureRecord
      Returns:
      LaneStructureRecord; the right LSR or null if not available
    • setRight

      public final void setRight​(RollingLaneStructureRecord rightRecord, GTUType gtuType)
      Parameters:
      rightRecord - RollingLaneStructureRecord; set the right LSR or null if not available. Left and right are relative to the <b>driving</b> direction
      gtuType - GTUType; GTU type
    • legalRight

      public final boolean legalRight()
      Returns whether a right lane change is legal.
      Specified by:
      legalRight in interface LaneStructureRecord
      Returns:
      whether a right lane change is legal
    • physicalRight

      public final boolean physicalRight()
      Returns whether a right lane change is physically possible.
      Specified by:
      physicalRight in interface LaneStructureRecord
      Returns:
      whether a right lane change is physically possible
    • getNext

      public final List<RollingLaneStructureRecord> getNext()
      Returns a list of next lanes. Callers of this method do not have to mind GTUDirectionality, this is taken care of.
      Specified by:
      getNext in interface LaneRecord<LaneStructureRecord>
      Returns:
      List; list of next lanes
    • addNext

      public final void addNext​(RollingLaneStructureRecord next) throws GTUException
      Parameters:
      next - RollingLaneStructureRecord; a next LSRs to add. Next is relative to the driving direction, not to the design line direction.
      Throws:
      GTUException - if the records is cut-off at the end
    • getPrev

      public final List<RollingLaneStructureRecord> getPrev()
      Returns a list of previous lanes. Callers of this method do not have to mind GTUDirectionality, this is taken care of.
      Specified by:
      getPrev in interface LaneRecord<LaneStructureRecord>
      Returns:
      List; list of previous lanes
    • addPrev

      public final void addPrev​(RollingLaneStructureRecord prev) throws GTUException
      Parameters:
      prev - RollingLaneStructureRecord; a previous LSRs to add. Previous is relative to the driving direction, not to the design line direction.
      Throws:
      GTUException - if the records is cut-off at the start
    • setCutOffEnd

      public final void setCutOffEnd​(Length cutOffEnd) throws GTUException
      Sets this record as being cut-off, i.e. there are no next records due to cut-off.
      Parameters:
      cutOffEnd - Length; where this lane was cut-off (in the driving direction) resulting in no next lanes
      Throws:
      GTUException - if there are next records
    • setCutOffStart

      public final void setCutOffStart​(Length cutOffStart) throws GTUException
      Sets this record as being cut-off, i.e. there are no previous records due to cut-off.
      Parameters:
      cutOffStart - Length; where this lane was cut-off (in the driving direction) resulting in no prev lanes
      Throws:
      GTUException - if there are previous records
    • isCutOffEnd

      public final boolean isCutOffEnd()
      Returns whether this lane has no next records as the lane structure was cut-off.
      Specified by:
      isCutOffEnd in interface LaneStructureRecord
      Returns:
      whether this lane has no next records as the lane structure was cut-off
    • isCutOffStart

      public final boolean isCutOffStart()
      Returns whether this lane has no previous records as the lane structure was cut-off.
      Specified by:
      isCutOffStart in interface LaneStructureRecord
      Returns:
      whether this lane has no previous records as the lane structure was cut-off
    • getCutOffEnd

      public final Length getCutOffEnd()
      Returns distance where the structure was cut-off.
      Returns:
      distance where the structure was cut-off
    • getCutOffStart

      public final Length getCutOffStart()
      Returns distance where the structure was cut-off.
      Returns:
      distance where the structure was cut-off
    • clearCutOffEnd

      public final void clearCutOffEnd()
      Clears the cut-off at the end.
    • clearCutOffStart

      public final void clearCutOffStart()
      Clears the cut-off at the start.
    • isDeadEnd

      public final boolean isDeadEnd()
      Returns whether the record forms a dead-end.
      Specified by:
      isDeadEnd in interface LaneStructureRecord
      Returns:
      whether the record forms a dead-end
    • getLane

      public final Lane getLane()
      Returns the lane.
      Specified by:
      getLane in interface LaneRecord<LaneStructureRecord>
      Returns:
      Lane lane;
    • getDirection

      public final GTUDirectionality getDirection()
      Returns the direction of travel.
      Specified by:
      getDirection in interface LaneRecord<LaneStructureRecord>
      Returns:
      GTUDirectionality; direction of travel
    • getStartDistance

      public final Length getStartDistance()
      Returns the distance from a reference to the start of this lane, negative for upstream distance.
      Specified by:
      getStartDistance in interface LaneRecord<LaneStructureRecord>
      Returns:
      Length; the distance from a reference to the start of this lane, negative for upstream distance
    • isDownstreamBranch

      public boolean isDownstreamBranch()
      Returns whether the record is part of the downstream branch. This means the GTU can potentially get here and the lane is not upstream or on the other branch upstream of a merge. Default implementation returns true.
      Specified by:
      isDownstreamBranch in interface LaneRecord<LaneStructureRecord>
      Returns:
      Boolean; whether the record is part of the downstream branch
    • toString

      public final String toString()
      Overrides:
      toString in class Object