Class GridCoverageFactory
- Object
-
- AbstractFactory
-
- GridCoverageFactory
-
- All Implemented Interfaces:
Factory
,RegistrableFactory
public class GridCoverageFactory extends AbstractFactory
A factory for grid coverage objects. This factory expects various combinations of the following informations:- A name as a character sequence.
- A raster, or an image, or an image function,
or a matrix of kind
float[][]
. - A (coordinate reference system - transform) pair, or an envelope, or a grid geometry. The envelope is easier to use, while the transform provides more control.
- Information about each sample dimensions (often called bands in the particular case of images), or minimal and maximal expected values for each bands.
- Optional properties as a map of key-value pairs.
"Properties" in Java Advanced Imaging are called "Metadata" by OpenGIS. Keys
are
String
objects (CaselessStringKey
are accepted as well), while values may be anyObject
.
The coordinate reference system is inferred from the supplied envelope or grid geometry parameters. If those parameters do not have CRS information, then this factory fallback on a default CRS.
Every
create
methods will ultimately delegate their work to a mastercreate
variant. Developpers can override this method if they want to intercept the creation of allGridCoverage2D
objects in this factory.- Since:
- 2.1
- Author:
- Martin Desruisseaux
-
-
Field Summary
-
Fields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
-
-
Constructor Summary
Constructors Constructor Description GridCoverageFactory()
Creates a default factory.GridCoverageFactory(Hints userHints)
Creates a factory using the specified set of hints.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GridCoverage2D
create(CharSequence name, float[][] matrix, Bounds envelope)
Constructs a grid coverage from the specified matrix and envelope.GridCoverage2D
create(CharSequence name, RenderedImage image, Bounds envelope)
GridCoverage2D
create(CharSequence name, RenderedImage image, Bounds envelope, GridSampleDimension[] bands, GridCoverage[] sources, Map<?,?> properties)
GridCoverage2D
create(CharSequence name, RenderedImage image, CoordinateReferenceSystem crs, MathTransform gridToCRS, GridSampleDimension[] bands, GridCoverage[] sources, Map<?,?> properties)
Constructs a grid coverage from the specified image and "grid to CRS" transform.GridCoverage2D
create(CharSequence name, RenderedImage image, GridGeometry2D gridGeometry, GridSampleDimension[] bands, GridCoverage[] sources, Map<?,?> properties)
Constructs a grid coverage from the specified image and grid geometry.GridCoverage2D
create(CharSequence name, WritableRaster raster, Bounds envelope)
GridCoverage2D
create(CharSequence name, WritableRaster raster, Bounds envelope, double[] minValues, double[] maxValues, Unit<?> units, Color[][] colors, RenderingHints hints)
GridCoverage2D
create(CharSequence name, WritableRaster raster, Bounds envelope, GridSampleDimension[] bands)
GridCoverage2D
create(CharSequence name, WritableRaster raster, CoordinateReferenceSystem crs, MathTransform gridToCRS, double[] minValues, double[] maxValues, Unit<?> units, Color[][] colors, RenderingHints hints)
Constructs a grid coverage from the specified raster and "grid to CRS" transform.GridCoverage2D
create(CharSequence name, WritableRaster raster, CoordinateReferenceSystem crs, MathTransform gridToCRS, GridSampleDimension[] bands)
Constructs a grid coverage from the specified raster and "grid to CRS" transform.GridCoverage2D
create(CharSequence name, ImageFunction function, GridGeometry2D gridGeometry, GridSampleDimension[] bands, Map<?,?> properties)
Constructs a grid coverage from an image function.protected CoordinateReferenceSystem
getDefaultCRS(int dimension)
Returns the default coordinate reference system to use when no CRS were explicitly specified by the user.-
Methods inherited from class AbstractFactory
addImplementationHints, equals, getImplementationHints, getPriority, hashCode, onDeregistration, onRegistration, toString
-
-
-
-
Constructor Detail
-
GridCoverageFactory
public GridCoverageFactory()
Creates a default factory. Users should not need to creates instance of this class directly. Invokeorg.geotools.coverage.FactoryFinder#getGridCoverageFactory
instead.
-
GridCoverageFactory
public GridCoverageFactory(Hints userHints)
Creates a factory using the specified set of hints. The factory recognizes the following hints:- Parameters:
userHints
- An optional set of hints to use for coverage constructions.
-
-
Method Detail
-
getDefaultCRS
protected CoordinateReferenceSystem getDefaultCRS(int dimension)
Returns the default coordinate reference system to use when no CRS were explicitly specified by the user. If aDEFAULT_COORDINATE_REFERENCE_SYSTEM
hint were provided at factory construction time, then the specified CRS is returned. Otherwise, the default implementation returnsDefaultGeographicCRS.WGS84
or its 3D variant. Subclasses should override this method if they want to use different defaults.- Parameters:
dimension
- The number of dimension expected in the CRS to be returned.- Returns:
- The new grid coverage.
- Since:
- 2.2
-
create
public GridCoverage2D create(CharSequence name, ImageFunction function, GridGeometry2D gridGeometry, GridSampleDimension[] bands, Map<?,?> properties)
Constructs a grid coverage from an image function.- Parameters:
name
- The grid coverage name.function
- The image function.gridGeometry
- The grid geometry. The grid range must contains the expected image size (width and height).bands
- Sample dimensions for each image band, ornull
for default sample dimensions.properties
- The set of properties for this coverage, ornull
if there is none.- Returns:
- The new grid coverage.
- Since:
- 2.2
-
create
public GridCoverage2D create(CharSequence name, float[][] matrix, Bounds envelope)
Constructs a grid coverage from the specified matrix and envelope. A default color palette is built from the minimal and maximal values found in the matrix.- Parameters:
name
- The grid coverage name.matrix
- The matrix data in a[row][column]
layout. NaN values are mapped to a transparent color.envelope
- The envelope.- Returns:
- The new grid coverage.
- Since:
- 2.2
-
create
public GridCoverage2D create(CharSequence name, WritableRaster raster, Bounds envelope)
Constructs a grid coverage from the specified raster and envelope. A default color palette is built from the minimal and maximal values found in the raster.- Parameters:
name
- The grid coverage name.raster
- The data (may be floating point numbers). NaN values are mapped to a transparent color.envelope
- The envelope.- Returns:
- The new grid coverage.
-
create
public GridCoverage2D create(CharSequence name, WritableRaster raster, Bounds envelope, double[] minValues, double[] maxValues, Unit<?> units, Color[][] colors, RenderingHints hints)
Constructs a grid coverage from the specified raster and envelope.See the
#create(CharSequence, RenderedImage, Envelope, GridSampleDimension[], GridCoverage[], Map)
rendered image variant for a note on heuristic rules applied by this method.- Parameters:
name
- The grid coverage name.raster
- The data (may be floating point numbers). NaN values are mapped to a transparent color.envelope
- The grid coverage cordinates and its CRS. This envelope must have at least two dimensions. The two first dimensions describe the image location along x and y axis. The other dimensions are optional and may be used to locate the image on a vertical axis or on the time axis.minValues
- The minimal value for each band in the raster, ornull
for computing it automatically.maxValues
- The maximal value for each band in the raster, ornull
for computing it automatically.units
- The units of sample values, ornull
if unknow.colors
- The colors to use for values fromminValues
tomaxValues
for each bands, ornull
for a default color palette. If non-null, each arrayscolors[b]
may have any length; colors will be interpolated as needed.hints
- An optional set of rendering hints, ornull
if none. Those hints will not affect the grid coverage to be created. The optionalSAMPLE_DIMENSION_TYPE
hint specifies theSampleDimensionType
to be used at rendering time, which can be one ofUNSIGNED_8BITS
orUNSIGNED_16BITS
.- Returns:
- The new grid coverage.
- Since:
- 2.2
-
create
public GridCoverage2D create(CharSequence name, WritableRaster raster, CoordinateReferenceSystem crs, MathTransform gridToCRS, double[] minValues, double[] maxValues, Unit<?> units, Color[][] colors, RenderingHints hints)
Constructs a grid coverage from the specified raster and "grid to CRS" transform.- Parameters:
name
- The grid coverage name.raster
- The data (may be floating point numbers). NaN values are mapped to a transparent color.crs
- The coordinate reference system. This specifies the CRS used when accessing a grid coverage with theevaluate
methods.gridToCRS
- The math transform from grid to coordinate reference system.minValues
- The minimal value for each band in the raster, ornull
for computing it automatically.maxValues
- The maximal value for each band in the raster, ornull
for computing it automatically.units
- The units of sample values, ornull
if unknow.colors
- The colors to use for values fromminValues
tomaxValues
for each bands, ornull
for a default color palette. If non-null, each arrayscolors[b]
may have any length; colors will be interpolated as needed.hints
- An optional set of rendering hints, ornull
if none. Those hints will not affect the grid coverage to be created. However, they may affect the grid coverage to be returned by
, i.e. the view to be used at rendering time. The optionalgeophysics
(false)SAMPLE_DIMENSION_TYPE
hint specifies theSampleDimensionType
to be used at rendering time, which can be one ofUNSIGNED_8BITS
orUNSIGNED_16BITS
.- Returns:
- The new grid coverage.
-
create
public GridCoverage2D create(CharSequence name, WritableRaster raster, Bounds envelope, GridSampleDimension[] bands)
Constructs a grid coverage from the specified raster and envelope. This convenience constructor performs the same assumptions on axis order than the rendered image variant.The coordinate reference system is inferred from the supplied envelope. The envelope must have at least two dimensions. The two first dimensions describe the image location along x and y axis. The other dimensions are optional and may be used to locate the image on a vertical axis or on the time axis.
- Parameters:
name
- The grid coverage name.raster
- The raster.envelope
- The grid coverage cordinates.bands
- Sample dimensions for each image band, ornull
for default sample dimensions. If non-null, then this array's length must matches the number of bands inimage
.- Returns:
- The new grid coverage.
- Since:
- 2.2
-
create
public GridCoverage2D create(CharSequence name, WritableRaster raster, CoordinateReferenceSystem crs, MathTransform gridToCRS, GridSampleDimension[] bands)
Constructs a grid coverage from the specified raster and "grid to CRS" transform.- Parameters:
name
- The grid coverage name.raster
- The raster.crs
- The coordinate reference system. This specifies the CRS used when accessing a grid coverage with theevaluate
methods. The number of dimensions must matches the number of target dimensions ofgridToCRS
.gridToCRS
- The math transform from grid to coordinate reference system.bands
- Sample dimensions for each image band, ornull
for default sample dimensions. If non-null, then this array's length must matches the number of bands inimage
.- Returns:
- The new grid coverage.
- Since:
- 2.2
-
create
public GridCoverage2D create(CharSequence name, RenderedImage image, Bounds envelope)
Constructs a grid coverage from the specified image and envelope. A default set of sample dimensions is used. The coordinate reference system is inferred from the supplied envelope.The envelope must have at least two dimensions. The two first dimensions describe the image location along x and y axis. The other dimensions are optional and may be used to locate the image on a vertical axis or on the time axis.
- Parameters:
name
- The grid coverage name.image
- The image.envelope
- The grid coverage cordinates.- Returns:
- The new grid coverage.
- Since:
- 2.2
-
create
public GridCoverage2D create(CharSequence name, RenderedImage image, Bounds envelope, GridSampleDimension[] bands, GridCoverage[] sources, Map<?,?> properties)
Constructs a grid coverage from the specified image and envelope. An affine transform will be computed automatically from the specified envelope using heuristic rules described below.This convenience constructor assumes that axis order in the supplied image matches exactly axis order in the supplied envelope. In other words, in the usual case where axis order in the image is (column, row), then the envelope should probably have a (longitude, latitude) or (easting, northing) axis order.
An exception to the above rule applies for CRS using exactly the following axis order: (
NORTH
|SOUTH
,EAST
|WEST
). An example of such CRS isEPSG:4326
. This convenience constructor will interchange automatically the (y,x) axis for such CRS.If more control on axis order and direction reversal is wanted, use the constructor variant expecting an explicit transform.
- Parameters:
name
- The grid coverage name.image
- The image.envelope
- The grid coverage cordinates. This envelope must have at least two dimensions. The two first dimensions describe the image location along x and y axis. The other dimensions are optional and may be used to locate the image on a vertical axis or on the time axis.bands
- Sample dimensions for each image band, ornull
for default sample dimensions. If non-null, then this array's length must matches the number of bands inimage
.sources
- The sources for this grid coverage, ornull
if none.properties
- The set of properties for this coverage, ornull
if there is none.- Returns:
- The new grid coverage.
- Since:
- 2.2
-
create
public GridCoverage2D create(CharSequence name, RenderedImage image, CoordinateReferenceSystem crs, MathTransform gridToCRS, GridSampleDimension[] bands, GridCoverage[] sources, Map<?,?> properties)
Constructs a grid coverage from the specified image and "grid to CRS" transform.- Parameters:
name
- The grid coverage name.image
- The image.crs
- The coordinate reference system. This specifies the CRS used when accessing a grid coverage with theevaluate
methods. The number of dimensions must matches the number of target dimensions ofgridToCRS
.gridToCRS
- The math transform from grid to coordinate reference system.bands
- Sample dimension for each image band, ornull
for default sample dimensions. If non-null, then this array's length must matches the number of bands in theimage
.sources
- The sources for this grid coverage, ornull
if none.properties
- The set of properties for this coverage, ornull
if there is none.- Returns:
- The new grid coverage.
-
create
public GridCoverage2D create(CharSequence name, RenderedImage image, GridGeometry2D gridGeometry, GridSampleDimension[] bands, GridCoverage[] sources, Map<?,?> properties)
Constructs a grid coverage from the specified image and grid geometry. The envelope (including the coordinate reference system) is inferred from the grid geometry.This is the most general constructor, the one that gives the maximum control on the grid coverage to be created. Every
create
methods will ultimately delegate their work this master method. Developpers can override this method if they want to intercept the creation of allGridCoverage2D
objects in this factory.- Parameters:
name
- The grid coverage name.image
- The image.gridGeometry
- The grid geometry (must contains an envelope with its coordinate reference system and a "grid to CRS" transform).bands
- Sample dimensions for each image band, ornull
for default sample dimensions. If non-null, then this array's length must matches the number of bands inimage
.sources
- The sources for this grid coverage, ornull
if none.properties
- The set of properties for this coverage, ornull
none.- Returns:
- The new grid coverage.
- Since:
- 2.2
-
-