Search in sources :

Example 1 with VehicleLocationRecordBean

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;
}
Also used : CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) VehicleLocationRecordBean(org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean)

Example 2 with VehicleLocationRecordBean

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;
}
Also used : CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) VehicleLocationRecordBean(org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean)

Example 3 with VehicleLocationRecordBean

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);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) BlockLocationRecord(org.onebusaway.transit_data_federation.impl.realtime.BlockLocationRecord) ArrayList(java.util.ArrayList) ListBean(org.onebusaway.transit_data.model.ListBean) VehicleLocationRecordBean(org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean)

Example 4 with VehicleLocationRecordBean

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)));
}
Also used : VehicleLocationRecordBean(org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 5 with VehicleLocationRecordBean

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;
}
Also used : CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) VehicleLocationRecordBean(org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean)

Aggregations

VehicleLocationRecordBean (org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean)6 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)4 ArrayList (java.util.ArrayList)2 BeanFactoryV2 (org.onebusaway.api.model.transit.BeanFactoryV2)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 EVehiclePhase (org.onebusaway.realtime.api.EVehiclePhase)1 VehicleLocationRecord (org.onebusaway.realtime.api.VehicleLocationRecord)1 ListBean (org.onebusaway.transit_data.model.ListBean)1 VehicleStatusBean (org.onebusaway.transit_data.model.VehicleStatusBean)1 TripDetailsBean (org.onebusaway.transit_data.model.trips.TripDetailsBean)1 TripDetailsInclusionBean (org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean)1 BlockLocationRecord (org.onebusaway.transit_data_federation.impl.realtime.BlockLocationRecord)1