use of org.onebusaway.transit_data.model.RoutesBean in project onebusaway-application-modules by camsys.
the class RouteForNameAction method execute.
@Override
public String execute() throws Exception {
CoordinateBounds bounds = getDefaultSearchArea();
if (bounds == null)
return NEEDS_DEFAULT_SEARCH_LOCATION;
if (_routeName == null || _routeName.length() == 0)
return INPUT;
SearchQueryBean routesQuery = new SearchQueryBean();
routesQuery.setBounds(bounds);
routesQuery.setMaxCount(10);
routesQuery.setQuery(_routeName);
routesQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
RoutesBean routesBean = _transitDataService.getRoutes(routesQuery);
List<RouteBean> routes = routesBean.getRoutes();
if (routes.size() == 0) {
return "noRoutesFound";
} else if (routes.size() == 1) {
_route = routes.get(0);
return SUCCESS;
} else {
_routes = routes;
return "multipleRoutesFound";
}
}
use of org.onebusaway.transit_data.model.RoutesBean in project onebusaway-application-modules by camsys.
the class RoutesBeanServiceImpl method constructResult.
private RoutesBean constructResult(List<RouteBean> routeBeans, boolean limitExceeded) {
Collections.sort(routeBeans, new RouteBeanIdComparator());
RoutesBean result = new RoutesBean();
result.setRoutes(routeBeans);
result.setLimitExceeded(limitExceeded);
return result;
}
use of org.onebusaway.transit_data.model.RoutesBean in project onebusaway-application-modules by camsys.
the class RoutesForLocationAction method index.
public DefaultHttpHeaders index() throws IOException, ServiceException {
int maxCount = _maxCount.getMaxCount();
if (maxCount <= 0)
addFieldError("maxCount", "must be greater than zero");
if (hasErrors())
return setValidationErrorsResponse();
CoordinateBounds bounds = getSearchBounds();
SearchQueryBean routesQuery = new SearchQueryBean();
if (_query != null)
routesQuery.setQuery(_query);
routesQuery.setBounds(bounds);
routesQuery.setMaxCount(maxCount);
routesQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
try {
RoutesBean result = _service.getRoutes(routesQuery);
return transformResult(result);
} catch (OutOfServiceAreaServiceException ex) {
return transformOutOfRangeResult();
}
}
use of org.onebusaway.transit_data.model.RoutesBean in project onebusaway-application-modules by camsys.
the class RoutesAction method execute.
@Override
@Actions({ @Action(value = "/where/iphone/routes") })
public String execute() throws ServiceException {
if (_query == null || _query.length() == 0)
return INPUT;
CoordinateBounds bounds = getServiceArea();
if (bounds == null) {
pushNextAction("routes", "query", _query);
return "query-default-search-location";
}
SearchQueryBean query = new SearchQueryBean();
query.setBounds(bounds);
query.setMaxCount(5);
query.setQuery(_query);
query.setType(EQueryType.BOUNDS_OR_CLOSEST);
RoutesBean routesResult = _transitDataService.getRoutes(query);
_routes = routesResult.getRoutes();
if (_routes.size() == 0) {
return "noRoutesFound";
} else if (_routes.size() > 1) {
return "multipleRoutesFound";
} else {
_route = _routes.get(0);
return "singleRouteFound";
}
}
use of org.onebusaway.transit_data.model.RoutesBean in project onebusaway-application-modules by camsys.
the class SearchServiceImpl method findRoutesStoppingNearPoint.
@Override
public SearchResultCollection findRoutesStoppingNearPoint(Double latitude, Double longitude, SearchResultFactory resultFactory) {
CoordinateBounds bounds = SphericalGeometryLibrary.bounds(latitude, longitude, DISTANCE_TO_ROUTES);
SearchResultCollection results = new SearchResultCollection();
SearchQueryBean queryBean = new SearchQueryBean();
queryBean.setType(SearchQueryBean.EQueryType.BOUNDS_OR_CLOSEST);
queryBean.setBounds(bounds);
queryBean.setMaxCount(100);
RoutesBean routes = null;
try {
routes = _transitDataService.getRoutes(queryBean);
} catch (OutOfServiceAreaServiceException e) {
return results;
}
Collections.sort(routes.getRoutes(), new RouteDistanceFromPointComparator(latitude, longitude));
for (RouteBean route : routes.getRoutes()) {
SearchResult result = resultFactory.getRouteResult(route);
results.addMatch(result);
if (results.getMatches().size() > MAX_ROUTES) {
break;
}
}
return results;
}
Aggregations