private void checkIfConfiguredAndLoadedWeightingsCompatible() { String loadedStr = properties.get("graph.ch.weightings"); List<String> loaded = parseList(loadedStr); List<Weighting> configured = getCHWeightings(); if (configured.isEmpty() && !loaded.isEmpty()) { throw new IllegalStateException("You loaded a CH graph, but you did not specify graph.ch.weightings"); } for (Weighting w : configured) { if (!loaded.contains(w.toString())) { throw new IllegalStateException("Configured weighting: " + w.toString() + " is not contained in loaded weightings " + loadedStr + ".\n" + "You configured graph.ch.weightings: " + configured); } } }
/** * Create a new storage from the specified one without copying the data. */ public static GraphHopperStorage newStorage(GraphHopperStorage store) { Directory outdir = guessDirectory(store); boolean is3D = store.getNodeAccess().is3D(); return new GraphHopperStorage(store.getCHWeightings(), outdir, store.getEncodingManager(), is3D, store.getExtension()). create(store.getNodes()); }
/** * After configuring this storage you need to create it explicitly. */ @Override public GraphHopperStorage create(long byteCount) { baseGraph.checkInit(); if (encodingManager == null) throw new IllegalStateException("EncodingManager can only be null if you call loadExisting"); dir.create(); long initSize = Math.max(byteCount, 100); properties.create(100); properties.put("graph.bytes_for_flags", encodingManager.getBytesForFlags()); properties.put("graph.flag_encoders", encodingManager.toDetailsString()); properties.put("graph.byte_order", dir.getByteOrder()); properties.put("graph.dimension", baseGraph.nodeAccess.getDimension()); properties.putCurrentVersions(); baseGraph.create(initSize); for (CHGraphImpl cg : chGraphs) { cg.create(byteCount); } properties.put("graph.ch.weightings", getCHWeightings().toString()); return this; }
@Test public void testLoadingWithLessWeightings_works() { // we start with a gh storage with two ch weightings and flush it to disk FastestWeighting weighting1 = new FastestWeighting(carEncoder); ShortestWeighting weighting2 = new ShortestWeighting(carEncoder); GraphHopperStorage originalStorage = createStorageWithWeightings(weighting1, weighting2); originalStorage.create(defaultSize); originalStorage.flush(); // now we create a new storage but only use one of the weightings, which should be ok GraphHopperStorage smallStorage = createStorageWithWeightings(weighting1); smallStorage.loadExisting(); assertEquals(1, smallStorage.getCHWeightings().size()); smallStorage.flush(); // now we create yet another storage that uses both weightings again, which still works GraphHopperStorage fullStorage = createStorageWithWeightings(weighting1, weighting2); fullStorage.loadExisting(); assertEquals(2, fullStorage.getCHWeightings().size()); fullStorage.flush(); }
private void checkIfConfiguredAndLoadedWeightingsCompatible() { String loadedStr = properties.get("graph.ch.weightings"); List<String> loaded = parseList(loadedStr); List<Weighting> configured = getCHWeightings(); if (configured.isEmpty() && !loaded.isEmpty()) { throw new IllegalStateException("You loaded a CH graph, but you did not specify graph.ch.weightings"); } for (Weighting w : configured) { if (!loaded.contains(w.toString())) { throw new IllegalStateException("Configured weighting: " + w.toString() + " is not contained in loaded weightings " + loadedStr + ".\n" + "You configured graph.ch.weightings: " + configured); } } }
String configuredCHWeightings = getCHWeightings().toString(); if (!loadedCHWeightings.equals(configuredCHWeightings)) throw new IllegalStateException("Configured graph.ch.weightings: " + configuredCHWeightings + " is not equal to loaded " + loadedCHWeightings);
String configuredCHWeightings = getCHWeightings().toString(); if (!loadedCHWeightings.equals(configuredCHWeightings)) throw new IllegalStateException("Configured graph.ch.weightings: " + configuredCHWeightings + " is not equal to loaded " + loadedCHWeightings);
/** * Create a new storage from the specified one without copying the data. */ public static GraphHopperStorage newStorage(GraphHopperStorage store) { Directory outdir = guessDirectory(store); boolean is3D = store.getNodeAccess().is3D(); return new GraphHopperStorage(store.getCHWeightings(), outdir, store.getEncodingManager(), is3D, store.getExtension()). create(store.getNodes()); }
/** * Create a new storage from the specified one without copying the data. */ public static GraphHopperStorage newStorage( GraphHopperStorage store ) { Directory outdir = guessDirectory(store); boolean is3D = store.getNodeAccess().is3D(); return new GraphHopperStorage(store.getCHWeightings(), outdir, store.getEncodingManager(), is3D, store.getExtension()). create(store.getNodes()); }
/** * Create a new storage from the specified one without copying the data. */ public static GraphHopperStorage newStorage(GraphHopperStorage store) { Directory outdir = guessDirectory(store); boolean is3D = store.getNodeAccess().is3D(); return new GraphHopperStorage(store.getCHWeightings(), outdir, store.getEncodingManager(), is3D, store.getExtension()). create(store.getNodes()); }
/** * After configuring this storage you need to create it explicitly. */ @Override public GraphHopperStorage create(long byteCount) { baseGraph.checkInit(); if (encodingManager == null) throw new IllegalStateException("EncodingManager can only be null if you call loadExisting"); dir.create(); long initSize = Math.max(byteCount, 100); properties.create(100); properties.put("graph.bytes_for_flags", encodingManager.getBytesForFlags()); properties.put("graph.flag_encoders", encodingManager.toDetailsString()); properties.put("graph.byte_order", dir.getByteOrder()); properties.put("graph.dimension", baseGraph.nodeAccess.getDimension()); properties.putCurrentVersions(); baseGraph.create(initSize); for (CHGraphImpl cg : chGraphs) { cg.create(byteCount); } properties.put("graph.ch.weightings", getCHWeightings().toString()); return this; }
/** * After configuring this storage you need to create it explicitly. */ @Override public GraphHopperStorage create(long byteCount) { baseGraph.checkInit(); if (encodingManager == null) throw new IllegalStateException("EncodingManager can only be null if you call loadExisting"); dir.create(); long initSize = Math.max(byteCount, 100); properties.create(100); properties.put("graph.bytes_for_flags", encodingManager.getBytesForFlags()); properties.put("graph.flag_encoders", encodingManager.toDetailsString()); properties.put("graph.byte_order", dir.getByteOrder()); properties.put("graph.dimension", baseGraph.nodeAccess.getDimension()); properties.putCurrentVersions(); baseGraph.create(initSize); for (CHGraphImpl cg : chGraphs) { cg.create(byteCount); } properties.put("graph.ch.weightings", getCHWeightings().toString()); return this; }
/** * After configuring this storage you need to create it explicitly. */ @Override public GraphHopperStorage create( long byteCount ) { baseGraph.checkInit(); if (encodingManager == null) throw new IllegalStateException("EncodingManager can only be null if you call loadExisting"); dir.create(); long initSize = Math.max(byteCount, 100); properties.create(100); properties.put("graph.bytes_for_flags", encodingManager.getBytesForFlags()); properties.put("graph.flag_encoders", encodingManager.toDetailsString()); properties.put("graph.byte_order", dir.getByteOrder()); properties.put("graph.dimension", baseGraph.nodeAccess.getDimension()); properties.putCurrentVersions(); baseGraph.create(initSize); for (CHGraphImpl cg : chGraphs) { cg.create(byteCount); } properties.put("graph.ch.weightings", getCHWeightings().toString()); return this; }