@Override public boolean canLoad( File filename ) { String ext = FileUtils.getFileExtension( filename ); for ( String s : ASCRasterIOProvider.FORMATS ) { if ( s.equalsIgnoreCase( ext ) ) { return true; } } 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 static File[] mapFileType( File entityFile ) { String filepath = FileUtils.getBasename( entityFile ); File data = new File( filepath + ".bin" ); File idx = new File( filepath + ".idx" ); File info = new File( filepath + ".info" ); return new File[] { idx, data, info }; }
@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; } } );
/** * Find the files in the given directory (and sub-directories) which match the given extension pattern(s). * * @param topDirectory * to start the search from. * @param recurse * @param patternList * comma seperated list of extensions to search for. * @return the list of files matching the given extension. */ public static List<File> findFilesForExtensions( File topDirectory, boolean recurse, String patternList ) { List<File> result = new LinkedList<File>(); if ( topDirectory.isDirectory() ) { FilenameFilter f = buildFilenameFilter( patternList ); findFiles( topDirectory, result, recurse, f ); } return result; }
/** * Returns the filename, without any extension. (Eg. /tmp/foo.txt -> /tmp/foo) * * @param file * @return the basename */ public static String getBasename( File file ) { return splitFilename( file ).first; }
if ( !indexFile.exists() || indexFile.lastModified() < directory.lastModified() ) { LOG.info( "Scanning for files in directory: {}", directory.getAbsolutePath() ); List<File> coverageFiles = FileUtils.findFilesForExtensions( directory, recursive, "grid,bin,jpg,jpeg,png,tif,tiff,bmp,gif" ); TiledRaster raster = null;
private static void findFiles( File dir, List<File> result, boolean recurse, FilenameFilter filter ) { File[] fs = dir.listFiles(); if ( fs != null ) { for ( File file : fs ) { if ( file.isFile() ) { if ( filter.accept( dir, file.getName() ) ) { result.add( file ); } } else if ( file.isDirectory() && recurse ) { findFiles( file, result, recurse, filter ); } } } }
String ext = FileUtils.getFileExtension( testFile ); if ( ext == null ) { ext = outputFormat; String fName = FileUtils.getFilename( testFile ); outputLocation = createNewFile( parent, fName, ext ); } else {
/** * Returns the file extension (Eg. /tmp/foo.txt -> txt) * * @param file * @return the file extension */ public static String getFileExtension( File file ) { return splitFilename( file ).second; }
if ( !indexFile.exists() || indexFile.lastModified() < directory.lastModified() ) { LOG.info( "Scanning for files in directory: {}", directory.getAbsolutePath() ); List<File> coverageFiles = FileUtils.findFilesForExtensions( directory, recursive, "grid,bin,jpg,jpeg,png,tif,tiff,bmp,gif" ); TiledRaster raster = null;
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 ); } } }
@Override public boolean canLoad( File filename ) { return "xyz".equalsIgnoreCase( FileUtils.getFileExtension( filename ) ); }
/** * Returns the world file for given file. * * @param rasterFile * the raster file * @return the world file or null if not found. */ private static File getWorldFile( File rasterFile ) { String basename = FileUtils.getBasename( rasterFile ); // Look for corresponding worldfiles. String wldName = ""; for ( String ext : WORLD_FILE_EXT ) { String tmp = basename + "." + ext; if ( new File( tmp ).exists() ) { wldName = tmp; break; } } return new File( wldName ); }
/** * Returns the filename, without any extension and path (Eg. /tmp/foo.txt -> foo) * * @param file * @return the basename or <code>null</code> if the file is null; */ public static String getFilename( File file ) { if ( file == null ) { return null; } String path = splitFilename( file ).first; String parent = file.getParent(); return ( parent != null ) ? ( path.substring( file.getParent().length() + 1 ) ) : path; }
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 ); } } }
@Override public boolean canLoad( File filename ) { return FILE_EXTENSION.equalsIgnoreCase( FileUtils.getFileExtension( filename ) ); }
/** * writes a RasterReference into a world file. * * @param renv * the envelope * @param file * the raster file * @param extension * the file extension for the world file (eg. 'wld', 'tfw', etc) * @throws IOException */ public static void writeWorldFile( RasterGeoReference renv, File file, String extension ) throws IOException { File f = new File( FileUtils.getBasename( file ) + "." + extension ); FileWriter fw = new FileWriter( f ); PrintWriter pw = new PrintWriter( fw ); writeWorldFile( renv, pw ); pw.close(); fw.close(); }
/** * 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; }
@Override public boolean canLoad( File filename ) { return filename != null && GridRasterIOProvider.FORMATS.contains( FileUtils.getFileExtension( filename ).toLowerCase() ); }