use of org.onebusaway.enterprise.webapp.actions.api.model.RouteAtStop in project onebusaway-application-modules by camsys.
the class SearchResultFactoryImpl method getStopResult.
@Override
public SearchResult getStopResult(StopBean stopBean, Set<RouteBean> routeFilter) {
List<RouteAtStop> routesAtStop = new ArrayList<RouteAtStop>();
for (RouteBean routeBean : stopBean.getRoutes()) {
StopsForRouteBean stopsForRoute = _transitDataService.getStopsForRoute(routeBean.getId());
List<RouteDirection> directions = new ArrayList<RouteDirection>();
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"))
continue;
List<String> polylines = new ArrayList<String>();
for (EncodedPolylineBean polyline : stopGroupBean.getPolylines()) {
polylines.add(polyline.getPoints());
}
Boolean hasUpcomingScheduledService = null;
// We do this to prevent checking if there is service in a direction that does not even serve this stop.
if (stopGroupBean.getStopIds().contains(stopBean.getId())) {
hasUpcomingScheduledService = _transitDataService.stopHasUpcomingScheduledService((routeBean.getAgency() != null ? routeBean.getAgency().getId() : null), SystemTime.currentTimeMillis(), stopBean.getId(), routeBean.getId(), stopGroupBean.getId());
// if there are buses on route, always have "scheduled service"
Boolean routeHasVehiclesInService = _realtimeService.getVehiclesInServiceForStopAndRoute(stopBean.getId(), routeBean.getId(), SystemTime.currentTimeMillis());
if (routeHasVehiclesInService) {
hasUpcomingScheduledService = true;
}
}
directions.add(new RouteDirection(stopGroupBean, polylines, null, hasUpcomingScheduledService));
}
}
RouteAtStop routeAtStop = new RouteAtStop(routeBean, directions);
routesAtStop.add(routeAtStop);
}
return new StopResult(stopBean, routesAtStop);
}
use of org.onebusaway.enterprise.webapp.actions.api.model.RouteAtStop in project onebusaway-application-modules by camsys.
the class StopForIdAction method execute.
@Override
public String execute() {
if (_stopId == null) {
return SUCCESS;
}
StopBean stop = _transitDataService.getStop(_stopId);
if (stop == null) {
return SUCCESS;
}
List<RouteAtStop> routesAtStop = new ArrayList<RouteAtStop>();
for (RouteBean routeBean : stop.getRoutes()) {
StopsForRouteBean stopsForRoute = _transitDataService.getStopsForRoute(routeBean.getId());
List<RouteDirection> routeDirections = new ArrayList<RouteDirection>();
List<StopGroupingBean> stopGroupings = stopsForRoute.getStopGroupings();
for (StopGroupingBean stopGroupingBean : stopGroupings) {
for (StopGroupBean stopGroupBean : stopGroupingBean.getStopGroups()) {
if (_transitDataService.stopHasRevenueServiceOnRoute((routeBean.getAgency() != null ? routeBean.getAgency().getId() : null), _stopId, routeBean.getId(), stopGroupBean.getId())) {
NameBean name = stopGroupBean.getName();
String type = name.getType();
if (!type.equals("destination"))
continue;
// filter out route directions that don't stop at this stop
if (!stopGroupBean.getStopIds().contains(_stopId))
continue;
Boolean hasUpcomingScheduledService = _transitDataService.stopHasUpcomingScheduledService((routeBean.getAgency() != null ? routeBean.getAgency().getId() : null), SystemTime.currentTimeMillis(), stop.getId(), routeBean.getId(), stopGroupBean.getId());
// if there are buses on route, always have "scheduled service"
Boolean routeHasVehiclesInService = true;
if (routeHasVehiclesInService) {
hasUpcomingScheduledService = true;
}
routeDirections.add(new RouteDirection(stopGroupBean, null, null, hasUpcomingScheduledService));
}
}
}
RouteAtStop routeAtStop = new RouteAtStop(routeBean, routeDirections);
routesAtStop.add(routeAtStop);
}
_result = new StopResult(stop, routesAtStop);
List<MonitoredStopVisitStructure> visits = _realtimeService.getMonitoredStopVisitsForStop(_stopId, 0, SystemTime.currentTimeMillis());
_response = generateSiriResponse(visits, AgencyAndIdLibrary.convertFromString(_stopId));
return SUCCESS;
}
Aggregations