use of org.onebusaway.transit_data.model.realtime.HistogramBean in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesBeanServiceImpl method getArrivalAndDepartureForStop.
@Override
public ArrivalAndDepartureBean getArrivalAndDepartureForStop(ArrivalAndDepartureQuery query) {
long time = query.getTime();
ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);
if (instance == null) {
return null;
}
ArrivalAndDepartureBean bean = getStopTimeInstanceAsBean(time, instance, new HashMap<AgencyAndId, StopBean>());
applyBlockLocationToBean(instance, bean, time);
applySituationsToBean(time, instance, bean);
if (!this.useScheduleDeviationHistory) {
return bean;
}
int step = 120;
ScheduleDeviationHistogram histo = _realTimeHistoryService.getScheduleDeviationHistogramForArrivalAndDepartureInstance(instance, step);
if (histo != null) {
int[] sds = histo.getScheduleDeviations();
double[] values = new double[sds.length];
String[] labels = new String[sds.length];
for (int i = 0; i < sds.length; i++) {
int sd = sds[i];
values[i] = sd;
labels[i] = Integer.toString(sd / 60);
}
HistogramBean hb = new HistogramBean();
hb.setValues(values);
hb.setCounts(histo.getCounts());
hb.setLabels(labels);
bean.setScheduleDeviationHistogram(hb);
}
return bean;
}
Aggregations