use of org.onebusaway.transit_data.model.StopsBean in project onebusaway-application-modules by camsys.
the class StopForCodeAction method execute.
public String execute() throws Exception {
CoordinateBounds bounds = getDefaultSearchArea();
if (bounds == null)
return NEEDS_DEFAULT_SEARCH_LOCATION;
if (_stopCode == null || _stopCode.length() == 0)
return INPUT;
SearchQueryBean searchQuery = new SearchQueryBean();
searchQuery.setBounds(bounds);
searchQuery.setMaxCount(5);
searchQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
searchQuery.setQuery(_stopCode);
StopsBean stopsBean = _transitDataService.getStops(searchQuery);
_stops = stopsBean.getStops();
if (_stops.size() == 0) {
return "noStopsFound";
} else if (_stops.size() == 1) {
StopBean stop = _stops.get(0);
_stopIds = Arrays.asList(stop.getId());
return SUCCESS;
} else {
return "multipleStopsFound";
}
}
use of org.onebusaway.transit_data.model.StopsBean in project onebusaway-application-modules by camsys.
the class StopsBeanServiceImpl method getStopsByName.
@Override
public StopsBean getStopsByName(String stopName) throws ServiceException {
List<StopBean> stopBeans = new ArrayList<StopBean>();
SearchResult<AgencyAndId> results = null;
try {
results = _searchService.searchForStopsByName(stopName, MAX_STOPS, NAME_MIN_SCORE);
for (AgencyAndId aid : results.getResultsByTopScore()) {
StopBean stopBean = _stopBeanService.getStopForId(aid);
if (stopBean != null) {
stopBeans.add(stopBean);
}
}
} catch (Exception e) {
_log.error("search failed!", e);
// simply return no results, the search was not understood
return new StopsBean();
}
if (results == null) {
return new StopsBean();
}
return constructResult(stopBeans, results.size() == MAX_STOPS);
}
Aggregations