@Override protected LocationIndex createLocationIndex(Directory dir) { return new LocationIndexTree(graph, dir); } };
protected LocationIndex createLocationIndex(Directory dir) { LocationIndexTree tmpIndex = new LocationIndexTree(ghStorage, dir); tmpIndex.setResolution(preciseIndexResolution); tmpIndex.setMaxRegionSearch(maxRegionSearch); if (!tmpIndex.loadExisting()) { ensureWriteAccess(); tmpIndex.prepareIndex(); } return tmpIndex; }
public LocationIndexTree createIndexNoPrepare(Graph g, int resolution) { Directory dir = new RAMDirectory(location); LocationIndexTree tmpIDX = new LocationIndexTree(g, dir); tmpIDX.setResolution(resolution); return tmpIDX; }
@Override public LocationIndexTree createIndexNoPrepare(Graph g, int resolution) { Directory dir = new RAMDirectory(location); LocationIndexTree tmpIdx = new LocationIndexTree(g, dir); tmpIdx.setResolution(resolution); return tmpIdx; }
public static LocationIndex createOrLoadIndex(GHDirectory directory, GraphHopperStorage graphHopperStorage) { final EdgeFilter filter = DefaultEdgeFilter.allEdges(graphHopperStorage.getEncodingManager().getEncoder("foot")); Graph walkNetwork = GraphSupport.filteredView(graphHopperStorage, filter); LocationIndex locationIndex = new LocationIndexTree(walkNetwork, directory); if (!locationIndex.loadExisting()) { locationIndex.prepareIndex(); } return locationIndex; }
walkNetworkIndex = new LocationIndexTree(graphHopperStorage, new RAMDirectory()).prepareIndex(); } else { walkNetworkIndex = new EmptyLocationIndex();
@Test public void testLookupAndCalcPaths_simpleSquareGraph() { Graph g = createSquareGraph(); // start at node 0 and head south, make sure the round trip is long enough to reach most southern node 6 GHPoint start = new GHPoint(1, -1); double heading = 180.0; int numPoints = 2; double roundTripDistance = 670000; GHRequest ghRequest = new GHRequest(Collections.singletonList(start), Collections.singletonList(heading)); ghRequest.getHints().put(Parameters.Algorithms.RoundTrip.POINTS, numPoints); ghRequest.getHints().put(Parameters.Algorithms.RoundTrip.DISTANCE, roundTripDistance); LocationIndex locationIndex = new LocationIndexTree(g, new RAMDirectory()).prepareIndex(); RoundTripRoutingTemplate routingTemplate = new RoundTripRoutingTemplate(ghRequest, new GHResponse(), locationIndex, 1); List<QueryResult> stagePoints = routingTemplate.lookup(ghRequest.getPoints(), carFE); assertEquals(3, stagePoints.size()); assertEquals(0, stagePoints.get(0).getClosestNode()); assertEquals(6, stagePoints.get(1).getClosestNode()); assertEquals(0, stagePoints.get(2).getClosestNode()); QueryGraph queryGraph = new QueryGraph(g); queryGraph.lookup(stagePoints); Weighting weighting = new FastestWeighting(carFE); List<Path> paths = routingTemplate.calcPaths( queryGraph, new RoutingAlgorithmFactorySimple(), new AlgorithmOptions(DIJKSTRA_BI, weighting, tMode)); // make sure the resulting paths are connected and form a round trip starting and ending at the start node 0 assertEquals(2, paths.size()); assertEquals(IntArrayList.from(new int[]{0, 7, 6, 5}), paths.get(0).calcNodes()); assertEquals(IntArrayList.from(new int[]{5, 4, 3, 2, 1, 0}), paths.get(1).calcNodes()); }
@Test public void testCalcRoundTrip() throws Exception { Weighting weighting = new FastestWeighting(carFE); Graph g = createTestGraph(true); RoundTripRoutingTemplate rTripRouting = new RoundTripRoutingTemplate(new GHRequest(), new GHResponse(), null, 1); LocationIndex locationIndex = new LocationIndexTree(g, new RAMDirectory()).prepareIndex(); QueryResult qr4 = locationIndex.findClosest(0.05, 0.25, EdgeFilter.ALL_EDGES); assertEquals(4, qr4.getClosestNode()); QueryResult qr5 = locationIndex.findClosest(0.00, 0.05, EdgeFilter.ALL_EDGES); assertEquals(5, qr5.getClosestNode()); QueryResult qr6 = locationIndex.findClosest(0.00, 0.10, EdgeFilter.ALL_EDGES); assertEquals(6, qr6.getClosestNode()); QueryGraph qGraph = new QueryGraph(g); qGraph.lookup(qr4, qr5); rTripRouting.setQueryResults(Arrays.asList(qr5, qr4, qr5)); List<Path> paths = rTripRouting.calcPaths(qGraph, new RoutingAlgorithmFactorySimple(), new AlgorithmOptions(DIJKSTRA_BI, weighting, tMode)); assertEquals(2, paths.size()); assertEquals(IntArrayList.from(new int[]{5, 6, 3, 4}), paths.get(0).calcNodes()); assertEquals(IntArrayList.from(new int[]{4, 8, 7, 6, 5}), paths.get(1).calcNodes()); qGraph = new QueryGraph(g); qGraph.lookup(qr4, qr6); rTripRouting.setQueryResults(Arrays.asList(qr6, qr4, qr6)); paths = rTripRouting.calcPaths(qGraph, new RoutingAlgorithmFactorySimple(), new AlgorithmOptions(DIJKSTRA_BI, weighting, tMode)); assertEquals(2, paths.size()); assertEquals(IntArrayList.from(new int[]{6, 3, 4}), paths.get(0).calcNodes()); assertEquals(IntArrayList.from(new int[]{4, 8, 7, 6}), paths.get(1).calcNodes()); }
Path calcPathViaQuery(Weighting weighting, GraphHopperStorage ghStorage, double fromLat, double fromLon, double toLat, double toLon) { LocationIndex index = new LocationIndexTree(ghStorage, new RAMDirectory()); index.prepareIndex(); QueryResult from = index.findClosest(fromLat, fromLon, EdgeFilter.ALL_EDGES); QueryResult to = index.findClosest(toLat, toLon, EdgeFilter.ALL_EDGES); // correct order for CH: in factory do prepare and afterwards wrap in query graph AlgorithmOptions opts = AlgorithmOptions.start().weighting(weighting).build(); RoutingAlgorithmFactory factory = createFactory(ghStorage, opts); QueryGraph qGraph = new QueryGraph(getGraph(ghStorage, weighting)).lookup(from, to); return factory.createAlgo(qGraph, opts). calcPath(from.getClosestNode(), to.getClosestNode()); }
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 3, 0.00, 0.00); AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 4, 0.00, 0.01); LocationIndex locationIndex = new LocationIndexTree(graph, new RAMDirectory()).prepareIndex();
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 4, 0.00, 0.01); LocationIndex locationIndex = new LocationIndexTree(graph, new RAMDirectory()) .prepareIndex();
LocationIndex index = new LocationIndexTree(graph, dir); index.prepareIndex();
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 11, 0, 3); LocationIndex locationIndex = new LocationIndexTree(graph, new RAMDirectory()) .prepareIndex();
protected LocationIndex createLocationIndex(Directory dir) { LocationIndexTree tmpIndex = new LocationIndexTree(ghStorage, dir); tmpIndex.setResolution(preciseIndexResolution); tmpIndex.setMaxRegionSearch(maxRegionSearch); if (!tmpIndex.loadExisting()) { ensureWriteAccess(); tmpIndex.prepareIndex(); } return tmpIndex; }
protected LocationIndex createLocationIndex(Directory dir) { LocationIndexTree tmpIndex = new LocationIndexTree(ghStorage, dir); tmpIndex.setResolution(preciseIndexResolution); tmpIndex.setMaxRegionSearch(maxRegionSearch); if (!tmpIndex.loadExisting()) { ensureWriteAccess(); tmpIndex.prepareIndex(); } return tmpIndex; }
protected LocationIndex createLocationIndex( Directory dir ) { LocationIndexTree tmpIndex = new LocationIndexTree(ghStorage, dir); tmpIndex.setResolution(preciseIndexResolution); tmpIndex.setMaxRegionSearch(maxRegionSearch); if (!tmpIndex.loadExisting()) { ensureWriteAccess(); tmpIndex.prepareIndex(); } return tmpIndex; }