Search in sources :

Example 6 with BlockLocation

use of org.onebusaway.transit_data_federation.services.realtime.BlockLocation 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 7 with BlockLocation

use of org.onebusaway.transit_data_federation.services.realtime.BlockLocation 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 8 with BlockLocation

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

the class CurrentVehicleEstimationServiceImpl method tryDirectMatchAgainstVehicleId.

/**
 **
 * Private Methods
 ***
 */
private boolean tryDirectMatchAgainstVehicleId(CurrentVehicleEstimateQueryBean query, List<Record> records, List<CurrentVehicleEstimateBean> beans) {
    if (query.getVehicleId() == null)
        return false;
    Record record = records.get(records.size() - 1);
    AgencyAndId vehicleId = AgencyAndIdLibrary.convertFromString(query.getVehicleId());
    BlockLocation location = _blockLocationService.getLocationForVehicleAndTime(vehicleId, new TargetTime(record.getTimestamp()));
    if (location == null)
        return false;
    double d = SphericalGeometryLibrary.distance(record.getLocation(), location.getLocation());
    double p = _realTimeLocationDeviationModel.probability(d);
    if (p < _shortCutProbability)
        return false;
    CurrentVehicleEstimateBean bean = new CurrentVehicleEstimateBean();
    bean.setProbability(p);
    bean.setTripStatus(_tripStatusBeanService.getBlockLocationAsStatusBean(location, query.getTime()));
    beans.add(bean);
    return true;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) CurrentVehicleEstimateBean(org.onebusaway.transit_data.model.realtime.CurrentVehicleEstimateBean) Record(org.onebusaway.transit_data.model.realtime.CurrentVehicleEstimateQueryBean.Record) ScheduledBlockLocation(org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation) BlockLocation(org.onebusaway.transit_data_federation.services.realtime.BlockLocation) TargetTime(org.onebusaway.transit_data_federation.model.TargetTime)

Example 9 with BlockLocation

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

the class CurrentVehicleEstimationServiceImpl method computeCumulativeProbabilityForRealTimeBlockLocations.

private void computeCumulativeProbabilityForRealTimeBlockLocations(Map<Date, Record> recordsByTime, List<BlockLocation> locations, double minProbabilityForConsideration, List<CurrentVehicleEstimateBean> beans) {
    DoubleArrayList ps = new DoubleArrayList();
    for (BlockLocation location : locations) {
        Date t = new Date(location.getTime());
        Record record = recordsByTime.get(t);
        CoordinatePoint userLocation = record.getLocation();
        CoordinatePoint vehicleLocation = location.getLocation();
        double d = SphericalGeometryLibrary.distance(userLocation, vehicleLocation);
        double p = _realTimeLocationDeviationModel.probability(d);
        ps.add(p);
    }
    BlockLocation last = locations.get(locations.size() - 1);
    double mu = Descriptive.mean(ps);
    String debug = asString(ps);
    addResult(last, mu, debug, minProbabilityForConsideration, beans);
}
Also used : CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) Record(org.onebusaway.transit_data.model.realtime.CurrentVehicleEstimateQueryBean.Record) DoubleArrayList(cern.colt.list.DoubleArrayList) ScheduledBlockLocation(org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation) BlockLocation(org.onebusaway.transit_data_federation.services.realtime.BlockLocation) Date(java.util.Date)

Example 10 with BlockLocation

use of org.onebusaway.transit_data_federation.services.realtime.BlockLocation 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)

Aggregations

BlockLocation (org.onebusaway.transit_data_federation.services.realtime.BlockLocation)33 BlockInstance (org.onebusaway.transit_data_federation.services.blocks.BlockInstance)19 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)15 ScheduledBlockLocation (org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation)15 ArrayList (java.util.ArrayList)14 TargetTime (org.onebusaway.transit_data_federation.model.TargetTime)12 Date (java.util.Date)11 ArrivalAndDepartureInstance (org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance)10 List (java.util.List)8 StopTimeInstance (org.onebusaway.transit_data_federation.model.StopTimeInstance)8 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)8 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)8 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)7 BlockEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl)7 VehicleLocationRecord (org.onebusaway.realtime.api.VehicleLocationRecord)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Record (org.onebusaway.transit_data.model.realtime.CurrentVehicleEstimateQueryBean.Record)5 ScheduledBlockLocationServiceImpl (org.onebusaway.transit_data_federation.impl.blocks.ScheduledBlockLocationServiceImpl)5 VehicleLocationRecordCacheImpl (org.onebusaway.transit_data_federation.impl.realtime.VehicleLocationRecordCacheImpl)5