org.geotools.coverageio.jp2k
Class JP2KReader

Object
  extended by AbstractGridCoverage2DReader
      extended by JP2KReader
All Implemented Interfaces:
GridCoverageReader

public final class JP2KReader
extends AbstractGridCoverage2DReader
implements GridCoverageReader

This class can read a JP2K data source and create a GridCoverage2D from the data.

Author:
Daniele Romagnoli, GeoSolutions., Simone Giannecchini (simboss), GeoSolutions

Field Summary
 
Fields inherited from class AbstractGridCoverage2DReader
closeMe, coverageFactory, coverageName, crs, demColors, EPS, gzipped, highestRes, hints, inStream, numOverviews, originalEnvelope, originalGridRange, overViewResolutions, raster2Model, source
 
Constructor Summary
JP2KReader(Object input)
          Creates a new instance of a JP2KReader.
JP2KReader(Object source, Hints uHints)
          Constructor.
 
Method Summary
 void dispose()
          Releases resources held by this reader.
protected  GeneralEnvelope getCoverageEnvelope()
           
protected  GridEnvelope2D getCoverageGridRange()
           
 Format getFormat()
           
 int getGridCoverageCount()
          Number of coverages for this reader is 1
protected  void parsePRJFile()
          Gets the coordinate reference system that will be associated to the GridCoverage by looking for a related PRJ.
protected  void parseWorldFile()
          Checks whether a world file is associated with the data source.
 GridCoverage2D read(GeneralParameterValue[] params)
          Read the current grid coverage from the stream.
protected  void setCoverageEnvelope(GeneralEnvelope coverageEnvelope)
           
protected  void setCoverageGridRange(GridEnvelope2D coverageGridRange)
           
protected  void setCoverageProperties(ImageReader reader)
          Setting Envelope, GridRange and CRS from the given ImageReader
 
Methods inherited from class AbstractGridCoverage2DReader
createImageCoverage, createImageCoverage, decimationOnReadingControl, finalize, getCrs, getCurrentSubname, getInfo, getMetadataNames, getMetadataValue, getOriginalEnvelope, getOriginalGridRange, getOriginalGridToWorld, getResolution, getSource, hasMoreGridCoverages, listSubNames, setReadParams, skip
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface GridCoverageReader
getCurrentSubname, getMetadataNames, getMetadataValue, getSource, hasMoreGridCoverages, listSubNames, skip
 

Constructor Detail

JP2KReader

public JP2KReader(Object input)
           throws IOException
Creates a new instance of a JP2KReader. I assume nothing about file extension.

Parameters:
input - Source object for which we want to build an JP2KReader.
Throws:
DataSourceException
IOException

JP2KReader

public JP2KReader(Object source,
                  Hints uHints)
           throws IOException
Constructor.

Parameters:
source - The source object.
Throws:
IOException
UnsupportedEncodingException
Method Detail

setCoverageProperties

protected void setCoverageProperties(ImageReader reader)
                              throws IOException
Setting Envelope, GridRange and CRS from the given ImageReader

Parameters:
reader - the ImageReader from which to retrieve metadata (if available) for setting properties
Throws:
IOException

setCoverageEnvelope

protected void setCoverageEnvelope(GeneralEnvelope coverageEnvelope)
Parameters:
nativeEnvelope - the nativeEnvelope to set

getCoverageEnvelope

protected GeneralEnvelope getCoverageEnvelope()
Returns:
the nativeEnvelope

setCoverageGridRange

protected void setCoverageGridRange(GridEnvelope2D coverageGridRange)
Parameters:
nativeGridRange - the nativeGridRange to set

getCoverageGridRange

protected GridEnvelope2D getCoverageGridRange()
Returns:
the nativeGridRange

getGridCoverageCount

public int getGridCoverageCount()
Number of coverages for this reader is 1

Overrides:
getGridCoverageCount in class AbstractGridCoverage2DReader
Returns:
the number of coverages for this reader.
See Also:
org.opengis.coverage.grid.GridCoverageReader#getGridCoverageCount()

dispose

public void dispose()
Releases resources held by this reader.

Specified by:
dispose in interface GridCoverageReader
Overrides:
dispose in class AbstractGridCoverage2DReader

getFormat

public Format getFormat()
Specified by:
getFormat in interface GridCoverageReader
See Also:
GridCoverageReader.getFormat()

read

public GridCoverage2D read(GeneralParameterValue[] params)
                    throws IOException
Description copied from class: AbstractGridCoverage2DReader
Read the current grid coverage from the stream.

Example:


 
The method AbstractGridCoverage2DReader.hasMoreGridCoverages() should be invoked first in order to verify that a coverage is available.

Specified by:
read in interface GridCoverageReader
Specified by:
read in class AbstractGridCoverage2DReader
Parameters:
params - Optional parameters matching Format.getReadParameters().
Returns:
a grid coverage from the input source.
Throws:
IOException - if a read operation failed for some other input/output reason, including FileNotFoundException if no file with the given name can be found, or IIOException if an error was thrown by the underlying image library.
See Also:
GridCoverageReader.read(org.opengis.parameter.GeneralParameterValue[])

parsePRJFile

protected void parsePRJFile()
                     throws UnsupportedEncodingException
Gets the coordinate reference system that will be associated to the GridCoverage by looking for a related PRJ.

Throws:
UnsupportedEncodingException

parseWorldFile

protected void parseWorldFile()
                       throws IOException
Checks whether a world file is associated with the data source. If found, set a proper envelope.

Throws:
IllegalStateException
IOException


Copyright © 1996-2010 Geotools. All Rights Reserved.