Package org.opentripplanner.routing.spt

Examples of org.opentripplanner.routing.spt.GraphPath


        RoutingRequest options = new RoutingRequest();
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 1, 16, 0, 0);
        options.setRoutingContext(graph, entrance, stop);
        ShortestPathTree spt = aStar.getShortestPathTree(options);
       
        GraphPath path = spt.getPath(stop, false);
        assertNotNull(path);
        assertEquals(TestUtils.dateInSeconds("America/New_York", 2009, 8, 1, 16, 0, 34), path.getEndTime());
    }
View Full Code Here


        Set<Edge> usedEdges = new HashSet<Edge>();
        for (Vertex vertex : startingVertices) {
            State state = new State(vertex, options);
            ShortestPathTree spt = search.getShortestPathTree(state);
            for (Vertex endVertex : startingVertices) {
                GraphPath path = spt.getPath(endVertex, false);
                if (path != null) {
                    for (Edge edge : path.edges) {
                        usedEdges.add(edge);
                    }
                }
View Full Code Here

        RoutingRequest options = new RoutingRequest();
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 8, 0, 0);
        options.setRoutingContext(graph, stop_a, stop_c);
        ShortestPathTree spt = aStar.getShortestPathTree(options);

        GraphPath path = spt.getPath(stop_c, false);
        assertNotNull(path);
        assertEquals(6, path.states.size());
        long endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 8, 30, 0);
        assertEquals(endTime, path.getEndTime());
    }
View Full Code Here

        RoutingRequest options = new RoutingRequest();
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 0, 0);

        ShortestPathTree spt;
        GraphPath path;

        // A to B
        options.setRoutingContext(graph, stop_a, stop_b);
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(stop_b, false);
        assertNotNull(path);
        assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_b));


        // A to C
        options.setRoutingContext(graph, stop_a, stop_c);
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(stop_c, false);
        assertNotNull(path);
        assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_c));


        // A to D
        options.setRoutingContext(graph, stop_a, stop_d);
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(stop_d, false);
        assertNotNull(path);
        assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_c, stop_d));
        long endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 0, 0) + 40 * 60;
        assertEquals(endTime, path.getEndTime());

        // A to E
        options.setRoutingContext(graph, stop_a, stop_e);
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(stop_e, false);
        assertNotNull(path);
        assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_c, stop_e));
        endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 0, 0) + 70 * 60;
        assertEquals(endTime, path.getEndTime());
    }
View Full Code Here

    private GraphPath getPath(SPTService sptService, RoutingRequest proto,
            Edge startBackEdge, Vertex u, Vertex v) {
        RoutingRequest options = proto.clone();
        options.setRoutingContext(_graph, startBackEdge, u, v);
        ShortestPathTree tree = sptService.getShortestPathTree(options);
        GraphPath path = tree.getPath(v, false);
        options.cleanup();
        return path;
    }
View Full Code Here

        options.setRoutingContext(_graph, start, end);
       
        GenericAStar aStar = new GenericAStar();
       
        ShortestPathTree tree = aStar.getShortestPathTree(options);
        GraphPath path = tree.getPath(end, false);
        options.cleanup();
        assertNotNull(path);
       
        double startEndWeight = path.getWeight();
        int startEndDuration = path.getDuration();
        assertTrue(startEndWeight > 0);
        assertEquals(startEndWeight, (double) startEndDuration, 1.0 * path.edges.size());
       
        // Try every vertex in the graph as an intermediate.
        boolean violated = false;
        for (Vertex intermediate : _graph.getVertices()) {
            if (intermediate == start || intermediate == end) {
                continue;
            }
           
            GraphPath startIntermediatePath = getPath(aStar, prototypeOptions, null, start, intermediate);
            if (startIntermediatePath == null) {
                continue;
            }
           
            Edge back = startIntermediatePath.states.getLast().getBackEdge();
            GraphPath intermediateEndPath = getPath(aStar, prototypeOptions, back, intermediate, end);
            if (intermediateEndPath == null) {
                continue;
            }
           
            double startIntermediateWeight = startIntermediatePath.getWeight();
            int startIntermediateDuration = startIntermediatePath.getDuration();
            double intermediateEndWeight = intermediateEndPath.getWeight();
            int intermediateEndDuration = intermediateEndPath.getDuration();
           
            // TODO(flamholz): fix traversal so that there's no rounding at the second resolution.
            assertEquals(startIntermediateWeight, (double) startIntermediateDuration,
                    1.0 * startIntermediatePath.edges.size());           
            assertEquals(intermediateEndWeight, (double) intermediateEndDuration,
View Full Code Here

        Vertex from = graph.getVertex("osm:node:2003617278");
        Vertex to = graph.getVertex("osm:node:40446276");
        options.setRoutingContext(graph, from, to);
        options.setMode(TraverseMode.BICYCLE);
        ShortestPathTree spt = aStar.getShortestPathTree(options);
        GraphPath path = spt.getPath(to, false);
        // At the time of writing this test, the router simply doesn't find a path at all when highway=construction
        // is filtered out, thus the null check.
        if (path != null) {
            for (Edge edge : path.edges) {
                assertFalse("Path should not use the as-yet unbuilt Tilikum Crossing bridge.",
View Full Code Here

                            LOG.trace("Skipping '{}', {}, already connected.", other.getStop(),
                                    other);
                            continue;
                        }
                        double distance = 0.0;
                        GraphPath graphPath = new GraphPath(state, false);
                        CoordinateArrayListSequence coordinates = new CoordinateArrayListSequence();

                        for (Edge edge : graphPath.edges) {
                            if (edge instanceof StreetEdge) {
                                LineString geometry = edge.getGeometry();
View Full Code Here

     * Build the walksteps from the final State of a path.
     * The path may contain more than one leg, because you may need to walk the bike.
     * Therefore accumulate the geometries into one long polyline, and accumulate the walksteps.
     */
    public StreetSegment (State state) {
        GraphPath path = new GraphPath(state, false);
        CoordinateArrayListSequence coordinates = new CoordinateArrayListSequence();
        for (Edge edge : path.edges) {
            LineString geometry = edge.getGeometry();
            if (geometry != null) {
                if (coordinates.size() == 0) {
View Full Code Here

    for (StopEntry nearbyStop : stops) {

      if (nearbyStop == stop)
        continue;

      GraphPath path = _itinerariesService.getWalkingItineraryBetweenStops(
          stop, nearbyStop, now, opts);
      if (path == null)
        continue;

      int duration = (int) (path.getDuration() / 1000);
      nearbyStopsAndWalkTimes.put(nearbyStop, duration);
    }

    return nearbyStopsAndWalkTimes;
  }
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.