@Override protected GraphHopperStorage newGHStorage(Directory dir, boolean is3D) { turnCostStorage = new TurnCostExtension(); return new GraphHopperStorage(dir, encodingManager, is3D, turnCostStorage); }
/** * Default graph is a {@link GraphHopperStorage} with an in memory directory and disabled storing on flush. * Afterwards you'll need to call {@link GraphHopperStorage#create} to have a usable object. Better use * {@link GraphHopperStorage#create} directly. */ public GraphHopperStorage build() { Directory dir = mmap ? new MMapDirectory(location) : new RAMDirectory(location, store); GraphHopperStorage graph; if (encodingManager.needsTurnCostsSupport() || singleCHWeighting == null) graph = new GraphHopperStorage(dir, encodingManager, elevation, new TurnCostExtension()); else graph = new GraphHopperStorage(Arrays.asList(singleCHWeighting), dir, encodingManager, elevation, new TurnCostExtension.NoOpExtension()); return graph; }
? new TurnCostExtension() : new GraphExtension.NoOpExtension();
@Test public void testTurnCostsProperlyPropagated_Issue282() { TurnCostExtension turnExt = new TurnCostExtension(); FlagEncoder encoder = new CarFlagEncoder(5, 5, 15); GraphHopperStorage graphWithTurnCosts = new GraphHopperStorage(new RAMDirectory(), new EncodingManager(encoder), false, turnExt). create(100); NodeAccess na = graphWithTurnCosts.getNodeAccess(); na.setNode(0, .00, .00); na.setNode(1, .00, .01); na.setNode(2, .01, .01); EdgeIteratorState edge0 = graphWithTurnCosts.edge(0, 1, 10, true); EdgeIteratorState edge1 = graphWithTurnCosts.edge(2, 1, 10, true); QueryGraph qGraph = new QueryGraph(graphWithTurnCosts); FastestWeighting weighting = new FastestWeighting(encoder); TurnWeighting turnWeighting = new TurnWeighting(weighting, (TurnCostExtension) qGraph.getExtension()); assertEquals(0, turnWeighting.calcTurnWeight(edge0.getEdge(), 1, edge1.getEdge()), .1); // now use turn costs and QueryGraph turnExt.addTurnInfo(edge0.getEdge(), 1, edge1.getEdge(), encoder.getTurnFlags(false, 10)); assertEquals(10, turnWeighting.calcTurnWeight(edge0.getEdge(), 1, edge1.getEdge()), .1); QueryResult res1 = createLocationResult(0.000, 0.005, edge0, 0, QueryResult.Position.EDGE); QueryResult res2 = createLocationResult(0.005, 0.010, edge1, 0, QueryResult.Position.EDGE); qGraph.lookup(Arrays.asList(res1, res2)); int fromQueryEdge = GHUtility.getEdge(qGraph, res1.getClosestNode(), 1).getEdge(); int toQueryEdge = GHUtility.getEdge(qGraph, res2.getClosestNode(), 1).getEdge(); assertEquals(10, turnWeighting.calcTurnWeight(fromQueryEdge, 1, toQueryEdge), .1); graphWithTurnCosts.close(); }
/** * Default graph is a {@link GraphHopperStorage} with an in memory directory and disabled storing on flush. * Afterwards you'll need to call {@link GraphHopperStorage#create} to have a usable object. Better use * {@link GraphHopperStorage#create} directly. */ public GraphHopperStorage build() { Directory dir = mmap ? new MMapDirectory(location) : new RAMDirectory(location, store); GraphHopperStorage graph; if (encodingManager.needsTurnCostsSupport() || singleCHWeighting == null) graph = new GraphHopperStorage(dir, encodingManager, elevation, new TurnCostExtension()); else graph = new GraphHopperStorage(Arrays.asList(singleCHWeighting), dir, encodingManager, elevation, new TurnCostExtension.NoOpExtension()); return graph; }
/** * Default graph is a GraphStorage with an in memory directory and disabled storing on flush. * Afterwards you'll need to call GraphStorage. Create to have a usable object. Better use * create. */ public GraphHopperStorage build() { Directory dir; if (mmap) dir = new MMapDirectory(location); else dir = new RAMDirectory(location, store); GraphHopperStorage graph; if (encodingManager.needsTurnCostsSupport() || singleCHWeighting == null) graph = new GraphHopperStorage(dir, encodingManager, elevation, new TurnCostExtension()); else graph = new GraphHopperStorage(Arrays.asList(singleCHWeighting), dir, encodingManager, elevation, new TurnCostExtension.NoOpExtension()); return graph; }
/** * Default graph is a GraphStorage with an in memory directory and disabled storing on flush. * Afterwards you'll need to call GraphStorage. Create to have a usable object. Better use * create. */ public GraphHopperStorage build() { Directory dir; if (mmap) dir = new MMapDirectory(location); else dir = new RAMDirectory(location, store); GraphHopperStorage graph; if (encodingManager.needsTurnCostsSupport() || singleCHWeighting == null) graph = new GraphHopperStorage(dir, encodingManager, elevation, new TurnCostExtension()); else graph = new GraphHopperStorage(Arrays.asList(singleCHWeighting), dir, encodingManager, elevation, new TurnCostExtension.NoOpExtension()); return graph; }
? new TurnCostExtension() : new GraphExtension.NoOpExtension();
? new TurnCostExtension() : new GraphExtension.NoOpExtension();
? new TurnCostExtension() : new GraphExtension.NoOpExtension();