use of org.onebusaway.api.actions.siri.model.RouteForDirection 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;
}
use of org.onebusaway.api.actions.siri.model.RouteForDirection in project onebusaway-application-modules by camsys.
the class SiriSupportV2 method fillAnnotatedStopPointStructure.
public static boolean fillAnnotatedStopPointStructure(AnnotatedStopPointStructure annotatedStopPoint, StopRouteDirection stopRouteDirection, Map<Filters, String> filters, DetailLevel detailLevel, long currentTime) {
StopBean stopBean = stopRouteDirection.getStop();
List<RouteForDirection> routeDirections = stopRouteDirection.getRouteDirections();
// Set Stop Name
NaturalLanguageStringStructure stopName = new NaturalLanguageStringStructure();
stopName.setValue(stopBean.getName());
// Set Route and Direction
Lines lines = new Lines();
for (RouteForDirection routeDirection : routeDirections) {
String directionId = routeDirection.getDirectionId();
String routeId = routeDirection.getRouteId();
LineRefStructure line = new LineRefStructure();
line.setValue(routeId);
DirectionRefStructure direction = new DirectionRefStructure();
direction.setValue(directionId);
LineDirectionStructure lineDirection = new LineDirectionStructure();
lineDirection.setDirectionRef(direction);
lineDirection.setLineRef(line);
lines.getLineRefOrLineDirection().add(lineDirection);
}
// Set Lat and Lon
BigDecimal stopLat = new BigDecimal(stopBean.getLat());
BigDecimal stopLon = new BigDecimal(stopBean.getLon());
LocationStructure location = new LocationStructure();
location.setLongitude(stopLon.setScale(6, BigDecimal.ROUND_HALF_DOWN));
location.setLatitude(stopLat.setScale(6, BigDecimal.ROUND_HALF_DOWN));
// Set StopId
StopPointRefStructure stopPointRef = new StopPointRefStructure();
stopPointRef.setValue(stopBean.getId());
// Details -- minimum
annotatedStopPoint.getStopName().add(stopName);
// Details -- normal
if (detailLevel.equals(DetailLevel.NORMAL) || detailLevel.equals(DetailLevel.FULL)) {
annotatedStopPoint.setLocation(location);
annotatedStopPoint.setLines(lines);
annotatedStopPoint.setMonitored(true);
}
annotatedStopPoint.setStopPointRef(stopPointRef);
return true;
}
Aggregations