Class ExtendedDataType<T,O,S,G extends GtuData>

java.lang.Object
org.opentrafficsim.kpi.sampling.DataType<T,G>
org.opentrafficsim.kpi.sampling.data.ExtendedDataType<T,O,S,G>
Type Parameters:
T - type of value
O - output type
S - storage type
G - GTU data type
All Implemented Interfaces:
Identifiable
Direct Known Subclasses:
ExtendedDataFloat, ExtendedDataList, ExtendedDataNumber

public abstract class ExtendedDataType<T,O,S,G extends GtuData> extends DataType<T,G>
Type class to define different types of data by which trajectories can be extended beyond the basic t, x, v, a. Extend this class to define a new data type. Extended data types are defined with 3 generic types. <T> is the type of a single scalar value, <O> is the output type of the whole trajectory, e.g. List<Double> or FloatLengthVector, and <S> is the storage type by which the data is gathered, e.g. List<Double> or float[].

Copyright (c) 2013-2026 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 Summary

    Constructors
    Constructor
    Description
    ExtendedDataType(String id, String description, Class<T> type)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract O
    convert(S storage, int size)
    Convert storage type to output type.
    abstract T
    getOutputValue(O output, int index)
    Returns a specific output value.
    abstract T
    getStorageValue(S storage, int index)
    Returns a specific storage value.
    abstract Optional<T>
    getValue(G gtu)
    Returns the current value of the GTU.
    abstract S
    Returns an initial storage object.
    <AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>, R extends org.djunits.value.vdouble.scalar.base.DoubleScalarRel<RU, R>, RA extends org.djunits.value.vdouble.scalar.base.DoubleScalarRelWithAbs<AU, A, RU, RA>, A extends org.djunits.value.vdouble.scalar.base.DoubleScalarAbs<AU, A, RU, RA>, FR extends org.djunits.value.vfloat.scalar.base.FloatScalarRel<RU, FR>, FRA extends org.djunits.value.vfloat.scalar.base.FloatScalarRelWithAbs<AU, FA, RU, FRA>, FA extends org.djunits.value.vfloat.scalar.base.FloatScalarAbs<AU, FA, RU, FRA>>
    T
    interpolate(T value0, T value1, double f)
    Interpolate value between two measured values.
    abstract T
    Parses a stored string representation to original type.
    abstract S
    setValue(S storage, int index, T value)
    Returns an updated list/array/vector of the storage type, including a new value at given index.
     

    Methods inherited from class org.opentrafficsim.kpi.sampling.DataType

    equals, getDescription, getId, getType, hashCode

    Methods inherited from class java.lang.Object

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

    • ExtendedDataType

      public ExtendedDataType(String id, String description, Class<T> type)
      Constructor.
      Parameters:
      id - id
      description - description
      type - type class
  • Method Details

    • getValue

      public abstract Optional<T> getValue(G gtu)
      Returns the current value of the GTU.
      Specified by:
      getValue in class DataType<T,G extends GtuData>
      Parameters:
      gtu - GTU
      Returns:
      current value of the GTU
    • setValue

      public abstract S setValue(S storage, int index, T value)
      Returns an updated list/array/vector of the storage type, including a new value at given index.
      Parameters:
      storage - storage
      index - index to store next value
      value - value to add
      Returns:
      updated list/array/vector of the storage type, including a new value at given index
    • getOutputValue

      public abstract T getOutputValue(O output, int index)
      Returns a specific output value. This is used to store extended data types as generic file, i.e. text file.
      Parameters:
      output - output
      index - index of value to return
      Returns:
      the i'th output value o
    • getStorageValue

      public abstract T getStorageValue(S storage, int index)
      Returns a specific storage value. This is used to bypass conversion to the output type when trajectories are cut.
      Parameters:
      storage - storage
      index - index of value to return
      Returns:
      the i'th output value
    • initializeStorage

      public abstract S initializeStorage()
      Returns an initial storage object.
      Returns:
      initial storage object
    • convert

      public abstract O convert(S storage, int size)
      Convert storage type to output type.
      Parameters:
      storage - stored data
      size - size of trajectory
      Returns:
      converted output
    • parseValue

      public abstract T parseValue(String string)
      Parses a stored string representation to original type.
      Parameters:
      string - stored string representation
      Returns:
      value in original type
    • interpolate

      public <AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>, R extends org.djunits.value.vdouble.scalar.base.DoubleScalarRel<RU, R>, RA extends org.djunits.value.vdouble.scalar.base.DoubleScalarRelWithAbs<AU, A, RU, RA>, A extends org.djunits.value.vdouble.scalar.base.DoubleScalarAbs<AU, A, RU, RA>, FR extends org.djunits.value.vfloat.scalar.base.FloatScalarRel<RU, FR>, FRA extends org.djunits.value.vfloat.scalar.base.FloatScalarRelWithAbs<AU, FA, RU, FRA>, FA extends org.djunits.value.vfloat.scalar.base.FloatScalarAbs<AU, FA, RU, FRA>> T interpolate(T value0, T value1, double f)
      Interpolate value between two measured values. The default implementation takes a linear interpolation over time for DoubleScalar, FloatScalar, Double and Float, or the closest value in time otherwise.
      Type Parameters:
      AU - unit of value, if values are DoubleScalar
      RU - the corresponding relative unit
      R - the relative double type
      RA - the relative double type belonging to the absolute type
      A - the absolute double type
      FR - the relative float type
      FRA - the relative float type belonging to the absolute type
      FA - the absolute float type
      Parameters:
      value0 - first value
      value1 - second value
      f - interpolation fraction
      Returns:
      interpolated value
    • toString

      public String toString()
      Overrides:
      toString in class Object