Class LaneBasedObjectIterable<H extends Headway,L extends LaneBasedObject>

Type Parameters:
H - headway type
L - lane based object type
All Implemented Interfaces:
Iterable<H>, PerceptionCollectable<H,L>, PerceptionIterable<H>

public abstract class LaneBasedObjectIterable<H extends Headway,L extends LaneBasedObject> extends AbstractPerceptionIterable<H,L,Boolean>
Iterable that searches downstream or upstream for a certain type of lane based object.

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, Wouter Schakel
  • Constructor Details

    • LaneBasedObjectIterable

      public LaneBasedObjectIterable(LaneBasedGtu perceivingGtu, Class<L> clazz, LaneRecordInterface<?> root, org.djunits.value.vdouble.scalar.Length initialPosition, boolean downstream, org.djunits.value.vdouble.scalar.Length maxDistance, RelativePosition relativePosition, Route route)
      Constructor.
      Parameters:
      perceivingGtu - LaneBasedGtu; perceiving GTU
      clazz - Class<L>; class of lane based objects to return
      root - LaneRecord<?>; root record
      initialPosition - Length; initial position
      downstream - boolean; downstream
      maxDistance - Length; max distance to search
      relativePosition - RelativePosition; relative position
      route - Route; route of the GTU, may be null
  • Method Details

    • getNext

      protected AbstractPerceptionIterable<H,L,Boolean>.Entry getNext(LaneRecordInterface<?> record, org.djunits.value.vdouble.scalar.Length position, 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 be null for the first object(s). For following object(s) it is whatever value is given with the previous output Entry. Hence, this method maintains its own counting system.
      Specified by:
      getNext in class AbstractPerceptionIterable<H extends Headway,L extends LaneBasedObject,Boolean>
      Parameters:
      record - LaneRecord<?>; record representing the lane and direction
      position - Length; position to look beyond
      counter - C; counter
      Returns:
      next object(s) on the lane or null if none
    • getDistance

      protected final org.djunits.value.vdouble.scalar.Length getDistance(L object, LaneRecordInterface<?> record, org.djunits.value.vdouble.scalar.Length position)
      Returns the distance to the object. The position fed in to this method is directly taken from an Entry returned by getNext. The two methods need to be consistent with each other.
      Specified by:
      getDistance in class AbstractPerceptionIterable<H extends Headway,L extends LaneBasedObject,Boolean>
      Parameters:
      object - U; underlying object
      record - LaneRecord<?>; record representing the lane and direction
      position - Length; position of the object on the lane
      Returns:
      Length; distance to the object
    • toString

      public String toString()
      Overrides:
      toString in class Object