Package org.apache.sis.coverage.grid
Class GridCoverageProcessor
Object
GridCoverageProcessor
- All Implemented Interfaces:
- Cloneable
A predefined set of operations on grid coverages as convenience methods.
 
Thread-safety
GridCoverageProcessor is safe for concurrent use in multi-threading environment.- Since:
- 1.1
- See Also:
Defined in the sis-feature module
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumTypes of changes that a coverage processor can do for executing an operation more efficiently.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final ImageProcessorThe processor to use for operations on two-dimensional slices.protected final EnumSet<GridCoverageProcessor.Optimization>The set of optimizations that are enabled.
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a new processor with default configuration.GridCoverageProcessor(ImageProcessor processor) Creates a new processor initialized to the given configuration.
- 
Method SummaryModifier and TypeMethodDescriptionclone()Returns a coverage processor with the same configuration than this processor.convert(GridCoverage source, MathTransform1D[] converters, Function<SampleDimension.Builder, SampleDimension> sampleDimensionModifier) Returns a coverage with sample values converted by the given functions.booleanReturnstrueif the given object is a coverage processor of the same class with the same configuration.Number[]Returns the values to use for pixels that cannot be computed.Returns the interpolation method to use for resampling operations.Returns the set of optimizations that are enabled.Quantity<?>[]Returns hints about the desired positional accuracy, in "real world" units or in pixel units.intReturns a hash code value for this coverage processor based on its current configuration.mask(GridCoverage source, RegionOfInterest mask, boolean maskInside) Applies a mask defined by a region of interest (ROI).resample(GridCoverage source, GridGeometry target) Creates a new coverage with a different grid extent, resolution or coordinate reference system.resample(GridCoverage source, CoordinateReferenceSystem target) Creates a new coverage with a different coordinate reference system.voidsetFillValues(Number... values) Sets the values to use for pixels that cannot be computed.voidsetInterpolation(Interpolation method) Sets the interpolation method to use for resampling operations.voidSpecifies the set of optimizations to enable.voidsetPositionalAccuracyHints(Quantity<?>... hints) Sets hints about desired positional accuracy, in "real world" units or in pixel units.shiftGrid(GridCoverage source, long... translation) Translates grid coordinates by the given amount of cells without changing "real world" coordinates.
- 
Field Details- 
imageProcessorThe processor to use for operations on two-dimensional slices.
- 
optimizationsThe set of optimizations that are enabled. By default, this set contains all enumeration values.- Since:
- 1.3
- See Also:
 
 
- 
- 
Constructor Details- 
GridCoverageProcessorpublic GridCoverageProcessor()Creates a new processor with default configuration.
- 
GridCoverageProcessorCreates a new processor initialized to the given configuration.- Parameters:
- processor- the processor to use for operations on two-dimensional slices.
 
 
- 
- 
Method Details- 
getInterpolationReturns the interpolation method to use for resampling operations. The default implementation delegates to the image processor.- Returns:
- interpolation method to use in resampling operations.
- See Also:
 
- 
setInterpolationSets the interpolation method to use for resampling operations. The default implementation delegates to the image processor.- Parameters:
- method- interpolation method to use in resampling operations.
- See Also:
 
- 
getPositionalAccuracyHintsReturns hints about the desired positional accuracy, in "real world" units or in pixel units. The default implementation delegates to the image processor.- Returns:
- desired accuracy in no particular order, or an empty array if none.
- See Also:
 
- 
setPositionalAccuracyHintsSets hints about desired positional accuracy, in "real world" units or in pixel units. The default implementation delegates to the image processor.- Parameters:
- hints- desired accuracy in no particular order, or a- nullarray if none. Null elements in the array are ignored.
- See Also:
 
- 
getOptimizationsReturns the set of optimizations that are enabled. By default, the returned set contains all optimizations.The returned set is a copy. Changes in this set will not affect the state of this processor. - Returns:
- copy of the set of optimizations that are enabled.
- Since:
- 1.3
 
- 
setOptimizationsSpecifies the set of optimizations to enable. All optimizations not in the given set will be disabled.- Parameters:
- enabled- set of optimizations to enable.
- Since:
- 1.3
 
- 
getFillValuesReturns the values to use for pixels that cannot be computed. The default implementation delegates to the image processor.- Returns:
- fill values to use for pixels that cannot be computed, or nullfor the defaults.
- Since:
- 1.2
- See Also:
 
- 
setFillValuesSets the values to use for pixels that cannot be computed. The default implementation delegates to the image processor.- Parameters:
- values- fill values to use for pixels that cannot be computed, or- nullfor the defaults.
- Since:
- 1.2
- See Also:
 
- 
maskpublic GridCoverage mask(GridCoverage source, RegionOfInterest mask, boolean maskInside) throws TransformException Applies a mask defined by a region of interest (ROI). IfmaskInsideistrue, then all pixels inside the given ROI are set to the fill values. IfmaskInsideisfalse, then the mask is reversed: the pixels set to fill values are the ones outside the ROI.- Parameters:
- source- the coverage on which to apply a mask.
- mask- region (in arbitrary CRS) of the mask.
- maskInside-- truefor masking pixels inside the shape, or- falsefor masking outside.
- Returns:
- a coverage with mask applied.
- Throws:
- TransformException- if ROI coordinates cannot be transformed to grid coordinates.
- Since:
- 1.2
- See Also:
 
