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 classImplementation 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 DataTypeOne 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 booleanWhether this grid coverage is for converted values.private final booleantrueif the conversion was defined by user, orfalseif this instance has been created byforConvertedValues(boolean)implementation.private final ImageProcessorThe image processor to use for creating the tiles of converted values.Fields inherited from class org.apache.sis.coverage.grid.DerivedGridCoverage
sourceFields 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 theconvertedstatus of those sources.(package private) static GridCoveragecreate(GridCoverage source, boolean converted) Returns a coverage of converted values computed from a coverage of packed values, or conversely.protected final GridCoveragecreateConvertedValues(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 whetherconvertedmatches the kind of content of this coverage.(package private) final DataTypeReturns the constant identifying the primitive type used for storing sample values.(package private) static DataTypegetBandType(List<SampleDimension> targets, boolean converted, GridCoverage source) Returns the data type for range of values of given sample dimensions.(package private) final booleanReturnstrueif 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
toTreeMethods 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 isUSerDefinedtrueif the conversion was defined by user, orfalseif 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 returnscoverageunchanged. This method is used forGridCoverage.forConvertedValues(boolean)default implementation.- Parameters:
source- the coverage containing values to convert.converted-truefor a coverage containing converted values, orfalsefor 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 theconvertedstatus of those sources. This method opportunistically adds the target sample dimensions intargetlist.- Parameters:
sources-GridCoverage.getSampleDimensions()ofsourcecoverage.targets- where to addSampleDimension.forConvertedValues(boolean)results.converted-truefor transforms to converted values, orfalsefor transforms to packed values.- Returns:
- the transforms, or
nullif 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:
getBandTypein classDerivedGridCoverage
-
IsNotRepleacable
final boolean IsNotRepleacable()Returnstrueif this coverage should not be replaced by its source.- Overrides:
IsNotRepleacablein classDerivedGridCoverage- See Also:
-
evaluator
Creates a new function for computing or interpolating sample values at given locations.Multi-threading
Evaluators are not thread-safe. For computing sample values concurrently, a newGridCoverage.Evaluatorinstance should be created for each thread.- Overrides:
evaluatorin 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:
renderin classGridCoverage- Parameters:
sliceExtent- a subspace of this grid coverage extent where all dimensions except two have a size of 1 cell. May benullif 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 whetherconvertedmatches the kind of content of this coverage.- Overrides:
forConvertedValuesin classGridCoverage- Parameters:
converted-truefor a coverage containing converted values, orfalsefor a coverage containing packed values.- Returns:
- a coverage containing converted or packed values, depending on
convertedargument value. May bethisbut nevernull. - See Also:
-
createConvertedValues
Overridden as a matter of principle, but should not been invoked.- Overrides:
createConvertedValuesin classGridCoverage- Parameters:
converted-truefor a coverage containing converted values, orfalsefor a coverage containing packed values.- Returns:
- a new coverage containing converted or packed values, depending on
convertedargument value. May bethisbut nevernull.
-