From db6db8b6d4716745962c61229cbdc4ef0aa4a574 Mon Sep 17 00:00:00 2001 From: Luis Zenteno Date: Mon, 30 Dec 2024 12:19:56 -0600 Subject: [PATCH] feat(natural-forest): add workaround to avoid displaying empty container when analyzing custom areas for natural forest layer, remove whitelist for Peru in forest loss --- components/analysis/selectors.js | 9 +++++++++ .../widgets/forest-change/tree-loss-plantations/index.js | 4 ---- components/widgets/land-cover/natural-forest/index.js | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/components/analysis/selectors.js b/components/analysis/selectors.js index c3a589f51d..3a83c54604 100644 --- a/components/analysis/selectors.js +++ b/components/analysis/selectors.js @@ -93,6 +93,15 @@ export const getLayerEndpoints = createSelector( (layers, location, widgetLayers) => { if (!layers || !layers.length) return null; + // NOTE: this is a horrible code smell but it was the only workaround + // I was able to find to avoid showing the Natural Forest data without widget in the map. + const naturalForest = layers.find( + (layer) => layer.dataset === 'natural-forests' + ); + if (naturalForest) { + return null; + } + const { type, adm2 } = location; const routeType = type === 'country' ? 'admin' : type; const lossLayer = layers.find((l) => l.metadata === 'tree_cover_loss'); diff --git a/components/widgets/forest-change/tree-loss-plantations/index.js b/components/widgets/forest-change/tree-loss-plantations/index.js index 0c15df324f..809299f18a 100644 --- a/components/widgets/forest-change/tree-loss-plantations/index.js +++ b/components/widgets/forest-change/tree-loss-plantations/index.js @@ -71,10 +71,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.', - whitelists: { - indicators: ['plantations'], - checkStatus: true, - }, settings: { threshold: 30, startYear: MIN_YEAR, diff --git a/components/widgets/land-cover/natural-forest/index.js b/components/widgets/land-cover/natural-forest/index.js index ff8b50c425..0a8eb0166f 100644 --- a/components/widgets/land-cover/natural-forest/index.js +++ b/components/widgets/land-cover/natural-forest/index.js @@ -34,7 +34,9 @@ export default { colors: 'extent', source: 'gadm', categories: ['land-cover', 'summary'], - types: ['global', 'country'], // this array dictates where do we want to show the widget in the map (i.e.: "only for countries but not for custom areas") + // NOTE: this `types` array dictates where do we want to show the widget in the map (i.e.: "only for countries but not for custom areas") + // see components/analysis/selectors.js getLayerEndpoints function since I had to do a workaround because it was showing an empty container + types: ['global', 'country'], admins: ['global', 'adm0', 'adm1', 'adm2'], visible: ['dashboard', 'analysis'], datasets: [