/** {@inheritDoc} */ @Override public void close() { if (fileOutStream != null) { try { fileOutStream.close(); } catch (Exception e) { // We cannot throw an exception within a release method. LOG.log(Level.WARNING, "Unable to close file output stream.", e); } fileOutStream = null; } if (fileInStream != null) { try { fileInStream.close(); } catch (Exception e) { // We cannot throw an exception within a release method. LOG.log(Level.WARNING, "Unable to close file input stream.", e); } fileInStream = null; } if (nodeStorageFile != null) { if (!nodeStorageFile.delete()) { // We cannot throw an exception within a release method. LOG.warning("Unable to delete file " + nodeStorageFile); } nodeStorageFile = null; } }
/** {@inheritDoc} */ @Override public NodeLocation getNodeLocation(long nodeId) { NodeLocation nodeLocation; long offset; initializeReadingStage(); offset = nodeId * NODE_DATA_SIZE; nodeLocation = invalidNodeLocation; if (offset < currentFileOffset) { try { byte validFlag; fileInStream.seek(offset); validFlag = dataInStream.readByte(); if (validFlag != 0) { nodeLocation = new NodeLocation( FixedPrecisionCoordinateConvertor.convertToDouble(dataInStream.readInt()), FixedPrecisionCoordinateConvertor.convertToDouble(dataInStream.readInt())); } } catch (IOException e) { throw new OsmosisRuntimeException( "Unable to read node information from the node storage file.", e); } } return nodeLocation; }