View Javadoc
1   package org.opentrafficsim.kpi.sampling.data;
2   
3   import org.djunits.unit.LengthUnit;
4   import org.djunits.value.vfloat.scalar.FloatLength;
5   import org.djunits.value.vfloat.vector.FloatLengthVector;
6   import org.opentrafficsim.kpi.interfaces.GtuData;
7   
8   /**
9    * Extended data type for length 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 ExtendedDataLength<G extends GtuData>
20          extends ExtendedDataFloat<LengthUnit, FloatLength, FloatLengthVector, G>
21  {
22  
23      /**
24       * Constructor.
25       * @param id id
26       * @param description description
27       */
28      public ExtendedDataLength(final String id, final String description)
29      {
30          super(id, description, FloatLength.class);
31      }
32  
33      @Override
34      protected final FloatLength convertValue(final float value)
35      {
36          return FloatLength.instantiateSI(value);
37      }
38  
39      @Override
40      protected final FloatLengthVector convert(final float[] storage)
41      {
42          return new FloatLengthVector(storage, LengthUnit.SI);
43      }
44  
45      @Override
46      public FloatLength interpolate(final FloatLength value0, final FloatLength value1, final double f)
47      {
48          return FloatLength.interpolate(value0, value1, (float) f);
49      }
50  
51      @Override
52      public FloatLength parseValue(final String string)
53      {
54          return FloatLength.instantiateSI(Float.valueOf(string));
55      }
56  
57  }