Package org.apache.sis.coverage.grid
Class ConvertedGridCoverage
java.lang.Object
org.apache.sis.coverage.BandedCoverage
org.apache.sis.coverage.grid.GridCoverage
org.apache.sis.coverage.grid.DerivedGridCoverage
org.apache.sis.coverage.grid.ConvertedGridCoverage
Decorates a
GridCoverage
in order to convert sample values on the fly.
There is two strategies about when to convert sample values:
- In calls to
render(GridExtent)
, sample values are converted when first needed on a tile-by-tile basis then cached for future reuse. Note however that discarding the returned image may result in the lost of cached tiles. - In calls to
BandedCoverage.Evaluator.apply(DirectPosition)
, the conversion is applied on-the-fly each time in order to avoid the potentially costly tile computations.
- Since:
- 1.0
- Version:
- 1.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class
Implementation of evaluator returned byevaluator()
.Nested classes/interfaces inherited from class org.apache.sis.coverage.grid.GridCoverage
GridCoverage.Evaluator, GridCoverage.Lazy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DataType
One of enumeration value that describe the sample values type in each band of images produced byrender(GridExtent)
.private final org.opengis.referencing.operation.MathTransform1D[]
Conversions from source values to converted values.private final boolean
Whether this grid coverage is for converted values.private final boolean
true
if the conversion was defined by user, orfalse
if this instance has been created byforConvertedValues(boolean)
implementation.private final ImageProcessor
The image processor to use for creating the tiles of converted values.Fields inherited from class org.apache.sis.coverage.grid.DerivedGridCoverage
source
Fields inherited from class org.apache.sis.coverage.grid.GridCoverage
gridGeometry
-
Constructor Summary
ConstructorsConstructorDescriptionConvertedGridCoverage
(GridCoverage source, List<SampleDimension> range, org.opengis.referencing.operation.MathTransform1D[] converters, boolean isConverted, ImageProcessor processor, boolean isUSerDefined) Creates a new coverage with the same grid geometry than the given coverage but converted sample dimensions. -
Method Summary
Modifier and TypeMethodDescription(package private) static org.opengis.referencing.operation.MathTransform1D[]
converters
(List<SampleDimension> sources, List<SampleDimension> targets, boolean converted) Returns the transforms for converting sample values from given sources to theconverted
status of those sources.(package private) static GridCoverage
create
(GridCoverage source, boolean converted) Returns a coverage of converted values computed from a coverage of packed values, or conversely.protected final GridCoverage
createConvertedValues
(boolean converted) Overridden as a matter of principle, but should not been invoked.Creates a new function for computing or interpolating sample values at given locations.forConvertedValues
(boolean converted) Returns this coverage or the source coverage depending on whetherconverted
matches the kind of content of this coverage.(package private) final DataType
Returns the constant identifying the primitive type used for storing sample values.(package private) static DataType
getBandType
(List<SampleDimension> targets, boolean converted, GridCoverage source) Returns the data type for range of values of given sample dimensions.(package private) final boolean
Returnstrue
if this coverage should not be replaced by its source.render
(GridExtent sliceExtent) Creates a converted view over source data for the given extent.Methods inherited from class org.apache.sis.coverage.grid.DerivedGridCoverage
toTree
Methods inherited from class org.apache.sis.coverage.grid.GridCoverage
appendDataLayout, convert, getCoordinateReferenceSystem, getEnvelope, getGridGeometry, getSampleDimensions, toString
-
Field Details
-
converters
private final org.opengis.referencing.operation.MathTransform1D[] convertersConversions from source values to converted values. The length of this array shall be equal to the number of bands. -
isConverted
private final boolean isConvertedWhether this grid coverage is for converted values. Iffalse
, then this coverage is for packed values. -
bandType
One of enumeration value that describe the sample values type in each band of images produced byrender(GridExtent)
. Shall not benull
.- See Also:
-
processor
The image processor to use for creating the tiles of converted values. -
isUSerDefined
private final boolean isUSerDefinedtrue
if the conversion was defined by user, orfalse
if this instance has been created byforConvertedValues(boolean)
implementation.
-
-
Constructor Details
-
ConvertedGridCoverage
ConvertedGridCoverage(GridCoverage source, List<SampleDimension> range, org.opengis.referencing.operation.MathTransform1D[] converters, boolean isConverted, ImageProcessor processor, boolean isUSerDefined) Creates a new coverage with the same grid geometry than the given coverage but converted sample dimensions.- Parameters:
source
- the coverage containing source values.range
- the sample dimensions to assign to the converted grid coverage.converters
- conversion from source to converted coverage, one transform per band.isConverted
- whether this grid coverage is for converted or packed values.processor
- the image processor to use for creating the tiles of converted values.
-
-
Method Details
-
create
static GridCoverage create(GridCoverage source, boolean converted) throws org.opengis.referencing.operation.NoninvertibleTransformException Returns a coverage of converted values computed from a coverage of packed values, or conversely. If the given coverage is already converted, then this method returnscoverage
unchanged. This method is used forGridCoverage.forConvertedValues(boolean)
default implementation.- Parameters:
source
- the coverage containing values to convert.converted
-true
for a coverage containing converted values, orfalse
for a coverage containing packed values.- Returns:
- the converted coverage. May be
source
. - Throws:
org.opengis.referencing.operation.NoninvertibleTransformException
- if this constructor cannot build a full conversion chain to target.
-
converters
static org.opengis.referencing.operation.MathTransform1D[] converters(List<SampleDimension> sources, List<SampleDimension> targets, boolean converted) throws org.opengis.referencing.operation.NoninvertibleTransformException Returns the transforms for converting sample values from given sources to theconverted
status of those sources. This method opportunistically adds the target sample dimensions intarget
list.- Parameters:
sources
-GridCoverage.getSampleDimensions()
ofsource
coverage.targets
- where to addSampleDimension.forConvertedValues(boolean)
results.converted
-true
for transforms to converted values, orfalse
for transforms to packed values.- Returns:
- the transforms, or
null
if all transforms are identity transform. - Throws:
org.opengis.referencing.operation.NoninvertibleTransformException
- if this method cannot build a full conversion chain.
-
getBandType
Returns the data type for range of values of given sample dimensions. This data type applies to each band, not to a packed sample model (e.g. we assume no packing of 4 byte values in a single 32-bits integer).- Parameters:
targets
- the sample dimensions for which to get the data type.converted
- whether the image will hold converted or packed values.source
- if the type cannot be determined, coverage from which to inherit the type as a fallback.- Returns:
- the data type (never null).
- See Also:
-
getBandType
Returns the constant identifying the primitive type used for storing sample values.- Overrides:
getBandType
in classDerivedGridCoverage
-
IsNotRepleacable
final boolean IsNotRepleacable()Returnstrue
if this coverage should not be replaced by its source.- Overrides:
IsNotRepleacable
in classDerivedGridCoverage
- See Also:
-
evaluator
Creates a new function for computing or interpolating sample values at given locations.Multi-threading
Evaluator
s are not thread-safe. For computing sample values concurrently, a newGridCoverage.Evaluator
instance should be created for each thread.- Overrides:
evaluator
in classDerivedGridCoverage
- Returns:
- a new function for computing or interpolating sample values.
-
render
Creates a converted view over source data for the given extent. Values will be converted when first requested on a tile-by-tile basis. Note that if the returned image is discarded, then the cache of converted tiles will be discarded too.- Specified by:
render
in classGridCoverage
- Parameters:
sliceExtent
- a subspace of this grid coverage extent where all dimensions except two have a size of 1 cell. May benull
if this grid coverage has only two dimensions with a size greater than 1 cell.- Returns:
- the grid slice as a rendered image with converted view.
-
forConvertedValues
Returns this coverage or the source coverage depending on whetherconverted
matches the kind of content of this coverage.- Overrides:
forConvertedValues
in classGridCoverage
- Parameters:
converted
-true
for a coverage containing converted values, orfalse
for a coverage containing packed values.- Returns:
- a coverage containing converted or packed values, depending on
converted
argument value. May bethis
but nevernull
. - See Also:
-
createConvertedValues
Overridden as a matter of principle, but should not been invoked.- Overrides:
createConvertedValues
in classGridCoverage
- Parameters:
converted
-true
for a coverage containing converted values, orfalse
for a coverage containing packed values.- Returns:
- a new coverage containing converted or packed values, depending on
converted
argument value. May bethis
but nevernull
.
-