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);
}
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) {
}
}
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);
}
Aggregations