LaneRecordInterface.java

  1. package org.opentrafficsim.road.gtu.lane.perception;

  2. import java.util.List;

  3. import org.djunits.value.vdouble.scalar.Length;
  4. import org.opentrafficsim.road.network.lane.Lane;

  5. /**
  6.  * Interface representing a lane for search algorithms, in particular PerceptionIterable.
  7.  * <p>
  8.  * Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  9.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  10.  * </p>
  11.  * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
  12.  * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
  13.  * @author <a href="https://dittlab.tudelft.nl">Wouter Schakel</a>\
  14.  * @param <R> lane record type
  15.  */
  16. public interface LaneRecordInterface<R extends LaneRecordInterface<R>>
  17. {

  18.     /**
  19.      * Returns a list of next lanes.
  20.      * @return List; list of next lanes
  21.      */
  22.     List<? extends R> getNext();

  23.     /**
  24.      * Returns a list of previous lanes.
  25.      * @return List; list of previous lanes
  26.      */
  27.     List<? extends R> getPrev();

  28.     /**
  29.      * Returns the distance from a reference to the start of this lane, negative for upstream distance.
  30.      * @return Length; the distance from a reference to the start of this lane, negative for upstream distance
  31.      */
  32.     Length getStartDistance();

  33.     /**
  34.      * Returns the length of the lane.
  35.      * @return Length; length of the lane.
  36.      */
  37.     Length getLength();

  38.     /**
  39.      * Returns the lane.
  40.      * @return Lane lane;
  41.      */
  42.     Lane getLane();

  43.     /**
  44.      * Returns the distance from the reference to the given location.
  45.      * @param position Length; position on the lane
  46.      * @return Length; distance from the reference to the given location
  47.      */
  48.     default Length getDistanceToPosition(final Length position)
  49.     {
  50.         return Length.instantiateSI(getStartDistance().si + position.si);
  51.     }

  52.     /**
  53.      * Returns whether the record is part of the downstream branch. This means the GTU can potentially get here and the lane is
  54.      * not upstream or on the other branch upstream of a merge. Default implementation returns {@code true}.
  55.      * @return Boolean; whether the record is part of the downstream branch
  56.      */
  57.     default boolean isDownstreamBranch()
  58.     {
  59.         return true;
  60.     }

  61. }