AbstractHeadwayLaneBasedObject.java

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

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

  5. /**
  6.  * Lane based object headway with constructors for stationary information.
  7.  * <p>
  8.  * Copyright (c) 2013-2024 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://github.com/peter-knoppers">Peter Knoppers</a>
  13.  * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
  14.  */
  15. public abstract class AbstractHeadwayLaneBasedObject extends AbstractHeadwayCopy implements HeadwayLaneBasedObject
  16. {

  17.     /** */
  18.     private static final long serialVersionUID = 20190515L;

  19.     /** Lane. */
  20.     private final Lane lane;

  21.     /**
  22.      * Construct a new Headway information object, for a non-moving object parallel with us.
  23.      * @param objectType the perceived object type, can be null if object type unknown.
  24.      * @param id the id of the object for comparison purposes, can not be null.
  25.      * @param overlapFront the front-front distance to the other object; if this constructor is used, this value cannot be null.
  26.      * @param overlap the 'center' overlap with the other object; if this constructor is used, this value cannot be null.
  27.      * @param overlapRear the rear-rear distance to the other object; if this constructor is used, this value cannot be null.
  28.      * @param length if this constructor is used, length cannot be null.
  29.      * @param lane the lane.
  30.      * @throws GtuException when id is null, or parameters are inconsistent
  31.      */
  32.     public AbstractHeadwayLaneBasedObject(final ObjectType objectType, final String id, final Length overlapFront,
  33.             final Length overlap, final Length overlapRear, final Length length, final Lane lane) throws GtuException
  34.     {
  35.         super(objectType, id, overlapFront, overlap, overlapRear, length);
  36.         this.lane = lane;
  37.     }

  38.     /**
  39.      * Construct a new Headway information object, for a non-moving object parallel with us.
  40.      * @param objectType the perceived object type, can be null if object type unknown.
  41.      * @param id the id of the object for comparison purposes, can not be null.
  42.      * @param overlapFront the front-front distance to the other object; if this constructor is used, this value cannot be null.
  43.      * @param overlap the 'center' overlap with the other object; if this constructor is used, this value cannot be null.
  44.      * @param overlapRear the rear-rear distance to the other object; if this constructor is used, this value cannot be null.
  45.      * @param lane the lane.
  46.      * @throws GtuException when id is null, or parameters are inconsistent
  47.      */
  48.     public AbstractHeadwayLaneBasedObject(final ObjectType objectType, final String id, final Length overlapFront,
  49.             final Length overlap, final Length overlapRear, final Lane lane) throws GtuException
  50.     {
  51.         super(objectType, id, overlapFront, overlap, overlapRear);
  52.         this.lane = lane;
  53.     }

  54.     /**
  55.      * Construct a new Headway information object, for a non-moving object ahead of us or behind us.
  56.      * @param objectType the perceived object type, can be null if object type unknown.
  57.      * @param id the id of the object for comparison purposes, can not be null.
  58.      * @param distance if this constructor is used, distance cannot be null.
  59.      * @param length if this constructor is used, length cannot be null.
  60.      * @param lane the lane.
  61.      * @throws GtuException when id is null, or parameters are inconsistent
  62.      */
  63.     public AbstractHeadwayLaneBasedObject(final ObjectType objectType, final String id, final Length distance,
  64.             final Length length, final Lane lane) throws GtuException
  65.     {
  66.         super(objectType, id, distance, length);
  67.         this.lane = lane;
  68.     }

  69.     /**
  70.      * Construct a new Headway information object, for a non-moving object ahead of us or behind us.
  71.      * @param objectType the perceived object type, can be null if object type unknown.
  72.      * @param id the id of the object for comparison purposes, can not be null.
  73.      * @param distance if this constructor is used, distance cannot be null.
  74.      * @param lane the lane.
  75.      * @throws GtuException when id is null, or parameters are inconsistent
  76.      */
  77.     public AbstractHeadwayLaneBasedObject(final ObjectType objectType, final String id, final Length distance, final Lane lane)
  78.             throws GtuException
  79.     {
  80.         super(objectType, id, distance);
  81.         this.lane = lane;
  82.     }

  83.     @Override
  84.     public Lane getLane()
  85.     {
  86.         return this.lane;
  87.     }

  88. }