public class GridCoverage2D extends AbstractGridCoverage
Grid coverages are usually two-dimensional. However, their envelope
may have more than two dimensions. For example, a remote sensing image may be valid only over
some time range (the time of satellite pass over the observed area). Envelopes for such grid
coverage can have three dimensions: the two usual ones (horizontal extent along x and
y), and a third one for start time and end time (time extent along t).
However, the grid range for all extra-dimension
must have a size not greater than 1. In
other words, a GridCoverage2D
can be a slice in a 3 dimensional grid coverage. Each slice
can have an arbitrary width and height (like any two-dimensional images), but only 1 voxel depth
(a "voxel" is a three-dimensional pixel).
Serialization note:
Because it is serializable, GridCoverage2D
can be included as method argument or as
return type in Remote Method Invocation (RMI). However, the pixel data are not sent
during serialization. Instead, the image data are transmitted "on-demand" using socket
communications. This mechanism is implemented using JAI SerializableRenderedImage
class.
While serialization (usually on server side) should work on J2SE 1.4 and above, deserialization
(usually on client side) of GridCoverage2D
instances requires J2SE 1.5.
Modifier and Type | Class and Description |
---|---|
protected class |
GridCoverage2D.Renderable
A view of a grid coverage as a renderable image.
|
Modifier and Type | Field and Description |
---|---|
protected GridGeometry2D |
gridGeometry
The grid geometry.
|
protected PlanarImage |
image
The raster data.
|
LOGGER
crs
Modifier | Constructor and Description |
---|---|
|
GridCoverage2D(CharSequence name,
GridCoverage2D coverage)
Constructs a new grid coverage with the same parameter than the specified coverage.
|
protected |
GridCoverage2D(CharSequence name,
PlanarImage image,
GridGeometry2D gridGeometry,
GridSampleDimension[] bands,
GridCoverage[] sources,
Map<?,?> properties,
Hints hints)
Constructs a grid coverage with the specified grid geometry and
sample dimensions.
|
Modifier and Type | Method and Description |
---|---|
boolean |
dispose(boolean force)
Provides a hint that a coverage will no longer be accessed from a reference in user space.
|
Object |
evaluate(DirectPosition point)
Returns the value vector for a given location (world coordinates).
|
byte[] |
evaluate(DirectPosition coord,
byte[] dest)
Returns a sequence of byte values for a given location (world coordinates).
|
double[] |
evaluate(DirectPosition coord,
double[] dest)
Returns a sequence of double values for a given location (world coordinates).
|
float[] |
evaluate(DirectPosition coord,
float[] dest)
Returns a sequence of float values for a given location (world coordinates).
|
int[] |
evaluate(DirectPosition coord,
int[] dest)
Returns a sequence of integer values for a given location (world coordinates).
|
double[] |
evaluate(GridCoordinates2D coord,
double[] dest)
Return sample dimension (band) values as an array of doubles for the given grid
location.
|
float[] |
evaluate(GridCoordinates2D coord,
float[] dest)
Return sample dimension (band) values as an array of floats for the given grid
location.
|
int[] |
evaluate(GridCoordinates2D coord,
int[] dest)
Return sample dimension (band) values as an array of integers for the given grid
location.
|
double[] |
evaluate(Point2D coord,
double[] dest)
Returns a sequence of double values for a given location (world coordinates).
|
float[] |
evaluate(Point2D coord,
float[] dest)
Returns a sequence of float values for a given location (world coordinates).
|
int[] |
evaluate(Point2D coord,
int[] dest)
Returns a sequence of integer values for a given location (world coordinates).
|
CoordinateReferenceSystem |
getCoordinateReferenceSystem2D()
Returns the two-dimensional part of this grid coverage CRS.
|
String |
getDebugString(DirectPosition coord)
Returns a debug string for the specified coordinate.
|
Envelope |
getEnvelope()
Returns the bounding box for the coverage domain in coordinate reference system coordinates.
|
Envelope2D |
getEnvelope2D()
Returns the two-dimensional bounding box for the coverage domain in coordinate reference
system coordinates.
|
GridGeometry2D |
getGridGeometry()
Returns information for the grid coverage geometry.
|
Interpolation |
getInterpolation()
Returns the interpolation used for all
evaluate(...) methods. |
int |
getNumSampleDimensions()
Returns the number of bands in the grid coverage.
|
int[] |
getOptimalDataBlockSizes()
Returns the optimal size to use for each dimension when accessing grid values.
|
RenderableImage |
getRenderableImage(int xAxis,
int yAxis)
Returns 2D view of this grid coverage as a renderable image.
|
RenderedImage |
getRenderedImage()
Returns grid data as a rendered image.
|
GridSampleDimension |
getSampleDimension(int index)
Retrieve sample dimension information for the coverage.
|
GridSampleDimension[] |
getSampleDimensions()
Returns all sample dimensions for this grid coverage.
|
boolean |
isDataEditable()
Returns
true if grid data can be edited. |
void |
prefetch(Rectangle2D area)
Hints that the given area may be needed in the near future.
|
void |
show(String title)
{inheritDoc}
|
void |
show(String title,
int xAxis,
int yAxis)
{inheritDoc}
|
String |
toString()
Returns a string representation of this grid coverage.
|
formatEvaluateError, formatEvaluateError, getNumOverviews, getOverview, getOverviewGridGeometry, getSources
evaluate, evaluate, getCoordinateReferenceSystem, getDimension, getLocale, getName, getRangeType, show
getProperties, getProperty, getPropertyClass, getPropertyNames, getPropertyNames
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
evaluate, evaluate, getCoordinateReferenceSystem, getRangeType
protected final transient PlanarImage image
protected final GridGeometry2D gridGeometry
public GridCoverage2D(CharSequence name, GridCoverage2D coverage)
name
- The name for this coverage, or null
for the same than coverage
.coverage
- The source grid coverage.protected GridCoverage2D(CharSequence name, PlanarImage image, GridGeometry2D gridGeometry, GridSampleDimension[] bands, GridCoverage[] sources, Map<?,?> properties, Hints hints) throws IllegalArgumentException
This constructor accepts an optional set of properties. Keys are String
objects
(CaselessStringKey
are accepted as well), while values may be
any Object
.
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, or null
for default sample
dimensions. If non-null, then this array's length must matches the number of bands in
image
.sources
- The sources for this grid coverage, or null
if none.properties
- The set of properties for this coverage, or null
none.hints
- An optional set of hints, or null
if none.IllegalArgumentException
- If the number of bands differs from the number of sample
dimensions.public boolean isDataEditable()
true
if grid data can be edited. The default implementation returns true
if image
is an instance of WritableRenderedImage
.isDataEditable
in interface GridCoverage
isDataEditable
in class AbstractGridCoverage
true
if grid data can be edited.public GridGeometry2D getGridGeometry()
public Envelope getEnvelope()
getEnvelope
in interface Coverage
getEnvelope
in class AbstractCoverage
public Envelope2D getEnvelope2D()
public CoordinateReferenceSystem getCoordinateReferenceSystem2D()
AbstractCoverage.getCoordinateReferenceSystem()
public int getNumSampleDimensions()
public GridSampleDimension getSampleDimension(int index)
index
- Index for sample dimension to retrieve. Indices are numbered 0 to
(n-1).public GridSampleDimension[] getSampleDimensions()
public Interpolation getInterpolation()
evaluate(...)
methods. The default
implementation returns InterpolationNearest
.public Object evaluate(DirectPosition point) throws CannotEvaluateException
point
- Point at which to find the grid values.PointOutsideCoverageException
- if the point is outside the coverage envelope.CannotEvaluateException
- If the point can't be evaluated for some other reason.Raster.getDataElements(int, int, Object)
public byte[] evaluate(DirectPosition coord, byte[] dest) throws CannotEvaluateException
evaluate
in interface Coverage
evaluate
in class AbstractCoverage
coord
- World coordinates of the location to evaluate.dest
- An array in which to store values, or null
.CannotEvaluateException
- if the values can't be computed at the specified coordinate.
More specifically, PointOutsideCoverageException
is thrown if the evaluation
failed because the input point has invalid coordinates.public int[] evaluate(DirectPosition coord, int[] dest) throws CannotEvaluateException
evaluate
in interface Coverage
evaluate
in class AbstractCoverage
coord
- World coordinates of the location to evaluate.dest
- An array in which to store values, or null
.CannotEvaluateException
- if the values can't be computed at the specified coordinate.
More specifically, PointOutsideCoverageException
is thrown if the evaluation
failed because the input point has invalid coordinates.Raster.getPixel(int, int, int[])
public float[] evaluate(DirectPosition coord, float[] dest) throws CannotEvaluateException
evaluate
in interface Coverage
evaluate
in class AbstractCoverage
coord
- World coordinates of the location to evaluate.dest
- An array in which to store values, or null
.CannotEvaluateException
- if the values can't be computed at the specified coordinate.
More specifically, PointOutsideCoverageException
is thrown if the evaluation
failed because the input point has invalid coordinates.Raster.getPixel(int, int, float[])
public double[] evaluate(DirectPosition coord, double[] dest) throws CannotEvaluateException
evaluate
in interface Coverage
evaluate
in class AbstractCoverage
coord
- World coordinates of the location to evaluate.dest
- An array in which to store values, or null
.CannotEvaluateException
- if the values can't be computed at the specified coordinate.
More specifically, PointOutsideCoverageException
is thrown if the evaluation
failed because the input point has invalid coordinates.Raster.getPixel(int, int, double[])
public int[] evaluate(Point2D coord, int[] dest) throws CannotEvaluateException
coord
- World coordinates of the location to evaluate.dest
- An array in which to store values, or null
.CannotEvaluateException
- if the values can't be computed at the specified coordinate.
More specifically, PointOutsideCoverageException
is thrown if the evaluation
failed because the input point has invalid coordinates.public float[] evaluate(Point2D coord, float[] dest) throws CannotEvaluateException
coord
- World coordinates of the location to evaluate.dest
- An array in which to store values, or null
.CannotEvaluateException
- if the values can't be computed at the specified coordinate.
More specifically, PointOutsideCoverageException
is thrown if the evaluation
failed because the input point has invalid coordinates.public double[] evaluate(Point2D coord, double[] dest) throws CannotEvaluateException
coord
- World coordinates of the location to evaluate.dest
- An array in which to store values, or null
.CannotEvaluateException
- if the values can't be computed at the specified coordinate.
More specifically, PointOutsideCoverageException
is thrown if the evaluation
failed because the input point has invalid coordinates.public int[] evaluate(GridCoordinates2D coord, int[] dest)
GridEnvelope2D gridBounds = coverage.getGridGeometry2D().getGridRange();
coord
- grid (ie. pixel) coordinatesdest
- an optionally pre-allocated array; if non-null, its length should be equal to the
number of bands (sample dimensions)PointOutsideCoverageException
- if the supplied coords are outside the grid boundspublic float[] evaluate(GridCoordinates2D coord, float[] dest)
GridEnvelope2D gridBounds = coverage.getGridGeometry2D().getGridRange();
coord
- grid (ie. pixel) coordinatesdest
- an optionally pre-allocated array; if non-null, its length should be equal to the
number of bands (sample dimensions)PointOutsideCoverageException
- if the supplied coords are outside the grid boundspublic double[] evaluate(GridCoordinates2D coord, double[] dest)
GridEnvelope2D gridBounds = coverage.getGridGeometry2D().getGridRange();
coord
- grid (ie. pixel) coordinatesdest
- an optionally pre-allocated array; if non-null, its length should be equal to the
number of bands (sample dimensions)PointOutsideCoverageException
- if the supplied coords are outside the grid boundspublic String getDebugString(DirectPosition coord)
(1171,1566)=[196 (29.6 °C)]
coord
- The coordinate point where to evaluate.null
if coord
is outside coverage.public int[] getOptimalDataBlockSizes()
null
if none.public RenderedImage getRenderedImage()
public RenderableImage getRenderableImage(int xAxis, int yAxis)
getRenderableImage
in interface Coverage
getRenderableImage
in class AbstractCoverage
xAxis
- Dimension to use for x axis.yAxis
- Dimension to use for y axis.public void show(String title, int xAxis, int yAxis)
show
in class AbstractCoverage
title
- The window title, or null
for default value.xAxis
- Dimension to use for the x display axis.yAxis
- Dimension to use for the y display axis.public void show(String title)
show
in class AbstractCoverage
title
- The window title, or null
for default value.public void prefetch(Rectangle2D area)
area
- A rectangle indicating which geographic area to prefetch. This area's coordinates
must be expressed according the grid coverage's coordinate reference system, as given by
AbstractCoverage.getCoordinateReferenceSystem()
.public boolean dispose(boolean force)
force
is true
, or
This safety check helps to prevent the disposal of an image that still used in a JAI operation chain. It doesn't prevent the disposal in every cases however. When unsure about whatever a coverage is still in use or not, it is safer to not invoke this method and rely on the garbage collector instead.
dispose
in class AbstractCoverage
force
- true
for forcing an inconditionnal disposal, or false
for
performing a conservative disposal. The recommanded value is false
.true
if this method disposed at least some resources, or false
if
this method vetoed against the disposal.PlanarImage.dispose()
public String toString()
toString
in class AbstractCoverage
Copyright © 1996–2019 Geotools. All rights reserved.