Class MemoryGridCoverageResource
Object
AbstractResource
AbstractGridCoverageResource
MemoryGridCoverageResource
- All Implemented Interfaces:
DataSet, GridCoverageResource, Resource
A Grid Coverage Resource stored in memory.
This resource wraps an arbitrary
GridCoverage specified at construction time.
Metadata can be specified by overriding the AbstractGridCoverageResource.createMetadata() method.
When to use
This class is useful for small grid coverages, or for testing purposes, or when the coverage is in memory anyway (for example, a computation result). It should generally not be used for large coverages read from files or databases.- Since:
- 1.6
-
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
FieldsModifier and TypeFieldDescriptionprotected final GridCoverageThe grid coverage specified at construction time.protected final GridCoverageProcessorThe grid coverage processor to use for selecting bands.Fields inherited from class AbstractResource
listenersModifier and TypeFieldDescriptionprotected final StoreListenersThe set of registeredStoreListeners for this resources. -
Constructor Summary
ConstructorsConstructorDescriptionMemoryGridCoverageResource(GridCoverage coverage) Creates a new resource with no parent and no identifier.MemoryGridCoverageResource(Resource parent, GenericName identifier, GridCoverage coverage, GridCoverageProcessor processor) Creates a new resource stored in memory. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTests whether this memory grid coverage resource is wrapping the same coverage as the given object.Returns the grid coverage wrapped by this resource.Returns information about the domain of wrapped grid coverage.Returns the resource identifier specified at construction time, if any.Returns an indication about whetherread(…)tries to force the loading of data.Returns information about the ranges of wrapped grid coverage.intReturns a hash code value for consistency withequals(Object).read(GridGeometry domain, int... ranges) Returns a subset of the wrapped grid coverage.booleansetLoadingStrategy(RasterLoadingStrategy strategy) Sets the preference about whetherread(…)should try to force the loading of data.Returns a string representation of this resource.Methods inherited from class AbstractGridCoverageResource
canNotRead, convertResolutionOf, createMetadata, getEnvelope, logReadOperationModifier 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, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface GridCoverageResource
getAvailableResolutions, getResolutions, subsetModifier and TypeMethodDescriptiondefault List<double[]> Returns the preferred resolutions (in units of CRS axes) for read operations in this data store.default List<double[]> Deprecated, for removal: This API element is subject to removal in a future version.default GridCoverageResourceRequests a subset of the coverage.Methods inherited from interface Resource
getFileSetModifier and TypeMethodDescriptiondefault Optional<Resource.FileSet> Gets the paths to the files potentially used by this resource.
-
Field Details
-
coverage
-
processor
The grid coverage processor to use for selecting bands. It may be configured with a colorizer for determining the color models.
-
-
Constructor Details
-
MemoryGridCoverageResource
Creates a new resource with no parent and no identifier.- Parameters:
coverage- the coverage to wrap in a in-memory resource.- Throws:
NullPointerException- ifcoverageis null.- Since:
- 1.7
-
MemoryGridCoverageResource
public MemoryGridCoverageResource(Resource parent, GenericName identifier, GridCoverage coverage, GridCoverageProcessor processor) Creates a new resource stored in memory.- Parameters:
parent- the parent resource, ornullif none.identifier- resource identifier, ornullif none.coverage- the coverage to wrap in a in-memory resource.processor- the grid coverage processor for selecting bands, ornullfor default.- Throws:
NullPointerException- ifcoverageis null.
-
-
Method Details
-
getIdentifier
Returns the resource identifier specified at construction time, if any.- Returns:
- a persistent identifier unique within the data store, or absent if this resource has no such identifier.
- See Also:
-
getGridCoverage
Returns the grid coverage wrapped by this resource. The grid coverage returned by this method shall be the same or equivalent to the coverage that would be returned by a call toread(null), and should not be expansive to get.- Returns:
- the grid coverage wrapped by this resource.
- See Also:
-
getGridGeometry
Returns information about the domain of wrapped grid coverage.- Returns:
- extent of grid coordinates together with their mapping to "real world" coordinates.
- See Also:
-
getSampleDimensions
Returns information about the ranges of wrapped grid coverage.- Returns:
- ranges of sample values together with their mapping to "real values".
- See Also:
-
getLoadingStrategy
Returns an indication about whetherread(…)tries to force the loading of data.- Returns:
- current raster data loading strategy for this resource.
-
setLoadingStrategy
Sets the preference about whetherread(…)should try to force the loading of data.- 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.
-
read
Returns a subset of the wrapped grid coverage. If a null grid geometry and a null or empty range is specified, then this method shall return the same grid coverage asgetGridCoverage()or an equivalent coverage. If a non-null grid geometry is specified, then this method tries to return a grid coverage matching the given grid geometry on a best-effort basis. It may be the whole coverage.- Parameters:
domain- desired grid extent and resolution, ornullfor 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.
-
equals
Tests whether this memory grid coverage resource is wrapping the same coverage as the given object. This method checks also that the listeners and the grid coverage processor are equal. -
hashCode
-
toString
-
GridCoverageResource.getAvailableResolutions()but with opposite order.