Class RelativeLane
java.lang.Object
org.opentrafficsim.road.gtu.lane.perception.RelativeLane
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<RelativeLane>
public class RelativeLane extends java.lang.Object implements java.lang.Comparable<RelativeLane>, java.io.Serializable
Defines a lane relative to the current lane.
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.
- Version:
- $Revision$, $LastChangedDate$, by $Author$, initial version May 2, 2016
- Author:
- Wouter Schakel
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static RelativeLaneCURRENTCurrent lane.static RelativeLaneLEFTLeft lane.static RelativeLaneRIGHTright lane.static RelativeLaneSECOND_LEFTSecond left lane.static RelativeLaneSECOND_RIGHTSecond right lane. -
Constructor Summary
Constructors Constructor Description RelativeLane(LateralDirectionality lat, int numLanes)Constructor. -
Method Summary
Modifier and Type Method Description RelativeLaneadd(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".intcompareTo(RelativeLane rel)booleanequals(java.lang.Object obj)LateralDirectionalitygetLateralDirectionality()Returns the lateral direction.RelativeLanegetLeft()Returns the left hand relative lane of this relative lane.intgetNumLanes()Returns the number of lanes in the lateral direction.RelativeLanegetRight()Returns the right hand relative lane of this relative lane.inthashCode()booleanisCurrent()Returns whether the current lane is referred to.booleanisLeft()Returns whether the left lane is referred to.booleanisRight()Returns whether the right lane is referred to.booleanisSecondLeft()Returns whether the second left lane is referred to.booleanisSecondRight()Returns whether the second right lane is referred to.java.lang.StringtoString()
-
Field Details
-
SECOND_LEFT
Second left lane. -
LEFT
Left lane. -
CURRENT
Current lane. -
RIGHT
right lane. -
SECOND_RIGHT
Second right lane.
-
-
Constructor Details
-
RelativeLane
Constructor.- Parameters:
lat- LateralDirectionality; lateral direction (usenullfor the current lane)numLanes- int; number of lanes in the lateral direction (not important for the current lane)- Throws:
java.lang.IllegalArgumentException- if numLanes is not at least 1, except iflat == null(current lane)java.lang.IllegalArgumentException- if numLanes is not 0 iflat == null(current lane)
-
-
Method Details
-
getLateralDirectionality
Returns the lateral direction.- Returns:
- lat lateral direction
-
getNumLanes
public final int getNumLanes()Returns the number of lanes in the lateral direction.- Returns:
- 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
Returns the left hand relative lane of this relative lane.- Returns:
- left hand relative lane of this relative lane.
-
getRight
Returns the right hand relative lane of this relative lane.- Returns:
- right hand relative lane of this relative lane.
-
add
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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
toString
public final java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
compareTo
- Specified by:
compareToin interfacejava.lang.Comparable<RelativeLane>
-