geotrellis.raster.io.geotiff.Int16GeoTiffMultibandTile.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geotrellis-raster_2.11 Show documentation
Show all versions of geotrellis-raster_2.11 Show documentation
GeoTrellis is an open source geographic data processing engine for high performance applications.
The newest version!
package geotrellis.raster.io.geotiff
import geotrellis.raster._
import geotrellis.raster.io.geotiff.compression._
import java.nio.ByteBuffer
class Int16GeoTiffMultibandTile(
compressedBytes: Array[Array[Byte]],
decompressor: Decompressor,
segmentLayout: GeoTiffSegmentLayout,
compression: Compression,
bandCount: Int,
hasPixelInterleave: Boolean,
val cellType: ShortCells with NoDataHandling
) extends GeoTiffMultibandTile(compressedBytes, decompressor, segmentLayout, compression, bandCount, hasPixelInterleave)
with Int16GeoTiffSegmentCollection {
val noDataValue: Option[Short] = cellType match {
case ShortCellType => None
case ShortConstantNoDataCellType => Some(Short.MinValue)
case ShortUserDefinedNoDataCellType(nd) => Some(nd)
}
protected def createSegmentCombiner(targetSize: Int): SegmentCombiner =
new SegmentCombiner(bandCount) {
private val arr = Array.ofDim[Short](targetSize)
def set(targetIndex: Int, v: Int): Unit = {
arr(targetIndex) = i2s(v)
}
def setDouble(targetIndex: Int, v: Double): Unit = {
arr(targetIndex) = d2s(v)
}
def getBytes(): Array[Byte] = {
val result = new Array[Byte](targetSize * ShortConstantNoDataCellType.bytes)
val bytebuff = ByteBuffer.wrap(result)
bytebuff.asShortBuffer.put(arr)
result
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy