Search in sources :

Example 1 with TimeIntervalBean

use of org.onebusaway.transit_data.model.TimeIntervalBean in project onebusaway-application-modules by camsys.

the class ArrivalAndDepartureServiceImpl method computePredictedDepartureTimeInterval.

private TimeIntervalBean computePredictedDepartureTimeInterval(ArrivalAndDepartureInstance instance, BlockLocation blockLocation, long targetTime) {
    BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
    StopTimeEntry stopTime = blockStopTime.getStopTime();
    // interval
    if (stopTime.getDepartureTime() <= blockLocation.getEffectiveScheduleTime())
        return null;
    ScheduleDeviationSamples samples = blockLocation.getScheduleDeviations();
    if (samples == null || samples.isEmpty())
        return null;
    double mu = InterpolationLibrary.interpolate(samples.getScheduleTimes(), samples.getScheduleDeviationMus(), stopTime.getDepartureTime(), EOutOfRangeStrategy.LAST_VALUE, EInRangeStrategy.INTERPOLATE);
    double sigma = InterpolationLibrary.interpolate(samples.getScheduleTimes(), samples.getScheduleDeviationSigmas(), stopTime.getDepartureTime(), EOutOfRangeStrategy.LAST_VALUE, EInRangeStrategy.INTERPOLATE);
    long from = (long) (instance.getScheduledDepartureTime() + (mu - sigma) * 1000);
    long to = (long) (instance.getScheduledDepartureTime() + (mu + sigma) * 1000);
    return new TimeIntervalBean(from, to);
}
Also used : StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) ScheduleDeviationSamples(org.onebusaway.transit_data_federation.services.realtime.ScheduleDeviationSamples) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) TimeIntervalBean(org.onebusaway.transit_data.model.TimeIntervalBean)

Example 2 with TimeIntervalBean

use of org.onebusaway.transit_data.model.TimeIntervalBean in project onebusaway-application-modules by camsys.

the class ArrivalAndDepartureServiceImpl method computePredictedArrivalTimeInterval.

private TimeIntervalBean computePredictedArrivalTimeInterval(ArrivalAndDepartureInstance instance, BlockLocation blockLocation, long targetTime) {
    BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
    StopTimeEntry stopTime = blockStopTime.getStopTime();
    // interval
    if (stopTime.getArrivalTime() <= blockLocation.getEffectiveScheduleTime())
        return null;
    ScheduleDeviationSamples samples = blockLocation.getScheduleDeviations();
    if (samples == null || samples.isEmpty())
        return null;
    double mu = InterpolationLibrary.interpolate(samples.getScheduleTimes(), samples.getScheduleDeviationMus(), stopTime.getArrivalTime(), EOutOfRangeStrategy.LAST_VALUE, EInRangeStrategy.INTERPOLATE);
    double sigma = InterpolationLibrary.interpolate(samples.getScheduleTimes(), samples.getScheduleDeviationSigmas(), stopTime.getArrivalTime(), EOutOfRangeStrategy.LAST_VALUE, EInRangeStrategy.INTERPOLATE);
    long from = (long) (instance.getScheduledArrivalTime() + (mu - sigma) * 1000);
    long to = (long) (instance.getScheduledArrivalTime() + (mu + sigma) * 1000);
    return new TimeIntervalBean(from, to);
}
Also used : StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) ScheduleDeviationSamples(org.onebusaway.transit_data_federation.services.realtime.ScheduleDeviationSamples) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) TimeIntervalBean(org.onebusaway.transit_data.model.TimeIntervalBean)

Example 3 with TimeIntervalBean

use of org.onebusaway.transit_data.model.TimeIntervalBean in project onebusaway-application-modules by camsys.

the class ArrivalAndDepartureServiceImpl method setPredictedTimeIntervals.

private void setPredictedTimeIntervals(ArrivalAndDepartureInstance instance, BlockLocation blockLocation, long targetTime) {
    TimeIntervalBean predictedArrivalTimeInterval = computePredictedArrivalTimeInterval(instance, blockLocation, targetTime);
    instance.setPredictedArrivalInterval(predictedArrivalTimeInterval);
    TimeIntervalBean predictedDepartureTimeInterval = computePredictedDepartureTimeInterval(instance, blockLocation, targetTime);
    instance.setPredictedDepartureInterval(predictedDepartureTimeInterval);
}
Also used : TimeIntervalBean(org.onebusaway.transit_data.model.TimeIntervalBean)

Aggregations

TimeIntervalBean (org.onebusaway.transit_data.model.TimeIntervalBean)3 ScheduleDeviationSamples (org.onebusaway.transit_data_federation.services.realtime.ScheduleDeviationSamples)2 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)2 StopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)2