Search in sources :

Example 1 with BlockLocationListener

use of org.onebusaway.transit_data_federation.services.realtime.BlockLocationListener in project onebusaway-application-modules by camsys.

the class BlockLocationServiceImpl method putBlockLocationRecord.

/**
 * We add the {@link BlockInstance} to the local cache and persist it to
 * a back-end data-store if necessary
 *
 * @param scheduledBlockLocation TODO
 * @param samples
 */
private void putBlockLocationRecord(BlockInstance blockInstance, VehicleLocationRecord record, ScheduledBlockLocation scheduledBlockLocation, ScheduleDeviationSamples samples) {
    // Cache the result
    VehicleLocationCacheElements elements = _cache.addRecord(blockInstance, record, scheduledBlockLocation, samples);
    if (!CollectionsLibrary.isEmpty(_blockLocationListeners)) {
        /**
         * We only fill in the block location if we have listeners
         */
        BlockLocation location = getBlockLocation(blockInstance, elements, scheduledBlockLocation, record.getTimeOfRecord());
        if (location != null) {
            for (BlockLocationListener listener : _blockLocationListeners) {
                listener.handleBlockLocation(location);
            }
        }
    }
    if (_persistBlockLocationRecords) {
        List<BlockLocationRecord> blockLocationRecords = getVehicleLocationRecordAsBlockLocationRecord(blockInstance, record, scheduledBlockLocation);
        addPredictionToPersistenceQueue(blockLocationRecords);
    }
}
Also used : VehicleLocationCacheElements(org.onebusaway.transit_data_federation.services.realtime.VehicleLocationCacheElements) BlockLocationListener(org.onebusaway.transit_data_federation.services.realtime.BlockLocationListener) ScheduledBlockLocation(org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation) BlockLocation(org.onebusaway.transit_data_federation.services.realtime.BlockLocation)

Aggregations

ScheduledBlockLocation (org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation)1 BlockLocation (org.onebusaway.transit_data_federation.services.realtime.BlockLocation)1 BlockLocationListener (org.onebusaway.transit_data_federation.services.realtime.BlockLocationListener)1 VehicleLocationCacheElements (org.onebusaway.transit_data_federation.services.realtime.VehicleLocationCacheElements)1