use of org.onebusaway.transit_data_federation.services.blocks.BlockInstance in project onebusaway-application-modules by camsys.
the class BlockBeanServiceImpl method getScheduledBlockLocationFromScheduledTime.
@Override
public ScheduledBlockLocationBean getScheduledBlockLocationFromScheduledTime(AgencyAndId blockId, long serviceDate, int scheduledTime) {
BlockInstance blockInstance = _blockCalendarService.getBlockInstance(blockId, serviceDate);
if (blockInstance == null)
return null;
ScheduledBlockLocation blockLocation = _scheduledBlockLocationService.getScheduledBlockLocationFromScheduledTime(blockInstance.getBlock(), scheduledTime);
if (blockLocation == null)
return null;
return getBlockLocationAsBean(blockLocation);
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockInstance in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesBeanServiceImpl method applySituationsToBean.
private void applySituationsToBean(long time, ArrivalAndDepartureInstance instance, ArrivalAndDepartureBean bean) {
BlockInstance blockInstance = instance.getBlockInstance();
AgencyAndId vehicleId = null;
BlockLocation blockLocation = instance.getBlockLocation();
if (blockLocation != null)
vehicleId = blockLocation.getVehicleId();
List<ServiceAlertBean> situations = _serviceAlertsBeanService.getServiceAlertsForStopCall(time, blockInstance, instance.getBlockStopTime(), vehicleId);
if (!situations.isEmpty())
bean.setSituations(situations);
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockInstance in project onebusaway-application-modules by camsys.
the class BlockLocationServiceImpl method getLocationForVehicleAndTime.
@Override
public BlockLocation getLocationForVehicleAndTime(AgencyAndId vehicleId, TargetTime targetTime) {
List<VehicleLocationCacheElements> cacheRecords = getBlockLocationRecordCollectionForVehicle(vehicleId, targetTime);
// multiple collections are returned
if (cacheRecords.size() > 1) {
_log.error("multiple cache entries for vehicle " + vehicleId);
}
for (VehicleLocationCacheElements cacheRecord : cacheRecords) {
BlockInstance blockInstance = cacheRecord.getBlockInstance();
BlockLocation location = getBlockLocation(blockInstance, cacheRecord, null, targetTime.getTargetTime());
if (location != null)
return location;
}
return null;
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockInstance in project onebusaway-application-modules by camsys.
the class BlockStatusServiceImpl method getBlocksForIndex.
@Override
public Map<BlockInstance, List<List<BlockLocation>>> getBlocksForIndex(BlockSequenceIndex index, List<Date> timestamps) {
List<BlockInstance> instances = getBlockInstancesForIndexAndTimestamps(index, timestamps);
Map<BlockInstance, List<List<BlockLocation>>> results = new HashMap<BlockInstance, List<List<BlockLocation>>>();
for (BlockInstance instance : instances) {
getBlockLocationsForInstanceAndTimestamps(instance, timestamps, results);
}
return results;
}
use of org.onebusaway.transit_data_federation.services.blocks.BlockInstance in project onebusaway-application-modules by camsys.
the class BlockStatusServiceImpl method getBlockInstances.
/**
**
* Private Methods
***
*/
private List<BlockInstance> getBlockInstances(AgencyAndId blockId, long serviceDate, long time) {
if (serviceDate != 0) {
BlockInstance blockInstance = _blockCalendarService.getBlockInstance(blockId, serviceDate);
if (blockInstance == null)
return Collections.emptyList();
BlockConfigurationEntry blockConfig = blockInstance.getBlock();
if (blockConfig.getFrequencies() == null)
return Arrays.asList(blockInstance);
List<BlockInstance> instances = new ArrayList<BlockInstance>();
for (FrequencyEntry frequency : blockConfig.getFrequencies()) instances.add(new BlockInstance(blockConfig, blockInstance.getServiceDate(), frequency));
return instances;
} else {
List<BlockInstance> instances = _blockCalendarService.getActiveBlocks(blockId, time, time);
if (instances.isEmpty()) {
instances = _blockCalendarService.getClosestActiveBlocks(blockId, time);
}
return instances;
}
}
Aggregations