Package org.geotools.gce.grassraster
Class GrassCoverageReader
- Object
-
- AbstractGridCoverage2DReader
-
- GrassCoverageReader
-
- All Implemented Interfaces:
GridCoverageReader
,GridCoverage2DReader
public class GrassCoverageReader extends AbstractGridCoverage2DReader implements GridCoverage2DReader
Coverage Reader class for reading GRASS raster maps.The class reads a GRASS raster map from a GRASS workspace (see package documentation for further info). The reading is really done via Imageio extended classes.
- Since:
- 3.0
- Author:
- Andrea Antonello (www.hydrologis.com)
- See Also:
GrassBinaryImageReader
,GrassBinaryRasterReadHandler
-
-
Field Summary
-
Fields inherited from class AbstractGridCoverage2DReader
closeMe, coverageFactory, coverageName, crs, dtLayout, EPS, gzipped, highestRes, hints, inStream, inStreamSPI, numOverviews, offsets, originalEnvelope, originalGridRange, overViewResolutions, raster2Model, scales, source
-
Fields inherited from interface GridCoverage2DReader
ELEVATION_DOMAIN, ELEVATION_DOMAIN_MAXIMUM, ELEVATION_DOMAIN_MINIMUM, ELEVATION_DOMAIN_RESOLUTION, FILE_SOURCE_PROPERTY, HAS_ELEVATION_DOMAIN, HAS_TIME_DOMAIN, MULTICRS_EPSGCODES, MULTICRS_READER, PAM_DATASET, REPROJECTING_READER, SOURCE_URL_PROPERTY, TIME_DOMAIN, TIME_DOMAIN_MAXIMUM, TIME_DOMAIN_MINIMUM, TIME_DOMAIN_RESOLUTION
-
-
Constructor Summary
Constructors Constructor Description GrassCoverageReader(Object input)
Sets the input source to use to the givenfile object
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getCategoriesString()
Getter for the categories string.Format
getFormat()
Returns the format handled by thisGridCoverageReader
.String
getLegendString()
Getter for the legend string.double[]
getRange()
Gets the range.GridCoverage2D
read(GeneralParameterValue[] params)
Read the current grid coverage from the stream.GridCoverage2D
readRaster(JGrassRegion region)
Performs the reading of the coverage.void
setParams(PixelInCell cellAnchor, Interpolation interpolation, boolean useSubSamplingAsColsRows, boolean castDoubleToFloating, ProgressListener monitor)
Constructor for theGrassCoverageReader
.-
Methods inherited from class AbstractGridCoverage2DReader
addAllSiblings, addSiblings, checkName, collectScaleOffset, createImageCoverage, createImageCoverage, createImageCoverage, createImageCoverage, decimationOnReadingControl, dispose, finalize, getCoordinateReferenceSystem, getCoordinateReferenceSystem, getDatasetLayout, getDatasetLayout, getDynamicParameters, getDynamicParameters, getFiles, getGridCoverageCount, getGridCoverageNames, getGroundControlPoints, getGroundControlPoints, getHighestRes, getHighestRes, getImageLayout, getImageLayout, getInfo, getInfo, getMetadataNames, getMetadataNames, getMetadataValue, getMetadataValue, getMultiLevelROIProvider, getOriginalEnvelope, getOriginalEnvelope, getOriginalGridRange, getOriginalGridRange, getOriginalGridToWorld, getOriginalGridToWorld, getOverviewGridEnvelope, getOverviewGridEnvelope, getPamDataset, getPamDataset, getReadingResolutions, getReadingResolutions, getRescaledRasterToModel, getResolution, getResolutionLevels, getResolutionLevels, getSibling, getSource, getSourceAsFile, read, setlayout, setLayout, setReadParams, setReadParams
-
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface GridCoverage2DReader
getCoordinateReferenceSystem, getCoordinateReferenceSystem, getDatasetLayout, getDatasetLayout, getDynamicParameters, getDynamicParameters, getImageLayout, getImageLayout, getInfo, getInfo, getOriginalEnvelope, getOriginalEnvelope, getOriginalGridRange, getOriginalGridRange, getOriginalGridToWorld, getOriginalGridToWorld, getReadingResolutions, getReadingResolutions, getResolutionLevels, getResolutionLevels, read
-
Methods inherited from interface GridCoverageReader
dispose, getGridCoverageCount, getGridCoverageNames, getMetadataNames, getMetadataNames, getMetadataValue, getMetadataValue, getSource
-
-
-
-
Constructor Detail
-
GrassCoverageReader
public GrassCoverageReader(Object input)
Sets the input source to use to the givenfile object
.The input source must be set before any of the query or read methods are used.
- Parameters:
input
- theFile
to use for future decoding.
-
-
Method Detail
-
setParams
public void setParams(PixelInCell cellAnchor, Interpolation interpolation, boolean useSubSamplingAsColsRows, boolean castDoubleToFloating, ProgressListener monitor)
Constructor for theGrassCoverageReader
.- Parameters:
cellAnchor
- the object defining whether to assume the pixel value to be read in the grid's cell corner or center.interpolation
- the type of interpolation to be used in the case some scaling or padding has to be done.useSubSamplingAsColsRows
- a flag that gives the possibility to bypass the imageio subsampling mechanism. With GRASS maps this is often more performant in some boundary situations. In the case this flag is set to true, the subsampling values will be handled as the requested columns and rows.castDoubleToFloating
- a flag that gives the possibility to force the reading of a map as a floating point map. This is necessary right now because of a imageio bug: https://jai-imageio-core.dev.java.net /issues/show_bug.cgi?id=180.monitor
- amonitor
for logging purposes. This can be null, in which case a dummy one will be used.
-
readRaster
public GridCoverage2D readRaster(JGrassRegion region) throws IOException
Performs the reading of the coverage.This method read the grass file with a special image I/O class. If the image support the tiling read the data with a special operation which are written for this case. The step are:
- set the region in the world
- set the region to read in the JAI coordinate
- read the data directly with driver or, if isTiling is true, with the operation.
- verify if the image cover whole the region, if not fill the rows and columns with padding (with the Border operation)
- scale the image to return an image with the number of columns and rows equal to the requestedRegion
- set the coverage (with the transformation from the JAI coordinate to the real world coordinate.
- Parameters:
region
- theregion
to read. If null, the map is read in its original boundary and resolution.- Returns:
- the
read coverage
. - Throws:
IOException
-
getLegendString
public String getLegendString()
Getter for the legend string.- Returns:
- the legendstring.
-
getCategoriesString
public String getCategoriesString()
Getter for the categories string.- Returns:
- the categories string.
-
getRange
public double[] getRange()
Gets the range.Note that the range is available only if the raster was read once.
- Returns:
- the range non considering novalues.
-
read
public GridCoverage2D read(GeneralParameterValue[] params) throws IllegalArgumentException, IOException
Description copied from class:AbstractGridCoverage2DReader
Read the current grid coverage from the stream.Example:
- Specified by:
read
in interfaceGridCoverage2DReader
- Specified by:
read
in interfaceGridCoverageReader
- Specified by:
read
in classAbstractGridCoverage2DReader
- Parameters:
params
- Optional parameters matchingFormat.getReadParameters()
.- Returns:
- a grid coverage from the input source.
- Throws:
InvalidParameterNameException
- if a parameter inparameters
doesn't have a recognized name.InvalidParameterValueException
- if a parameter inparameters
doesn't have a valid value.ParameterNotFoundException
- if a parameter was required for the operation but was not provided in theparameters
list.IOException
- if a read operation failed for some other input/output reason, includingFileNotFoundException
if no file with the givenname
can be found, orIIOException
if an error was thrown by the underlying image library.IllegalArgumentException
-
getFormat
public Format getFormat()
Description copied from interface:GridCoverageReader
Returns the format handled by thisGridCoverageReader
.- Specified by:
getFormat
in interfaceGridCoverageReader
-
-