use of org.opentripplanner.routing.services.TransitAlertService in project OpenTripPlanner by opentripplanner.
the class GtfsRealtimeAlertsUpdater method setup.
@Override
public void setup(Graph graph) {
TransitAlertService transitAlertService = new TransitAlertServiceImpl(graph);
if (fuzzyTripMatching) {
this.fuzzyTripMatcher = new GtfsRealtimeFuzzyTripMatcher(new RoutingService(graph));
}
this.transitAlertService = transitAlertService;
if (updateHandler == null) {
updateHandler = new AlertsUpdateHandler();
}
updateHandler.setEarlyStart(earlyStart);
updateHandler.setFeedId(feedId);
updateHandler.setTransitAlertService(transitAlertService);
updateHandler.setFuzzyTripMatcher(fuzzyTripMatcher);
}
use of org.opentripplanner.routing.services.TransitAlertService in project OpenTripPlanner by opentripplanner.
the class EstimatedCallType method getAllRelevantAlerts.
/**
* Resolves all AlertPatches that are relevant for the supplied TripTimeShort.
*/
private static Collection<TransitAlert> getAllRelevantAlerts(TripTimeShort tripTimeShort, RoutingService routingService) {
FeedScopedId tripId = tripTimeShort.tripId;
Trip trip = routingService.getTripForId().get(tripId);
FeedScopedId routeId = trip.getRoute().getId();
FeedScopedId stopId = tripTimeShort.stopId;
Stop stop = routingService.getStopForId(stopId);
FeedScopedId parentStopId = stop.getParentStation().getId();
Collection<TransitAlert> allAlerts = new HashSet<>();
TransitAlertService alertPatchService = routingService.getTransitAlertService();
// Quay
allAlerts.addAll(alertPatchService.getStopAlerts(stopId));
allAlerts.addAll(alertPatchService.getStopAndTripAlerts(stopId, tripId));
allAlerts.addAll(alertPatchService.getStopAndRouteAlerts(stopId, routeId));
// StopPlace
allAlerts.addAll(alertPatchService.getStopAlerts(parentStopId));
allAlerts.addAll(alertPatchService.getStopAndTripAlerts(parentStopId, tripId));
allAlerts.addAll(alertPatchService.getStopAndRouteAlerts(parentStopId, routeId));
// Trip
allAlerts.addAll(alertPatchService.getTripAlerts(tripId));
// Route
allAlerts.addAll(alertPatchService.getRouteAlerts(routeId));
// Agency
// TODO OTP2 This should probably have a FeedScopeId argument instead of string
allAlerts.addAll(alertPatchService.getAgencyAlerts(trip.getRoute().getAgency().getId()));
// TripPattern
allAlerts.addAll(alertPatchService.getTripPatternAlerts(routingService.getPatternForTrip().get(trip).getId()));
long serviceDayMillis = 1000 * tripTimeShort.serviceDay;
long arrivalMillis = 1000 * tripTimeShort.realtimeArrival;
long departureMillis = 1000 * tripTimeShort.realtimeDeparture;
filterSituationsByDateAndStopConditions(allAlerts, new Date(serviceDayMillis + arrivalMillis), new Date(serviceDayMillis + departureMillis), Arrays.asList(StopCondition.STOP, StopCondition.START_POINT, StopCondition.EXCEPTIONAL_STOP));
return allAlerts;
}
Aggregations