geotrellis.raster.io.geotiff.Float64GeoTiffTile.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 Float64GeoTiffTile(
val compressedBytes: Array[Array[Byte]],
val decompressor: Decompressor,
segmentLayout: GeoTiffSegmentLayout,
compression: Compression,
val cellType: DoubleCells with NoDataHandling
) extends GeoTiffTile(segmentLayout, compression) with Float64GeoTiffSegmentCollection {
val noDataValue: Option[Double] = cellType match {
case DoubleCellType => None
case DoubleConstantNoDataCellType => Some(Double.NaN)
case DoubleUserDefinedNoDataCellType(nd) => Some(nd)
}
def mutable: MutableArrayTile = {
val arr = Array.ofDim[Byte](cols * rows * DoubleConstantNoDataCellType.bytes)
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 * DoubleConstantNoDataCellType.bytes
val tileWidth = segmentLayout.tileLayout.tileCols * DoubleConstantNoDataCellType.bytes
cfor(0)(_ < tileWidth * segmentTransform.segmentRows, _ + tileWidth) { i =>
val col = segmentTransform.indexToCol(i / DoubleConstantNoDataCellType.bytes)
val row = segmentTransform.indexToRow(i / DoubleConstantNoDataCellType.bytes)
val j = ((row * cols) + col) * DoubleConstantNoDataCellType.bytes
System.arraycopy(segment.bytes, i, arr, j, width)
}
}
}
DoubleArrayTile.fromBytes(arr, cols, rows, cellType)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy