Class UpstreamNeighborsIterable
java.lang.Object
org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable<H,U>
org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionIterable<HeadwayGtu,LaneBasedGtu,Integer>
org.opentrafficsim.road.gtu.lane.perception.UpstreamNeighborsIterable
- All Implemented Interfaces:
Iterable<HeadwayGtu>,PerceptionCollectable<HeadwayGtu,,LaneBasedGtu> PerceptionIterable<HeadwayGtu>
public class UpstreamNeighborsIterable
extends AbstractPerceptionIterable<HeadwayGtu,LaneBasedGtu,Integer>
Iterable to find upstream GTU's.
Copyright (c) 2013-2023 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, Wouter Schakel
-
Nested Class Summary
Nested classes/interfaces inherited from class org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionIterable
AbstractPerceptionIterable.EntryNested classes/interfaces inherited from class org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable
AbstractPerceptionReiterable.PerceptionIterator, AbstractPerceptionReiterable.PrimaryIteratorEntryNested classes/interfaces inherited from interface org.opentrafficsim.road.gtu.lane.perception.PerceptionCollectable
PerceptionCollectable.Intermediate<I>, PerceptionCollectable.PerceptionAccumulator<U,I>, PerceptionCollectable.PerceptionCollector<C, U, I>, PerceptionCollectable.PerceptionFinalizer<C, I>, PerceptionCollectable.UnderlyingDistance<U> -
Constructor Summary
ConstructorsConstructorDescriptionUpstreamNeighborsIterable(LaneBasedGtu perceivingGtu, LaneRecordInterface<?> root, Length initialPosition, Length maxDistance, RelativePosition relativePosition, HeadwayGtuType headwayGtuType, RelativeLane lane) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected LengthgetDistance(LaneBasedGtu object, LaneRecordInterface<?> record, Length position) Returns the distance to the object.protected AbstractPerceptionIterable<HeadwayGtu,LaneBasedGtu, Integer>.Entry getNext(LaneRecordInterface<?> record, Length position, Integer counter) Returns the next object(s) on the lane represented by the record.perceive(LaneBasedGtu perceivingGtu, LaneBasedGtu object, Length distance) Returns a perceived version of the underlying object.Methods inherited from class org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionIterable
getDx, isDownstream, isOnRoute, primaryIteratorMethods inherited from class org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable
addNext, assureNext, collect, first, getGtu, getPrimaryIterator, isEmpty, iterator, underlying, underlyingWithDistanceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.opentrafficsim.road.gtu.lane.perception.PerceptionCollectable
collect
-
Constructor Details
-
UpstreamNeighborsIterable
public UpstreamNeighborsIterable(LaneBasedGtu perceivingGtu, LaneRecordInterface<?> root, Length initialPosition, Length maxDistance, RelativePosition relativePosition, HeadwayGtuType headwayGtuType, RelativeLane lane) Constructor.- Parameters:
perceivingGtu- LaneBasedGtu; perceiving GTUroot- LaneRecord<?>; root recordinitialPosition- Length; position on the root recordmaxDistance- Length; maximum distance to searchrelativePosition- RelativePosition; position to which distance are calculated by subclassesheadwayGtuType- HeadwayGtuType; type of HeadwayGtu to returnlane- RelativeLane; relative lane (used for a left/right distinction to prevent dead-locks)
-
-
Method Details
-
getNext
protected AbstractPerceptionIterable<HeadwayGtu,LaneBasedGtu, getNextInteger>.Entry (LaneRecordInterface<?> record, Length position, Integer counter) throws GtuException Returns the next object(s) on the lane represented by the record. This should only consider objects on the given lane. This method should not check the distance towards objects with the maximum distance. The counter will benullfor the first object(s). For following object(s) it is whatever value is given with the previous outputEntry. Hence, this method maintains its own counting system.- Specified by:
getNextin classAbstractPerceptionIterable<HeadwayGtu,LaneBasedGtu, Integer> - Parameters:
record- LaneRecord<?>; record representing the lane and directionposition- Length; position to look beyondcounter- C; counter- Returns:
- next object(s) on the lane or
nullif none - Throws:
GtuException- on any exception in the process
-
getDistance
Returns the distance to the object. The position fed in to this method is directly taken from anEntryreturned bygetNext. The two methods need to be consistent with each other.- Specified by:
getDistancein classAbstractPerceptionIterable<HeadwayGtu,LaneBasedGtu, Integer> - Parameters:
object- U; underlying objectrecord- LaneRecord<?>; record representing the lane and directionposition- Length; position of the object on the lane- Returns:
- Length; distance to the object
-
perceive
public HeadwayGtu perceive(LaneBasedGtu perceivingGtu, LaneBasedGtu object, Length distance) throws GtuException, org.opentrafficsim.base.parameters.ParameterException Returns a perceived version of the underlying object.- Specified by:
perceivein classAbstractPerceptionReiterable<HeadwayGtu,LaneBasedGtu> - Parameters:
perceivingGtu- LaneBasedGtu; perceiving GTUobject- U; underlying objectdistance- Length; distance to the object- Returns:
- H; perceived version of the underlying object
- Throws:
GtuException- on exceptionorg.opentrafficsim.base.parameters.ParameterException- on invalid parameter value or missing parameter
-