geotrellis.raster.io.geotiff.UInt16GeoTiffTile.scala Maven / Gradle / Ivy
package geotrellis.raster.io.geotiff
import geotrellis.raster._
import geotrellis.raster.io.geotiff.compression._
import spire.syntax.cfor._
class UInt16GeoTiffTile(
val compressedBytes: Array[Array[Byte]],
val decompressor: Decompressor,
segmentLayout: GeoTiffSegmentLayout,
compression: Compression,
val cellType: UShortCells with NoDataHandling
) extends GeoTiffTile(segmentLayout, compression) with UInt16GeoTiffSegmentCollection {
val noDataValue: Option[Int] = cellType match {
case UShortCellType => None
case UShortConstantNoDataCellType => Some(0)
case UShortUserDefinedNoDataCellType(nd) => Some(nd)
}
def mutable: MutableArrayTile = {
val arr = Array.ofDim[Short](cols * rows)
cfor(0)(_ < segmentCount, _ + 1) { segmentIndex =>
val segment =
getSegment(segmentIndex)
val segmentTransform = segmentLayout.getSegmentTransform(segmentIndex)
cfor(0)(_ < segment.size, _ + 1) { i =>
val col = segmentTransform.indexToCol(i)
val row = segmentTransform.indexToRow(i)
if(col < cols && row < rows) {
val data = segment.getRaw(i)
arr(row * cols + col) = data
}
}
}
UShortArrayTile(arr, cols, rows, cellType)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy