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