CHEdgeIteratorState edgeState = prepareGraph.shortcut(sc.from, sc.to); edgeState.setFlags(sc.flags); edgeState.setWeight(sc.weight); edgeState.setDistance(sc.dist);
assertTrue(Double.isInfinite(sc1.getWeight())); sc1.setFlags(flags); sc1.setWeight(100.123); assertEquals(100.123, sc1.getWeight(), 1e-3); sc1.setFlags(flags); sc1.setWeight(100.123); assertEquals(100.123, sc1.getWeight(), 1e-3); sc1.setFlags(flags); sc1.setWeight(1e-5); assertEquals(1e-3, sc1.getWeight(), 1e-10);
@Test public void testSimpleShortcutCreationAndTraversal() { graph = createGHStorage(); graph.edge(1, 3, 10, true); graph.edge(3, 4, 10, true); graph.freeze(); CHGraph lg = graph.getGraph(CHGraph.class); lg.shortcut(1, 4).setWeight(3).setFlags(carEncoder.setProperties(10, true, true)); EdgeExplorer vehicleOutExplorer = lg.createEdgeExplorer(DefaultEdgeFilter.outEdges(carEncoder)); // iteration should result in same nodes even if reusing the iterator assertEquals(GHUtility.asSet(3, 4), GHUtility.getNeighbors(vehicleOutExplorer.setBaseNode(1))); assertEquals(GHUtility.asSet(3, 4), GHUtility.getNeighbors(vehicleOutExplorer.setBaseNode(1))); }
@Test public void testGetWeightIfAdvancedEncoder() { FlagEncoder customEncoder = new Bike2WeightFlagEncoder(); EncodingManager em = new EncodingManager(customEncoder); FastestWeighting weighting = new FastestWeighting(customEncoder); GraphHopperStorage ghStorage = new GraphBuilder(em).setCHGraph(weighting).create(); ghStorage.edge(0, 2); ghStorage.freeze(); CHGraphImpl lg = (CHGraphImpl) ghStorage.getGraph(CHGraph.class, weighting); CHEdgeIteratorState sc1 = lg.shortcut(0, 1); long flags = customEncoder.setProperties(10, false, true); sc1.setFlags(flags); sc1.setWeight(100.123); assertEquals(100.123, lg.getEdgeIteratorState(sc1.getEdge(), sc1.getAdjNode()).getWeight(), 1e-3); assertEquals(100.123, lg.getEdgeIteratorState(sc1.getEdge(), sc1.getBaseNode()).getWeight(), 1e-3); assertEquals(100.123, ((CHEdgeIteratorState) GHUtility.getEdge(lg, sc1.getBaseNode(), sc1.getAdjNode())).getWeight(), 1e-3); assertEquals(100.123, ((CHEdgeIteratorState) GHUtility.getEdge(lg, sc1.getAdjNode(), sc1.getBaseNode())).getWeight(), 1e-3); sc1 = lg.shortcut(1, 0); assertTrue(sc1.isShortcut()); sc1.setFlags(PrepareEncoder.getScDirMask()); sc1.setWeight(1.011011); assertEquals(1.011011, sc1.getWeight(), 1e-3); }
edgeState.setFlags(sc.flags); edgeState.setWeight(sc.weight); edgeState.setDistance(sc.dist);
CHEdgeIteratorState edgeState = prepareGraph.shortcut(sc.from, sc.to); edgeState.setFlags(sc.flags); edgeState.setWeight(sc.weight); edgeState.setDistance(sc.dist);
CHEdgeIteratorState edgeState = prepareGraph.shortcut(sc.from, sc.to); edgeState.setFlags(sc.flags); edgeState.setWeight(sc.weight); edgeState.setDistance(sc.dist);