Class 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-2022 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 Detail

      • RollingLaneStructureRecord

        public RollingLaneStructureRecord​(Lane lane,
                                          GTUDirectionality direction,
                                          RollingLaneStructureRecord startDistanceSource,
                                          RollingLaneStructureRecord.RecordLink recordLink)
        Constructor.
        Parameters:
        lane - Lane; lane
        direction - GTUDirectionality; direction of travel for the GTU
        startDistanceSource - RollingLaneStructureRecord; record on which the start distance is based
        recordLink - RecordLink; link type to source
      • RollingLaneStructureRecord

        public RollingLaneStructureRecord​(Lane lane,
                                          GTUDirectionality direction,
                                          Length startDistance)
        Parameters:
        lane - Lane; the lane of the LSR
        direction - GTUDirectionality; the direction on which we process this lane
        startDistance - Length; distance to start of the record, negative for backwards
    • Method Detail

      • changeStartDistanceSource

        final void changeStartDistanceSource​(RollingLaneStructureRecord startDistanceSource,
                                             RollingLaneStructureRecord.RecordLink recordLink)
        Change the source of the distance.
        Parameters:
        startDistanceSource - RollingLaneStructureRecord; record on which the start distance is based
        recordLink - RecordLink; link type to source
      • updateStartDistance

        final void updateStartDistance​(double fractionalPosition,
                                       RollingLaneStructure laneStructure)
        Updates the start distance, including all records who's start distance depends on this value. Advised is to only initiate this at the root record. Note that before this is invoked, all record-links should be updated.
        Parameters:
        fractionalPosition - double; fractional position at the current cross-section
        laneStructure - RollingLaneStructure; parent lane structure
      • getStartDistanceSource

        final RollingLaneStructureRecord getStartDistanceSource()
        Returns the source of the start distance.
        Returns:
        LaneStructureRecord; source of the start distance
      • 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
      • clearNextList

        final void clearNextList()
        Clears the next list.
      • 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
      • clearPrevList

        final void clearPrevList()
        Clears the prev list.
      • 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
      • 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