1 package org.opentrafficsim.kpi.sampling.indicator;
2
3 import org.djunits.value.vdouble.scalar.Length;
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 TotalTravelDistance extends AbstractIndicator<Length>
21 {
22
23
24 @Override
25 public final Length calculate(final Query query, final Time startTime, final Time endTime)
26 {
27 Length sum = Length.ZERO;
28 for (TrajectoryGroup trajectoryGroup : query.getTrajectoryGroups(startTime, endTime))
29 {
30 for (Trajectory trajectory : trajectoryGroup.getTrajectories())
31 {
32 sum = sum.plus(trajectory.getTotalLength());
33 }
34 }
35 return sum;
36 }
37
38 @SuppressWarnings("checkstyle:designforextension")
39
40 @Override
41 public String toString()
42 {
43 return "TotalTravelDistance []";
44 }
45
46 }