org.opentrafficsim.kpi.sampling.indicator.TotalTravelTime Maven / Gradle / Ivy
package org.opentrafficsim.kpi.sampling.indicator;
import java.util.List;
import org.djunits.value.vdouble.scalar.Duration;
import org.djunits.value.vdouble.scalar.Time;
import org.opentrafficsim.kpi.interfaces.GtuData;
import org.opentrafficsim.kpi.sampling.Query;
import org.opentrafficsim.kpi.sampling.Trajectory;
import org.opentrafficsim.kpi.sampling.TrajectoryGroup;
/**
* Sum of trajectory durations.
*
* Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
* @author Alexander Verbraeck
* @author Peter Knoppers
* @author Wouter Schakel
*/
public class TotalTravelTime extends AbstractIndicator
{
/** {@inheritDoc} */
@Override
protected Duration calculate(final Query query, final Time startTime, final Time endTime,
final List> trajectoryGroups)
{
Duration sum = Duration.ZERO;
for (TrajectoryGroup> trajectoryGroup : trajectoryGroups)
{
for (Trajectory> trajectory : trajectoryGroup.getTrajectories())
{
sum = sum.plus(trajectory.getTotalDuration());
}
}
return sum;
}
/** {@inheritDoc} */
@Override
@SuppressWarnings("checkstyle:designforextension")
public String toString()
{
return "TotalTravelTime []";
}
}