Class RasterWriter

java.lang.Object
org.apache.sis.internal.sql.postgis.RasterWriter

public final class RasterWriter extends Object
A writer of rasters encoded in Well Known Binary (WKB) format. This format is specific to PostGIS 2 (this is not yet an OGC standard at the time of writing this class), but it can nevertheless be used elsewhere.

Multi-threading

This class is not safe for multi-threading. Furthermore, if a non-null InfoStatements has been specified to the constructor, then this object is valid only as long as the caller holds a connection to the database.
Since:
1.2
Version:
1.2
Author:
Johann Sorel (Geomatys), Martin Desruisseaux (Geomatys)
  • Constructor Details

    • RasterWriter

      public RasterWriter(InfoStatements spatialRefSys)
      Creates a new writer. If the spatialRefSys argument is non-null, then this object is valid only as long as the caller holds a connection to the database.
      Parameters:
      spatialRefSys - the object to use for mapping CRS to the "spatial_ref_sys" table, or null for using the EPSG codes.
  • Method Details

    • reset

      public void reset()
      Restores this writer to its initial state. It resets the byte order, grid to CRS transform and SRID to their default values.
    • setGridToCRS

      public void setGridToCRS(GridGeometry gg) throws Exception
      Sets the conversion from grid coordinates to CRS coordinates together with target CRS. The conversion must be affine. Other grid properties (e.g. envelope and extent) are ignored.
      Parameters:
      gg - the grid to CRS conversion together with target CRS.
      Throws:
      IllegalArgumentException - if the "grid to CRS" transform is not affine.
      Exception - if an error occurred during the search for SRID code. May be SQL error, WKT parsing error, factory error, etc.
    • setNodataValues

      public void setNodataValues(List<? extends SampleDimension> bands)
      Infers the "no data" values from the given sample dimensions. This method uses the background value if available.
      Parameters:
      bands - the sample dimensions from which to infer the "no data" values.
    • write

      public void write(GridCoverage coverage, ChannelDataOutput output) throws Exception
      Encodes the given grid coverage to the specified output. This method sets the "grid to CRS" conversion and the no data values, then delegates to write(RenderedImage, ChannelDataOutput).
      Parameters:
      coverage - the grid coverage to encode.
      output - where to write the bytes.
      Throws:
      RasterFormatException - if the raster to write is not supported.
      IOException - in an error occurred while writing to the given output.
      Exception - if an error occurred during the search for SRID code. May be SQL error, WKT parsing error, factory error, etc.
    • write

      public void write(RenderedImage image, ChannelDataOutput output) throws IOException
      Encodes the given image to the specified output.
      Parameters:
      image - the image to encode.
      output - where to write the bytes.
      Throws:
      RasterFormatException - if the raster to write is not supported.
      IOException - in an error occurred while writing to the given output.
    • write

      public void write(Raster raster, ChannelDataOutput output) throws IOException
      Encodes the given raster to the specified output.
      Parameters:
      raster - the raster to encode.
      output - where to write the bytes.
      Throws:
      RasterFormatException - if the raster to write is not supported.
      IOException - in an error occurred while writing to the given output.