View Javadoc
1   package org.opentrafficsim.kpi.sampling.indicator;
2   
3   import java.util.List;
4   
5   import org.djunits.unit.DurationUnit;
6   import org.djunits.value.vdouble.scalar.Duration;
7   import org.djunits.value.vdouble.scalar.Time;
8   import org.opentrafficsim.kpi.sampling.Query;
9   import org.opentrafficsim.kpi.sampling.TrajectoryGroup;
10  
11  /**
12   * Inverse of mean speed.
13   * <p>
14   * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
16   * <p>
17   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 1 okt. 2016 <br>
18   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
19   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
20   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
21   */
22  public class MeanTravelTimePerDistance extends AbstractIndicator<Duration>
23  {
24  
25      /** Mean speed indicator. */
26      private final MeanSpeed meanSpeed;
27  
28      /**
29       * @param meanSpeed mean speed indicator
30       */
31      public MeanTravelTimePerDistance(final MeanSpeed meanSpeed)
32      {
33          this.meanSpeed = meanSpeed;
34      }
35  
36      /** {@inheritDoc} */
37      @Override
38      protected Duration calculate(final Query query, final Time startTime, final Time endTime,
39              final List<TrajectoryGroup> trajectoryGroups)
40      {
41          return new Duration(1.0 / this.meanSpeed.getValue(query, startTime, endTime, trajectoryGroups).si, DurationUnit.SI);
42      }
43  
44      /** {@inheritDoc} */
45      @Override
46      @SuppressWarnings("checkstyle:designforextension")
47      public String toString()
48      {
49          return "MeanTravelTime [meanTravelTime=" + this.meanSpeed + " (per km)]";
50      }
51  
52  }