Class WorldFileResource
java.lang.Object
org.apache.sis.storage.AbstractResource
org.apache.sis.storage.AbstractGridCoverageResource
org.apache.sis.internal.storage.image.WorldFileResource
- All Implemented Interfaces:
StoreResource
,DataSet
,GridCoverageResource
,Resource
- Direct Known Subclasses:
WritableResource
A single image in a
WorldFileStore
.- Since:
- 1.2
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SoftReference<GridCoverage>
Cached coverage for the full image, ornull
if none.private GridGeometry
The grid geometry of this resource.private org.opengis.util.GenericName
The identifier as a sequence number in the namespace of theWorldFileStore
.private int
Index of the image to read or write in the image file.private List<SampleDimension>
The ranges of sample values, computed when first needed.private WorldFileStore
The parent data store, ornull
if this resource is not valid anymore.(package private) static final int
The dimensions of x and y axes.(package private) static final int
The dimensions of x and y axes.Fields inherited from class org.apache.sis.storage.AbstractResource
listeners
-
Constructor Summary
ConstructorsConstructorDescriptionWorldFileResource
(WorldFileStore store, StoreListeners parent, int imageIndex, GridGeometry gridGeometry) Creates a new resource. -
Method Summary
Modifier and TypeMethodDescription(package private) final void
Decrements the image index.(package private) final void
dispose()
Notifies this resource that it should not be used anymore.final GridGeometry
Returns the valid extent of grid coordinates together with the conversion from those grid coordinates to real world coordinates.final Optional<org.opengis.util.GenericName>
Returns the resource identifier.(package private) final int
Returns the index of the image to read or write in the image file.final DataStore
Returns the data store that produced this resource.final List<SampleDimension>
Returns the ranges of sample values in each band.final GridCoverage
read
(GridGeometry domain, int... ranges) Loads a subset of the image wrapped by this resource.(package private) final void
setGridCoverage
(GridCoverage coverage) Sets the grid coverage to the given value.(package private) final WorldFileStore
store()
Returns the data store.Methods inherited from class org.apache.sis.storage.AbstractGridCoverageResource
canNotRead, createMetadata, getEnvelope, logReadOperation
Methods inherited from class org.apache.sis.storage.AbstractResource
addListener, clearCache, 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
getLoadingStrategy, getResolutions, setLoadingStrategy, subset
Methods inherited from interface org.apache.sis.storage.Resource
addListener, getMetadata, removeListener
-
Field Details
-
X_DIMENSION
static final int X_DIMENSIONThe dimensions of x and y axes. Static constants for now, may become configurable fields in the future.- See Also:
-
Y_DIMENSION
static final int Y_DIMENSIONThe dimensions of x and y axes. Static constants for now, may become configurable fields in the future.- See Also:
-
store
The parent data store, ornull
if this resource is not valid anymore. -
imageIndex
private int imageIndexIndex of the image to read or write in the image file. This is usually 0. May be decremented when other resources are removed.- See Also:
-
identifier
private org.opengis.util.GenericName identifierThe identifier as a sequence number in the namespace of theWorldFileStore
. The first image has the sequence number "1". This is computed when first needed.WritableResource
have no identifier because the numbers may change.- See Also:
-
gridGeometry
The grid geometry of this resource. The grid extent is the image size.- See Also:
-
sampleDimensions
The ranges of sample values, computed when first needed. Shall be an unmodifiable list.- See Also:
-
fullCoverage
Cached coverage for the full image, ornull
if none.
-
-
Constructor Details
-
WorldFileResource
WorldFileResource(WorldFileStore store, StoreListeners parent, int imageIndex, GridGeometry gridGeometry) Creates a new resource. This resource will have its own set of listeners, but the listeners of the data store that created this resource will be notified as well.
-
-
Method Details
-
getOriginator
Returns the data store that produced this resource.- Specified by:
getOriginator
in interfaceStoreResource
- Returns:
- the data store that created this resource.
-
store
Returns the data store.- Throws:
DataStoreException
- if this resource is not valid anymore.
-
getImageIndex
final int getImageIndex()Returns the index of the image to read or write in the image file. This is usually 0. Note that contrarily togetIdentifier()
, this index is not guaranteed to be constant. -
decrementImageIndex
Decrements the image index. This is needed if images before this image have been removed.- Throws:
DataStoreException
-
getIdentifier
Returns the resource identifier. The name space is the file name and the local part of the name is the image index number, starting at 1. This identifier should be constant.- Specified by:
getIdentifier
in interfaceResource
- Overrides:
getIdentifier
in classAbstractResource
- 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:
-
getGridGeometry
Returns the valid extent of grid coordinates together with the conversion from those grid coordinates to real world coordinates. The CRS and "pixels to CRS" conversion may be unknown if this image is not themain image
, or if the*.prj
and/or world auxiliary file has not been found.- 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 in each band. Those sample dimensions describe colors because the World File format does not provide more information.- 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:
-
read
Loads a subset of the image wrapped by this resource.- 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.
-
setGridCoverage
Sets the grid coverage to the given value. This is used during write operations only. -
dispose
final void dispose()Notifies this resource that it should not be used anymore.
-