Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ShortArrayTileResult result ArrayTile fulfillment #3268

Merged
merged 1 commit into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions raster/src/main/scala/geotrellis/raster/ShortArrayTile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand Down Expand Up @@ -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] = {
Expand Down Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down