Class Lane
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.road.network.lane.CrossSectionElement
org.opentrafficsim.road.network.lane.Lane
- All Implemented Interfaces:
Serializable
,Remote
,nl.tudelft.simulation.dsol.animation.Locatable
,org.djutils.base.Identifiable
,org.djutils.event.EventProducer
,org.opentrafficsim.base.geometry.OtsLocatable
,org.opentrafficsim.base.HierarchicallyTyped<LaneType,
,Lane> Drawable
,SpatialObject
- Direct Known Subclasses:
Shoulder
public class Lane
extends CrossSectionElement
implements org.opentrafficsim.base.HierarchicallyTyped<LaneType,Lane>, SpatialObject, Serializable
The Lane is the CrossSectionElement of a CrossSectionLink on which GTUs can drive. The Lane stores several important
properties, such as the successor lane(s), predecessor lane(s), and adjacent lane(s), all separated per GTU type. It can, for
instance, be that a truck is not allowed to move into an adjacent lane, while a car is allowed to do so. Furthermore, the
lane contains detectors that can be triggered by passing GTUs. The Lane class also contains methods to determine to trigger
the detectors at exactly calculated and scheduled times, given the movement of the GTUs.
Finally, the Lane stores the GTUs on the lane, and contains several access methods to determine successor and predecessor GTUs, as well as methods to add a GTU to a lane (either at the start or in the middle when changing lanes), and remove a GTU from the lane (either at the end, or in the middle when changing onto another lane). The GTU is only booked with its reference point on the lane, and is -- unless during a lane change -- only booked on one lane at a time.
Finally, the Lane stores the GTUs on the lane, and contains several access methods to determine successor and predecessor GTUs, as well as methods to add a GTU to a lane (either at the start or in the middle when changing lanes), and remove a GTU from the lane (either at the end, or in the middle when changing onto another lane). The GTU is only booked with its reference point on the lane, and is -- unless during a lane change -- only booked on one lane at a time.
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:
- Alexander Verbraeck, Peter Knoppers
- See Also:
-
Field Summary
Modifier and TypeFieldDescription(package private) static final org.djunits.value.vdouble.scalar.Length
Lateral alignment margin for longitudinally connected Lanes.static final org.djutils.event.EventType
The timed event type for pub/sub indicating the addition of a Detector to the lane.static final org.djutils.event.EventType
The timed event type for pub/sub indicating the removal of a Detector from the lane.static final org.djutils.event.EventType
The timed event type for pub/sub indicating the addition of a GTU to the lane.static final org.djutils.event.EventType
The timed event type for pub/sub indicating the removal of a GTU from the lane.static final org.djunits.value.vdouble.scalar.Length
Lateral alignment margin for longitudinally connected Lanes.static final org.djutils.event.EventType
The event type for pub/sub indicating the addition of a LaneBasedObject to the lane.static final org.djutils.event.EventType
The event type for pub/sub indicating the removal of a LaneBasedObject from the lane.Fields inherited from class org.opentrafficsim.road.network.lane.CrossSectionElement
link
Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
Constructor Summary
ConstructorDescriptionLane
(CrossSectionLink link, String id, OtsLine2d centerLine, org.djutils.draw.line.Polygon2d contour, List<CrossSectionSlice> crossSectionSlices, LaneType laneType, Map<GtuType, org.djunits.value.vdouble.scalar.Speed> speedLimitMap) Constructor specifying geometry. -
Method Summary
Modifier and TypeMethodDescriptionaccessibleAdjacentLanesLegal
(LateralDirectionality lateralDirection, GtuType gtuType) Determine the set of lanes to the left or to the right of this lane, which are accessible from this lane, or an empty set if no lane could be found.accessibleAdjacentLanesPhysical
(LateralDirectionality lateralDirection, GtuType gtuType) Determine the set of lanes to the left or to the right of this lane, which are accessible from this lane, or an empty set if no lane could be found.final void
addDetector
(LaneDetector detector) Insert a detector at the right place in the detector list of this Lane.final int
addGtu
(LaneBasedGtu gtu, double fractionalPosition) Add a LaneBasedGtu to the list of this Lane.final int
addGtu
(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Length longitudinalPosition) Add a LaneBasedGtu to the list of this Lane.final void
addLaneBasedObject
(LaneBasedObject laneBasedObject) Insert a laneBasedObject at the right place in the laneBasedObject list of this Lane.final org.djunits.value.vdouble.scalar.Length
coveredDistance
(double fraction) Returns the covered distance driven to the given fractional position.boolean
void
forceNextLanes
(Set<Lane> lanes) Forces the next lanes to be as specified.void
forcePrevLanes
(Set<Lane> lanes) Forces the previous lanes to be as specified.final double
fraction
(org.djunits.value.vdouble.scalar.Length position) Transform a position on the lane (can be less than zero or larger than the lane length) to a fraction.final double
fractionAtCoveredDistance
(org.djunits.value.vdouble.scalar.Length distance) Deprecated.final double
fractionSI
(double positionSI) Transform a position on the lane in SI units (can be less than zero or larger than the lane length) to a fraction.getAdjacentLane
(LateralDirectionality laneChangeDirection, GtuType gtuType) Returns one adjacent lane.final SortedMap<Double,
List<LaneDetector>> getDetectorMap
(GtuType gtuType) Retrieve the list of Detectors of this Lane for the given GtuType.final List<LaneDetector>
Retrieve the list of all Detectors of this Lane.final List<LaneDetector>
getDetectors
(org.djunits.value.vdouble.scalar.Length minimumPosition, org.djunits.value.vdouble.scalar.Length maximumPosition, GtuType gtuType) Retrieve the list of Detectors of this Lane in the specified distance range for the given GtuType.final List<LaneDetector>
getDetectors
(GtuType gtuType) Retrieve the list of Detectors of this Lane that are triggered by the given GtuType.final LaneBasedGtu
Get the first GTU on the lane, relative to a driving direction on this lane.final LaneBasedGtu
getGtu
(int index) Returns the index'th GTU.final LaneBasedGtu
getGtu
(int index, org.djunits.value.vdouble.scalar.Time time) Returns the index'th GTU at specified time.final LaneBasedGtu
getGtuAhead
(org.djunits.value.vdouble.scalar.Length position, RelativePosition.Type relativePosition, org.djunits.value.vdouble.scalar.Time when) Get the first GTU where the relativePosition is in front of another GTU on the lane, in a driving direction on this lane, compared to the DESIGN LINE.final LaneBasedGtu
getGtuBehind
(org.djunits.value.vdouble.scalar.Length position, RelativePosition.Type relativePosition, org.djunits.value.vdouble.scalar.Time when) Get the first GTU where the relativePosition is behind a certain position on the lane, in a driving direction on this lane, compared to the DESIGN LINE.final org.djutils.immutablecollections.ImmutableList<LaneBasedGtu>
final List<LaneBasedGtu>
getGtuList
(org.djunits.value.vdouble.scalar.Time time) Returns the list of GTU's at the specified time.final org.djunits.value.vdouble.scalar.Speed
Get the highest speed limit of this lane.final SortedMap<Double,
List<LaneBasedObject>> Retrieve the list of LaneBasedObjects of this Lane.final List<LaneBasedObject>
Retrieve the list of all LaneBasedObjects of this Lane.final List<LaneBasedObject>
getLaneBasedObjects
(org.djunits.value.vdouble.scalar.Length minimumPosition, org.djunits.value.vdouble.scalar.Length maximumPosition) Retrieve the list of LaneBasedObjects of this Lane in the specified distance range.final LaneBasedGtu
Get the last GTU on the lane, relative to a driving direction on this lane.final org.djunits.value.vdouble.scalar.Speed
Get the lowest speed limit of this lane.final List<LaneBasedObject>
getObjectAhead
(org.djunits.value.vdouble.scalar.Length position) Get the first object where the relativePosition is in front of a certain position on the lane, in a driving direction on this lane, compared to the DESIGN LINE.final List<LaneBasedObject>
getObjectBehind
(org.djunits.value.vdouble.scalar.Length position) Get the first object where the relativePosition is behind of a certain position on the lane, in a driving direction on this lane, compared to the DESIGN LINE.org.djutils.draw.line.Polygon2d
getShape()
org.djunits.value.vdouble.scalar.Speed
getSpeedLimit
(GtuType gtuType) Get the speed limit of this lane, which can differ per GTU type.final LaneType
getType()
int
hashCode()
final int
indexOfGtu
(LaneBasedGtu gtu) Returns the index of the given GTU, or -1 if not present.final int
indexOfGtu
(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Time time) Returns the index of the given GTU, or -1 if not present, at specified time.NextLanes returns the successor lane(s) in the design line direction, if any exist.
The next lane(s) are cached, as it is too expensive to make the calculation every time.final int
Returns the number of GTU's.final int
numberOfGtus
(org.djunits.value.vdouble.scalar.Time time) Returns the number of GTU's at specified time.final org.djunits.value.vdouble.scalar.Length
position
(double fraction) Transform a fraction on the lane to a relative length (can be less than zero or larger than the lane length).final double
positionSI
(double fraction) Transform a fraction on the lane to a relative length in SI units (can be less than zero or larger than the lane length).PrevLanes returns the predecessor lane(s) relative to the design line direction, if any exist.
The previous lane(s) are cached, as it is too expensive to make the calculation every time.final org.djunits.value.vdouble.scalar.Length
remainingDistance
(double fraction) Returns the remaining distance to be driven from the given fractional position.final void
removeDetector
(LaneDetector detector) Remove a detector from the detector list of this Lane.final void
removeGtu
(LaneBasedGtu gtu, boolean removeFromParentLink, org.djunits.value.vdouble.scalar.Length position) Remove a GTU from the GTU list of this lane.final void
removeLaneBasedObject
(LaneBasedObject laneBasedObject) Remove a laneBasedObject from the laneBasedObject list of this Lane.final void
removeSpeedLimit
(GtuType gtuType) Remove the set speed limit for a GtuType.final void
scheduleDetectorTriggers
(LaneBasedGtu gtu, double referenceStartSI, double referenceMoveSI) Schedule triggering of the detectors for a certain time step; from now until the nextEvaluationTime of the GTU.final void
setSpeedLimit
(GtuType gtuType, org.djunits.value.vdouble.scalar.Speed speedLimit) Set the speed limit of this lane, which can differ per GTU type.final String
toString()
Methods inherited from class org.opentrafficsim.road.network.lane.CrossSectionElement
getBeginWidth, getBounds, getCenterLine, getContour, getElevation, getElevation, getEndWidth, getFullId, getGrade, getGrade, getId, getLateralBoundaryPosition, getLateralBoundaryPosition, getLateralCenterPosition, getLateralCenterPosition, getLength, getLink, getLocation, getNetwork, getOffsetAtBegin, getOffsetAtEnd, getWidth, getWidth, getZ
Methods inherited from class org.djutils.event.LocalEventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opentrafficsim.base.HierarchicallyTyped
isOfType
Methods inherited from interface nl.tudelft.simulation.dsol.animation.Locatable
getDirZ
-
Field Details
-
GTU_ADD_EVENT
public static final org.djutils.event.EventType GTU_ADD_EVENTThe timed event type for pub/sub indicating the addition of a GTU to the lane.
Payload: Object[] {String gtuId, int count_after_addition, String laneId, String linkId} -
GTU_REMOVE_EVENT
public static final org.djutils.event.EventType GTU_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a GTU from the lane.
Payload: Object[] {String gtuId, LaneBasedGtu gtu, int count_after_removal, Length position, String laneId, String linkId} -
DETECTOR_ADD_EVENT
public static final org.djutils.event.EventType DETECTOR_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Detector to the lane.
Payload: Object[] {String detectorId, Detector detector} -
DETECTOR_REMOVE_EVENT
public static final org.djutils.event.EventType DETECTOR_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Detector from the lane.
Payload: Object[] {String detectorId, Detector detector} -
OBJECT_ADD_EVENT
public static final org.djutils.event.EventType OBJECT_ADD_EVENTThe event type for pub/sub indicating the addition of a LaneBasedObject to the lane.
Payload: Object[] {LaneBasedObject laneBasedObject} -
OBJECT_REMOVE_EVENT
public static final org.djutils.event.EventType OBJECT_REMOVE_EVENTThe event type for pub/sub indicating the removal of a LaneBasedObject from the lane.
Payload: Object[] {LaneBasedObject laneBasedObject} -
ADJACENT_MARGIN
static final org.djunits.value.vdouble.scalar.Length ADJACENT_MARGINLateral alignment margin for longitudinally connected Lanes. -
MARGIN
public static final org.djunits.value.vdouble.scalar.Length MARGINLateral alignment margin for longitudinally connected Lanes.
-
-
Constructor Details
-
Lane
public Lane(CrossSectionLink link, String id, OtsLine2d centerLine, org.djutils.draw.line.Polygon2d contour, List<CrossSectionSlice> crossSectionSlices, LaneType laneType, Map<GtuType, org.djunits.value.vdouble.scalar.Speed> speedLimitMap) throws NetworkExceptionConstructor specifying geometry.- Parameters:
link
- CrossSectionLink; link.id
- String; the id of this lane within the link; should be unique within the link.centerLine
- OtsLine2d; center line.contour
- Polygon2d; contour shape.crossSectionSlices
- List<CrossSectionSlice>; cross-section slices.laneType
- LaneType; lane type.speedLimitMap
- Map<GtuType, Speed>; the speed limit on this lane, specified per GTU Type.- Throws:
NetworkException
- when no cross-section slice is defined.
-
-
Method Details
-
addDetector
Insert a detector at the right place in the detector list of this Lane.- Parameters:
detector
- Detector; the detector to add- Throws:
NetworkException
- when the position of the detector is beyond (or before) the range of this Lane
-
removeDetector
Remove a detector from the detector list of this Lane.- Parameters:
detector
- Detector; the detector to remove.- Throws:
NetworkException
- when the detector was not found on this Lane
-
getDetectors
public final List<LaneDetector> getDetectors(org.djunits.value.vdouble.scalar.Length minimumPosition, org.djunits.value.vdouble.scalar.Length maximumPosition, GtuType gtuType) Retrieve the list of Detectors of this Lane in the specified distance range for the given GtuType. The resulting list is a defensive copy.- Parameters:
minimumPosition
- Length; the minimum distance on the Lane (inclusive)maximumPosition
- Length; the maximum distance on the Lane (inclusive)gtuType
- GtuType; the GTU type to provide the detectors for- Returns:
- List<Detector>; list of the detectors in the specified range. This is a defensive copy.
-
getDetectors
Retrieve the list of Detectors of this Lane that are triggered by the given GtuType. The resulting list is a defensive copy.- Parameters:
gtuType
- GtuType; the GTU type to provide the detectors for- Returns:
- List<Detector>; list of the detectors, in ascending order for the location on the Lane
-
getDetectors
Retrieve the list of all Detectors of this Lane. The resulting list is a defensive copy.- Returns:
- List<Detector>; list of the detectors, in ascending order for the location on the Lane
-
getDetectorMap
Retrieve the list of Detectors of this Lane for the given GtuType. The resulting Map is a defensive copy.- Parameters:
gtuType
- GtuType; the GTU type to provide the detectors for- Returns:
- SortedMap<Double, List<Detector>>; all detectors on this lane for the given GtuType as a map per distance
-
scheduleDetectorTriggers
public final void scheduleDetectorTriggers(LaneBasedGtu gtu, double referenceStartSI, double referenceMoveSI) throws NetworkException, nl.tudelft.simulation.dsol.SimRuntimeException Schedule triggering of the detectors for a certain time step; from now until the nextEvaluationTime of the GTU.- Parameters:
gtu
- LaneBasedGtu; the lane based GTU for which to schedule triggering of the detectors.referenceStartSI
- double; the SI distance of the GTU reference point on the lane at the current timereferenceMoveSI
- double; the SI distance travelled in the next time step.- Throws:
NetworkException
- when GTU not on this lane.nl.tudelft.simulation.dsol.SimRuntimeException
- when method cannot be scheduled.
-
addLaneBasedObject
Insert a laneBasedObject at the right place in the laneBasedObject list of this Lane. Register it in the network WITH the Lane id.- Parameters:
laneBasedObject
- LaneBasedObject; the laneBasedObject to add- Throws:
NetworkException
- when the position of the laneBasedObject is beyond (or before) the range of this Lane
-
removeLaneBasedObject
Remove a laneBasedObject from the laneBasedObject list of this Lane.- Parameters:
laneBasedObject
- LaneBasedObject; the laneBasedObject to remove.- Throws:
NetworkException
- when the laneBasedObject was not found on this Lane
-
getLaneBasedObjects
public final List<LaneBasedObject> getLaneBasedObjects(org.djunits.value.vdouble.scalar.Length minimumPosition, org.djunits.value.vdouble.scalar.Length maximumPosition) Retrieve the list of LaneBasedObjects of this Lane in the specified distance range. The resulting list is a defensive copy.- Parameters:
minimumPosition
- Length; the minimum distance on the Lane (inclusive)maximumPosition
- Length; the maximum distance on the Lane (inclusive)- Returns:
- List<LaneBasedObject>; list of the laneBasedObject in the specified range. This is a defensive copy.
-
getLaneBasedObjects
Retrieve the list of all LaneBasedObjects of this Lane. The resulting list is a defensive copy.- Returns:
- List<LaneBasedObject>; list of the laneBasedObjects, in ascending order for the location on the Lane
-
getLaneBasedObjectMap
Retrieve the list of LaneBasedObjects of this Lane. The resulting Map is a defensive copy.- Returns:
- SortedMap<Double, List<LaneBasedObject>>; all laneBasedObjects on this lane
-
position
public final org.djunits.value.vdouble.scalar.Length position(double fraction) Transform a fraction on the lane to a relative length (can be less than zero or larger than the lane length).- Parameters:
fraction
- double; fraction relative to the lane length.- Returns:
- Length; the longitudinal length corresponding to the fraction.
-
positionSI
public final double positionSI(double fraction) Transform a fraction on the lane to a relative length in SI units (can be less than zero or larger than the lane length).- Parameters:
fraction
- double; fraction relative to the lane length.- Returns:
- double; length corresponding to the fraction, in SI units.
-
fraction
public final double fraction(org.djunits.value.vdouble.scalar.Length position) Transform a position on the lane (can be less than zero or larger than the lane length) to a fraction.- Parameters:
position
- Length; relative length on the lane (may be less than zero or larger than the lane length).- Returns:
- fraction double; fraction relative to the lane length.
-
fractionSI
public final double fractionSI(double positionSI) Transform a position on the lane in SI units (can be less than zero or larger than the lane length) to a fraction.- Parameters:
positionSI
- double; relative length on the lane in SI units (may be less than zero or larger than the lane length).- Returns:
- double; fraction relative to the lane length.
-
getShape
public org.djutils.draw.line.Polygon2d getShape()- Specified by:
getShape
in interfaceSpatialObject
-
addGtu
Add a LaneBasedGtu to the list of this Lane.- Parameters:
gtu
- LaneBasedGtu; the GTU to addfractionalPosition
- double; the fractional position that the newly added GTU will have on this Lane- Returns:
- int; the rank that the newly added GTU has on this Lane (should be 0, except when the GTU enters this Lane due to a lane change operation)
- Throws:
GtuException
- when the fractionalPosition is outside the range 0..1, or the GTU is already registered on this Lane
-
addGtu
public final int addGtu(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Length longitudinalPosition) throws GtuException Add a LaneBasedGtu to the list of this Lane.- Parameters:
gtu
- LaneBasedGtu; the GTU to addlongitudinalPosition
- Length; the longitudinal position that the newly added GTU will have on this Lane- Returns:
- int; the rank that the newly added GTU has on this Lane (should be 0, except when the GTU enters this Lane due to a lane change operation)
- Throws:
GtuException
- when longitudinalPosition is negative or exceeds the length of this Lane
-
removeGtu
public final void removeGtu(LaneBasedGtu gtu, boolean removeFromParentLink, org.djunits.value.vdouble.scalar.Length position) Remove a GTU from the GTU list of this lane.- Parameters:
gtu
- LaneBasedGtu; the GTU to remove.removeFromParentLink
- boolean; when the GTU leaves the last lane of the parentLink of this Laneposition
- Length; last position of the GTU
-
getLastGtu
Get the last GTU on the lane, relative to a driving direction on this lane.- Returns:
- LaneBasedGtu; the last GTU on this lane in the given direction, or null if no GTU could be found.
- Throws:
GtuException
- when there is a problem with the position of the GTUs on the lane.
-
getFirstGtu
Get the first GTU on the lane, relative to a driving direction on this lane.- Returns:
- LaneBasedGtu; the first GTU on this lane in the given direction, or null if no GTU could be found.
- Throws:
GtuException
- when there is a problem with the position of the GTUs on the lane.
-
getGtuAhead
public final LaneBasedGtu getGtuAhead(org.djunits.value.vdouble.scalar.Length position, RelativePosition.Type relativePosition, org.djunits.value.vdouble.scalar.Time when) throws GtuException Get the first GTU where the relativePosition is in front of another GTU on the lane, in a driving direction on this lane, compared to the DESIGN LINE.- Parameters:
position
- Length; the position before which the relative position of a GTU will be searched.relativePosition
- RelativePosition.TYPE; the relative position we want to compare againstwhen
- Time; the time for which to evaluate the positions.- Returns:
- LaneBasedGtu; the first GTU before a position on this lane in the given direction, or null if no GTU could be found.
- Throws:
GtuException
- when there is a problem with the position of the GTUs on the lane.
-
getGtuBehind
public final LaneBasedGtu getGtuBehind(org.djunits.value.vdouble.scalar.Length position, RelativePosition.Type relativePosition, org.djunits.value.vdouble.scalar.Time when) throws GtuException Get the first GTU where the relativePosition is behind a certain position on the lane, in a driving direction on this lane, compared to the DESIGN LINE.- Parameters:
position
- Length; the position before which the relative position of a GTU will be searched.relativePosition
- RelativePosition.TYPE; the relative position of the GTU we are looking for.when
- Time; the time for which to evaluate the positions.- Returns:
- LaneBasedGtu; the first GTU after a position on this lane in the given direction, or null if no GTU could be found.
- Throws:
GtuException
- when there is a problem with the position of the GTUs on the lane.
-
getObjectAhead
Get the first object where the relativePosition is in front of a certain position on the lane, in a driving direction on this lane, compared to the DESIGN LINE. Perception should iterate over results from this method to see what is most limiting.- Parameters:
position
- Length; the position after which the relative position of an object will be searched.- Returns:
- List<LaneBasedObject>; the first object(s) before a position on this lane in the given direction, or null if no object could be found.
-
getObjectBehind
public final List<LaneBasedObject> getObjectBehind(org.djunits.value.vdouble.scalar.Length position) Get the first object where the relativePosition is behind of a certain position on the lane, in a driving direction on this lane, compared to the DESIGN LINE. Perception should iterate over results from this method to see what is most limiting.- Parameters:
position
- Length; the position after which the relative position of an object will be searched.- Returns:
- List<LaneBasedObject>; the first object(s) after a position on this lane in the given direction, or null if no object could be found.
-
nextLanes
NextLanes returns the successor lane(s) in the design line direction, if any exist.
The next lane(s) are cached, as it is too expensive to make the calculation every time. There are several possibilities: (1) Returning an empty set when there is no successor lane in the design direction or there is no longitudinal transfer possible to a successor lane in the design direction. (2) Returning a set with just one lane if the lateral position of the successor lane matches the lateral position of this lane (based on an overlap of the lateral positions of the two joining lanes of more than a certain percentage). (3) Multiple lanes in case the Node where the underlying Link for this Lane has multiple "outgoing" Links, and there are multiple lanes that match the lateral position of this lane.
The next lanes can differ per GTU type. For instance, a lane where cars and buses are allowed can have a next lane where only buses are allowed, forcing the cars to leave that lane.- Parameters:
gtuType
- the GTU type for which we return the next lanes, usenull
to return all next lanes and their design direction- Returns:
- set of Lanes following this lane for the given GTU type.
-
forceNextLanes
Forces the next lanes to be as specified. For specific GTU types, a subset of these lanes is taken.- Parameters:
lanes
- Set<Lane>; lanes to set as next lanes.
-
prevLanes
PrevLanes returns the predecessor lane(s) relative to the design line direction, if any exist.
The previous lane(s) are cached, as it is too expensive to make the calculation every time. There are several possibilities: (1) Returning an empty set when there is no predecessor lane relative to the design direction or there is no longitudinal transfer possible to a predecessor lane relative to the design direction. (2) Returning a set with just one lane if the lateral position of the predecessor lane matches the lateral position of this lane (based on an overlap of the lateral positions of the two joining lanes of more than a certain percentage). (3) Multiple lanes in case the Node where the underlying Link for this Lane has multiple "incoming" Links, and there are multiple lanes that match the lateral position of this lane.
The previous lanes can differ per GTU type. For instance, a lane where cars and buses are allowed can be preceded by a lane where only buses are allowed.- Parameters:
gtuType
- the GTU type for which we return the next lanes, usenull
to return all prev lanes and their design direction- Returns:
- set of Lanes following this lane for the given GTU type.
-
forcePrevLanes
Forces the previous lanes to be as specified. For specific GTU types, a subset of these lanes is taken.- Parameters:
lanes
- Set<Lane>; lanes to set as previous lanes.
-
accessibleAdjacentLanesPhysical
public final Set<Lane> accessibleAdjacentLanesPhysical(LateralDirectionality lateralDirection, GtuType gtuType) Determine the set of lanes to the left or to the right of this lane, which are accessible from this lane, or an empty set if no lane could be found. The method ignores all legal restrictions such as allowable directions and stripes.
A lane is called adjacent to another lane if the lateral edges are not more than a delta distance apart. This means that a lane that overlaps with another lane is not returned as an adjacent lane.
Note: LEFT and RIGHT are seen from the direction of the GTU, in its forward driving direction.- Parameters:
lateralDirection
- LateralDirectionality; LEFT or RIGHT.gtuType
- GtuType; the type of GTU for which to return the adjacent lanes.- Returns:
- the set of lanes that are accessible, or null if there is no lane that is accessible with a matching driving direction.
-
accessibleAdjacentLanesLegal
public final Set<Lane> accessibleAdjacentLanesLegal(LateralDirectionality lateralDirection, GtuType gtuType) Determine the set of lanes to the left or to the right of this lane, which are accessible from this lane, or an empty set if no lane could be found. The method takes the LongitidinalDirectionality of the lane into account. In other words, if we drive in the DIR_PLUS direction and look for a lane on the LEFT, and there is a lane but the Directionality of that lane is not DIR_PLUS or DIR_BOTH, it will not be included.
A lane is called adjacent to another lane if the lateral edges are not more than a delta distance apart. This means that a lane that overlaps with another lane is not returned as an adjacent lane.
Note: LEFT and RIGHT are seen from the direction of the GTU, in its forward driving direction.- Parameters:
lateralDirection
- LateralDirectionality; LEFT or RIGHT.gtuType
- GtuType; the type of GTU for which to return the adjacent lanes.- Returns:
- the set of lanes that are accessible, or null if there is no lane that is accessible with a matching driving direction.
-
getAdjacentLane
Returns one adjacent lane.- Parameters:
laneChangeDirection
- LateralDirectionality; lane change directiongtuType
- GtuType; GTU type.- Returns:
- Lane; adjacent lane,
null
if none
-
getSpeedLimit
public org.djunits.value.vdouble.scalar.Speed getSpeedLimit(GtuType gtuType) throws NetworkException Get the speed limit of this lane, which can differ per GTU type. E.g., cars might be allowed to drive 120 km/h and trucks 90 km/h.- Parameters:
gtuType
- GtuType; the GTU type to provide the speed limit for- Returns:
- the speedLimit.
- Throws:
NetworkException
- on network inconsistency
-
getLowestSpeedLimit
Get the lowest speed limit of this lane.- Returns:
- the lowest speedLimit.
- Throws:
NetworkException
- on network inconsistency
-
getHighestSpeedLimit
Get the highest speed limit of this lane.- Returns:
- the highest speedLimit.
- Throws:
NetworkException
- on network inconsistency
-
setSpeedLimit
Set the speed limit of this lane, which can differ per GTU type. Cars might be allowed to drive 120 km/h and trucks 90 km/h. If the speed limit is the same for all GTU types, GtuType.ALL will be used. This means that the settings can be used additive, or subtractive.
In additive use, do not set the speed limit for GtuType.ALL. Now, one by one, the allowed maximum speeds for each of the GTU Types have be added. Do this when there are few GTU types or the speed limits per TU type are very different.
In subtractive use, set the speed limit for GtuType.ALL to the most common one. Override the speed limit for certain GtuTypes to a different value. An example is a lane on a highway where all vehicles, except truck (CAR, BUS, MOTORCYCLE, etc.), can drive 120 km/h, but trucks are allowed only 90 km/h. In that case, set the speed limit for GtuType.ALL to 120 km/h, and for TRUCK to 90 km/h.- Parameters:
gtuType
- GtuType; the GTU type to provide the speed limit forspeedLimit
- Speed; the speed limit for this gtu type
-
removeSpeedLimit
Remove the set speed limit for a GtuType. If the speed limit for GtuType.ALL will be removed, there will not be a 'default' speed limit anymore. If the speed limit for a certain GtuType is removed, its speed limit will default to the speed limit of GtuType.ALL.
Note: if no speed limit is known for a GtuType, getSpeedLimit will throw a NetworkException when the speed limit is retrieved for that GtuType.- Parameters:
gtuType
- GtuType; the GTU type to provide the speed limit for
-
getType
-
getGtuList
- Returns:
- gtuList.
-
getGtuList
Returns the list of GTU's at the specified time.- Parameters:
time
- Time; time- Returns:
- list of GTU's at the specified times
-
numberOfGtus
public final int numberOfGtus()Returns the number of GTU's.- Returns:
- int; number of GTU's.
-
numberOfGtus
public final int numberOfGtus(org.djunits.value.vdouble.scalar.Time time) Returns the number of GTU's at specified time.- Parameters:
time
- Time; time- Returns:
- int; number of GTU's.
-
indexOfGtu
Returns the index of the given GTU, or -1 if not present.- Parameters:
gtu
- LaneBasedGtu; gtu to get the index of- Returns:
- int; index of the given GTU, or -1 if not present
-
indexOfGtu
Returns the index of the given GTU, or -1 if not present, at specified time.- Parameters:
gtu
- LaneBasedGtu; gtu to get the index oftime
- Time; time- Returns:
- int; index of the given GTU, or -1 if not present
-
getGtu
Returns the index'th GTU.- Parameters:
index
- int; index of the GTU- Returns:
- LaneBasedGtu; the index'th GTU
-
getGtu
Returns the index'th GTU at specified time.- Parameters:
index
- int; index of the GTUtime
- Time; time- Returns:
- LaneBasedGtu; the index'th GTU
-
coveredDistance
public final org.djunits.value.vdouble.scalar.Length coveredDistance(double fraction) Returns the covered distance driven to the given fractional position.- Parameters:
fraction
- double; fractional position- Returns:
- Length; covered distance driven to the given fractional position
-
remainingDistance
public final org.djunits.value.vdouble.scalar.Length remainingDistance(double fraction) Returns the remaining distance to be driven from the given fractional position.- Parameters:
fraction
- double; fractional position- Returns:
- Length; remaining distance to be driven from the given fractional position
-
fractionAtCoveredDistance
@Deprecated public final double fractionAtCoveredDistance(org.djunits.value.vdouble.scalar.Length distance) Deprecated.Returns the fraction along the design line for having covered the given distance.- Parameters:
distance
- Length; covered distance- Returns:
- double; fraction along the design line for having covered the given distance
-
toString
- Overrides:
toString
in classCrossSectionElement
-
hashCode
public int hashCode()- Overrides:
hashCode
in classCrossSectionElement
-
equals
- Overrides:
equals
in classCrossSectionElement
-