At this point GDAL CellSize derivation does not take into account bitsPerSample, so it will never derive a BitCellType: https://github.com/locationtech/geotrellis/blob/master/gdal/src/main/scala/geotrellis/raster/gdal/GDALDataset.scala#L308
That is how it is used: https://github.com/locationtech/geotrellis/blob/master/gdal/src/main/scala/geotrellis/raster/gdal/GDALUtils.scala#L44
The proposal is to modify GDALWarp.get_band_data_type function to return not only the sampleFormat but a tuple of sampleFormat and bitsPerSample.
Add the following test into GDALRasterSourceSpec (it fails for the BitCellType now):
describe("should derive the cellType consistently with GeoTiffRasterSource") {
val ext = Extent(0.0, 0.0, 3.0, 3.0)
val data = Array(
1, 2, 3,
4, 5, 6,
7, 8, 9
)
List(BitCellType, ByteCellType, UByteCellType, ShortCellType, UShortCellType, IntCellType, FloatCellType, DoubleCellType).map { ct =>
it(ct.getClass.getName.split("\\$").last.split("\\.").last) {
val path = s"/tmp/gdal-$ct-test.tiff"
val raster = Raster(ArrayTile(data, 3, 3).convert(ct), ext)
GeoTiff(raster, LatLng).write(path)
GDALRasterSource(path).cellType shouldBe ct
GeoTiffRasterSource(path).cellType shouldBe ct
}
}
}
P.S. The result of this PR can also be some test that simplifies the derivation function and proofs that we can't make it work consistently for Byte and UByte CellTypes.
P.P.S. it is definitely obvious that we can fix its behavior for the BitCellType
At this point GDAL CellSize derivation does not take into account
bitsPerSample, so it will never derive aBitCellType: https://github.com/locationtech/geotrellis/blob/master/gdal/src/main/scala/geotrellis/raster/gdal/GDALDataset.scala#L308That is how it is used: https://github.com/locationtech/geotrellis/blob/master/gdal/src/main/scala/geotrellis/raster/gdal/GDALUtils.scala#L44
The proposal is to modify
GDALWarp.get_band_data_typefunction to return not only thesampleFormatbut a tuple ofsampleFormatandbitsPerSample.Add the following test into GDALRasterSourceSpec (it fails for the BitCellType now):
P.S. The result of this PR can also be some test that simplifies the derivation function and proofs that we can't make it work consistently for
ByteandUByteCellTypes.P.P.S. it is definitely obvious that we can fix its behavior for the
BitCellType