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