Search in sources :

Example 1 with TransitLayerUpdater

use of org.opentripplanner.routing.algorithm.raptor.transit.mappers.TransitLayerUpdater in project OpenTripPlanner by opentripplanner.

the class Router method startup.

/*
     * Below is functionality moved into Router from the "router lifecycle manager" interface and implementation.
     * Current responsibilities are: 1) Binding proper services (depending on the configuration from command-line or
     * JSON config files) and 2) starting / stopping real-time updaters (delegated to the GraphUpdaterConfigurator class).
     */
/**
 * Start up a new router once it has been created.
 */
public void startup() {
    this.tileRendererManager = new TileRendererManager(this.graph);
    this.defaultRoutingRequest = routerConfig.routingRequestDefaults();
    if (routerConfig.requestLogFile() != null) {
        this.requestLogger = createLogger(routerConfig.requestLogFile());
        LOG.info("Logging incoming requests at '{}'", routerConfig.requestLogFile());
    } else {
        LOG.info("Incoming requests will not be logged.");
    }
    /* Create transit layer for Raptor routing. Here we map the scheduled timetables. */
    /* Realtime updates can be mapped similarly by a recurring operation in a GraphUpdater below. */
    LOG.info("Creating transit layer for Raptor routing.");
    if (graph.hasTransit && graph.index != null) {
        graph.setTransitLayer(TransitLayerMapper.map(routerConfig.transitTuningParameters(), graph));
        graph.setRealtimeTransitLayer(new TransitLayer(graph.getTransitLayer()));
        graph.transitLayerUpdater = new TransitLayerUpdater(graph, graph.index.getServiceCodesRunningForDate());
    } else {
        LOG.warn("Cannot create Raptor data, that requires the graph to have transit data and be indexed.");
    }
    /* Create Graph updater modules from JSON config. */
    GraphUpdaterConfigurator.setupGraph(this.graph, routerConfig.updaterConfig());
    /* Compute ellipsoidToGeoidDifference for this Graph */
    try {
        WorldEnvelope env = graph.getEnvelope();
        double lat = (env.getLowerLeftLatitude() + env.getUpperRightLatitude()) / 2;
        double lon = (env.getLowerLeftLongitude() + env.getUpperRightLongitude()) / 2;
        graph.ellipsoidToGeoidDifference = ElevationUtils.computeEllipsoidToGeoidDifference(lat, lon);
        LOG.info("Computed ellipsoid/geoid offset at (" + lat + ", " + lon + ") as " + graph.ellipsoidToGeoidDifference);
    } catch (Exception e) {
        LOG.error("Error computing ellipsoid/geoid difference");
    }
    if (OTPFeature.SandboxAPITransmodelApi.isOn()) {
        TransmodelAPI.setUp(routerConfig.transmodelApiHideFeedId(), graph, defaultRoutingRequest);
    }
}
Also used : TileRendererManager(org.opentripplanner.inspector.TileRendererManager) TransitLayerUpdater(org.opentripplanner.routing.algorithm.raptor.transit.mappers.TransitLayerUpdater) WorldEnvelope(org.opentripplanner.util.WorldEnvelope) TransitLayer(org.opentripplanner.routing.algorithm.raptor.transit.TransitLayer)

Aggregations

TileRendererManager (org.opentripplanner.inspector.TileRendererManager)1 TransitLayer (org.opentripplanner.routing.algorithm.raptor.transit.TransitLayer)1 TransitLayerUpdater (org.opentripplanner.routing.algorithm.raptor.transit.mappers.TransitLayerUpdater)1 WorldEnvelope (org.opentripplanner.util.WorldEnvelope)1