Search in sources :

Example 1 with RouteComparator

use of org.onebusaway.presentation.impl.RouteComparator in project onebusaway-application-modules by camsys.

the class RouteListServiceImpl method getRoutes.

@Override
public List<RouteBean> getRoutes() {
    List<RouteBean> allRoutes = new ArrayList<RouteBean>();
    List<AgencyWithCoverageBean> agencies = _transitDataService.getAgenciesWithCoverage();
    for (AgencyWithCoverageBean agency : agencies) {
        allRoutes.addAll(_transitDataService.getRoutesForAgencyId(agency.getAgency().getId()).getList());
    }
    Collections.sort(allRoutes, (getShowAgencyNames() ? new AgencyAndRouteComparator() : new RouteComparator()));
    return allRoutes;
}
Also used : AgencyAndRouteComparator(org.onebusaway.presentation.impl.AgencyAndRouteComparator) RouteBean(org.onebusaway.transit_data.model.RouteBean) AgencyWithCoverageBean(org.onebusaway.transit_data.model.AgencyWithCoverageBean) ArrayList(java.util.ArrayList) AgencyAndRouteComparator(org.onebusaway.presentation.impl.AgencyAndRouteComparator) RouteComparator(org.onebusaway.presentation.impl.RouteComparator)

Example 2 with RouteComparator

use of org.onebusaway.presentation.impl.RouteComparator 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)

Aggregations

RouteComparator (org.onebusaway.presentation.impl.RouteComparator)2 RouteBean (org.onebusaway.transit_data.model.RouteBean)2 ArrayList (java.util.ArrayList)1 OutOfServiceAreaServiceException (org.onebusaway.exceptions.OutOfServiceAreaServiceException)1 AgencyAndRouteComparator (org.onebusaway.presentation.impl.AgencyAndRouteComparator)1 SearchResultCollection (org.onebusaway.presentation.model.SearchResultCollection)1 AgencyWithCoverageBean (org.onebusaway.transit_data.model.AgencyWithCoverageBean)1 RoutesBean (org.onebusaway.transit_data.model.RoutesBean)1 SearchQueryBean (org.onebusaway.transit_data.model.SearchQueryBean)1 StopsForRouteBean (org.onebusaway.transit_data.model.StopsForRouteBean)1