| java.lang.Object org.geotools.coverage.processing.AbstractOperation org.geotools.coverage.processing.Operation2D org.geotools.coverage.processing.OperationJAI
All known Subclasses: org.geotools.coverage.processing.operation.MinFilter, org.geotools.coverage.processing.operation.Invert, org.geotools.coverage.processing.operation.SubtractFromConst, org.geotools.coverage.processing.operation.Rescale, org.geotools.coverage.processing.operation.MaxFilter, org.geotools.coverage.processing.operation.Log, org.geotools.coverage.processing.operation.GradientMagnitude, org.geotools.coverage.processing.operation.Exp, org.geotools.coverage.processing.operation.SubtractConst, org.geotools.coverage.processing.operation.MedianFilter, org.geotools.coverage.processing.operation.MultiplyConst, org.geotools.coverage.processing.BilevelOperation, org.geotools.coverage.processing.operation.Convolve, org.geotools.coverage.processing.operation.AddConst, org.geotools.coverage.processing.FilterOperation, org.geotools.coverage.processing.operation.Absolute, org.geotools.coverage.processing.AbstractStatisticsOperationJAI, org.geotools.coverage.processing.operation.DivideByConst,
OperationJAI | public class OperationJAI extends Operation2D (Code) | | Wraps a JAI's
OperationDescriptor for interoperability with
Java Advanced Imaging.
This class help to leverage the rich set of JAI operators in an GeoAPI framework.
OperationJAI inherits operation name and argument types from
OperationDescriptor ,
except the source argument type (usually
.class ) which is
set to
.class . If there is only one source argument, it
will be renamed
"source" for better compliance with OpenGIS usage.
The entry point for applying an operation is the usual
OperationJAI.doOperation doOperation method.
The default implementation forward the call to other methods for different bits of tasks,
resulting in the following chain of calls:
since: 2.2 version: $Id: OperationJAI.java 27848 2007-11-12 13:10:32Z desruisseaux $ author: Martin Desruisseaux author: Simone Giannecchini |
Inner Class :final protected static class Parameters | |
Field Summary | |
final protected static String | RENDERED_MODE The rendered mode for JAI operation. | final protected OperationDescriptor | operation The JAI's operation descriptor. |
Constructor Summary | |
public | OperationJAI(String operation) Constructs a grid coverage operation from a JAI operation name. | public | OperationJAI(OperationDescriptor operation) Constructs a grid coverage operation backed by a JAI operation. | protected | OperationJAI(OperationDescriptor operation, ParameterDescriptorGroup descriptor) Constructs a grid coverage operation backed by a JAI operation. |
Method Summary | |
protected RenderedImage | createRenderedImage(ParameterBlockJAI parameters, RenderingHints hints) Applies the JAI operation. | protected Category | deriveCategory(Category[] categories, Parameters parameters) Returns the quantitative category for a single
in the target
. | protected GridCoverage2D | deriveGridCoverage(GridCoverage2D[] sources, Parameters parameters) Applies a JAI operation to a grid coverage. | protected InternationalString | deriveName(GridCoverage2D[] sources, int primarySourceIndex, Parameters parameters) Returns a name for the target
based on the given
sources. | protected NumberRange | deriveRange(NumberRange[] ranges, Parameters parameters) Returns the range of value for a single
in the target
. | protected GridSampleDimension[] | deriveSampleDimension(GridSampleDimension[][] bandLists, Parameters parameters) Returns the
for the target
. | protected Unit | deriveUnit(Unit[] units, Parameters parameters) Returns the unit of data for a single
in the
target
. | public Coverage | doOperation(ParameterValueGroup parameters, Hints hints) Applies a process operation to a grid coverage.
The default implementation performs the following steps:
- Converts source grid coverages to their geophysics view using
(true) .
This allow to performs all computation on geophysics values instead of encoded
samples. | public boolean | equals(Object object) Compares the specified object with this operation for equality. | public static JAI | getJAI(RenderingHints hints) Returns the
JAI instance to use for operations on
RenderedImage .
If no JAI instance is defined for the
Hints.JAI_INSTANCE key, then the
default instance is returned.
Parameters: hints - The rendering hints, or null if none. | protected static OperationDescriptor | getOperationDescriptor(String name) Returns the operation descriptor for the specified JAI operation name. | protected Map | getProperties(RenderedImage data, CoordinateReferenceSystem crs, InternationalString name, MathTransform gridToCRS, GridCoverage2D[] sources, Parameters parameters) Prepares the properties to be given to the coverage created by the
OperationJAI.deriveGridCoverage deriveGridCoverage method. | protected static int | getQuantitative(Category[] categories) Returns the index of the quantitative category, providing that there is
one and only one quantitative category. | protected ParameterBlockJAI | prepareParameters(ParameterValueGroup parameters) Copies parameter values from the specified
ParameterValueGroup to the
ParameterBlockJAI , except the sources.
Note: it would be possible to use
ImagingParameters.parameters directly in some occasions. | protected void | resampleToCommonGeometry(GridCoverage2D[] sources, CoordinateReferenceSystem crs2D, MathTransform2D gridToCrs2D, Hints hints) Resamples all sources grid coverages to the same
before to apply the
. |
RENDERED_MODE | final protected static String RENDERED_MODE(Code) | | The rendered mode for JAI operation.
|
operation | final protected OperationDescriptor operation(Code) | | The JAI's operation descriptor.
|
OperationJAI | public OperationJAI(String operation) throws OperationNotFoundException(Code) | | Constructs a grid coverage operation from a JAI operation name. This convenience
constructor fetch the
OperationDescriptor from the specified operation
name using the default
JAI instance.
Parameters: operation - JAI operation name (e.g. "GradientMagnitude" ). throws: OperationNotFoundException - if no JAI descriptor was found for the given name. |
OperationJAI | public OperationJAI(OperationDescriptor operation)(Code) | | Constructs a grid coverage operation backed by a JAI operation. The operation descriptor
must supports the
"rendered" mode (which is the case for most JAI operations).
Parameters: operation - The JAI operation descriptor. |
OperationJAI | protected OperationJAI(OperationDescriptor operation, ParameterDescriptorGroup descriptor)(Code) | | Constructs a grid coverage operation backed by a JAI operation. The operation descriptor
must supports the
"rendered" mode (which is the case for most JAI operations).
Parameters: operation - The JAI operation descriptor. Parameters: descriptor - The OGC parameters descriptor. |
createRenderedImage | protected RenderedImage createRenderedImage(ParameterBlockJAI parameters, RenderingHints hints)(Code) | | Applies the JAI operation. The operation name can be fetch from
OperationJAI.operation .
The JAI instance to use can be fetch from
OperationJAI.getJAI . The default implementation
returns the following:
(hints).
(
.getName(), parameters, hints)
Subclasses may override this method in order to invokes a different JAI operation
according the parameters.
Parameters: parameters - The parameters to be given to JAI. Parameters: hints - The rendering hints to be given to JAI. |
deriveCategory | protected Category deriveCategory(Category[] categories, Parameters parameters)(Code) | | Returns the quantitative category for a single
in the target
. This method is invoked automatically
by the
OperationJAI.deriveSampleDimension deriveSampleDimension method for each band in the
target image. The default implementation creates a default category from the target range
of values returned by
OperationJAI.deriveRange deriveRange .
Parameters: categories - The quantitative categories from every sources. For unary operationslike "GradientMagnitude" , this array has a length of 1. For binaryoperations like "add" and "multiply" , this array has a length of 2. Parameters: parameters - Parameters, rendering hints and coordinate reference system to use. The quantative category to use in the destination image, or null if unknow. |
deriveName | protected InternationalString deriveName(GridCoverage2D[] sources, int primarySourceIndex, Parameters parameters)(Code) | | Returns a name for the target
based on the given
sources. This method is invoked once by the
OperationJAI.deriveGridCoverage deriveGridCoverage method. The default implementation returns the operation name followed by the source name
between parenthesis, for example "GradientMagnitude(Sea Surface Temperature)".
Parameters: sources - The sources grid coverage. Parameters: primarySourceIndex - The index of what seems to be the primary source, or -1 if none of unknow. Parameters: parameters - Parameters, rendering hints and coordinate reference system to use. A name for the target grid coverage. |
deriveRange | protected NumberRange deriveRange(NumberRange[] ranges, Parameters parameters)(Code) | | Returns the range of value for a single
in the target
. This method is invoked automatically
by the
OperationJAI.deriveCategory deriveCategory method for each band in the target image.
Subclasses should override this method in order to compute the target range of values.
For example, the
"add" operation may implements this method as below:
double min = ranges[0].getMinimum() + ranges[1].getMinimum();
double max = ranges[0}.getMaximum() + ranges[1}.getMaximum();
return new NumberRange(min, max);
Parameters: ranges - The range of values from every sources. For unary operations like "GradientMagnitude" , this array has a length of 1. For binary operationslike "add" and "multiply" , this array has a length of 2. Parameters: parameters - Parameters, rendering hints and coordinate reference system to use. The range of values to use in the destination image, or null if unknow. |
deriveSampleDimension | protected GridSampleDimension[] deriveSampleDimension(GridSampleDimension[][] bandLists, Parameters parameters)(Code) | | Returns the
for the target
. This method is invoked automatically by
OperationJAI.deriveGridCoverage deriveGridCoverage with a
bandLists argument
initialized as below:
- The
bandLists array length is equals to the number of source coverages.
- The
bandLists[i] array length is equals to the number of
sample dimensions in the source coverage i.
- The sample dimension for a band at index band in the source at index
source is
bandLists[source][band] .
This method shall returns an array with a length equals to the number of bands in the target
image. If the sample dimensions can't be determined, then this method is allowed to returns
null .
The default implementation iterates among all bands and invokes the
OperationJAI.deriveCategoryderiveCategory and
OperationJAI.deriveUnit deriveUnit methods for each of them. Subclasses
should override this method if they know a more accurate algorithm for determining sample
dimensions.
Parameters: bandLists - The set of sample dimensions for each source GridCoverage2Ds. Parameters: parameters - Parameters, rendering hints and coordinate reference system to use. The sample dimensions for each band in the destination image, or null if unknow. See Also: OperationJAI.deriveCategory See Also: OperationJAI.deriveUnit |
deriveUnit | protected Unit deriveUnit(Unit[] units, Parameters parameters)(Code) | | Returns the unit of data for a single
in the
target
. This method is invoked automatically by
the
OperationJAI.deriveSampleDimension deriveSampleDimension method for each band in the target
image. Subclasses should override this method in order to compute the target units from the
source units. For example a
"multiply" operation may implement this method as below:
if (units[0]!=null && units[1]!=null) {
return units[0].
Unit.multiply(Unit) multiply (units[1]);
} else {
return super.deriveUnit(units, cs, parameters);
}
Parameters: units - The units from every sources. For unary operations like "GradientMagnitude" , this array has a length of 1. For binary operationslike "add" and "multiply" , this array has a length of 2. Parameters: parameters - Parameters, rendering hints and coordinate reference system to use. The unit of data in the destination image, or null if unknow. |
doOperation | public Coverage doOperation(ParameterValueGroup parameters, Hints hints) throws CoverageProcessingException(Code) | | Applies a process operation to a grid coverage.
The default implementation performs the following steps:
- Converts source grid coverages to their geophysics view using
(true) .
This allow to performs all computation on geophysics values instead of encoded
samples. Note: this step is disabled if
OperationJAI.computeOnGeophysicsValues computeOnGeophysicsValues returns
false .
- Ensures that every sources
GridCoverage2D s use the same coordinate reference
system (at least for the two-dimensional part) with the same
GridGeometry2D.getGridToCRS2D gridToCRS relationship.
- Invokes
OperationJAI.deriveGridCoverage .
The sources in the
ParameterBlock are
RenderedImage objects
obtained from
GridCoverage2D.getRenderedImage .
- If a changes from non-geophysics to geophysics view were performed at step 1,
converts the result back to the original view using
(false) .
Parameters: parameters - List of name value pairs for the parameters required for the operation. Parameters: hints - A set of rendering hints, or null if none. The result as a grid coverage. throws: CoverageProcessingException - if the operation can't be applied. See Also: OperationJAI.deriveGridCoverage |
equals | public boolean equals(Object object)(Code) | | Compares the specified object with this operation for equality.
|
getJAI | public static JAI getJAI(RenderingHints hints)(Code) | | Returns the
JAI instance to use for operations on
RenderedImage .
If no JAI instance is defined for the
Hints.JAI_INSTANCE key, then the
default instance is returned.
Parameters: hints - The rendering hints, or null if none. The JAI instance to use (never null ). |
getOperationDescriptor | protected static OperationDescriptor getOperationDescriptor(String name) throws OperationNotFoundException(Code) | | Returns the operation descriptor for the specified JAI operation name. This method
uses the default
JAI instance and looks for the
mode.
Parameters: name - The operation name. The operation descriptor for the given name. throws: OperationNotFoundException - if no JAI descriptor was found for the given name. since: 2.4 |
getProperties | protected Map getProperties(RenderedImage data, CoordinateReferenceSystem crs, InternationalString name, MathTransform gridToCRS, GridCoverage2D[] sources, Parameters parameters)(Code) | | Prepares the properties to be given to the coverage created by the
OperationJAI.deriveGridCoverage deriveGridCoverage method. The default
implementation returns
null .
Parameters: data - The RenderedImage created by this operation. Parameters: crs - The coordinate reference system assigned to the coverage this OperationJAI will produce. Parameters: name - The name assigned to the coverage this OperationJAI will produce. Parameters: gridToCRS - The from grid to crs to beassigned to the coverage this OperationJAI will produce. Parameters: sources - The sources to be assigned to the coverage this OperationJAI willproduce. Parameters: parameters - The parameters that were used by this OperationJAI. a Map with the properties generated by thisOperationJAI or null if we haven't any. since: 2.4 |
getQuantitative | protected static int getQuantitative(Category[] categories)(Code) | | Returns the index of the quantitative category, providing that there is
one and only one quantitative category. If
categories contains 0,
2 or more quantative category, then this method returns
-1 .
since: 2.4 |
prepareParameters | protected ParameterBlockJAI prepareParameters(ParameterValueGroup parameters)(Code) | | Copies parameter values from the specified
ParameterValueGroup to the
ParameterBlockJAI , except the sources.
Note: it would be possible to use
ImagingParameters.parameters directly in some occasions. However, we peform an unconditional copy instead
because some operations (e.g. "GradientMagnitude") may change the values.
Parameters: parameters - The ParameterValueGroup to be copied. A copy of the provided ParameterValueGroup as a JAI block. since: 2.4 |
resampleToCommonGeometry | protected void resampleToCommonGeometry(GridCoverage2D[] sources, CoordinateReferenceSystem crs2D, MathTransform2D gridToCrs2D, Hints hints) throws InvalidGridGeometryException, CannotReprojectException(Code) | | Resamples all sources grid coverages to the same
before to apply the
. This method is invoked automatically
by the
OperationJAI.doOperation doOperation method. Only the two-dimensional part is reprojected
(usually the spatial component of a CRS). Extra dimension (if any) are left unchanged. Extra
dimensions are typically time axis or depth. Note that extra dimensions are
not forced to a common geometry; only the two dimensions that apply to a
javax.media.jai.PlanarImage are. This is because the extra dimensions don't need to
be compatible for all operations. For example if a source image is a slice in a time series,
a second source image could be a slice in the frequency representation of this time series.
Subclasses should override this method if they want to specify target
and
different than the
default ones. For example if a subclass wants to force all images to be referenced in a
CRS, then
it may overrides this method as below:
protected void resampleToCommonGeometry(...) {
crs2D = DefaultGeographicCRS.WGS84;
super.resampleToCommonGeometry(sources, crs2D, gridToCrs2D, hints);
}
Parameters: sources - The source grid coverages to resample. This array is updated in-place asneeded (for example if a grid coverage is replaced by a projected one). Parameters: crs2D - The target coordinate reference system to use, or null for adefault one. Parameters: gridToCrs2D - The target "grid to coordinate reference system" transform, or null for a default one. Parameters: hints - The rendering hints, or null if none. throws: InvalidGridGeometryException - if a source coverage has an unsupported grid geometry. throws: CannotReprojectException - if a grid coverage can't be resampled for some other reason. |
Fields inherited from org.geotools.coverage.processing.Operation2D | final protected static int PRIMARY_SOURCE_INDEX(Code)(Java Doc) final public static ParameterDescriptor SOURCE_0(Code)(Java Doc)
|
Fields inherited from org.geotools.coverage.processing.AbstractOperation | final protected ParameterDescriptorGroup descriptor(Code)(Java Doc)
|
|
|