Package org.opentripplanner.routing.graph

Examples of org.opentripplanner.routing.graph.Graph


    private GenericAStar aStar = new GenericAStar();

    public void setUp() throws Exception {
        GtfsContext context = GtfsLibrary.readGtfs(new File(ConstantsForTests.FAKE_GTFS));
        graph = new Graph();
        GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
        factory.run(graph);
        graph.putService(CalendarServiceData.class,
                GtfsLibrary.createCalendarServiceData(context.getDao()));
    }
View Full Code Here


    private GenericAStar aStar = new GenericAStar();

    public void setUp() throws Exception {
        GtfsContext context = GtfsLibrary.readGtfs(new File(ConstantsForTests.FAKE_GTFS));
        options = new RoutingRequest();
        graph = new Graph();
        GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
        factory.run(graph);
        graph.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
        graph.index(new DefaultStreetVertexIndexFactory());
    }
View Full Code Here

    public SimpleIntersectionTraversalCostModel costModel;
   
    @Before
    public void before() {
        _graph = new Graph();
        costModel = new SimpleIntersectionTraversalCostModel();
       
        // Initialize the routing request.
        options = new RoutingRequest();
        options.carSpeed = 1.0;
View Full Code Here

        // Create a star search
        aStar = new GenericAStar();

        // Create graph
        GtfsContext context = GtfsLibrary.readGtfs(new File(ConstantsForTests.FAKE_GTFS));
        graph = spy(new Graph());
        GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
        factory.run(graph);
        graph.index(new DefaultStreetVertexIndexFactory());
        graph.putService(CalendarServiceData.class,
                GtfsLibrary.createCalendarServiceData(context.getDao()));
View Full Code Here

    public BikeRentalStationList getBikeRentalStations(
            @QueryParam("lowerLeft") String lowerLeft,
            @QueryParam("upperRight") String upperRight,
            @PathParam("routerId") String routerId) {

        Graph graph = server.graphService.getGraph(routerId);
        if (graph == null) return null;
        BikeRentalStationService bikeRentalService = graph.getService(BikeRentalStationService.class);
        if (bikeRentalService == null) return new BikeRentalStationList();
        Envelope envelope;
        if (lowerLeft != null) {
            envelope = getEnvelope(lowerLeft, upperRight);
        } else {
View Full Code Here

   
    /** @return a map from each vertex to minimum travel time over the course of the day. */
    private Map<Vertex, Double> makePoints () throws Exception {
        rangeCheckParameters();
        request = buildRequest(0);
        Graph graph = otpServer.graphService.getGraph();
        //double speed = request.getWalkSpeed();
        Coordinate originCoord = request.from.getCoordinate();
        if (originCoord == null) return null;
        List<TransitStop> stops = graph.streetIndex.getNearbyTransitStops(originCoord, radiusMeters);
        if (stops.isEmpty()) {
            LOG.error("No stops found within {} meters.", radiusMeters);
            return null;
        }
        if (shpName == null)
            shpName = stops.get(0).getName().split(" ")[0];  
        StreetVertex origin = new IntersectionVertex(graph, "iso_temp", originCoord.x, originCoord.y);
        for (TransitStop stop : stops) {
            new StreetTransitLink(origin, stop, false);
            LOG.debug("linked to stop {}", stop.getName());
        }
        request.setRoutingContext(graph, origin, null);
       
        /* Make one request every M minutes over H hours */
        int nRequests = (requestTimespanHours * 60) / requestSpacingMinutes;
        request.clampInitialWait = (requestSpacingMinutes * 60);
        Date date = request.getDateTime();
        MinMap<Vertex, Double> points = new MinMap<Vertex, Double>();
        for (int r = 0; r < nRequests; r++) {
            request.dateTime = date.getTime() / 1000 + r * requestSpacingMinutes * 60;
            LOG.debug("date: {} {}", new Date(request.dateTime), request.dateTime);
            ShortestPathTree spt = sptService.getShortestPathTree(request, 10);
            /* This could even be a good use for a generic SPT merging function */
            for (State s : spt.getAllStates()) {
                if ( stopsOnly && ! (s.getVertex() instanceof TransitStop)) continue;
                points.putMin(s.getVertex(), (double)(s.getActiveTime()));
            }
        }
        graph.removeVertexAndEdges(origin);
        return points;
    }
View Full Code Here

        basePath = new File("test_graphs");
        if (!basePath.exists())
            basePath.mkdir();

        // Create an empty graph and it's serialized form
        emptyGraph = new Graph();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        emptyGraph.save(new ObjectOutputStream(baos));
        emptyGraphData = baos.toByteArray();

        // Create a small graph with 2 vertices and one edge and it's serialized form
        smallGraph = new Graph();
        StreetVertex v1 = new IntersectionVertex(smallGraph, "v1", 0, 0);
        StreetVertex v2 = new IntersectionVertex(smallGraph, "v2", 0, 0.1);
        new StreetEdge(v1, v2, null, "v1v2", 11000, StreetTraversalPermission.PEDESTRIAN, false);
        baos = new ByteArrayOutputStream();
        smallGraph.save(new ObjectOutputStream(baos));
View Full Code Here

        GraphServiceImpl graphService = new GraphServiceImpl();
        graphService.registerGraph("A", new MemoryGraphSource("A", emptyGraph));
        assertEquals(1, graphService.getRouterIds().size());

        Graph graph = graphService.getGraph("A");
        assertNotNull(graph);
        assertEquals(emptyGraph, graph);
        assertEquals("A", emptyGraph.routerId);

        try {
View Full Code Here

        boolean registered = graphService.registerGraph("A",
                graphSourceFactory.createGraphSource("A"));
        assertTrue(registered);

        // Check if the loaded graph is the one we saved earlier
        Graph graph = graphService.getGraph("A");
        assertNotNull(graph);
        assertEquals("A", graph.routerId);
        assertEquals(0, graph.getVertices().size());
        assertEquals(1, graphService.getRouterIds().size());

        // Save A again, with more data this time
        int verticesCount = smallGraph.getVertices().size();
        int edgesCount = smallGraph.getEdges().size();
        graphSourceFactory.save("A", new ByteArrayInputStream(smallGraphData));

        // Force a reload, get again the graph
        graphService.reloadGraphs(false);
        graph = graphService.getGraph("A");

        // Check if loaded graph is the one modified
        assertEquals(verticesCount, graph.getVertices().size());
        assertEquals(edgesCount, graph.getEdges().size());

        // Remove the file from disk and reload
        boolean deleted = new File(new File(basePath, "A"), InputStreamGraphSource.GRAPH_FILENAME)
                .delete();
        assertTrue(deleted);
View Full Code Here

   
    private StreetEdge maple_main1, broad1_2;

    @Before
    public void before() {
        _graph = new Graph();

        // Graph for a fictional grid city with turn restrictions
        StreetVertex maple1 = vertex("maple_1st", 2.0, 2.0);
        StreetVertex maple2 = vertex("maple_2nd", 1.0, 2.0);
        StreetVertex maple3 = vertex("maple_3rd", 0.0, 2.0);
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.graph.Graph

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.