public PrepareLandmarks(Directory dir, GraphHopperStorage graph, Weighting weighting, int landmarks, int activeLandmarks) { if (activeLandmarks > landmarks) throw new IllegalArgumentException("Default value for active landmarks " + activeLandmarks + " should be less or equal to landmark count of " + landmarks); this.graph = graph; this.defaultActiveLandmarks = activeLandmarks; this.weighting = weighting; lms = new LandmarkStorage(graph, dir, weighting, landmarks); }
@Test public void testInfinitWeight() { Directory dir = new RAMDirectory(); EdgeIteratorState edge = ghStorage.edge(0, 1); int res = new LandmarkStorage(ghStorage, dir, new FastestWeighting(encoder) { @Override public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) { return Integer.MAX_VALUE * 2L; } }, 8).setMaximumWeight(LandmarkStorage.PRECISION).calcWeight(edge, false); assertEquals(Integer.MAX_VALUE, res); dir = new RAMDirectory(); res = new LandmarkStorage(ghStorage, dir, new FastestWeighting(encoder) { @Override public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) { return Double.POSITIVE_INFINITY; } }, 8).setMaximumWeight(LandmarkStorage.PRECISION).calcWeight(edge, false); assertEquals(Integer.MAX_VALUE, res); }
da.create(2000); LandmarkStorage lms = new LandmarkStorage(ghStorage, dir, new FastestWeighting(encoder), 4). setMaximumWeight(LandmarkStorage.PRECISION);
@Test public void testWithSubnetworks2() { // should not happen with subnetwork preparation // 0 - 1 - 2 = 3 - 4 ghStorage.edge(0, 1, 10, true); ghStorage.edge(1, 2, 10, true); ghStorage.edge(2, 3, 10, false); ghStorage.edge(3, 2, 10, false); ghStorage.edge(3, 4, 10, true); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); storage.setMinimumNodes(3); storage.createLandmarks(); assertEquals(2, storage.getSubnetworksWithLandmarks()); assertEquals("[4, 0]", Arrays.toString(storage.getLandmarks(1))); }
@Test public void testWithSubnetworks() { ghStorage.edge(0, 1, 10, true); ghStorage.edge(1, 2, 10, true); ghStorage.edge(2, 4).setFlags(encoder.setAccess(0, false, false)); ghStorage.edge(4, 5, 10, true); ghStorage.edge(5, 6, 10, false); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); storage.setMinimumNodes(2); storage.createLandmarks(); assertEquals(3, storage.getSubnetworksWithLandmarks()); assertEquals("[2, 0]", Arrays.toString(storage.getLandmarks(1))); assertEquals("[6, 4]", Arrays.toString(storage.getLandmarks(2))); }
@Test public void testWeightingConsistence() { // create an indifferent problem: shortest weighting can pass the speed==0 edge but fastest cannot (?) ghStorage.edge(0, 1, 10, true); ghStorage.edge(1, 2).setDistance(10).setFlags(encoder.setProperties(0.9, true, true)); ghStorage.edge(2, 3, 10, true); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); storage.setMinimumNodes(2); storage.createLandmarks(); assertEquals(2, storage.getSubnetworksWithLandmarks()); assertEquals("[1, 0]", Arrays.toString(storage.getLandmarks(1))); }
@Test public void testWithOnewaySubnetworks() { // should not happen with subnetwork preparation // create an indifferent problem: node 2 and 3 are part of two 'disconnected' subnetworks ghStorage.edge(0, 1, 10, true); ghStorage.edge(1, 2, 10, false); ghStorage.edge(2, 3, 10, false); ghStorage.edge(4, 5, 10, true); ghStorage.edge(5, 2, 10, false); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); storage.setMinimumNodes(2); storage.createLandmarks(); assertEquals(2, storage.getSubnetworksWithLandmarks()); assertEquals("[4, 0]", Arrays.toString(storage.getLandmarks(1))); }
AbstractRoutingAlgorithmTester.initBiGraph(ghStorage); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); final SpatialRule ruleRight = new DefaultSpatialRule() { @Override
@Test public void testDeltaWarning() { int distance = 1000000; ghStorage.edge(1, 2, distance, false); ghStorage.edge(2, 3, distance, false); ghStorage.edge(3, 4, distance, false); ghStorage.edge(4, 5, distance, false); ghStorage.edge(5, 6, distance, false); ghStorage.edge(6, 1, distance, false); ghStorage.edge(1, 7, distance, true); ghStorage.edge(7, 8, distance, true); ghStorage.edge(8, 9, distance, true); ghStorage.edge(6, 10, distance, true); ghStorage.edge(10, 11, distance, true); ghStorage.edge(11, 12, distance, true); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); storage.createLandmarks(); assertEquals(12, storage.getLandmarks(1)[0]); assertEquals(9, storage.getLandmarks(1)[1]); assertEquals((int) Math.pow(2, 13) - 2, storage.getToWeight(0, 9) - storage.getFromWeight(0, 9)); assertEquals((int) -Math.pow(2, 13), storage.getToWeight(1, 12) - storage.getFromWeight(1, 12)); } }
LandmarkStorage store = new LandmarkStorage(graph, dir, weighting, lm); store.setMinimumNodes(2); store.createLandmarks();
public PrepareLandmarks(Directory dir, GraphHopperStorage graph, Weighting weighting, int landmarks, int activeLandmarks) { if (activeLandmarks > landmarks) throw new IllegalArgumentException("Default value for active landmarks " + activeLandmarks + " should be less or equal to landmark count of " + landmarks); this.graph = graph; this.defaultActiveLandmarks = activeLandmarks; this.weighting = weighting; lms = new LandmarkStorage(graph, dir, weighting, landmarks); }
ghStorage.edge(14, 15, distance, true); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); storage.createLandmarks();
public PrepareLandmarks(Directory dir, GraphHopperStorage graph, Weighting weighting, TraversalMode traversalMode, int landmarks, int activeLandmarks) { if (activeLandmarks > landmarks) throw new IllegalArgumentException("Default value for active landmarks " + activeLandmarks + " should be less or equal to landmark count of " + landmarks); this.graph = graph; this.defaultActiveLandmarks = activeLandmarks; this.weighting = weighting; lms = new LandmarkStorage(graph, dir, landmarks, weighting, traversalMode); }