Class CoverageCombiner

java.lang.Object
org.apache.sis.internal.coverage.CoverageCombiner

public final class CoverageCombiner extends Object
Combines an arbitrary number of coverages into a single one. The combined coverages may use different coordinate systems. The workflow is as below:
  1. Creates a CoverageCombiner with the destination coverage where to write.
  2. Configure with methods such as setInterpolation(…).
  3. Invoke apply(…) methods for each list of coverages to combine.
  4. Get the combined coverage with
    invalid reference
    #result()
    .
Coverages are combined in the order they are specified.

Limitations

Current implementation does not apply interpolations except in the two dimensions specified at construction time. For all other dimensions, data are taken from the nearest neighbor two-dimensional slice.

In addition, current implementation does not verify if sample dimensions are in the same order, and does not expand the destination coverage for accommodating data in given coverages that would be outside the bounds of destination coverage.

Since:
1.2
Version:
1.3
See Also:
  • Field Details

    • BIDIMENSIONAL

      private static final int BIDIMENSIONAL
      The 2 value for identifying code expecting exactly 2 dimensions.
      See Also:
    • processor

      private final ImageProcessor processor
      The image processor for resampling operation. The same processor is used for all slices.
    • destination

      private final GridCoverage destination
      The destination coverage where to write the coverages given to this CoverageCombiner.
    • xdim

      private final int xdim
      The dimension to extract as RenderedImages. This is usually 0 for x and 1 for y.
    • ydim

      private final int ydim
      The dimension to extract as RenderedImages. This is usually 0 for x and 1 for y.
  • Constructor Details

    • CoverageCombiner

      public CoverageCombiner(GridCoverage destination, int xdim, int ydim)
      Creates a coverage combiner which will write in the given coverage. The coverage is not cleared; cells that are not overwritten by calls to the accept(…) method will be left unchanged.
      Parameters:
      destination - the destination coverage where to combine source coverages.
      xdim - the dimension to extract as RenderedImage x axis. This is usually 0.
      ydim - the dimension to extract as RenderedImage y axis. This is usually 1.
  • Method Details

    • getInterpolation

      public Interpolation getInterpolation()
      Returns the interpolation method to use during resample operations.

      Limitations

      In current version, the interpolation is applied only in the xdim and ydim dimensions specified at construction time. For all other dimensions, nearest neighbor interpolation is applied.
      Returns:
      interpolation method to use during resample operations.
    • setInterpolation

      public void setInterpolation(Interpolation method)
      Sets the interpolation method to use during resample operations.

      Limitations

      In current version, the interpolation is applied only in the xdim and ydim dimensions specified at construction time. For all other dimensions, nearest neighbor interpolation is applied.
      Parameters:
      method - interpolation method to use during resample operations.
    • getGridGeometry

      private static GridGeometry getGridGeometry(RenderedImage image, GridCoverage coverage, GridExtent slice)
      Returns information about conversion from pixel coordinates to "real world" coordinates. This is taken from PlanarImage.GRID_GEOMETRY_KEY if available, or computed otherwise.
      Parameters:
      image - the image from which to get the conversion.
      coverage - the coverage to use as a fallback if the information is not provided with the image.
      slice - identification of the slice to read in the coverage.
      Returns:
      information about conversion from pixel to "real world" coordinates.
    • apply

      public boolean apply(GridCoverage... sources) throws org.opengis.referencing.operation.TransformException
      Writes the given coverages on top of the destination coverage. The given coverages are resampled to the grid geometry of the destination coverage. Coverages that do not intercept with the destination coverage are silently ignored.
      Parameters:
      sources - the coverages to write on top of destination coverage.
      Returns:
      true on success, or false if at least one slice in the destination coverage is not writable.
      Throws:
      org.opengis.referencing.operation.TransformException - if the coordinates of a given coverage cannot be transformed to the coordinates of destination coverage.