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 GridCoverageResourceThe 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 voidCloses the data store associated to the resource, then discards the resource.protected abstract GridCoverageResourceCreates 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.MetadataReturns 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 ObjectReturns 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.booleansetLoadingStrategy(RasterLoadingStrategy strategy) Sets the preferred strategy about when to do the "physical" loading of raster data.protected final GridCoverageResourcesource()Returns the potentially cached source.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.sis.storage.GridCoverageResource
subset
-
Field Details
-
source
The coverage resource instance which provides the data. This is initiallynulland 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:
getIdentifierin 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:
getMetadatain 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:
getEnvelopein 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:
getGridGeometryin 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:
getSampleDimensionsin 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:
getResolutionsin 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:
readin interfaceGridCoverageResource- Parameters:
domain- desired grid extent and resolution, ornullfor reading the whole domain.ranges- 0-based indices of sample dimensions to read, ornullor 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:
getLoadingStrategyin 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:
setLoadingStrategyin interfaceGridCoverageResource- Parameters:
strategy- the desired strategy for loading raster data.- Returns:
trueif the given strategy has been accepted, orfalseif 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:
addListenerin interfaceResource- Type Parameters:
T- compile-time value of theeventTypeargument.- Parameters:
listener- listener to notify about events.eventType- type ofStoreEventto listen (cannot benull).
-
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:
removeListenerin interfaceResource- Type Parameters:
T- compile-time value of theeventTypeargument.- Parameters:
listener- listener to stop notifying about events.eventType- type ofStoreEventwhich were listened (cannot benull).
-
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.
-