Class RasterWriter
java.lang.Object
org.apache.sis.internal.sql.postgis.RasterWriter
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-nullInfoStatements 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidreset()Restores this writer to its initial state.voidSets the conversion from grid coordinates to CRS coordinates together with target CRS.voidsetNodataValues(List<? extends SampleDimension> bands) Infers the "no data" values from the given sample dimensions.voidwrite(Raster raster, ChannelDataOutput output) Encodes the given raster to the specified output.voidwrite(RenderedImage image, ChannelDataOutput output) Encodes the given image to the specified output.voidwrite(GridCoverage coverage, ChannelDataOutput output) Encodes the given grid coverage to the specified output.
-
Constructor Details
-
RasterWriter
Creates a new writer. If thespatialRefSysargument 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, ornullfor 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
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
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
Encodes the given grid coverage to the specified output. This method sets the "grid to CRS" conversion and the no data values, then delegates towrite(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
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
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.
-