- 
convertpublic GridCoverage convert(GridCoverage source, MathTransform1D[] converters, Function<SampleDimension.Builder, SampleDimension> sampleDimensionModifier) Returns a coverage with sample values converted by the given functions. The number of sample dimensions in the returned coverage is the length of theconvertersarray, which must be greater than 0 and not greater than the number of sample dimensions in the source coverage. If theconvertersarray length is less than the number of source sample dimensions, then all sample dimensions at index ≥converters.lengthwill be ignored.Sample dimensions customizationBy default, this method creates new sample dimensions with the same names and categories than in the previous coverage, but with sample ranges converted using the given converters and with units of measurement omitted. This behavior can be modified by specifying a non-nullsampleDimensionModifierfunction. If non-null, that function will be invoked with, as input, a pre-configured sample dimension builder. ThesampleDimensionModifierfunction can change the sample dimension name or rebuild the categories.Result relationship with sourceIf the source coverage is backed by aWritableRenderedImage, then changes in the source coverage are reflected in the returned coverage and conversely.- Parameters:
- source- the coverage for which to convert sample values.
- converters- the transfer functions to apply on each sample dimension of the source coverage.
- sampleDimensionModifier- a callback for modifying the- SampleDimension.Builderdefault configuration for each sample dimension of the target coverage, or- nullif none.
- Returns:
- the coverage which computes converted values from the given source.
- Since:
- 1.3
- See Also:
 
- 
shiftGridTranslates grid coordinates by the given amount of cells without changing "real world" coordinates. The translated grid has the same size than the source, i.e. both low and high grid coordinates are displaced by the same amount of cells. The "grid to CRS" transforms are adjusted accordingly in order to map to the same "real world" coordinates.Number of argumentsThetranslationarray length should be equal to the number of dimensions in the source coverage. If the array is shorter, missing values default to 0 (i.e. no translation in unspecified dimensions). If the array is longer, extraneous values are ignored.OptimizationsThe following optimizations are applied by default and can be disabled if desired:- GridCoverageProcessor.Optimization.REPLACE_SOURCEfor merging many calls of this- translate(…)method into a single translation.
 - Parameters:
- source- the grid coverage to translate.
- translation- translation to apply on each grid axis in order.
- Returns:
- a grid coverage whose grid coordinates (both low and high ones) and the "grid to CRS" transforms have been translated by given amounts. If the given translation is a no-op (no value or only 0 ones), then the source is returned as is.
- Throws:
- ArithmeticException- if the translation results in coordinates that overflow 64-bits integer.
- Since:
- 1.3
- See Also:
 
- 
resampleCreates a new coverage with a different grid extent, resolution or coordinate reference system. The desired properties are specified by theGridGeometryargument, which may be incomplete. The missing grid geometry components are completed as below:
 The interpolation method can be specified byDefault values for undefined grid geometry components Component Default value Grid extent A default size preserving resolution at source point of interest. Grid to CRS transform Whatever it takes for fitting data inside the supplied extent. Coordinate reference system Same as source coverage. setInterpolation(Interpolation). If the grid coverage values are themselves interpolated, this method tries to use the original data. The intent is to avoid adding interpolations on top of other interpolations.OptimizationsThe following optimizations are applied by default and can be disabled if desired:- GridCoverageProcessor.Optimization.REPLACE_SOURCEfor merging many calls of- resample(…)or- translate(…)method into a single resampling.
- GridCoverageProcessor.Optimization.REPLACE_OPERATIONfor replacing- resample(…)operation by- translate(…)when possible.
 - Parameters:
- source- the grid coverage to resample.
- target- the desired geometry of returned grid coverage. May be incomplete.
- Returns:
- a grid coverage with the characteristics specified in the given grid geometry.
- Throws:
- IncompleteGridGeometryException- if the source grid geometry is missing an information. It may be the source CRS, the source extent, etc. depending on context.
- TransformException- if some coordinates cannot be transformed to the specified target.
- See Also:
 
- 
resamplepublic GridCoverage resample(GridCoverage source, CoordinateReferenceSystem target) throws TransformException Creates a new coverage with a different coordinate reference system. The grid extent and "grid to CRS" transform are determined automatically with default values preserving the resolution of source coverage at its point of interest.See resample(GridCoverage, GridGeometry)for more information about interpolation and allowed optimizations.- Parameters:
- source- the grid coverage to resample.
- target- the desired coordinate reference system.
- Returns:
- a grid coverage with the given coordinate reference system.
- Throws:
- IncompleteGridGeometryException- if the source grid geometry is missing an information.
- TransformException- if some coordinates cannot be transformed to the specified target.
- Since:
- 1.3
 
- 
equalsReturnstrueif the given object is a coverage processor of the same class with the same configuration.
- 
hashCodepublic int hashCode()Returns a hash code value for this coverage processor based on its current configuration.
- 
cloneReturns a coverage processor with the same configuration than this processor.
 
-