View Javadoc
1   package org.opentrafficsim.kpi.sampling.data;
2   
3   import java.util.Optional;
4   
5   import org.djunits.value.vfloat.scalar.FloatSpeed;
6   import org.opentrafficsim.kpi.interfaces.GtuData;
7   
8   /**
9    * Reference speed for trajectories, as defined by the used GtuData.
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   */
18  public class ReferenceSpeed extends ExtendedDataSpeed<GtuData>
19  {
20  
21      /** Single instance. */
22      public static final ReferenceSpeed INSTANCE = new ReferenceSpeed();
23  
24      /**
25       * Constructor.
26       */
27      public ReferenceSpeed()
28      {
29          super("referenceSpeed", "Reference speed");
30      }
31  
32      @Override
33      public final Optional<FloatSpeed> getValue(final GtuData gtu)
34      {
35          return Optional.of(FloatSpeed.ofSI((float) gtu.getReferenceSpeed().si));
36      }
37  
38      @Override
39      public final String toString()
40      {
41          return "Reference Speed";
42      }
43  
44  }