Class RasterWriter
java.lang.Object
org.apache.sis.internal.sql.postgis.RasterFormat
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ByteOrder
The byte order to use for encoding the WKB.private AffineTransform
Conversion from pixel coordinates to CRS coordinates.private Number[]
The "no data" value for each band, ornull
if none.private int
The spatial reference identifier, or 0 if undefined.Fields inherited from class org.apache.sis.internal.sql.postgis.RasterFormat
ANCHOR, spatialRefSys
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
ensureUnsignedShort
(String name, int value) Ensures that the given value is in the range of unsigned short.void
reset()
Restores this writer to its initial state.void
Sets the conversion from grid coordinates to CRS coordinates together with target CRS.void
setNodataValues
(List<? extends SampleDimension> bands) Infers the "no data" values from the given sample dimensions.void
write
(Raster raster, ChannelDataOutput output) Encodes the given raster to the specified output.void
write
(RenderedImage image, ChannelDataOutput output) Encodes the given image to the specified output.void
write
(GridCoverage coverage, ChannelDataOutput output) Encodes the given grid coverage to the specified output.
-
Field Details
-
byteOrder
The byte order to use for encoding the WKB. -
gridToCRS
Conversion from pixel coordinates to CRS coordinates. This is defined by 6 affine transform coefficients similar to the World File format. -
srid
private int sridThe spatial reference identifier, or 0 if undefined. Note that this is a primary key in the"spatial_ref_sys"
table, not necessarily an EPSG code. -
noDataValues
The "no data" value for each band, ornull
if none. If the array length is greater than the number of bands, the last elements are ignored. If the array length is smaller than the number of bands, all remaining bands are assumed to have no "no data" value.
-
-
Constructor Details
-
RasterWriter
Creates a new writer. If thespatialRefSys
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, ornull
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
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.
-
ensureUnsignedShort
Ensures that the given value is in the range of unsigned short.- Parameters:
name
- name of the value, for error message.value
- the value to check.- Returns:
value
.
-