use of org.onebusaway.transit_data_federation.impl.realtime.history.BlockLocationArchiveRecord in project onebusaway-application-modules by camsys.
the class BlockLocationHistoryTask method sortAndArrangeTraces.
private void sortAndArrangeTraces(BlockLocationArchiveRecordMap recordsByInstance, List<SortedMap<Integer, Double>> maps, Range tRange) {
for (List<BlockLocationArchiveRecord> records : recordsByInstance.values()) {
SortedMap<Integer, Double> m = new TreeMap<Integer, Double>();
for (BlockLocationArchiveRecord record : records) {
int effectiveScheduleTime = (int) ((record.getTime() - record.getServiceDate()) / 1000 - record.getScheduleDeviation());
m.put(effectiveScheduleTime, (double) record.getScheduleDeviation());
tRange.addValue(effectiveScheduleTime);
}
maps.add(m);
}
}
use of org.onebusaway.transit_data_federation.impl.realtime.history.BlockLocationArchiveRecord in project onebusaway-application-modules by camsys.
the class BlockLocationHistoryTask method processTrip.
private void processTrip(TripEntry trip) {
List<BlockLocationArchiveRecord> records = _source.getRecordsForTrip(trip.getId());
Map<AgencyAndId, BlockLocationArchiveRecordMap> recordsByTrip = loadRecords(records);
List<ScheduleDeviationHistory> histories = new ArrayList<ScheduleDeviationHistory>();
for (Map.Entry<AgencyAndId, BlockLocationArchiveRecordMap> entry : recordsByTrip.entrySet()) {
AgencyAndId tripId = entry.getKey();
BlockLocationArchiveRecordMap recordsByInstance = entry.getValue();
/**
* If we don't have enough samples, skip the trip
*/
if (recordsByInstance.size() < _minSampleSize)
continue;
ScheduleDeviationHistory history = constructHistory(tripId, recordsByInstance);
histories.add(history);
}
if (!histories.isEmpty())
_scheduleDeviationHistoryDao.saveScheduleDeviationHistory(histories);
}
use of org.onebusaway.transit_data_federation.impl.realtime.history.BlockLocationArchiveRecord in project onebusaway-application-modules by camsys.
the class BlockLocationHistoryTask method loadRecords.
private Map<AgencyAndId, BlockLocationArchiveRecordMap> loadRecords(List<BlockLocationArchiveRecord> records) {
Map<AgencyAndId, BlockLocationArchiveRecordMap> recordsByTrip = new FactoryMap<AgencyAndId, BlockLocationArchiveRecordMap>(new BlockLocationArchiveRecordMap());
for (BlockLocationArchiveRecord record : records) {
AgencyAndId tripId = record.getTripId();
AgencyAndIdInstance instance = new AgencyAndIdInstance(tripId, record.getServiceDate());
recordsByTrip.get(record.getTripId()).get(instance).add(record);
}
return recordsByTrip;
}
Aggregations