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-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
$LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Feb 21, 2016
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RollingLaneStructureRecord.RecordLink
Link between records that defines the dependence of start position and hence how this is updated as the GTU moves.
-
Constructor Summary
Constructors Constructor Description RollingLaneStructureRecord(Lane lane, GTUDirectionality direction, Length startDistance)
RollingLaneStructureRecord(Lane lane, GTUDirectionality direction, RollingLaneStructureRecord startDistanceSource, RollingLaneStructureRecord.RecordLink recordLink)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addNext(RollingLaneStructureRecord next)
void
addPrev(RollingLaneStructureRecord prev)
boolean
allowsRoute(Route route, GTUType gtuType)
Returns whether this lane allows the route to be followed.boolean
allowsRouteAtEnd(Route route, GTUType gtuType)
Returns whether the end of this lane allows the route to be followed.(package private) void
changeStartDistanceSource(RollingLaneStructureRecord startDistanceSource, RollingLaneStructureRecord.RecordLink recordLink)
Change the source of the distance.void
clearCutOffEnd()
Clears the cut-off at the end.void
clearCutOffStart()
Clears the cut-off at the start.(package private) void
clearNextList()
Clears the next list.(package private) void
clearPrevList()
Clears the prev list.Length
getCutOffEnd()
Returns distance where the structure was cut-off.Length
getCutOffStart()
Returns distance where the structure was cut-off.GTUDirectionality
getDirection()
Returns the direction of travel.Node
getFromNode()
Returns the the 'from' node of the link belonging to this lane, in the driving direction.Lane
getLane()
Returns the lane.RollingLaneStructureRecord
getLeft()
Returns the left LSR or null if not available.Length
getLength()
Returns the length of the lane.List<RollingLaneStructureRecord>
getNext()
Returns a list of next lanes.List<RollingLaneStructureRecord>
getPrev()
Returns a list of previous lanes.RollingLaneStructureRecord
getRight()
Returns the right LSR or null if not available.Length
getStartDistance()
Returns the distance from a reference to the start of this lane, negative for upstream distance.(package private) RollingLaneStructureRecord
getStartDistanceSource()
Returns the source of the start distance.Node
getToNode()
Returns the the 'to' node of the link belonging to this lane, in the driving direction.boolean
isCutOffEnd()
Returns whether this lane has no next records as the lane structure was cut-off.boolean
isCutOffStart()
Returns whether this lane has no previous records as the lane structure was cut-off.boolean
isDeadEnd()
Returns whether the record forms a dead-end.boolean
isDownstreamBranch()
Returns whether the record is part of the downstream branch.boolean
isLinkMerge()
boolean
isLinkSplit()
Deprecated.boolean
legalLeft()
Returns whether a left lane change is legal.boolean
legalRight()
Returns whether a right lane change is legal.boolean
physicalLeft()
Returns whether a left lane change is physically possible.boolean
physicalRight()
Returns whether a right lane change is physically possible.void
setCutOffEnd(Length cutOffEnd)
Sets this record as being cut-off, i.e.void
setCutOffStart(Length cutOffStart)
Sets this record as being cut-off, i.e.void
setLeft(RollingLaneStructureRecord leftRecord, GTUType gtuType)
void
setRight(RollingLaneStructureRecord rightRecord, GTUType gtuType)
String
toString()
(package private) void
updateStartDistance(double fractionalPosition, RollingLaneStructure laneStructure)
Updates the start distance, including all records who's start distance depends on this value.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.opentrafficsim.road.gtu.lane.perception.LaneRecord
getDistanceToPosition
-
Methods inherited from interface org.opentrafficsim.road.gtu.lane.perception.LaneStructureRecord
possibleLeft, possibleRight
-
-
-
-
Constructor Detail
-
RollingLaneStructureRecord
public RollingLaneStructureRecord(Lane lane, GTUDirectionality direction, RollingLaneStructureRecord startDistanceSource, RollingLaneStructureRecord.RecordLink recordLink)
Constructor.- Parameters:
lane
- Lane; lanedirection
- GTUDirectionality; direction of travel for the GTUstartDistanceSource
- RollingLaneStructureRecord; record on which the start distance is basedrecordLink
- RecordLink; link type to source
-
RollingLaneStructureRecord
public RollingLaneStructureRecord(Lane lane, GTUDirectionality direction, Length startDistance)
- Parameters:
lane
- Lane; the lane of the LSRdirection
- GTUDirectionality; the direction on which we process this lanestartDistance
- Length; distance to start of the record, negative for backwards
-
-
Method Detail
-
getLength
public Length getLength()
Returns the length of the lane.- Specified by:
getLength
in interfaceLaneRecord<LaneStructureRecord>
- Returns:
- Length; length of the lane.
-
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 basedrecordLink
- 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-sectionlaneStructure
- 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 interfaceLaneStructureRecord
- 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 interfaceLaneStructureRecord
- 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 interfaceLaneStructureRecord
- Parameters:
route
- Route; the route to followgtuType
- 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 interfaceLaneStructureRecord
- Parameters:
route
- Route; the route to followgtuType
- 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 interfaceLaneStructureRecord
- 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 interfaceLaneStructureRecord
- 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 interfaceLaneStructureRecord
- 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 interfaceLaneStructureRecord
- 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> directiongtuType
- GTUType; GTU type
-
legalRight
public final boolean legalRight()
Returns whether a right lane change is legal.- Specified by:
legalRight
in interfaceLaneStructureRecord
- 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 interfaceLaneStructureRecord
- 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 interfaceLaneRecord<LaneStructureRecord>
- Returns:
- List; list of next lanes
-
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
-
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 interfaceLaneRecord<LaneStructureRecord>
- Returns:
- List; list of previous lanes
-
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 interfaceLaneStructureRecord
- 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 interfaceLaneStructureRecord
- 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 interfaceLaneStructureRecord
- Returns:
- whether the record forms a dead-end
-
getLane
public final Lane getLane()
Returns the lane.- Specified by:
getLane
in interfaceLaneRecord<LaneStructureRecord>
- Returns:
- Lane lane;
-
getDirection
public final GTUDirectionality getDirection()
Returns the direction of travel.- Specified by:
getDirection
in interfaceLaneRecord<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 interfaceLaneRecord<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 returnstrue
.- Specified by:
isDownstreamBranch
in interfaceLaneRecord<LaneStructureRecord>
- Returns:
- Boolean; whether the record is part of the downstream branch
-
-