Package org.apache.sis.storage
Class CoverageSubset
java.lang.Object
org.apache.sis.storage.AbstractResource
org.apache.sis.storage.AbstractGridCoverageResource
org.apache.sis.storage.CoverageSubset
- All Implemented Interfaces:
DataSet
,GridCoverageResource
,Resource
The result of
CoverageQuery.execute(GridCoverageResource)
.
This implementation merges the domain and range specified by the query with
arguments of GridCoverageResource.read(GridGeometry, int...)
method.- Since:
- 1.1
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CoverageQuery
The domain and range to read from the source coverage.private final GridCoverageResource
The coverage resource instance which provides the data.Fields inherited from class org.apache.sis.storage.AbstractResource
listeners
-
Constructor Summary
ConstructorsConstructorDescriptionCoverageSubset
(GridCoverageResource source, CoverageQuery query) Creates a new coverage resource by filtering the given coverage using the given query. -
Method Summary
Modifier and TypeMethodDescriptionprivate GridGeometry
clip
(GridGeometry domain, GridRoundingMode rounding, GridClippingMode clipping) Clips the given domain to the area of interest specified by the query.protected org.opengis.metadata.Metadata
Creates metadata about this subset.Returns the valid extent of grid coordinates clipped to the area specified in the query.Returns an indication about when the "physical" loading of raster data will happen.Returns the ranges of sample values together with the conversion from samples to real values.private String
invalidRange
(int size, int index) Creates an exception message for an invalid range index.read
(GridGeometry domain, int... ranges) Loads a subset of the grid coverage represented by this resource.boolean
setLoadingStrategy
(RasterLoadingStrategy strategy) Sets the preferred strategy about when to do the "physical" loading of raster data.Methods inherited from class org.apache.sis.storage.AbstractGridCoverageResource
canNotRead, getEnvelope, logReadOperation
Methods inherited from class org.apache.sis.storage.AbstractResource
addListener, clearCache, createExceptionMessage, getIdentifier, getMetadata, getSynchronizationLock, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.sis.storage.GridCoverageResource
getResolutions, subset
Methods inherited from interface org.apache.sis.storage.Resource
addListener, getIdentifier, getMetadata, removeListener
-
Field Details
-
source
The coverage resource instance which provides the data. -
query
The domain and range to read from the source coverage.
-
-
Constructor Details
-
CoverageSubset
CoverageSubset(GridCoverageResource source, CoverageQuery query) Creates a new coverage resource by filtering the given coverage using the given query. This given query is stored as-is (it is not cloned neither optimized).- Parameters:
source
- the coverage resource instances which provides the data.query
- the domain and range to read from thesource
coverage.
-
-
Method Details
-
createMetadata
Creates metadata about this subset. It includes information about the complete feature set.- Overrides:
createMetadata
in classAbstractGridCoverageResource
- Returns:
- the newly created metadata, or
null
if unknown. - Throws:
DataStoreException
- if an error occurred while reading metadata from this resource.
-
getGridGeometry
Returns the valid extent of grid coordinates clipped to the area specified in the query. It should be the geometry of the coverage that we get when invokingread(…)
withnull
arguments, but this is not guaranteed. The returned grid geometry may be approximate.- Returns:
- extent of grid coordinates clipped to the query.
- Throws:
DataStoreException
- if an error occurred while reading definitions from the underlying data store, or if the grid geometry cannot be clipped to the query area.- See Also:
-
clip
private GridGeometry clip(GridGeometry domain, GridRoundingMode rounding, GridClippingMode clipping) throws DataStoreException Clips the given domain to the area of interest specified by the query. If any grid geometry is null, the other one is returned. Thedomain
argument should be the domain to read as specified toread(GridGeometry, int...)
, or the fullCoverageSubset
domain if no value were given to theread(…)
method.- Parameters:
domain
- the domain requested in a read operation, ornull
.rounding
- whether to clip to nearest box or an enclosing box.clipping
- whether to clip the resulting extent to the specifieddomain
extent.- Returns:
- intersection of the given grid geometry with the query domain.
- Throws:
DataStoreException
- if the intersection cannot be computed.
-
getSampleDimensions
Returns the ranges of sample values together with the conversion from samples to real values. The returned list should never be empty.- Returns:
- ranges of sample values together with their mapping to "real values".
- Throws:
DataStoreException
- if an error occurred while reading definitions from the underlying data store.- See Also:
-
getLoadingStrategy
Returns an indication about when the "physical" loading of raster data will happen. This information is fetched from the wrapped resource doing the actual real operations.- Returns:
- current raster data loading strategy for this resource.
- Throws:
DataStoreException
- if an error occurred while fetching data store configuration.
-
setLoadingStrategy
Sets the preferred strategy about when to do the "physical" loading of raster data. This information is forwarded to the wrapped resource doing the actual real operations.- Parameters:
strategy
- the desired strategy for loading raster data.- Returns:
true
if the given strategy has been accepted, orfalse
if this implementation replaced the given strategy by an alternative.- Throws:
DataStoreException
- if an error occurred while setting data store configuration.
-
read
Loads a subset of the grid coverage represented by this resource. The domain to be read by the resource is computed as below:- If the query specifies a
domain
, the given domain is intersected with the query domain. - If the query specifies a domain expansion, the given domain is expanded by the amount specified in the query.
- Parameters:
domain
- desired grid extent and resolution, ornull
for reading the whole domain.ranges
- 0-based indices of sample dimensions to read, ornull
or an empty sequence for reading them all.- Returns:
- the grid coverage for the specified domain and ranges.
- Throws:
DataStoreException
- if an error occurred while reading the grid coverage data.
- If the query specifies a
-
invalidRange
Creates an exception message for an invalid range index.- Parameters:
size
- number of sample dimensions in source coverage.index
- the index which is out of bounds.
-