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);
}
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);
}
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);
}
Aggregations