Search in sources :

Example 1 with TransitAlertService

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);
}
Also used : TransitAlertService(org.opentripplanner.routing.services.TransitAlertService) GtfsRealtimeFuzzyTripMatcher(org.opentripplanner.updater.GtfsRealtimeFuzzyTripMatcher) RoutingService(org.opentripplanner.routing.RoutingService) TransitAlertServiceImpl(org.opentripplanner.routing.impl.TransitAlertServiceImpl)

Example 2 with TransitAlertService

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;
}
Also used : Trip(org.opentripplanner.model.Trip) TransitAlert(org.opentripplanner.routing.alertpatch.TransitAlert) TransitAlertService(org.opentripplanner.routing.services.TransitAlertService) Stop(org.opentripplanner.model.Stop) FeedScopedId(org.opentripplanner.model.FeedScopedId) Date(java.util.Date) HashSet(java.util.HashSet)

Aggregations

TransitAlertService (org.opentripplanner.routing.services.TransitAlertService)2 Date (java.util.Date)1 HashSet (java.util.HashSet)1 FeedScopedId (org.opentripplanner.model.FeedScopedId)1 Stop (org.opentripplanner.model.Stop)1 Trip (org.opentripplanner.model.Trip)1 RoutingService (org.opentripplanner.routing.RoutingService)1 TransitAlert (org.opentripplanner.routing.alertpatch.TransitAlert)1 TransitAlertServiceImpl (org.opentripplanner.routing.impl.TransitAlertServiceImpl)1 GtfsRealtimeFuzzyTripMatcher (org.opentripplanner.updater.GtfsRealtimeFuzzyTripMatcher)1