Search in sources :

Example 6 with BlockInstance

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);
}
Also used : ScheduledBlockLocation(org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance)

Example 7 with BlockInstance

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);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) BlockLocation(org.onebusaway.transit_data_federation.services.realtime.BlockLocation) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 8 with BlockInstance

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;
}
Also used : VehicleLocationCacheElements(org.onebusaway.transit_data_federation.services.realtime.VehicleLocationCacheElements) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) ScheduledBlockLocation(org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation) BlockLocation(org.onebusaway.transit_data_federation.services.realtime.BlockLocation)

Example 9 with BlockInstance

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;
}
Also used : HashMap(java.util.HashMap) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) ArrayList(java.util.ArrayList) List(java.util.List) BlockLocation(org.onebusaway.transit_data_federation.services.realtime.BlockLocation)

Example 10 with BlockInstance

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;
    }
}
Also used : BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) ArrayList(java.util.ArrayList) FrequencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)

Aggregations

BlockInstance (org.onebusaway.transit_data_federation.services.blocks.BlockInstance)63 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)36 BlockEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl)25 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)24 Test (org.junit.Test)20 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)20 ArrayList (java.util.ArrayList)19 BlockLocation (org.onebusaway.transit_data_federation.services.realtime.BlockLocation)19 VehicleLocationRecord (org.onebusaway.realtime.api.VehicleLocationRecord)16 Date (java.util.Date)15 ScheduledBlockLocation (org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation)12 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)12 List (java.util.List)11 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)11 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)10 ArrivalAndDepartureInstance (org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance)10 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)10 StopTimeUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate)9 StopTimeInstance (org.onebusaway.transit_data_federation.model.StopTimeInstance)9 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)9