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