Class RasterReader
java.lang.Object
org.apache.sis.internal.sql.postgis.RasterReader
A reader 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)
-
Field Summary
FieldsModifier and TypeFieldDescriptionorg.opengis.referencing.crs.CoordinateReferenceSystemThe default Coordinate Reference System (CRS) if the raster does not specify a CRS. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchannel(InputStream input) Wraps the given input stream into a channel that can be used byread(…)methods in this class.Returns the conversion from pixel coordinates to CRS coordinates found in the last raster read.intgetSRID()Returns the spatial reference identifier for the last raster read.readAsCoverage(ChannelDataInput input) Parses a raster from the given input stream and returns as a coverage.readAsImage(ChannelDataInput input) Parses a raster from the given input stream and returns as an image.readAsRaster(ChannelDataInput input) Parses a raster from the given input stream and returns a single tile.voidreset()Restores this reader to its initial state.
-
Field Details
-
defaultCRS
public org.opengis.referencing.crs.CoordinateReferenceSystem defaultCRSThe default Coordinate Reference System (CRS) if the raster does not specify a CRS. This isnullif there is no default.
-
-
Constructor Details
-
RasterReader
Creates a new reader. 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 building CRS from the"spatial_ref_sys"table, ornullfor using the SRID as an EPSG code.
-
-
Method Details
-
reset
public void reset()Restores this reader to its initial state. This method can be invoked for reading more than one raster with the same reader. -
getGridToCRS
Returns the conversion from pixel coordinates to CRS coordinates found in the last raster read. This property is non-null only if aread(…)method has been invoked andreset()has not been invoked.- Returns:
- conversion from pixel coordinates to CRS coordinates, or
nullif undefined.
-
getSRID
public int getSRID()Returns the spatial reference identifier for the last raster read. This property is non-zero only if aread(…)method has been invoked andreset()has not been invoked.- Returns:
- spatial reference identifier, or 0 if undefined.
-
readAsRaster
Parses a raster from the given input stream and returns a single tile.- Parameters:
input- source of bytes to read.- Returns:
- the raster, or
nullif the raster is empty. - Throws:
IOException- in an error occurred while reading from the given input.RasterFormatException- if the raster format is not supported by current implementation.ArithmeticException- if the raster is too large.
-
readAsImage
Parses a raster from the given input stream and returns as an image.- Parameters:
input- source of bytes to read.- Returns:
- the raster as an image, or
nullif the raster is empty. - Throws:
IOException- in an error occurred while reading from the given input.RasterFormatException- if the raster format is not supported by current implementation.ArithmeticException- if the raster is too large.
-
readAsCoverage
Parses a raster from the given input stream and returns as a coverage.- Parameters:
input- source of bytes to read.- Returns:
- the raster as a coverage, or
nullif the raster is empty. - Throws:
Exception- in an error occurred while reading from the given input or creating the coverage. Exception type may be I/O, SQL, factory, data store, arithmetic, raster format, etc., too numerous for enumerating them all.
-
channel
Wraps the given input stream into a channel that can be used byread(…)methods in this class. The returned channel should be used and discarded before to create a newChannelDataInput, because this method recycles the sameByteBuffer.- Parameters:
input- the input stream to wrap.- Returns:
- a channel together with a buffer.
- Throws:
IOException- if an error occurred while reading data from the input stream.
-