1 package org.opentrafficsim.kpi.sampling.indicator;
2
3 import java.util.List;
4
5 import org.djunits.unit.DimensionlessUnit;
6 import org.djunits.value.vdouble.scalar.Dimensionless;
7 import org.djunits.value.vdouble.scalar.Time;
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 TotalNumberOfStops extends AbstractIndicator<Dimensionless>
24 {
25
26
27 @Override
28 protected Dimensionless calculate(final Query query, final Time startTime, final Time endTime,
29 final List<TrajectoryGroup> trajectoryGroups)
30 {
31 int sum = 0;
32 for (TrajectoryGroup trajectoryGroup : trajectoryGroups)
33 {
34 for (Trajectory<?> trajectory : trajectoryGroup.getTrajectories())
35 {
36 float[] v = trajectory.getV();
37 for (int i = 1; i < v.length; i++)
38 {
39 if (v[i] == 0 && v[i - 1] > 0)
40 {
41 sum++;
42 }
43 }
44 }
45 }
46 return new Dimensionless(sum, DimensionlessUnit.SI);
47 }
48
49
50 @Override
51 @SuppressWarnings("checkstyle:designforextension")
52 public String toString()
53 {
54 return "TotalNumberOfStops []";
55 }
56
57 }