Search in sources :

Example 1 with StopOnRoute

use of org.onebusaway.enterprise.webapp.actions.api.model.StopOnRoute in project onebusaway-application-modules by camsys.

the class StopsOnRouteForDirectionAction method execute.

@Override
public String execute() {
    if (_routeId == null) {
        return SUCCESS;
    }
    StopsForRouteBean stopsForRoute = _transitDataService.getStopsForRoute(_routeId);
    // create stop ID->stop bean map
    Map<String, StopBean> stopIdToStopBeanMap = new HashMap<String, StopBean>();
    for (StopBean stopBean : stopsForRoute.getStops()) {
        stopIdToStopBeanMap.put(stopBean.getId(), stopBean);
    }
    // break up stops into destinations
    List<StopGroupingBean> stopGroupings = stopsForRoute.getStopGroupings();
    for (StopGroupingBean stopGroupingBean : stopGroupings) {
        for (StopGroupBean stopGroupBean : stopGroupingBean.getStopGroups()) {
            NameBean name = stopGroupBean.getName();
            String type = name.getType();
            if (!type.equals("destination") || !stopGroupBean.getId().equals(_directionId))
                continue;
            if (!stopGroupBean.getStopIds().isEmpty()) {
                for (String stopId : stopGroupBean.getStopIds()) {
                    String agencyId = AgencyAndIdLibrary.convertFromString(_routeId).getAgencyId();
                    if (_transitDataService.stopHasRevenueServiceOnRoute(agencyId, stopId, stopsForRoute.getRoute().getId(), stopGroupBean.getId())) {
                        _stops.add(new StopOnRoute(stopIdToStopBeanMap.get(stopId)));
                    }
                }
            }
        }
    }
    return SUCCESS;
}
Also used : StopGroupingBean(org.onebusaway.transit_data.model.StopGroupingBean) HashMap(java.util.HashMap) StopGroupBean(org.onebusaway.transit_data.model.StopGroupBean) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) StopBean(org.onebusaway.transit_data.model.StopBean) NameBean(org.onebusaway.transit_data.model.NameBean) StopOnRoute(org.onebusaway.enterprise.webapp.actions.api.model.StopOnRoute)

Example 2 with StopOnRoute

use of org.onebusaway.enterprise.webapp.actions.api.model.StopOnRoute in project onebusaway-application-modules by camsys.

the class StopsWithinBoundsAction method execute.

@Override
public String execute() {
    if (_bounds == null) {
        return SUCCESS;
    }
    SearchQueryBean queryBean = new SearchQueryBean();
    queryBean.setType(SearchQueryBean.EQueryType.BOUNDS_OR_CLOSEST);
    queryBean.setBounds(_bounds);
    queryBean.setMaxCount(200);
    StopsBean stops = null;
    try {
        stops = _transitDataService.getStops(queryBean);
    } catch (OutOfServiceAreaServiceException e) {
        _log.error(" invalid results: ", e);
        return SUCCESS;
    }
    for (StopBean stop : stops.getStops()) {
        String agencyId = AgencyAndIdLibrary.convertFromString(stop.getId()).getAgencyId();
        if (_transitDataService.stopHasRevenueService(agencyId, stop.getId())) {
            _stops.add(new StopOnRoute(stop));
        }
    }
    return SUCCESS;
}
Also used : SearchQueryBean(org.onebusaway.transit_data.model.SearchQueryBean) OutOfServiceAreaServiceException(org.onebusaway.exceptions.OutOfServiceAreaServiceException) StopBean(org.onebusaway.transit_data.model.StopBean) StopOnRoute(org.onebusaway.enterprise.webapp.actions.api.model.StopOnRoute) StopsBean(org.onebusaway.transit_data.model.StopsBean)

Aggregations

StopOnRoute (org.onebusaway.enterprise.webapp.actions.api.model.StopOnRoute)2 StopBean (org.onebusaway.transit_data.model.StopBean)2 HashMap (java.util.HashMap)1 OutOfServiceAreaServiceException (org.onebusaway.exceptions.OutOfServiceAreaServiceException)1 NameBean (org.onebusaway.transit_data.model.NameBean)1 SearchQueryBean (org.onebusaway.transit_data.model.SearchQueryBean)1 StopGroupBean (org.onebusaway.transit_data.model.StopGroupBean)1 StopGroupingBean (org.onebusaway.transit_data.model.StopGroupingBean)1 StopsBean (org.onebusaway.transit_data.model.StopsBean)1 StopsForRouteBean (org.onebusaway.transit_data.model.StopsForRouteBean)1