boolean check(String key, int vers, boolean silent) { String str = get(key + ".version"); if (!str.equals(vers + "")) { if (silent) return false; throw new IllegalStateException("Version of " + key + " unsupported: " + str + ", expected:" + vers + ". " + "Make sure you are using the same GraphHopper version for reading the files that was used for creating them. " + "See https://discuss.graphhopper.com/t/722"); } return true; }
private boolean isLMPrepared() { return "true".equals(ghStorage.getProperties().get(Landmark.PREPARE + "done")); }
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 the EncodingManager from the provided GraphHopper location. Throws an * IllegalStateException if it fails. Used if no EncodingManager specified on load. */ public static EncodingManager create(FlagEncoderFactory factory, String ghLoc) { Directory dir = new RAMDirectory(ghLoc, true); StorableProperties properties = new StorableProperties(dir); if (!properties.loadExisting()) throw new IllegalStateException("Cannot load properties to fetch EncodingManager configuration at: " + dir.getLocation()); // check encoding for compatibility properties.checkVersions(false); String acceptStr = properties.get("graph.flag_encoders"); if (acceptStr.isEmpty()) throw new IllegalStateException("EncodingManager was not configured. And no one was found in the graph: " + dir.getLocation()); int bytesForFlags = 4; if ("8".equals(properties.get("graph.bytes_for_flags"))) bytesForFlags = 8; return new EncodingManager(factory, acceptStr, bytesForFlags); }
@GET public Info getInfo() { final Info info = new Info(); // use bbox always without elevation (for backward compatibility) info.bbox = new BBox(storage.getBounds().minLon, storage.getBounds().maxLon, storage.getBounds().minLat, storage.getBounds().maxLat); info.supported_vehicles = storage.getEncodingManager().toString().split(","); for (String v : info.supported_vehicles) { Info.PerVehicle perVehicleJson = new Info.PerVehicle(); perVehicleJson.elevation = hasElevation; info.features.put(v, perVehicleJson); } info.import_date = storage.getProperties().get("datareader.import.date"); info.data_date = storage.getProperties().get("datareader.data.date"); info.prepare_ch_date = storage.getProperties().get("prepare.ch.date"); info.prepare_date = storage.getProperties().get("prepare.ch.date"); return info; } }
@Override public boolean loadExisting() { baseGraph.checkInit(); if (properties.loadExisting()) { properties.checkVersions(false); // check encoding for compatibility String flagEncodersStr = properties.get("graph.flag_encoders"); if (!flagEncodersStr.isEmpty() && !encodingManager.toDetailsString().equalsIgnoreCase(flagEncodersStr)) { throw new IllegalStateException("Encoding does not match:" + "\nGraphhopper config: " + encodingManager.toDetailsString() + "\nGraph: " + flagEncodersStr + "\nChange configuration to match the graph or delete " + dir.getLocation()); } String byteOrder = properties.get("graph.byte_order"); if (!byteOrder.equalsIgnoreCase("" + dir.getByteOrder())) throw new IllegalStateException("Configured graph.byte_order (" + dir.getByteOrder() + ") is not equal to loaded " + byteOrder + ""); String bytesForFlags = properties.get("graph.bytes_for_flags"); if (!bytesForFlags.equalsIgnoreCase("" + encodingManager.getBytesForFlags())) throw new IllegalStateException("Configured graph.bytes_for_flags (" + encodingManager.getBytesForFlags() + ") is not equal to loaded " + bytesForFlags); String dim = properties.get("graph.dimension"); baseGraph.loadExisting(dim); checkIfConfiguredAndLoadedWeightingsCompatible(); for (CHGraphImpl cg : chGraphs) { if (!cg.loadExisting()) throw new IllegalStateException("Cannot load " + cg); } return true; } return false; }
@Test public void testStore() { String dir = "./target/test"; Helper.removeDir(new File(dir)); StorableProperties instance = new StorableProperties(createDir(dir, true)); instance.create(1000); instance.put("test.min", 123); instance.put("test.max", 321); instance.flush(); instance.close(); instance = new StorableProperties(createDir(dir, true)); assertTrue(instance.loadExisting()); assertEquals("123", instance.get("test.min")); assertEquals("321", instance.get("test.max")); instance.close(); Helper.removeDir(new File(dir)); }
boolean check(String key, int vers, boolean silent) { String str = get(key + ".version"); if (!str.equals(vers + "")) { if (silent) return false; throw new IllegalStateException("Version of " + key + " unsupported: " + str + ", expected:" + vers + ". " + "Make sure you are using the same GraphHopper version for reading the files that was used for creating them. " + "See https://discuss.graphhopper.com/t/722"); } return true; }
boolean check(String key, int vers, boolean silent) { String str = get(key + ".version"); if (!str.equals(vers + "")) { if (silent) return false; throw new IllegalStateException("Version of " + key + " unsupported: " + str + ", expected:" + vers + ". " + "Make sure you are using the same GraphHopper version for reading the files that was used for creating them. " + "See https://discuss.graphhopper.com/t/722"); } return true; }
boolean check( String key, int vers, boolean silent ) { String str = get(key + ".version"); if (!str.equals(vers + "")) { if (silent) return false; throw new IllegalStateException("Version of " + key + " unsupported: " + str + ", expected:" + vers + ". " + "Make sure you are using the same GraphHopper version for reading the files that was used for creating them. " + "See https://discuss.graphhopper.com/t/722"); } return true; }
private boolean isPrepared() { return "true".equals(ghStorage.getProperties().get("prepare.done")); }
private boolean isLMPrepared() { return "true".equals(ghStorage.getProperties().get(Landmark.PREPARE + "done")); }
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); } } }