geotrellis.raster.io.geotiff.UByteGeoTiffTile.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 spire.syntax.cfor._
class UByteGeoTiffTile(
val compressedBytes: Array[Array[Byte]],
val decompressor: Decompressor,
segmentLayout: GeoTiffSegmentLayout,
compression: Compression,
val cellType: UByteCells with NoDataHandling
) extends GeoTiffTile(segmentLayout, compression) with UByteGeoTiffSegmentCollection {
val noDataValue: Option[Int] = cellType match {
case UByteCellType => None
case UByteConstantNoDataCellType => Some(0)
case UByteUserDefinedNoDataCellType(nd) => Some(nd)
}
def mutable: MutableArrayTile = {
val arr = Array.ofDim[Byte](cols * rows)
if(segmentLayout.isStriped) {
var i = 0
cfor(0)(_ < segmentCount, _ + 1) { segmentIndex =>
val segment =
getSegment(segmentIndex)
val size = segment.bytes.size
System.arraycopy(segment.bytes, 0, arr, i, size)
i += size
}
} else {
cfor(0)(_ < segmentCount, _ + 1) { segmentIndex =>
val segment = getSegment(segmentIndex)
val segmentTransform = segmentLayout.getSegmentTransform(segmentIndex)
val width = segmentTransform.segmentCols
val tileWidth = segmentLayout.tileLayout.tileCols
cfor(0)(_ < tileWidth * segmentTransform.segmentRows, _ + tileWidth) { i =>
val col = segmentTransform.indexToCol(i)
val row = segmentTransform.indexToRow(i)
val j = (row * cols) + col
System.arraycopy(segment.bytes, i, arr, j, width)
}
}
}
UByteArrayTile.fromBytes(arr, cols, rows, cellType)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy