Skip to content

Commit

Permalink
fix(18809): filter out values with 0 in denominator or null/undefined…
Browse files Browse the repository at this point in the history
… in numerator/denominator
  • Loading branch information
albaranau committed Jun 28, 2024
1 parent 2499b8c commit 0e586cd
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ export function filterSetup(layers: MCDAConfig['layers']) {
);
}
});
layers.forEach(({ axis, range }) => {
conditions.push(
// check numerator and denominator for null/undefined
notEqual(featureProp(axis[0]), null),
notEqual(featureProp(axis[1]), null),
// this checks for 0 in denominator (which causes makes the result == Infinity)
notEqual(featureProp(axis[1]), 0),
);
});
if (conditions.length > 1) {
return allCondition(...conditions);
}
Expand Down Expand Up @@ -98,10 +107,6 @@ function sentimentPaint({
['var', 'mcdaResult'],
...colorPoints.flatMap((point) => [point.value, point.color]),
],
// mcdaResult == Infinity if any of the denominators is 0.
// We consider these values invalid
['==', ['var', 'mcdaResult'], Infinity],
'transparent',
// paint all values below absoluteMin (0 by default) same as absoluteMin
['<', ['var', 'mcdaResult'], absoluteMin],
bad,
Expand Down

0 comments on commit 0e586cd

Please sign in to comment.