1 package org.opentrafficsim.kpi.sampling.indicator;
2
3 import org.djunits.value.vdouble.scalar.Speed;
4 import org.djunits.value.vdouble.scalar.Time;
5 import org.opentrafficsim.kpi.sampling.Query;
6
7
8
9
10
11
12
13
14
15
16
17
18 public class MeanSpeed extends AbstractIndicator<Speed>
19 {
20
21
22 private final TotalTravelDistance travelDistance;
23
24
25 private final TotalTravelTime travelTime;
26
27
28
29
30
31 public MeanSpeed(final TotalTravelDistance travelDistance, final TotalTravelTime travelTime)
32 {
33 this.travelDistance = travelDistance;
34 this.travelTime = travelTime;
35 }
36
37
38 @Override
39 public final Speed calculate(final Query query, final Time startTime, final Time endTime)
40 {
41 return this.travelDistance.getValue(query, startTime, endTime).divideBy(
42 this.travelTime.getValue(query, startTime, endTime));
43 }
44
45
46 @Override
47 @SuppressWarnings("checkstyle:designforextension")
48 public String toString()
49 {
50 return "MeanSpeed [travelDistance=" + this.travelDistance + ", travelTime=" + this.travelTime + "]";
51 }
52
53 }