Package org.apache.sis.internal.storage
Class GridResourceWrapper
java.lang.Object
org.apache.sis.internal.storage.GridResourceWrapper
- All Implemented Interfaces:
DataSet
,GridCoverageResource
,Resource
- Direct Known Subclasses:
Band
,MultiResolutionImage
A grid coverage resource which is a wrapper around another grid coverage resource.
Wrappers can be used for delaying data loading, modifying the identifier, completing metadata, etc.
The wrapped resource is created only when first needed.
- Since:
- 1.1
- Version:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate GridCoverageResource
The coverage resource instance which provides the data. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends StoreEvent>
voidaddListener
(Class<T> eventType, StoreListener<? super T> listener) Registers a listener to notify when the specified kind of event occurs in this resource or in children.final void
Closes the data store associated to the resource, then discards the resource.protected abstract GridCoverageResource
Creates the resource on which to delegate operations.Optional
<org.opengis.geometry.Envelope> Returns the spatiotemporal extent of this resource in its most natural coordinate reference system.Returns the valid extent of grid coordinates together with the conversion from those grid coordinates to real world coordinates.Optional
<org.opengis.util.GenericName> Returns the resource persistent identifier.Returns an indication about when the "physical" loading of raster data will happen.org.opengis.metadata.Metadata
Returns information about this resource.List
<double[]> Returns the preferred resolutions (in units of CRS axes) for read operations in this data store.Returns the ranges of sample values together with the conversion from samples to real values.protected abstract Object
Returns the object on which to perform all synchronizations for thread-safety.read
(GridGeometry domain, int... ranges) Loads a subset of the grid coverage represented by this resource.<T extends StoreEvent>
voidremoveListener
(Class<T> eventType, StoreListener<? super T> listener) Unregisters a listener previously added to this resource for the given type of events.boolean
setLoadingStrategy
(RasterLoadingStrategy strategy) Sets the preferred strategy about when to do the "physical" loading of raster data.protected final GridCoverageResource
source()
Returns the potentially cached source.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
subset
-
Field Details
-
source
The coverage resource instance which provides the data. This is initiallynull
and created when first needed.
-
-
Constructor Details
-
GridResourceWrapper
protected GridResourceWrapper()Creates a new wrapper.
-
-
Method Details
-
getSynchronizationLock
Returns the object on which to perform all synchronizations for thread-safety.- Returns:
- the object on which to perform synchronizations.
-
createSource
Creates the resource on which to delegate operations. This method is invoked in a synchronized block when first needed and the result is cached.- Returns:
- the resource on which to delegate operations.
- Throws:
DataStoreException
- if the resource cannot be created.
-
source
Returns the potentially cached source. This method invokescreateSource()
when first needed and caches the result.- Returns:
- the resource on which to delegate operations.
- Throws:
DataStoreException
- if the resource cannot be created.
-
getIdentifier
Returns the resource persistent identifier. The default implementation delegates to the source.- Specified by:
getIdentifier
in interfaceResource
- Returns:
- a persistent identifier unique within the data store, or absent if this resource has no such identifier.
- Throws:
DataStoreException
- if an error occurred while fetching the identifier.- See Also:
-
getMetadata
Returns information about this resource. The default implementation delegates to the source.- Specified by:
getMetadata
in interfaceResource
- Returns:
- information about this resource. Should not be
null
. - Throws:
DataStoreException
- if an error occurred while reading the metadata.- See Also:
-
getEnvelope
Returns the spatiotemporal extent of this resource in its most natural coordinate reference system. This is not necessarily the smallest bounding box encompassing all data. The default implementation delegates to the source.- Specified by:
getEnvelope
in interfaceDataSet
- Returns:
- the spatiotemporal resource extent. May be absent if none or too costly to compute.
- Throws:
DataStoreException
- if an error occurred while reading or computing the envelope.
-
getGridGeometry
Returns the valid extent of grid coordinates together with the conversion from those grid coordinates to real world coordinates. The default implementation delegates to the source.- Specified by:
getGridGeometry
in interfaceGridCoverageResource
- Returns:
- extent of grid coordinates together with their mapping to "real world" coordinates.
- Throws:
DataStoreException
- if an error occurred while reading definitions from the underlying data store.- See Also:
-
getSampleDimensions
Returns the ranges of sample values together with the conversion from samples to real values. The default implementation delegates to the source.- Specified by:
getSampleDimensions
in interfaceGridCoverageResource
- 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:
-
getResolutions
Returns the preferred resolutions (in units of CRS axes) for read operations in this data store. Elements are ordered from finest (smallest numbers) to coarsest (largest numbers) resolution.- Specified by:
getResolutions
in interfaceGridCoverageResource
- Returns:
- preferred resolutions for read operations in this data store, or an empty array if none.
- Throws:
DataStoreException
- if an error occurred while reading definitions from the underlying data store.- See Also:
-
read
Loads a subset of the grid coverage represented by this resource. The default implementation delegates to the source.- Specified by:
read
in interfaceGridCoverageResource
- 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.
-
getLoadingStrategy
Returns an indication about when the "physical" loading of raster data will happen. The default implementation delegates to the source.- Specified by:
getLoadingStrategy
in interfaceGridCoverageResource
- 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. The default implementation delegates to the source.- Specified by:
setLoadingStrategy
in interfaceGridCoverageResource
- 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.
-
addListener
public <T extends StoreEvent> void addListener(Class<T> eventType, StoreListener<? super T> listener) Registers a listener to notify when the specified kind of event occurs in this resource or in children. The default implementation delegates to the source.- Specified by:
addListener
in interfaceResource
- Type Parameters:
T
- compile-time value of theeventType
argument.- Parameters:
eventType
- type ofStoreEvent
to listen (cannot benull
).listener
- listener to notify about events.
-
removeListener
public <T extends StoreEvent> void removeListener(Class<T> eventType, StoreListener<? super T> listener) Unregisters a listener previously added to this resource for the given type of events. The default implementation delegates to the source.- Specified by:
removeListener
in interfaceResource
- Type Parameters:
T
- compile-time value of theeventType
argument.- Parameters:
eventType
- type ofStoreEvent
which were listened (cannot benull
).listener
- listener to stop notifying about events.
-
closeDataStore
Closes the data store associated to the resource, then discards the resource. This method does not verify if the data store is still used by other resources.- Throws:
DataStoreException
- if an error occurred while closing the data store.
-