From 6af36dd140ae471ea1dd0b9bca092e8a154e12b6 Mon Sep 17 00:00:00 2001 From: AngelArcones Date: Thu, 22 Feb 2024 12:53:22 +0100 Subject: [PATCH 01/54] tree gain new decoding initial test --- providers/datasets-provider/config.js | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/providers/datasets-provider/config.js b/providers/datasets-provider/config.js index 1a4506b957..e86715aa12 100644 --- a/providers/datasets-provider/config.js +++ b/providers/datasets-provider/config.js @@ -55,6 +55,36 @@ const decodes = { alpha = 0.; } `, + treeCoverGain5y: ` + // values for creating power scale, domain (input), and range (output) + float domainMin = 0.; + float domainMax = 255.; + float rangeMin = 0.; + float rangeMax = 255.; + + float exponent = zoom < 13. ? 0.3 + (zoom - 3.) / 20. : 1.; + float intensity = color.r * 255.; + + // get the min, max, and current values on the power scale + float minPow = pow(domainMin, exponent - domainMin); + float maxPow = pow(domainMax, exponent); + float currentPow = pow(intensity, exponent); + + // get intensity value mapped to range + float scaleIntensity = ((currentPow - minPow) / (maxPow - minPow) * (rangeMax - rangeMin)) + rangeMin; + // a value between 0 and 255 + alpha = zoom < 13. ? scaleIntensity / 255. : color.g; + + float year = 1999.0 + ((color.b * 5.) * 255.); + // map to years + if (year >= startYear && year <= endYear && year >= 2001.) { + color.r = 109. / 255.; + color.g = (72. - zoom + 109. - 3. * scaleIntensity / zoom) / 255.; + color.b = (33. - zoom + 229. - intensity / zoom) / 255.; + } else { + alpha = 0.; + } +`, treeCoverLossFire: ` // values for creating power scale, domain (input), and range (output) float domainMin = 0.; @@ -1051,6 +1081,7 @@ const decodes = { export default { treeCover: decodes.treeCover, treeCoverLoss: decodes.treeCoverLoss, + treeCoverGain5y: decodes.treeCoverGain5y, treeCoverLossFire: decodes.treeCoverLossFire, treeLossByDriver: decodes.treeLossByDriver, integratedAlerts8Bit: decodes.integratedAlerts8Bit, From 687e91e2e298ebd1d9fa433a6c4ce5b90cea63b1 Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Tue, 19 Mar 2024 13:05:33 +0000 Subject: [PATCH 02/54] Default canPlay to true in the Timestep component and remove hardcoded timestep canPlay in decode params --- components/timestep/index.js | 2 +- providers/datasets-provider/actions.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/components/timestep/index.js b/components/timestep/index.js index 7a36169029..ce805c3b08 100644 --- a/components/timestep/index.js +++ b/components/timestep/index.js @@ -45,7 +45,7 @@ class Timestep extends PureComponent { customClass: null, range: true, pushable: 0, - canPlay: false, + canPlay: true, trim: null, diff --git a/providers/datasets-provider/actions.js b/providers/datasets-provider/actions.js index 18fa932203..9ea6315404 100644 --- a/providers/datasets-provider/actions.js +++ b/providers/datasets-provider/actions.js @@ -270,7 +270,6 @@ export const fetchDatasets = createThunkAction( minDate: decodeParams.startDate, maxDate: decodeParams.endDate, trimEndDate: decodeParams.endDate, - canPlay: true, }), }, }), From ddcd03f8a1f6400d6153b903fc76c90e3b12bf49 Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Thu, 21 Mar 2024 13:06:29 +0000 Subject: [PATCH 03/54] Timeline Component to support an option to match the legend to the slider's steps --- .../components/legend/components/timeline/index.js | 5 ++++- .../legend/components/timeline/selectors.js | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/components/map/components/legend/components/timeline/index.js b/components/map/components/legend/components/timeline/index.js index c83d91e3a7..3d335ba90e 100644 --- a/components/map/components/legend/components/timeline/index.js +++ b/components/map/components/legend/components/timeline/index.js @@ -15,6 +15,8 @@ const mapStateToProps = ( startDate, endDate, trimEndDate, + step, + matchLegend, dynamicTimeline, ...props } @@ -28,7 +30,8 @@ const mapStateToProps = ( dynamicTimeline, }; return { - marks: getMarks({ dates, dynamicTimeline }), + marks: getMarks({ dates, step, matchLegend, dynamicTimeline }), + step, ...props, }; }; diff --git a/components/map/components/legend/components/timeline/selectors.js b/components/map/components/legend/components/timeline/selectors.js index 222c7564f6..b71e6ae9b1 100644 --- a/components/map/components/legend/components/timeline/selectors.js +++ b/components/map/components/legend/components/timeline/selectors.js @@ -3,7 +3,15 @@ import moment from 'moment'; import range from 'lodash/range'; const getDates = (state) => state.dates; -export const getMarks = createSelector(getDates, (dates) => { +const getSliderStep = (state) => state.step; +const getMatchLegend = (state) => state.matchLegend; + +const getTicksStep = (numOfYears, sliderStep, matchLegend) => { + if (matchLegend && numOfYears && sliderStep) return numOfYears / sliderStep; + return (numOfYears > 6 ? 6 : numOfYears); +} + +export const getMarks = createSelector(getDates, getSliderStep, getMatchLegend, (dates, sliderStep, matchLegend) => { if (!dates) return null; const { minDate, maxDate, dynamicTimeline = false } = dates; const numOfYears = moment(maxDate).diff(minDate, 'years'); @@ -12,11 +20,12 @@ export const getMarks = createSelector(getDates, (dates) => { if (!numOfYears || maxDays <= 365) return null; const marks = {}; + const ticksStep = getTicksStep(numOfYears, sliderStep, matchLegend); let ticks = range( 0, maxDays + 1, - maxDays / (numOfYears > 6 ? 6 : numOfYears) + maxDays / ticksStep ); if (dynamicTimeline) { From 739032a628456bdc81c6f8d7e63f91a91c3d7e83 Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Fri, 22 Mar 2024 15:19:06 +0000 Subject: [PATCH 04/54] Add support for disabling start/end handles in the Timestep component --- components/slider/index.js | 53 ++++++++++++++++++++++++++++++++++-- components/timestep/index.js | 9 ++++++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/components/slider/index.js b/components/slider/index.js index a398df127c..b6e3b41022 100644 --- a/components/slider/index.js +++ b/components/slider/index.js @@ -23,6 +23,10 @@ export class Slider extends PureComponent { railStyle: PropTypes.shape({}), dotStyle: PropTypes.shape({}), pushable: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]), + disableStartHandle: PropTypes.bool, + disableEndHandle: PropTypes.bool, + playing: PropTypes.bool, + onChange: PropTypes.func, }; static defaultProps = { @@ -44,14 +48,33 @@ export class Slider extends PureComponent { railStyle: { backgroundColor: '#d9d9d9' }, dotStyle: { visibility: 'hidden', border: '0px' }, pushable: true, + disableStartHandle: false, + disableEndHandle: false, + playing: false, + onChange: () => { }, }; renderHandle = (props) => { - const { formatValue, showTooltip } = this.props; + const { formatValue, showTooltip, playing, disableStartHandle, disableEndHandle } = this.props; const { value, dragging, index, ...restProps } = props; const formattedValue = formatValue ? formatValue(value) : value; const tooltipVisible = showTooltip ? showTooltip(index) : false; + // Start handle + if (disableStartHandle && props?.index === 0) { + return null; + } + + // End handle + if (disableEndHandle && props?.index === 2) { + return null; + } + + // Vertical line that indicates the current position, when playing + if (!playing && props?.index === 1) { + return null; + } + return ( { + const { value, disableStartHandle, disableEndHandle, onChange } = this.props; + + // Both handles are disabled, no possible changes can be made. + if (disableStartHandle && disableEndHandle) { + return null; + } + + // Start handle disabled. We allow trim and end value, but keep the start value the same. + if (disableStartHandle) { + onChange([value[0], newValue[1], newValue[2]]) + return null; + } + + // End handle disabled. We allow the start value, but keep the same trim and end value. + if (disableEndHandle) { + onChange([newValue[0], value[1], value[2]]) + return null; + } + + // Full functionality, pass the new values along. + onChange(newValue); + return null; + } + render() { - const { customClass, range, handleStyle, value, ...rest } = this.props; + const { customClass, range, handleStyle, value, onChange, ...rest } = this.props; const Component = range ? Range : RCSlider; const handleNum = Array.isArray(value) ? value.length : 1; @@ -98,6 +146,7 @@ export class Slider extends PureComponent { handle={this.renderHandle} handleStyle={handleStyles} value={value} + onChange={this.handleOnChange} {...rest} /> diff --git a/components/timestep/index.js b/components/timestep/index.js index ce805c3b08..477cc277b6 100644 --- a/components/timestep/index.js +++ b/components/timestep/index.js @@ -39,6 +39,8 @@ class Timestep extends PureComponent { handleOnChange: PropTypes.func, handleOnAfterChange: PropTypes.func, handleOnPlay: PropTypes.func, + disableStartHandle: PropTypes.bool, + disableEndHandle: PropTypes.bool, }; static defaultProps = { @@ -75,6 +77,8 @@ class Timestep extends PureComponent { handleOnChange: null, handleOnAfterChange: null, handleOnPlay: null, + disableStartHandle: false, + disableEndHandle: false, }; constructor(props) { @@ -462,6 +466,8 @@ class Timestep extends PureComponent { range, pushable, PlayButton, + disableStartHandle, + disableEndHandle, } = this.props; const { playing } = this.state; @@ -488,6 +494,9 @@ class Timestep extends PureComponent { pushable={pushable} onChange={this.handleOnChange} onAfterChange={this.handleOnAfterChange} + disableStartHandle={disableStartHandle} + disableEndHandle={disableEndHandle} + playing={playing} /> From 16cda70554753c4c1c32c5116c197f30ec75d9f1 Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Thu, 25 Jul 2024 11:22:08 +0100 Subject: [PATCH 05/54] Tweak slider component variable names to be more descriptive --- components/slider/index.js | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/components/slider/index.js b/components/slider/index.js index b6e3b41022..009a060c6c 100644 --- a/components/slider/index.js +++ b/components/slider/index.js @@ -51,11 +51,17 @@ export class Slider extends PureComponent { disableStartHandle: false, disableEndHandle: false, playing: false, - onChange: () => { }, + onChange: () => {}, }; renderHandle = (props) => { - const { formatValue, showTooltip, playing, disableStartHandle, disableEndHandle } = this.props; + const { + formatValue, + showTooltip, + playing, + disableStartHandle, + disableEndHandle, + } = this.props; const { value, dragging, index, ...restProps } = props; const formattedValue = formatValue ? formatValue(value) : value; const tooltipVisible = showTooltip ? showTooltip(index) : false; @@ -91,8 +97,13 @@ export class Slider extends PureComponent { ); }; - handleOnChange = (newValue) => { - const { value, disableStartHandle, disableEndHandle, onChange } = this.props; + handleOnChange = (newSliderPositions) => { + const { + value: sliderPositions, + disableStartHandle, + disableEndHandle, + onChange, + } = this.props; // Both handles are disabled, no possible changes can be made. if (disableStartHandle && disableEndHandle) { @@ -101,23 +112,28 @@ export class Slider extends PureComponent { // Start handle disabled. We allow trim and end value, but keep the start value the same. if (disableStartHandle) { - onChange([value[0], newValue[1], newValue[2]]) + onChange([ + sliderPositions[0], + newSliderPositions[1], + newSliderPositions[2], + ]); return null; } // End handle disabled. We allow the start value, but keep the same trim and end value. if (disableEndHandle) { - onChange([newValue[0], value[1], value[2]]) + onChange([newSliderPositions[0], sliderPositions[1], sliderPositions[2]]); return null; } // Full functionality, pass the new values along. - onChange(newValue); + onChange(newSliderPositions); return null; - } + }; render() { - const { customClass, range, handleStyle, value, onChange, ...rest } = this.props; + const { customClass, range, handleStyle, value, onChange, ...rest } = + this.props; const Component = range ? Range : RCSlider; const handleNum = Array.isArray(value) ? value.length : 1; From 7460f9df40960c201ddef72ac46ad70a37f92f2a Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 18 Oct 2024 10:00:10 -0300 Subject: [PATCH 06/54] feat(tree-cover): add baselineYear dropdown --- .../forest-change/tree-cover-gain/index.js | 22 +++++++++++++------ .../tree-cover-gain/selectors.js | 5 ++++- components/widgets/options.js | 2 ++ data/baseline-year.js | 22 +++++++++++++++++++ 4 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 data/baseline-year.js diff --git a/components/widgets/forest-change/tree-cover-gain/index.js b/components/widgets/forest-change/tree-cover-gain/index.js index 362668d51a..ab58b26639 100644 --- a/components/widgets/forest-change/tree-cover-gain/index.js +++ b/components/widgets/forest-change/tree-cover-gain/index.js @@ -33,6 +33,13 @@ export default { placeholder: 'All tree cover', clearable: true, }, + { + key: 'baselineYear', + label: 'Baseline Year', + type: 'select', + placeholder: '2000', + clearable: true, + }, { key: 'landCategory', label: 'Land Category', @@ -41,7 +48,7 @@ export default { clearable: true, }, ], - refetchKeys: ['forestType', 'landCategory', 'threshold'], + refetchKeys: ['forestType', 'landCategory', 'threshold', 'baselineYear'], chartType: 'rankedList', colors: 'gain', metaKey: 'umd_tree_cover_gain_from_height', @@ -65,20 +72,21 @@ export default { }, sentences: { globalInitial: - 'From 2000 to 2020, {gain} of tree cover was gained {location}.', + 'From {baselineYear} to 2020, {gain} of tree cover was gained {location}.', globalWithIndicator: - 'From 2000 to 2020, {gain} of tree cover was gained within {indicator} {location}.', + 'From {baselineYear} to 2020, {gain} of tree cover was gained within {indicator} {location}.', initial: - 'From 2000 to 2020, {location} gained {gain} of tree cover equal to {gainPercent} of the global total.', + 'From {baselineYear} to 2020, {location} gained {gain} of tree cover equal to {gainPercent} of the global total.', withIndicator: - 'From 2000 to 2020, {location} gained {gain} of tree cover in {indicator} equal to {gainPercent} of the global total.', + 'From {baselineYear} to 2020, {location} gained {gain} of tree cover in {indicator} equal to {gainPercent} of the global total.', regionInitial: - 'From 2000 to 2020, {location} gained {gain} of tree cover {indicator} equal to {gainPercent} of all tree cover gain in {parent}.', + 'From {baselineYear} to 2020, {location} gained {gain} of tree cover {indicator} equal to {gainPercent} of all tree cover gain in {parent}.', regionWithIndicator: - 'From 2000 to 2020, {location} gained {gain} of tree cover in {indicator} equal to {gainPercent} of all tree cover gain in {parent}.', + 'From {baselineYear} to 2020, {location} gained {gain} of tree cover in {indicator} equal to {gainPercent} of all tree cover gain in {parent}.', }, settings: { threshold: 0, + baselineYear: 2000, unit: 'ha', pageSize: 5, page: 0, diff --git a/components/widgets/forest-change/tree-cover-gain/selectors.js b/components/widgets/forest-change/tree-cover-gain/selectors.js index 3163455707..8c3ef4e1e0 100644 --- a/components/widgets/forest-change/tree-cover-gain/selectors.js +++ b/components/widgets/forest-change/tree-cover-gain/selectors.js @@ -112,6 +112,7 @@ export const parseSentence = createSelector( getSentences, getAdminLevel, getParentLabel, + getSettings, ], ( data, @@ -120,7 +121,8 @@ export const parseSentence = createSelector( currentLabel, sentences, adminLevel, - parentLabel + parentLabel, + settings ) => { if ( !data || @@ -150,6 +152,7 @@ export const parseSentence = createSelector( percent: formatNumber({ num: areaPercent, unit: '%' }), gainPercent: formatNumber({ num: gainPercent, unit: '%' }), parent: parentLabel || null, + baselineYear: settings?.baselineYear || 2000, }; let sentence = indicator ? withIndicator : initial; diff --git a/components/widgets/options.js b/components/widgets/options.js index 6031c8f521..1ed922982d 100644 --- a/components/widgets/options.js +++ b/components/widgets/options.js @@ -1,5 +1,6 @@ import forestType from 'data/forest-types'; import landCategory from 'data/land-categories'; +import baselineYear from 'data/baseline-year'; import threshold from 'data/thresholds.json'; import decile from 'data/deciles.json'; import firesThreshold from 'data/fires-thresholds.json'; @@ -24,6 +25,7 @@ import yearRange from 'data/year-range.json'; export default { forestType: forestType.filter((f) => !f.hidden), landCategory: landCategory.filter((l) => !l.hidden), + baselineYear, threshold, decile, firesThreshold, diff --git a/data/baseline-year.js b/data/baseline-year.js new file mode 100644 index 0000000000..74bd4d8c08 --- /dev/null +++ b/data/baseline-year.js @@ -0,0 +1,22 @@ +export default [ + { + label: '2000', + value: 2000, + }, + { + label: '2005', + value: 2005, + }, + { + label: '2010', + value: 2010, + }, + { + label: '2015', + value: 2015, + }, + { + label: '2020', + value: 2020, + }, +]; From 044ce964a78154365538bf841ab488334fb175a7 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 4 Oct 2024 11:38:13 -0300 Subject: [PATCH 07/54] feat(datasets): update datasets versions --- data/analysis-datasets-versions.json | 58 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/data/analysis-datasets-versions.json b/data/analysis-datasets-versions.json index bdc0547fe4..49c11d7f5a 100644 --- a/data/analysis-datasets-versions.json +++ b/data/analysis-datasets-versions.json @@ -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", @@ -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", From 3a8d34abfac943f8ac1d80036d442b176707d782 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 22 Oct 2024 10:39:09 -0300 Subject: [PATCH 08/54] feat(tree-cover): add baselineYear to the SQL query --- .../forest-change/tree-cover-gain-simple/index.js | 14 ++++++++++++-- .../tree-cover-gain-simple/selectors.js | 6 ++++-- services/analysis-cached.js | 10 +++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/components/widgets/forest-change/tree-cover-gain-simple/index.js b/components/widgets/forest-change/tree-cover-gain-simple/index.js index a11afcca41..317f95da13 100644 --- a/components/widgets/forest-change/tree-cover-gain-simple/index.js +++ b/components/widgets/forest-change/tree-cover-gain-simple/index.js @@ -24,7 +24,7 @@ export default { metaKey: 'umd_tree_cover_gain_from_height', dataType: 'gain', pendingKeys: ['threshold'], - refetchKeys: ['threshold'], + refetchKeys: ['threshold', 'baselineYear'], datasets: [ { dataset: POLITICAL_BOUNDARIES_DATASET, @@ -45,11 +45,21 @@ export default { settings: { threshold: 0, extentYear: 2000, + baselineYear: 2000, }, chartType: 'listLegend', colors: 'gain', sentence: - 'From 2000 to 2020, {location} gained {gain} of tree cover equal to {gainPercent} is its total extent.', + 'From {baselineYear} to 2020, {location} gained {gain} of tree cover equal to {gainPercent} is its total extent in that time period.', + settingsConfig: [ + { + key: 'baselineYear', + label: 'Baseline Year', + type: 'select', + placeholder: '2000', + clearable: true, + }, + ], getData: (params) => { if (shouldQueryPrecomputedTables(params)) { return getGain(params).then((response) => { diff --git a/components/widgets/forest-change/tree-cover-gain-simple/selectors.js b/components/widgets/forest-change/tree-cover-gain-simple/selectors.js index 3ce854c3d9..ac512d80cf 100644 --- a/components/widgets/forest-change/tree-cover-gain-simple/selectors.js +++ b/components/widgets/forest-change/tree-cover-gain-simple/selectors.js @@ -7,10 +7,11 @@ const getExtent = (state) => state.data && state.data.extent; const getSentence = (state) => state.sentence; const getLocationName = (state) => state.locationLabel; const getColors = (state) => state.colors; +const getSettings = (state) => state.settings; export const parseSentence = createSelector( - [getGain, getExtent, getSentence, getLocationName], - (gain, extent, sentence, location) => { + [getGain, getExtent, getSentence, getLocationName, getSettings], + (gain, extent, sentence, location, settings) => { if (!gain && !extent) return null; const gainPerc = (gain && extent && (gain / extent) * 100) || 0; @@ -18,6 +19,7 @@ export const parseSentence = createSelector( gain: formatNumber({ num: gain, unit: 'ha', spaceUnit: true }), gainPercent: formatNumber({ num: gainPerc, unit: '%' }), location, + baselineYear: settings?.baselineYear || 2000, }; return { diff --git a/services/analysis-cached.js b/services/analysis-cached.js index 827ce84830..4a21e4a482 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -36,7 +36,7 @@ const SQL_QUERIES = { carbonFluxOTF: `SELECT SUM("gfw_forest_carbon_net_flux__Mg_CO2e"), SUM("gfw_forest_carbon_gross_removals__Mg_CO2e"), SUM("gfw_forest_carbon_gross_emissions__Mg_CO2e") FROM data WHERE umd_tree_cover_density_2000__threshold >= {threshold} OR is__umd_tree_cover_gain = 'true'&geostore_origin={geostoreOrigin}&geostore_id={geostoreId}`, extent: 'SELECT {select_location}, SUM(umd_tree_cover_extent_{extentYear}__ha) AS umd_tree_cover_extent_{extentYear}__ha, SUM(area__ha) AS area__ha FROM data {WHERE} GROUP BY {location} ORDER BY {location}', - gain: 'SELECT {select_location}, SUM("umd_tree_cover_gain__ha") AS "umd_tree_cover_gain__ha", SUM(umd_tree_cover_extent_2000__ha) AS umd_tree_cover_extent_2000__ha FROM data {WHERE} GROUP BY {location} ORDER BY {location}', + gain: `SELECT {select_location}, SUM("umd_tree_cover_gain__ha") AS "umd_tree_cover_gain__ha", SUM(umd_tree_cover_extent_2000__ha) AS umd_tree_cover_extent_2000__ha FROM data {WHERE} AND umd_tree_cover_gain__period >= '{baselineYear}' GROUP BY {location} ORDER BY {location}`, areaIntersection: 'SELECT {select_location}, SUM(area__ha) AS area__ha {intersection} FROM data {WHERE} GROUP BY {location} {intersection} ORDER BY area__ha DESC', glad: 'SELECT {select_location}, alert__year, alert__week, SUM(alert__count) AS alert__count, SUM(alert_area__ha) AS alert_area__ha FROM data {WHERE} GROUP BY {location}, alert__year, alert__week', @@ -1206,7 +1206,8 @@ export const getExtentGrouped = (params) => { // summed gain for single location export const getGain = (params) => { - const { forestType, landCategory, ifl, download } = params || {}; + const { forestType, landCategory, ifl, download, baselineYear } = + params || {}; const requestUrl = getRequestUrl({ ...params, @@ -1225,6 +1226,7 @@ export const getGain = (params) => { getLocationSelect({ ...params, cast: false }) ) .replace(/{location}/g, getLocationSelect({ ...params })) + .replace('{baselineYear}', baselineYear) .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'annual' })) ); @@ -1252,7 +1254,8 @@ export const getGain = (params) => { // disaggregated gain for child of location export const getGainGrouped = (params) => { - const { forestType, landCategory, ifl, download } = params || {}; + const { forestType, landCategory, ifl, download, baselineYear } = + params || {}; const requestUrl = getRequestUrl({ ...params, @@ -1272,6 +1275,7 @@ export const getGainGrouped = (params) => { /{select_location}/g, getLocationSelect({ ...params, grouped: true, cast: false }) ) + .replace('{baselineYear}', baselineYear) .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'annual' })) ); From bcff20ddb9a341c1ddf76d5ba33b84cb51e19f01 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 22 Oct 2024 10:54:34 -0300 Subject: [PATCH 09/54] feat(tree-cover): add baselineYear dropdown to Location of Tree cover gain widget --- .../forest-change/tree-cover-gain/index.js | 12 ++++++------ .../forest-change/tree-gain-located/index.js | 18 +++++++++++++----- .../tree-gain-located/selectors.js | 9 +++------ 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/components/widgets/forest-change/tree-cover-gain/index.js b/components/widgets/forest-change/tree-cover-gain/index.js index ab58b26639..288739917a 100644 --- a/components/widgets/forest-change/tree-cover-gain/index.js +++ b/components/widgets/forest-change/tree-cover-gain/index.js @@ -34,17 +34,17 @@ export default { clearable: true, }, { - key: 'baselineYear', - label: 'Baseline Year', + key: 'landCategory', + label: 'Land Category', type: 'select', - placeholder: '2000', + placeholder: 'All categories', clearable: true, }, { - key: 'landCategory', - label: 'Land Category', + key: 'baselineYear', + label: 'Baseline Year', type: 'select', - placeholder: 'All categories', + placeholder: '2000', clearable: true, }, ], diff --git a/components/widgets/forest-change/tree-gain-located/index.js b/components/widgets/forest-change/tree-gain-located/index.js index fe11d1c976..25f876d38c 100644 --- a/components/widgets/forest-change/tree-gain-located/index.js +++ b/components/widgets/forest-change/tree-gain-located/index.js @@ -37,8 +37,15 @@ export default { clearable: true, border: true, }, + { + key: 'baselineYear', + label: 'Baseline Year', + type: 'select', + placeholder: '2000', + clearable: true, + }, ], - refetchKeys: ['forestType', 'landCategory'], + refetchKeys: ['forestType', 'landCategory', 'baselineYear'], chartType: 'rankedList', colors: 'gain', datasets: [ @@ -60,13 +67,13 @@ export default { }, sentences: { initial: - 'In {location}, the top {percentileLength} regions were responsible for {topGain} of all tree cover gain between 2000 and 2020. {region} had the most tree cover gain at {value} compared to an average of {average}.', + 'In {location}, the top {percentileLength} were responsible for {topGain}% of all tree cover gain between {baselineYear} and 2020. {region} had the most tree cover gain at {value} compared to an average of {average} in that time period.', withIndicator: - 'For {indicator} in {location}, the top {percentileLength} regions were responsible for {topGain} of all tree cover gain between 2000 and 2020. {region} had the most tree cover gain at {value} compared to an average of {average}.', + 'For {indicator} in {location}, the top {percentileLength} were responsible for {topGain}% of all tree cover gain between {baselineYear} and 2020. {region} had the most tree cover gain at {value} compared to an average of {average} in that time period.', initialPercent: - 'In {location}, the top {percentileLength} regions were responsible for {topGain} of all tree cover gain between 2000 and 2020. {region} had the most relative tree cover gain at {value} compared to an average of {average}.', + 'In {location}, the top {percentileLength} were responsible for {topGain}% of all tree cover gain between {baselineYear} and 2020. {region} had the most tree cover gain at {value} compared to an average of {average} in that time period.', withIndicatorPercent: - 'For {indicator} in {location}, the top {percentileLength} regions were responsible for {topGain} of all tree cover gain between 2000 and 2020. {region} had the most relative tree cover gain at {value} compared to an average of {average}.', + 'For {indicator} in {location}, the top {percentileLength} were responsible for {topGain}% of all tree cover gain between {baselineYear} and 2020. {region} had the most tree cover gain at {value} compared to an average of {average} in that time period.', }, settings: { threshold: 0, @@ -75,6 +82,7 @@ export default { page: 0, extentYear: 2000, ifl: 2000, + baselineYear: 2000, }, getData: (params) => all([getExtentGrouped(params), getGainGrouped(params)]).then( diff --git a/components/widgets/forest-change/tree-gain-located/selectors.js b/components/widgets/forest-change/tree-gain-located/selectors.js index 9a7b29e4ee..8f9475039b 100644 --- a/components/widgets/forest-change/tree-gain-located/selectors.js +++ b/components/widgets/forest-change/tree-gain-located/selectors.js @@ -57,12 +57,8 @@ export const parseSentence = createSelector( ], (data, sortedData, settings, indicator, locationName, sentences) => { if (!data || !locationName) return null; - const { - initial, - withIndicator, - initialPercent, - withIndicatorPercent, - } = sentences; + const { initial, withIndicator, initialPercent, withIndicatorPercent } = + sentences; const totalGain = sumBy(data, 'gain') || 0; const topRegion = (sortedData && sortedData.length && sortedData[0]) || {}; const avgGainPercentage = sumBy(data, 'percentage') || 0 / data.length; @@ -90,6 +86,7 @@ export const parseSentence = createSelector( const aveFormat = avgGain < 1 ? '.3r' : '.3s'; const params = { + baselineYear: settings?.baselineYear || 2000, indicator: indicator && indicator.label, location: locationName, topGain: formatNumber({ From e52cb88a4338d5fcbbb317f714ac2f2aefd6947e Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 22 Oct 2024 10:54:59 -0300 Subject: [PATCH 10/54] chore(tree-cover): set 2000 as default value for baselineYear query --- services/analysis-cached.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/analysis-cached.js b/services/analysis-cached.js index 4a21e4a482..3dcbb6f43b 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -1226,7 +1226,7 @@ export const getGain = (params) => { getLocationSelect({ ...params, cast: false }) ) .replace(/{location}/g, getLocationSelect({ ...params })) - .replace('{baselineYear}', baselineYear) + .replace('{baselineYear}', baselineYear || 2000) .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'annual' })) ); @@ -1275,7 +1275,7 @@ export const getGainGrouped = (params) => { /{select_location}/g, getLocationSelect({ ...params, grouped: true, cast: false }) ) - .replace('{baselineYear}', baselineYear) + .replace('{baselineYear}', baselineYear || 2000) .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'annual' })) ); From 08a1fd9ef4d7f2c39b857cf6f2e9409fc63d908d Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 13 Nov 2024 14:35:13 -0300 Subject: [PATCH 11/54] feat(tree-cover): add baselineYear dropdown to Tree cover gain outside plantations widget --- .../index.js | 18 +++++++++++++----- .../selectors.js | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js index e15028a62a..21ab816f81 100644 --- a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js +++ b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js @@ -43,8 +43,15 @@ export default { clearable: true, blacklist: ['wdpa'], }, + { + key: 'baselineYear', + label: 'Baseline Year', + type: 'select', + placeholder: '2000', + clearable: true, + }, ], - refetchKeys: ['forestType', 'landCategory'], + refetchKeys: ['forestType', 'landCategory', 'baselineYear'], chartType: 'pieChart', colors: 'gainWithinOutsidePlantations', metaKey: 'widget_tree_cover_gain_outside_plantations', @@ -70,19 +77,20 @@ export default { }, sentences: { globalInitial: - 'Globally between 2000 and 2020, {gainPercent} of tree cover gain occurred outside of plantations.', + 'Globally between {baselineYear} and 2020, {gainPercent} of tree cover gain occurred outside of plantations.', globalWithIndicator: - 'Globally between 2000 and 2020, {gainPercent} of tree cover gain within {indicator} occurred outside of plantations.', + 'Globally between {baselineYear} and 2020, {gainPercent} of tree cover within {indicator} gain occurred outside of plantations.', regionInitial: - 'In {location} between 2000 and 2020, {gainPercent} of tree cover gain occurred outside of plantations.', + 'In {location} between {baselineYear} and 2020, {gainPercent} of tree cover gain occurred outside of plantations.', regionWithIndicator: - 'In {location} between 2000 and 2020, {gainPercent} of tree cover gain within {indicator} occurred outside of plantations.', + 'In {location} between {baselineYear} and 2020, {gainPercent} of tree cover gain within {indicator} occurred outside of plantations. ', }, blacklists: { adm0: EuropeFAOCountries, }, settings: { threshold: 0, + baselineYear: 2000, }, getData: (params) => { return getTreeCoverGainByPlantationType(params).then((response) => { diff --git a/components/widgets/forest-change/tree-cover-gain-outside-plantations/selectors.js b/components/widgets/forest-change/tree-cover-gain-outside-plantations/selectors.js index c9283d4023..4ab515e44c 100644 --- a/components/widgets/forest-change/tree-cover-gain-outside-plantations/selectors.js +++ b/components/widgets/forest-change/tree-cover-gain-outside-plantations/selectors.js @@ -46,6 +46,7 @@ export const parseSentence = createSelector( indicator: indicator && indicator.label, startYear: settings.startYear, endYear: settings.endYear, + baselineYear: settings?.baselineYear || 2000, gainPercent: formatNumber({ num: (100 * data?.areaOutsidePlantations) / data?.totalArea, unit: '%', From 74dbf7751963eb23b48b14d30e346286899205f1 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 14 Nov 2024 14:34:03 -0300 Subject: [PATCH 12/54] fix(query): add baseline year to tree cover gain by plantation type --- .../tree-cover-gain-outside-plantations/index.js | 2 +- services/analysis-cached.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js index 21ab816f81..b2449969e7 100644 --- a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js +++ b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js @@ -79,7 +79,7 @@ export default { globalInitial: 'Globally between {baselineYear} and 2020, {gainPercent} of tree cover gain occurred outside of plantations.', globalWithIndicator: - 'Globally between {baselineYear} and 2020, {gainPercent} of tree cover within {indicator} gain occurred outside of plantations.', + 'Globally between {baselineYear} and 2020, {gainPercent} of tree cover gain within {indicator} occurred outside of plantations.', regionInitial: 'In {location} between {baselineYear} and 2020, {gainPercent} of tree cover gain occurred outside of plantations.', regionWithIndicator: diff --git a/services/analysis-cached.js b/services/analysis-cached.js index 3dcbb6f43b..52f3e3b35f 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -77,7 +77,7 @@ const SQL_QUERIES = { 'SELECT {select_location}, SUM("whrc_aboveground_biomass_stock_2000__Mg") AS "whrc_aboveground_biomass_stock_2000__Mg", SUM("whrc_aboveground_co2_stock_2000__Mg") AS "whrc_aboveground_co2_stock_2000__Mg", SUM(umd_tree_cover_extent_2000__ha) AS umd_tree_cover_extent_2000__ha FROM data {WHERE} GROUP BY {location} ORDER BY {location}', organicSoilCarbonGrouped: 'SELECT {select_location}, CASE WHEN SUM("umd_tree_cover_extent_2000__ha") = 0 THEN NULL ELSE SUM("gfw_soil_carbon_stocks_2000__Mg_C") END AS "gfw_soil_carbon_stocks_2000__Mg_C", CASE WHEN SUM("umd_tree_cover_extent_2000__ha") = 0 THEN NULL ELSE SUM("gfw_soil_carbon_stocks_2000__Mg_C") / SUM("umd_tree_cover_extent_2000__ha") END AS soil_carbon_density__t_ha FROM data {WHERE} GROUP BY {location} ORDER BY {location}', - treeCoverGainByPlantationType: `SELECT CASE WHEN gfw_planted_forests__type IS NULL THEN 'Outside of Plantations' ELSE gfw_planted_forests__type END AS plantation_type, SUM(umd_tree_cover_gain__ha) as gain_area_ha FROM data {WHERE} GROUP BY gfw_planted_forests__type`, + treeCoverGainByPlantationType: `SELECT CASE WHEN gfw_planted_forests__type IS NULL THEN 'Outside of Plantations' ELSE gfw_planted_forests__type END AS plantation_type, SUM(umd_tree_cover_gain__ha) as gain_area_ha FROM data {WHERE} AND umd_tree_cover_gain__period >= '{baselineYear}' GROUP BY gfw_planted_forests__type`, treeCoverOTF: 'SELECT SUM(area__ha) FROM data WHERE umd_tree_cover_density_2000__threshold >= {threshold}&geostore_id={geostoreId}', treeCoverOTFExtent: 'SELECT SUM(area__ha) FROM data&geostore_id={geostoreId}', @@ -890,13 +890,12 @@ export const getLossFiresGrouped = (params) => { }; export const getTreeCoverGainByPlantationType = (params) => { - const { forestType, landCategory, ifl, download } = params; + const { forestType, landCategory, ifl, download, baselineYear } = params; const requestUrl = getRequestUrl({ ...params, dataset: 'annual', datasetType: 'summary', - version: 'v20221012', }); if (!requestUrl) return new Promise(() => {}); @@ -904,7 +903,9 @@ export const getTreeCoverGainByPlantationType = (params) => { const sqlQuery = SQL_QUERIES.treeCoverGainByPlantationType; const url = encodeURI( - `${requestUrl}${sqlQuery}`.replace('{WHERE}', getWHEREQuery({ ...params })) + `${requestUrl}${sqlQuery}` + .replace('{baselineYear}', baselineYear || 2000) + .replace('{WHERE}', getWHEREQuery({ ...params })) ); if (download) { From 7505fe2d10897003fb50b338d30253f9e45c8367 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 13 Nov 2024 16:15:21 -0300 Subject: [PATCH 13/54] feat(tree-cover): validate if data is empty --- .../forest-change/tree-cover-gain-outside-plantations/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js index b2449969e7..40464e6459 100644 --- a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js +++ b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js @@ -96,6 +96,8 @@ export default { return getTreeCoverGainByPlantationType(params).then((response) => { const { data } = (response && response.data) || {}; + if (data?.length === 0) return null; + const totalArea = data.reduce( (prev, curr) => prev + curr?.gain_area_ha, 0 From 54aea5983764199526534c9f6a791c3b50cf6893 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 13 Nov 2024 16:17:48 -0300 Subject: [PATCH 14/54] chore(selector): encapsulate settings.baselineYear to the params object --- .../widgets/forest-change/tree-cover-gain-simple/selectors.js | 2 +- components/widgets/forest-change/tree-cover-gain/selectors.js | 2 +- components/widgets/forest-change/tree-gain-located/selectors.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/widgets/forest-change/tree-cover-gain-simple/selectors.js b/components/widgets/forest-change/tree-cover-gain-simple/selectors.js index ac512d80cf..491290e1f0 100644 --- a/components/widgets/forest-change/tree-cover-gain-simple/selectors.js +++ b/components/widgets/forest-change/tree-cover-gain-simple/selectors.js @@ -19,7 +19,7 @@ export const parseSentence = createSelector( gain: formatNumber({ num: gain, unit: 'ha', spaceUnit: true }), gainPercent: formatNumber({ num: gainPerc, unit: '%' }), location, - baselineYear: settings?.baselineYear || 2000, + baselineYear: (settings?.baselineYear) || 2000, }; return { diff --git a/components/widgets/forest-change/tree-cover-gain/selectors.js b/components/widgets/forest-change/tree-cover-gain/selectors.js index 8c3ef4e1e0..6dc86b906b 100644 --- a/components/widgets/forest-change/tree-cover-gain/selectors.js +++ b/components/widgets/forest-change/tree-cover-gain/selectors.js @@ -152,7 +152,7 @@ export const parseSentence = createSelector( percent: formatNumber({ num: areaPercent, unit: '%' }), gainPercent: formatNumber({ num: gainPercent, unit: '%' }), parent: parentLabel || null, - baselineYear: settings?.baselineYear || 2000, + baselineYear: (settings?.baselineYear) || 2000, }; let sentence = indicator ? withIndicator : initial; diff --git a/components/widgets/forest-change/tree-gain-located/selectors.js b/components/widgets/forest-change/tree-gain-located/selectors.js index 8f9475039b..8ea4c3ac2a 100644 --- a/components/widgets/forest-change/tree-gain-located/selectors.js +++ b/components/widgets/forest-change/tree-gain-located/selectors.js @@ -86,7 +86,7 @@ export const parseSentence = createSelector( const aveFormat = avgGain < 1 ? '.3r' : '.3s'; const params = { - baselineYear: settings?.baselineYear || 2000, + baselineYear: (settings?.baselineYear) || 2000, indicator: indicator && indicator.label, location: locationName, topGain: formatNumber({ From 4601297ae0fa35de8f91c08393ab1596c258619e Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 15 Nov 2024 11:06:51 -0300 Subject: [PATCH 15/54] fix(baseline-year): remove 2020 --- data/baseline-year.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/data/baseline-year.js b/data/baseline-year.js index 74bd4d8c08..41b0342b9f 100644 --- a/data/baseline-year.js +++ b/data/baseline-year.js @@ -15,8 +15,4 @@ export default [ label: '2015', value: 2015, }, - { - label: '2020', - value: 2020, - }, ]; From bbd3f3bb4e4ebb0546c558dd462f38015c252c82 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 15 Nov 2024 11:24:51 -0300 Subject: [PATCH 16/54] chore(envs): Split RW and GFW API's keys to make it more flexible Now we can set each API separatedly, making it easier to test different environments at once --- pages/api/metadata/[...params].js | 2 +- providers/datasets-provider/actions.js | 2 +- services/datasets.js | 2 +- services/shape.js | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pages/api/metadata/[...params].js b/pages/api/metadata/[...params].js index f9e4816f09..92ce9c4962 100644 --- a/pages/api/metadata/[...params].js +++ b/pages/api/metadata/[...params].js @@ -1,7 +1,7 @@ import { GFW_METADATA_API, GFW_STAGING_METADATA_API } from 'utils/apis'; import axios from 'axios'; -const ENVIRONMENT = process.env.NEXT_PUBLIC_FEATURE_ENV; +const ENVIRONMENT = process.env.NEXT_PUBLIC_RW_FEATURE_ENV; const GFW_METADATA_API_URL = ENVIRONMENT === 'staging' ? GFW_STAGING_METADATA_API : GFW_METADATA_API; diff --git a/providers/datasets-provider/actions.js b/providers/datasets-provider/actions.js index 9ea6315404..b56bc30bf9 100644 --- a/providers/datasets-provider/actions.js +++ b/providers/datasets-provider/actions.js @@ -14,7 +14,7 @@ export const setDatasets = createAction('setDatasets'); export const setDatasetsWithMetadata = createAction('setDatasetsWithMetadata'); const handleFeatureEnvLock = (env) => { - const currEnv = process.env.NEXT_PUBLIC_FEATURE_ENV; + const currEnv = process.env.NEXT_PUBLIC_RW_FEATURE_ENV; const MIXED_ENV = 'preproduction-staging'; if (env === MIXED_ENV && currEnv !== 'production') { return true; diff --git a/services/datasets.js b/services/datasets.js index 4d1b819d71..a7ff3012f6 100644 --- a/services/datasets.js +++ b/services/datasets.js @@ -1,7 +1,7 @@ import { rwRequest, dataRequest } from 'utils/request'; const environmentString = () => { - const env = process.env.NEXT_PUBLIC_FEATURE_ENV; + const env = process.env.NEXT_PUBLIC_RW_FEATURE_ENV; let envString = 'production'; if (env === 'preproduction') { envString += ',preproduction'; diff --git a/services/shape.js b/services/shape.js index 003208f9c7..d859860ac8 100644 --- a/services/shape.js +++ b/services/shape.js @@ -3,7 +3,9 @@ import request from 'utils/request'; import { GFW_API, GFW_STAGING_API } from 'utils/apis'; const GFW_API_URL = - process.env.NEXT_PUBLIC_FEATURE_ENV === 'staging' ? GFW_STAGING_API : GFW_API; + process.env.NEXT_PUBLIC_RW_FEATURE_ENV === 'staging' + ? GFW_STAGING_API + : GFW_API; const QUERIES = { ogrConvert: '/v2/ogr/convert', From e33204e564fa154d97b1dcdf69794b5db62d861c Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 12 Nov 2024 14:09:43 -0300 Subject: [PATCH 17/54] chore(sentence): remove the bold formatting from the word 'and' used to separate indicators --- components/ui/dynamic-sentence/component.jsx | 11 ++++++----- components/ui/dynamic-sentence/styles.scss | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/components/ui/dynamic-sentence/component.jsx b/components/ui/dynamic-sentence/component.jsx index a5328c431b..0a44dbc225 100644 --- a/components/ui/dynamic-sentence/component.jsx +++ b/components/ui/dynamic-sentence/component.jsx @@ -49,13 +49,14 @@ class DynamicSentence extends PureComponent { } } else { // eslint-disable-next-line security/detect-non-literal-regexp - const regex = new RegExp(`{${p}}`, 'g'); + const DYNAMIC_PARAMETERS = new RegExp(`{${p}}`, 'g'); + const AND = new RegExp(`\\band\\b`, 'g'); // regex to remove the bold from the word 'and' between indicators + formattedSentence = formattedSentence && - formattedSentence.replace( - regex, - `${translateText(param)}` - ); + formattedSentence + .replace(DYNAMIC_PARAMETERS, `${translateText(param)}`) + .replace(AND, `and`); } } }); diff --git a/components/ui/dynamic-sentence/styles.scss b/components/ui/dynamic-sentence/styles.scss index 6fa5496519..176e13efa9 100644 --- a/components/ui/dynamic-sentence/styles.scss +++ b/components/ui/dynamic-sentence/styles.scss @@ -7,6 +7,10 @@ font-size: 20px; color: $slate; + .no-bold { + font-weight: 300 !important; + } + strong, b, span { From 9091af78e61abd79f4221e3a77f761fcba588576 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 13 Nov 2024 15:21:59 -0300 Subject: [PATCH 18/54] fix(sentence): add placeholder instead of the word and to avoid set bold for parameters separator --- components/ui/dynamic-sentence/component.jsx | 4 ++-- components/widgets/utils/config.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/ui/dynamic-sentence/component.jsx b/components/ui/dynamic-sentence/component.jsx index 0a44dbc225..006692bff3 100644 --- a/components/ui/dynamic-sentence/component.jsx +++ b/components/ui/dynamic-sentence/component.jsx @@ -50,13 +50,13 @@ class DynamicSentence extends PureComponent { } else { // eslint-disable-next-line security/detect-non-literal-regexp const DYNAMIC_PARAMETERS = new RegExp(`{${p}}`, 'g'); - const AND = new RegExp(`\\band\\b`, 'g'); // regex to remove the bold from the word 'and' between indicators + const PLACEHOLDER = new RegExp(`\\bPLACEHOLDER\\b`, 'g'); // regex to remove the bold from the word 'and' between indicators formattedSentence = formattedSentence && formattedSentence .replace(DYNAMIC_PARAMETERS, `${translateText(param)}`) - .replace(AND, `and`); + .replace(PLACEHOLDER, `and`); } } }); diff --git a/components/widgets/utils/config.js b/components/widgets/utils/config.js index 9481fd6a56..bbd26ce5f4 100644 --- a/components/widgets/utils/config.js +++ b/components/widgets/utils/config.js @@ -177,7 +177,7 @@ export const getIndicator = (forestType, landCategory) => { : landCatLabel.toLowerCase(); if (forestType && landCategory) { - label = `${forestTypeLabel} and ${landCatLabel}`; + label = `${forestTypeLabel} PLACEHOLDER ${landCatLabel}`; value = `${forestType.value}__${landCategory.value}`; } else if (landCategory) { label = landCatLabel; From ac9942193d30e120b11dcd5def492702fafabb18 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 15 Nov 2024 15:35:45 -0300 Subject: [PATCH 19/54] fix(layer): set the correct dataset_slug to the widget --- data/datasets.js | 2 +- data/layers.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/datasets.js b/data/datasets.js index ca9eea2d3d..fe66dbfe4f 100644 --- a/data/datasets.js +++ b/data/datasets.js @@ -10,7 +10,7 @@ export const INTEGRATED_DEFORESTATION_ALERTS = export const GLAD_S2_DEFORESTATION_ALERTS_DATASET = 'glad-s2-deforestation-alerts'; export const RADD_DEFORESTATION_ALERTS_DATASET = 'radd-deforestation-alerts'; -export const FOREST_GAIN_DATASET = 'tree-cover-gain'; +export const FOREST_GAIN_DATASET = 'tree-cover-gain-5y'; export const FOREST_EXTENT_DATASET = 'tree-cover'; export const BIOMASS_LOSS_DATASET = 'carbon-dioxide-emissions-from-tree-cover-loss'; diff --git a/data/layers.js b/data/layers.js index 28b73186fb..06a3a33760 100644 --- a/data/layers.js +++ b/data/layers.js @@ -1,6 +1,6 @@ export const DISPUTED_POLITICAL_BOUNDARIES = 'disputed-political-boundaries'; export const POLITICAL_BOUNDARIES = 'political-boundaries'; -export const FOREST_GAIN = 'tree-cover-gain-2001-2020'; +export const FOREST_GAIN = 'tree-cover-gain-5y'; export const FOREST_LOSS = 'tree-cover-loss'; export const FOREST_LOSS_FIRES = 'tree-cover-loss-fires'; export const NET_CHANGE = 'forest-net-change'; From b40b014651ce5798da1bc576ef3f67c9234f6aee Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 19 Nov 2024 18:40:07 -0300 Subject: [PATCH 20/54] fix(baseline-year): get startYear instead of baseline year for analysis --- components/widgets/forest-change/tree-cover-gain/index.js | 7 +++++-- .../widgets/forest-change/tree-cover-gain/selectors.js | 4 +++- services/analysis-cached.js | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/components/widgets/forest-change/tree-cover-gain/index.js b/components/widgets/forest-change/tree-cover-gain/index.js index 288739917a..d0041be960 100644 --- a/components/widgets/forest-change/tree-cover-gain/index.js +++ b/components/widgets/forest-change/tree-cover-gain/index.js @@ -14,6 +14,8 @@ import { import getWidgetProps from './selectors'; +const MIN_YEAR = 2000; + export default { widget: 'treeCoverGain', title: { @@ -44,7 +46,7 @@ export default { key: 'baselineYear', label: 'Baseline Year', type: 'select', - placeholder: '2000', + placeholder: MIN_YEAR, clearable: true, }, ], @@ -86,7 +88,7 @@ export default { }, settings: { threshold: 0, - baselineYear: 2000, + baselineYear: MIN_YEAR, unit: 'ha', pageSize: 5, page: 0, @@ -99,6 +101,7 @@ export default { adm1: adm1 && !adm2 ? null : adm1, adm2: null, }; + return all([getGainGrouped({ ...rest, ...parentLocation })]).then( spread((gainResponse) => { let groupKey = 'iso'; diff --git a/components/widgets/forest-change/tree-cover-gain/selectors.js b/components/widgets/forest-change/tree-cover-gain/selectors.js index 6dc86b906b..74cb3d95d3 100644 --- a/components/widgets/forest-change/tree-cover-gain/selectors.js +++ b/components/widgets/forest-change/tree-cover-gain/selectors.js @@ -144,6 +144,8 @@ export const parseSentence = createSelector( const gain = locationData ? locationData.gain : sumBy(data, 'gain') || 0; const gainPercent = gain ? (100 * gain) / sumBy(data, 'gain') || 0 : 0; const areaPercent = (locationData && locationData.percentage) || 0; + const { baselineYear: dateFromDashboard, startYear: dateFromMapLayer } = + settings; const params = { location: currentLabel === 'global' ? 'globally' : currentLabel, @@ -152,7 +154,7 @@ export const parseSentence = createSelector( percent: formatNumber({ num: areaPercent, unit: '%' }), gainPercent: formatNumber({ num: gainPercent, unit: '%' }), parent: parentLabel || null, - baselineYear: (settings?.baselineYear) || 2000, + baselineYear: dateFromMapLayer || dateFromDashboard || 2000, }; let sentence = indicator ? withIndicator : initial; diff --git a/services/analysis-cached.js b/services/analysis-cached.js index 52f3e3b35f..8255c17915 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -1255,7 +1255,7 @@ export const getGain = (params) => { // disaggregated gain for child of location export const getGainGrouped = (params) => { - const { forestType, landCategory, ifl, download, baselineYear } = + const { forestType, landCategory, ifl, download, baselineYear, startYear } = params || {}; const requestUrl = getRequestUrl({ @@ -1276,7 +1276,7 @@ export const getGainGrouped = (params) => { /{select_location}/g, getLocationSelect({ ...params, grouped: true, cast: false }) ) - .replace('{baselineYear}', baselineYear || 2000) + .replace('{baselineYear}', startYear || baselineYear || 2000) .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'annual' })) ); From bd39ad6c938f2e77c5d481f67070ce9af3095c35 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 19 Nov 2024 19:42:25 -0300 Subject: [PATCH 21/54] feat(baseline-year): add new case for baseline year dropdown --- .../components/widget-settings/component.jsx | 30 ++++++++++++++++--- .../forest-change/tree-cover-gain/index.js | 15 ++++++++-- services/analysis-cached.js | 5 ++-- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/components/widget/components/widget-header/components/widget-settings/component.jsx b/components/widget/components/widget-header/components/widget-settings/component.jsx index e08d77bffd..e14dedee29 100644 --- a/components/widget/components/widget-header/components/widget-settings/component.jsx +++ b/components/widget/components/widget-header/components/widget-settings/component.jsx @@ -98,7 +98,29 @@ class WidgetSettings extends PureComponent { /> ); - + case 'baseline-select': + return ( + options && + !!options.length && ( + + propagateChange({ [startKey]: change && change.value })} + disabled={loading} + clearable={clearable} + infoAction={metaKey ? () => handleShowInfo(metaKey) : null} + optionsAction={handleShowInfo} + optionsActionKey="metaKey" + noSelectedValue={placeholder} + /> + ) + ); case 'compare-select': return (
@@ -120,7 +142,7 @@ class WidgetSettings extends PureComponent { const loadingDatepicker = !startValue || !minDate || !maxDate; return ( -
+
From @@ -130,7 +152,7 @@ class WidgetSettings extends PureComponent { selected={new Date(startValue)} onChange={(change) => propagateChange({ - [startKey]: moment(change).format("YYYY-MM-DD"), + [startKey]: moment(change).format('YYYY-MM-DD'), })} minDate={new Date(minDate)} maxDate={new Date(maxDate)} @@ -146,7 +168,7 @@ class WidgetSettings extends PureComponent { selected={new Date(endValue)} onChange={(change) => propagateChange({ - [endKey]: moment(change).format("YYYY-MM-DD"), + [endKey]: moment(change).format('YYYY-MM-DD'), })} minDate={new Date(minDate)} maxDate={new Date(maxDate)} diff --git a/components/widgets/forest-change/tree-cover-gain/index.js b/components/widgets/forest-change/tree-cover-gain/index.js index d0041be960..3e5d93f97d 100644 --- a/components/widgets/forest-change/tree-cover-gain/index.js +++ b/components/widgets/forest-change/tree-cover-gain/index.js @@ -45,12 +45,20 @@ export default { { key: 'baselineYear', label: 'Baseline Year', - type: 'select', + type: 'baseline-select', + startKey: 'startYear', + endKey: 2020, placeholder: MIN_YEAR, clearable: true, }, ], - refetchKeys: ['forestType', 'landCategory', 'threshold', 'baselineYear'], + refetchKeys: [ + 'forestType', + 'landCategory', + 'threshold', + 'baselineYear', + 'startYear', + ], chartType: 'rankedList', colors: 'gain', metaKey: 'umd_tree_cover_gain_from_height', @@ -88,7 +96,8 @@ export default { }, settings: { threshold: 0, - baselineYear: MIN_YEAR, + startYear: MIN_YEAR, + endYear: 2020, unit: 'ha', pageSize: 5, page: 0, diff --git a/services/analysis-cached.js b/services/analysis-cached.js index 8255c17915..e5d035b602 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -1255,8 +1255,7 @@ export const getGain = (params) => { // disaggregated gain for child of location export const getGainGrouped = (params) => { - const { forestType, landCategory, ifl, download, baselineYear, startYear } = - params || {}; + const { forestType, landCategory, ifl, download, startYear } = params || {}; const requestUrl = getRequestUrl({ ...params, @@ -1276,7 +1275,7 @@ export const getGainGrouped = (params) => { /{select_location}/g, getLocationSelect({ ...params, grouped: true, cast: false }) ) - .replace('{baselineYear}', startYear || baselineYear || 2000) + .replace('{baselineYear}', startYear || 2000) .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'annual' })) ); From cf79bf5d6e54394db1c691a1588b1c8537a39651 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 20 Nov 2024 11:35:30 -0300 Subject: [PATCH 22/54] feat(baseline-year): use startYear instead of baselineYear to be able to sync with the map --- .../tree-cover-gain-outside-plantations/index.js | 12 ++++++++---- .../tree-cover-gain-outside-plantations/selectors.js | 5 ++++- .../forest-change/tree-cover-gain-simple/index.js | 12 ++++++++---- .../tree-cover-gain-simple/selectors.js | 4 +++- .../widgets/forest-change/tree-cover-gain/index.js | 11 ++--------- .../widgets/forest-change/tree-gain-located/index.js | 12 ++++++++---- .../forest-change/tree-gain-located/selectors.js | 6 +++++- services/analysis-cached.js | 9 ++++----- 8 files changed, 42 insertions(+), 29 deletions(-) diff --git a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js index 40464e6459..293d68203c 100644 --- a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js +++ b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js @@ -16,6 +16,8 @@ import { EuropeFAOCountries } from 'utils/fao-countries'; import getWidgetProps from './selectors'; +const MIN_YEAR = 2000; + export default { widget: 'treeCoverGainOutsidePlantations', title: { @@ -46,12 +48,13 @@ export default { { key: 'baselineYear', label: 'Baseline Year', - type: 'select', - placeholder: '2000', + type: 'baseline-select', + startKey: 'startYear', + placeholder: MIN_YEAR, clearable: true, }, ], - refetchKeys: ['forestType', 'landCategory', 'baselineYear'], + refetchKeys: ['forestType', 'landCategory', 'startYear'], chartType: 'pieChart', colors: 'gainWithinOutsidePlantations', metaKey: 'widget_tree_cover_gain_outside_plantations', @@ -90,7 +93,8 @@ export default { }, settings: { threshold: 0, - baselineYear: 2000, + startYear: MIN_YEAR, + endYear: 2020, // reference to display the correct data on the map }, getData: (params) => { return getTreeCoverGainByPlantationType(params).then((response) => { diff --git a/components/widgets/forest-change/tree-cover-gain-outside-plantations/selectors.js b/components/widgets/forest-change/tree-cover-gain-outside-plantations/selectors.js index 4ab515e44c..fa289b6e83 100644 --- a/components/widgets/forest-change/tree-cover-gain-outside-plantations/selectors.js +++ b/components/widgets/forest-change/tree-cover-gain-outside-plantations/selectors.js @@ -41,12 +41,15 @@ export const parseSentence = createSelector( } })(); + const { baselineYear: dateFromDashboard, startYear: dateFromMapLayer } = + settings; + const params = { location: locationName, indicator: indicator && indicator.label, startYear: settings.startYear, endYear: settings.endYear, - baselineYear: settings?.baselineYear || 2000, + baselineYear: dateFromMapLayer || dateFromDashboard || 2000, gainPercent: formatNumber({ num: (100 * data?.areaOutsidePlantations) / data?.totalArea, unit: '%', diff --git a/components/widgets/forest-change/tree-cover-gain-simple/index.js b/components/widgets/forest-change/tree-cover-gain-simple/index.js index 317f95da13..12ceb291cc 100644 --- a/components/widgets/forest-change/tree-cover-gain-simple/index.js +++ b/components/widgets/forest-change/tree-cover-gain-simple/index.js @@ -14,6 +14,8 @@ import { import getWidgetProps from './selectors'; +const MIN_YEAR = 2000; + export default { widget: 'treeCoverGainSimple', title: 'Tree cover gain in {location}', @@ -24,7 +26,7 @@ export default { metaKey: 'umd_tree_cover_gain_from_height', dataType: 'gain', pendingKeys: ['threshold'], - refetchKeys: ['threshold', 'baselineYear'], + refetchKeys: ['threshold', 'startYear'], datasets: [ { dataset: POLITICAL_BOUNDARIES_DATASET, @@ -45,7 +47,8 @@ export default { settings: { threshold: 0, extentYear: 2000, - baselineYear: 2000, + startYear: MIN_YEAR, + endYear: 2020, // reference to display the correct data on the map }, chartType: 'listLegend', colors: 'gain', @@ -55,8 +58,9 @@ export default { { key: 'baselineYear', label: 'Baseline Year', - type: 'select', - placeholder: '2000', + type: 'baseline-select', + startKey: 'startYear', + placeholder: MIN_YEAR, clearable: true, }, ], diff --git a/components/widgets/forest-change/tree-cover-gain-simple/selectors.js b/components/widgets/forest-change/tree-cover-gain-simple/selectors.js index 491290e1f0..ad841a570e 100644 --- a/components/widgets/forest-change/tree-cover-gain-simple/selectors.js +++ b/components/widgets/forest-change/tree-cover-gain-simple/selectors.js @@ -14,12 +14,14 @@ export const parseSentence = createSelector( (gain, extent, sentence, location, settings) => { if (!gain && !extent) return null; const gainPerc = (gain && extent && (gain / extent) * 100) || 0; + const { baselineYear: dateFromDashboard, startYear: dateFromMapLayer } = + settings; const params = { gain: formatNumber({ num: gain, unit: 'ha', spaceUnit: true }), gainPercent: formatNumber({ num: gainPerc, unit: '%' }), location, - baselineYear: (settings?.baselineYear) || 2000, + baselineYear: dateFromMapLayer || dateFromDashboard || 2000, }; return { diff --git a/components/widgets/forest-change/tree-cover-gain/index.js b/components/widgets/forest-change/tree-cover-gain/index.js index 3e5d93f97d..6d06465504 100644 --- a/components/widgets/forest-change/tree-cover-gain/index.js +++ b/components/widgets/forest-change/tree-cover-gain/index.js @@ -47,18 +47,11 @@ export default { label: 'Baseline Year', type: 'baseline-select', startKey: 'startYear', - endKey: 2020, placeholder: MIN_YEAR, clearable: true, }, ], - refetchKeys: [ - 'forestType', - 'landCategory', - 'threshold', - 'baselineYear', - 'startYear', - ], + refetchKeys: ['forestType', 'landCategory', 'threshold', 'startYear'], chartType: 'rankedList', colors: 'gain', metaKey: 'umd_tree_cover_gain_from_height', @@ -97,7 +90,7 @@ export default { settings: { threshold: 0, startYear: MIN_YEAR, - endYear: 2020, + endYear: 2020, // reference to display the correct data on the map unit: 'ha', pageSize: 5, page: 0, diff --git a/components/widgets/forest-change/tree-gain-located/index.js b/components/widgets/forest-change/tree-gain-located/index.js index 25f876d38c..332a23d17a 100644 --- a/components/widgets/forest-change/tree-gain-located/index.js +++ b/components/widgets/forest-change/tree-gain-located/index.js @@ -13,6 +13,8 @@ import { import getWidgetProps from './selectors'; +const MIN_YEAR = 2000; + export default { widget: 'treeGainLocated', title: 'Location of tree cover gain in {location}', @@ -40,12 +42,13 @@ export default { { key: 'baselineYear', label: 'Baseline Year', - type: 'select', - placeholder: '2000', + type: 'baseline-select', + startKey: 'startYear', + placeholder: MIN_YEAR, clearable: true, }, ], - refetchKeys: ['forestType', 'landCategory', 'baselineYear'], + refetchKeys: ['forestType', 'landCategory', 'startYear'], chartType: 'rankedList', colors: 'gain', datasets: [ @@ -82,7 +85,8 @@ export default { page: 0, extentYear: 2000, ifl: 2000, - baselineYear: 2000, + startYear: MIN_YEAR, + endYear: 2020, // reference to display the correct data on the map }, getData: (params) => all([getExtentGrouped(params), getGainGrouped(params)]).then( diff --git a/components/widgets/forest-change/tree-gain-located/selectors.js b/components/widgets/forest-change/tree-gain-located/selectors.js index 8ea4c3ac2a..55f3ef8f43 100644 --- a/components/widgets/forest-change/tree-gain-located/selectors.js +++ b/components/widgets/forest-change/tree-gain-located/selectors.js @@ -57,12 +57,16 @@ export const parseSentence = createSelector( ], (data, sortedData, settings, indicator, locationName, sentences) => { if (!data || !locationName) return null; + const { initial, withIndicator, initialPercent, withIndicatorPercent } = sentences; const totalGain = sumBy(data, 'gain') || 0; const topRegion = (sortedData && sortedData.length && sortedData[0]) || {}; const avgGainPercentage = sumBy(data, 'percentage') || 0 / data.length; const avgGain = (sumBy(data, 'gain') || 0) / data.length; + const { baselineYear: dateFromDashboard, startYear: dateFromMapLayer } = + settings; + let percentileGain = 0; let percentileLength = 0; @@ -86,7 +90,7 @@ export const parseSentence = createSelector( const aveFormat = avgGain < 1 ? '.3r' : '.3s'; const params = { - baselineYear: (settings?.baselineYear) || 2000, + baselineYear: dateFromMapLayer || dateFromDashboard || 2000, indicator: indicator && indicator.label, location: locationName, topGain: formatNumber({ diff --git a/services/analysis-cached.js b/services/analysis-cached.js index e5d035b602..f5ac3608a5 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -890,7 +890,7 @@ export const getLossFiresGrouped = (params) => { }; export const getTreeCoverGainByPlantationType = (params) => { - const { forestType, landCategory, ifl, download, baselineYear } = params; + const { forestType, landCategory, ifl, download, startYear } = params; const requestUrl = getRequestUrl({ ...params, @@ -904,7 +904,7 @@ export const getTreeCoverGainByPlantationType = (params) => { const url = encodeURI( `${requestUrl}${sqlQuery}` - .replace('{baselineYear}', baselineYear || 2000) + .replace('{baselineYear}', startYear || 2000) .replace('{WHERE}', getWHEREQuery({ ...params })) ); @@ -1207,8 +1207,7 @@ export const getExtentGrouped = (params) => { // summed gain for single location export const getGain = (params) => { - const { forestType, landCategory, ifl, download, baselineYear } = - params || {}; + const { forestType, landCategory, ifl, download, startYear } = params || {}; const requestUrl = getRequestUrl({ ...params, @@ -1227,7 +1226,7 @@ export const getGain = (params) => { getLocationSelect({ ...params, cast: false }) ) .replace(/{location}/g, getLocationSelect({ ...params })) - .replace('{baselineYear}', baselineYear || 2000) + .replace('{baselineYear}', startYear || 2000) .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'annual' })) ); From 5684ac33d2ca5c92e94e6f5681b2e4cdde4325fe Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 11:18:28 -0300 Subject: [PATCH 23/54] feat(tree-cover): change tree cover by type name to tree coover --- components/widgets/land-cover/tree-cover/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/widgets/land-cover/tree-cover/index.js b/components/widgets/land-cover/tree-cover/index.js index ad5415a613..ad4af68e0a 100644 --- a/components/widgets/land-cover/tree-cover/index.js +++ b/components/widgets/land-cover/tree-cover/index.js @@ -24,9 +24,8 @@ import getWidgetProps from './selectors'; export default { widget: 'treeCover', title: { - default: 'Tree Cover by type in {location}', - global: 'Global tree cover by type', - withPlantations: 'Forest cover by type in {location}', + default: 'Tree Cover in {location}', + global: 'Global tree cover', }, alerts: [ { From 4751a89ebfc86b67506f2483b9277859a1fc63e4 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 11:27:18 -0300 Subject: [PATCH 24/54] feat(tree-cover): add plantations intersection --- .../widgets/land-cover/tree-cover/index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/components/widgets/land-cover/tree-cover/index.js b/components/widgets/land-cover/tree-cover/index.js index ad4af68e0a..c710603369 100644 --- a/components/widgets/land-cover/tree-cover/index.js +++ b/components/widgets/land-cover/tree-cover/index.js @@ -108,7 +108,13 @@ export default { summary: 4, landCover: 1, }, - refetchKeys: ['threshold', 'decile', 'extentYear', 'landCategory'], + refetchKeys: [ + 'threshold', + 'decile', + 'extentYear', + 'landCategory', + 'forestType', + ], pendingKeys: ['threshold', 'decile', 'extentYear'], settings: { threshold: 30, @@ -139,6 +145,14 @@ export default { clearable: true, border: true, }, + { + key: 'forestType', + whitelist: ['plantations'], + label: 'Forest Type', + type: 'select', + placeholder: 'All tree cover', + clearable: true, + }, { key: isTropicalTreeCover ? 'decile' : 'threshold', label: 'Tree cover', From 47fd61672da14cf7a89d5190744e3d02e957da2d Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 12:26:07 -0300 Subject: [PATCH 25/54] feat(tree-cover): adjust chart data when plantations is selected --- .../land-cover/tree-cover/selectors.js | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/components/widgets/land-cover/tree-cover/selectors.js b/components/widgets/land-cover/tree-cover/selectors.js index c95a4f9d47..5b71dffa49 100644 --- a/components/widgets/land-cover/tree-cover/selectors.js +++ b/components/widgets/land-cover/tree-cover/selectors.js @@ -28,21 +28,23 @@ export const isoHasPlantations = createSelector( ); export const parseData = createSelector( - [getData, getColors, getIndicator, isoHasPlantations], - (data, colors, indicator, hasPlantations) => { + [getData, getColors, getIndicator], + (data, colors, indicator) => { if (isEmpty(data)) return null; const { totalArea, totalCover, cover, plantations } = data; const otherCover = indicator ? totalCover - cover : 0; - const plantationsCover = hasPlantations ? plantations : 0; + const plantationsCover = plantations || 0; const label = indicator ? ` in ${indicator.label}` : ''; + const indicators = indicator?.value?.split('__') || []; + const hasPlantations = indicators.includes('plantations'); + const parsedData = [ { - label: hasPlantations - ? 'Natural Forest'.concat(label) - : 'Tree Cover'.concat(label), - value: cover - plantationsCover, + label: 'Tree Cover'.concat(label), + value: hasPlantations ? plantationsCover : cover - plantationsCover, color: colors.naturalForest, - percentage: ((cover - plantationsCover) / totalArea) * 100, + percentage: + ((hasPlantations ? plantationsCover : cover) / totalArea) * 100, }, { label: 'Other Land Cover', @@ -51,21 +53,16 @@ export const parseData = createSelector( percentage: ((totalArea - cover - otherCover) / totalArea) * 100, }, ]; - if (indicator) { + + if (hasPlantations) { parsedData.splice(1, 0, { - label: hasPlantations ? 'Other forest cover' : 'Other tree cover', + label: 'Other tree cover', value: otherCover, color: colors.otherCover, percentage: (otherCover / totalArea) * 100, }); - } else if (!indicator && hasPlantations) { - parsedData.splice(1, 0, { - label: 'Plantations', - value: plantations, - color: colors.plantedForest, - percentage: (plantations / totalArea) * 100, - }); } + return parsedData; } ); From 2cdf5f4a80c06bfb9be1d9d7e86225b53391d61d Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 12:26:57 -0300 Subject: [PATCH 26/54] feat(tree-cover): adjust widget sentence for plantations intersection --- .../widgets/land-cover/tree-cover/selectors.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/components/widgets/land-cover/tree-cover/selectors.js b/components/widgets/land-cover/tree-cover/selectors.js index 5b71dffa49..099ab0f715 100644 --- a/components/widgets/land-cover/tree-cover/selectors.js +++ b/components/widgets/land-cover/tree-cover/selectors.js @@ -82,17 +82,8 @@ export const parseSentence = createSelector( getIndicator, getSentence, getAdminLevel, - isoHasPlantations, ], - ( - data, - settings, - locationName, - indicator, - sentences, - admLevel, - isoPlantations - ) => { + (data, settings, locationName, indicator, sentences, admLevel) => { if (!data || !sentences) return null; const { extentYear, threshold, decile } = settings; @@ -108,9 +99,11 @@ export const parseSentence = createSelector( : 'treeCover'; const sentence = sentences[sentenceKey][sentenceSubkey][sentenceTreeCoverType]; + const indicators = indicator?.value?.split('__') || []; + const hasPlantations = indicators.includes('plantations'); const { cover, plantations, totalCover, totalArea } = data; - const top = isoPlantations ? cover - plantations : cover; + const top = !hasPlantations ? cover - plantations : plantations; const bottom = indicator ? totalCover : totalArea; const percentCover = (100 * top) / bottom; From 8536d8ccbb49ce641c50ae55d91ce0f4945ea5b3 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 12:27:16 -0300 Subject: [PATCH 27/54] feat(tree-cover): change chart colors --- data/colors.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/colors.json b/data/colors.json index eaf308194b..9150404417 100644 --- a/data/colors.json +++ b/data/colors.json @@ -17,7 +17,7 @@ "intactForest": "#6b8729", "primaryForest": "#84a637", "plantedForest": "#a0c746", - "otherCover": "#c7e67c", + "otherCover": "#a0c746", "nonForest": "#e7e5a4" }, "loss": { From 57183f0b3b05f215f531f9b97bcc513c9864cfd0 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 3 Oct 2024 12:37:16 -0300 Subject: [PATCH 28/54] feat(tree-cover): remove out dated method --- .../widgets/land-cover/tree-cover/selectors.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/components/widgets/land-cover/tree-cover/selectors.js b/components/widgets/land-cover/tree-cover/selectors.js index 099ab0f715..9e2235889f 100644 --- a/components/widgets/land-cover/tree-cover/selectors.js +++ b/components/widgets/land-cover/tree-cover/selectors.js @@ -6,7 +6,6 @@ import { formatNumber } from 'utils/format'; const getData = (state) => state.data; const getSettings = (state) => state.settings; const getIndicator = (state) => state.indicator; -const getWhitelist = (state) => state.polynamesWhitelist; const getColors = (state) => state.colors; const getSentence = (state) => state.sentence; const getTitle = (state) => state.title; @@ -14,19 +13,6 @@ const getLocationName = (state) => state.locationLabel; const getMetaKey = (state) => state.metaKey; const getAdminLevel = (state) => state.adminLevel; -export const isoHasPlantations = createSelector( - [getWhitelist, getLocationName], - (whitelist, name) => { - const hasPlantations = - name === 'global' - ? true - : whitelist && - whitelist.annual && - whitelist.annual.includes('plantations'); - return hasPlantations; - } -); - export const parseData = createSelector( [getData, getColors, getIndicator], (data, colors, indicator) => { From 8d1a12e1ef40ae3108c3b44b100e77553a31e354 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 11 Oct 2024 11:33:02 -0300 Subject: [PATCH 29/54] chore(land-categories): set preserveString as true for Indigenous and Community Lands When this property is true it keeps the label as it's written --- data/land-categories.js | 1 + 1 file changed, 1 insertion(+) diff --git a/data/land-categories.js b/data/land-categories.js index 80a0cf9ffd..9acaf5f5a9 100644 --- a/data/land-categories.js +++ b/data/land-categories.js @@ -93,6 +93,7 @@ export default [ }, { label: 'Indigenous and Community Lands', + preserveString: true, value: 'landmark', dataType: 'keyword', metaKey: 'landmark_icls_2020', From b08290f4653106c681bb1c77282d8da725d24209 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 4 Oct 2024 11:23:31 -0300 Subject: [PATCH 30/54] feat(plantations): change sentence string --- .../tree-cover-plantations/index.js | 8 ++----- .../tree-cover-plantations/selectors.js | 22 +++++-------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/components/widgets/land-cover/tree-cover-plantations/index.js b/components/widgets/land-cover/tree-cover-plantations/index.js index 83744bf023..345b1c459a 100644 --- a/components/widgets/land-cover/tree-cover-plantations/index.js +++ b/components/widgets/land-cover/tree-cover-plantations/index.js @@ -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'], diff --git a/components/widgets/land-cover/tree-cover-plantations/selectors.js b/components/widgets/land-cover/tree-cover-plantations/selectors.js index cb0301d504..4e465b6054 100644 --- a/components/widgets/land-cover/tree-cover-plantations/selectors.js +++ b/components/widgets/land-cover/tree-cover-plantations/selectors.js @@ -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; @@ -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, From 2f46ed11ac22fc73376b5c9dabaa5d0f9d9a33b1 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 4 Oct 2024 11:38:13 -0300 Subject: [PATCH 31/54] feat(datasets): update datasets versions --- data/analysis-datasets-versions.json | 58 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/data/analysis-datasets-versions.json b/data/analysis-datasets-versions.json index bdc0547fe4..49c11d7f5a 100644 --- a/data/analysis-datasets-versions.json +++ b/data/analysis-datasets-versions.json @@ -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", @@ -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", From ee079e9d4e7be1e5d31f4b8d210e6fcb117be80e Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Mon, 4 Nov 2024 12:03:08 -0300 Subject: [PATCH 32/54] chore(sentence): improve sentence to display dataset name --- .../widgets/land-cover/tree-cover/index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/widgets/land-cover/tree-cover/index.js b/components/widgets/land-cover/tree-cover/index.js index c710603369..4686d7963b 100644 --- a/components/widgets/land-cover/tree-cover/index.js +++ b/components/widgets/land-cover/tree-cover/index.js @@ -46,29 +46,29 @@ export default { default: { global: { treeCover: - 'As of {year}, {percentage} of {location} land cover was {threshold} tree cover.', + 'As of {year}, {percentage} of {location} land cover was tree cover with {threshold} canopy density.', tropicalTreeCover: - 'As of {year}, {percentage} of {location} land cover was {threshold} tropical tree cover.', + 'As of {year}, {percentage} of {location} land cover was tropical tree cover with {threshold} canopy density.', }, region: { treeCover: - 'As of {year}, {percentage} of {location} land cover was {threshold} tree cover.', + 'As of {year}, {percentage} of {location} land cover was tree cover with {threshold} canopy density.', tropicalTreeCover: - 'As of {year}, {percentage} of {location} land cover was {threshold} tropical tree cover.', + 'As of {year}, {percentage} of {location} land cover was tropical tree cover with {threshold} canopy density.', }, }, withIndicator: { global: { treeCover: - 'As of {year}, {percentage} of {location} land cover in {indicator} was {threshold} tree cover.', + 'As of {year}, {percentage} of {location} land cover in {indicator} was tree cover with {threshold} canopy density.', tropicalTreeCover: - 'As of {year}, {percentage} of {location} land cover in {indicator} was {threshold} tropical tree cover.', + 'As of {year}, {percentage} of {location} land cover in {indicator} was tropical tree cover with {threshold} canopy density.', }, region: { treeCover: - 'As of {year}, {percentage} of {indicator} in {location} was {threshold} tree cover.', + 'As of {year}, {percentage} of {indicator} in {location} was tree cover with {threshold} canopy density.', tropicalTreeCover: - 'As of {year}, {percentage} of {indicator} in {location} was {threshold} tropical tree cover.', + 'As of {year}, {percentage} of {indicator} in {location} was tropical tree cover with {threshold} canopy density.', }, }, }, From a21a54f9e038617b6ed14a0f6252119596115a84 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Mon, 4 Nov 2024 12:13:14 -0300 Subject: [PATCH 33/54] chore(sentence): improve chart labels --- .../widgets/land-cover/tree-cover-plantations/index.js | 2 +- .../widgets/land-cover/tree-cover-plantations/selectors.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/widgets/land-cover/tree-cover-plantations/index.js b/components/widgets/land-cover/tree-cover-plantations/index.js index 345b1c459a..4a602cfa73 100644 --- a/components/widgets/land-cover/tree-cover-plantations/index.js +++ b/components/widgets/land-cover/tree-cover-plantations/index.js @@ -44,7 +44,7 @@ export default { }, sentences: { initial: - 'In {location}, the largest type of plantation area is {topType}, spanning {extent} and {percent} land area.', + 'In {location}, the largest type of plantation area is {topType}, spanning {extent} and {percent} of land area.', }, whitelists: { indicators: ['plantations'], diff --git a/components/widgets/land-cover/tree-cover-plantations/selectors.js b/components/widgets/land-cover/tree-cover-plantations/selectors.js index 4e465b6054..ab953ca4ba 100644 --- a/components/widgets/land-cover/tree-cover-plantations/selectors.js +++ b/components/widgets/land-cover/tree-cover-plantations/selectors.js @@ -3,7 +3,6 @@ import isEmpty from 'lodash/isEmpty'; import sumBy from 'lodash/sumBy'; import sortBy from 'lodash/sortBy'; import { formatNumber } from 'utils/format'; -import endsWith from 'lodash/endsWith'; // get list data const getData = (state) => state.data; @@ -26,7 +25,7 @@ export const parseData = createSelector( plantations .filter((d) => d.intersection_area) .map((d) => ({ - label: d.plantations, + label: d.plantations.toLowerCase(), value: d.intersection_area, color: allColors[d.plantations], percentage: (d.intersection_area / totalPlantations) * 100, @@ -48,7 +47,9 @@ export const parseSentence = createSelector( const params = { location: locationName, extent: formatNumber({ num: topExtent, unit: 'ha', spaceUnit: true }), - topType: `${top[0].label}${endsWith(top[0].label, 's') ? '' : 's'}`, + topType: `${top[0].label.charAt(0).toUpperCase()}${top[0].label.slice( + 1 + )}`, percent: formatNumber({ num: areaPerc, unit: '%' }), }; const sentence = initial; From d8f0715fbc008acd0bd913716dc7234da1bc9a70 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Mon, 4 Nov 2024 12:30:45 -0300 Subject: [PATCH 34/54] fix(plantations): fix plantations colors we match plantations label with the color name but for some reason some uppercase words became lowercase --- data/colors.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/data/colors.json b/data/colors.json index 9150404417..64ea8be873 100644 --- a/data/colors.json +++ b/data/colors.json @@ -91,19 +91,19 @@ "plantations": { "main": "#d67828", "species": { - "Oil Palm": "#fdada9", - "Wood fiber / Timber": "#98a7c4", + "Oil palm": "#fdada9", + "Wood fiber or timber": "#98a7c4", "Rubber": "#9993a3", "Fruit": "#dada95", "Other": "#d1e6ab", - "Wood fiber / Timber Mix": "#9ebbf2", - "Oil Palm Mix": "#fcc4c1", - "Rubber Mix": "#a4fdff", - "Fruit Mix": "#fefe97", - "Other Mix": "#e1efc8", + "Wood fiber or timber mix": "#9ebbf2", + "Oil palm mix": "#fcc4c1", + "Rubber mix": "#a4fdff", + "Fruit mix": "#fefe97", + "Other mix": "#e1efc8", "Unknown": "#dcd9d9", - "Recently Cleared": "#d5a6ea", - "Unknown Mix": "#a0c746" + "Recently cleared": "#d5a6ea", + "Unknown mix": "#a0c746" }, "types": { "Large industrial plantation": "#fdada9", From 2fd15ad668ba50e923f8cc882832be862755da70 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Mon, 4 Nov 2024 12:33:50 -0300 Subject: [PATCH 35/54] fix(plantations): set plantations itens as lowercase to avoid match errors --- .../tree-cover-plantations/selectors.js | 2 +- data/colors.json | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/components/widgets/land-cover/tree-cover-plantations/selectors.js b/components/widgets/land-cover/tree-cover-plantations/selectors.js index ab953ca4ba..766313dd16 100644 --- a/components/widgets/land-cover/tree-cover-plantations/selectors.js +++ b/components/widgets/land-cover/tree-cover-plantations/selectors.js @@ -27,7 +27,7 @@ export const parseData = createSelector( .map((d) => ({ label: d.plantations.toLowerCase(), value: d.intersection_area, - color: allColors[d.plantations], + color: allColors[d.plantations.toLowerCase()], percentage: (d.intersection_area / totalPlantations) * 100, })), 'value' diff --git a/data/colors.json b/data/colors.json index 64ea8be873..e651571f3b 100644 --- a/data/colors.json +++ b/data/colors.json @@ -91,19 +91,19 @@ "plantations": { "main": "#d67828", "species": { - "Oil palm": "#fdada9", - "Wood fiber or timber": "#98a7c4", - "Rubber": "#9993a3", - "Fruit": "#dada95", - "Other": "#d1e6ab", - "Wood fiber or timber mix": "#9ebbf2", - "Oil palm mix": "#fcc4c1", - "Rubber mix": "#a4fdff", - "Fruit mix": "#fefe97", - "Other mix": "#e1efc8", - "Unknown": "#dcd9d9", - "Recently cleared": "#d5a6ea", - "Unknown mix": "#a0c746" + "oil palm": "#fdada9", + "wood fiber or timber": "#98a7c4", + "rubber": "#9993a3", + "fruit": "#dada95", + "other": "#d1e6ab", + "wood fiber or timber mix": "#9ebbf2", + "oil palm mix": "#fcc4c1", + "rubber mix": "#a4fdff", + "fruit mix": "#fefe97", + "other mix": "#e1efc8", + "unknown": "#dcd9d9", + "recently cleared": "#d5a6ea", + "unknown mix": "#a0c746" }, "types": { "Large industrial plantation": "#fdada9", From 40fa443bbea1e165098db7ff34d9a2fbc745efb2 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 12 Nov 2024 13:39:29 -0300 Subject: [PATCH 36/54] chore(sentence): improve widget sentence --- components/widgets/land-cover/tree-cover-plantations/index.js | 2 +- .../widgets/land-cover/tree-cover-plantations/selectors.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/components/widgets/land-cover/tree-cover-plantations/index.js b/components/widgets/land-cover/tree-cover-plantations/index.js index 4a602cfa73..63a69cb67b 100644 --- a/components/widgets/land-cover/tree-cover-plantations/index.js +++ b/components/widgets/land-cover/tree-cover-plantations/index.js @@ -44,7 +44,7 @@ export default { }, sentences: { initial: - 'In {location}, the largest type of plantation area is {topType}, spanning {extent} and {percent} of land area.', + 'In {location}, the largest type of plantation area is {topType}, spanning {extent} and {percent} of land area.', }, whitelists: { indicators: ['plantations'], diff --git a/components/widgets/land-cover/tree-cover-plantations/selectors.js b/components/widgets/land-cover/tree-cover-plantations/selectors.js index 766313dd16..00fd41b766 100644 --- a/components/widgets/land-cover/tree-cover-plantations/selectors.js +++ b/components/widgets/land-cover/tree-cover-plantations/selectors.js @@ -47,9 +47,7 @@ export const parseSentence = createSelector( const params = { location: locationName, extent: formatNumber({ num: topExtent, unit: 'ha', spaceUnit: true }), - topType: `${top[0].label.charAt(0).toUpperCase()}${top[0].label.slice( - 1 - )}`, + topType: top[0].label, percent: formatNumber({ num: areaPerc, unit: '%' }), }; const sentence = initial; From 77df734e8a31b15286fdf19f65d67d99e34f66cf Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 12 Nov 2024 14:09:43 -0300 Subject: [PATCH 37/54] chore(sentence): remove the bold formatting from the word 'and' used to separate indicators --- components/ui/dynamic-sentence/component.jsx | 11 ++++++----- components/ui/dynamic-sentence/styles.scss | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/components/ui/dynamic-sentence/component.jsx b/components/ui/dynamic-sentence/component.jsx index a5328c431b..0a44dbc225 100644 --- a/components/ui/dynamic-sentence/component.jsx +++ b/components/ui/dynamic-sentence/component.jsx @@ -49,13 +49,14 @@ class DynamicSentence extends PureComponent { } } else { // eslint-disable-next-line security/detect-non-literal-regexp - const regex = new RegExp(`{${p}}`, 'g'); + const DYNAMIC_PARAMETERS = new RegExp(`{${p}}`, 'g'); + const AND = new RegExp(`\\band\\b`, 'g'); // regex to remove the bold from the word 'and' between indicators + formattedSentence = formattedSentence && - formattedSentence.replace( - regex, - `${translateText(param)}` - ); + formattedSentence + .replace(DYNAMIC_PARAMETERS, `${translateText(param)}`) + .replace(AND, `and`); } } }); diff --git a/components/ui/dynamic-sentence/styles.scss b/components/ui/dynamic-sentence/styles.scss index 6fa5496519..176e13efa9 100644 --- a/components/ui/dynamic-sentence/styles.scss +++ b/components/ui/dynamic-sentence/styles.scss @@ -7,6 +7,10 @@ font-size: 20px; color: $slate; + .no-bold { + font-weight: 300 !important; + } + strong, b, span { From 2f5aef1785c2f702c9e3cae5c3f86fc977852d38 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 13 Nov 2024 15:21:59 -0300 Subject: [PATCH 38/54] fix(sentence): add placeholder instead of the word and to avoid set bold for parameters separator --- components/ui/dynamic-sentence/component.jsx | 4 ++-- components/widgets/utils/config.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/ui/dynamic-sentence/component.jsx b/components/ui/dynamic-sentence/component.jsx index 0a44dbc225..006692bff3 100644 --- a/components/ui/dynamic-sentence/component.jsx +++ b/components/ui/dynamic-sentence/component.jsx @@ -50,13 +50,13 @@ class DynamicSentence extends PureComponent { } else { // eslint-disable-next-line security/detect-non-literal-regexp const DYNAMIC_PARAMETERS = new RegExp(`{${p}}`, 'g'); - const AND = new RegExp(`\\band\\b`, 'g'); // regex to remove the bold from the word 'and' between indicators + const PLACEHOLDER = new RegExp(`\\bPLACEHOLDER\\b`, 'g'); // regex to remove the bold from the word 'and' between indicators formattedSentence = formattedSentence && formattedSentence .replace(DYNAMIC_PARAMETERS, `${translateText(param)}`) - .replace(AND, `and`); + .replace(PLACEHOLDER, `and`); } } }); diff --git a/components/widgets/utils/config.js b/components/widgets/utils/config.js index 9481fd6a56..bbd26ce5f4 100644 --- a/components/widgets/utils/config.js +++ b/components/widgets/utils/config.js @@ -177,7 +177,7 @@ export const getIndicator = (forestType, landCategory) => { : landCatLabel.toLowerCase(); if (forestType && landCategory) { - label = `${forestTypeLabel} and ${landCatLabel}`; + label = `${forestTypeLabel} PLACEHOLDER ${landCatLabel}`; value = `${forestType.value}__${landCategory.value}`; } else if (landCategory) { label = landCatLabel; From 286ae604e752a91060cc22a70a3ad2194728729a Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 13 Nov 2024 17:13:40 -0300 Subject: [PATCH 39/54] fix(placeholder): replace placeholder inside piechart --- components/charts/components/pie-chart-legend/component.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/charts/components/pie-chart-legend/component.jsx b/components/charts/components/pie-chart-legend/component.jsx index f5b9fa618e..0810ee12b1 100644 --- a/components/charts/components/pie-chart-legend/component.jsx +++ b/components/charts/components/pie-chart-legend/component.jsx @@ -31,17 +31,20 @@ class PieChartLegend extends PureComponent { >
    {data.map((item, index) => { + const PLACEHOLDER = new RegExp(`\\bPLACEHOLDER\\b`, 'g'); + const label = item.label.replace(PLACEHOLDER, `and`); const value = `${formatNumber({ num: item[config.key], unit: item.unit ? item.unit : config.unit, spaceUnit: item.unit !== '%' && config.unit !== 'countsK', })}`; + return (
  • {}

    - {item.label} + {label} {sizeClass === 'x-small' && `- ${value}`}

    From 489c1d904be7c5e35143f4f672b32345080735c9 Mon Sep 17 00:00:00 2001 From: Luis Zenteno Date: Thu, 21 Nov 2024 14:34:55 -0600 Subject: [PATCH 40/54] feat(rankedPlantations): update data version and update CustomTick component to not render hyphen --- .../custom-tick-component.jsx | 10 ++-------- .../land-cover/ranked-plantations/index.js | 13 +++++++++++-- .../land-cover/ranked-plantations/selectors.js | 15 +++++++++------ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/components/charts/horizontal-bar-chart/custom-tick-component.jsx b/components/charts/horizontal-bar-chart/custom-tick-component.jsx index 2a3610239c..0987a13865 100644 --- a/components/charts/horizontal-bar-chart/custom-tick-component.jsx +++ b/components/charts/horizontal-bar-chart/custom-tick-component.jsx @@ -22,19 +22,13 @@ const CustomTick = ({ x, y, index, yAxisDotFill, data, settings }) => { {extLink ? ( - {region} - {' '} - - - {formatNumber({ num: total, unit: '%' })} + {region}: {formatNumber({ num: total, unit: '%' })} {index === 0 ? ' are plantations' : ''} ) : ( - {region} - {' '} - - - {formatNumber({ num: total, unit: '%' })} + {region}: {formatNumber({ num: total, unit: '%' })} {index === 0 ? ' are plantations' : ''} diff --git a/components/widgets/land-cover/ranked-plantations/index.js b/components/widgets/land-cover/ranked-plantations/index.js index 22c6cc6b57..d59f954f8a 100644 --- a/components/widgets/land-cover/ranked-plantations/index.js +++ b/components/widgets/land-cover/ranked-plantations/index.js @@ -55,11 +55,15 @@ export default { }, getData: (params) => all([ - getExtentGrouped(params), + getExtentGrouped({ + ...params, + version: 'v20240815', + }), getAreaIntersectionGrouped({ ...params, forestType: 'plantations', summary: true, + version: 'v20240815', }), ]).then( spread((extentGrouped, plantationsExtentResponse) => { @@ -78,12 +82,17 @@ export default { }) ), getDataURL: (params) => [ - getExtentGrouped({ ...params, download: true }), + getExtentGrouped({ + ...params, + download: true, + version: 'v20240815', + }), getAreaIntersectionGrouped({ ...params, forestType: 'plantations', download: true, summary: true, + version: 'v20240815', }), ], getWidgetProps, diff --git a/components/widgets/land-cover/ranked-plantations/selectors.js b/components/widgets/land-cover/ranked-plantations/selectors.js index 2b02a0fa6b..2c13efb841 100644 --- a/components/widgets/land-cover/ranked-plantations/selectors.js +++ b/components/widgets/land-cover/ranked-plantations/selectors.js @@ -52,11 +52,14 @@ export const parseData = createSelector( const totalArea = regionExtent && regionExtent.total_area; plantationKeys.forEach((key) => { const labelFromKey = - regionGroup && regionGroup.find((p) => p.plantations === key); + regionGroup && + regionGroup.find( + (p) => p.plantations.toLowerCase() === key.toLowerCase() + ); const pExtent = labelFromKey && labelFromKey.intersection_area; const pPercentage = (pExtent / totalRegionPlantations) * 100; - yKeys[key] = pPercentage || 0; - yKeys[`${key} label`] = key; + yKeys[key.toLowerCase()] = pPercentage || 0; + yKeys[`${key.toLowerCase()} label`] = key.toLowerCase(); }); return { @@ -83,12 +86,12 @@ export const parseConfig = createSelector( colors: colorsByType, unit: '%', xKey: 'region', - yKeys: dataKeys, + yKeys: dataKeys.map((item) => item.toLowerCase()), yAxisDotFill: '#d4d4d4', tooltip: dataKeys.map((item) => ({ - key: item, + key: item.toLowerCase(), label: item, - color: colorsByType[item], + color: colorsByType[item.toLowerCase()], unitFormat: (value) => formatNumber({ num: value, unit: '%' }), })), }; From becc80caf40e2142d38f26da71d0ef60668129c0 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 26 Nov 2024 20:59:29 -0300 Subject: [PATCH 41/54] fix(query): improve the way we compare baseline year Change the way we compare baseline years to match the value in the Data API. e.g. ('2015-2020) --- services/analysis-cached.js | 57 +++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/services/analysis-cached.js b/services/analysis-cached.js index f5ac3608a5..ef0b4ba8ed 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -36,7 +36,7 @@ const SQL_QUERIES = { carbonFluxOTF: `SELECT SUM("gfw_forest_carbon_net_flux__Mg_CO2e"), SUM("gfw_forest_carbon_gross_removals__Mg_CO2e"), SUM("gfw_forest_carbon_gross_emissions__Mg_CO2e") FROM data WHERE umd_tree_cover_density_2000__threshold >= {threshold} OR is__umd_tree_cover_gain = 'true'&geostore_origin={geostoreOrigin}&geostore_id={geostoreId}`, extent: 'SELECT {select_location}, SUM(umd_tree_cover_extent_{extentYear}__ha) AS umd_tree_cover_extent_{extentYear}__ha, SUM(area__ha) AS area__ha FROM data {WHERE} GROUP BY {location} ORDER BY {location}', - gain: `SELECT {select_location}, SUM("umd_tree_cover_gain__ha") AS "umd_tree_cover_gain__ha", SUM(umd_tree_cover_extent_2000__ha) AS umd_tree_cover_extent_2000__ha FROM data {WHERE} AND umd_tree_cover_gain__period >= '{baselineYear}' GROUP BY {location} ORDER BY {location}`, + gain: `SELECT {select_location}, SUM("umd_tree_cover_gain__ha") AS "umd_tree_cover_gain__ha", SUM(umd_tree_cover_extent_2000__ha) AS umd_tree_cover_extent_2000__ha FROM data {WHERE} AND umd_tree_cover_gain__period in ({baselineYear}) GROUP BY {location} ORDER BY {location}`, areaIntersection: 'SELECT {select_location}, SUM(area__ha) AS area__ha {intersection} FROM data {WHERE} GROUP BY {location} {intersection} ORDER BY area__ha DESC', glad: 'SELECT {select_location}, alert__year, alert__week, SUM(alert__count) AS alert__count, SUM(alert_area__ha) AS alert_area__ha FROM data {WHERE} GROUP BY {location}, alert__year, alert__week', @@ -77,7 +77,7 @@ const SQL_QUERIES = { 'SELECT {select_location}, SUM("whrc_aboveground_biomass_stock_2000__Mg") AS "whrc_aboveground_biomass_stock_2000__Mg", SUM("whrc_aboveground_co2_stock_2000__Mg") AS "whrc_aboveground_co2_stock_2000__Mg", SUM(umd_tree_cover_extent_2000__ha) AS umd_tree_cover_extent_2000__ha FROM data {WHERE} GROUP BY {location} ORDER BY {location}', organicSoilCarbonGrouped: 'SELECT {select_location}, CASE WHEN SUM("umd_tree_cover_extent_2000__ha") = 0 THEN NULL ELSE SUM("gfw_soil_carbon_stocks_2000__Mg_C") END AS "gfw_soil_carbon_stocks_2000__Mg_C", CASE WHEN SUM("umd_tree_cover_extent_2000__ha") = 0 THEN NULL ELSE SUM("gfw_soil_carbon_stocks_2000__Mg_C") / SUM("umd_tree_cover_extent_2000__ha") END AS soil_carbon_density__t_ha FROM data {WHERE} GROUP BY {location} ORDER BY {location}', - treeCoverGainByPlantationType: `SELECT CASE WHEN gfw_planted_forests__type IS NULL THEN 'Outside of Plantations' ELSE gfw_planted_forests__type END AS plantation_type, SUM(umd_tree_cover_gain__ha) as gain_area_ha FROM data {WHERE} AND umd_tree_cover_gain__period >= '{baselineYear}' GROUP BY gfw_planted_forests__type`, + treeCoverGainByPlantationType: `SELECT CASE WHEN gfw_planted_forests__type IS NULL THEN 'Outside of Plantations' ELSE gfw_planted_forests__type END AS plantation_type, SUM(umd_tree_cover_gain__ha) as gain_area_ha FROM data {WHERE} AND umd_tree_cover_gain__period in ({baselineYear}) GROUP BY gfw_planted_forests__type`, treeCoverOTF: 'SELECT SUM(area__ha) FROM data WHERE umd_tree_cover_density_2000__threshold >= {threshold}&geostore_id={geostoreId}', treeCoverOTFExtent: 'SELECT SUM(area__ha) FROM data&geostore_id={geostoreId}', @@ -110,7 +110,7 @@ const typeByGrouped = { }, adm1: { default: 'adm1', - grouped: 'adm2', + grouped: 'adm1', }, adm2: { default: 'adm2', @@ -890,7 +890,8 @@ export const getLossFiresGrouped = (params) => { }; export const getTreeCoverGainByPlantationType = (params) => { - const { forestType, landCategory, ifl, download, startYear } = params; + const { forestType, landCategory, ifl, download, startYear, endYear } = + params; const requestUrl = getRequestUrl({ ...params, @@ -902,9 +903,21 @@ export const getTreeCoverGainByPlantationType = (params) => { const sqlQuery = SQL_QUERIES.treeCoverGainByPlantationType; + const baselineYearQuery = []; + let year = startYear; + + while (year < endYear) { + const nextYear = year + 5; + baselineYearQuery.push(`${year}-${nextYear}`); + year = nextYear; + } + const url = encodeURI( `${requestUrl}${sqlQuery}` - .replace('{baselineYear}', startYear || 2000) + .replace( + '{baselineYear}', + `'${baselineYearQuery.join("', '")}'` || '2000-2020' + ) .replace('{WHERE}', getWHEREQuery({ ...params })) ); @@ -1207,7 +1220,8 @@ export const getExtentGrouped = (params) => { // summed gain for single location export const getGain = (params) => { - const { forestType, landCategory, ifl, download, startYear } = params || {}; + const { forestType, landCategory, ifl, download, startYear, endYear } = + params || {}; const requestUrl = getRequestUrl({ ...params, @@ -1219,6 +1233,15 @@ export const getGain = (params) => { return new Promise(() => {}); } + const baselineYearQuery = []; + let year = startYear; + + while (year < endYear) { + const nextYear = year + 5; + baselineYearQuery.push(`${year}-${nextYear}`); + year = nextYear; + } + const url = encodeURI( `${requestUrl}${SQL_QUERIES.gain}` .replace( @@ -1226,7 +1249,10 @@ export const getGain = (params) => { getLocationSelect({ ...params, cast: false }) ) .replace(/{location}/g, getLocationSelect({ ...params })) - .replace('{baselineYear}', startYear || 2000) + .replace( + '{baselineYear}', + `'${baselineYearQuery.join("', '")}'` || '2000-2020' + ) .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'annual' })) ); @@ -1254,7 +1280,8 @@ export const getGain = (params) => { // disaggregated gain for child of location export const getGainGrouped = (params) => { - const { forestType, landCategory, ifl, download, startYear } = params || {}; + const { forestType, landCategory, ifl, download, startYear, endYear } = + params || {}; const requestUrl = getRequestUrl({ ...params, @@ -1267,6 +1294,15 @@ export const getGainGrouped = (params) => { return new Promise(() => {}); } + const baselineYearQuery = []; + let year = parseInt(startYear, 10); + + while (year < parseInt(endYear, 10)) { + const nextYear = year + 5; + baselineYearQuery.push(`${year}-${nextYear}`); + year = nextYear; + } + const url = encodeURI( `${requestUrl}${SQL_QUERIES.gain}` .replace(/{location}/g, getLocationSelect({ ...params, grouped: true })) @@ -1274,7 +1310,10 @@ export const getGainGrouped = (params) => { /{select_location}/g, getLocationSelect({ ...params, grouped: true, cast: false }) ) - .replace('{baselineYear}', startYear || 2000) + .replace( + '{baselineYear}', + `'${baselineYearQuery.join("', '")}'` || '2000-2020' + ) .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'annual' })) ); From 2ae8181236f5574a7ab166f7f0e04e31d1b392c1 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 27 Nov 2024 08:19:31 -0300 Subject: [PATCH 42/54] fix(tree-gain): use getGain instead of getGainGrouped When we use the parameter grouped as true, we set adm1 as the table instead of iso --- components/widgets/forest-change/tree-cover-gain/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/widgets/forest-change/tree-cover-gain/index.js b/components/widgets/forest-change/tree-cover-gain/index.js index 6d06465504..46ee5b3c2b 100644 --- a/components/widgets/forest-change/tree-cover-gain/index.js +++ b/components/widgets/forest-change/tree-cover-gain/index.js @@ -1,6 +1,6 @@ import { all, spread } from 'axios'; -import { getGainGrouped } from 'services/analysis-cached'; +import { getGain } from 'services/analysis-cached'; import { POLITICAL_BOUNDARIES_DATASET, @@ -104,7 +104,7 @@ export default { adm2: null, }; - return all([getGainGrouped({ ...rest, ...parentLocation })]).then( + return all([getGain({ ...rest, ...parentLocation })]).then( spread((gainResponse) => { let groupKey = 'iso'; if (adm1) groupKey = 'adm1'; @@ -130,6 +130,6 @@ export default { }) ); }, - getDataURL: (params) => [getGainGrouped({ ...params, download: true })], + getDataURL: (params) => [getGain({ ...params, download: true })], getWidgetProps, }; From 6b26d88ea68b6c444c30a851fb2c54a785c8f93e Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 27 Nov 2024 09:05:15 -0300 Subject: [PATCH 43/54] fix(baseline-year): add a default value for the startYear --- services/analysis-cached.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/services/analysis-cached.js b/services/analysis-cached.js index ef0b4ba8ed..75db610489 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -904,7 +904,7 @@ export const getTreeCoverGainByPlantationType = (params) => { const sqlQuery = SQL_QUERIES.treeCoverGainByPlantationType; const baselineYearQuery = []; - let year = startYear; + let year = parseInt(startYear, 10) || 2000; while (year < endYear) { const nextYear = year + 5; @@ -914,10 +914,7 @@ export const getTreeCoverGainByPlantationType = (params) => { const url = encodeURI( `${requestUrl}${sqlQuery}` - .replace( - '{baselineYear}', - `'${baselineYearQuery.join("', '")}'` || '2000-2020' - ) + .replace('{baselineYear}', `'${baselineYearQuery.join("', '")}'`) .replace('{WHERE}', getWHEREQuery({ ...params })) ); @@ -1234,7 +1231,7 @@ export const getGain = (params) => { } const baselineYearQuery = []; - let year = startYear; + let year = parseInt(startYear, 10) || 2000; while (year < endYear) { const nextYear = year + 5; @@ -1249,10 +1246,7 @@ export const getGain = (params) => { getLocationSelect({ ...params, cast: false }) ) .replace(/{location}/g, getLocationSelect({ ...params })) - .replace( - '{baselineYear}', - `'${baselineYearQuery.join("', '")}'` || '2000-2020' - ) + .replace('{baselineYear}', `'${baselineYearQuery.join("', '")}'`) .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'annual' })) ); @@ -1295,7 +1289,7 @@ export const getGainGrouped = (params) => { } const baselineYearQuery = []; - let year = parseInt(startYear, 10); + let year = parseInt(startYear, 10) || 2000; while (year < parseInt(endYear, 10)) { const nextYear = year + 5; @@ -1310,10 +1304,7 @@ export const getGainGrouped = (params) => { /{select_location}/g, getLocationSelect({ ...params, grouped: true, cast: false }) ) - .replace( - '{baselineYear}', - `'${baselineYearQuery.join("', '")}'` || '2000-2020' - ) + .replace('{baselineYear}', `'${baselineYearQuery.join("', '")}'`) .replace('{WHERE}', getWHEREQuery({ ...params, dataset: 'annual' })) ); From aa6871381ebc358474b41c38e665d3571874fd0a Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 27 Nov 2024 09:18:07 -0300 Subject: [PATCH 44/54] chore(filename): add baseline year to the download filename --- services/analysis-cached.js | 66 +++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/services/analysis-cached.js b/services/analysis-cached.js index 75db610489..81ea8a957a 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -890,8 +890,14 @@ export const getLossFiresGrouped = (params) => { }; export const getTreeCoverGainByPlantationType = (params) => { - const { forestType, landCategory, ifl, download, startYear, endYear } = - params; + const { + forestType, + landCategory, + ifl, + download, + startYear = 2000, + endYear, + } = params; const requestUrl = getRequestUrl({ ...params, @@ -904,12 +910,12 @@ export const getTreeCoverGainByPlantationType = (params) => { const sqlQuery = SQL_QUERIES.treeCoverGainByPlantationType; const baselineYearQuery = []; - let year = parseInt(startYear, 10) || 2000; + let startYearRef = parseInt(startYear, 10); - while (year < endYear) { - const nextYear = year + 5; - baselineYearQuery.push(`${year}-${nextYear}`); - year = nextYear; + while (startYearRef < endYear) { + const nextYear = startYearRef + 5; + baselineYearQuery.push(`${startYearRef}-${nextYear}`); + startYearRef = nextYear; } const url = encodeURI( @@ -921,7 +927,7 @@ export const getTreeCoverGainByPlantationType = (params) => { if (download) { const indicator = getIndicator(forestType, landCategory, ifl); return { - name: `tree_cover_gain_by_plantation_type${ + name: `tree_cover_gain_by_plantation_type_${startYear}-2020${ indicator ? `_in_${snakeCase(indicator.label)}` : '' }__ha`, url: getDownloadUrl(url), @@ -1217,8 +1223,14 @@ export const getExtentGrouped = (params) => { // summed gain for single location export const getGain = (params) => { - const { forestType, landCategory, ifl, download, startYear, endYear } = - params || {}; + const { + forestType, + landCategory, + ifl, + download, + startYear = 2000, + endYear, + } = params || {}; const requestUrl = getRequestUrl({ ...params, @@ -1231,12 +1243,12 @@ export const getGain = (params) => { } const baselineYearQuery = []; - let year = parseInt(startYear, 10) || 2000; + let startYearRef = parseInt(startYear, 10); - while (year < endYear) { - const nextYear = year + 5; - baselineYearQuery.push(`${year}-${nextYear}`); - year = nextYear; + while (startYearRef < endYear) { + const nextYear = startYearRef + 5; + baselineYearQuery.push(`${startYearRef}-${nextYear}`); + startYearRef = nextYear; } const url = encodeURI( @@ -1253,7 +1265,7 @@ export const getGain = (params) => { if (download) { const indicator = getIndicator(forestType, landCategory, ifl); return { - name: `treecover_gain_2000-2020${ + name: `treecover_gain_${startYear}-2020${ indicator ? `_in_${snakeCase(indicator.label)}` : '' }__ha`, url: getDownloadUrl(url), @@ -1274,8 +1286,14 @@ export const getGain = (params) => { // disaggregated gain for child of location export const getGainGrouped = (params) => { - const { forestType, landCategory, ifl, download, startYear, endYear } = - params || {}; + const { + forestType, + landCategory, + ifl, + download, + startYear = 2000, + endYear, + } = params || {}; const requestUrl = getRequestUrl({ ...params, @@ -1289,12 +1307,12 @@ export const getGainGrouped = (params) => { } const baselineYearQuery = []; - let year = parseInt(startYear, 10) || 2000; + let startYearRef = parseInt(startYear, 10); - while (year < parseInt(endYear, 10)) { - const nextYear = year + 5; - baselineYearQuery.push(`${year}-${nextYear}`); - year = nextYear; + while (startYearRef < parseInt(endYear, 10)) { + const nextYear = startYearRef + 5; + baselineYearQuery.push(`${startYearRef}-${nextYear}`); + startYearRef = nextYear; } const url = encodeURI( @@ -1311,7 +1329,7 @@ export const getGainGrouped = (params) => { if (download) { const indicator = getIndicator(forestType, landCategory, ifl); return { - name: `treecover_gain_2000-2020_by_region${ + name: `treecover_gain_${startYear}-2020_by_region${ indicator ? `_in_${snakeCase(indicator.label)}` : '' }__ha`, url: getDownloadUrl(url), From d82eb1b58c52bd19278dbf5e5728118e2df7426f Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 5 Dec 2024 14:22:15 -0300 Subject: [PATCH 45/54] chore(label): remove lowercase --- .../widgets/land-cover/tree-cover-plantations/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/widgets/land-cover/tree-cover-plantations/selectors.js b/components/widgets/land-cover/tree-cover-plantations/selectors.js index 00fd41b766..62b6ce3362 100644 --- a/components/widgets/land-cover/tree-cover-plantations/selectors.js +++ b/components/widgets/land-cover/tree-cover-plantations/selectors.js @@ -25,7 +25,7 @@ export const parseData = createSelector( plantations .filter((d) => d.intersection_area) .map((d) => ({ - label: d.plantations.toLowerCase(), + label: d.plantations, value: d.intersection_area, color: allColors[d.plantations.toLowerCase()], percentage: (d.intersection_area / totalPlantations) * 100, From 64dda8d3e6a59277edb6e42f6dfc93b3e548ceb7 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 5 Dec 2024 16:00:56 -0300 Subject: [PATCH 46/54] chore(dataset): remove hard coded version from getTreeCoverGainByPlantationType --- services/analysis-cached.js | 1 - 1 file changed, 1 deletion(-) diff --git a/services/analysis-cached.js b/services/analysis-cached.js index 827ce84830..4116b812a9 100644 --- a/services/analysis-cached.js +++ b/services/analysis-cached.js @@ -896,7 +896,6 @@ export const getTreeCoverGainByPlantationType = (params) => { ...params, dataset: 'annual', datasetType: 'summary', - version: 'v20221012', }); if (!requestUrl) return new Promise(() => {}); From 14aacb681cd4fba34c80081969426c6df7e66cbf Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 10 Dec 2024 11:15:15 -0300 Subject: [PATCH 47/54] fix(layer): update decode function --- providers/datasets-provider/config.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/providers/datasets-provider/config.js b/providers/datasets-provider/config.js index e86715aa12..5396cff16b 100644 --- a/providers/datasets-provider/config.js +++ b/providers/datasets-provider/config.js @@ -77,10 +77,13 @@ const decodes = { float year = 1999.0 + ((color.b * 5.) * 255.); // map to years + // Old colors: 109, 72, 33 + // New colors: 19, 3, 255 if (year >= startYear && year <= endYear && year >= 2001.) { - color.r = 109. / 255.; - color.g = (72. - zoom + 109. - 3. * scaleIntensity / zoom) / 255.; - color.b = (33. - zoom + 229. - intensity / zoom) / 255.; + color.r = 19. / 255.; + color.g = (72. - zoom + 3. - scaleIntensity / zoom) / 255.; + color.b = (33. - zoom + 255. - intensity / zoom) / 255.; + alpha = (8. * intensity) / 255.; } else { alpha = 0.; } From f4638ded799f9a4106030c2b1f7965e369e450dd Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Fri, 15 Nov 2024 11:24:51 -0300 Subject: [PATCH 48/54] chore(envs): Split RW and GFW API's keys to make it more flexible Now we can set each API separatedly, making it easier to test different environments at once --- pages/api/metadata/[...params].js | 2 +- providers/datasets-provider/actions.js | 2 +- services/datasets.js | 2 +- services/shape.js | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pages/api/metadata/[...params].js b/pages/api/metadata/[...params].js index f9e4816f09..92ce9c4962 100644 --- a/pages/api/metadata/[...params].js +++ b/pages/api/metadata/[...params].js @@ -1,7 +1,7 @@ import { GFW_METADATA_API, GFW_STAGING_METADATA_API } from 'utils/apis'; import axios from 'axios'; -const ENVIRONMENT = process.env.NEXT_PUBLIC_FEATURE_ENV; +const ENVIRONMENT = process.env.NEXT_PUBLIC_RW_FEATURE_ENV; const GFW_METADATA_API_URL = ENVIRONMENT === 'staging' ? GFW_STAGING_METADATA_API : GFW_METADATA_API; diff --git a/providers/datasets-provider/actions.js b/providers/datasets-provider/actions.js index 18fa932203..cb0784831b 100644 --- a/providers/datasets-provider/actions.js +++ b/providers/datasets-provider/actions.js @@ -14,7 +14,7 @@ export const setDatasets = createAction('setDatasets'); export const setDatasetsWithMetadata = createAction('setDatasetsWithMetadata'); const handleFeatureEnvLock = (env) => { - const currEnv = process.env.NEXT_PUBLIC_FEATURE_ENV; + const currEnv = process.env.NEXT_PUBLIC_RW_FEATURE_ENV; const MIXED_ENV = 'preproduction-staging'; if (env === MIXED_ENV && currEnv !== 'production') { return true; diff --git a/services/datasets.js b/services/datasets.js index 4d1b819d71..a7ff3012f6 100644 --- a/services/datasets.js +++ b/services/datasets.js @@ -1,7 +1,7 @@ import { rwRequest, dataRequest } from 'utils/request'; const environmentString = () => { - const env = process.env.NEXT_PUBLIC_FEATURE_ENV; + const env = process.env.NEXT_PUBLIC_RW_FEATURE_ENV; let envString = 'production'; if (env === 'preproduction') { envString += ',preproduction'; diff --git a/services/shape.js b/services/shape.js index 003208f9c7..d859860ac8 100644 --- a/services/shape.js +++ b/services/shape.js @@ -3,7 +3,9 @@ import request from 'utils/request'; import { GFW_API, GFW_STAGING_API } from 'utils/apis'; const GFW_API_URL = - process.env.NEXT_PUBLIC_FEATURE_ENV === 'staging' ? GFW_STAGING_API : GFW_API; + process.env.NEXT_PUBLIC_RW_FEATURE_ENV === 'staging' + ? GFW_STAGING_API + : GFW_API; const QUERIES = { ogrConvert: '/v2/ogr/convert', From 6da50c5fa7ac85e973df070e91ec4fb7acb3cb14 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 12 Dec 2024 13:47:13 -0300 Subject: [PATCH 49/54] fix(sentence): set the topType as lowercase --- .../widgets/land-cover/tree-cover-plantations/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/widgets/land-cover/tree-cover-plantations/selectors.js b/components/widgets/land-cover/tree-cover-plantations/selectors.js index 62b6ce3362..11c62bf946 100644 --- a/components/widgets/land-cover/tree-cover-plantations/selectors.js +++ b/components/widgets/land-cover/tree-cover-plantations/selectors.js @@ -47,7 +47,7 @@ export const parseSentence = createSelector( const params = { location: locationName, extent: formatNumber({ num: topExtent, unit: 'ha', spaceUnit: true }), - topType: top[0].label, + topType: top[0].label.toLowerCase(), percent: formatNumber({ num: areaPerc, unit: '%' }), }; const sentence = initial; From 4fb26778e0b748eb8b7a2c8adf50f4a211b43ef1 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 18 Dec 2024 14:49:24 -0300 Subject: [PATCH 50/54] fix(dataset): bump datasets versions with patch from Data API for new VIIRS data --- data/analysis-datasets-versions.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/data/analysis-datasets-versions.json b/data/analysis-datasets-versions.json index 49c11d7f5a..140ec84655 100644 --- a/data/analysis-datasets-versions.json +++ b/data/analysis-datasets-versions.json @@ -9,9 +9,9 @@ "ANNUAL_ADM2_SUMMARY": "v20240815", "ANNUAL_ADM2_WHITELIST": "v20240815", - "ANNUAL_GEOSTORE_CHANGE": "v20240815", - "ANNUAL_GEOSTORE_SUMMARY": "v20240815", - "ANNUAL_GEOSTORE_WHITELIST": "v20240815", + "ANNUAL_GEOSTORE_CHANGE": "v20241209", + "ANNUAL_GEOSTORE_SUMMARY": "v20241209", + "ANNUAL_GEOSTORE_WHITELIST": "v20241209", "ANNUAL_WDPA_CHANGE": "v20240813", "ANNUAL_WDPA_SUMMARY": "v20240813", "ANNUAL_WDPA_WHITELIST": "v20240813", @@ -24,9 +24,9 @@ "VIIRS_ADM1_WEEKLY": "v20240815", "VIIRS_ADM2_WEEKLY": "v20240815", - "VIIRS_GEOSTORE_WHITELIST": "v20240122", - "VIIRS_GEOSTORE_DAILY": "v20240122", - "VIIRS_GEOSTORE_WEEKLY": "v20240122", + "VIIRS_GEOSTORE_DAILY": "v20241209", + "VIIRS_GEOSTORE_WEEKLY": "v20241209", + "VIIRS_GEOSTORE_WHITELIST": "v20241209", "VIIRS_WDPA_DAILY": "v20240122", "VIIRS_WDPA_WEEKLY": "v20240122", "VIIRS_WDPA_WHITELIST": "v20240122", From 7e2d54b9ccfc045458036167fbbeb629985105e3 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Wed, 18 Dec 2024 14:49:24 -0300 Subject: [PATCH 51/54] fix(dataset): bump datasets versions with patch from Data API for new VIIRS data --- data/analysis-datasets-versions.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/data/analysis-datasets-versions.json b/data/analysis-datasets-versions.json index 49c11d7f5a..140ec84655 100644 --- a/data/analysis-datasets-versions.json +++ b/data/analysis-datasets-versions.json @@ -9,9 +9,9 @@ "ANNUAL_ADM2_SUMMARY": "v20240815", "ANNUAL_ADM2_WHITELIST": "v20240815", - "ANNUAL_GEOSTORE_CHANGE": "v20240815", - "ANNUAL_GEOSTORE_SUMMARY": "v20240815", - "ANNUAL_GEOSTORE_WHITELIST": "v20240815", + "ANNUAL_GEOSTORE_CHANGE": "v20241209", + "ANNUAL_GEOSTORE_SUMMARY": "v20241209", + "ANNUAL_GEOSTORE_WHITELIST": "v20241209", "ANNUAL_WDPA_CHANGE": "v20240813", "ANNUAL_WDPA_SUMMARY": "v20240813", "ANNUAL_WDPA_WHITELIST": "v20240813", @@ -24,9 +24,9 @@ "VIIRS_ADM1_WEEKLY": "v20240815", "VIIRS_ADM2_WEEKLY": "v20240815", - "VIIRS_GEOSTORE_WHITELIST": "v20240122", - "VIIRS_GEOSTORE_DAILY": "v20240122", - "VIIRS_GEOSTORE_WEEKLY": "v20240122", + "VIIRS_GEOSTORE_DAILY": "v20241209", + "VIIRS_GEOSTORE_WEEKLY": "v20241209", + "VIIRS_GEOSTORE_WHITELIST": "v20241209", "VIIRS_WDPA_DAILY": "v20240122", "VIIRS_WDPA_WEEKLY": "v20240122", "VIIRS_WDPA_WHITELIST": "v20240122", From 9dc1fe670f4536aae9f39e30e6bc2dbfa6620bb2 Mon Sep 17 00:00:00 2001 From: Luis Zenteno Date: Wed, 18 Dec 2024 12:08:15 -0600 Subject: [PATCH 52/54] feat(treeCover): fix tree cover calculations --- components/widgets/land-cover/tree-cover/index.js | 2 +- components/widgets/land-cover/tree-cover/selectors.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/widgets/land-cover/tree-cover/index.js b/components/widgets/land-cover/tree-cover/index.js index 4686d7963b..e2960ec9ef 100644 --- a/components/widgets/land-cover/tree-cover/index.js +++ b/components/widgets/land-cover/tree-cover/index.js @@ -106,7 +106,7 @@ export default { ], sortOrder: { summary: 4, - landCover: 1, + landCover: 1.5, }, refetchKeys: [ 'threshold', diff --git a/components/widgets/land-cover/tree-cover/selectors.js b/components/widgets/land-cover/tree-cover/selectors.js index 9e2235889f..c7775e21c5 100644 --- a/components/widgets/land-cover/tree-cover/selectors.js +++ b/components/widgets/land-cover/tree-cover/selectors.js @@ -27,7 +27,7 @@ export const parseData = createSelector( const parsedData = [ { label: 'Tree Cover'.concat(label), - value: hasPlantations ? plantationsCover : cover - plantationsCover, + value: hasPlantations ? plantationsCover : cover, color: colors.naturalForest, percentage: ((hasPlantations ? plantationsCover : cover) / totalArea) * 100, @@ -43,9 +43,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, }); } From 06dc0c06c315b2e18b01e25ff7a706c96094abb6 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 19 Dec 2024 12:29:20 -0300 Subject: [PATCH 53/54] chore(blacklist): remove fao europe blacklist for tcl and tcg --- .../index.js | 5 -- .../tree-loss-plantations/index.js | 5 -- utils/fao-countries.js | 54 ------------------- 3 files changed, 64 deletions(-) delete mode 100644 utils/fao-countries.js diff --git a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js index e15028a62a..7fd6f4ee14 100644 --- a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js +++ b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js @@ -12,8 +12,6 @@ import { TREE_PLANTATIONS, } from 'data/layers'; -import { EuropeFAOCountries } from 'utils/fao-countries'; - import getWidgetProps from './selectors'; export default { @@ -78,9 +76,6 @@ export default { regionWithIndicator: 'In {location} between 2000 and 2020, {gainPercent} of tree cover gain within {indicator} occurred outside of plantations.', }, - blacklists: { - adm0: EuropeFAOCountries, - }, settings: { threshold: 0, }, diff --git a/components/widgets/forest-change/tree-loss-plantations/index.js b/components/widgets/forest-change/tree-loss-plantations/index.js index 4fe681bdf1..626c529957 100644 --- a/components/widgets/forest-change/tree-loss-plantations/index.js +++ b/components/widgets/forest-change/tree-loss-plantations/index.js @@ -14,8 +14,6 @@ import { TREE_PLANTATIONS, } from 'data/layers'; -import { EuropeFAOCountries } from 'utils/fao-countries'; - import getWidgetProps from './selectors'; const MIN_YEAR = 2013; @@ -75,9 +73,6 @@ export default { indicators: ['plantations'], checkStatus: true, }, - blacklists: { - adm0: EuropeFAOCountries, - }, settings: { threshold: 30, startYear: MIN_YEAR, diff --git a/utils/fao-countries.js b/utils/fao-countries.js deleted file mode 100644 index 07d1b38cfd..0000000000 --- a/utils/fao-countries.js +++ /dev/null @@ -1,54 +0,0 @@ -export const EuropeFAOCountries = [ - 'ALB', - 'AND', - 'AUT', - 'BLR', - 'BEL', - 'BIH', - 'BGR', - 'HRV', - 'CZE', - 'DNK', - 'EST', - 'FRO', - 'FIN', - 'FRA', - 'DEU', - 'GIB', - 'GRC', - 'GGY', - 'VAT', - 'HUN', - 'ISL', - 'IRL', - 'IMN', - 'ITA', - 'JEY', - 'LVA', - 'LIE', - 'LTU', - 'LUX', - 'MLT', - 'MCO', - 'MNE', - 'NLD', - 'MKD', - 'NOR', - 'POL', - 'PRT', - 'MDA', - 'ROU', - 'RUS', - 'SMR', - 'SRB', - 'SVK', - 'SVN', - 'ESP', - 'SJM', - 'SWE', - 'CHE', - 'UKR', - 'GBR', -]; - -export default EuropeFAOCountries; From 83f256e820da465ff2cebf679e2da7ba63d76c15 Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Thu, 19 Dec 2024 12:29:20 -0300 Subject: [PATCH 54/54] chore(blacklist): remove fao europe blacklist for tcl and tcg --- .../index.js | 5 -- .../tree-loss-plantations/index.js | 5 -- utils/fao-countries.js | 54 ------------------- 3 files changed, 64 deletions(-) delete mode 100644 utils/fao-countries.js diff --git a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js index 293d68203c..7ebc03f20e 100644 --- a/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js +++ b/components/widgets/forest-change/tree-cover-gain-outside-plantations/index.js @@ -12,8 +12,6 @@ import { TREE_PLANTATIONS, } from 'data/layers'; -import { EuropeFAOCountries } from 'utils/fao-countries'; - import getWidgetProps from './selectors'; const MIN_YEAR = 2000; @@ -88,9 +86,6 @@ export default { regionWithIndicator: 'In {location} between {baselineYear} and 2020, {gainPercent} of tree cover gain within {indicator} occurred outside of plantations. ', }, - blacklists: { - adm0: EuropeFAOCountries, - }, settings: { threshold: 0, startYear: MIN_YEAR, diff --git a/components/widgets/forest-change/tree-loss-plantations/index.js b/components/widgets/forest-change/tree-loss-plantations/index.js index 4fe681bdf1..626c529957 100644 --- a/components/widgets/forest-change/tree-loss-plantations/index.js +++ b/components/widgets/forest-change/tree-loss-plantations/index.js @@ -14,8 +14,6 @@ import { TREE_PLANTATIONS, } from 'data/layers'; -import { EuropeFAOCountries } from 'utils/fao-countries'; - import getWidgetProps from './selectors'; const MIN_YEAR = 2013; @@ -75,9 +73,6 @@ export default { indicators: ['plantations'], checkStatus: true, }, - blacklists: { - adm0: EuropeFAOCountries, - }, settings: { threshold: 30, startYear: MIN_YEAR, diff --git a/utils/fao-countries.js b/utils/fao-countries.js deleted file mode 100644 index 07d1b38cfd..0000000000 --- a/utils/fao-countries.js +++ /dev/null @@ -1,54 +0,0 @@ -export const EuropeFAOCountries = [ - 'ALB', - 'AND', - 'AUT', - 'BLR', - 'BEL', - 'BIH', - 'BGR', - 'HRV', - 'CZE', - 'DNK', - 'EST', - 'FRO', - 'FIN', - 'FRA', - 'DEU', - 'GIB', - 'GRC', - 'GGY', - 'VAT', - 'HUN', - 'ISL', - 'IRL', - 'IMN', - 'ITA', - 'JEY', - 'LVA', - 'LIE', - 'LTU', - 'LUX', - 'MLT', - 'MCO', - 'MNE', - 'NLD', - 'MKD', - 'NOR', - 'POL', - 'PRT', - 'MDA', - 'ROU', - 'RUS', - 'SMR', - 'SRB', - 'SVK', - 'SVN', - 'ESP', - 'SJM', - 'SWE', - 'CHE', - 'UKR', - 'GBR', -]; - -export default EuropeFAOCountries;