use of org.onebusaway.api.actions.siri.model.StopRouteDirection in project onebusaway-application-modules by camsys.
the class RealtimeServiceV2Impl method processAnnotatedStopPoints.
private void processAnnotatedStopPoints(List<String> agencyIds, List<AgencyAndId> routeIds, List<StopBean> stopBeans, List<AnnotatedStopPointStructure> annotatedStopPoints, Map<Filters, String> filters, Map<String, StopsForRouteBean> stopsForRouteCache, DetailLevel detailLevel, long currentTime) {
for (StopBean stopBean : stopBeans) {
List<StopsForRouteBean> stopsForRouteList = new ArrayList<StopsForRouteBean>();
boolean filterByLineRef = (routeIds != null && routeIds.size() > 0) ? true : false;
boolean containsLineRef = false;
// Get a list of all the routes for the stop
for (RouteBean route : stopBean.getRoutes()) {
// Filter By AgencyID
if (route.getAgency() == null || !agencyIds.contains(route.getAgency().getId()))
continue;
// Add list of stops retreived from route to cache
StopsForRouteBean stopsForRoute = stopsForRouteCache.get(route.getId());
if (stopsForRoute == null) {
stopsForRoute = _transitDataService.getStopsForRoute(route.getId());
stopsForRouteCache.put(route.getId(), stopsForRoute);
}
if (stopsForRoute != null)
stopsForRouteList.add(stopsForRoute);
if (filterByLineRef && routeIds.contains(AgencyAndIdLibrary.convertFromString(route.getId())))
containsLineRef = true;
}
// Filter By LineRef
if (filterByLineRef && !containsLineRef)
continue;
// Get Stops with List of Routes, Direction, and Upcoming Service Info
StopRouteDirection stopRouteDirection = getStopRouteDirection(stopBean, stopsForRouteList, filters);
// Skip if No Route Directions Found
if (stopRouteDirection == null)
continue;
// Used to filter stops that don't have any routes that match hasUpcomingScheduledStop
if (stopRouteDirection.getRouteDirections() == null || stopRouteDirection.getRouteDirections().size() == 0)
continue;
AnnotatedStopPointStructure annotatedStopPoint = new AnnotatedStopPointStructure();
boolean isValid = SiriSupportV2.fillAnnotatedStopPointStructure(annotatedStopPoint, stopRouteDirection, filters, detailLevel, currentTime);
if (isValid)
annotatedStopPoints.add(annotatedStopPoint);
}
}
use of org.onebusaway.api.actions.siri.model.StopRouteDirection in project onebusaway-application-modules by camsys.
the class RealtimeServiceV2Impl method getStopRouteDirection.
private StopRouteDirection getStopRouteDirection(StopBean stop, List<StopsForRouteBean> stopsForRouteList, Map<Filters, String> filters) {
// Filter Values
String upcomingScheduledServiceFilter = filters.get(Filters.UPCOMING_SCHEDULED_SERVICE);
String directionIdFilter = filters.get(Filters.DIRECTION_REF);
StopRouteDirection stopRouteDirection = new StopRouteDirection(stop);
for (StopsForRouteBean stopsForRoute : stopsForRouteList) // Check to see which stop group the specified stop exists in (usually 2 stop groups)
for (StopGroupingBean stopGrouping : stopsForRoute.getStopGroupings()) {
for (StopGroupBean stopGroup : stopGrouping.getStopGroups()) {
NameBean name = stopGroup.getName();
String type = name.getType();
String directionId = stopGroup.getId();
RouteBean route = stopsForRoute.getRoute();
// Destination and DirectionId Filter
if (!type.equals("destination") || !SiriSupportV2.passFilter(directionId, directionIdFilter))
continue;
// filter out route directions that don't stop at this stop
if (!stopGroup.getStopIds().contains(stop.getId()))
continue;
// filter hasUpcomingScheduledService
Boolean hasUpcomingScheduledService = _transitDataService.stopHasUpcomingScheduledService((route.getAgency() != null ? route.getAgency().getId() : null), SystemTime.currentTimeMillis(), stop.getId(), stopsForRoute.getRoute().getId(), directionId);
String hasUpcomingScheduledServiceVal = String.valueOf(hasUpcomingScheduledService);
if (!hasUpcomingScheduledServiceVal.trim().equals("false")) {
hasUpcomingScheduledServiceVal = "true";
}
if (!SiriSupportV2.passFilter(hasUpcomingScheduledServiceVal, upcomingScheduledServiceFilter))
continue;
stopRouteDirection.addRouteDirection(new RouteForDirection(route.getId(), directionId, hasUpcomingScheduledService));
}
}
return stopRouteDirection;
}
Aggregations