Package org.opentripplanner.routing.services

Examples of org.opentripplanner.routing.services.SPTService


        double maxWalk = options.getMaxWalkDistance();
        double initialMaxWalk = maxWalk;
        long maxTime = options.arriveBy ? 0 : Long.MAX_VALUE;
        RoutingRequest currOptions;
       
        SPTService sptService = this.sptServiceFactory.instantiate();
       
        while (paths.size() < options.numItineraries) {
            currOptions = optionQueue.poll();
            if (currOptions == null) {
                LOG.debug("Ran out of options to try.");
                break;
            }
            currOptions.setMaxWalkDistance(maxWalk);
           
            // apply appropriate timeout
            double timeout = paths.isEmpty() ? firstPathTimeout : multiPathTimeout;
           
            // options.worstTime = maxTime;
            //options.maxWeight = maxWeight;
            long subsearchBeginTime = System.currentTimeMillis();
           
            LOG.debug("BEGIN SUBSEARCH");
            ShortestPathTree spt = sptService.getShortestPathTree(currOptions, timeout);
            if (spt == null) {
                // Serious failure, no paths provided. This could be signaled with an exception.
                LOG.warn("Aborting search. {} paths found, elapsed time {} sec",
                        paths.size(), (System.currentTimeMillis() - searchBeginTime) / 1000.0);
                break;
View Full Code Here


  }

    @Override
    public List<GraphPath> getPaths(RoutingRequest options) {
     
      SPTService sptService = this.sptServiceFactory.instantiate();

        ArrayList<GraphPath> paths = new ArrayList<GraphPath>();

        // make sure the options has a routing context *before* cloning it (otherwise you get
        // orphan RoutingContexts leaving temporary edges in the graph until GC)
        if (options.rctx == null) {
            options.setRoutingContext(graphService.getGraph(options.routerId));
            options.rctx.pathParsers = new PathParser[] { new BasicPathParser(),
                    new NoThruTrafficPathParser() };
        }

        long searchBeginTime = System.currentTimeMillis();
       
        ShortestPathTree spt = sptService.getShortestPathTree(options, timeout);
       
        if(sptVisitor!=null){
          System.out.println( "setting spt" );
          sptVisitor.spt = spt;
        } else {
View Full Code Here

        if (options == null) {
            LOG.error("PathService was passed a null routing request.");
            return null;
        }
       
        SPTService sptService = this.sptServiceFactory.instantiate();

        if (options.rctx == null) {
            options.setRoutingContext(graphService.getGraph(options.routerId));
            options.rctx.pathParsers = new PathParser[] { new Parser() };
        }

        LOG.debug("rreq={}", options);
       
        RemainingWeightHeuristic heuristic;
        if (options.disableRemainingWeightHeuristic) {
            heuristic = new TrivialRemainingWeightHeuristic();
        } else if (options.modes.isTransit()) {
            // Only use the BiDi heuristic for transit.
            heuristic = new InterleavedBidirectionalHeuristic(options.rctx.graph);
        } else {
            heuristic = new DefaultRemainingWeightHeuristic();
        }
        options.rctx.remainingWeightHeuristic = heuristic;
        /* In RoutingRequest, maxTransfers defaults to 2. Over long distances, we may see
         * itineraries with far more transfers. We do not expect transfer limiting to improve
         * search times on the LongDistancePathService, so we set it to the maximum we ever expect
         * to see. Because people may use either the traditional path services or the
         * LongDistancePathService, we do not change the global default but override it here. */
        options.setMaxTransfers(10);

        /* In long distance mode, maxWalk has a different meaning. It's the radius around the origin or destination
         * within which you can walk on the streets. If no value is provided, max walk defaults to the largest
         * double-precision float. This would cause long distance mode to do unbounded street searches and consider
         * the whole graph walkable. */
        if (options.maxWalkDistance == Double.MAX_VALUE) options.maxWalkDistance = DEFAULT_MAX_WALK;
        if (options.maxWalkDistance > CLAMP_MAX_WALK) options.maxWalkDistance = CLAMP_MAX_WALK;

        long searchBeginTime = System.currentTimeMillis();
        LOG.debug("BEGIN SEARCH");
        ShortestPathTree spt = sptService.getShortestPathTree(options, timeout);
        LOG.debug("END SEARCH ({} msec)", System.currentTimeMillis() - searchBeginTime);
       
        if (spt == null) { // timeout or other fail
            LOG.warn("SPT was null.");
            return null;
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.services.SPTService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.