Class SpeedLimitProspect

java.lang.Object
org.opentrafficsim.road.network.speed.SpeedLimitProspect
All Implemented Interfaces:
Serializable

public class SpeedLimitProspect extends Object implements Serializable
Prospect of speed limits ahead, both legal and otherwise (e.g. curve, speed bump).

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, Wouter Schakel
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    SpeedLimitProspect(org.djunits.value.vdouble.scalar.Length odometer)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    final <T> void
    addSpeedInfo(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<T> speedLimitType, T speedInfo, Object source)
    Sets the speed info of a speed limit type.
    final <T> SpeedLimitInfo
    buildSpeedLimitInfo(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<T> speedLimitType)
    Builds speed limit info with only MAX_VEHICLE_SPEED and the given speed limit type, where the speed info is obtained at the given distance.
    final boolean
    Returns whether the given source is already added in the prospect.
    final boolean
    Returns whether the given source is already removed in the prospect.
    final List<org.djunits.value.vdouble.scalar.Length>
    Returns the distances at which a change in the prospect is present in order (upstream first).
    final List<org.djunits.value.vdouble.scalar.Length>
    getDistances(SpeedLimitType<?> speedLimitType)
    Returns the distances at which a change of the given speed limit type in the prospect is present in order (most upstream first).
    final List<org.djunits.value.vdouble.scalar.Length>
    Returns the downstream distances at which a change of the given speed limit type in the prospect is present in order (most upstream first).
    final org.djunits.value.vdouble.scalar.Length
    Returns the odometer value at which the last update was performed.
    final <T> T
    getSpeedInfoChange(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<T> speedLimitType)
    Returns the speed info of given speed limit type where it changed.
    getSpeedLimitInfo(org.djunits.value.vdouble.scalar.Length distance)
    Returns the speed info at a given location.
    getSpeedLimitInfo(org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Duration time)
    Returns the speed info at a location following an acceleration over some duration.
    final List<org.djunits.value.vdouble.scalar.Length>
    Returns the upstream distances at which a change of the given speed limit type in the prospect is present in order (most upstream first).
    final void
    removeSpeedInfo(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<?> speedLimitType, Object source)
    Removes the speed info of a speed limit type.
    final boolean
    speedInfoChanged(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<?> speedLimitType)
    Returns whether the given speed limit type is changed at the given distance.
    final String
    void
    update(org.djunits.value.vdouble.scalar.Length newOdometer)
    Updates the distance values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SpeedLimitProspect

      public SpeedLimitProspect(org.djunits.value.vdouble.scalar.Length odometer)
      Constructor.
      Parameters:
      odometer - Length; odometer value
  • Method Details

    • update

      public void update(org.djunits.value.vdouble.scalar.Length newOdometer)
      Updates the distance values.
      Parameters:
      newOdometer - Length; odometer value
    • containsAddSource

      public final boolean containsAddSource(Object source)
      Returns whether the given source is already added in the prospect.
      Parameters:
      source - Object; source
      Returns:
      whether the given source is already added in the prospect
    • containsRemoveSource

      public final boolean containsRemoveSource(Object source)
      Returns whether the given source is already removed in the prospect.
      Parameters:
      source - Object; source
      Returns:
      whether the given source is already removed in the prospect
    • getOdometer

      public final org.djunits.value.vdouble.scalar.Length getOdometer()
      Returns the odometer value at which the last update was performed.
      Returns:
      Length; odometer value at which the last update was performed
    • addSpeedInfo

      public final <T> void addSpeedInfo(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<T> speedLimitType, T speedInfo, Object source)
      Sets the speed info of a speed limit type.
      Type Parameters:
      T - class of speed info
      Parameters:
      distance - Length; location to set info for a speed limit type
      speedLimitType - SpeedLimitType<T>; speed limit type to set the info for
      speedInfo - T; speed info to set
      source - Object; source object
      Throws:
      IllegalStateException - if speed info for a specific speed limit type is set or removed twice at the same distance
      IllegalStateException - if speed info for a specific speed limit type is set twice with negative distance
      NullPointerException - if any input is null
    • removeSpeedInfo

      public final void removeSpeedInfo(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<?> speedLimitType, Object source)
      Removes the speed info of a speed limit type.
      Parameters:
      distance - Length; distance to remove speed info of a speed limit type
      speedLimitType - SpeedLimitType<?>; speed limit type to remove speed info of
      source - Object; source object
      Throws:
      IllegalStateException - if speed info for a specific speed limit type is set or removed twice at the same distance
      IllegalArgumentException - if the speed limit type is MAX_VEHICLE_SPEED
      IllegalArgumentException - if the distance is negative
      NullPointerException - if any input is null
    • getDistances

      public final List<org.djunits.value.vdouble.scalar.Length> getDistances()
      Returns the distances at which a change in the prospect is present in order (upstream first). If multiple changes are present at the same distance, only one distance is returned in the list.
      Returns:
      distances at which a change in the prospect is present in order (upstream first)
    • getDistances

      public final List<org.djunits.value.vdouble.scalar.Length> getDistances(SpeedLimitType<?> speedLimitType)
      Returns the distances at which a change of the given speed limit type in the prospect is present in order (most upstream first). If multiple changes are present at the same distance, only one distance is returned in the list.
      Parameters:
      speedLimitType - SpeedLimitType<?>; speed limit type to get the distances of
      Returns:
      distances at which a change of the given speed limit type in the prospect is present in order
    • getUpstreamDistances

      public final List<org.djunits.value.vdouble.scalar.Length> getUpstreamDistances(SpeedLimitType<?> speedLimitType)
      Returns the upstream distances at which a change of the given speed limit type in the prospect is present in order (most upstream first). If multiple changes are present at the same distance, only one distance is returned in the list.
      Parameters:
      speedLimitType - SpeedLimitType<?>; speed limit type to get the distances of
      Returns:
      distances at which a change of the given speed limit type in the prospect is present in order
    • getDownstreamDistances

      public final List<org.djunits.value.vdouble.scalar.Length> getDownstreamDistances(SpeedLimitType<?> speedLimitType)
      Returns the downstream distances at which a change of the given speed limit type in the prospect is present in order (most upstream first). If multiple changes are present at the same distance, only one distance is returned in the list.
      Parameters:
      speedLimitType - SpeedLimitType<?>; speed limit type to get the distances of
      Returns:
      distances at which a change of the given speed limit type in the prospect is present in order
    • speedInfoChanged

      public final boolean speedInfoChanged(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<?> speedLimitType)
      Returns whether the given speed limit type is changed at the given distance.
      Parameters:
      distance - Length; distance to check
      speedLimitType - SpeedLimitType<?>; speed limit type to check
      Returns:
      whether the given speed limit type is changed at the given distance
      Throws:
      NullPointerException - if distance is null
    • getSpeedInfoChange

      public final <T> T getSpeedInfoChange(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<T> speedLimitType)
      Returns the speed info of given speed limit type where it changed. If the change was removing the speed limit type (e.g. end of corner), then null is returned.
      Type Parameters:
      T - class of the speed limit type info
      Parameters:
      distance - Length; distance where the info changed
      speedLimitType - SpeedLimitType<T>; speed limit type
      Returns:
      speed info of given speed limit type where it changed, null if speed limit type is removed
      Throws:
      IllegalArgumentException - if the speed info did not change at the given distance for the speed limit type
    • getSpeedLimitInfo

      public final SpeedLimitInfo getSpeedLimitInfo(org.djunits.value.vdouble.scalar.Length distance)
      Returns the speed info at a given location.
      Parameters:
      distance - Length; where to get the speed info
      Returns:
      speed info at a given distance
      Throws:
      NullPointerException - if distance is null
    • getSpeedLimitInfo

      public final SpeedLimitInfo getSpeedLimitInfo(org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Duration time)
      Returns the speed info at a location following an acceleration over some duration.
      Parameters:
      speed - Speed; current speed
      acceleration - Acceleration; acceleration to apply
      time - Duration; duration of acceleration
      Returns:
      speed info at a given distance
      Throws:
      NullPointerException - if any input is null
    • buildSpeedLimitInfo

      public final <T> SpeedLimitInfo buildSpeedLimitInfo(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<T> speedLimitType)
      Builds speed limit info with only MAX_VEHICLE_SPEED and the given speed limit type, where the speed info is obtained at the given distance.
      Type Parameters:
      T - class of speed info of given speed limit type
      Parameters:
      distance - Length; distance to get the speed info at
      speedLimitType - SpeedLimitType<T>; speed limit type of which to include the info
      Returns:
      speed limit info with only MAX_VEHICLE_SPEED and the given speed limit type
    • toString

      public final String toString()
      Overrides:
      toString in class Object