Skip to content

Commit

Permalink
Fix InterpolatedColorMap.render function
Browse files Browse the repository at this point in the history
  • Loading branch information
pomadchin committed Jun 16, 2021
1 parent e0f029f commit 6613640
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- WMS Parent Layer default time should be omitted [#368](https://github.com/geotrellis/geotrellis-server/pull/368)
- Fix WCS DescribeCoverage extents axis ordering [#369](https://github.com/geotrellis/geotrellis-server/pull/369)
- Fix TIFF CellType of identity MAML Layers [#375](https://github.com/geotrellis/geotrellis-server/pull/375)
- Fix InterpolatedColorMap.render function [#381](https://github.com/geotrellis/geotrellis-server/pull/381)

## Changed
- OgcTime logic cleanup [#371](https://github.com/geotrellis/geotrellis-server/pull/371)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,23 @@ case class InterpolatedColorMap(

def interpolate: Double => Int = { dbl: Double => interpolation(poles, clipDefinition)(dbl) }

def render(tile: Tile): Tile =
def render(tile: Tile): Tile = {
// IntCellType is used to store interpolated colors, since the source cellType can have not enough bits to encode interpolated colors.
// See https://github.com/locationtech/geotrellis/blob/v3.6.0/raster/src/main/scala/geotrellis/raster/render/ColorMap.scala#L164-L176
val result = ArrayTile.empty(IntCellType, tile.cols, tile.rows)
if (tile.cellType.isFloatingPoint) {
tile.mapDouble { cellValue: Double =>
if (isData(cellValue)) interpolate(cellValue)
else 0
tile.foreachDouble { (col, row, z) =>
if (isData(z)) result.setDouble(col, row, interpolate(z))
else result.setDouble(col, row, 0d)
}
} else {
tile.map { cellValue: Int =>
if (isData(cellValue)) interpolate(cellValue)
else 0
tile.foreach { (col, row, z) =>
if (isData(z)) result.setDouble(col, row, interpolate(z))
else result.set(col, row, 0)
}
}
result
}
}

object InterpolatedColorMap {
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object Dependencies {

val dispatchVer = "0.11.3"
val gtVer = "3.6.0"
val stac4sVer = "0.5.0-8-gaab61a6-SNAPSHOT"
val stac4sVer = "0.5.0-13-g35ad8d4-SNAPSHOT"
val jaxbApiVer = "2.3.1"
val refinedVer = "0.9.20"
val shapelessVer = "2.3.3"
Expand Down

0 comments on commit 6613640

Please sign in to comment.