Skip to content

Commit

Permalink
Merge pull request #4865 from wri/feat/plantations-FLAG-1099
Browse files Browse the repository at this point in the history
[FLAG-1099] Priority 3: Update Plantations widget
  • Loading branch information
willian-viana authored Oct 11, 2024
2 parents 700c328 + b6e9364 commit 53ab33d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 51 deletions.
8 changes: 2 additions & 6 deletions components/widgets/land-cover/tree-cover-plantations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ export default {
extentYear: 2010,
},
sentences: {
initialSpecies:
'In {location}, {firstSpecies} and {secondSpecies} represent the largest plantation area by {type}, spanning {extent} and {percent} of land area.',
singleSpecies:
'In {location}, {firstSpecies} represent the largest plantation area by {type}, spanning {extent} and {percent} of land area.',
initialTypes:
'In {location}, the largest plantation area by type is {topType}, spanning {extent} and {percent} of land area.',
initial:
'In {location}, the largest type of plantation area is {topType}, spanning {extent} and {percent} land area.',
},
whitelists: {
indicators: ['plantations'],
Expand Down
22 changes: 6 additions & 16 deletions components/widgets/land-cover/tree-cover-plantations/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import endsWith from 'lodash/endsWith';

// get list data
const getData = (state) => state.data;
const getSettings = (state) => state.settings;
const getLocatonName = (state) => state.locationLabel;
const getColors = (state) => state.colors;
const getSentences = (state) => state.sentences;
Expand Down Expand Up @@ -38,30 +37,21 @@ export const parseData = createSelector(
);

export const parseSentence = createSelector(
[getData, parseData, getSettings, getLocatonName, getSentences],
(rawData, data, settings, locationName, sentences) => {
[getData, parseData, getLocatonName, getSentences],
(rawData, data, locationName, sentences) => {
if (isEmpty(data) || !sentences) return null;
const { initialSpecies, singleSpecies, initialTypes } = sentences;
const top =
settings.type === 'bound2' ? data.slice(0, 2) : data.slice(0, 1);

const { initial } = sentences;
const top = data.slice(0, 1);
const areaPerc = (100 * (sumBy(top, 'value') || 0)) / rawData.totalArea;
const topExtent = sumBy(top, 'value') || 0;
const otherExtent = sumBy(data.slice(2), 'value') || 0;
const params = {
location: locationName,
firstSpecies: top[0].label.toLowerCase(),
secondSpecies: top.length > 1 && top[1].label.toLowerCase(),
type: settings.type === 'bound2' ? 'species' : 'type',
extent: formatNumber({ num: topExtent, unit: 'ha', spaceUnit: true }),
other: formatNumber({ num: otherExtent, unit: 'ha', spaceUnit: true }),
count: data.length - top.length,
topType: `${top[0].label}${endsWith(top[0].label, 's') ? '' : 's'}`,
percent: formatNumber({ num: areaPerc, unit: '%' }),
};
const sentence =
settings.type === 'bound1'
? initialTypes
: `${top.length > 1 ? initialSpecies : singleSpecies}`;
const sentence = initial;

return {
sentence,
Expand Down
58 changes: 29 additions & 29 deletions data/analysis-datasets-versions.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"ANNUAL_ADM0_CHANGE": "v20240404",
"ANNUAL_ADM0_SUMMARY": "v20240404",
"ANNUAL_ADM0_WHITELIST": "v20240404",
"ANNUAL_ADM1_CHANGE": "v20240404",
"ANNUAL_ADM1_SUMMARY": "v20240404",
"ANNUAL_ADM1_WHITELIST": "v20240404",
"ANNUAL_ADM2_CHANGE": "v20240404",
"ANNUAL_ADM2_SUMMARY": "v20240404",
"ANNUAL_ADM2_WHITELIST": "v20240404",
"ANNUAL_ADM0_CHANGE": "v20240815",
"ANNUAL_ADM0_SUMMARY": "v20240815",
"ANNUAL_ADM0_WHITELIST": "v20240815",
"ANNUAL_ADM1_CHANGE": "v20240815",
"ANNUAL_ADM1_SUMMARY": "v20240815",
"ANNUAL_ADM1_WHITELIST": "v20240815",
"ANNUAL_ADM2_CHANGE": "v20240815",
"ANNUAL_ADM2_SUMMARY": "v20240815",
"ANNUAL_ADM2_WHITELIST": "v20240815",

"ANNUAL_GEOSTORE_CHANGE": "v20240404",
"ANNUAL_GEOSTORE_SUMMARY": "v20240404",
"ANNUAL_GEOSTORE_WHITELIST": "v20240404",
"ANNUAL_WDPA_CHANGE": "v20240404",
"ANNUAL_WDPA_SUMMARY": "v20240404",
"ANNUAL_WDPA_WHITELIST": "v20240404",
"ANNUAL_GEOSTORE_CHANGE": "v20240815",
"ANNUAL_GEOSTORE_SUMMARY": "v20240815",
"ANNUAL_GEOSTORE_WHITELIST": "v20240815",
"ANNUAL_WDPA_CHANGE": "v20240813",
"ANNUAL_WDPA_SUMMARY": "v20240813",
"ANNUAL_WDPA_WHITELIST": "v20240813",

"VIIRS_ADM0_WHITELIST": "v20240118",
"VIIRS_ADM1_WHITELIST": "v20240118",
"VIIRS_ADM2_WHITELIST": "v20240118",
"VIIRS_ADM2_DAILY": "v20240118",
"VIIRS_ADM0_WEEKLY": "v20240118",
"VIIRS_ADM1_WEEKLY": "v20240118",
"VIIRS_ADM2_WEEKLY": "v20240118",
"VIIRS_ADM0_WHITELIST": "v20240815",
"VIIRS_ADM1_WHITELIST": "v20240815",
"VIIRS_ADM2_WHITELIST": "v20240815",
"VIIRS_ADM2_DAILY": "v20240815",
"VIIRS_ADM0_WEEKLY": "v20240815",
"VIIRS_ADM1_WEEKLY": "v20240815",
"VIIRS_ADM2_WEEKLY": "v20240815",

"VIIRS_GEOSTORE_WHITELIST": "v20240122",
"VIIRS_GEOSTORE_DAILY": "v20240122",
Expand All @@ -31,13 +31,13 @@
"VIIRS_WDPA_WEEKLY": "v20240122",
"VIIRS_WDPA_WHITELIST": "v20240122",

"MODIS_ADM0_WHITELIST": "v20240118",
"MODIS_ADM1_WHITELIST": "v20240118",
"MODIS_ADM2_WHITELIST": "v20240118",
"MODIS_ADM2_DAILY": "v20240118",
"MODIS_ADM0_WEEKLY": "v20240118",
"MODIS_ADM1_WEEKLY": "v20240118",
"MODIS_ADM2_WEEKLY": "v20240118",
"MODIS_ADM0_WHITELIST": "v20240815",
"MODIS_ADM1_WHITELIST": "v20240815",
"MODIS_ADM2_WHITELIST": "v20240815",
"MODIS_ADM2_DAILY": "v20240815",
"MODIS_ADM0_WEEKLY": "v20240815",
"MODIS_ADM1_WEEKLY": "v20240815",
"MODIS_ADM2_WEEKLY": "v20240815",

"MODIS_GEOSTORE_WHITELIST": "v20240122",
"MODIS_GEOSTORE_DAILY": "v20240122",
Expand Down

0 comments on commit 53ab33d

Please sign in to comment.