use of org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean in project onebusaway-application-modules by camsys.
the class VehicleStatusBeanServiceImpl method getVehicleLocationRecordAsBean.
private VehicleLocationRecordBean getVehicleLocationRecordAsBean(VehicleLocationRecord record) {
VehicleLocationRecordBean bean = new VehicleLocationRecordBean();
bean.setBlockId(AgencyAndIdLibrary.convertToString(record.getBlockId()));
if (record.getPhase() != null)
bean.setPhase(record.getPhase().toLabel());
if (record.isCurrentLocationSet()) {
CoordinatePoint location = new CoordinatePoint(record.getCurrentLocationLat(), record.getCurrentLocationLon());
bean.setCurrentLocation(location);
}
if (record.isCurrentOrientationSet())
bean.setCurrentOrientation(record.getCurrentOrientation());
if (record.isDistanceAlongBlockSet())
bean.setDistanceAlongBlock(record.getDistanceAlongBlock());
if (record.isScheduleDeviationSet())
bean.setScheduleDeviation(record.getScheduleDeviation());
bean.setStatus(record.getStatus());
bean.setServiceDate(record.getServiceDate());
bean.setTimeOfRecord(record.getTimeOfRecord());
bean.setTripId(AgencyAndIdLibrary.convertToString(record.getTripId()));
bean.setVehicleId(AgencyAndIdLibrary.convertToString(record.getVehicleId()));
return bean;
}
use of org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean in project onebusaway-application-modules by camsys.
the class VehicleStatusBeanServiceImpl method getBlockLocationAsVehicleLocationRecord.
private VehicleLocationRecordBean getBlockLocationAsVehicleLocationRecord(BlockLocation record) {
VehicleLocationRecordBean bean = new VehicleLocationRecordBean();
bean.setBlockId(AgencyAndIdLibrary.convertToString(record.getBlockInstance().getBlock().getBlock().getId()));
if (record.getPhase() != null)
bean.setPhase(record.getPhase().toLabel());
CoordinatePoint location = record.getLocation();
if (location != null)
bean.setCurrentLocation(location);
if (record.isOrientationSet())
bean.setCurrentOrientation(record.getOrientation());
if (record.isDistanceAlongBlockSet())
bean.setDistanceAlongBlock(record.getDistanceAlongBlock());
if (record.isScheduleDeviationSet())
bean.setScheduleDeviation(record.getScheduleDeviation());
bean.setStatus(record.getStatus());
bean.setServiceDate(record.getBlockInstance().getServiceDate());
bean.setTimeOfRecord(record.getLastUpdateTime());
bean.setTimeOfLocationUpdate(record.getLastLocationUpdateTime());
bean.setTripId(AgencyAndIdLibrary.convertToString(record.getActiveTrip().getTrip().getId()));
bean.setVehicleId(AgencyAndIdLibrary.convertToString(record.getVehicleId()));
return bean;
}
use of org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean in project onebusaway-application-modules by camsys.
the class VehicleStatusBeanServiceImpl method getVehicleLocations.
@Override
public ListBean<VehicleLocationRecordBean> getVehicleLocations(VehicleLocationRecordQueryBean query) {
AgencyAndId blockId = AgencyAndIdLibrary.convertFromString(query.getBlockId());
AgencyAndId tripId = AgencyAndIdLibrary.convertFromString(query.getTripId());
AgencyAndId vehicleId = AgencyAndIdLibrary.convertFromString(query.getVehicleId());
List<BlockLocationRecord> records = _blockLocationRecordDao.getBlockLocationRecords(blockId, tripId, vehicleId, query.getServiceDate(), query.getFromTime(), query.getToTime(), 1000);
List<VehicleLocationRecordBean> beans = new ArrayList<VehicleLocationRecordBean>(records.size());
for (BlockLocationRecord record : records) {
VehicleLocationRecordBean bean = getBlockLocationRecordAsVehicleLocationRecord(record);
beans.add(bean);
}
return new ListBean<VehicleLocationRecordBean>(beans, false);
}
use of org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean in project onebusaway-application-modules by camsys.
the class VehicleLocationRecordForVehicleAction method show.
public DefaultHttpHeaders show() throws IOException, ServiceException {
if (!isVersion(V2))
return setUnknownVersionResponse();
if (hasErrors())
return setValidationErrorsResponse();
BeanFactoryV2 factory = getBeanFactoryV2();
VehicleLocationRecordBean record = _service.getVehicleLocationRecordForVehicleId(_id, _time);
if (record == null)
return setResourceNotFoundResponse();
return setOkResponse(factory.entry(factory.getVehicleLocationRecord(record)));
}
use of org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean in project onebusaway-application-modules by camsys.
the class VehicleStatusBeanServiceImpl method getBlockLocationRecordAsVehicleLocationRecord.
private VehicleLocationRecordBean getBlockLocationRecordAsVehicleLocationRecord(BlockLocationRecord record) {
VehicleLocationRecordBean bean = new VehicleLocationRecordBean();
bean.setBlockId(AgencyAndIdLibrary.convertToString(record.getBlockId()));
if (record.getPhase() != null)
bean.setPhase(record.getPhase().toLabel());
CoordinatePoint location = record.getLocation();
if (location != null)
bean.setCurrentLocation(location);
if (record.getOrientation() != null)
bean.setCurrentOrientation(record.getOrientation());
if (record.getDistanceAlongBlock() != null)
bean.setDistanceAlongBlock(record.getDistanceAlongBlock());
if (record.getScheduleDeviation() != null)
bean.setScheduleDeviation(record.getScheduleDeviation());
bean.setStatus(record.getStatus());
bean.setServiceDate(record.getServiceDate());
bean.setTimeOfRecord(record.getTime());
bean.setTripId(AgencyAndIdLibrary.convertToString(record.getTripId()));
bean.setVehicleId(AgencyAndIdLibrary.convertToString(record.getVehicleId()));
return bean;
}
Aggregations