|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.resources.coverage.CoverageUtilities
public final class CoverageUtilities
A set of utilities methods for the Grid Coverage package. Those methods are not really rigorous; must of them should be seen as temporary implementations.
Method Summary | |
---|---|
static boolean |
checkEmptySourceRegion(javax.imageio.ImageReadParam readParameters,
java.awt.Rectangle dimensions)
Checks that the provided dimensions when intersected with the source region used by
the provided ImageReadParam instance does not result in an empty Rectangle . |
static double[] |
getBackgroundValues(GridCoverage2D coverage)
Retrieves a best guess for the sample value to use for background, inspecting the categories of the provided GridCoverage2D . |
static org.opengis.referencing.crs.CoordinateReferenceSystem |
getCRS2D(org.opengis.coverage.Coverage coverage)
Returns a two-dimensional CRS for the given coverage. |
static Envelope2D |
getEnvelope2D(org.opengis.coverage.Coverage coverage)
Returns a two-dimensional envelope for the given coverage. |
static org.opengis.referencing.crs.CoordinateReferenceSystem |
getHorizontalCRS(org.opengis.coverage.Coverage coverage)
Returns a two-dimensional horizontal CRS for the given coverage. |
static double[] |
getResolution(java.awt.geom.AffineTransform gridToCRS)
Computes the resolutions for the provided "grid to world" transformation The returned resolution array is of length of 2. |
static int |
getVisibleBand(java.lang.Object image)
Returns the visible band in the specified RenderedImage or PropertySource . |
static boolean |
hasRenderingCategories(org.opengis.coverage.grid.GridCoverage gridCoverage)
Returns true if the provided GridCoverage
has Category objects with a real transformation. |
static boolean |
hasTransform(org.opengis.coverage.SampleDimension[] sampleDimensions)
Returns true if at least one of the specified sample dimensions has a
sample to geophysics transform
which is not the identity transform. |
static boolean |
isScaleTranslate(org.opengis.referencing.operation.MathTransform transform,
double EPS)
Checks if the transformation is a pure scale/translate instance (using the provided tolerance factor) |
static boolean |
isSimpleGridToWorldTransform(java.awt.geom.AffineTransform gridToCRS,
double EPS)
Tries to estimate if the supplied affine transform is either a scale and translate transform or if it contains a rotations which is an integer multiple of PI/2. |
static ViewType |
preferredViewAfterOperation(GridCoverage2D coverage)
The preferred view in which to returns the coverage after the operation. |
static ViewType |
preferredViewForOperation(GridCoverage2D coverage,
javax.media.jai.Interpolation interpolation,
boolean hasFilter,
java.awt.RenderingHints hints)
General purpose method used in various operations for GridCoverage2D to help
with taking decisions on how to treat coverages with respect to their ColorModel . |
static boolean |
uses(org.opengis.coverage.grid.GridCoverage coverage,
java.awt.image.RenderedImage image)
Returns true if the specified grid coverage or any of its source
uses the following image. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static org.opengis.referencing.crs.CoordinateReferenceSystem getCRS2D(org.opengis.coverage.Coverage coverage) throws org.opengis.referencing.operation.TransformException
coverage
- The coverage for which to obtains a two-dimensional CRS.
org.opengis.referencing.operation.TransformException
- if the CRS can't be reduced to two dimensions.public static org.opengis.referencing.crs.CoordinateReferenceSystem getHorizontalCRS(org.opengis.coverage.Coverage coverage) throws org.opengis.referencing.operation.TransformException
coverage
- The coverage for which to obtains a two-dimensional horizontal CRS.
org.opengis.referencing.operation.TransformException
- if the CRS can't be reduced to two dimensions.public static Envelope2D getEnvelope2D(org.opengis.coverage.Coverage coverage) throws org.opengis.geometry.MismatchedDimensionException
coverage
- The coverage for which to obtains a two-dimensional envelope.
org.opengis.geometry.MismatchedDimensionException
- if the envelope can't be reduced to two dimensions.public static double[] getBackgroundValues(GridCoverage2D coverage)
GridCoverage2D
.
coverage
- to use for guessing background values.
public static boolean hasRenderingCategories(org.opengis.coverage.grid.GridCoverage gridCoverage)
true
if the provided GridCoverage
has Category
objects with a real transformation.
Common use case for this method is understanding if a GridCoverage
has an
accompanying Geophysics or non-Geophysics view, which means a dicotomy between the
coverage with the "real" data and the coverage with the rendered version of the original
data exists. An example is when you have raw data whose data type is float and you want
to render them using a palette. You usually do this by specifying a set of Category
object which will map some intervals of the raw data to some specific colors. The rendered
version that we will create using the method GridCoverage2D#geophysics(false)
will
be backed by a RenderedImage with an IndexColorModel representing the colors provided in
the Categories.
gridCoverage
- to check for the existence of categories with tranformations
between original data and their rendered counterpart.
false
if this coverage has only a single view associated with it,
true
otherwise.public static boolean hasTransform(org.opengis.coverage.SampleDimension[] sampleDimensions)
true
if at least one of the specified sample dimensions has a
sample to geophysics transform
which is not the identity transform.
public static boolean uses(org.opengis.coverage.grid.GridCoverage coverage, java.awt.image.RenderedImage image)
true
if the specified grid coverage or any of its source
uses the following image.
public static int getVisibleBand(java.lang.Object image)
RenderedImage
or PropertySource
.
This method fetch the "GC_VisibleBand"
property. If this property is undefined,
then the visible band default to the first one.
image
- The image for which to fetch the visible band, or null
.
public static ViewType preferredViewForOperation(GridCoverage2D coverage, javax.media.jai.Interpolation interpolation, boolean hasFilter, java.awt.RenderingHints hints)
GridCoverage2D
to help
with taking decisions on how to treat coverages with respect to their ColorModel
.
The need for this method arose in consideration of the fact that applying most operations
on coverage whose ColorModel
is an instance of IndexColorModel
may lead to
unpredictable results depending on the applied Interpolation
(think about applying
"Scale" with InterpolationBilinear
on a non-geophysics GridCoverage2D
with an
IndexColorModel
) or more simply on the operation itself ("SubsampleAverage" cannot
be applied at all on a GridCoverage2D
backed by an IndexColorModel
).
This method suggests the actions to take depending on the structure of the provided
GridCoverage2D
, the provided Interpolation
and if the operation uses
a filter or not (this is useful for operations like SubsampleAverage or FilteredSubsample).
In general the idea is as follows: If the original coverage is backed by a
RenderedImage
with an IndexColorModel
, we have the following cases:
InterpolationNearest
and there is no filter involved
we can apply the operation on the IndexColorModel
-backed coverage with nor
problems.IndexColorModel
view) we need to perform an RGB(A) color expansion
before applying the operation.A special case is when we want to apply an operation on the geophysics view of a coverage that does not involve high order interpolation or filters. In this case we suggest to apply the operation on the non-geophysics view, which is usually much faster. Users may ignore this advice.
coverage
- The coverage to check for the action to take.interpolation
- The interpolation to use for the action to take, or null
if none.hasFilter
- true
if the operation we will apply is going to use a filter.hints
- The hints to use when applying a certain operation.
ViewType.SAME
if nothing has to be done on the provided coverage,
ViewType.PHOTOGRAPHIC
if a color expansion has to be provided,
ViewType.GEOPHYSICS
if we need to employ the geophysics view of
the provided coverage,
ViewType.NATIVE
if we suggest to employ the native (usually packed) view
of the provided coverage.public static ViewType preferredViewAfterOperation(GridCoverage2D coverage)
coverage
- The source coverage before the operation.
ViewType.SAME
if this method doesn't
have any suggestion.public static boolean isScaleTranslate(org.opengis.referencing.operation.MathTransform transform, double EPS)
transform
- The MathTransform
to check.EPS
- The tolerance factor.
true
if the provided transformation is a simple scale and translate,
false
otherwise.public static double[] getResolution(java.awt.geom.AffineTransform gridToCRS)
gridToCRS
- The grid to world transformation.public static boolean isSimpleGridToWorldTransform(java.awt.geom.AffineTransform gridToCRS, double EPS)
gridToCRS
- an instance of AffineTransform
to check against.EPS
- tolerance value for comparisons.
true
if this transform is "simple", false
otherwise.public static boolean checkEmptySourceRegion(javax.imageio.ImageReadParam readParameters, java.awt.Rectangle dimensions)
dimensions
when intersected with the source region used by
the provided ImageReadParam
instance does not result in an empty Rectangle
.
Finally, in case the region intersection is not empty, set it as new source region for the
provided ImageReadParam
.
Input parameters cannot be null.
readParameters
- an instance of ImageReadParam
for which we want to check
the source region element.dimensions
- an instance of Rectangle
to use for the check.
true
if the intersection is not empty, false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |