Package org.opentripplanner.routing.spt

Examples of org.opentripplanner.routing.spt.GraphPath


    /**
     * Generates a TripPlan from a set of paths
     */
    TripPlan generatePlan(List<GraphPath> paths, RoutingRequest request) {

        GraphPath exemplar = paths.get(0);
        Vertex tripStartVertex = exemplar.getStartVertex();
        Vertex tripEndVertex = exemplar.getEndVertex();
        String startName = tripStartVertex.getName();
        String endName = tripEndVertex.getName();

        // Use vertex labels if they don't have names
        if (startName == null) {
View Full Code Here


       
        Vertex firstIntermediate = shortestPath.vertices.get(0);
       
        HashMap<Vertex, GraphPath> pathsFromFV = paths.get(fromVertex);
        //get the path from the end of the first subpath
        GraphPath newPath = new GraphPath(pathsFromFV.get(firstIntermediate).states.getLast(), false);
        Vertex lastVertex = firstIntermediate;
        for (Vertex v : shortestPath.vertices.subList(1, shortestPath.vertices.size())) {
               State lastState = newPath.states.getLast();
               GraphPath subPath = paths.get(lastVertex).get(v);
               //add a leg-switching state
               LegSwitchingEdge legSwitchingEdge = new LegSwitchingEdge(lastVertex, lastVertex);
               lastState = legSwitchingEdge.traverse(lastState);
               newPath.edges.add(legSwitchingEdge);
             newPath.states.add(lastState);
View Full Code Here

       
        PathPrinter pp = ((PathPrinter) pathsList.getSelectedValue());
        if(pp==null){
          return;
        }
        GraphPath path = pp.gp;
       
        DefaultListModel<State> pathModel = new DefaultListModel<State>();
        for( State st : path.states ){
          pathModel.addElement( st );
        }
View Full Code Here

                /* the worst trip we are willing to accept is at most twice as bad or twice as long */
                if (somePaths.isEmpty()) {
                    // if there is no first path, there won't be any other paths
                    return null;
                }
                GraphPath path = somePaths.get(0);
                long duration = path.getDuration();
                LOG.debug("Setting max time and weight for subsequent searches.");
                LOG.debug("First path start time:  {}", path.getStartTime());
                maxTime = path.getStartTime() +
                      MAX_TIME_FACTOR * (currOptions.arriveBy ? -duration : duration);
                LOG.debug("First path duration:  {}", duration);
                LOG.debug("Max time set to:  {}", maxTime);
                maxWeight = path.getWeight() * MAX_WEIGHT_FACTOR;
                LOG.debug("Max weight set to:  {}", maxWeight);
                if (path.getWalkDistance() > maxWalk) {
                    maxWalk = path.getWalkDistance() * 1.25;
                }
            }
            if (somePaths.isEmpty()) {
                //try again doubling maxwalk
                LOG.debug("No paths were found.");
View Full Code Here

    public void actionPerformed(ActionEvent e) {
      PathPrinter pp = ((PathPrinter) pathsList.getSelectedValue());
      if(pp==null){
        return;
      }
      GraphPath path = pp.gp;
     
      firstComparePath = secondComparePath;
      secondComparePath = path;
     
      if(firstComparePath != null) {
View Full Code Here

     * Also test that such a LEG_SWITCH mode does not show up as part of the itinerary.
     */
    @Test
    public void testEndWithLegSwitch() {
        // Reuse testGenerateItinerary()'s graph path, but shorten it
        GraphPath graphPath = new GraphPath(buildPaths()[0].states.get(3), false);

        Itinerary itinerary = planGenerator.generateItinerary(graphPath, false);

        assertEquals(1, itinerary.legs.size());
        assertEquals("WALK", itinerary.legs.get(0).mode);
View Full Code Here

        State s54Onboard = e53.traverse(s52Onboard);
        State s56Onboard = e55.traverse(s54Onboard);
        State s58Onboard = e57.traverse(s56Onboard);
        State s60Onboard = e59.traverse(s58Onboard);

        return new GraphPath[] {new GraphPath(s60Forward, false),
                new GraphPath(s0Backward, false), new GraphPath(s60Onboard, false)};
    }
View Full Code Here

     * @return ordered list of states and edges in the journey
     */
    private GraphPath planJourney(RoutingRequest options, boolean optimize) {
        // Calculate route and convert to path
        ShortestPathTree spt = aStar.getShortestPathTree(options);
        GraphPath path = spt.getPath(options.rctx.target, optimize);

        // Return list of states and edges in the journey
        return path;
    }
View Full Code Here

        RoutingRequest options = new RoutingRequest();
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 7, 11, 11, 11, 0);
        options.setRoutingContext(graph, origin, destination);

        // Plan journey
        GraphPath path;
        List<Trip> trips;
        path = planJourney(options);
        trips = extractTrips(path);
        // Validate result
        assertEquals("8.1", trips.get(0).getId().getId());
View Full Code Here

        options.setArriveBy(true);
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 7, 12, 1, 0, 0);
        options.setRoutingContext(graph, origin, destination);

        // Plan journey
        GraphPath path;
        List<Trip> trips;
        path = planJourney(options, true);
        trips = extractTrips(path);
        // Validate result
        assertEquals("8.1", trips.get(0).getId().getId());
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.spt.GraphPath

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.