Class GrassBinaryRasterWriteHandler

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class GrassBinaryRasterWriteHandler
    extends Object
    implements Closeable
    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 Detail

      • GrassBinaryRasterWriteHandler

        public GrassBinaryRasterWriteHandler​(File destMapset,
                                             String newMapName,
                                             ProgressListener monitor)
        A constructor to build a GrassBinaryRasterWriteHandler usable for writing grass rasters.
        Parameters:
        destMapset - the mapset file into which the map has to be written.
        newMapName - the name for the written map.
    • Method Detail

      • writeRaster

        public void writeRaster​(RenderedImage renderedImage,
                                int columns,
                                int rows,
                                double west,
                                double south,
                                double xRes,
                                double yRes,
                                double noDataValue)
                         throws IOException
        Writes the raster, given an raster iterator and region metadata.
        Parameters:
        renderedImage - the RenderedImage to write.
        columns - the columns of the raster to write.
        rows - the rows of the raster to write.
        west - the western bound of the raster to write.
        south - the southern bound of the raster to write.
        xRes - the east-west resolution of the raster to write.
        yRes - the north-south resolution of the raster to write.
        noDataValue - the value representing noData.
        Throws:
        IOException
      • getWriteRegion

        public JGrassRegion getWriteRegion()
                                    throws IOException
        Calculates the region that is going to be written.
        Returns:
        the region that will be written by this Writer.
        Throws:
        IOException
      • setWriteRegion

        public void setWriteRegion​(JGrassRegion writeRegion)
      • close

        public void close()
                   throws IOException
        Closes the I/O streams.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Throws:
        IOException
      • 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.
      • 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.