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.interfaces.GtuDataInterface;
9 import org.opentrafficsim.kpi.sampling.Query;
10 import org.opentrafficsim.kpi.sampling.TrajectoryGroup;
11
12
13
14
15
16
17
18
19
20
21
22
23 public class MeanTravelTimePerDistance extends AbstractIndicator<Duration>
24 {
25
26
27 private final MeanSpeed meanSpeed;
28
29
30
31
32 public MeanTravelTimePerDistance(final MeanSpeed meanSpeed)
33 {
34 this.meanSpeed = meanSpeed;
35 }
36
37
38 @Override
39 protected <G extends GtuDataInterface> Duration calculate(final Query<G> query, final Time startTime, final Time endTime,
40 final List<TrajectoryGroup<G>> trajectoryGroups)
41 {
42 return new Duration(1.0 / this.meanSpeed.getValue(query, startTime, endTime, trajectoryGroups).si, DurationUnit.SI);
43 }
44
45
46 @Override
47 @SuppressWarnings("checkstyle:designforextension")
48 public String toString()
49 {
50 return "MeanTravelTime [meanTravelTime=" + this.meanSpeed + " (per km)]";
51 }
52
53 }