/** * Create edge between nodes a and b * <p> * * @return EdgeIteratorState of newly created edge */ @Override public EdgeIteratorState edge(int nodeA, int nodeB) { if (isFrozen()) throw new IllegalStateException("Cannot create edge if graph is already frozen"); ensureNodeIndex(Math.max(nodeA, nodeB)); int edgeId = edgeAccess.internalEdgeAdd(nextEdgeId(), nodeA, nodeB); EdgeIterable iter = new EdgeIterable(this, edgeAccess, EdgeFilter.ALL_EDGES); boolean ret = iter.init(edgeId, nodeB); assert ret; if (extStorage.isRequireEdgeField()) iter.setAdditionalField(extStorage.getDefaultEdgeFieldValue()); return iter; }
void close() { wayGeometry.close(); nameIndex.close(); edges.close(); nodes.close(); extStorage.close(); }
extStorage.copyTo(clonedG.extStorage);
/** * Initializes the node area with the empty edge value and default additional value. */ void initNodeRefs(long oldCapacity, long newCapacity) { for (long pointer = oldCapacity + N_EDGE_REF; pointer < newCapacity; pointer += nodeEntryBytes) { nodes.setInt(pointer, EdgeIterator.NO_EDGE); } if (extStorage.isRequireNodeField()) { for (long pointer = oldCapacity + N_ADDITIONAL; pointer < newCapacity; pointer += nodeEntryBytes) { nodes.setInt(pointer, extStorage.getDefaultNodeFieldValue()); } } }
if (extStorage.isRequireEdgeField()) E_ADDITIONAL = nextEdgeEntryIndex(4); else N_ELE = -1; if (extStorage.isRequireNodeField()) N_ADDITIONAL = nextNodeEntryIndex(4); else
@Override public final int getAdditionalNodeField(int index) { if (that.extStorage.isRequireNodeField() && that.N_ADDITIONAL >= 0) return that.nodes.getInt((long) index * that.nodeEntryBytes + that.N_ADDITIONAL); else throw new AssertionError("This graph does not provide an additional node field"); }
void create(long initSize) { nodes.create(initSize); edges.create(initSize); initSize = Math.min(initSize, 2000); wayGeometry.create(initSize); nameIndex.create(initSize); extStorage.create(initSize); initStorage(); // 0 stands for no separate geoRef maxGeoRef = 4; initNodeRefs(0, nodes.getCapacity()); }
void flush() { setNodesHeader(); setEdgesHeader(); setWayGeometryHeader(); wayGeometry.flush(); nameIndex.flush(); edges.flush(); nodes.flush(); extStorage.flush(); }
public void setAdditionalEdgeField(long edgePointer, int value) { if (extStorage.isRequireEdgeField() && E_ADDITIONAL >= 0) edges.setInt(edgePointer + E_ADDITIONAL, value); else throw new AssertionError("This graph does not support an additional edge field."); }
long getCapacity() { return edges.getCapacity() + nodes.getCapacity() + nameIndex.getCapacity() + wayGeometry.getCapacity() + extStorage.getCapacity(); }
this.nodeAccess = new GHNodeAccess(this, withElevation); this.extStorage = extendedStorage; this.extStorage.init(this, dir);
EdgeIteratorState iter = storage.edge(0, 1, 10, true); assertEquals(extStorage.getDefaultEdgeFieldValue(), iter.getAdditionalField());
@Override public final void setNode(int nodeId, double lat, double lon, double ele) { that.ensureNodeIndex(nodeId); long tmp = (long) nodeId * that.nodeEntryBytes; that.nodes.setInt(tmp + that.N_LAT, Helper.degreeToInt(lat)); that.nodes.setInt(tmp + that.N_LON, Helper.degreeToInt(lon)); if (is3D()) { // meter precision is sufficient for now that.nodes.setInt(tmp + that.N_ELE, Helper.eleToInt(ele)); that.bounds.update(lat, lon, ele); } else { that.bounds.update(lat, lon); } // set the default value for the additional field of this node if (that.extStorage.isRequireNodeField()) that.nodes.setInt(tmp + that.N_ADDITIONAL, that.extStorage.getDefaultNodeFieldValue()); }
if (extStorage.isRequireEdgeField()) E_ADDITIONAL = nextEdgeEntryIndex(4); else N_ELE = -1; if (extStorage.isRequireNodeField()) N_ADDITIONAL = nextNodeEntryIndex(4); else
@Override public final void setAdditionalNodeField(int index, int additionalValue) { if (that.extStorage.isRequireNodeField() && that.N_ADDITIONAL >= 0) { that.ensureNodeIndex(index); long tmp = (long) index * that.nodeEntryBytes; that.nodes.setInt(tmp + that.N_ADDITIONAL, additionalValue); } else { throw new AssertionError("This graph does not provide an additional node field"); } }
void create(long initSize) { nodes.create(initSize); edges.create(initSize); initSize = Math.min(initSize, 2000); wayGeometry.create(initSize); nameIndex.create(initSize); extStorage.create(initSize); initStorage(); // 0 stands for no separate geoRef maxGeoRef = 4; initNodeRefs(0, nodes.getCapacity()); }
void flush() { setNodesHeader(); setEdgesHeader(); setWayGeometryHeader(); wayGeometry.flush(); nameIndex.flush(); edges.flush(); nodes.flush(); extStorage.flush(); }
public void setAdditionalEdgeField( long edgePointer, int value ) { if (extStorage.isRequireEdgeField() && E_ADDITIONAL >= 0) edges.setInt(edgePointer + E_ADDITIONAL, value); else throw new AssertionError("This graph does not support an additional edge field."); }
long getCapacity() { return edges.getCapacity() + nodes.getCapacity() + nameIndex.getCapacity() + wayGeometry.getCapacity() + extStorage.getCapacity(); }
this.nodeAccess = new GHNodeAccess(this, withElevation); this.extStorage = extendedStorage; this.extStorage.init(this, dir);