| org.geotools.image.io.text.TextImageReader org.geotools.image.io.text.TextRecordImageReader
TextRecordImageReader | public class TextRecordImageReader extends TextImageReader (Code) | | Image decoder for text files storing pixel values as records.
Such text files use one line (record) by pixel. Each line contains
at least 3 columns (in arbitrary order):
- Pixel's x coordinate.
- Pixel's y coordinate.
- An arbitrary number of pixel values.
For example, some Sea Level Anomaly (SLA) files contains rows of longitude
(degrees), latitude (degrees), SLA (cm), East/West current (cm/s) and
North/South current (cm/s), as below:
45.1250 -29.8750 -7.28 10.3483 -0.3164
45.1250 -29.6250 -4.97 11.8847 3.6192
45.1250 -29.3750 -2.91 3.7900 3.0858
45.1250 -29.1250 -3.48 -5.1833 -5.0759
45.1250 -28.8750 -4.36 -1.8129 -16.3689
45.1250 -28.6250 -3.91 7.5577 -24.6801
(...etc...)
From this decoder point of view, the two first columns (longitude and latitude)
are pixel's logical coordinate (x,y), while the three last
columns are three image's bands. The whole file contains only one image (unless
TextRecordImageReader.getNumImages has been overridden). All (x,y)
coordinates belong to pixel's center. This decoder will automatically translate
(x,y) coordinates from logical space to pixel space. The
TextRecordImageReader.getTransform method provides a convenient
AffineTransform for
performing coordinate transformations between pixel and logical spaces.
By default,
TextRecordImageReader assumes that x and
y coordinates appear in column #0 and 1 respectively. It also assumes
that numeric values are encoded using current defaults
java.nio.charset.Charset and
java.util.Locale , and that there is no pad value. The easiest way to change
the default setting is to create a
Spi subclass. There is no need to subclass
TextRecordImageReader , unless you want more control on the decoding process.
since: 2.1 version: $Id: TextRecordImageReader.java 27629 2007-10-26 09:59:20Z desruisseaux $ author: Martin Desruisseaux |
Method Summary | |
protected int | getColumnX(int imageIndex) Returns the column number for x values. | protected int | getColumnY(int imageIndex) Returns the column number for x values. | public int | getHeight(int imageIndex) Returns the height in pixels of the given image within the input source.
Parameters: imageIndex - the index of the image to be queried. | public IIOMetadata | getImageMetadata(int imageIndex) Returns metadata associated with the given image.
Calling this method may force loading of full image.
Parameters: imageIndex - The image index. | public int | getNumBands(int imageIndex) Returns the number of bands available for the specified image. | public int | getWidth(int imageIndex) Returns the width in pixels of the given image within the input source.
Parameters: imageIndex - the index of the image to be queried. | public BufferedImage | read(int imageIndex, ImageReadParam param) Reads the image indexed by
imageIndex and returns it as a complete buffered image.
Parameters: imageIndex - the index of the image to be retrieved. Parameters: param - Parameters used to control the reading process, or null . | public void | reset() Restores the
TextRecordImageReader to its initial state. | protected void | round(double[] values) Rounds the specified values. | public void | setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata) Set the input source. |
TextRecordImageReader | public TextRecordImageReader(ImageReaderSpi provider)(Code) | | Constructs a new image reader.
Parameters: provider - the provider that is invoking this constructor, or null if none. |
getColumnX | protected int getColumnX(int imageIndex) throws IOException(Code) | | Returns the column number for x values. The default implementation returns
TextRecordImageReader.Spi.xColumn . Subclasses should override this method if
this information should be obtained in an other way.
Parameters: imageIndex - The index of the image to be queried. throws: IOException - If an error occurs reading the from the input source. |
getColumnY | protected int getColumnY(int imageIndex) throws IOException(Code) | | Returns the column number for x values. The default implementation returns
TextRecordImageReader.Spi.yColumn . Subclasses should override this method if
this information should be obtained in an other way.
Parameters: imageIndex - The index of the image to be queried. throws: IOException - If an error occurs reading the from the input source. |
getHeight | public int getHeight(int imageIndex) throws IOException(Code) | | Returns the height in pixels of the given image within the input source.
Parameters: imageIndex - the index of the image to be queried. Image height. throws: IOException - If an error occurs reading the height information from the input source. |
getImageMetadata | public IIOMetadata getImageMetadata(int imageIndex) throws IOException(Code) | | Returns metadata associated with the given image.
Calling this method may force loading of full image.
Parameters: imageIndex - The image index. The metadata, or null if none. throws: IOException - If an error occurs reading the data information from the input source. |
getNumBands | public int getNumBands(int imageIndex) throws IOException(Code) | | Returns the number of bands available for the specified image.
Parameters: imageIndex - The image index. throws: IOException - if an error occurs reading the information from the input source. |
getWidth | public int getWidth(int imageIndex) throws IOException(Code) | | Returns the width in pixels of the given image within the input source.
Parameters: imageIndex - the index of the image to be queried. Image width. throws: IOException - If an error occurs reading the width information from the input source. |
read | public BufferedImage read(int imageIndex, ImageReadParam param) throws IOException(Code) | | Reads the image indexed by
imageIndex and returns it as a complete buffered image.
Parameters: imageIndex - the index of the image to be retrieved. Parameters: param - Parameters used to control the reading process, or null . the desired portion of the image. throws: IOException - if an error occurs during reading. |
reset | public void reset()(Code) | | Restores the
TextRecordImageReader to its initial state.
|
round | protected void round(double[] values)(Code) | | Rounds the specified values. This method is invoked automatically by the
TextRecordImageReader.read read method while reading an image. It provides a place where to fix rounding errors in latitude
and longitude coordinates. For example if longitudes have a step 1/6° but are written with
only 3 decimal digits, then we get
values like
10.000 ,
10.167 ,
10.333 , etc., which can leads to an error of 0.001°
in longitude. This error may cause
TextRecordImageReader to fails validation tests
and throws an
javax.imageio.IIOException : "Points dont seem to be distributed
on a regular grid". A work around is to multiply the x and y
coordinates by 6, round to the nearest integer and divide them by 6.
The default implementation do nothing.
Parameters: values - The values to round in place. |
|
|