/**
  * @param info
  * @param files
  * @param rasters
  * @param options
  */
 public DiskBasedTileContainer(
     QTreeInfo info, List<File> files, List<AbstractRaster> rasters, RasterIOOptions options) {
   qtree = new QTree<File>(createEnvelope(info.envelope), info.numberOfObjects);
   envelope = info.envelope;
   AbstractRaster raster = rasters.iterator().next();
   rasterDataInfo = raster.getRasterDataInfo();
   rasterGeoReference = info.rasterGeoReference;
   resolutionInfo = raster.getResolutionInfo();
   this.options = options;
   Iterator<File> iter = files.iterator();
   for (AbstractRaster r : rasters) {
     File f = iter.next();
     qtree.insert(createEnvelope(r.getEnvelope()), f);
     cache.put(f, new SoftReference<AbstractRaster>(r));
   }
   initialized = true;
 }
Ejemplo n.º 2
0
 /**
  * @param datasource
  * @param adapter
  * @return a corresponding raster, null if files could not be fund
  */
 public static AbstractRaster fromDatasource(RasterDataSource datasource, XMLAdapter adapter) {
   if (datasource != null) {
     String defCRS = datasource.getCrs();
     CRS crs = null;
     if (defCRS != null) {
       crs = new CRS(defCRS);
     }
     RasterFileSetType directory = datasource.getRasterDirectory();
     RasterFileType file = datasource.getRasterFile();
     try {
       if (directory != null) {
         File rasterFiles = new File(adapter.resolve(directory.getValue()).getFile());
         boolean recursive = directory.isRecursive() == null ? false : directory.isRecursive();
         RasterIOOptions options = new RasterIOOptions();
         if (crs != null) {
           options.add(RasterIOOptions.CRS, crs.getName());
         }
         return buildTiledRaster(rasterFiles, directory.getFilePattern(), recursive, options);
       }
       if (file != null) {
         final File loc = new File(adapter.resolve(file.getValue()).getFile());
         AbstractRaster raster = loadRasterFromFile(loc);
         raster.setCoordinateSystem(crs);
         return raster;
       }
     } catch (MalformedURLException e) {
       if (directory != null) {
         LOG.warn(
             "Could not resolve the file {}, corresponding data will not be available.",
             directory.getValue());
       } else {
         LOG.warn(
             "Could not resolve the file {}, corresponding data will not be available.",
             file.getValue());
       }
     } catch (IOException e) {
       LOG.warn(
           "Could not load the file {}, corresponding data will not be available.",
           file.getValue());
     }
   }
   throw new NullPointerException("The configured raster datasource may not be null.");
 }