1 package org.opentrafficsim.kpi.sampling.indicator;
2
3 import org.djunits.value.vdouble.scalar.Duration;
4 import org.djunits.value.vdouble.scalar.Time;
5 import org.opentrafficsim.kpi.sampling.Query;
6 import org.opentrafficsim.kpi.sampling.Trajectory;
7 import org.opentrafficsim.kpi.sampling.TrajectoryGroup;
8
9
10
11
12
13
14
15
16
17
18
19
20 public class TotalTravelTime extends AbstractIndicator<Duration>
21 {
22
23
24 @Override
25 public final Duration calculate(final Query query, final Time startTime, final Time endTime)
26 {
27 Duration sum = Duration.ZERO;
28 for (TrajectoryGroup trajectoryGroup : query.getTrajectoryGroups(startTime, endTime))
29 {
30 for (Trajectory trajectory : trajectoryGroup.getTrajectories())
31 {
32 sum = sum.plus(trajectory.getTotalDuration());
33 }
34 }
35 return sum;
36 }
37
38
39 @Override
40 @SuppressWarnings("checkstyle:designforextension")
41 public String toString()
42 {
43 return "TotalTravelTime []";
44 }
45
46 }