Class LaneBasedObjectIterable<H extends Headway,L extends LaneBasedObject>
java.lang.Object
org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable<H,U>
org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionIterable<H,L,java.lang.Boolean>
org.opentrafficsim.road.gtu.lane.perception.LaneBasedObjectIterable<H,L>
- Type Parameters:
H- headway typeL- lane based object type
- All Implemented Interfaces:
java.lang.Iterable<H>,PerceptionCollectable<H,L>,PerceptionIterable<H>
public abstract class LaneBasedObjectIterable<H extends Headway,L extends LaneBasedObject> extends AbstractPerceptionIterable<H,L,java.lang.Boolean>
Iterable that searches downstream or upstream for a certain type of lane based object.
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 16 feb. 2018
- 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
Constructors Constructor Description LaneBasedObjectIterable(LaneBasedGTU perceivingGtu, java.lang.Class<L> clazz, LaneRecord<?> root, Length initialPosition, boolean downstream, Length maxDistance, RelativePosition relativePosition, Route route)Constructor. -
Method Summary
Modifier and Type Method Description protected LengthgetDistance(L object, LaneRecord<?> record, Length position)Returns the distance to the object.protected AbstractPerceptionIterable.EntrygetNext(LaneRecord<?> record, Length position, java.lang.Boolean counter)Returns the next object(s) on the lane represented by the record.java.lang.StringtoString()Methods inherited from class org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionIterable
getDx, isDownstream, primaryIteratorMethods inherited from class org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable
collect, first, getGtu, isEmpty, iterator, perceive, underlying, underlyingWithDistanceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opentrafficsim.road.gtu.lane.perception.PerceptionCollectable
collect
-
Constructor Details
-
LaneBasedObjectIterable
public LaneBasedObjectIterable(LaneBasedGTU perceivingGtu, java.lang.Class<L> clazz, LaneRecord<?> root, Length initialPosition, boolean downstream, Length maxDistance, RelativePosition relativePosition, Route route)Constructor.- Parameters:
perceivingGtu- LaneBasedGTU; perceiving GTUclazz- Class<L>; class of lane based objects to returnroot- LaneRecord<?>; root recordinitialPosition- Length; initial positiondownstream- boolean; downstreammaxDistance- Length; max distance to searchrelativePosition- RelativePosition; relative positionroute- Route; route of the GTU, may benull
-
-
Method Details
-
getNext
protected AbstractPerceptionIterable.Entry getNext(LaneRecord<?> record, Length position, java.lang.Boolean counter)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<H extends Headway,L extends LaneBasedObject,java.lang.Boolean>- 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
-
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<H extends Headway,L extends LaneBasedObject,java.lang.Boolean>- 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
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-