? new TurnCostExtension() : new GraphExtension.NoOpExtension();
? new TurnCostExtension() : new GraphExtension.NoOpExtension();
? new TurnCostExtension() : new GraphExtension.NoOpExtension();
? new TurnCostExtension() : new GraphExtension.NoOpExtension();
/** * 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; }
/** * 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; }
list.add(new TmpCarFlagEncoder(29, 0.001, 0)); EncodingManager manager = new EncodingManager(list, 8); graph = new GraphHopperStorage(dir, manager, false, new GraphExtension.NoOpExtension()).create(defaultSize); graph.close(); graph = new GraphHopperStorage(dir, manager, false, new GraphExtension.NoOpExtension()).create(defaultSize);
public GraphHopperStorage createTestGraph(boolean fullGraph, EncodingManager tmpEM) { GraphHopperStorage graph = new GraphHopperStorage(new RAMDirectory(), tmpEM, false, new GraphExtension.NoOpExtension()); graph.create(1000);
chWeightings.add(new FastestWeighting(tmpBike)); graph = new GraphHopperStorage(chWeightings, new RAMDirectory(), em, false, new GraphExtension.NoOpExtension()).create(1000); graph.edge(0, 1).setDistance(10).setFlags(tmpCar.setProperties(100, true, true) | tmpBike.setProperties(10, true, true)); graph.edge(1, 2).setDistance(10).setFlags(tmpCar.setProperties(100, true, true) | tmpBike.setProperties(10, true, true));
private Graph createSquareGraph() { // simple square // 1 | 0 1 2 // 0 | 7 3 // -1 | 6 5 4 // ---|------ // |-1 0 1 GraphHopperStorage graph = new GraphHopperStorage(new RAMDirectory(), em, false, new GraphExtension.NoOpExtension()); graph.create(1000); for (int i = 0; i < 8; ++i) { graph.edge(i, (i + 1) % 8, 1, true); } updateDistancesFor(graph, 0, 1, -1); updateDistancesFor(graph, 1, 1, 0); updateDistancesFor(graph, 2, 1, 1); updateDistancesFor(graph, 3, 0, 1); updateDistancesFor(graph, 4, -1, 1); updateDistancesFor(graph, 5, -1, 0); updateDistancesFor(graph, 6, -1, -1); updateDistancesFor(graph, 7, 0, -1); return graph; } }
@Test public void testUseMeanElevation() { g.close(); g = new GraphHopperStorage(new RAMDirectory(), encodingManager, true, new GraphExtension.NoOpExtension()).create(100); NodeAccess na = g.getNodeAccess(); na.setNode(0, 0, 0, 0); na.setNode(1, 0, 0.0001, 20); EdgeIteratorState edge = g.edge(0, 1); EdgeIteratorState edgeReverse = edge.detach(true); DistanceCalc2D distCalc = new DistanceCalc2D(); QueryResult qr = new QueryResult(0, 0.00005); qr.setClosestEdge(edge); qr.setWayIndex(0); qr.setSnappedPosition(EDGE); qr.calcSnappedPoint(distCalc); assertEquals(10, qr.getSnappedPoint().getEle(), 1e-1); qr = new QueryResult(0, 0.00005); qr.setClosestEdge(edgeReverse); qr.setWayIndex(0); qr.setSnappedPosition(EDGE); qr.calcSnappedPoint(distCalc); assertEquals(10, qr.getSnappedPoint().getEle(), 1e-1); }
@Test public void addWeighting() { LMAlgoFactoryDecorator dec = new LMAlgoFactoryDecorator().setEnabled(true); dec.addWeighting("fastest"); assertEquals(Arrays.asList("fastest"), dec.getWeightingsAsStrings()); // special parameters like the maximum weight dec = new LMAlgoFactoryDecorator().setEnabled(true); dec.addWeighting("fastest|maximum=65000"); dec.addWeighting("shortest|maximum=20000"); assertEquals(Arrays.asList("fastest", "shortest"), dec.getWeightingsAsStrings()); FlagEncoder car = new CarFlagEncoder(); EncodingManager em = new EncodingManager(car); dec.addWeighting(new FastestWeighting(car)).addWeighting(new ShortestWeighting(car)); dec.createPreparations(new GraphHopperStorage(new RAMDirectory(), em, false, new GraphExtension.NoOpExtension()), null); assertEquals(1, dec.getPreparations().get(0).getLandmarkStorage().getFactor(), .1); assertEquals(0.3, dec.getPreparations().get(1).getLandmarkStorage().getFactor(), .1); }
@Test public void testMultiplePreparationsIdenticalView() { CarFlagEncoder tmpCarEncoder = new CarFlagEncoder(); BikeFlagEncoder tmpBikeEncoder = new BikeFlagEncoder(); EncodingManager tmpEncodingManager = new EncodingManager(tmpCarEncoder, tmpBikeEncoder); // FastestWeighting would lead to different shortcuts due to different default speeds for bike and car Weighting carWeighting = new ShortestWeighting(tmpCarEncoder); Weighting bikeWeighting = new ShortestWeighting(tmpBikeEncoder); List<Weighting> chWeightings = Arrays.asList(carWeighting, bikeWeighting); GraphHopperStorage ghStorage = new GraphHopperStorage(chWeightings, dir, tmpEncodingManager, false, new GraphExtension.NoOpExtension()).create(1000); initShortcutsGraph(ghStorage); ghStorage.freeze(); for (Weighting w : chWeightings) { checkPath(ghStorage, w, 7, 5, IntArrayList.from(3, 9, 14, 16, 13, 12)); } }
@Test public void testMultiplePreparationsDifferentView() { CarFlagEncoder tmpCarEncoder = new CarFlagEncoder(); BikeFlagEncoder tmpBikeEncoder = new BikeFlagEncoder(); EncodingManager tmpEncodingManager = new EncodingManager(tmpCarEncoder, tmpBikeEncoder); Weighting carWeighting = new FastestWeighting(tmpCarEncoder); Weighting bikeWeighting = new FastestWeighting(tmpBikeEncoder); List<Weighting> chWeightings = Arrays.asList(carWeighting, bikeWeighting); GraphHopperStorage ghStorage = new GraphHopperStorage(chWeightings, dir, tmpEncodingManager, false, new GraphExtension.NoOpExtension()).create(1000); initShortcutsGraph(ghStorage); EdgeIteratorState edge = GHUtility.getEdge(ghStorage, 9, 14); edge.setFlags(tmpBikeEncoder.setAccess(edge.getFlags(), false, false)); ghStorage.freeze(); checkPath(ghStorage, carWeighting, 7, 5, IntArrayList.from(3, 9, 14, 16, 13, 12)); // detour around blocked 9,14 checkPath(ghStorage, bikeWeighting, 9, 5, IntArrayList.from(3, 10, 14, 16, 13, 12)); }
/** * 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; }
protected GraphHopperStorage newGHStorage(Directory dir, boolean enabled3D) { return new GraphHopperStorage(dir, encodingManager, enabled3D, new GraphExtension.NoOpExtension()); }
GraphHopperStorage createGHStorage(Directory dir, EncodingManager encodingManager, boolean is3D) { return new GraphHopperStorage(dir, encodingManager, is3D, new GraphExtension.NoOpExtension()).create(100); }
protected final GraphHopperStorage newRAMGHStorage() { return new GraphHopperStorage(new RAMDirectory(), encodingManager, false, new GraphExtension.NoOpExtension()); }
@SuppressWarnings("resource") @Before public void setUp() { dataFlagEncoder = new DataFlagEncoder(); graph = new GraphHopperStorage(new RAMDirectory(), new EncodingManager(Arrays.asList(dataFlagEncoder, new FootFlagEncoder()), 8), true, new GraphExtension.NoOpExtension()).create(100); edgeElevationInterpolator = createEdgeElevationInterpolator(); interpolatableWay = createInterpolatableWay(); normalWay = new ReaderWay(0); normalWay.setTag("highway", "primary"); }