org.geotoolkit.image.io.plugin
Class AsciiGridWriter

Object
  extended by ImageWriter
      extended by SpatialImageWriter
          extended by StreamImageWriter
              extended by TextImageWriter
                  extended by AsciiGridWriter
All Implemented Interfaces:
ImageTranscoder, WarningProducer, Disposable, Localized

public class AsciiGridWriter
extends TextImageWriter

Writer for the ASCII Grid format. As the "ASCII" name implies, the data file are written in US-ASCII character encoding no matter what the TextImageWriter.Spi.charset value is. In addition, the US locale is enforced no matter what the ImageWriter.locale value is. The default implementation writes only the header attribute defined below:

Keyword Value type Obligation
 NCOLS   Integer   Mandatory 
 NROWS   Integer   Mandatory 
 XLLCORNER or XLLCENTER   Floating point   Mandatory 
 YLLCORNER or YLLCENTER   Floating point   Mandatory 
 CELLSIZE   Floating point   Mandatory, unless DX and DY are allowed. 
 DX and DY   Floating point   Forbidden if strict cell size has been set to false 
 NODATA_VALUE   Floating point   Optional, default to -9999 

The DX and DY attributes are non-standard, but recognized by the GDAL library and Golden Surfer as documented here. The default AsciiGridWriter behavior is to use those parameters if the image has rectangular pixels, unless setStrictCellSize(true) is invoked.

Since:
3.08 (derived from 3.07)
Version:
3.08
Author:
Martin Desruisseaux (Geomatys)
See Also:
ASCII Grid Format Description, ESRI Grid on Wikipedia, AsciiGridReader
Module:
coverage/geotk-coverageio (download)    View source code for this class

Nested Class Summary
static class AsciiGridWriter.Spi
          Service provider interface (SPI) for AsciiGridWriters.
 
Field Summary
 
Fields inherited from class StreamImageWriter
closeOnReset
 
Fields inherited from class ImageWriter
availableLocales, locale, originatingProvider, output, progressListeners, warningListeners, warningLocales
 
Fields inherited from interface WarningProducer
LOGGER
 
Constructor Summary
protected AsciiGridWriter(AsciiGridWriter.Spi provider)
          Constructs a new image writer.
 
Method Summary
 boolean getStrictCellSize()
          Returns the value set by the last call to setStrictCellSize(boolean).
 void setStrictCellSize(boolean strict)
          Sets whatever the policy about the CELLSIZE attribute is to be strict.
 void write(IIOMetadata streamMetadata, IIOImage image, ImageWriteParam parameters)
          Appends a complete image stream containing a single image.
 
Methods inherited from class TextImageWriter
close, createNumberFormat, getCharset, getDataLocale, getExpectedFractionPosition, getLineSeparator, getWriter
 
Methods inherited from class StreamImageWriter
finalize, getOutputStream, setOutput
 
Methods inherited from class SpatialImageWriter
canWriteRasters, computeSize, convertImageMetadata, convertStreamMetadata, createRectIter, dispose, getDefaultImageMetadata, getDefaultStreamMetadata, getDefaultWriteParam, getSampleModel, processImageComplete, processImageStarted, processThumbnailComplete, processThumbnailStarted, processWarningOccurred, processWarningOccurred, warningOccurred
 
Methods inherited from class ImageWriter
abort, abortRequested, addIIOWriteProgressListener, addIIOWriteWarningListener, canInsertEmpty, canInsertImage, canRemoveImage, canReplaceImageMetadata, canReplacePixels, canReplaceStreamMetadata, canWriteEmpty, canWriteSequence, clearAbortRequest, endInsertEmpty, endReplacePixels, endWriteEmpty, endWriteSequence, getAvailableLocales, getLocale, getNumThumbnailsSupported, getOriginatingProvider, getOutput, getPreferredThumbnailSizes, prepareInsertEmpty, prepareReplacePixels, prepareWriteEmpty, prepareWriteSequence, processImageProgress, processImageStarted, processThumbnailProgress, processThumbnailStarted, processWarningOccurred, processWarningOccurred, processWriteAborted, removeAllIIOWriteProgressListeners, removeAllIIOWriteWarningListeners, removeIIOWriteProgressListener, removeIIOWriteWarningListener, removeImage, replaceImageMetadata, replacePixels, replacePixels, replaceStreamMetadata, reset, setLocale, write, write, writeInsert, writeToSequence
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Localized
getLocale
 

Constructor Detail

AsciiGridWriter

protected AsciiGridWriter(AsciiGridWriter.Spi provider)
Constructs a new image writer.

Parameters:
provider - The ImageWriterSpi that is constructing this object, or null.
Method Detail

setStrictCellSize

public void setStrictCellSize(boolean strict)
Sets whatever the policy about the CELLSIZE attribute is to be strict. If true, attempts to write an image with non-square pixels will throw an exception. If false (the default) and an image has rectangular pixels, then the DX and DY attributes will be used instead of CELLSIZE and a warning will be emitted.

The DX and DY attributes are non-standard, but recognized by the GDAL library and Golden Surfer. The default value is false, thus allowing creation of non-standard ASCII grid file.

Parameters:
strict - true if attempts to write an image with non-square pixels should throw an exception, or false for emitting a warning instead.

getStrictCellSize

public boolean getStrictCellSize()
Returns the value set by the last call to setStrictCellSize(boolean). The default value is false.

Returns:
true if attempts to write an image with non-square pixels should throw an exception, or false for emitting a warning instead.

write

public void write(IIOMetadata streamMetadata,
                  IIOImage image,
                  ImageWriteParam parameters)
           throws IOException
Appends a complete image stream containing a single image.

Specified by:
write in class ImageWriter
Parameters:
streamMetadata - The stream metadata (ignored in default implementation).
image - The image or raster to be written.
parameters - The write parameters, or null if the whole image will be written.
Throws:
IOException - If an error occurred while writing to the stream.


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