View Javadoc
1   package org.opentrafficsim.kpi.sampling.data;
2   
3   import org.djunits.unit.SpeedUnit;
4   import org.djunits.value.ValueRuntimeException;
5   import org.djunits.value.storage.StorageType;
6   import org.djunits.value.vfloat.scalar.FloatSpeed;
7   import org.djunits.value.vfloat.vector.FloatSpeedVector;
8   import org.djunits.value.vfloat.vector.base.FloatVector;
9   import org.opentrafficsim.kpi.interfaces.GtuData;
10  
11  /**
12   * Extended data type for speed values.
13   * <p>
14   * Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
16   * </p>
17   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
18   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
19   * @author <a href="https://dittlab.tudelft.nl">Wouter Schakel</a>
20   * @param <G> gtu data type
21   */
22  public abstract class ExtendedDataSpeed<G extends GtuData>
23          extends ExtendedDataFloat<SpeedUnit, FloatSpeed, FloatSpeedVector, G>
24  {
25  
26      /**
27       * Constructor setting the id.
28       * @param id String; id
29       * @param description String; description
30       */
31      public ExtendedDataSpeed(final String id, final String description)
32      {
33          super(id, description, FloatSpeed.class);
34      }
35  
36      /** {@inheritDoc} */
37      @Override
38      protected final FloatSpeed convertValue(final float value)
39      {
40          return FloatSpeed.instantiateSI(value);
41      }
42  
43      /** {@inheritDoc} */
44      @Override
45      protected final FloatSpeedVector convert(final float[] storage) throws ValueRuntimeException
46      {
47          return FloatVector.instantiate(storage, SpeedUnit.SI, StorageType.DENSE);
48      }
49  
50      /** {@inheritDoc} */
51      @Override
52      public FloatSpeed interpolate(final FloatSpeed value0, final FloatSpeed value1, final double f)
53      {
54          return FloatSpeed.interpolate(value0, value1, (float) f);
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      public FloatSpeed parseValue(final String string)
60      {
61          return FloatSpeed.instantiateSI(Float.valueOf(string));
62      }
63  
64  }