|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.imageio.ImageReader
org.geotools.image.io.GeographicImageReader
org.geotools.image.io.StreamImageReader
org.geotools.image.io.text.TextImageReader
org.geotools.image.io.text.TextRecordImageReader
public class TextRecordImageReader
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):
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 (unless45.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...)
GeographicImageReader.getNumImages(boolean)
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.
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 Charset
and Locale
, and that there is no pad value. The easiest way to change
the default setting is to create a TextRecordImageReader.Spi
subclass. There is no need to subclass
TextRecordImageReader
, unless you want more control on the decoding process.
Nested Class Summary | |
---|---|
static class |
TextRecordImageReader.Spi
Service provider interface (SPI) for TextRecordImageReader s. |
Field Summary |
---|
Fields inherited from class org.geotools.image.io.StreamImageReader |
---|
closeOnReset |
Fields inherited from class javax.imageio.ImageReader |
---|
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales |
Constructor Summary | |
---|---|
TextRecordImageReader(javax.imageio.spi.ImageReaderSpi provider)
Constructs a new image reader. |
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. |
int |
getHeight(int imageIndex)
Returns the height in pixels of the given image within the input source. |
javax.imageio.metadata.IIOMetadata |
getImageMetadata(int imageIndex)
Returns metadata associated with the given image. |
int |
getNumBands(int imageIndex)
Returns the number of bands available for the specified image. |
int |
getWidth(int imageIndex)
Returns the width in pixels of the given image within the input source. |
java.awt.image.BufferedImage |
read(int imageIndex,
javax.imageio.ImageReadParam param)
Reads the image indexed by imageIndex and returns it as a complete buffered image. |
void |
reset()
Restores the TextRecordImageReader to its initial state. |
protected void |
round(double[] values)
Rounds the specified values. |
void |
setInput(java.lang.Object input,
boolean seekForwardOnly,
boolean ignoreMetadata)
Set the input source. |
Methods inherited from class org.geotools.image.io.text.TextImageReader |
---|
close, getCharset, getLineFormat, getPadValue, getPositionString, getReader, isComment |
Methods inherited from class org.geotools.image.io.StreamImageReader |
---|
dispose, finalize, getInputStream, getStreamLength |
Methods inherited from class org.geotools.image.io.GeographicImageReader |
---|
checkBandIndex, checkImageIndex, collapseNoDataValues, flipVertically, getDefaultReadParam, getDestination, getDimension, getGeographicMetadata, getImageTypes, getNumImages, getRawDataType, getRawImageType, getRawImageType, getStreamMetadata, read, warningOccurred |
Methods inherited from class javax.imageio.ImageReader |
---|
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDestination, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TextRecordImageReader(javax.imageio.spi.ImageReaderSpi provider)
provider
- the provider that is invoking this constructor, or null
if none.Method Detail |
---|
protected int getColumnX(int imageIndex) throws java.io.IOException
TextRecordImageReader.Spi.xColumn
. Subclasses should override this method if
this information should be obtained in an other way.
imageIndex
- The index of the image to be queried.
java.io.IOException
- If an error occurs reading the from the input source.protected int getColumnY(int imageIndex) throws java.io.IOException
TextRecordImageReader.Spi.yColumn
. Subclasses should override this method if
this information should be obtained in an other way.
imageIndex
- The index of the image to be queried.
java.io.IOException
- If an error occurs reading the from the input source.public void setInput(java.lang.Object input, boolean seekForwardOnly, boolean ignoreMetadata)
File
, URL
, BufferedReader
.
Reader
, InputStream
or
ImageInputStream
.
setInput
in class StreamImageReader
input
- The input object to use for future decoding.seekForwardOnly
- If true
, images and metadata may only be read
in ascending order from this input source.ignoreMetadata
- If true
, metadata may be ignored during reads.ImageReader.getInput()
,
StreamImageReader.getInputStream()
public int getNumBands(int imageIndex) throws java.io.IOException
getNumBands
in class GeographicImageReader
imageIndex
- The image index.
java.io.IOException
- if an error occurs reading the information from the input source.public int getWidth(int imageIndex) throws java.io.IOException
getWidth
in class javax.imageio.ImageReader
imageIndex
- the index of the image to be queried.
java.io.IOException
- If an error occurs reading the width information from the input source.public int getHeight(int imageIndex) throws java.io.IOException
getHeight
in class javax.imageio.ImageReader
imageIndex
- the index of the image to be queried.
java.io.IOException
- If an error occurs reading the height information from the input source.public javax.imageio.metadata.IIOMetadata getImageMetadata(int imageIndex) throws java.io.IOException
getImageMetadata
in class GeographicImageReader
imageIndex
- The image index.
null
if none.
java.io.IOException
- If an error occurs reading the data information from the input source.protected void round(double[] values)
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 x 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 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.
values
- The values to round in place.public java.awt.image.BufferedImage read(int imageIndex, javax.imageio.ImageReadParam param) throws java.io.IOException
imageIndex
and returns it as a complete buffered image.
read
in class javax.imageio.ImageReader
imageIndex
- the index of the image to be retrieved.param
- Parameters used to control the reading process, or null
.
java.io.IOException
- if an error occurs during reading.public void reset()
TextRecordImageReader
to its initial state.
reset
in class StreamImageReader
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |