public NameIndex(Directory dir) { names = dir.find("names"); }
@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; }
@Override public void release() { cacheData.clear(); // for memory mapped type we create temporary unpacked files which should be removed if (autoRemoveTemporary && dir != null) dir.clear(); }
/** * @param g the graph for which this index should do the lookup based on latitude,longitude. */ public LocationIndexTree(Graph g, Directory dir) { if (g instanceof CHGraph) throw new IllegalArgumentException("Use base graph for LocationIndexTree instead of CHGraph"); MAGIC_INT = Integer.MAX_VALUE / 22316; this.graph = g; this.nodeAccess = g.getNodeAccess(); dataAccess = dir.find("location_index", DAType.getPreferredInt(dir.getDefaultType())); }
this.dir = dir; this.encodingManager = encodingManager; this.bitUtil = BitUtil.get(dir.getByteOrder()); this.wayGeometry = dir.find("geometry"); this.nameIndex = new NameIndex(dir); this.nodes = dir.find("nodes", DAType.getPreferredInt(dir.getDefaultType())); this.edges = dir.find("edges", DAType.getPreferredInt(dir.getDefaultType())); this.listener = listener; this.edgeAccess = new EdgeAccess(edges, bitUtil) {
void loadGtfsFromFile(String id, ZipFile zip) { File file = new File(dir.getLocation() + "/" + id); try { Files.deleteIfExists(file.toPath()); GTFSFeed feed = new GTFSFeed(file); feed.loadFromFileAndLogErrors(zip); fixFares(feed, zip); this.gtfsFeeds.put(id, feed); } catch (IOException e) { throw new RuntimeException(e); } this.gtfsFeedIds.add(id); }
this.dir = dir; this.encodingManager = encodingManager; this.bitUtil = BitUtil.get(dir.getByteOrder()); this.wayGeometry = dir.find("geometry"); this.nameIndex = new NameIndex(dir); this.nodes = dir.find("nodes"); this.edges = dir.find("edges"); this.listener = listener; this.edgeAccess = new EdgeAccess(edges, bitUtil) {
/** * 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; }
@Override public String toString() { return (isCHPossible() ? "CH|" : "") + encodingManager + "|" + getDirectory().getDefaultType() + "|" + baseGraph.nodeAccess.getDimension() + "D" + "|" + baseGraph.extStorage + "|" + getProperties().versionsToString(); }
public void clear() { dir.remove(da); } }
public SubnetworkStorage(Directory dir, String postfix) { DAType type = dir.getDefaultType(); da = dir.find("subnetwork_" + postfix, type.isMMap() ? DAType.MMAP : (type.isStoring() ? DAType.RAM_STORE : DAType.RAM)); }
@Override public boolean loadExisting() { this.data = DBMaker.newFileDB(new File(dir.getLocation() + "/transit_schedule")).transactionDisable().mmapFileEnable().readOnly().make(); init(); for (String gtfsFeedId : this.gtfsFeedIds) { GTFSFeed feed = new GTFSFeed(new File(dir.getLocation() + "/" + gtfsFeedId)); this.gtfsFeeds.put(gtfsFeedId, feed); this.transfers.put(gtfsFeedId, new Transfers(feed)); } return true; }
this.dir = dir; this.encodingManager = encodingManager; this.bitUtil = BitUtil.get(dir.getByteOrder()); this.wayGeometry = dir.find("geometry"); this.nameIndex = new NameIndex(dir); this.nodes = dir.find("nodes"); this.edges = dir.find("edges"); this.listener = listener; this.edgeAccess = new EdgeAccess(edges, bitUtil) {
/** * 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; }
if (ghStorage.getDirectory().getDefaultType().isStoring() && isAllowWrites()) { lockFactory.setLockDir(new File(ghLocation)); lock = lockFactory.create(fileLockName, false);
public void remove() { dir.remove(keys); }
public StorableProperties(Directory dir) { this.da = dir.find("properties"); // reduce size da.setSegmentSize(1 << 15); }
this.baseGraph = baseGraph; final String name = AbstractWeighting.weightingToFileName(w); this.nodesCH = dir.find("nodes_ch_" + name, DAType.getPreferredInt(dir.getDefaultType())); this.shortcuts = dir.find("shortcuts_" + name, DAType.getPreferredInt(dir.getDefaultType())); this.chEdgeAccess = new EdgeAccess(shortcuts, baseGraph.bitUtil) { @Override
+ "\nGraph: " + flagEncodersStr + ", dir:" + dir.getLocation()); if (!byteOrder.equalsIgnoreCase("" + dir.getByteOrder())) throw new IllegalStateException("Configured graph.byte_order (" + dir.getByteOrder() + ") is not equal to loaded " + byteOrder + "");
@Override public GraphExtension create(long byteCount) { final File file = new File(dir.getLocation() + "/transit_schedule"); try { Files.deleteIfExists(file.toPath()); } catch (IOException e) { throw new RuntimeException(e); } this.data = DBMaker.newFileDB(file).transactionDisable().mmapFileEnable().asyncWriteEnable().make(); init(); return this; }