Skip to content

Commit

Permalink
feat(natural-forest): add workaround to avoid displaying empty contai…
Browse files Browse the repository at this point in the history
…ner when analyzing custom areas for natural forest layer, remove whitelist for Peru in forest loss
  • Loading branch information
wri7tno committed Dec 30, 2024
1 parent 65906dd commit 7044b80
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 9 additions & 0 deletions components/analysis/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion components/widgets/land-cover/natural-forest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit 7044b80

Please sign in to comment.