org.geotoolkit.coverage.io
Class GridCoverageWriter

Object
  extended by GridCoverageStore
      extended by GridCoverageWriter
All Implemented Interfaces:
Localized, LogProducer
Direct Known Subclasses:
ImageCoverageWriter

public abstract class GridCoverageWriter
extends GridCoverageStore

Base class of GridCoverage writers. Writing is a two steps process:

Example:

GridCoverage coverage = ...
GridCoverageWriter writer = ...
writer.setOutput(new File("MyCoverage.asc"));
writer.write(coverage, null);
Note: This class is conceptually equivalent to the ImageWriter class provided in the standard Java library. Implementations of this class are often wrappers around a Java ImageWriter, converting geodetic coordinates to pixel coordinates before to delegate the writing of pixel values.

Since:
3.14
Version:
3.20
Author:
Martin Desruisseaux (Geomatys), Johann Sorel (Geomatys)
See Also:
ImageWriter
Module:
coverage/geotk-coverageio (download)    View source code for this class

Field Summary
 
Fields inherited from class GridCoverageStore
abortRequested
 
Constructor Summary
protected GridCoverageWriter()
          Creates a new instance.
 
Method Summary
 void dispose()
          Allows any resources held by this writer to be released.
 Object getOutput()
          Returns the output which was set by the last call to setOutput(Object), or null if none.
 void reset()
          Restores the GridCoverageWriter to its initial state.
 void setOutput(Object output)
          Sets the output destination to the given object.
abstract  void write(GridCoverage coverage, GridCoverageWriteParam param)
          Writes a single grid coverage.
 void write(Iterable<? extends GridCoverage> coverages, GridCoverageWriteParam param)
          Writes one or many grid coverages.
 
Methods inherited from class GridCoverageStore
abort, getLocale, getLogLevel, setLocale, setLogLevel
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridCoverageWriter

protected GridCoverageWriter()
Creates a new instance.

Method Detail

setOutput

public void setOutput(Object output)
               throws CoverageStoreException
Sets the output destination to the given object. The output is typically a File or a String object. But some other types (e.g. ImageOutputStream) may be accepted as well depending on the implementation.

How streams are closed

Parameters:
output - The output (typically File or String) to be written.
Throws:
IllegalArgumentException - If the output is not a valid instance for this writer.
CoverageStoreException - If the operation failed.
See Also:
ImageWriter.setOutput(Object)

getOutput

public Object getOutput()
                 throws CoverageStoreException
Returns the output which was set by the last call to setOutput(Object), or null if none.

Returns:
The current output, or null if none.
Throws:
CoverageStoreException - If the operation failed.
See Also:
ImageWriter.getOutput()

write

public abstract void write(GridCoverage coverage,
                           GridCoverageWriteParam param)
                    throws CoverageStoreException,
                           CancellationException
Writes a single grid coverage.

Parameters:
coverage - The coverage to write.
param - Optional parameters used to control the writing process, or null.
Throws:
IllegalStateException - If the output destination has not been set.
CoverageStoreException - If an error occurs while writing the information to the output destination.
CancellationException - If GridCoverageStore.abort() has been invoked in an other thread during the execution of this method.

write

public void write(Iterable<? extends GridCoverage> coverages,
                  GridCoverageWriteParam param)
           throws CoverageStoreException,
                  CancellationException
Writes one or many grid coverages. The default implementation delegates to write(GridCoverage, GridCoverageWriteParam) if the given iterable contains exactly one coverage, or throws an CoverageStoreException otherwise.

Parameters:
coverages - The coverages to write.
param - Optional parameters used to control the writing process, or null.
Throws:
IllegalStateException - If the output destination has not been set.
CoverageStoreException - If the iterable contains an unsupported number of coverages, or if an error occurs while writing the information to the output destination.
CancellationException - If GridCoverageStore.abort() has been invoked in an other thread during the execution of this method.
Since:
3.20

reset

public void reset()
           throws CoverageStoreException
Restores the GridCoverageWriter to its initial state.

Overrides:
reset in class GridCoverageStore
Throws:
CoverageStoreException - If an error occurs while restoring to the initial state.
See Also:
ImageWriter.reset()

dispose

public void dispose()
             throws CoverageStoreException
Allows any resources held by this writer to be released. The result of calling any other method subsequent to a call to this method is undefined.

Overrides:
dispose in class GridCoverageStore
Throws:
CoverageStoreException - If an error occurs while disposing resources.
See Also:
ImageWriter.dispose()


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.