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