use of org.onebusaway.transit_data.model.trips.TripsForBoundsQueryBean in project onebusaway-application-modules by camsys.
the class TripsForLocationAction method index.
public DefaultHttpHeaders index() throws IOException, ServiceException {
if (!isVersion(V2))
return setUnknownVersionResponse();
if (hasErrors())
return setValidationErrorsResponse();
CoordinateBounds bounds = _searchBoundsFactory.createBounds();
long time = SystemTime.currentTimeMillis();
if (_time != 0)
time = _time;
TripsForBoundsQueryBean query = new TripsForBoundsQueryBean();
query.setBounds(bounds);
query.setTime(time);
query.setMaxCount(_maxCount.getMaxCount());
TripDetailsInclusionBean inclusion = query.getInclusion();
inclusion.setIncludeTripBean(_includeTrip);
inclusion.setIncludeTripSchedule(_includeSchedule);
inclusion.setIncludeTripStatus(_includeStatus);
BeanFactoryV2 factory = getBeanFactoryV2();
try {
ListBean<TripDetailsBean> trips = _service.getTripsForBounds(query);
return setOkResponse(factory.getTripDetailsResponse(trips));
} catch (OutOfServiceAreaServiceException ex) {
return setOkResponse(factory.getEmptyList(TripDetailsV2Bean.class, true));
}
}
use of org.onebusaway.transit_data.model.trips.TripsForBoundsQueryBean 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();
}
Aggregations