Search in sources :

Example 6 with VehicleLocationRecordBean

use of org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean in project onebusaway-application-modules by camsys.

the class VehicleStatusBeanServiceImpl method getStatusAsBean.

/**
 **
 *
 ***
 */
private VehicleStatusBean getStatusAsBean(VehicleStatus status, long time) {
    VehicleLocationRecord record = status.getRecord();
    VehicleStatusBean bean = new VehicleStatusBean();
    bean.setLastUpdateTime(record.getTimeOfRecord());
    bean.setLastLocationUpdateTime(record.getTimeOfLocationUpdate());
    EVehiclePhase phase = record.getPhase();
    if (phase != null)
        bean.setPhase(phase.toLabel());
    bean.setStatus(record.getStatus());
    if (record.isCurrentLocationSet())
        bean.setLocation(new CoordinatePoint(record.getCurrentLocationLat(), record.getCurrentLocationLon()));
    bean.setVehicleId(AgencyAndIdLibrary.convertToString(record.getVehicleId()));
    TripDetailsBean details = _tripDetailsBeanService.getTripForVehicle(record.getVehicleId(), time, new TripDetailsInclusionBean(true, false, true));
    if (details != null && details.getStatus() != null) {
        bean.setTrip(details.getTrip());
        bean.setTripStatus(details.getStatus());
    }
    List<VehicleLocationRecord> allRecords = status.getAllRecords();
    if (!CollectionsLibrary.isEmpty(allRecords)) {
        List<VehicleLocationRecordBean> allRecordBeans = new ArrayList<VehicleLocationRecordBean>();
        bean.setAllRecords(allRecordBeans);
        for (VehicleLocationRecord r : allRecords) {
            VehicleLocationRecordBean rBean = getVehicleLocationRecordAsBean(r);
            allRecordBeans.add(rBean);
        }
    }
    return bean;
}
Also used : CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) EVehiclePhase(org.onebusaway.realtime.api.EVehiclePhase) ArrayList(java.util.ArrayList) VehicleLocationRecord(org.onebusaway.realtime.api.VehicleLocationRecord) TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean) VehicleLocationRecordBean(org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean) VehicleStatusBean(org.onebusaway.transit_data.model.VehicleStatusBean)

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