Package org.apache.sis.internal.coverage
Class CoverageCombiner
java.lang.Object
org.apache.sis.internal.coverage.CoverageCombiner
Combines an arbitrary number of coverages into a single one.
The combined coverages may use different coordinate systems.
The workflow is as below:
- Creates a
CoverageCombiner
with the destination coverage where to write. - Configure with methods such as
setInterpolation(…)
. - Invoke
apply(…)
methods for each list of coverages to combine. - Get the combined coverage with
invalid reference
#result()
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
The 2 value for identifying code expecting exactly 2 dimensions.private final GridCoverage
The destination coverage where to write the coverages given to thisCoverageCombiner
.private final ImageProcessor
The image processor for resampling operation.private final int
The dimension to extract asRenderedImage
s.private final int
The dimension to extract asRenderedImage
s. -
Constructor Summary
ConstructorsConstructorDescriptionCoverageCombiner
(GridCoverage destination, int xdim, int ydim) Creates a coverage combiner which will write in the given coverage. -
Method Summary
Modifier and TypeMethodDescriptionboolean
apply
(GridCoverage... sources) Writes the given coverages on top of the destination coverage.private static GridGeometry
getGridGeometry
(RenderedImage image, GridCoverage coverage, GridExtent slice) Returns information about conversion from pixel coordinates to "real world" coordinates.Returns the interpolation method to use during resample operations.void
setInterpolation
(Interpolation method) Sets the interpolation method to use during resample operations.
-
Field Details
-
BIDIMENSIONAL
private static final int BIDIMENSIONALThe 2 value for identifying code expecting exactly 2 dimensions.- See Also:
-
processor
The image processor for resampling operation. The same processor is used for all slices. -
destination
The destination coverage where to write the coverages given to thisCoverageCombiner
. -
xdim
private final int xdimThe dimension to extract asRenderedImage
s. This is usually 0 for x and 1 for y. -
ydim
private final int ydimThe dimension to extract asRenderedImage
s. This is usually 0 for x and 1 for y.
-
-
Constructor Details
-
CoverageCombiner
Creates a coverage combiner which will write in the given coverage. The coverage is not cleared; cells that are not overwritten by calls to theaccept(…)
method will be left unchanged.- Parameters:
destination
- the destination coverage where to combine source coverages.xdim
- the dimension to extract asRenderedImage
x axis. This is usually 0.ydim
- the dimension to extract asRenderedImage
y axis. This is usually 1.
-
-
Method Details
-
getInterpolation
Returns the interpolation method to use during resample operations.Limitations
In current version, the interpolation is applied only in thexdim
andydim
dimensions specified at construction time. For all other dimensions, nearest neighbor interpolation is applied.- Returns:
- interpolation method to use during resample operations.
-
setInterpolation
Sets the interpolation method to use during resample operations.Limitations
In current version, the interpolation is applied only in thexdim
andydim
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 fromPlanarImage.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, orfalse
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.
-