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
13
14
15
16
17
18
19
20
21
22 public class MeanTravelTimePerDistance extends AbstractIndicator<Duration>
23 {
24
25
26 private final MeanSpeed meanSpeed;
27
28
29
30
31 public MeanTravelTimePerDistance(final MeanSpeed meanSpeed)
32 {
33 this.meanSpeed = meanSpeed;
34 }
35
36
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
45 @Override
46 @SuppressWarnings("checkstyle:designforextension")
47 public String toString()
48 {
49 return "MeanTravelTime [meanTravelTime=" + this.meanSpeed + " (per km)]";
50 }
51
52 }