Class AbstractGridCoverageResource
Object
AbstractResource
AbstractGridCoverageResource
- All Implemented Interfaces:
DataSet, GridCoverageResource, Resource
- Direct Known Subclasses:
MemoryGridCoverageResource, TiledGridCoverageResource
public abstract class AbstractGridCoverageResource
extends AbstractResource
implements GridCoverageResource
Default implementations of several methods for classes that want to implement the
GridCoverageResource interface.
Subclasses should override the following methods:
GridCoverageResource.getGridGeometry()(mandatory)GridCoverageResource.getSampleDimensions()(mandatory)
read(…) method in subclasses:
canNotRead(String, GridGeometry, Throwable)for reporting a failure to read operation.logReadOperation(Object, GridGeometry, long)for logging a notice about a read operation.
- Since:
- 1.2
-
Nested Class Summary
Nested classes/interfaces inherited from interface Resource
Resource.FileSetModifier and TypeInterfaceDescriptionstatic classPaths to the files potentially used by the enclosing resource. -
Field Summary
Fields inherited from class AbstractResource
listenersModifier and TypeFieldDescriptionprotected final StoreListenersThe set of registeredStoreListeners for this resources. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractGridCoverageResource(StoreListeners parentListeners, boolean hidden) Creates a new resource which can send notifications to the given set of listeners.protectedCreates a new resource, potentially as a child of another resource. -
Method Summary
Modifier and TypeMethodDescriptionprotected DataStoreExceptioncanNotRead(String filename, GridGeometry request, Throwable cause) Creates an exception for a failure to load data.protected double[]convertResolutionOf(GridGeometry domain) Returns the resolution of the given grid geometry as a resolution in units of this coverage CRS.protected MetadataInvoked in a synchronized block the first time thatgetMetadata()is invoked.Returns the envelope of the grid geometry if known.protected voidlogReadOperation(Object file, GridGeometry domain, long startTime) Logs the execution of aGridCoverageResource.read(GridGeometry, int...)operation.Methods inherited from class AbstractResource
addListener, clearCache, getMetadata, getSynchronizationLock, removeListenerModifier 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.protected voidClears any cache in this resource, forcing the data to be recomputed when needed again.final MetadataReturns a description of this resource.protected ObjectReturns the object on which to perform synchronizations for thread-safety.<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.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface GridCoverageResource
getAvailableResolutions, getGridGeometry, getLoadingStrategy, getResolutions, getSampleDimensions, read, setLoadingStrategy, subsetModifier and TypeMethodDescriptiondefault List<double[]> Returns the preferred resolutions (in units of CRS axes) for read operations in this data store.Returns the valid extent of grid coordinates together with the conversion from those grid coordinates to real world coordinates.default RasterLoadingStrategyReturns an indication about when the "physical" loading of raster data will happen.default List<double[]> Deprecated, for removal: This API element is subject to removal in a future version.Returns the ranges of sample values together with the conversion from samples to real values.read(GridGeometry domain, int... ranges) Loads a subset of the grid coverage represented by this resource.default booleansetLoadingStrategy(RasterLoadingStrategy strategy) Sets the preferred strategy about when to do the "physical" loading of raster data.default GridCoverageResourceRequests a subset of the coverage.Methods inherited from interface Resource
getFileSet, getIdentifierModifier and TypeMethodDescriptiondefault Optional<Resource.FileSet> Gets the paths to the files potentially used by this resource.default Optional<GenericName> Returns the resource persistent identifier.
-
Constructor Details
-
AbstractGridCoverageResource
-
AbstractGridCoverageResource
Creates a new resource which can send notifications to the given set of listeners. Thehiddenargument specifies whether the new resource should be invisible in the tree of resources. See the parent constructor for more information.- Parameters:
parentListeners- listeners of the parent resource, ornullif none. This is usually the listeners of theDataStorethat created this resource.hidden-falseif this resource shall use its ownStoreListenerswith the specified parent, ortruefor usingparentListenersdirectly.
-
-
Method Details
-
getEnvelope
Returns the envelope of the grid geometry if known. The envelope is absent if the grid geometry does not provide this information.- Specified by:
getEnvelopein interfaceDataSet- Specified by:
getEnvelopein interfaceGridCoverageResource- Overrides:
getEnvelopein classAbstractResource- Returns:
- the grid geometry envelope.
- Throws:
DataStoreException- if an error occurred while computing the grid geometry.- See Also:
-
createMetadata
Invoked in a synchronized block the first time thatgetMetadata()is invoked. The default implementation populates metadata based on information provided bygetIdentifier(),getEnvelope(),getGridGeometry()andgetSampleDimensions(). Subclasses should override if they can provide more information. The default value can be completed by casting toDefaultMetadata.- Overrides:
createMetadatain classAbstractResource- Returns:
- the newly created metadata, or
nullif unknown. - Throws:
DataStoreException- if an error occurred while reading metadata from this resource.
-
convertResolutionOf
Returns the resolution of the given grid geometry as a resolution in units of this coverage CRS. If the CRS of the given domain is equivalent to the CRS of this coverage, then the returned values are equal todomain.getResolution(true). Otherwise, a coordinate operation is applied.This is a helper method for implementations of the
read(…)method by subclasses. The argument given to this method is typically thedomainargument given toread(…). Subclasses can use the returned values for choosing a subsampling or a pyramid level.- Parameters:
domain- the geometry from which to get the resolution, ornullif unspecified.- Returns:
- resolution of the given grid geometry in units of this coverage CRS, or
nullif none. - Throws:
DataStoreException- if an error occurred while converting thedomainresolution.- Since:
- 1.7
- See Also:
-
canNotRead
Creates an exception for a failure to load data. The exception sub-type is inferred from the arguments. If the failure is caused by an envelope outside the resource domain, then that envelope will be inferred from therequestargument.- Parameters:
filename- some identification (typically a file name) of the data that cannot be read.request- the requested domain, ornullif unspecified.cause- the cause of the failure, ornullif none.- Returns:
- the exception to throw.
- See Also:
-
logReadOperation
Logs the execution of aGridCoverageResource.read(GridGeometry, int...)operation. The log level will beLevel.FINEif the operation was quick enough, orPerformanceLevel.SLOWNESSor higher level otherwise.- Parameters:
file- the file that was opened, ornullforStoreListeners.getSourceName().domain- domain of the created grid coverage.startTime- value ofSystem.nanoTime()when the loading process started.
-
GridCoverageResource.getAvailableResolutions()but with opposite order.