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 valueO- output typeS- storage typeG- GTU data type
- All Implemented Interfaces:
Identifiable
- Direct Known Subclasses:
ExtendedDataFloat,ExtendedDataList,ExtendedDataNumber
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 -
Method Summary
Modifier and TypeMethodDescriptionabstract OConvert storage type to output type.abstract TgetOutputValue(O output, int index) Returns a specific output value.abstract TgetStorageValue(S storage, int index) Returns a specific storage value.Returns the current value of the GTU.abstract SReturns 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>>
Tinterpolate(T value0, T value1, double f) Interpolate value between two measured values.abstract TparseValue(String string) Parses a stored string representation to original type.abstract SReturns an updated list/array/vector of the storage type, including a new value at given index.toString()
-
Constructor Details
-
ExtendedDataType
Constructor.- Parameters:
id- iddescription- descriptiontype- type class
-
-
Method Details
-
getValue
Returns the current value of the GTU. -
setValue
Returns an updated list/array/vector of the storage type, including a new value at given index.- Parameters:
storage- storageindex- index to store next valuevalue- value to add- Returns:
- updated list/array/vector of the storage type, including a new value at given index
-
getOutputValue
Returns a specific output value. This is used to store extended data types as generic file, i.e. text file.- Parameters:
output- outputindex- index of value to return- Returns:
- the i'th output value o
-
getStorageValue
Returns a specific storage value. This is used to bypass conversion to the output type when trajectories are cut.- Parameters:
storage- storageindex- index of value to return- Returns:
- the i'th output value
-
initializeStorage
Returns an initial storage object.- Returns:
- initial storage object
-
convert
Convert storage type to output type.- Parameters:
storage- stored datasize- size of trajectory- Returns:
- converted output
-
parseValue
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>, T interpolateRU 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 value0, T value1, double f) Interpolate value between two measured values. The default implementation takes a linear interpolation over time forDoubleScalar,FloatScalar,DoubleandFloat, or the closest value in time otherwise.- Type Parameters:
AU- unit of value, if values areDoubleScalarRU- the corresponding relative unitR- the relative double typeRA- the relative double type belonging to the absolute typeA- the absolute double typeFR- the relative float typeFRA- the relative float type belonging to the absolute typeFA- the absolute float type- Parameters:
value0- first valuevalue1- second valuef- interpolation fraction- Returns:
- interpolated value
-
toString
-