Search in sources :

Example 1 with BlockLocationArchiveRecord

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);
    }
}
Also used : BlockLocationArchiveRecord(org.onebusaway.transit_data_federation.impl.realtime.history.BlockLocationArchiveRecord) TreeMap(java.util.TreeMap)

Example 2 with BlockLocationArchiveRecord

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);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) DoubleArrayList(cern.colt.list.DoubleArrayList) ArrayList(java.util.ArrayList) BlockLocationArchiveRecord(org.onebusaway.transit_data_federation.impl.realtime.history.BlockLocationArchiveRecord) ScheduleDeviationHistory(org.onebusaway.transit_data_federation.impl.realtime.history.ScheduleDeviationHistory) TreeMap(java.util.TreeMap) Map(java.util.Map) FactoryMap(org.onebusaway.collections.FactoryMap) SortedMap(java.util.SortedMap)

Example 3 with BlockLocationArchiveRecord

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;
}
Also used : FactoryMap(org.onebusaway.collections.FactoryMap) AgencyAndIdInstance(org.onebusaway.gtfs.model.AgencyAndIdInstance) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) BlockLocationArchiveRecord(org.onebusaway.transit_data_federation.impl.realtime.history.BlockLocationArchiveRecord)

Aggregations

BlockLocationArchiveRecord (org.onebusaway.transit_data_federation.impl.realtime.history.BlockLocationArchiveRecord)3 TreeMap (java.util.TreeMap)2 FactoryMap (org.onebusaway.collections.FactoryMap)2 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 DoubleArrayList (cern.colt.list.DoubleArrayList)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 AgencyAndIdInstance (org.onebusaway.gtfs.model.AgencyAndIdInstance)1 ScheduleDeviationHistory (org.onebusaway.transit_data_federation.impl.realtime.history.ScheduleDeviationHistory)1