@Override public boolean accept( File pathname ) { if ( !pathname.isDirectory() ) { String ext = FileUtils.getFileExtension( pathname ); String file = FileUtils.getFilename( pathname ); return ( file.startsWith( BLOB_FILE_NAME ) && BLOB_FILE_EXT.equalsIgnoreCase( "." + ext ) ); } return false; } } );
private void setID( RasterIOOptions options ) { this.dataLocationId = options != null ? options.get( RasterIOOptions.ORIGIN_OF_RASTER ) : null; if ( dataLocationId == null ) { if ( this.file != null ) { this.dataLocationId = FileUtils.getFilename( this.file ); } } }
private void setID( RasterIOOptions options ) { this.dataLocationId = options != null ? options.get( RasterIOOptions.ORIGIN_OF_RASTER ) : null; if ( dataLocationId == null ) { if ( this.file != null ) { this.dataLocationId = FileUtils.getFilename( this.file ); } } }
private void setID( RasterIOOptions options ) { this.dataLocationId = options != null ? options.get( RasterIOOptions.ORIGIN_OF_RASTER ) : null; if ( dataLocationId == null ) { if ( this.file != null ) { this.dataLocationId = FileUtils.getFilename( this.file ); } } }
/** * Get the resolution from the resolution or if no value was configured try to get it from the name of the * directory. * * @param resolution * @param resolutionDir * * @return the resolution from the configuration if missing from the directory name, if not parse-able return NaN */ private static double getPixelResolution( Double resolution, File resolutionDir ) { Double result = resolution; if ( result == null || result.isNaN() ) { File rasterDirectory = resolutionDir; String dirRes = FileUtils.getFilename( rasterDirectory ); try { result = Double.parseDouble( dirRes ); } catch ( NumberFormatException e ) { LOG.debug( "No resolution found in raster datasource defintion, nor in the directory name: " + dirRes + " returning 0" ); result = Double.NaN; } } return result; }
/** * Get the resolution from the resolution or if no value was configured try to get it from the name of the * directory. * * @param resolution * @param resolutionDir * * @return the resolution from the configuration if missing from the directory name, if not parse-able return NaN */ private static double getPixelResolution( Double resolution, File resolutionDir ) { Double result = resolution; if ( result == null || result.isNaN() ) { File rasterDirectory = resolutionDir; String dirRes = FileUtils.getFilename( rasterDirectory ); try { result = Double.parseDouble( dirRes ); } catch ( NumberFormatException e ) { LOG.debug( "No resolution found in raster datasource defintion, nor in the directory name: " + dirRes + " returning 0" ); result = Double.NaN; } } return result; }
/** * @param options * @throws IOException * @throws NumberFormatException */ private synchronized void instantiate( File gridFile, RasterIOOptions options ) throws NumberFormatException, IOException { if ( infoFile == null && gridFile != null ) { this.dataLocationId = options == null ? FileUtils.getFilename( gridFile ) : options.get( RasterIOOptions.ORIGIN_OF_RASTER ); File metaInfo = GridMetaInfoFile.fileNameFromOptions( gridFile.getParent(), FileUtils.getFilename( gridFile ), options ); this.instantiate( GridMetaInfoFile.readFromFile( metaInfo, options ), gridFile ); } }
/** * Instantiates this grid reader with the given information. * * @param infoFile * @param gridFile */ protected synchronized void instantiate( GridMetaInfoFile infoFile, File gridFile ) { super.instantiate( infoFile ); this.gridFile = gridFile; // set the location id to the grid files file name. if ( this.dataLocationId == null && gridFile != null ) { this.dataLocationId = FileUtils.getFilename( this.gridFile ); } // if ( gridFile != null ) { // // set the tiles per blob depend on the gridFile size (if not full etc.) // setTilesPerBlob( (int) ( gridFile.length() / getBytesPerTile() ) ); // } LOG.debug( "Tiles in grid blob (" + gridFile + "): " + getTilesPerBlob() ); }
String id = buildingID; if ( buildingID == null ) { id = FileUtils.getFilename( new File( fileName ) ); id = id.replaceAll( "\\s", "_" );
/** * Delete the file this cache reader is using. * * @return true if this cached reader no longer references an existing file. */ public boolean deleteCacheFile() { boolean result = true; synchronized ( LOCK ) { super.dispose(); File f = file(); if ( f != null ) { if ( f.exists() && f.isFile() ) { result = f.delete(); File metaInfo = GridMetaInfoFile.fileNameFromOptions( f.getParent(), FileUtils.getFilename( f ), null ); if ( metaInfo.exists() ) { boolean mR = metaInfo.delete(); if ( !mR ) { LOG.warn( "Could not delete meta info file for raster cache file: " + f.getAbsolutePath() ); } } } } } return result; }
ext = outputFormat; String fName = FileUtils.getFilename( testFile ); outputLocation = createNewFile( parent, fName, ext ); } else {
/** * Writes the metadata file for this grid file. * * @param options * @return the file containing the metainfo * @throws IOException */ public File writeMetadataFile( RasterIOOptions options ) throws IOException { File metaInfo = null; if ( gridFile != null ) { metaInfo = GridMetaInfoFile.fileNameFromOptions( gridFile.getParent(), FileUtils.getFilename( gridFile ), options ); } else { throw new IOException( "No gridfile specified, could not write the info file" ); } GridMetaInfoFile.writeToFile( metaInfo, new GridMetaInfoFile( this.geoRef, this.rows, this.columns, this.tileRasterWidth, this.tileRasterHeight, this.dataInfo ), options ); return metaInfo; }
private void setID( RasterIOOptions options ) { this.dataLocationId = options != null ? options.get( RasterIOOptions.ORIGIN_OF_RASTER ) : null; if ( dataLocationId == null ) { if ( reader != null && reader.file() != null ) { this.dataLocationId = FileUtils.getFilename( reader.file() ); } } }
if ( cacheFile != null && cacheFile.exists() ) { String parent = cacheFile.getParent(); File metaInfo = GridMetaInfoFile.fileNameFromOptions( parent, FileUtils.getFilename( cacheFile ), null ); if ( !metaInfo.exists() ) { LOG.warn(
/** * @param reader * @param nOpts * @throws IOException */ private SimpleRaster createSimpleRaster( BufferedReader reader, RasterIOOptions nOpts ) throws IOException { ByteBufferRasterData data = readASCIIGrid( reader, nOpts ); ByteBuffer byteBuffer = data.getByteBuffer(); data = RasterDataFactory.createRasterData( width, height, data.getDataInfo(), geoReference, byteBuffer, true, FileUtils.getFilename( this.file ), nOpts ); SimpleRaster simpleRaster = new SimpleRaster( data, this.envelope, geoReference, null ); return simpleRaster; }
private boolean writeCacheInfo() { boolean result = false; if ( gridWriter != null && file() != null ) { File metaInfo = GridMetaInfoFile.fileNameFromOptions( file().getParent(), FileUtils.getFilename( file() ), null ); boolean[][] tilesOnFiles = new boolean[getTileRows()][getTileColumns()]; for ( int row = 0; row < getTileRows(); ++row ) { for ( int col = 0; col < getTileColumns(); ++col ) { TileEntry entry = getEntry( col, row ); tilesOnFiles[row][col] = ( entry != null && entry.isOnFile() ); } } CacheInfoFile info = new CacheInfoFile( getGeoReference(), getTileRows(), getTileColumns(), getTileRasterWidth(), getTileRasterHeight(), getRasterDataInfo(), getWidth(), getHeight(), tilesOnFiles, file().lastModified() ); try { CacheInfoFile.write( metaInfo, info ); result = true; } catch ( IOException e ) { if ( LOG.isDebugEnabled() ) { LOG.debug( "Writing of info file failed, this will make the cachefile invalid. Reason: {}.", e.getLocalizedMessage(), e ); } else { LOG.debug( "Writing of info file failed, this will make the cachefile invalid. Reason: {}.", e.getLocalizedMessage() ); } } } return result; }
Envelope rasterEnvelope = this.geoReference.getEnvelope( width, height, options.getCRS() ); RasterData data = RasterDataFactory.createRasterData( width, height, rdi, geoReference, buffer, true, FileUtils.getFilename( this.file ), options );