Class WorldFileResource

All Implemented Interfaces:
StoreResource, DataSet, GridCoverageResource, Resource
Direct Known Subclasses:
WritableResource

class WorldFileResource extends AbstractGridCoverageResource implements StoreResource
A single image in a WorldFileStore.
Since:
1.2
Version:
1.3
  • Field Details

    • X_DIMENSION

      static final int X_DIMENSION
      The 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_DIMENSION
      The dimensions of x and y axes. Static constants for now, may become configurable fields in the future.
      See Also:
    • store

      private volatile WorldFileStore store
      The parent data store, or null if this resource is not valid anymore.
    • imageIndex

      private int imageIndex
      Index 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 identifier
      The identifier as a sequence number in the namespace of the WorldFileStore. 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

      private GridGeometry gridGeometry
      The grid geometry of this resource. The grid extent is the image size.
      See Also:
    • sampleDimensions

      private List<SampleDimension> sampleDimensions
      The ranges of sample values, computed when first needed. Shall be an unmodifiable list.
      See Also:
    • fullCoverage

      private SoftReference<GridCoverage> fullCoverage
      Cached coverage for the full image, or null 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

      public final DataStore getOriginator()
      Returns the data store that produced this resource.
      Specified by:
      getOriginator in interface StoreResource
      Returns:
      the data store that created this resource.
    • store

      final WorldFileStore store() throws DataStoreException
      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 to getIdentifier(), this index is not guaranteed to be constant.
    • decrementImageIndex

      final void decrementImageIndex() throws DataStoreException
      Decrements the image index. This is needed if images before this image have been removed.
      Throws:
      DataStoreException
    • getIdentifier

      public final Optional<org.opengis.util.GenericName> getIdentifier() throws DataStoreException
      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 interface Resource
      Overrides:
      getIdentifier in class AbstractResource
      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

      public final GridGeometry getGridGeometry() throws DataStoreException
      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 the main image, or if the *.prj and/or world auxiliary file has not been found.
      Specified by:
      getGridGeometry in interface GridCoverageResource
      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

      public final List<SampleDimension> getSampleDimensions() throws DataStoreException
      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 interface GridCoverageResource
      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

      public final GridCoverage read(GridGeometry domain, int... ranges) throws DataStoreException
      Loads a subset of the image wrapped by this resource.
      Specified by:
      read in interface GridCoverageResource
      Parameters:
      domain - desired grid extent and resolution, or null for reading the whole domain.
      ranges - 0-based indices of sample dimensions to read, or null 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

      final void setGridCoverage(GridCoverage coverage)
      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.