Skip to content

Commit 3081abc

Browse files
committed
Use correct alpha band
1 parent efb02c2 commit 3081abc

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

packages/base/src/dialogs/symbology/tiff_layer/types/MultibandColor.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const MultibandColor = ({
3636
blue: 3
3737
});
3838

39+
const numOfBandsRef = useRef(0);
3940
const selectedBandsRef = useRef<ISelectedBands>({
4041
red: selectedBands.red,
4142
green: selectedBands.green,
@@ -56,6 +57,14 @@ const MultibandColor = ({
5657
};
5758
}, []);
5859

60+
useEffect(() => {
61+
numOfBandsRef.current = bandRows.length;
62+
}, [bandRows]);
63+
64+
useEffect(() => {
65+
selectedBandsRef.current = selectedBands;
66+
}, [selectedBands]);
67+
5968
const populateOptions = async () => {
6069
const layerParams = layer.parameters as IWebGlLayer;
6170
const red = layerParams.symbologyState?.redBand ?? 1;
@@ -65,10 +74,6 @@ const MultibandColor = ({
6574
setSelectedBands({ red, green, blue });
6675
};
6776

68-
useEffect(() => {
69-
selectedBandsRef.current = selectedBands;
70-
}, [selectedBands]);
71-
7277
const updateBand = (color: rgbEnum, value: number) => {
7378
setSelectedBands(prevBands => ({
7479
...prevBands,
@@ -91,7 +96,8 @@ const MultibandColor = ({
9196
});
9297

9398
// Array expression expects 4 values
94-
colorExpr.push(['band', 5]);
99+
// Last band should be alpha band added by OpenLayers
100+
colorExpr.push(['band', numOfBandsRef.current + 1]);
95101

96102
const symbologyState = {
97103
renderType: 'Multiband Color',

0 commit comments

Comments
 (0)