public double getAverageSpeedForTrips (Collection<Trip> trips, LocalTime from, LocalTime to) {
        TDoubleList speeds = new TDoubleArrayList();

        for (Trip trip : trips) {
            StopTime firstStopTime = feed.stop_times.ceilingEntry(Fun.t2(trip.trip_id, null)).getValue();
            LocalTime tripBeginTime = LocalTime.ofSecondOfDay(firstStopTime.departure_time % 86399); // convert 24hr+ seconds to 0 - 86399

            // skip trip if begin time is before or after specified time period
            if (tripBeginTime.isAfter(to) || tripBeginTime.isBefore(from)) {
                continue;
            }
            // TODO: swap straight lines for actual geometry?
            double speed = feed.getTripSpeed(trip.trip_id, true);

            if (!Double.isNaN(speed)) {
                speeds.add(speed);
            }
        }

        if (speeds.isEmpty()) return -1;

        return speeds.sum() / speeds.size();
    }
public double getAverageSpeedForTrips (Collection<Trip> trips, LocalTime from, LocalTime to) {
        TDoubleList speeds = new TDoubleArrayList();

        for (Trip trip : trips) {
            StopTime firstStopTime = feed.stop_times.ceilingEntry(Fun.t2(trip.trip_id, null)).getValue();
            LocalTime tripBeginTime = LocalTime.ofSecondOfDay(firstStopTime.departure_time % 86399); 

            
            if (tripBeginTime.isAfter(to) || tripBeginTime.isBefore(from)) {
                continue;
            }
            
            double speed = feed.getTripSpeed(trip.trip_id, true);

            if (!Double.isNaN(speed)) {
                speeds.add(speed);
            }
        }

        if (speeds.isEmpty()) return -1;

        return speeds.sum() / speeds.size();
    }
public double getAverageSpeedForTrips ( Collection < Trip > trips , LocalTime from , LocalTime to ) { TDoubleList speeds = new TDoubleArrayList ( ) ; for ( Trip trip : trips ) { StopTime firstStopTime = feed . stop_times . ceilingEntry ( Fun . t2 ( trip . trip_id , null ) ) . getValue ( ) ; LocalTime tripBeginTime = LocalTime . ofSecondOfDay ( firstStopTime . departure_time % 86399 ) ; // convert 24hr+ seconds to 0 - 86399 // skip trip if begin time is before or after specified time period if ( tripBeginTime . isAfter ( to ) || tripBeginTime . isBefore ( from ) ) { continue ; } // TODO: swap straight lines for actual geometry? double speed = feed . getTripSpeed ( trip . trip_id , true ) ; if ( ! Double . isNaN ( speed ) ) { speeds . add ( speed ) ; } } if ( speeds . isEmpty ( ) ) return - 1 ; return speeds . sum ( ) / speeds . size ( ) ; }
Get average speed for set of trips that begin within the time window in meters per second.
@param trips
@param from
@param to
@return avg. speed (meters per second)
Get average speed for set of trips that begin within the time window in meters per second .