diff --git a/src/components/earthEngine/layers/landcover_MCD12Q1.js b/src/components/earthEngine/layers/landcover_MCD12Q1.js index 47072cec5..a7f709e31 100644 --- a/src/components/earthEngine/layers/landcover_MCD12Q1.js +++ b/src/components/earthEngine/layers/landcover_MCD12Q1.js @@ -6,7 +6,7 @@ export default { format: 'ImageCollection', layerId: 'MODIS/006/MCD12Q1', // Layer id kept for backward compability for saved maps datasetId: 'MODIS/061/MCD12Q1', // No longer in use: 'MODIS/006/MCD12Q1' / 'MODIS/051/MCD12Q1', - name: i18n.t('Landcover NASA'), + name: i18n.t('Landcover'), description: i18n.t('Distinct landcover types collected from satellites.'), img: 'images/landcover.png', source: 'NASA LP DAAC / Google Earth Engine', diff --git a/src/components/edit/earthEngine/EarthEngineDialog.js b/src/components/edit/earthEngine/EarthEngineDialog.js index 6a723a369..e60cc161e 100644 --- a/src/components/edit/earthEngine/EarthEngineDialog.js +++ b/src/components/edit/earthEngine/EarthEngineDialog.js @@ -219,9 +219,12 @@ EarthEngineDialog.propTypes = { onLayerValidation: PropTypes.func.isRequired, aggregations: PropTypes.array, areaRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), - band: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), // TODO: Why array? + band: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), bands: PropTypes.array, - defaultAggregations: PropTypes.array, + defaultAggregations: PropTypes.oneOfType([ + PropTypes.array, + PropTypes.string, + ]), description: PropTypes.string, filters: PropTypes.array, legend: PropTypes.object, diff --git a/src/loaders/earthEngineLoader.js b/src/loaders/earthEngineLoader.js index 7e9f6029c..1379c13c5 100644 --- a/src/loaders/earthEngineLoader.js +++ b/src/loaders/earthEngineLoader.js @@ -3,7 +3,11 @@ import { getInstance as getD2 } from 'd2' import { precisionFixed, formatLocale } from 'd3-format' import { getEarthEngineLayer } from '../constants/earthEngine.js' import { getOrgUnitsFromRows } from '../util/analytics.js' -import { hasClasses, getFilterFromPeriod } from '../util/earthEngine.js' +import { + hasClasses, + getFilterFromPeriod, + getPeriodFromFilter, +} from '../util/earthEngine.js' import { getDisplayProperty } from '../util/helpers.js' import { toGeoJson } from '../util/map.js' import { @@ -24,6 +28,8 @@ const earthEngineLoader = async (config) => { let dataset let features + console.log('earthEngineLoader', config) + if (orgUnits && orgUnits.length) { const d2 = await getD2() const displayProperty = getDisplayProperty(d2).toUpperCase() @@ -87,6 +93,25 @@ const earthEngineLoader = async (config) => { // From database as favorite layerConfig = JSON.parse(config.config) + console.log('layerConfig', layerConfig) + + const { filter, params } = layerConfig + + // Backward compability for layers saved before 2.41 + if (filter) { + layerConfig.period = getPeriodFromFilter(filter) + delete layerConfig.filter + } + + // Backward compability for layers saved before 2.41 + if (params) { + layerConfig.style = params + if (params.palette) { + layerConfig.style.palette = params.palette.split(',') + } + delete layerConfig.params + } + // Backward compability for layers with periods saved before 2.36 // (could also be fixed in a db update script) if (layerConfig.image) {