@hisptz/dhis2-analytics 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/components/ChartAnalytics/ChartAnalytics.stories.js +253 -0
- package/build/cjs/components/ChartAnalytics/ChartAnalytics.test.js +51 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/components/Menu.js +48 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/constants/menu.js +34 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/index.js +67 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.js +1 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/column-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/complex-multi-series-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/multi-series-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/pie-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/stacked-chart-data.json +0 -0
- package/build/cjs/components/ChartAnalytics/hooks/useChart.js +38 -0
- package/build/cjs/components/ChartAnalytics/index.js +69 -0
- package/build/cjs/components/ChartAnalytics/models/column.js +53 -0
- package/build/cjs/components/ChartAnalytics/models/index.js +102 -0
- package/build/cjs/components/ChartAnalytics/models/line.js +35 -0
- package/build/cjs/components/ChartAnalytics/models/multi-series.js +111 -0
- package/build/cjs/components/ChartAnalytics/models/pie.js +53 -0
- package/build/cjs/components/ChartAnalytics/services/export.js +50 -0
- package/{src → build/cjs}/components/ChartAnalytics/styles/custom-highchart.css +0 -0
- package/build/cjs/components/ChartAnalytics/types/props.js +1 -0
- package/build/cjs/components/ChartAnalytics/utils/chart.js +133 -0
- package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +45 -0
- package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.test.js +13 -0
- package/build/cjs/components/CircularProgressDashboard/index.js +49 -0
- package/build/cjs/components/CircularProgressDashboard/types/props.js +1 -0
- package/build/cjs/components/Map/Map.stories.js +352 -0
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +32 -0
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +40 -0
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/index.js +458 -0
- package/build/cjs/components/Map/components/MapArea/index.js +101 -0
- package/build/cjs/components/Map/components/MapArea/interfaces/index.js +1 -0
- package/build/cjs/components/Map/components/MapControls/components/CustomControl/index.js +32 -0
- package/build/cjs/components/Map/components/MapControls/components/DownloadControl/index.js +25 -0
- package/build/cjs/components/Map/components/MapControls/components/FullscreenControl/index.js +13 -0
- package/build/cjs/components/Map/components/MapControls/index.js +42 -0
- package/build/cjs/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.js +13 -0
- package/build/cjs/components/Map/components/MapLayer/components/BoundaryLayer/index.js +51 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.js +106 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.js +379 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.js +36 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/index.js +200 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.js +1 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +10 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +412 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.js +124 -0
- package/{src → build/cjs}/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +0 -0
- package/build/cjs/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.js +26 -0
- package/build/cjs/components/Map/components/MapLayer/components/LegendArea/index.js +181 -0
- package/build/cjs/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.js +86 -0
- package/build/cjs/components/Map/components/MapLayer/components/PointLayer/hooks/index.js +14 -0
- package/build/cjs/components/Map/components/MapLayer/components/PointLayer/index.js +46 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.js +57 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.js +145 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.js +43 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.js +56 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.js +61 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js +43 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js +35 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.js +15 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/index.js +57 -0
- package/{src → build/cjs}/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +0 -0
- package/build/cjs/components/Map/components/MapLayer/index.js +40 -0
- package/build/cjs/components/Map/components/MapLayer/interfaces/index.js +8 -0
- package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +389 -0
- package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/index.js +116 -0
- package/build/cjs/components/Map/components/MapProvider/hooks/index.js +19 -0
- package/build/cjs/components/Map/components/MapProvider/index.js +121 -0
- package/build/cjs/components/Map/components/MapUpdater/index.js +24 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +32 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +40 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.js +40 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.js +428 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.js +63 -0
- package/{src → build/cjs}/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +0 -0
- package/{src → build/cjs}/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +0 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.js +72 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.js +71 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.js +47 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.js +79 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/index.js +265 -0
- package/build/cjs/components/Map/constants/colors.js +428 -0
- package/build/cjs/components/Map/constants/legendSet.js +22 -0
- package/build/cjs/components/Map/hooks/map.js +52 -0
- package/build/cjs/components/Map/index.js +108 -0
- package/build/cjs/components/Map/interfaces/index.js +1 -0
- package/build/cjs/components/Map/state/index.js +23 -0
- package/build/cjs/components/Map/utils/colors.js +78 -0
- package/build/cjs/components/Map/utils/helpers.js +25 -0
- package/build/cjs/components/Map/utils/map.js +161 -0
- package/build/cjs/components/SingleValueContainer/SingleValueContainer.stories.js +127 -0
- package/build/cjs/components/SingleValueContainer/SingleValueContainer.test.js +23 -0
- package/build/cjs/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.js +54 -0
- package/build/cjs/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.js +24 -0
- package/build/cjs/components/SingleValueContainer/index.js +43 -0
- package/{src → build/cjs}/components/SingleValueContainer/styles/SingleValueContainer.module.css +0 -0
- package/build/cjs/components/SingleValueContainer/types/props.js +1 -0
- package/{src → build/cjs}/data/map.json +0 -0
- package/build/cjs/dataProviders/map.js +31 -0
- package/build/cjs/index.js +49 -0
- package/build/cjs/index.test.js +7 -0
- package/build/cjs/locales/en/translations.json +128 -0
- package/build/cjs/locales/index.js +22 -0
- package/build/es/components/ChartAnalytics/ChartAnalytics.stories.js +235 -0
- package/build/es/components/ChartAnalytics/ChartAnalytics.test.js +46 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/components/Menu.js +41 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/constants/menu.js +26 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/index.js +58 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.js +1 -0
- package/build/es/components/ChartAnalytics/data/column-data.json +210 -0
- package/build/es/components/ChartAnalytics/data/complex-multi-series-data.json +124 -0
- package/build/es/components/ChartAnalytics/data/multi-series-data.json +536 -0
- package/build/es/components/ChartAnalytics/data/pie-data.json +115 -0
- package/build/es/components/ChartAnalytics/data/stacked-chart-data.json +415 -0
- package/build/es/components/ChartAnalytics/hooks/useChart.js +32 -0
- package/build/es/components/ChartAnalytics/index.js +40 -0
- package/build/es/components/ChartAnalytics/models/column.js +45 -0
- package/build/es/components/ChartAnalytics/models/index.js +95 -0
- package/build/es/components/ChartAnalytics/models/line.js +28 -0
- package/build/es/components/ChartAnalytics/models/multi-series.js +104 -0
- package/build/es/components/ChartAnalytics/models/pie.js +46 -0
- package/build/es/components/ChartAnalytics/services/export.js +36 -0
- package/build/es/components/ChartAnalytics/styles/custom-highchart.css +48 -0
- package/build/es/components/ChartAnalytics/types/props.js +1 -0
- package/build/es/components/ChartAnalytics/utils/chart.js +122 -0
- package/{src/components/CircularProgressDashboard/CircularProgressIndicator.stories.tsx → build/es/components/CircularProgressDashboard/CircularProgressIndicator.stories.js} +9 -16
- package/build/es/components/CircularProgressDashboard/CircularProgressIndicator.test.js +10 -0
- package/build/es/components/CircularProgressDashboard/index.js +41 -0
- package/build/es/components/CircularProgressDashboard/types/props.js +1 -0
- package/build/es/components/Map/Map.stories.js +334 -0
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +23 -0
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +31 -0
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/index.js +448 -0
- package/build/es/components/Map/components/MapArea/index.js +91 -0
- package/build/es/components/Map/components/MapArea/interfaces/index.js +1 -0
- package/build/es/components/Map/components/MapControls/components/CustomControl/index.js +25 -0
- package/build/es/components/Map/components/MapControls/components/DownloadControl/index.js +18 -0
- package/build/es/components/Map/components/MapControls/components/FullscreenControl/index.js +6 -0
- package/build/es/components/Map/components/MapControls/index.js +35 -0
- package/build/es/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.js +7 -0
- package/build/es/components/Map/components/MapLayer/components/BoundaryLayer/index.js +41 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.js +95 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.js +369 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.js +29 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/index.js +191 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.js +1 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +10 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +403 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.js +111 -0
- package/build/es/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +12 -0
- package/build/es/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.js +19 -0
- package/build/es/components/Map/components/MapLayer/components/LegendArea/index.js +172 -0
- package/build/es/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.js +76 -0
- package/build/es/components/Map/components/MapLayer/components/PointLayer/hooks/index.js +8 -0
- package/build/es/components/Map/components/MapLayer/components/PointLayer/index.js +39 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.js +49 -0
- package/{src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.tsx → build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.js} +57 -74
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.js +33 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.js +47 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.js +50 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js +36 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js +28 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.js +9 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/index.js +50 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +62 -0
- package/build/es/components/Map/components/MapLayer/index.js +33 -0
- package/build/es/components/Map/components/MapLayer/interfaces/index.js +1 -0
- package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +381 -0
- package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/index.js +107 -0
- package/{src/components/Map/components/MapProvider/hooks/index.ts → build/es/components/Map/components/MapProvider/hooks/index.js} +3 -6
- package/build/es/components/Map/components/MapProvider/index.js +112 -0
- package/build/es/components/Map/components/MapUpdater/index.js +17 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +23 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +31 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.js +33 -0
- package/{src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.ts → build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.js} +46 -59
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.js +53 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +15 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +12 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.js +56 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.js +64 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.js +38 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.js +70 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/index.js +254 -0
- package/{src/components/Map/constants/colors.ts → build/es/components/Map/constants/colors.js} +46 -59
- package/build/es/components/Map/constants/legendSet.js +15 -0
- package/build/es/components/Map/hooks/map.js +44 -0
- package/build/es/components/Map/index.js +51 -0
- package/build/es/components/Map/interfaces/index.js +1 -0
- package/build/es/components/Map/state/index.js +14 -0
- package/build/es/components/Map/utils/colors.js +61 -0
- package/build/es/components/Map/utils/helpers.js +14 -0
- package/build/es/components/Map/utils/map.js +147 -0
- package/build/es/components/SingleValueContainer/SingleValueContainer.stories.js +115 -0
- package/build/es/components/SingleValueContainer/SingleValueContainer.test.js +20 -0
- package/build/es/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.js +47 -0
- package/build/es/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.js +17 -0
- package/build/es/components/SingleValueContainer/index.js +29 -0
- package/build/es/components/SingleValueContainer/styles/SingleValueContainer.module.css +39 -0
- package/build/es/components/SingleValueContainer/types/props.js +1 -0
- package/build/es/data/map.json +5984 -0
- package/build/es/dataProviders/map.js +24 -0
- package/{src/index.ts → build/es/index.js} +1 -0
- package/build/es/index.test.js +6 -0
- package/build/es/locales/en/translations.json +128 -0
- package/build/es/locales/index.js +13 -0
- package/package.json +21 -4
- package/d2.config.js +0 -8
- package/i18n/en.pot +0 -409
- package/src/components/ChartAnalytics/ChartAnalytics.stories.tsx +0 -250
- package/src/components/ChartAnalytics/ChartAnalytics.test.tsx +0 -51
- package/src/components/ChartAnalytics/components/DownloadMenu/components/Menu.tsx +0 -48
- package/src/components/ChartAnalytics/components/DownloadMenu/constants/menu.ts +0 -38
- package/src/components/ChartAnalytics/components/DownloadMenu/index.tsx +0 -67
- package/src/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.ts +0 -1
- package/src/components/ChartAnalytics/hooks/useChart.ts +0 -35
- package/src/components/ChartAnalytics/index.tsx +0 -23
- package/src/components/ChartAnalytics/models/column.ts +0 -50
- package/src/components/ChartAnalytics/models/index.ts +0 -78
- package/src/components/ChartAnalytics/models/line.ts +0 -31
- package/src/components/ChartAnalytics/models/multi-series.ts +0 -115
- package/src/components/ChartAnalytics/models/pie.ts +0 -54
- package/src/components/ChartAnalytics/services/export.ts +0 -38
- package/src/components/ChartAnalytics/types/props.tsx +0 -48
- package/src/components/ChartAnalytics/utils/chart.ts +0 -123
- package/src/components/CircularProgressDashboard/CircularProgressIndicator.test.tsx +0 -9
- package/src/components/CircularProgressDashboard/index.tsx +0 -35
- package/src/components/CircularProgressDashboard/types/props.tsx +0 -17
- package/src/components/Map/Map.stories.tsx +0 -339
- package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.tsx +0 -28
- package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.tsx +0 -34
- package/src/components/Map/components/EarthEngineLayerConfiguration/index.tsx +0 -412
- package/src/components/Map/components/MapArea/index.tsx +0 -83
- package/src/components/Map/components/MapArea/interfaces/index.ts +0 -39
- package/src/components/Map/components/MapControls/components/CustomControl/index.tsx +0 -24
- package/src/components/Map/components/MapControls/components/DownloadControl/index.tsx +0 -10
- package/src/components/Map/components/MapControls/components/FullscreenControl/index.tsx +0 -7
- package/src/components/Map/components/MapControls/index.tsx +0 -24
- package/src/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.ts +0 -7
- package/src/components/Map/components/MapLayer/components/BoundaryLayer/index.tsx +0 -55
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.tsx +0 -76
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.ts +0 -430
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.ts +0 -34
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/index.tsx +0 -185
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.ts +0 -56
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +0 -34233
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.ts +0 -431
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.ts +0 -105
- package/src/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.tsx +0 -17
- package/src/components/Map/components/MapLayer/components/LegendArea/index.tsx +0 -168
- package/src/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.tsx +0 -44
- package/src/components/Map/components/MapLayer/components/PointLayer/hooks/index.ts +0 -8
- package/src/components/Map/components/MapLayer/components/PointLayer/index.tsx +0 -36
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.tsx +0 -48
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.tsx +0 -39
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.tsx +0 -57
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.tsx +0 -43
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx +0 -38
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx +0 -26
- package/src/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.ts +0 -10
- package/src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx +0 -46
- package/src/components/Map/components/MapLayer/index.tsx +0 -32
- package/src/components/Map/components/MapLayer/interfaces/index.ts +0 -139
- package/src/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.tsx +0 -359
- package/src/components/Map/components/MapProvider/components/MapLayerProvider/index.tsx +0 -105
- package/src/components/Map/components/MapProvider/index.tsx +0 -93
- package/src/components/Map/components/MapUpdater/index.tsx +0 -8
- package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.tsx +0 -28
- package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.tsx +0 -34
- package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.tsx +0 -24
- package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.tsx +0 -50
- package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.ts +0 -91
- package/src/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.tsx +0 -45
- package/src/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.tsx +0 -47
- package/src/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.tsx +0 -57
- package/src/components/Map/components/ThematicLayerConfiguration/index.tsx +0 -248
- package/src/components/Map/constants/legendSet.ts +0 -19
- package/src/components/Map/hooks/map.ts +0 -47
- package/src/components/Map/index.tsx +0 -65
- package/src/components/Map/interfaces/index.ts +0 -57
- package/src/components/Map/state/index.tsx +0 -31
- package/src/components/Map/utils/colors.ts +0 -95
- package/src/components/Map/utils/helpers.ts +0 -15
- package/src/components/Map/utils/map.ts +0 -150
- package/src/components/SingleValueContainer/SingleValueContainer.stories.tsx +0 -146
- package/src/components/SingleValueContainer/SingleValueContainer.test.tsx +0 -24
- package/src/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.tsx +0 -46
- package/src/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.tsx +0 -12
- package/src/components/SingleValueContainer/index.tsx +0 -30
- package/src/components/SingleValueContainer/types/props.tsx +0 -16
- package/src/dataProviders/map.tsx +0 -24
- package/src/index.test.ts +0 -7
- package/tsconfig.json +0 -45
package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js
ADDED
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EarthEngine = void 0;
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
var _lodash = require("lodash");
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
async function importEEModule() {
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
if (import.meta.env.STORYBOOK_BUILD === "true") {
|
|
17
|
+
return await Promise.resolve().then(() => _interopRequireWildcard(require("@google/earthengine")));
|
|
18
|
+
}
|
|
19
|
+
return await Promise.resolve().then(() => _interopRequireWildcard(require("./api")));
|
|
20
|
+
}
|
|
21
|
+
const EE = await importEEModule();
|
|
22
|
+
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
const ee = EE;
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
window.ee = ee;
|
|
27
|
+
const FEATURE_STYLE = {
|
|
28
|
+
color: "FFA500",
|
|
29
|
+
strokeWidth: 2
|
|
30
|
+
};
|
|
31
|
+
const DEFAULT_TILE_SCALE = 1;
|
|
32
|
+
class EarthEngine {
|
|
33
|
+
constructor(_ref) {
|
|
34
|
+
let {
|
|
35
|
+
options
|
|
36
|
+
} = _ref;
|
|
37
|
+
_defineProperty(this, "token", void 0);
|
|
38
|
+
_defineProperty(this, "options", void 0);
|
|
39
|
+
_defineProperty(this, "refresh", void 0);
|
|
40
|
+
_defineProperty(this, "orgUnits", void 0);
|
|
41
|
+
_defineProperty(this, "initialized", false);
|
|
42
|
+
_defineProperty(this, "period", void 0);
|
|
43
|
+
_defineProperty(this, "instance", void 0);
|
|
44
|
+
_defineProperty(this, "scale", void 0);
|
|
45
|
+
_defineProperty(this, "image", void 0);
|
|
46
|
+
_defineProperty(this, "aggregationData", void 0);
|
|
47
|
+
this.options = options;
|
|
48
|
+
this.initialized = true;
|
|
49
|
+
this.getInstance();
|
|
50
|
+
}
|
|
51
|
+
static async setToken(token, refresh) {
|
|
52
|
+
const tokenType = "Bearer";
|
|
53
|
+
function refreshToken(authArgs, callback) {
|
|
54
|
+
refresh().then(_ref2 => {
|
|
55
|
+
let {
|
|
56
|
+
token
|
|
57
|
+
} = _ref2;
|
|
58
|
+
callback({
|
|
59
|
+
...token,
|
|
60
|
+
token_type: tokenType !== null && tokenType !== void 0 ? tokenType : "Bearer",
|
|
61
|
+
state: authArgs === null || authArgs === void 0 ? void 0 : authArgs.scope
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
await new Promise((resolve, reject) => {
|
|
66
|
+
if (ee.data.getAuthToken()) {
|
|
67
|
+
ee.initialize(null, null, resolve, reject);
|
|
68
|
+
}
|
|
69
|
+
if (token) {
|
|
70
|
+
const {
|
|
71
|
+
access_token,
|
|
72
|
+
client_id,
|
|
73
|
+
expires_in
|
|
74
|
+
} = token;
|
|
75
|
+
ee.data.setAuthToken(client_id, tokenType !== null && tokenType !== void 0 ? tokenType : "Bearer", access_token, expires_in, null, () => {
|
|
76
|
+
ee.initialize(null, null, resolve, reject);
|
|
77
|
+
}, false);
|
|
78
|
+
ee.data.setAuthTokenRefresher(refreshToken);
|
|
79
|
+
}
|
|
80
|
+
resolve("Token not found");
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
setOrgUnits(orgUnits) {
|
|
84
|
+
this.orgUnits = orgUnits;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
setPeriod(period) {
|
|
88
|
+
this.period = period;
|
|
89
|
+
}
|
|
90
|
+
async getValue(geoJSON, type) {
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
const point = this.getGeometryByType(geoJSON);
|
|
93
|
+
const reducer = this.getReducerByType(type);
|
|
94
|
+
const image = this.getImage();
|
|
95
|
+
const reducedImage = image.reduceRegion(reducer, point, 1);
|
|
96
|
+
reducedImage.evaluate((data, error) => {
|
|
97
|
+
if (error) {
|
|
98
|
+
reject(error);
|
|
99
|
+
} else {
|
|
100
|
+
resolve(data);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
async getPeriod() {
|
|
106
|
+
const {
|
|
107
|
+
type
|
|
108
|
+
} = this.options;
|
|
109
|
+
if (type !== "ImageCollection") {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const imageCollection = this.instance.distinct("system:time_start").sort("system:time_start", false);
|
|
113
|
+
const featureCollection = ee.FeatureCollection(imageCollection).select(["system:time_start", "system:time_end"], null, false);
|
|
114
|
+
return (0, _utils.getInfo)(featureCollection);
|
|
115
|
+
}
|
|
116
|
+
async info() {
|
|
117
|
+
return new Promise(resolve => {
|
|
118
|
+
this.instance.getInfo(resolve);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
async getScale() {
|
|
122
|
+
try {
|
|
123
|
+
const {
|
|
124
|
+
type
|
|
125
|
+
} = this.options;
|
|
126
|
+
switch (type) {
|
|
127
|
+
case "ImageCollection":
|
|
128
|
+
this.scale = await (0, _utils.getScale)(this.instance.first());
|
|
129
|
+
break;
|
|
130
|
+
default:
|
|
131
|
+
this.scale = await (0, _utils.getScale)(this.getImage());
|
|
132
|
+
}
|
|
133
|
+
} catch (e) {}
|
|
134
|
+
}
|
|
135
|
+
async getFeatureCollectionAggregation() {
|
|
136
|
+
const {
|
|
137
|
+
datasetId
|
|
138
|
+
} = this.options;
|
|
139
|
+
const dataset = ee.FeatureCollection(datasetId);
|
|
140
|
+
const collection = this.getFeatureCollection();
|
|
141
|
+
const aggFeatures = collection === null || collection === void 0 ? void 0 : collection.map(feature => {
|
|
142
|
+
feature = ee.Feature(feature);
|
|
143
|
+
const count = dataset.filterBounds(feature.geometry()).size();
|
|
144
|
+
return feature.set("count", count);
|
|
145
|
+
}).select(["count"], null, false);
|
|
146
|
+
return (0, _utils.getInfo)(aggFeatures).then(_utils.getFeatureCollectionProperties);
|
|
147
|
+
}
|
|
148
|
+
async getHistogramAggregations() {
|
|
149
|
+
try {
|
|
150
|
+
var _head, _this$options$legend, _this$options$tileSca;
|
|
151
|
+
const aggregation = (_head = (0, _lodash.head)(this.options.aggregations)) !== null && _head !== void 0 ? _head : "";
|
|
152
|
+
const reducer = ee.Reducer.frequencyHistogram();
|
|
153
|
+
const collection = this.getFeatureCollection();
|
|
154
|
+
const legend = (_this$options$legend = this.options.legend) === null || _this$options$legend === void 0 ? void 0 : _this$options$legend.items;
|
|
155
|
+
const scale = this.scale;
|
|
156
|
+
const tileScale = (_this$options$tileSca = this.options.tileScale) !== null && _this$options$tileSca !== void 0 ? _this$options$tileSca : DEFAULT_TILE_SCALE;
|
|
157
|
+
const scaleValue = await (0, _utils.getInfo)(scale);
|
|
158
|
+
const image = this.getImage();
|
|
159
|
+
const features = Object.values(await (0, _utils.getInfo)(image.reduceRegions({
|
|
160
|
+
collection,
|
|
161
|
+
reducer,
|
|
162
|
+
scale,
|
|
163
|
+
tileScale
|
|
164
|
+
}).select(["histogram"], null, false)).then(data => (0, _utils.getHistogramStatistics)({
|
|
165
|
+
data,
|
|
166
|
+
scale: scaleValue,
|
|
167
|
+
aggregationType: aggregation,
|
|
168
|
+
legend
|
|
169
|
+
})));
|
|
170
|
+
return features.map((feature, index) => {
|
|
171
|
+
var _this$orgUnits;
|
|
172
|
+
return {
|
|
173
|
+
orgUnit: (_this$orgUnits = this.orgUnits) === null || _this$orgUnits === void 0 ? void 0 : _this$orgUnits[index],
|
|
174
|
+
data: feature
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
} catch (e) {
|
|
178
|
+
throw Error("Could not get histogram", {
|
|
179
|
+
cause: e
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async getAggregations() {
|
|
184
|
+
var _head2, _this$options$tileSca2, _this$orgUnits2;
|
|
185
|
+
await this.getScale();
|
|
186
|
+
const {
|
|
187
|
+
type
|
|
188
|
+
} = this.options;
|
|
189
|
+
if (type === "FeatureCollection") {
|
|
190
|
+
this.aggregationData = await this.getFeatureCollectionAggregation();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const aggregations = this.options.aggregations;
|
|
194
|
+
if (!aggregations) return;
|
|
195
|
+
if ((0, _utils.hasClasses)((_head2 = (0, _lodash.head)(aggregations)) !== null && _head2 !== void 0 ? _head2 : "")) {
|
|
196
|
+
this.aggregationData = await this.getHistogramAggregations();
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const reducer = (0, _utils.combineReducers)(ee)(aggregations);
|
|
200
|
+
const collection = this.getFeatureCollection();
|
|
201
|
+
const image = this.getImage();
|
|
202
|
+
const scale = this.scale;
|
|
203
|
+
const tileScale = (_this$options$tileSca2 = this.options.tileScale) !== null && _this$options$tileSca2 !== void 0 ? _this$options$tileSca2 : DEFAULT_TILE_SCALE;
|
|
204
|
+
const aggregatedFeatures = image.reduceRegions({
|
|
205
|
+
collection,
|
|
206
|
+
reducer,
|
|
207
|
+
scale,
|
|
208
|
+
tileScale
|
|
209
|
+
}).select(aggregations, null, false);
|
|
210
|
+
const features = Object.values((0, _utils.getFeatureCollectionProperties)(await (0, _utils.getInfo)(aggregatedFeatures)));
|
|
211
|
+
if (!(0, _lodash.isEmpty)(features) && features.length === ((_this$orgUnits2 = this.orgUnits) === null || _this$orgUnits2 === void 0 ? void 0 : _this$orgUnits2.length)) {
|
|
212
|
+
//Mapping features to orgUnits using index.
|
|
213
|
+
this.aggregationData = features.map((feature, index) => {
|
|
214
|
+
var _this$orgUnits3;
|
|
215
|
+
return {
|
|
216
|
+
orgUnit: (_this$orgUnits3 = this.orgUnits) === null || _this$orgUnits3 === void 0 ? void 0 : _this$orgUnits3[index],
|
|
217
|
+
data: feature
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
getAggregation(orgUnit) {
|
|
223
|
+
if ((0, _lodash.isEmpty)(this.aggregationData)) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
return (0, _lodash.find)(this.aggregationData, aggregation => aggregation.orgUnit.id === orgUnit.id);
|
|
227
|
+
}
|
|
228
|
+
async url() {
|
|
229
|
+
if (!this.initialized) throw "You need to call init() first";
|
|
230
|
+
return this.visualize(this.getImage());
|
|
231
|
+
}
|
|
232
|
+
applyPeriod(imageCollection) {
|
|
233
|
+
const period = this.period;
|
|
234
|
+
if (period) {
|
|
235
|
+
return imageCollection.filterDate(period);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
applyMask(image) {
|
|
239
|
+
if (this.options.mask) {
|
|
240
|
+
return image.updateMask(image.gt(0));
|
|
241
|
+
} else {
|
|
242
|
+
return image;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
applyBand(imageCollection) {
|
|
246
|
+
if (this.options.selectedBands) {
|
|
247
|
+
return imageCollection.select(this.options.selectedBands);
|
|
248
|
+
} else {
|
|
249
|
+
return imageCollection;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
getReducerByType(type) {
|
|
253
|
+
return ee.Reducer[type].call();
|
|
254
|
+
}
|
|
255
|
+
getGeometryByType(geoJSON) {
|
|
256
|
+
return ee.Geometry(geoJSON === null || geoJSON === void 0 ? void 0 : geoJSON.geometry);
|
|
257
|
+
}
|
|
258
|
+
getFeatureByType(geoJSON) {
|
|
259
|
+
var _geoJSON$features;
|
|
260
|
+
const featureType = geoJSON.type;
|
|
261
|
+
const features = (_geoJSON$features = geoJSON.features) !== null && _geoJSON$features !== void 0 ? _geoJSON$features : [];
|
|
262
|
+
const geometry = this.getGeometryByType(geoJSON);
|
|
263
|
+
switch (featureType) {
|
|
264
|
+
case "Feature":
|
|
265
|
+
return ee.Feature(geometry);
|
|
266
|
+
case "FeatureCollection":
|
|
267
|
+
return ee.FeatureCollection([...features.map(feature => ee.Feature(this.getGeometryByType(feature)))]);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
getFeatureCollection() {
|
|
271
|
+
if (this.orgUnits) {
|
|
272
|
+
return ee.FeatureCollection(this.orgUnits.map(orgUnit => this.getFeatureByType(orgUnit.geoJSON)));
|
|
273
|
+
} else {
|
|
274
|
+
throw "You need to set org units first";
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
getParamsFromLegend() {
|
|
278
|
+
if (!this.options.legend) return;
|
|
279
|
+
const legend = this.options.legend.items;
|
|
280
|
+
const keys = legend.map(l => l.id);
|
|
281
|
+
const min = Math.min(...keys);
|
|
282
|
+
const max = Math.max(...keys);
|
|
283
|
+
const palette = legend.map(l => l.color).join(",");
|
|
284
|
+
return {
|
|
285
|
+
min,
|
|
286
|
+
max,
|
|
287
|
+
palette
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
async visualize(image) {
|
|
291
|
+
var _ref3, _this$getParamsFromLe, _await$Promise;
|
|
292
|
+
const {
|
|
293
|
+
min,
|
|
294
|
+
max,
|
|
295
|
+
palette
|
|
296
|
+
} = (_ref3 = (_this$getParamsFromLe = this.getParamsFromLegend()) !== null && _this$getParamsFromLe !== void 0 ? _this$getParamsFromLe : this.options.params) !== null && _ref3 !== void 0 ? _ref3 : {
|
|
297
|
+
min: null,
|
|
298
|
+
max: null,
|
|
299
|
+
palette: null
|
|
300
|
+
};
|
|
301
|
+
return (_await$Promise = await new Promise((resolve, reject) => {
|
|
302
|
+
image.getMap({
|
|
303
|
+
min,
|
|
304
|
+
max,
|
|
305
|
+
palette
|
|
306
|
+
}, resolve);
|
|
307
|
+
})) === null || _await$Promise === void 0 ? void 0 : _await$Promise.urlFormat;
|
|
308
|
+
}
|
|
309
|
+
getImageCollectionInstance() {
|
|
310
|
+
const {
|
|
311
|
+
datasetId
|
|
312
|
+
} = this.options;
|
|
313
|
+
let imageCollection = ee.ImageCollection(datasetId);
|
|
314
|
+
if (this.period) {
|
|
315
|
+
imageCollection = this.applyPeriod(imageCollection);
|
|
316
|
+
}
|
|
317
|
+
imageCollection = this.applyBand(imageCollection);
|
|
318
|
+
return imageCollection;
|
|
319
|
+
}
|
|
320
|
+
getImageFromImageCollection() {
|
|
321
|
+
const {
|
|
322
|
+
mosaic
|
|
323
|
+
} = this.options;
|
|
324
|
+
const imageCollection = this.instance;
|
|
325
|
+
return mosaic ? imageCollection.mosaic().clipToCollection(this.getFeatureCollection()) : ee.Image(imageCollection.first()).clipToCollection(this.getFeatureCollection());
|
|
326
|
+
}
|
|
327
|
+
getImageInstance() {
|
|
328
|
+
const {
|
|
329
|
+
datasetId
|
|
330
|
+
} = this.options;
|
|
331
|
+
return ee.Image(datasetId).clipToCollection(this.getFeatureCollection());
|
|
332
|
+
}
|
|
333
|
+
getImageFromImage() {
|
|
334
|
+
return this.instance;
|
|
335
|
+
}
|
|
336
|
+
getFeatureInstance() {
|
|
337
|
+
const {
|
|
338
|
+
datasetId
|
|
339
|
+
} = this.options;
|
|
340
|
+
const feature = ee.Feature(datasetId);
|
|
341
|
+
this.instance = feature;
|
|
342
|
+
return feature;
|
|
343
|
+
}
|
|
344
|
+
getImageFromFeature() {
|
|
345
|
+
return this.instance;
|
|
346
|
+
}
|
|
347
|
+
getFeatureCollectionInstance() {
|
|
348
|
+
const {
|
|
349
|
+
datasetId
|
|
350
|
+
} = this.options;
|
|
351
|
+
let featureCollection = ee.FeatureCollection(datasetId);
|
|
352
|
+
if (this.period) {
|
|
353
|
+
featureCollection = this.applyPeriod(featureCollection);
|
|
354
|
+
}
|
|
355
|
+
return featureCollection;
|
|
356
|
+
}
|
|
357
|
+
getImageFromFeatureCollection() {
|
|
358
|
+
let featureCollection = this.instance;
|
|
359
|
+
return featureCollection.draw(FEATURE_STYLE).clipToCollection(this.getFeatureCollection());
|
|
360
|
+
}
|
|
361
|
+
getInstance() {
|
|
362
|
+
const {
|
|
363
|
+
type
|
|
364
|
+
} = this.options;
|
|
365
|
+
switch (type) {
|
|
366
|
+
case "Feature":
|
|
367
|
+
this.instance = this.getFeatureInstance();
|
|
368
|
+
break;
|
|
369
|
+
case "FeatureCollection":
|
|
370
|
+
this.instance = this.getFeatureCollectionInstance();
|
|
371
|
+
break;
|
|
372
|
+
case "Image":
|
|
373
|
+
this.instance = this.getImageInstance();
|
|
374
|
+
break;
|
|
375
|
+
case "ImageCollection":
|
|
376
|
+
this.instance = this.getImageCollectionInstance();
|
|
377
|
+
break;
|
|
378
|
+
default:
|
|
379
|
+
this.instance = this.getImageFromImage();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
getImage() {
|
|
383
|
+
if (this.image) {
|
|
384
|
+
return this.image;
|
|
385
|
+
}
|
|
386
|
+
const {
|
|
387
|
+
type
|
|
388
|
+
} = this.options;
|
|
389
|
+
let image;
|
|
390
|
+
switch (type) {
|
|
391
|
+
case "Feature":
|
|
392
|
+
image = this.getImageFromFeature();
|
|
393
|
+
break;
|
|
394
|
+
case "FeatureCollection":
|
|
395
|
+
image = this.getImageFromFeatureCollection();
|
|
396
|
+
break;
|
|
397
|
+
case "Image":
|
|
398
|
+
image = this.getImageFromImage();
|
|
399
|
+
break;
|
|
400
|
+
case "ImageCollection":
|
|
401
|
+
image = this.getImageFromImageCollection();
|
|
402
|
+
break;
|
|
403
|
+
default:
|
|
404
|
+
image = this.getImageFromImage();
|
|
405
|
+
}
|
|
406
|
+
image = this.applyMask(image);
|
|
407
|
+
image = this.applyBand(image);
|
|
408
|
+
this.image = image;
|
|
409
|
+
return image;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
exports.EarthEngine = EarthEngine;
|
package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hasClasses = exports.getScale = exports.getInfo = exports.getHistogramStatistics = exports.getFeatureCollectionProperties = exports.getClassifiedImage = exports.combineReducers = void 0;
|
|
7
|
+
const combineReducers = ee => types => types.reduce((r, t, i) => i === 0 ? r[t]() : r.combine({
|
|
8
|
+
reducer2: ee.Reducer[t](),
|
|
9
|
+
sharedInputs: true
|
|
10
|
+
}), ee.Reducer);
|
|
11
|
+
exports.combineReducers = combineReducers;
|
|
12
|
+
const getInfo = instance => new Promise((resolve, reject) => instance.evaluate((data, error) => {
|
|
13
|
+
if (error) {
|
|
14
|
+
reject(error);
|
|
15
|
+
} else {
|
|
16
|
+
resolve(data);
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
exports.getInfo = getInfo;
|
|
20
|
+
const getFeatureCollectionProperties = data => data.features.reduce((obj, f) => ({
|
|
21
|
+
...obj,
|
|
22
|
+
[f.id]: f.properties
|
|
23
|
+
}), {});
|
|
24
|
+
exports.getFeatureCollectionProperties = getFeatureCollectionProperties;
|
|
25
|
+
const getScale = async image => {
|
|
26
|
+
return image.select(0).projection().nominalScale();
|
|
27
|
+
};
|
|
28
|
+
exports.getScale = getScale;
|
|
29
|
+
const getParamsFromLegend = legend => {
|
|
30
|
+
const keys = legend.map(l => l.id);
|
|
31
|
+
const min = Math.min(...keys);
|
|
32
|
+
const max = Math.max(...keys);
|
|
33
|
+
const palette = legend.map(l => l.color).join(",");
|
|
34
|
+
return {
|
|
35
|
+
min,
|
|
36
|
+
max,
|
|
37
|
+
palette
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const getClassifiedImage = (eeImage, _ref) => {
|
|
41
|
+
var _legends$items;
|
|
42
|
+
let {
|
|
43
|
+
legend: legends,
|
|
44
|
+
params
|
|
45
|
+
} = _ref;
|
|
46
|
+
const legend = (_legends$items = legends === null || legends === void 0 ? void 0 : legends.items) !== null && _legends$items !== void 0 ? _legends$items : [];
|
|
47
|
+
if (!params) {
|
|
48
|
+
// Image has classes (e.g. landcover)
|
|
49
|
+
return {
|
|
50
|
+
eeImage,
|
|
51
|
+
params: getParamsFromLegend(legend)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const min = 0;
|
|
55
|
+
const max = legend.length - 1;
|
|
56
|
+
const {
|
|
57
|
+
palette
|
|
58
|
+
} = params;
|
|
59
|
+
let zones;
|
|
60
|
+
for (let i = min, item; i < max; i++) {
|
|
61
|
+
item = legend[i];
|
|
62
|
+
if (!zones) {
|
|
63
|
+
zones = eeImage.gt(item.to);
|
|
64
|
+
} else {
|
|
65
|
+
zones = zones.add(eeImage.gt(item.to));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
eeImage: zones,
|
|
70
|
+
params: {
|
|
71
|
+
min,
|
|
72
|
+
max,
|
|
73
|
+
palette
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
exports.getClassifiedImage = getClassifiedImage;
|
|
78
|
+
const squareMetersToHectares = value => value / 10000;
|
|
79
|
+
const squareMetersToAcres = value => value / 4046.8564224;
|
|
80
|
+
const classAggregation = ["percentage", "hectares", "acres"];
|
|
81
|
+
const hasClasses = type => classAggregation.includes(type);
|
|
82
|
+
exports.hasClasses = hasClasses;
|
|
83
|
+
const getHistogramStatistics = _ref2 => {
|
|
84
|
+
let {
|
|
85
|
+
data,
|
|
86
|
+
scale,
|
|
87
|
+
aggregationType,
|
|
88
|
+
legend
|
|
89
|
+
} = _ref2;
|
|
90
|
+
return data.features.reduce((obj, _ref3) => {
|
|
91
|
+
let {
|
|
92
|
+
id,
|
|
93
|
+
properties
|
|
94
|
+
} = _ref3;
|
|
95
|
+
const {
|
|
96
|
+
histogram
|
|
97
|
+
} = properties;
|
|
98
|
+
const sum = Object.values(histogram).reduce((a, b) => a + b, 0);
|
|
99
|
+
obj[id] = legend.reduce((values, _ref4) => {
|
|
100
|
+
let {
|
|
101
|
+
id
|
|
102
|
+
} = _ref4;
|
|
103
|
+
const count = histogram[id] || 0;
|
|
104
|
+
const sqMeters = count * (scale * scale);
|
|
105
|
+
let value;
|
|
106
|
+
switch (aggregationType) {
|
|
107
|
+
case "hectares":
|
|
108
|
+
value = Math.round(squareMetersToHectares(sqMeters));
|
|
109
|
+
break;
|
|
110
|
+
case "acres":
|
|
111
|
+
value = Math.round(squareMetersToAcres(sqMeters));
|
|
112
|
+
break;
|
|
113
|
+
default:
|
|
114
|
+
value = count / sum * 100;
|
|
115
|
+
// percentage
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
values[id] = value;
|
|
119
|
+
return values;
|
|
120
|
+
}, {});
|
|
121
|
+
return obj;
|
|
122
|
+
}, {});
|
|
123
|
+
};
|
|
124
|
+
exports.getHistogramStatistics = getHistogramStatistics;
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = LegendCardHeader;
|
|
7
|
+
var _ui = require("@dhis2/ui");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function LegendCardHeader(_ref) {
|
|
11
|
+
let {
|
|
12
|
+
title,
|
|
13
|
+
collapsible,
|
|
14
|
+
onCollapse
|
|
15
|
+
} = _ref;
|
|
16
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
17
|
+
className: "row w-100 space-between align-items-center"
|
|
18
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
19
|
+
style: {
|
|
20
|
+
margin: 0
|
|
21
|
+
},
|
|
22
|
+
className: "legend-header"
|
|
23
|
+
}, title), collapsible && /*#__PURE__*/_react.default.createElement("div", {
|
|
24
|
+
onClick: onCollapse
|
|
25
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.IconLaunch16, null)));
|
|
26
|
+
}
|