Class Band
java.lang.Object
org.apache.sis.internal.sql.postgis.Band
Information about a single band in PostGIS WKB raster.
Used during reading and writing processes.
This class is also the place where WKB constants are defined. Some constants are defined directly in an array, or indirectly as index in an array.
- Since:
- 1.2
- Version:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]
MapsDataBuffer
types to WKB pixel types.(package private) Object
The raster pixel values as abyte[]
,short[]
,int[]
,float[]
ordouble[]
array.private static final int
If this bit is set, the stored nodata value is a true nodata value.(package private) final int
The header byte, which is a bit pattern decomposed by thePIXEL_TYPE
,IS_OFFLINE
,HAS_NODATA
andIS_NODATA
masks.private static final int
If this bit is set, all the values of the band are expected to be nodata values.private static final int
If this bit is set, data is to be found on the file system, through the path specified inRASTERDATA
.(package private) Number
The "no data" value, ornull
if none.(package private) static final int
A bitmask applied toDataBuffer.TYPE_BYTE
orDataBuffer.TYPE_INT
for meaning that the actual data type has a sign opposite to the data buffer type.private static final byte[]
Type of Java2D buffer for each WKB data type.private static final int
Mask for the type of pixel values.private static final byte[]
Number of bits for each WKB data type.private static final byte[]
Maps sample sizes (in bits) to WKB pixel types. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static int
bufferToPixelType
(int dataType) Returns the WKB pixel type for the givenDataBuffer
constant.(package private) final int
Returns the type of Java2D buffer for this band.(package private) final int
Returns the number of bits per sample value in this band.private int
Returns a code for the type of pixel values.(package private) final boolean
Iftrue
, the stored nodata value is a true nodata value.(package private) final boolean
isNodata()
Iftrue
, all the values of the band are expected to be nodata values.(package private) final boolean
Returnstrue
if data is to be found on the file system, through the path specified inRASTERDATA
.(package private) final boolean
Returnstrue
if the data type of this band is an unsigned type.(package private) static int
sizeToPixelType
(int size) Returns the WKB pixel type for an unsigned integer capable to store the given number of bits.(package private) final double[]
toNaN
(double[] array) Replaces all "no data" value in the given array by theDouble.NaN
value.(package private) final float[]
toNaN
(float[] array) Replaces all "no data" value in the given array by theFloat.NaN
value.toString()
Returns a string representation of this WKB raster band for debugging purpose.
-
Field Details
-
IS_OFFLINE
private static final int IS_OFFLINEIf this bit is set, data is to be found on the file system, through the path specified inRASTERDATA
.- See Also:
-
HAS_NODATA
private static final int HAS_NODATAIf this bit is set, the stored nodata value is a true nodata value. Otherwise the value stored as a nodata value should be ignored.- See Also:
-
IS_NODATA
private static final int IS_NODATAIf this bit is set, all the values of the band are expected to be nodata values. This is a dirty flag.- See Also:
-
PIXEL_TYPE
private static final int PIXEL_TYPEMask for the type of pixel values. This mask is applied onheader
.- See Also:
-
header
final int headerThe header byte, which is a bit pattern decomposed by thePIXEL_TYPE
,IS_OFFLINE
,HAS_NODATA
andIS_NODATA
masks. -
noDataValue
Number noDataValueThe "no data" value, ornull
if none. -
data
Object dataThe raster pixel values as abyte[]
,short[]
,int[]
,float[]
ordouble[]
array. -
OPPOSITE_SIGN
static final int OPPOSITE_SIGNA bitmask applied toDataBuffer.TYPE_BYTE
orDataBuffer.TYPE_INT
for meaning that the actual data type has a sign opposite to the data buffer type. We use a mask for making easy to ignore this difference when desired.Limitations
We do not have good support for those types yet. For now, we handle them using their standard counterparts and ignore the sign difference, except if the user asked for aGridCoverage
in which case we raise an exception (because theevaluate(…)
methods would return wrong values). If we need a real support of those types, we should create customDataBufferSignedByte
andDataBufferUInt
classes.- See Also:
-
PIXEL_TO_BUFFER_TYPE
private static final byte[] PIXEL_TO_BUFFER_TYPEType of Java2D buffer for each WKB data type. In the case ofDataBuffer.TYPE_BYTE
, sample values may be packed in 1, 2 or 4 bits (theDataBuffer
type does not tell). For all integer types exceptshort
, we may have a sign mismatch.- See Also:
-
BUFFER_TO_PIXEL_TYPE
private static final byte[] BUFFER_TO_PIXEL_TYPEMapsDataBuffer
types to WKB pixel types. This array is the converse ofPIXEL_TO_BUFFER_TYPE
. -
PIXEL_TYPE_TO_SIZE
private static final byte[] PIXEL_TYPE_TO_SIZENumber of bits for each WKB data type. Indices in the array are WKB pixel types.- See Also:
-
SIZE_TO_PIXEL_TYPE
private static final byte[] SIZE_TO_PIXEL_TYPEMaps sample sizes (in bits) to WKB pixel types. Indices in the array are the logarithm in base 2 of the pixel size. This array is the converse ofPIXEL_TYPE_TO_SIZE
.
-
-
Constructor Details
-
Band
Band(int header) Creates an initially empty band.- Parameters:
header
- the byte header of the band.
-
Band
Band(int pixelType, Number noDataValue) Creates a band of the given type with the given no-data value.- Parameters:
pixelType
- WKB code for the type of pixel values.noDataValue
- the "no data" value, ornull
if none.
-
-
Method Details
-
getPixelType
private int getPixelType()Returns a code for the type of pixel values. -
isOffline
final boolean isOffline()Returnstrue
if data is to be found on the file system, through the path specified inRASTERDATA
. -
hasNodata
final boolean hasNodata()Iftrue
, the stored nodata value is a true nodata value. Otherwise the value stored as a nodata value should be ignored. -
isNodata
final boolean isNodata()Iftrue
, all the values of the band are expected to be nodata values. This is a dirty flag. -
isUnsigned
final boolean isUnsigned()Returnstrue
if the data type of this band is an unsigned type. -
getDataBufferType
final int getDataBufferType()Returns the type of Java2D buffer for this band. In the case ofDataBuffer.TYPE_BYTE
, sample values may be packed in 1, 2 or 4 bits (theDataBuffer
type does not tell). For all integer types exceptshort
, we may have a sign mismatch.- Returns:
- buffer type, or
DataBuffer.TYPE_UNDEFINED
if the band type is unknown.
-
bufferToPixelType
static int bufferToPixelType(int dataType) Returns the WKB pixel type for the givenDataBuffer
constant.- Parameters:
dataType
- one ofDataBuffer
TYPE_*
constants.- Returns:
- WKB type for the given data type.
- Throws:
RasterFormatException
- if the given type is invalid.
-
getDataTypeSize
final int getDataTypeSize()Returns the number of bits per sample value in this band.- Returns:
- number of bits.
- Throws:
RasterFormatException
- if the pixel type is unknown.
-
sizeToPixelType
static int sizeToPixelType(int size) Returns the WKB pixel type for an unsigned integer capable to store the given number of bits.- Parameters:
size
- number of bits.- Returns:
- WKB type for the given size.
- Throws:
RasterFormatException
- if the given size is invalid.
-
toNaN
final float[] toNaN(float[] array) Replaces all "no data" value in the given array by theFloat.NaN
value. ThenoDataValue
field is set tonull
for telling that there is no longer a sentinel value (other than NaN) after this method call. -
toNaN
final double[] toNaN(double[] array) Replaces all "no data" value in the given array by theDouble.NaN
value. ThenoDataValue
field is set tonull
for telling that there is no longer a sentinel value (other than NaN) after this method call. -
toString
Returns a string representation of this WKB raster band for debugging purpose.
-