Search in sources :

Example 1 with NetexBundle

use of org.opentripplanner.netex.loader.NetexBundle in project OpenTripPlanner by opentripplanner.

the class NetexModule method buildGraph.

@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra, DataImportIssueStore issueStore) {
    graph.clearTimeZone();
    CalendarServiceData calendarServiceData = new CalendarServiceData();
    try {
        for (NetexBundle netexBundle : netexBundles) {
            netexBundle.checkInputs();
            OtpTransitServiceBuilder transitBuilder = netexBundle.loadBundle(graph.deduplicator, issueStore);
            transitBuilder.limitServiceDays(transitPeriodLimit);
            calendarServiceData.add(transitBuilder.buildCalendarServiceData());
            OtpTransitService otpService = transitBuilder.build();
            // TODO OTP2 - Move this into the AddTransitModelEntitiesToGraph
            // - and make sure thay also work with GTFS feeds - GTFS do no
            // - have operators and notice assignments.
            graph.getOperators().addAll(otpService.getAllOperators());
            graph.addNoticeAssignments(otpService.getNoticeAssignments());
            GtfsFeedId feedId = new GtfsFeedId.Builder().id(netexFeedId).build();
            AddTransitModelEntitiesToGraph.addToGraph(feedId, otpService, subwayAccessTime, graph);
            new GeometryAndBlockProcessor(otpService, fareServiceFactory, MAX_STOP_TO_SHAPE_SNAP_DISTANCE, maxInterlineDistance).run(graph, issueStore);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    graph.putService(CalendarServiceData.class, calendarServiceData);
    graph.updateTransitFeedValidity(calendarServiceData, issueStore);
    graph.hasTransit = true;
    graph.calculateTransitCenter();
}
Also used : CalendarServiceData(org.opentripplanner.model.calendar.CalendarServiceData) OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder) GeometryAndBlockProcessor(org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor) NetexBundle(org.opentripplanner.netex.loader.NetexBundle) GtfsFeedId(org.opentripplanner.graph_builder.module.GtfsFeedId) OtpTransitService(org.opentripplanner.model.OtpTransitService) OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder)

Example 2 with NetexBundle

use of org.opentripplanner.netex.loader.NetexBundle in project OpenTripPlanner by opentripplanner.

the class NetexLoaderSmokeTest method smokeTestOfNetexLoadData.

/**
 * This test load a very simple Netex data set and do assertions on it.
 * For each type we assert some of the most important fields for one element
 * and then check the expected number of that type. This is not a replacement
 * for unit tests on mappers. Try to focus on relation between entities and Netex
 * import integration.
 */
@Test
public void smokeTestOfNetexLoadData() {
    // Given
    NetexBundle netexBundle = ConstantsForTests.createMinimalNetexBundle();
    // Run the check to make sure it does not throw an exception
    netexBundle.checkInputs();
    // When
    OtpTransitServiceBuilder transitBuilder = netexBundle.loadBundle(new Deduplicator(), new DataImportIssueStore(false));
    // Then - smoke test model
    OtpTransitService otpModel = transitBuilder.build();
    assertAgencies(otpModel.getAllAgencies());
    assertMultiModalStations(otpModel.getAllMultiModalStations());
    assertOperators(otpModel.getAllOperators());
    assertStops(otpModel.getAllStops());
    assertStations(otpModel.getAllStations());
    assertTripPatterns(otpModel.getTripPatterns());
    assertTrips(otpModel.getAllTrips());
    assertServiceIds(otpModel.getAllServiceIds());
    assertNoticeAssignments(otpModel.getNoticeAssignments());
    // And then - smoke test service calendar
    assetServiceCalendar(transitBuilder.buildCalendarServiceData());
}
Also used : OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder) NetexBundle(org.opentripplanner.netex.loader.NetexBundle) OtpTransitService(org.opentripplanner.model.OtpTransitService) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore) Deduplicator(org.opentripplanner.routing.trippattern.Deduplicator) Test(org.junit.Test)

Example 3 with NetexBundle

use of org.opentripplanner.netex.loader.NetexBundle in project OpenTripPlanner by opentripplanner.

the class NetexConfig method netexModule.

private NetexModule netexModule(Iterable<DataSource> netexSources) {
    List<NetexBundle> netexBundles = new ArrayList<>();
    for (DataSource it : netexSources) {
        NetexBundle netexBundle = netexBundle((CompositeDataSource) it);
        netexBundles.add(netexBundle);
    }
    return new NetexModule(buildParams.netex.netexFeedId, buildParams.parentStopLinking, buildParams.stationTransfers, buildParams.getSubwayAccessTimeSeconds(), buildParams.maxInterlineDistance, buildParams.getTransitServicePeriod(), netexBundles);
}
Also used : NetexModule(org.opentripplanner.netex.NetexModule) NetexBundle(org.opentripplanner.netex.loader.NetexBundle) ArrayList(java.util.ArrayList) DataSource(org.opentripplanner.datastore.DataSource) CompositeDataSource(org.opentripplanner.datastore.CompositeDataSource) ZipFileDataSource(org.opentripplanner.datastore.file.ZipFileDataSource)

Aggregations

NetexBundle (org.opentripplanner.netex.loader.NetexBundle)3 OtpTransitService (org.opentripplanner.model.OtpTransitService)2 OtpTransitServiceBuilder (org.opentripplanner.model.impl.OtpTransitServiceBuilder)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 CompositeDataSource (org.opentripplanner.datastore.CompositeDataSource)1 DataSource (org.opentripplanner.datastore.DataSource)1 ZipFileDataSource (org.opentripplanner.datastore.file.ZipFileDataSource)1 DataImportIssueStore (org.opentripplanner.graph_builder.DataImportIssueStore)1 GtfsFeedId (org.opentripplanner.graph_builder.module.GtfsFeedId)1 GeometryAndBlockProcessor (org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor)1 CalendarServiceData (org.opentripplanner.model.calendar.CalendarServiceData)1 NetexModule (org.opentripplanner.netex.NetexModule)1 Deduplicator (org.opentripplanner.routing.trippattern.Deduplicator)1