Class DefaultGridCoverageResponse
- Object
-
- DefaultGridCoverageResponse
-
- All Implemented Interfaces:
Coverage
,GridCoverage
,GridCoverageResponse
public class DefaultGridCoverageResponse extends Object implements GridCoverageResponse
Default GridCoverageResponse implementation.- Author:
- Daniele Romagnoli, GeoSolutions SAS
-
-
Constructor Summary
Constructors Constructor Description DefaultGridCoverageResponse(GridCoverage gridCoverage, DateRange temporalExtent, NumberRange<Double> verticalExtent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
evaluate(Position point)
Return the value vector for a given point in the coverage.boolean[]
evaluate(Position point, boolean[] destination)
Return a sequence of boolean values for a given point in the coverage.byte[]
evaluate(Position point, byte[] destination)
Return a sequence of unsigned byte values for a given point in the coverage.double[]
evaluate(Position point, double[] destination)
Return a sequence of double values for a given point in the coverage.float[]
evaluate(Position point, float[] destination)
Return a sequence of float values for a given point in the coverage.int[]
evaluate(Position point, int[] destination)
Return a sequence of integer values for a given point in the coverage.Set<Record>
evaluate(Position p, Collection<String> list)
Returns a set of records of feature attribute values for the specified direct position.CoordinateReferenceSystem
getCoordinateReferenceSystem()
Returns the coordinate reference system to which the objects in its domain are referenced.Bounds
getEnvelope()
The bounding box for the coverage domain in coordinate reference system coordinates.GridCoverage2D
getGridCoverage2D()
Return the underlying GridCoverage2D (responses are always 2D)GridGeometry
getGridGeometry()
Information for the grid coverage geometry.int
getNumOverviews()
Number of predetermined overviews for the grid.int
getNumSampleDimensions()
The number of sample dimensions in the coverage.int[]
getOptimalDataBlockSizes()
Optimal size to use for each dimension when accessing grid values.GridCoverage
getOverview(int index)
Returns a pre-calculated overview for a grid coverage.GridGeometry
getOverviewGridGeometry(int index)
Returns the grid geometry for an overview.RecordType
getRangeType()
Describes the range of the coverage.RenderableImage
getRenderableImage(int xAxis, int yAxis)
Returns 2D view of this coverage as a renderable image.RenderedImage
getRenderedImage()
Returns grid data as a rendered image.SampleDimension
getSampleDimension(int index)
Retrieve sample dimension information for the coverage.List<GridCoverage>
getSources()
Returns the sources data for a grid coverage.DateRange
getTemporalExtent()
Return the temporal extent of this gridcoverageNumberRange<Double>
getVerticalExtent()
Return the vertical extent of this gridcoverageboolean
isDataEditable()
Returnstrue
if grid data can be edited.
-
-
-
Constructor Detail
-
DefaultGridCoverageResponse
public DefaultGridCoverageResponse(GridCoverage gridCoverage, DateRange temporalExtent, NumberRange<Double> verticalExtent)
-
-
Method Detail
-
getTemporalExtent
public DateRange getTemporalExtent()
Description copied from interface:GridCoverageResponse
Return the temporal extent of this gridcoverage- Specified by:
getTemporalExtent
in interfaceGridCoverageResponse
-
getVerticalExtent
public NumberRange<Double> getVerticalExtent()
Description copied from interface:GridCoverageResponse
Return the vertical extent of this gridcoverage- Specified by:
getVerticalExtent
in interfaceGridCoverageResponse
-
getCoordinateReferenceSystem
public CoordinateReferenceSystem getCoordinateReferenceSystem()
Description copied from interface:Coverage
Returns the coordinate reference system to which the objects in its domain are referenced. This is the CRS used when accessing a coverage or grid coverage with theevaluate(...)
methods. This coordinate reference system is usually different than coordinate system of the grid. It is the target coordinate reference system of thegridToCRS
math transform.Grid coverage can be accessed (re-projected) with new coordinate reference system with the
GridCoverageProcessor
component. In this case, a new instance of a grid coverage is created.- Specified by:
getCoordinateReferenceSystem
in interfaceCoverage
- Returns:
- The coordinate reference system used when accessing a coverage or grid coverage with
the
evaluate(...)
methods.
-
getEnvelope
public Bounds getEnvelope()
Description copied from interface:Coverage
The bounding box for the coverage domain in coordinate reference system coordinates. For grid coverages, the grid cells are centered on each grid coordinate. The envelope for a 2-D grid coverage includes the following corner positions.(Minimum row - 0.5, Minimum column - 0.5) for the minimum coordinates (Maximum row - 0.5, Maximum column - 0.5) for the maximum coordinates
- Specified by:
getEnvelope
in interfaceCoverage
- Returns:
- The bounding box for the coverage domain in coordinate system coordinates.
-
getRangeType
public RecordType getRangeType()
Description copied from interface:Coverage
Describes the range of the coverage. It consists of a list of attribute name/data type pairs. A simple list is the most common form of range type, butRecordType
can be used recursively to describe more complex structures. The range type for a specific coverage shall be specified in an application schema.- Specified by:
getRangeType
in interfaceCoverage
- Returns:
- The coverage range.
-
evaluate
public Set<Record> evaluate(Position p, Collection<String> list) throws PointOutsideCoverageException, CannotEvaluateException
Description copied from interface:Coverage
Returns a set of records of feature attribute values for the specified direct position. The parameterlist
is a sequence of feature attribute names each of which identifies a field of the range type. Iflist
is null, the operation shall return a value for every field of the range type. Otherwise, it shall return a value for each field included inlist
. If the direct position passed is not in the domain of the coverage, then an exception is thrown. If the input direct position falls within two or more geometric objects within the domain, the operation shall return records of feature attribute values computed according to the common point rule.NOTE: Normally, the operation will return a single record of feature attribute values.
- Specified by:
evaluate
in interfaceCoverage
- Parameters:
p
- The position where to evaluate.list
- The field of interest, ornull
for every fields.- Returns:
- The feature attributes.
- Throws:
PointOutsideCoverageException
- if the point is outside the coverage domain.CannotEvaluateException
- If the point can't be evaluated for some other reason.
-
evaluate
public Object evaluate(Position point) throws PointOutsideCoverageException, CannotEvaluateException
Description copied from interface:Coverage
Return the value vector for a given point in the coverage. A value for each sample dimension is included in the vector. The default interpolation type used when accessing grid values for points which fall between grid cells is nearest neighbor.The coordinate reference system of the point is the same as the grid coverage coordinate reference system (specified by the
Coverage.getCoordinateReferenceSystem()
method).WARNING: This method is inherited from the legacy OGC 01-004 specification and may be deprecated in a future version. We are for more experience and feedbacks on the value of this method.
- Specified by:
evaluate
in interfaceCoverage
- Parameters:
point
- Point at which to find the grid values.- Returns:
- The value vector for a given point in the coverage.
- Throws:
PointOutsideCoverageException
- if the point is outside the coverage envelope.CannotEvaluateException
- If the point can't be evaluated for some other reason.- See Also:
Raster.getDataElements(int, int, Object)
-
evaluate
public boolean[] evaluate(Position point, boolean[] destination) throws PointOutsideCoverageException, CannotEvaluateException, ArrayIndexOutOfBoundsException
Description copied from interface:Coverage
Return a sequence of boolean values for a given point in the coverage. A value for each sample dimension is included in the sequence. The default interpolation type used when accessing grid values for points which fall between grid cells is nearest neighbor.The coordinate reference system of the point is the same as the grid coverage coordinate reference system (specified by the
Coverage.getCoordinateReferenceSystem()
method).- Specified by:
evaluate
in interfaceCoverage
- Parameters:
point
- Point at which to find the coverage values.destination
- An optionally preallocated array in which to store the values, ornull
if none.- Returns:
- A sequence of boolean values for a given point in the coverage. If
destination
was non-null, then it is returned. Otherwise, a new array is allocated and returned. - Throws:
PointOutsideCoverageException
- if the point is outside the coverage envelope.CannotEvaluateException
- if the point can't be evaluated for some othe reason.ArrayIndexOutOfBoundsException
- if thedestination
array is not null and too small to hold the output.
-
evaluate
public byte[] evaluate(Position point, byte[] destination) throws PointOutsideCoverageException, CannotEvaluateException, ArrayIndexOutOfBoundsException
Description copied from interface:Coverage
Return a sequence of unsigned byte values for a given point in the coverage. A value for each sample dimension is included in the sequence. The default interpolation type used when accessing grid values for points which fall between grid cells is nearest neighbor.The coordinate reference system of the point is the same as the grid coverage coordinate reference system (specified by the
Coverage.getCoordinateReferenceSystem()
method).- Specified by:
evaluate
in interfaceCoverage
- Parameters:
point
- Point at which to find the coverage values.destination
- An optionally preallocated array in which to store the values, ornull
if none.- Returns:
- A sequence of unsigned byte values for a given point in the coverage. If
destination
was non-null, then it is returned. Otherwise, a new array is allocated and returned. - Throws:
PointOutsideCoverageException
- if the point is outside the coverage envelope.CannotEvaluateException
- if the point can't be evaluated for some othe reason.ArrayIndexOutOfBoundsException
- if thedestination
array is not null and too small to hold the output.
-
evaluate
public int[] evaluate(Position point, int[] destination) throws PointOutsideCoverageException, CannotEvaluateException, ArrayIndexOutOfBoundsException
Description copied from interface:Coverage
Return a sequence of integer values for a given point in the coverage. A value for each sample dimension is included in the sequence. The default interpolation type used when accessing grid values for points which fall between grid cells is nearest neighbor.The coordinate reference system of the point is the same as the grid coverage coordinate reference system (specified by the
Coverage.getCoordinateReferenceSystem()
method).- Specified by:
evaluate
in interfaceCoverage
- Parameters:
point
- Point at which to find the grid values.destination
- An optionally preallocated array in which to store the values, ornull
if none.- Returns:
- A sequence of integer values for a given point in the coverage. If
destination
was non-null, then it is returned. Otherwise, a new array is allocated and returned. - Throws:
PointOutsideCoverageException
- if the point is outside the coverage envelope.CannotEvaluateException
- if the point can't be evaluated for some othe reason.ArrayIndexOutOfBoundsException
- if thedestination
array is not null and too small to hold the output.- See Also:
Raster.getPixel(int, int, int[])
-
evaluate
public float[] evaluate(Position point, float[] destination) throws PointOutsideCoverageException, CannotEvaluateException, ArrayIndexOutOfBoundsException
Description copied from interface:Coverage
Return a sequence of float values for a given point in the coverage. A value for each sample dimension is included in the sequence. The default interpolation type used when accessing grid values for points which fall between grid cells is nearest neighbor.The coordinate reference system of the point is the same as the grid coverage coordinate reference system (specified by the
Coverage.getCoordinateReferenceSystem()
method).- Specified by:
evaluate
in interfaceCoverage
- Parameters:
point
- Point at which to find the grid values.destination
- An optionally preallocated array in which to store the values, ornull
if none.- Returns:
- A sequence of float values for a given point in the coverage. If
destination
was non-null, then it is returned. Otherwise, a new array is allocated and returned. - Throws:
PointOutsideCoverageException
- if the point is outside the coverage envelope.CannotEvaluateException
- if the point can't be evaluated for some othe reason.ArrayIndexOutOfBoundsException
- if thedestination
array is not null and too small to hold the output.- See Also:
Raster.getPixel(int, int, float[])
-
evaluate
public double[] evaluate(Position point, double[] destination) throws PointOutsideCoverageException, CannotEvaluateException, ArrayIndexOutOfBoundsException
Description copied from interface:Coverage
Return a sequence of double values for a given point in the coverage. A value for each sample dimension is included in the sequence. The default interpolation type used when accessing grid values for points which fall between grid cells is nearest neighbor.The coordinate reference system of the point is the same as the grid coverage coordinate reference system (specified by the
Coverage.getCoordinateReferenceSystem()
method).- Specified by:
evaluate
in interfaceCoverage
- Parameters:
point
- Point at which to find the grid values.destination
- An optionally preallocated array in which to store the values, ornull
if none.- Returns:
- A sequence of double values for a given point in the coverage. If
destination
was non-null, then it is returned. Otherwise, a new array is allocated and returned. - Throws:
PointOutsideCoverageException
- if the point is outside the coverage envelope.CannotEvaluateException
- If the point can't be evaluated for some othe reason.ArrayIndexOutOfBoundsException
- if thedestination
array is not null and too small to hold the output.- See Also:
Raster.getPixel(int, int, double[])
-
getNumSampleDimensions
public int getNumSampleDimensions()
Description copied from interface:Coverage
The number of sample dimensions in the coverage. For grid coverages, a sample dimension is a band.WARNING: This method is inherited from the legacy OGC 01-004 specification and may be deprecated in a future version. We are for more experience and feedbacks on the value of this method.
- Specified by:
getNumSampleDimensions
in interfaceCoverage
- Returns:
- The number of sample dimensions in the coverage.
-
getSampleDimension
public SampleDimension getSampleDimension(int index) throws IndexOutOfBoundsException
Description copied from interface:Coverage
Retrieve sample dimension information for the coverage. For a grid coverage a sample dimension is a band. The sample dimension information include such things as description, data type of the value (bit, byte, integer...), the no data values, minimum and maximum values and a color table if one is associated with the dimension. A coverage must have at least one sample dimension.WARNING: This method is inherited from the legacy OGC 01-004 specification and may be deprecated in a future version. We are for more experience and feedbacks on the value of this method.
- Specified by:
getSampleDimension
in interfaceCoverage
- Parameters:
index
- Index for sample dimension to retrieve. Indices are numbered 0 to (n-1).- Returns:
- Sample dimension information for the coverage.
- Throws:
IndexOutOfBoundsException
- ifindex
is out of bounds.
-
getRenderableImage
public RenderableImage getRenderableImage(int xAxis, int yAxis) throws UnsupportedOperationException, IndexOutOfBoundsException
Description copied from interface:Coverage
Returns 2D view of this coverage as a renderable image. This optional operation allows interoperability with Java2D. If this coverage is aGridCoverage
backed by aRenderedImage
, the underlying image can be obtained with:getRenderableImage(0,1).createDefaultRendering()
- Specified by:
getRenderableImage
in interfaceCoverage
- Parameters:
xAxis
- Dimension to use for the x axis.yAxis
- Dimension to use for the y axis.- Returns:
- A 2D view of this coverage as a renderable image.
- Throws:
UnsupportedOperationException
- if this optional operation is not supported.IndexOutOfBoundsException
- ifxAxis
oryAxis
is out of bounds.
-
isDataEditable
public boolean isDataEditable()
Description copied from interface:GridCoverage
Returnstrue
if grid data can be edited.- Specified by:
isDataEditable
in interfaceGridCoverage
- Returns:
true
if grid data can be edited.
-
getGridGeometry
public GridGeometry getGridGeometry()
Description copied from interface:GridCoverage
Information for the grid coverage geometry. Grid geometry includes the valid range of grid coordinates and the georeferencing.- Specified by:
getGridGeometry
in interfaceGridCoverage
- Returns:
- The information for the grid coverage geometry.
-
getOptimalDataBlockSizes
public int[] getOptimalDataBlockSizes()
Description copied from interface:GridCoverage
Optimal size to use for each dimension when accessing grid values. These values together give the optimal block size to use when retrieving grid coverage values. For example, a client application can achieve better performance for a 2-D grid coverage by reading blocks of 128 by 128 if the grid is tiled into blocks of this size. The sequence is ordered by dimension. If the implementation does not have optimal sizes, the sequence will benull
.- Specified by:
getOptimalDataBlockSizes
in interfaceGridCoverage
- Returns:
- The optimal size to use for each dimension when accessing grid values, or
null
if none.
-
getNumOverviews
public int getNumOverviews()
Description copied from interface:GridCoverage
Number of predetermined overviews for the grid.- Specified by:
getNumOverviews
in interfaceGridCoverage
- Returns:
- The number of predetermined overviews for the grid.
-
getOverviewGridGeometry
public GridGeometry getOverviewGridGeometry(int index) throws IndexOutOfBoundsException
Description copied from interface:GridCoverage
Returns the grid geometry for an overview.- Specified by:
getOverviewGridGeometry
in interfaceGridCoverage
- Parameters:
index
- Overview index for which to retrieve grid geometry. Indices start at 0.- Returns:
- The grid geometry for an overview.
- Throws:
IndexOutOfBoundsException
- ifoverviewIndex
is out of bounds.
-
getOverview
public GridCoverage getOverview(int index) throws IndexOutOfBoundsException
Description copied from interface:GridCoverage
Returns a pre-calculated overview for a grid coverage. The overview indices are numbered from 0 tonumberOverviews-1
. The overviews are ordered from highest (index 0) to lowest (numberOverviews-1
) resolution. Overview grid coverages will have overviews which are the overviews for the grid coverage with lower resolution than the overview. For example, a 1 meter grid coverage with 3, 9, and 27 meter overviews will be ordered as in the left side below. The 3 meter overview will have 2 overviews as in the right side below:1 meter GC 3 meter overview Index resolution 0 3 1 9 2 27 Index resolution 0 9 1 27 - Specified by:
getOverview
in interfaceGridCoverage
- Parameters:
index
- Index of grid coverage overview to retrieve. Indexes start at 0.- Returns:
- A pre-calculated overview for a grid coverage.
- Throws:
IndexOutOfBoundsException
- ifoverviewIndex
is out of bounds.
-
getSources
public List<GridCoverage> getSources()
Description copied from interface:GridCoverage
Returns the sources data for a grid coverage. If theGridCoverage
was produced from an underlying dataset (byread(...)
for instance), this method should returns an empty list.If the
GridCoverage
was produced using {link org.geotools.api.coverage.processing.GridCoverageProcessor} then it should return the source grid coverages of the one used as input toGridCoverageProcessor
. In general this method is intended to return the originalGridCoverage
on which it depends.This is intended to allow applications to establish what
GridCoverage
s will be affected when others are updated, as well as to trace back to the "raw data".- Specified by:
getSources
in interfaceCoverage
- Specified by:
getSources
in interfaceGridCoverage
- Returns:
- The sources data for a grid coverage.
-
getRenderedImage
public RenderedImage getRenderedImage()
Description copied from interface:GridCoverage
Returns grid data as a rendered image.- Specified by:
getRenderedImage
in interfaceGridCoverage
-
getGridCoverage2D
public GridCoverage2D getGridCoverage2D()
Description copied from interface:GridCoverageResponse
Return the underlying GridCoverage2D (responses are always 2D)- Specified by:
getGridCoverage2D
in interfaceGridCoverageResponse
-
-