From 44ac67813badb296ee97a7c9817c199092edf682 Mon Sep 17 00:00:00 2001 From: Grigory Pomadchin Date: Fri, 10 Jul 2020 14:20:38 -0400 Subject: [PATCH] Fix ShortArrayTileResult result ArrayTile --- CHANGELOG.md | 1 + .../geotrellis/raster/ShortArrayTile.scala | 18 +++++++++--------- .../mapalgebra/focal/FocalCalculation.scala | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9ace0a02a..c15ab9a137 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - GeoTiffRasterSource is not threadsafe enough [#3265](https://github.com/locationtech/geotrellis/pull/3265) +- Fix ShortArrayTileResult result ArrayTile fulfillment [#3268](https://github.com/locationtech/geotrellis/pull/3268) ## [3.4.0] - 2020-06-19 diff --git a/raster/src/main/scala/geotrellis/raster/ShortArrayTile.scala b/raster/src/main/scala/geotrellis/raster/ShortArrayTile.scala index 2fe356146d..700f8053ee 100644 --- a/raster/src/main/scala/geotrellis/raster/ShortArrayTile.scala +++ b/raster/src/main/scala/geotrellis/raster/ShortArrayTile.scala @@ -266,11 +266,11 @@ object ShortArrayTile { def ofDim(cols: Int, rows: Int, cellType: ShortCells with NoDataHandling): ShortArrayTile = cellType match { case ShortCellType => - new ShortRawArrayTile(Array.ofDim[Short](cols * rows), cols, rows) + ShortRawArrayTile(Array.ofDim[Short](cols * rows), cols, rows) case ShortConstantNoDataCellType => - new ShortConstantNoDataArrayTile(Array.ofDim[Short](cols * rows), cols, rows) + ShortConstantNoDataArrayTile(Array.ofDim[Short](cols * rows), cols, rows) case udct: ShortUserDefinedNoDataCellType => - new ShortUserDefinedNoDataArrayTile(Array.ofDim[Short](cols * rows), cols, rows, udct) + ShortUserDefinedNoDataArrayTile(Array.ofDim[Short](cols * rows), cols, rows, udct) } /** @@ -327,11 +327,11 @@ object ShortArrayTile { def fill(v: Short, cols: Int, rows: Int, cellType: ShortCells with NoDataHandling): ShortArrayTile = cellType match { case ShortCellType => - new ShortRawArrayTile(Array.ofDim[Short](cols * rows).fill(v), cols, rows) + ShortRawArrayTile(Array.ofDim[Short](cols * rows).fill(v), cols, rows) case ShortConstantNoDataCellType => - new ShortConstantNoDataArrayTile(Array.ofDim[Short](cols * rows).fill(v), cols, rows) + ShortConstantNoDataArrayTile(Array.ofDim[Short](cols * rows).fill(v), cols, rows) case udct: ShortUserDefinedNoDataCellType => - new ShortUserDefinedNoDataArrayTile(Array.ofDim[Short](cols * rows).fill(v), cols, rows, udct) + ShortUserDefinedNoDataArrayTile(Array.ofDim[Short](cols * rows).fill(v), cols, rows, udct) } private def constructShortArray(bytes: Array[Byte]): Array[Short] = { @@ -366,10 +366,10 @@ object ShortArrayTile { def fromBytes(bytes: Array[Byte], cols: Int, rows: Int, cellType: ShortCells with NoDataHandling): ShortArrayTile = cellType match { case ShortCellType => - new ShortRawArrayTile(constructShortArray(bytes), cols, rows) + ShortRawArrayTile(constructShortArray(bytes), cols, rows) case ShortConstantNoDataCellType => - new ShortConstantNoDataArrayTile(constructShortArray(bytes), cols, rows) + ShortConstantNoDataArrayTile(constructShortArray(bytes), cols, rows) case udct: ShortUserDefinedNoDataCellType => - new ShortUserDefinedNoDataArrayTile(constructShortArray(bytes), cols, rows, udct) + ShortUserDefinedNoDataArrayTile(constructShortArray(bytes), cols, rows, udct) } } diff --git a/raster/src/main/scala/geotrellis/raster/mapalgebra/focal/FocalCalculation.scala b/raster/src/main/scala/geotrellis/raster/mapalgebra/focal/FocalCalculation.scala index 6ee6c924e9..74acf18728 100644 --- a/raster/src/main/scala/geotrellis/raster/mapalgebra/focal/FocalCalculation.scala +++ b/raster/src/main/scala/geotrellis/raster/mapalgebra/focal/FocalCalculation.scala @@ -226,7 +226,7 @@ trait ShortArrayTileResult extends Resulting[Tile] { self: FocalCalculation[Tile /** [[ShortArrayTile]] that will be returned by the focal calculation */ val cols: Int = bounds.width val rows: Int = bounds.height - val resultTile = ShortArrayTile(Array.ofDim[Short](cols * rows), cols, rows) + val resultTile = ShortArrayTile.empty(cols, rows) val copyOriginalValue: (Int, Int, Int, Int) => Unit = { (focusCol: Int, focusRow: Int, col: Int, row: Int) => resultTile.set(col, row, r.get(focusCol, focusRow))