Class RelativeLane

java.lang.Object
org.opentrafficsim.road.gtu.lane.perception.RelativeLane
All Implemented Interfaces:
Serializable, Comparable<RelativeLane>

public class RelativeLane extends Object implements Comparable<RelativeLane>, Serializable
Defines a lane relative to the current lane.

Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Wouter Schakel
See Also:
  • Field Details

    • SECOND_LEFT

      public static final RelativeLane SECOND_LEFT
      Second left lane.
    • LEFT

      public static final RelativeLane LEFT
      Left lane.
    • CURRENT

      public static final RelativeLane CURRENT
      Current lane.
    • SECOND_RIGHT

      public static final RelativeLane SECOND_RIGHT
      Second right lane.
  • Constructor Details

    • RelativeLane

      public RelativeLane(LateralDirectionality lat, int numLanes)
      Constructor.
      Parameters:
      lat - LateralDirectionality; lateral direction (use null for the current lane)
      numLanes - int; number of lanes in the lateral direction (not important for the current lane)
      Throws:
      IllegalArgumentException - if numLanes is not at least 1, except if lat == null (current lane)
      IllegalArgumentException - if numLanes is not 0 if lat == null (current lane)
  • Method Details

    • getLateralDirectionality

      public final LateralDirectionality getLateralDirectionality()
      Returns the lateral direction.
      Returns:
      LateralDirectionality; the lateral direction
    • getNumLanes

      public final int getNumLanes()
      Returns the number of lanes in the lateral direction.
      Returns:
      int; number of lanes in the lateral direction
    • isSecondLeft

      public final boolean isSecondLeft()
      Returns whether the second left lane is referred to.
      Returns:
      whether the second left lane is referred to
    • isLeft

      public final boolean isLeft()
      Returns whether the left lane is referred to.
      Returns:
      whether the left lane is referred to
    • isCurrent

      public final boolean isCurrent()
      Returns whether the current lane is referred to.
      Returns:
      whether the current lane is referred to
    • isRight

      public final boolean isRight()
      Returns whether the right lane is referred to.
      Returns:
      whether the right lane is referred to
    • isSecondRight

      public final boolean isSecondRight()
      Returns whether the second right lane is referred to.
      Returns:
      whether the second right lane is referred to
    • getLeft

      public final RelativeLane getLeft()
      Returns the left hand relative lane of this relative lane.
      Returns:
      left hand relative lane of this relative lane.
    • getRight

      public final RelativeLane getRight()
      Returns the right hand relative lane of this relative lane.
      Returns:
      right hand relative lane of this relative lane.
    • add

      public final RelativeLane add(RelativeLane relativeLane)
      Returns the relative lane relative to this lane, for example "the left lane" of "the 3rd right lane" is "the 2nd right lane".
      Parameters:
      relativeLane - RelativeLane; relative lane to get of this lane
      Returns:
      relative lane relative to this lane
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

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

      public final int compareTo(RelativeLane rel)
      Specified by:
      compareTo in interface Comparable<RelativeLane>