Search in sources :

Example 6 with RoutesBean

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

the class SearchServiceImpl method findRoutesStoppingWithinRegion.

@Override
public SearchResultCollection findRoutesStoppingWithinRegion(CoordinateBounds bounds, SearchResultFactory resultFactory) {
    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 RouteComparator());
    for (RouteBean route : routes.getRoutes()) {
        results.addMatch(resultFactory.getRouteResultForRegion(route));
    }
    return results;
}
Also used : RouteBean(org.onebusaway.transit_data.model.RouteBean) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) SearchQueryBean(org.onebusaway.transit_data.model.SearchQueryBean) RoutesBean(org.onebusaway.transit_data.model.RoutesBean) RouteComparator(org.onebusaway.presentation.impl.RouteComparator) SearchResultCollection(org.onebusaway.presentation.model.SearchResultCollection) OutOfServiceAreaServiceException(org.onebusaway.exceptions.OutOfServiceAreaServiceException)

Example 7 with RoutesBean

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

the class RouteForNameAction method execute.

public String execute() throws Exception {
    _log.debug("in RouteForName with routeName " + _routeName);
    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();
    sessionMap.put("navState", new Integer(DISPLAY_DATA));
    logUserInteraction("route", _routeName);
    if (routes.size() == 0) {
        sessionMap.put("messageFromAction", getText(Messages.NO_ROUTES_WERE_FOUND));
        sessionMap.put("backAction", "search-index");
        return "noRoutesFound";
    } else if (routes.size() == 1) {
        _route = routes.get(0);
        return SUCCESS;
    } else {
        _routes = routes;
        return "multipleRoutesFound";
    }
}
Also used : RouteBean(org.onebusaway.transit_data.model.RouteBean) SearchQueryBean(org.onebusaway.transit_data.model.SearchQueryBean) RoutesBean(org.onebusaway.transit_data.model.RoutesBean) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds)

Example 8 with RoutesBean

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

the class RealtimeServiceV2Impl method getRoutesForBounds.

private List<RouteBean> getRoutesForBounds(CoordinateBounds bounds) {
    if (bounds != null) {
        SearchQueryBean queryBean = new SearchQueryBean();
        queryBean.setType(SearchQueryBean.EQueryType.BOUNDS_OR_CLOSEST);
        queryBean.setBounds(bounds);
        queryBean.setMaxCount(Integer.MAX_VALUE);
        RoutesBean routes = _transitDataService.getRoutes(queryBean);
        return routes.getRoutes();
    }
    return new ArrayList<RouteBean>();
}
Also used : SearchQueryBean(org.onebusaway.transit_data.model.SearchQueryBean) RoutesBean(org.onebusaway.transit_data.model.RoutesBean) ArrayList(java.util.ArrayList)

Aggregations

RoutesBean (org.onebusaway.transit_data.model.RoutesBean)8 SearchQueryBean (org.onebusaway.transit_data.model.SearchQueryBean)7 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)5 RouteBean (org.onebusaway.transit_data.model.RouteBean)4 OutOfServiceAreaServiceException (org.onebusaway.exceptions.OutOfServiceAreaServiceException)3 SearchResultCollection (org.onebusaway.presentation.model.SearchResultCollection)2 StopsForRouteBean (org.onebusaway.transit_data.model.StopsForRouteBean)2 ArrayList (java.util.ArrayList)1 Actions (org.apache.struts2.convention.annotation.Actions)1 RouteComparator (org.onebusaway.presentation.impl.RouteComparator)1 SearchResult (org.onebusaway.presentation.model.SearchResult)1