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