View Javadoc
1   package org.opentrafficsim.kpi.sampling.data;
2   
3   import org.djunits.unit.AbsoluteLinearUnit;
4   import org.djunits.unit.SpeedUnit;
5   import org.djunits.unit.Unit;
6   import org.djunits.value.StorageType;
7   import org.djunits.value.ValueException;
8   import org.djunits.value.vfloat.scalar.FloatSpeed;
9   import org.djunits.value.vfloat.vector.FloatSpeedVector;
10  import org.opentrafficsim.kpi.interfaces.GtuDataInterface;
11  
12  /**
13   * Extended data type for speed values.
14   * <p>
15   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
16   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
17   * <p>
18   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 21 mrt. 2017 <br>
19   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
20   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
21   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
22   * @param <G> gtu data type
23   */
24  public abstract class ExtendedDataTypeSpeed<G extends GtuDataInterface>
25          extends ExtendedDataTypeFloat<SpeedUnit, FloatSpeed, FloatSpeedVector, G>
26  {
27  
28      /**
29       * Constructor setting the id.
30       * @param id String; id
31       */
32      public ExtendedDataTypeSpeed(String id)
33      {
34          super(id);
35      }
36  
37      /** {@inheritDoc} */
38      @Override
39      protected final FloatSpeed convertValue(final float value)
40      {
41          return FloatSpeed.createSI(value);
42      }
43  
44      /** {@inheritDoc} */
45      @Override
46      protected final FloatSpeedVector convert(final float[] storage) throws ValueException
47      {
48          return new FloatSpeedVector(storage, SpeedUnit.SI, StorageType.DENSE);
49      }
50  
51      /** {@inheritDoc} */
52      @Override
53      public <AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>> FloatSpeed interpolate(final FloatSpeed value0,
54              final FloatSpeed value1, final double f)
55      {
56          return FloatSpeed.interpolate(value0, value1, (float) f);
57      }
58  
59  }