View Javadoc
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   * Sum of trajectory lengths.
13   * <p>
14   * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
16   * <p>
17   * @version $Revision$, $LastChangedDate$, by $Author$, initial version Sep 22, 2016 <br>
18   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
19   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
20   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
21   */
22  public class TotalTravelDistance extends AbstractIndicator<Length>
23  {
24  
25      /** {@inheritDoc} */
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      /** {@inheritDoc} */
43      @Override
44      public String toString()
45      {
46          return "TotalTravelDistance []";
47      }
48  
49  }