Skip to content

Commit

Permalink
feat(treeCover): fix other three cover value calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
wri7tno committed Dec 11, 2024
1 parent 108b4fd commit 93c9607
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {
NATURAL_FOREST_2020,
} from 'data/layers';

import { EuropeFAOCountries } from 'utils/fao-countries';

import getWidgetProps from './selectors';

const MIN_YEAR = 2021;
Expand Down Expand Up @@ -72,9 +70,6 @@ export default {
},
sentence:
'From {startYear} to {endYear}, {percentage} of tree cover loss in {location} occurred within {lossPhrase}. The total loss within natural forest was {totalLoss} equivalent to {value} of CO\u2082e emissions.',
blacklists: {
adm0: EuropeFAOCountries,
},
settings: {
threshold: 30,
startYear: MIN_YEAR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export const parseData = createSelector(
const mappedData = zeroFilledData.map((list) => {
return {
iso: list[0].iso,
outsideAreaLoss: list[1].area,
outsideCo2Loss: list[1].emissions,
outsideAreaLoss: list[1].area || 0,
outsideCo2Loss: list[1].emissions || 0,
areaLoss: list[0].area,
co2Loss: list[0].emissions,
totalLoss: list[0].area + list[1].area + list[2].area,
totalLoss: list[0].area || 0 + list[1].area || 0 + list[2].area || 0,
year: list[0].year,
};
});
Expand Down
8 changes: 5 additions & 3 deletions components/widgets/land-cover/tree-cover/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const parseData = createSelector(
value: hasPlantations ? plantationsCover : cover - plantationsCover,
color: colors.naturalForest,
percentage:
((hasPlantations ? plantationsCover : cover) / totalArea) * 100,
((hasPlantations ? plantationsCover : cover - plantationsCover) /
totalArea) *
100,
},
{
label: 'Other Land Cover',
Expand All @@ -43,9 +45,9 @@ export const parseData = createSelector(
if (hasPlantations) {
parsedData.splice(1, 0, {
label: 'Other tree cover',
value: otherCover,
value: totalCover - plantationsCover,
color: colors.otherCover,
percentage: (otherCover / totalArea) * 100,
percentage: ((totalCover - plantationsCover) / totalArea) * 100,
});
}

Expand Down

0 comments on commit 93c9607

Please sign in to comment.