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);
}
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;
}
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;
}
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);
}
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;
}
Aggregations