org.geotools.gce.grassraster.core
Class GrassBinaryRasterReadHandler

Object
  extended by GrassBinaryRasterReadHandler

public class GrassBinaryRasterReadHandler
extends Object

Grass binary data input/ouput handler.

Reading and writing is supported.

Since:
3.0
Author:
Andrea Antonello (www.hydrologis.com)
See Also:
GrassBinaryImageReader, GrassBinaryImageReadParam, GrassBinaryImageMetadata

Constructor Summary
GrassBinaryRasterReadHandler(File cellFile)
          the constructor to build a GrassBinaryRasterReadHandler usable for reading grass rasters.
 
Method Summary
 void abort()
          sets the abortrequired flag to true.
 void close()
          closes the I/O streams.
 List<String> getCategories()
          Getter for the categories.
 List<String> getColorRules(double[] range)
          Getter for the colorrules.
 CoordinateReferenceSystem getCrs()
          Reads the crs definition for the map.
 JGrassRegion getNativeRasterRegion()
          Getter for nativeRasterRegion.
 double getNoData()
          Getter for the noData value.
 double[] getRange()
           
 int getRasterMapHeight()
           
 int getRasterMapWidth()
           
 SampleModel getSampleModel()
          returns the SampleModel compatible with the WritableRaster.
 boolean isAborting()
          Getter for the abortrequired flag.
 void parseHeaderAndAccessoryFiles()
          Determines the metadata of the raster map.
 WritableRaster readRaster(ImageReadParam param)
          reads a grass raster, given the read parameters.
 WritableRaster readRaster(ImageReadParam param, boolean useSubSamplingAsRequestedRowcols, boolean castDoubleToFloating, ProgressListener monitor)
          Reads a grass raster, adding the possibility to override subsampling.
 void setNoData(double noData)
          Setter for the noData value.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GrassBinaryRasterReadHandler

public GrassBinaryRasterReadHandler(File cellFile)
the constructor to build a GrassBinaryRasterReadHandler usable for reading grass rasters.

Parameters:
cellFile - the file of the raw raster data.
Method Detail

readRaster

public WritableRaster readRaster(ImageReadParam param,
                                 boolean useSubSamplingAsRequestedRowcols,
                                 boolean castDoubleToFloating,
                                 ProgressListener monitor)
                          throws IOException,
                                 DataFormatException
Reads a grass raster, adding the possibility to override subsampling.

Parameters:
param - the read parameters.
useSubSamplingAsRequestedRowcols - a flag that gives the possibility to bypass the imageio subsampling mechanism. With GRASS maps this is often more performing 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 -
Returns:
the read raster
Throws:
IOException
DataFormatException

readRaster

public WritableRaster readRaster(ImageReadParam param)
                          throws IOException,
                                 DataFormatException
reads a grass raster, given the read parameters.

The data are read into a single banded, floating point WritableRaster. A RectIter can be used to access the data afterwards.

Parameters:
param - the read parameters.
Returns:
the read raster
Throws:
IOException
DataFormatException

parseHeaderAndAccessoryFiles

public void parseHeaderAndAccessoryFiles()
                                  throws IOException
Determines the metadata of the raster map.

Reads the map type given a file and its mapset, the information from the header file in the cellhd directory and determines the geographic limits, format of the data, etc from the file.

NOTE: for further informations about cell header files, read the package description.

INFO: this is a reader method.

Throws:
IOException

getNativeRasterRegion

public JGrassRegion getNativeRasterRegion()
Getter for nativeRasterRegion.

INFO: this is a reader method.

Returns:
the nativeRasterRegion.

getColorRules

public List<String> getColorRules(double[] range)
                           throws IOException
Getter for the colorrules.

INFO: this is a reader method.

Returns:
the list of single colorrules.
Throws:
IOException

getCategories

public List<String> getCategories()
                           throws IOException
Getter for the categories.

INFO: this is a reader method.

Returns:
the attribute table as read in the categories file
Throws:
IOException

close

public void close()
           throws IOException
closes the I/O streams.

Throws:
IOException

abort

public void abort()
sets the abortrequired flag to true.

As soon as possible that should abort the reader.


isAborting

public boolean isAborting()
Getter for the abortrequired flag.

Returns:
the abortRequired flag.

setNoData

public void setNoData(double noData)
Setter for the noData value.

Parameters:
noData - the nodata value to set.

getNoData

public double getNoData()
Getter for the noData value.

Returns:
the nodata value.

getCrs

public CoordinateReferenceSystem getCrs()
                                 throws IOException
Reads the crs definition for the map.

The definition for grass maps is held in the location. Grass projection definitions are usually in a non parsable internal format. In JGrass we ask the user to choose the CRS. If the user doesn't do so, the CRS will result to be undefined.

Returns:
the CoordinateReferenceSystem for the map. Null if it is not defined.
Throws:
IOException - if there were problems in parsing the CRS file.

getSampleModel

public SampleModel getSampleModel()
returns the SampleModel compatible with the WritableRaster.

Returns:
the sample model compatible with the created raster

getRasterMapWidth

public int getRasterMapWidth()

getRasterMapHeight

public int getRasterMapHeight()

getRange

public double[] getRange()


Copyright © 1996-2014 Geotools. All Rights Reserved.