# Class GeoTiffStore

Object
DataStore
GeoTiffStore

All Implemented Interfaces:
  `AutoCloseable, Aggregate, Resource, Localized`

public class GeoTiffStore extends DataStore implements Aggregate
A data store backed by GeoTIFF files.

Since:
  0.8

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Resource

  `Resource​.FileSet`

- ## Field Summary

  ### Fields inherited from class DataStore

  `listeners, provider`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GeoTiffStore(DataStoreProvider provider, StorageConnector connector)`
  Creates a new GeoTIFF store from the given file, URL or stream object.
  `GeoTiffStore(DataStore parent, DataStoreProvider provider, StorageConnector connector, boolean hidden)`
  Creates a new GeoTIFF store as a component of a larger data store.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<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 data store.
  `GridCoverageResource`
  `append(RenderedImage image, GridGeometry grid, Metadata metadata)`
  Encodes the given image in the GeoTIFF file.
  `GridCoverageResource`
  `append(GridCoverage coverage, Metadata metadata)`
  Adds a new grid coverage in the GeoTIFF file.
  `void`
  `close()`
  Closes this GeoTIFF store and releases any underlying resources.
  `List<GridCoverageResource>`
  `components()`
  Returns descriptions of all images in this GeoTIFF file.
  `GridCoverageResource`
  `findResource(String sequence)`
  Returns the image at the given index.
  `Optional<Compression>`
  `getCompression()`
  Returns the compression used when writing tiles.
  `Optional<Resource​.FileSet>`
  `getFileSet()`
  Returns the paths to the files used by this GeoTIFF store.
  `Optional<GenericName>`
  `getIdentifier()`
  Returns an identifier constructed from the name of the TIFF file.
  `Metadata`
  `getMetadata()`
  Returns information about the dataset as a whole.
  `Set<FormatModifier>`
  `getModifiers()`
  Returns the modifiers (BigTIFF, COG…) of this data store.
  `Optional<TreeTable>`
  `getNativeMetadata()`
  Returns TIFF tags and GeoTIFF keys as a tree for debugging purpose.
  `Optional<ParameterValueGroup>`
  `getOpenParameters()`
  Returns the parameters used to open this GeoTIFF data store.

  ### Methods inherited from class DataStore

  `getDisplayName, getLocale, getProvider, removeListener, setLocale, toString`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface Resource

  `removeListener`

- ## Constructor Details

  - ### GeoTiffStore

    public GeoTiffStore(DataStoreProvider provider, StorageConnector connector) throws DataStoreException
    Creates a new GeoTIFF store from the given file, URL or stream object. This constructor invokes `StorageConnector​.closeAllExcept(Object)`, keeping open only the needed resource.
    Parameters:
      `provider` - the factory that created this `DataStore` instance, or `null` if unspecified.
      `connector` - information about the storage (URL, stream, etc).
    Throws:
      `DataStoreException` - if an error occurred while opening the GeoTIFF file.
    Since:
      1.5

  - ### GeoTiffStore

    public GeoTiffStore(DataStore parent, DataStoreProvider provider, StorageConnector connector, boolean hidden) throws DataStoreException
    Creates a new GeoTIFF store as a component of a larger data store. If the `hidden` parameter is `true`, some metadata that would normally be provided in this `GeoTiffStore` will be provided by individual components instead.

    #### Example

    A Landsat data set is a collection of files in a directory or ZIP file, which includes more than 10 GeoTIFF files (one image per band or product for a scene). `LandsatStore` is a data store opening the Landsat metadata file as the main file, then opening each band/product using a GeoTIFF data store. Those bands/products are components of the Landsat data store.
    Parameters:
      `parent` - the parent that contains this new GeoTIFF store component, or `null` if none.
      `provider` - the factory that created this `DataStore` instance, or `null` if unspecified.
      `connector` - information about the storage (URL, stream, etc).
      `hidden` - `true` if this GeoTIFF store will not be directly accessible from the parent. It is the case if the parent store will expose only some components instead of the GeoTIFF store itself.
    Throws:
      `DataStoreException` - if an error occurred while opening the GeoTIFF file.
    Since:
      1.1

- ## Method Details

  - ### getOpenParameters

    public Optional<ParameterValueGroup> getOpenParameters()
    Returns the parameters used to open this GeoTIFF data store. The parameters are described by `GeoTiffStoreProvider​.getOpenParameters()` and contains at least a parameter named "location" with a `URI` value. The return value may be empty if the storage input cannot be described by a URI (for example a GeoTIFF file reading directly from a `ReadableByteChannel`).
    Specified by:
      `getOpenParameters` in class `DataStore`
    Returns:
      parameters used for opening this data store.
    See Also:
      - `DataStoreProvider​.getOpenParameters()`

  - ### getModifiers

    public Set<FormatModifier> getModifiers()
    Returns the modifiers (BigTIFF, COG…) of this data store.
    Returns:
      format modifiers of this data store.
    Since:
      1.5

  - ### getCompression

    public Optional<Compression> getCompression()
    Returns the compression used when writing tiles. This is not necessarily the compression of images to be read. For the compression of existing images, see the metadata.
    Returns:
      the compression to use for writing new images, or empty if unspecified.
    Since:
      1.5

  - ### getIdentifier

    public Optional<GenericName> getIdentifier() throws DataStoreException
    Returns an identifier constructed from the name of the TIFF file. An identifier is available only if the storage input specified at construction time was something convertible to `URI`, for example an `URL`, `File` or `Path`.
    Specified by:
      `getIdentifier` in interface `Resource`
    Overrides:
      `getIdentifier` in class `DataStore`
    Returns:
      the identifier derived from the filename.
    Throws:
      `DataStoreException` - if an error occurred while fetching the identifier.
    Since:
      1.0
    See Also:
      - `DataStore​.getMetadata()`
      - `DataStore​.getDisplayName()`

  - ### getMetadata

    public Metadata getMetadata() throws DataStoreException
    Returns information about the dataset as a whole. The returned metadata object can contain information such as the spatiotemporal extent of the dataset, contact information about the creator or distributor, data quality, usage constraints and more.
    Specified by:
      `getMetadata` in interface `Resource`
    Specified by:
      `getMetadata` in class `DataStore`
    Returns:
      information about the dataset.
    Throws:
      `DataStoreException` - if an error occurred while reading the data.
    See Also:
      - `DataStore​.getIdentifier()`
      - `DefaultMetadata​.deepCopy(Metadata)`

  - ### getNativeMetadata

    public Optional<TreeTable> getNativeMetadata() throws DataStoreException
    Returns TIFF tags and GeoTIFF keys as a tree for debugging purpose. The tags and keys appear in the order they are declared in the file. The columns are tag numerical code as an `Integer`, tag name as a `String` and value as an `Object`.

    This method should not be invoked during normal operations; the standard metadata are preferred because they allow abstraction of data format details. Native metadata should be used only when an information does not appear in standard metadata, or for debugging purposes.

    #### Performance note

    Since this method should not be invoked in normal operations, it has not been tuned for performance. Invoking this method may cause a lot of seek operations.
    Overrides:
      `getNativeMetadata` in class `DataStore`
    Returns:
      resources information structured in an implementation-specific way.
    Throws:
      `DataStoreException` - if an error occurred while reading the metadata.
    Since:
      1.2

  - ### getFileSet

    public Optional<Resource.FileSet> getFileSet() throws DataStoreException
    Returns the paths to the files used by this GeoTIFF store. The fileset contains the path of the file given at construction time.
    Specified by:
      `getFileSet` in interface `Resource`
    Returns:
      files used by this resource, or an empty value if unknown.
    Throws:
      `DataStoreException` - if an error occurred while preparing the set of files.
    Since:
      1.5

  - ### components

    public List<GridCoverageResource> components() throws DataStoreException
    Returns descriptions of all images in this GeoTIFF file. Images are not immediately loaded.

    If an error occurs during iteration in the returned collection, an unchecked `BackingStoreException` will be thrown with a `DataStoreException` as its cause.

    Specified by:
      `components` in interface `Aggregate`
    Returns:
      descriptions of all images in this GeoTIFF file.
    Throws:
      `DataStoreException` - if an error occurred while fetching the image descriptions.
    Since:
      1.0

  - ### findResource

    public GridCoverageResource findResource(String sequence) throws DataStoreException
    Returns the image at the given index. Images numbering starts at 1. If the given string has a scope (e.g. "filename:1"), then the scope
    Overrides:
      `findResource` in class `DataStore`
    Parameters:
      `sequence` - string representation of the image index, starting at 1.
    Returns:
      image at the given index.
    Throws:
      `DataStoreException` - if the requested image cannot be obtained.
    See Also:
      - `Resource​.getIdentifier()`
      - `FeatureNaming`

  - ### append

    public GridCoverageResource append(RenderedImage image, GridGeometry grid, Metadata metadata) throws DataStoreException
    Encodes the given image in the GeoTIFF file. The image is appended after any existing images in the GeoTIFF file. This method does not handle pyramids such as Cloud Optimized GeoTIFF (COG).
    Parameters:
      `image` - the image to encode.
      `grid` - mapping from pixel coordinates to "real world" coordinates, or `null` if none.
      `metadata` - title, author and other information, or `null` if none.
    Returns:
      the effectively added resource. Using this resource may cause data to be reloaded.
    Throws:
      `ReadOnlyStorageException` - if this data store is read-only.
      `IncompatibleResourceException` - if the given `image` has a property which is not supported by this writer.
      `DataStoreException` - if an error occurred while writing to the output stream.
    Since:
      1.5

  - ### append

    public GridCoverageResource append(GridCoverage coverage, Metadata metadata) throws DataStoreException
    Adds a new grid coverage in the GeoTIFF file. The coverage is appended after any existing images in the GeoTIFF file. This method does not handle pyramids such as Cloud Optimized GeoTIFF (COG).
    Parameters:
      `coverage` - the grid coverage to encode.
      `metadata` - title, author and other information, or `null` if none.
    Returns:
      the effectively added resource. Using this resource may cause data to be reloaded.
    Throws:
      `SubspaceNotSpecifiedException` - if the given grid coverage is not a two-dimensional slice.
      `ReadOnlyStorageException` - if this data store is read-only.
      `DataStoreException` - if the given `image` has a property which is not supported by this writer, or if an error occurred while writing to the output stream.
    Since:
      1.5

  - ### 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 data store. The current implementation of this data store can emit only `WarningEvent`s; any listener specified for another kind of events will be ignored.
    Specified by:
      `addListener` in interface `Resource`
    Overrides:
      `addListener` in class `DataStore`
    Type Parameters:
      `T` - compile-time value of the `eventType` argument.
    Parameters:
      `eventType` - type of `StoreEvent` to listen (cannot be `null`).
      `listener` - listener to notify about events.

  - ### close

    public void close() throws DataStoreException
    Closes this GeoTIFF store and releases any underlying resources. This method can be invoked asynchronously for interrupting a long reading process.
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in class `DataStore`
    Throws:
      `DataStoreException` - if an error occurred while closing the GeoTIFF file.
    See Also:
      - `StoreListeners​.close()`