Search in sources :

Example 1 with TransitAlertServiceImpl

use of org.opentripplanner.routing.impl.TransitAlertServiceImpl in project OpenTripPlanner by opentripplanner.

the class SiriSXUpdater method setup.

@Override
public void setup(Graph graph) {
    this.transitAlertService = new TransitAlertServiceImpl(graph);
    SiriFuzzyTripMatcher fuzzyTripMatcher = new SiriFuzzyTripMatcher(new RoutingService(graph));
    if (updateHandler == null) {
        updateHandler = new SiriAlertsUpdateHandler(feedId);
    }
    updateHandler.setEarlyStart(earlyStart);
    updateHandler.setTransitAlertService(transitAlertService);
    updateHandler.setSiriFuzzyTripMatcher(fuzzyTripMatcher);
}
Also used : RoutingService(org.opentripplanner.routing.RoutingService) SiriAlertsUpdateHandler(org.opentripplanner.ext.siri.SiriAlertsUpdateHandler) TransitAlertServiceImpl(org.opentripplanner.routing.impl.TransitAlertServiceImpl) SiriFuzzyTripMatcher(org.opentripplanner.ext.siri.SiriFuzzyTripMatcher)

Example 2 with TransitAlertServiceImpl

use of org.opentripplanner.routing.impl.TransitAlertServiceImpl in project OpenTripPlanner by opentripplanner.

the class GtfsTest method setUp.

protected void setUp() {
    File gtfs = new File("src/test/resources/" + getFeedName());
    File gtfsRealTime = new File("src/test/resources/" + getFeedName() + ".pb");
    GtfsBundle gtfsBundle = new GtfsBundle(gtfs);
    feedId = new GtfsFeedId.Builder().id("FEED").build();
    gtfsBundle.setFeedId(feedId);
    List<GtfsBundle> gtfsBundleList = Collections.singletonList(gtfsBundle);
    GtfsModule gtfsGraphBuilderImpl = new GtfsModule(gtfsBundleList, ServiceDateInterval.unbounded());
    alertsUpdateHandler = new AlertsUpdateHandler();
    graph = new Graph();
    router = new Router(graph, RouterConfig.DEFAULT);
    gtfsBundle.setTransfersTxtDefinesStationPaths(true);
    gtfsGraphBuilderImpl.buildGraph(graph, null);
    // Set the agency ID to be used for tests to the first one in the feed.
    agencyId = graph.getAgencies().iterator().next().getId().getId();
    System.out.printf("Set the agency ID for this test to %s\n", agencyId);
    graph.index();
    timetableSnapshotSource = new TimetableSnapshotSource(graph);
    timetableSnapshotSource.purgeExpiredData = false;
    graph.getOrSetupTimetableSnapshotProvider(g -> timetableSnapshotSource);
    alertPatchServiceImpl = new TransitAlertServiceImpl(graph);
    alertsUpdateHandler.setTransitAlertService(alertPatchServiceImpl);
    alertsUpdateHandler.setFeedId(feedId.getId());
    try {
        final boolean fullDataset = false;
        InputStream inputStream = new FileInputStream(gtfsRealTime);
        FeedMessage feedMessage = FeedMessage.PARSER.parseFrom(inputStream);
        List<FeedEntity> feedEntityList = feedMessage.getEntityList();
        List<TripUpdate> updates = new ArrayList<TripUpdate>(feedEntityList.size());
        for (FeedEntity feedEntity : feedEntityList) {
            updates.add(feedEntity.getTripUpdate());
        }
        timetableSnapshotSource.applyTripUpdates(graph, fullDataset, updates, feedId.getId());
        alertsUpdateHandler.update(feedMessage);
    } catch (Exception exception) {
    }
}
Also used : TripUpdate(com.google.transit.realtime.GtfsRealtime.TripUpdate) GtfsFeedId(org.opentripplanner.graph_builder.module.GtfsFeedId) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) Router(org.opentripplanner.standalone.server.Router) FileInputStream(java.io.FileInputStream) FeedMessage(com.google.transit.realtime.GtfsRealtime.FeedMessage) GtfsModule(org.opentripplanner.graph_builder.module.GtfsModule) Graph(org.opentripplanner.routing.graph.Graph) GtfsBundle(org.opentripplanner.graph_builder.model.GtfsBundle) FeedEntity(com.google.transit.realtime.GtfsRealtime.FeedEntity) File(java.io.File) TransitAlertServiceImpl(org.opentripplanner.routing.impl.TransitAlertServiceImpl) TimetableSnapshotSource(org.opentripplanner.updater.stoptime.TimetableSnapshotSource) AlertsUpdateHandler(org.opentripplanner.updater.alerts.AlertsUpdateHandler)

Example 3 with TransitAlertServiceImpl

use of org.opentripplanner.routing.impl.TransitAlertServiceImpl 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)

Aggregations

TransitAlertServiceImpl (org.opentripplanner.routing.impl.TransitAlertServiceImpl)3 RoutingService (org.opentripplanner.routing.RoutingService)2 FeedEntity (com.google.transit.realtime.GtfsRealtime.FeedEntity)1 FeedMessage (com.google.transit.realtime.GtfsRealtime.FeedMessage)1 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 SiriAlertsUpdateHandler (org.opentripplanner.ext.siri.SiriAlertsUpdateHandler)1 SiriFuzzyTripMatcher (org.opentripplanner.ext.siri.SiriFuzzyTripMatcher)1 GtfsBundle (org.opentripplanner.graph_builder.model.GtfsBundle)1 GtfsFeedId (org.opentripplanner.graph_builder.module.GtfsFeedId)1 GtfsModule (org.opentripplanner.graph_builder.module.GtfsModule)1 Graph (org.opentripplanner.routing.graph.Graph)1 TransitAlertService (org.opentripplanner.routing.services.TransitAlertService)1 Router (org.opentripplanner.standalone.server.Router)1 GtfsRealtimeFuzzyTripMatcher (org.opentripplanner.updater.GtfsRealtimeFuzzyTripMatcher)1 AlertsUpdateHandler (org.opentripplanner.updater.alerts.AlertsUpdateHandler)1 TimetableSnapshotSource (org.opentripplanner.updater.stoptime.TimetableSnapshotSource)1