public RoutingAlgorithmFactory createRoutingFactory() { return new RoutingAlgorithmFactorySimple(); }
public RoutingAlgorithmFactory getAlgorithmFactory(HintsMap map) { RoutingAlgorithmFactory routingAlgorithmFactory = new RoutingAlgorithmFactorySimple(); for (RoutingAlgorithmFactoryDecorator decorator : algoDecorators) { if (decorator.isEnabled()) routingAlgorithmFactory = decorator.getDecoratedAlgorithmFactory(routingAlgorithmFactory, map); } return routingAlgorithmFactory; }
public RoutingAlgorithm createAlgo(Graph g, AlgorithmOptions opts) { opts = AlgorithmOptions.start(opts).algorithm(algoStr).build(); return new RoutingAlgorithmFactorySimple().createAlgo(g, opts); }
@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()); }
@Test public void testBaseGraph() { CarFlagEncoder carFE = new CarFlagEncoder(); EncodingManager em = new EncodingManager(carFE); AlgorithmOptions opts = AlgorithmOptions.start(). weighting(new ShortestWeighting(carFE)).build(); GraphHopperStorage ghStorage = createGHStorage(em, Arrays.asList(opts.getWeighting()), false); initDirectedAndDiffSpeed(ghStorage, carFE); // do CH preparation for car createFactory(ghStorage, opts); // use base graph for solving normal Dijkstra Path p1 = new RoutingAlgorithmFactorySimple().createAlgo(ghStorage, defaultOpts).calcPath(0, 3); assertEquals(IntArrayList.from(0, 1, 5, 2, 3), p1.calcNodes()); assertEquals(p1.toString(), 402.29, p1.getDistance(), 1e-2); assertEquals(p1.toString(), 144823, p1.getTime()); }
@Test public void testBaseGraphMultipleVehicles() { AlgorithmOptions footOptions = AlgorithmOptions.start(). weighting(new FastestWeighting(footEncoder)).build(); AlgorithmOptions carOptions = AlgorithmOptions.start(). weighting(new FastestWeighting(carEncoder)).build(); GraphHopperStorage g = createGHStorage(encodingManager, Arrays.asList(footOptions.getWeighting(), carOptions.getWeighting()), false); initFootVsCar(g); // do CH preparation for car RoutingAlgorithmFactory contractedFactory = createFactory(g, carOptions); // use contracted graph Path p1 = contractedFactory.createAlgo(getGraph(g, carOptions.getWeighting()), carOptions).calcPath(0, 7); assertEquals(IntArrayList.from(0, 4, 6, 7), p1.calcNodes()); assertEquals(p1.toString(), 15000, p1.getDistance(), 1e-6); // use base graph for solving normal Dijkstra via car Path p2 = new RoutingAlgorithmFactorySimple().createAlgo(g, carOptions).calcPath(0, 7); assertEquals(IntArrayList.from(0, 4, 6, 7), p2.calcNodes()); assertEquals(p2.toString(), 15000, p2.getDistance(), 1e-6); assertEquals(p2.toString(), 2700 * 1000, p2.getTime()); // use base graph for solving normal Dijkstra via foot Path p3 = new RoutingAlgorithmFactorySimple().createAlgo(g, footOptions).calcPath(0, 7); assertEquals(p3.toString(), 17000, p3.getDistance(), 1e-6); assertEquals(p3.toString(), 12240 * 1000, p3.getTime()); assertEquals(IntArrayList.from(0, 4, 5, 7), p3.calcNodes()); }
public RoutingAlgorithmFactory createRoutingFactory() { return new RoutingAlgorithmFactorySimple(); }
public RoutingAlgorithmFactory createRoutingFactory() { return new RoutingAlgorithmFactorySimple(); }
public RoutingAlgorithm createAlgo( Graph qGraph ) { return new RoutingAlgorithmFactorySimple().createAlgo(qGraph, opts); }
public RoutingAlgorithmFactory getAlgorithmFactory( HintsMap map ) { RoutingAlgorithmFactory routingAlgorithmFactory = new RoutingAlgorithmFactorySimple(); for (RoutingAlgorithmFactoryDecorator decorator : algoDecorators) { if (decorator.isEnabled()) routingAlgorithmFactory = decorator.getDecoratedAlgorithmFactory(routingAlgorithmFactory, map); } return routingAlgorithmFactory; }
public RoutingAlgorithmFactory getAlgorithmFactory(HintsMap map) { RoutingAlgorithmFactory routingAlgorithmFactory = new RoutingAlgorithmFactorySimple(); for (RoutingAlgorithmFactoryDecorator decorator : algoDecorators) { if (decorator.isEnabled()) routingAlgorithmFactory = decorator.getDecoratedAlgorithmFactory(routingAlgorithmFactory, map); } return routingAlgorithmFactory; }
public RoutingAlgorithmFactory getAlgorithmFactory(HintsMap map) { RoutingAlgorithmFactory routingAlgorithmFactory = new RoutingAlgorithmFactorySimple(); for (RoutingAlgorithmFactoryDecorator decorator : algoDecorators) { if (decorator.isEnabled()) routingAlgorithmFactory = decorator.getDecoratedAlgorithmFactory(routingAlgorithmFactory, map); } return routingAlgorithmFactory; }