Search in sources :

Example 11 with TripDetailsInclusionBean

use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean in project onebusaway-application-modules by camsys.

the class VehicleLocationsAction method getAllTripsForRoute.

private ListBean<TripDetailsBean> getAllTripsForRoute(String routeId, long currentTime) {
    TripsForRouteQueryBean query = new TripsForRouteQueryBean();
    query.setRouteId(routeId);
    query.setTime(currentTime);
    TripDetailsInclusionBean inclusionBean = new TripDetailsInclusionBean();
    inclusionBean.setIncludeTripBean(true);
    inclusionBean.setIncludeTripStatus(true);
    query.setInclusion(inclusionBean);
    return _transitDataService.getTripsForRoute(query);
}
Also used : TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean) TripsForRouteQueryBean(org.onebusaway.transit_data.model.trips.TripsForRouteQueryBean)

Example 12 with TripDetailsInclusionBean

use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean in project onebusaway-application-modules by camsys.

the class VehicleLocationsAction method getAllTripsForAgency.

private ListBean<TripDetailsBean> getAllTripsForAgency(String agencyId, long currentTime) {
    TripsForAgencyQueryBean query = new TripsForAgencyQueryBean();
    query.setAgencyId(agencyId);
    query.setTime(currentTime);
    TripDetailsInclusionBean inclusionBean = new TripDetailsInclusionBean();
    inclusionBean.setIncludeTripBean(true);
    inclusionBean.setIncludeTripStatus(true);
    query.setInclusion(inclusionBean);
    return _transitDataService.getTripsForAgency(query);
}
Also used : TripsForAgencyQueryBean(org.onebusaway.transit_data.model.trips.TripsForAgencyQueryBean) TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean)

Example 13 with TripDetailsInclusionBean

use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean in project onebusaway-application-modules by camsys.

the class MetricResource method getScheduledTrips.

protected int getScheduledTrips(String agencyId, String routeId) {
    Set<TripDetailsBean> agencyTrips = new HashSet<TripDetailsBean>();
    TripsForBoundsQueryBean query = new TripsForBoundsQueryBean();
    List<CoordinateBounds> allBounds = getTDS().getAgencyIdsWithCoverageArea().get(agencyId);
    for (CoordinateBounds bounds : allBounds) {
        query.setBounds(bounds);
        query.setTime(SystemTime.currentTimeMillis());
        query.setMaxCount(Integer.MAX_VALUE);
        TripDetailsInclusionBean inclusion = query.getInclusion();
        inclusion.setIncludeTripBean(true);
        ListBean<TripDetailsBean> allTrips = getTDS().getTripsForBounds(query);
        if (allTrips == null) {
            continue;
        }
        _log.debug("allTrips size=" + allTrips.getList().size());
        AgencyAndId routeAndId = new AgencyAndId(agencyId, routeId);
        for (TripDetailsBean trip : allTrips.getList()) {
            if (trip.getTripId().startsWith(agencyId)) {
                if (routeId == null || routeAndId.toString().equals(trip.getTrip().getRoute().getId())) {
                    agencyTrips.add(trip);
                }
            }
        }
    }
    return agencyTrips.size();
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean) TripsForBoundsQueryBean(org.onebusaway.transit_data.model.trips.TripsForBoundsQueryBean) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean) HashSet(java.util.HashSet) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds)

Example 14 with TripDetailsInclusionBean

use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean 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

TripDetailsInclusionBean (org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean)14 TripDetailsBean (org.onebusaway.transit_data.model.trips.TripDetailsBean)10 BeanFactoryV2 (org.onebusaway.api.model.transit.BeanFactoryV2)5 TripsForRouteQueryBean (org.onebusaway.transit_data.model.trips.TripsForRouteQueryBean)4 OutOfServiceAreaServiceException (org.onebusaway.exceptions.OutOfServiceAreaServiceException)3 TripForVehicleQueryBean (org.onebusaway.transit_data.model.trips.TripForVehicleQueryBean)3 Date (java.util.Date)2 TripDetailsV2Bean (org.onebusaway.api.model.transit.TripDetailsV2Bean)2 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)2 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 TimepointPredictionRecord (org.onebusaway.realtime.api.TimepointPredictionRecord)2 TripDetailsQueryBean (org.onebusaway.transit_data.model.trips.TripDetailsQueryBean)2 TripsForAgencyQueryBean (org.onebusaway.transit_data.model.trips.TripsForAgencyQueryBean)2 TripsForBoundsQueryBean (org.onebusaway.transit_data.model.trips.TripsForBoundsQueryBean)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)1 EVehiclePhase (org.onebusaway.realtime.api.EVehiclePhase)1 VehicleLocationRecord (org.onebusaway.realtime.api.VehicleLocationRecord)1 VehicleStatusBean (org.onebusaway.transit_data.model.VehicleStatusBean)1