Skip to content

Commit 42457ae

Browse files
committed
Fix bug with noDataValue for single banded COGs
1 parent babd669 commit 42457ae

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/essence/Basics/Map_/Map_.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,11 @@ function makeImageLayer(layerObj) {
15281528
'variables.image'
15291529
)
15301530

1531+
const hideNoDataValue = F_.getIn(
1532+
L_.layers.data[layerObj.name],
1533+
'variables.hideNoDataValue'
1534+
)
1535+
15311536
let min = null
15321537
let max = null
15331538
if (georaster.numberOfRasters === 1) {
@@ -1608,10 +1613,15 @@ function makeImageLayer(layerObj) {
16081613
var pixelValue = values[0] // single band
16091614
// don't return a color
16101615
if (
1611-
georaster.noDataValue &&
1616+
georaster.noDataValue != null &&
16121617
georaster.noDataValue === pixelValue
16131618
) {
1614-
return null
1619+
if (hideNoDataValue) {
1620+
return null
1621+
}
1622+
1623+
// Handle the case where we do not want to hide noDataValue
1624+
return [0, 0, 0]
16151625
}
16161626

16171627
// scale from 0 - 1

src/essence/Tools/Layers/LayersTool.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,14 +2292,28 @@ function interfaceWithMMGIS(fromInit) {
22922292
layerData.cogColormap
22932293
)
22942294

2295+
const hideNoDataValue = F_.getIn(
2296+
L_.layers.data[layerName],
2297+
'variables.hideNoDataValue'
2298+
)
2299+
22952300
let pixelValuesToColorFn = (values) => {
22962301
let georaster = layer.options.georaster
22972302
var pixelValue = values[0] // single band
22982303

22992304
// don't return a color
2300-
if (georaster.noDataValue && georaster.noDataValue === pixelValue) {
2301-
return null
2305+
if (
2306+
georaster.noDataValue != null &&
2307+
georaster.noDataValue === pixelValue
2308+
) {
2309+
if (hideNoDataValue) {
2310+
return null
2311+
}
2312+
2313+
// Handle the case where we do not want to hide noDataValue
2314+
return [0, 0, 0]
23022315
}
2316+
23032317
// scale from 0 - 1
23042318
var scaledPixelValue = (pixelValue - vMin) / range
23052319
if (!(scaledPixelValue >= 0 && scaledPixelValue <= 1)) {

0 commit comments

Comments
 (0)