@hisptz/dhis2-analytics 1.0.4 → 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 -423
- 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/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.ts
DELETED
|
@@ -1,423 +0,0 @@
|
|
|
1
|
-
import {MapOrgUnit} from "../../../../../interfaces";
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import EE from "./api";
|
|
4
|
-
// import EE from "@google/earthengine";
|
|
5
|
-
import {EarthEngineOptions, EarthEngineToken, RefreshToken} from "../interfaces";
|
|
6
|
-
import {
|
|
7
|
-
combineReducers,
|
|
8
|
-
getFeatureCollectionProperties,
|
|
9
|
-
getHistogramStatistics,
|
|
10
|
-
getInfo,
|
|
11
|
-
getScale,
|
|
12
|
-
hasClasses
|
|
13
|
-
} from "../utils";
|
|
14
|
-
import {find, head, isEmpty} from "lodash";
|
|
15
|
-
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
const ee = EE as any;
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
window.ee = ee;
|
|
20
|
-
|
|
21
|
-
const FEATURE_STYLE = { color: "FFA500", strokeWidth: 2 };
|
|
22
|
-
const DEFAULT_TILE_SCALE = 1;
|
|
23
|
-
|
|
24
|
-
export class EarthEngine {
|
|
25
|
-
token?: EarthEngineToken;
|
|
26
|
-
options: EarthEngineOptions;
|
|
27
|
-
refresh?: RefreshToken;
|
|
28
|
-
orgUnits?: MapOrgUnit[];
|
|
29
|
-
initialized = false;
|
|
30
|
-
period?: string | string[];
|
|
31
|
-
instance: any;
|
|
32
|
-
scale?: any;
|
|
33
|
-
image: any;
|
|
34
|
-
aggregationData: any;
|
|
35
|
-
|
|
36
|
-
constructor({ options }: { options: EarthEngineOptions }) {
|
|
37
|
-
this.options = options;
|
|
38
|
-
this.initialized = true;
|
|
39
|
-
this.getInstance();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static async setToken(token: EarthEngineToken, refresh: RefreshToken): Promise<void> {
|
|
43
|
-
const tokenType = "Bearer";
|
|
44
|
-
|
|
45
|
-
function refreshToken(authArgs: { scope: any }, callback: (props: any) => void) {
|
|
46
|
-
refresh().then(({ token }: { token: EarthEngineToken }) => {
|
|
47
|
-
callback({
|
|
48
|
-
...token,
|
|
49
|
-
token_type: tokenType ?? "Bearer",
|
|
50
|
-
state: authArgs?.scope,
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
await new Promise((resolve, reject) => {
|
|
56
|
-
if (ee.data.getAuthToken()) {
|
|
57
|
-
ee.initialize(null, null, resolve, reject);
|
|
58
|
-
}
|
|
59
|
-
if (token) {
|
|
60
|
-
const { access_token, client_id, expires_in } = token;
|
|
61
|
-
ee.data.setAuthToken(
|
|
62
|
-
client_id,
|
|
63
|
-
tokenType ?? "Bearer",
|
|
64
|
-
access_token,
|
|
65
|
-
expires_in,
|
|
66
|
-
null,
|
|
67
|
-
() => {
|
|
68
|
-
ee.initialize(null, null, resolve, reject);
|
|
69
|
-
},
|
|
70
|
-
false
|
|
71
|
-
);
|
|
72
|
-
ee.data.setAuthTokenRefresher(refreshToken);
|
|
73
|
-
}
|
|
74
|
-
resolve("Token not found");
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
setOrgUnits(orgUnits: MapOrgUnit[]): EarthEngine {
|
|
79
|
-
this.orgUnits = orgUnits;
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
setPeriod(period: string) {
|
|
84
|
-
this.period = period;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async getValue(geoJSON: any, type: string) {
|
|
88
|
-
return new Promise((resolve, reject) => {
|
|
89
|
-
const point = this.getGeometryByType(geoJSON);
|
|
90
|
-
const reducer = this.getReducerByType(type);
|
|
91
|
-
const image = this.getImage();
|
|
92
|
-
|
|
93
|
-
const reducedImage = image.reduceRegion(reducer, point, 1);
|
|
94
|
-
|
|
95
|
-
reducedImage.evaluate((data: unknown, error: any) => {
|
|
96
|
-
if (error) {
|
|
97
|
-
reject(error);
|
|
98
|
-
} else {
|
|
99
|
-
resolve(data);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async getPeriod() {
|
|
106
|
-
const { type } = this.options;
|
|
107
|
-
if (type !== "ImageCollection") {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const imageCollection = this.instance.distinct("system:time_start").sort("system:time_start", false);
|
|
112
|
-
const featureCollection = ee.FeatureCollection(imageCollection).select(["system:time_start", "system:time_end"], null, false);
|
|
113
|
-
|
|
114
|
-
return getInfo(featureCollection);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async info() {
|
|
118
|
-
return new Promise((resolve) => {
|
|
119
|
-
this.instance.getInfo(resolve);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async getScale() {
|
|
124
|
-
try {
|
|
125
|
-
const { type } = this.options;
|
|
126
|
-
switch (type) {
|
|
127
|
-
case "ImageCollection":
|
|
128
|
-
this.scale = await getScale(this.instance.first());
|
|
129
|
-
break;
|
|
130
|
-
default:
|
|
131
|
-
this.scale = await getScale(this.getImage());
|
|
132
|
-
}
|
|
133
|
-
} catch (e) {}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async getFeatureCollectionAggregation() {
|
|
137
|
-
const { datasetId } = this.options;
|
|
138
|
-
const dataset = ee.FeatureCollection(datasetId);
|
|
139
|
-
const collection = this.getFeatureCollection() as any;
|
|
140
|
-
const aggFeatures = collection
|
|
141
|
-
?.map((feature: any) => {
|
|
142
|
-
feature = ee.Feature(feature);
|
|
143
|
-
const count = dataset.filterBounds(feature.geometry()).size();
|
|
144
|
-
|
|
145
|
-
return feature.set("count", count);
|
|
146
|
-
})
|
|
147
|
-
.select(["count"], null, false);
|
|
148
|
-
|
|
149
|
-
return getInfo(aggFeatures).then(getFeatureCollectionProperties);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async getHistogramAggregations() {
|
|
153
|
-
try {
|
|
154
|
-
const aggregation = head(this.options.aggregations) ?? "";
|
|
155
|
-
const reducer = ee.Reducer.frequencyHistogram();
|
|
156
|
-
const collection = this.getFeatureCollection();
|
|
157
|
-
const legend = this.options.legend?.items;
|
|
158
|
-
const scale = this.scale;
|
|
159
|
-
const tileScale = this.options.tileScale ?? DEFAULT_TILE_SCALE;
|
|
160
|
-
const scaleValue = await getInfo(scale);
|
|
161
|
-
|
|
162
|
-
const image = this.getImage();
|
|
163
|
-
const features = Object.values(
|
|
164
|
-
await getInfo(
|
|
165
|
-
image
|
|
166
|
-
.reduceRegions({
|
|
167
|
-
collection,
|
|
168
|
-
reducer,
|
|
169
|
-
scale,
|
|
170
|
-
tileScale,
|
|
171
|
-
})
|
|
172
|
-
.select(["histogram"], null, false)
|
|
173
|
-
).then((data) =>
|
|
174
|
-
getHistogramStatistics({
|
|
175
|
-
data,
|
|
176
|
-
scale: scaleValue,
|
|
177
|
-
aggregationType: aggregation,
|
|
178
|
-
legend,
|
|
179
|
-
})
|
|
180
|
-
)
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
return features.map((feature: any, index: number) => {
|
|
184
|
-
return {
|
|
185
|
-
orgUnit: this.orgUnits?.[index],
|
|
186
|
-
data: feature,
|
|
187
|
-
};
|
|
188
|
-
});
|
|
189
|
-
} catch (e: any) {
|
|
190
|
-
throw Error("Could not get histogram", {
|
|
191
|
-
cause: e,
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
async getAggregations() {
|
|
197
|
-
await this.getScale();
|
|
198
|
-
const { type } = this.options;
|
|
199
|
-
if (type === "FeatureCollection") {
|
|
200
|
-
this.aggregationData = await this.getFeatureCollectionAggregation();
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
const aggregations = this.options.aggregations;
|
|
204
|
-
if (!aggregations) return;
|
|
205
|
-
|
|
206
|
-
if (hasClasses(head(aggregations) ?? "")) {
|
|
207
|
-
this.aggregationData = await this.getHistogramAggregations();
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const reducer = combineReducers(ee)(aggregations);
|
|
212
|
-
const collection = this.getFeatureCollection();
|
|
213
|
-
const image = this.getImage();
|
|
214
|
-
const scale = this.scale;
|
|
215
|
-
const tileScale = this.options.tileScale ?? DEFAULT_TILE_SCALE;
|
|
216
|
-
const aggregatedFeatures = image
|
|
217
|
-
.reduceRegions({
|
|
218
|
-
collection,
|
|
219
|
-
reducer,
|
|
220
|
-
scale,
|
|
221
|
-
tileScale,
|
|
222
|
-
})
|
|
223
|
-
.select(aggregations, null, false);
|
|
224
|
-
|
|
225
|
-
const features = Object.values(getFeatureCollectionProperties(await getInfo(aggregatedFeatures))) as any[];
|
|
226
|
-
if (!isEmpty(features) && features.length === this.orgUnits?.length) {
|
|
227
|
-
//Mapping features to orgUnits using index.
|
|
228
|
-
this.aggregationData = features.map((feature: any, index: number) => {
|
|
229
|
-
return {
|
|
230
|
-
orgUnit: this.orgUnits?.[index],
|
|
231
|
-
data: feature,
|
|
232
|
-
};
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
getAggregation(orgUnit: MapOrgUnit) {
|
|
238
|
-
if (isEmpty(this.aggregationData)) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
return find(this.aggregationData, (aggregation) => aggregation.orgUnit.id === orgUnit.id);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
async url(): Promise<string> {
|
|
245
|
-
if (!this.initialized) throw "You need to call init() first";
|
|
246
|
-
return this.visualize(this.getImage());
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
protected applyPeriod(imageCollection: any) {
|
|
250
|
-
const period = this.period;
|
|
251
|
-
if (period) {
|
|
252
|
-
return imageCollection.filterDate(period);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
protected applyMask(image: any) {
|
|
257
|
-
if (this.options.mask) {
|
|
258
|
-
return image.updateMask(image.gt(0));
|
|
259
|
-
} else {
|
|
260
|
-
return image;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
protected applyBand(imageCollection: any) {
|
|
265
|
-
if (this.options.selectedBands) {
|
|
266
|
-
return imageCollection.select(this.options.selectedBands);
|
|
267
|
-
} else {
|
|
268
|
-
return imageCollection;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
protected getReducerByType(type: string) {
|
|
273
|
-
return ee.Reducer[type].call();
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
protected getGeometryByType(geoJSON: any) {
|
|
277
|
-
return ee.Geometry(geoJSON?.geometry);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
protected getFeatureByType(geoJSON: any) {
|
|
281
|
-
const featureType = geoJSON.type;
|
|
282
|
-
const features = geoJSON.features ?? [];
|
|
283
|
-
const geometry = this.getGeometryByType(geoJSON);
|
|
284
|
-
switch (featureType) {
|
|
285
|
-
case "Feature":
|
|
286
|
-
return ee.Feature(geometry);
|
|
287
|
-
case "FeatureCollection":
|
|
288
|
-
return ee.FeatureCollection([...features.map((feature: any) => ee.Feature(this.getGeometryByType(feature)))]);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
protected getFeatureCollection(): unknown {
|
|
293
|
-
if (this.orgUnits) {
|
|
294
|
-
return ee.FeatureCollection(this.orgUnits.map((orgUnit: MapOrgUnit) => this.getFeatureByType(orgUnit.geoJSON)));
|
|
295
|
-
} else {
|
|
296
|
-
throw "You need to set org units first";
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
protected getParamsFromLegend() {
|
|
301
|
-
if (!this.options.legend) return;
|
|
302
|
-
const legend = this.options.legend.items;
|
|
303
|
-
const keys = legend.map((l) => l.id);
|
|
304
|
-
const min = Math.min(...keys);
|
|
305
|
-
const max = Math.max(...keys);
|
|
306
|
-
const palette = legend.map((l) => l.color).join(",");
|
|
307
|
-
return { min, max, palette };
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
protected async visualize(image: any): Promise<string> {
|
|
311
|
-
const { min, max, palette } = this.getParamsFromLegend() ??
|
|
312
|
-
this.options.params ?? {
|
|
313
|
-
min: null,
|
|
314
|
-
max: null,
|
|
315
|
-
palette: null,
|
|
316
|
-
};
|
|
317
|
-
return (
|
|
318
|
-
(await new Promise((resolve, reject) => {
|
|
319
|
-
image.getMap({ min, max, palette }, resolve);
|
|
320
|
-
})) as any
|
|
321
|
-
)?.urlFormat;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
protected getImageCollectionInstance() {
|
|
325
|
-
const { datasetId } = this.options;
|
|
326
|
-
let imageCollection = ee.ImageCollection(datasetId);
|
|
327
|
-
if (this.period) {
|
|
328
|
-
imageCollection = this.applyPeriod(imageCollection);
|
|
329
|
-
}
|
|
330
|
-
imageCollection = this.applyBand(imageCollection);
|
|
331
|
-
return imageCollection;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
protected getImageFromImageCollection() {
|
|
335
|
-
const { mosaic } = this.options;
|
|
336
|
-
const imageCollection = this.instance;
|
|
337
|
-
return mosaic
|
|
338
|
-
? imageCollection.mosaic().clipToCollection(this.getFeatureCollection())
|
|
339
|
-
: ee.Image(imageCollection.first()).clipToCollection(this.getFeatureCollection());
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
protected getImageInstance() {
|
|
343
|
-
const { datasetId } = this.options;
|
|
344
|
-
return ee.Image(datasetId).clipToCollection(this.getFeatureCollection());
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
protected getImageFromImage() {
|
|
348
|
-
return this.instance;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
protected getFeatureInstance() {
|
|
352
|
-
const { datasetId } = this.options;
|
|
353
|
-
const feature = ee.Feature(datasetId);
|
|
354
|
-
this.instance = feature;
|
|
355
|
-
return feature;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
protected getImageFromFeature() {
|
|
359
|
-
return this.instance;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
protected getFeatureCollectionInstance() {
|
|
363
|
-
const { datasetId } = this.options;
|
|
364
|
-
let featureCollection = ee.FeatureCollection(datasetId);
|
|
365
|
-
if (this.period) {
|
|
366
|
-
featureCollection = this.applyPeriod(featureCollection);
|
|
367
|
-
}
|
|
368
|
-
return featureCollection;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
protected getImageFromFeatureCollection() {
|
|
372
|
-
let featureCollection = this.instance;
|
|
373
|
-
return featureCollection.draw(FEATURE_STYLE).clipToCollection(this.getFeatureCollection());
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
protected getInstance() {
|
|
377
|
-
const { type } = this.options;
|
|
378
|
-
switch (type) {
|
|
379
|
-
case "Feature":
|
|
380
|
-
this.instance = this.getFeatureInstance();
|
|
381
|
-
break;
|
|
382
|
-
case "FeatureCollection":
|
|
383
|
-
this.instance = this.getFeatureCollectionInstance();
|
|
384
|
-
break;
|
|
385
|
-
case "Image":
|
|
386
|
-
this.instance = this.getImageInstance();
|
|
387
|
-
break;
|
|
388
|
-
case "ImageCollection":
|
|
389
|
-
this.instance = this.getImageCollectionInstance();
|
|
390
|
-
break;
|
|
391
|
-
default:
|
|
392
|
-
this.instance = this.getImageFromImage();
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
protected getImage(): any {
|
|
397
|
-
if (this.image) {
|
|
398
|
-
return this.image;
|
|
399
|
-
}
|
|
400
|
-
const { type } = this.options;
|
|
401
|
-
let image;
|
|
402
|
-
switch (type) {
|
|
403
|
-
case "Feature":
|
|
404
|
-
image = this.getImageFromFeature();
|
|
405
|
-
break;
|
|
406
|
-
case "FeatureCollection":
|
|
407
|
-
image = this.getImageFromFeatureCollection();
|
|
408
|
-
break;
|
|
409
|
-
case "Image":
|
|
410
|
-
image = this.getImageFromImage();
|
|
411
|
-
break;
|
|
412
|
-
case "ImageCollection":
|
|
413
|
-
image = this.getImageFromImageCollection();
|
|
414
|
-
break;
|
|
415
|
-
default:
|
|
416
|
-
image = this.getImageFromImage();
|
|
417
|
-
}
|
|
418
|
-
image = this.applyMask(image);
|
|
419
|
-
image = this.applyBand(image);
|
|
420
|
-
this.image = image;
|
|
421
|
-
return image;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import {EarthEngineOptions} from "../interfaces";
|
|
2
|
-
|
|
3
|
-
export const combineReducers = (ee: any) => (types: string[]) =>
|
|
4
|
-
types.reduce(
|
|
5
|
-
(r: any, t: any, i: any) =>
|
|
6
|
-
i === 0
|
|
7
|
-
? r[t]()
|
|
8
|
-
: r.combine({
|
|
9
|
-
reducer2: ee.Reducer[t](),
|
|
10
|
-
sharedInputs: true,
|
|
11
|
-
}),
|
|
12
|
-
ee.Reducer
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
export const getInfo = (instance: any) =>
|
|
16
|
-
new Promise((resolve, reject) =>
|
|
17
|
-
instance.evaluate((data: any, error: Error) => {
|
|
18
|
-
if (error) {
|
|
19
|
-
reject(error);
|
|
20
|
-
} else {
|
|
21
|
-
resolve(data);
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export const getFeatureCollectionProperties = (data: any) =>
|
|
27
|
-
data.features.reduce(
|
|
28
|
-
(obj: any, f: any) => ({
|
|
29
|
-
...obj,
|
|
30
|
-
[f.id]: f.properties,
|
|
31
|
-
}),
|
|
32
|
-
{}
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
export const getScale = async (image: any) => {
|
|
36
|
-
return image.select(0).projection().nominalScale();
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const getParamsFromLegend = (legend: any[]) => {
|
|
40
|
-
const keys = legend.map((l) => l.id);
|
|
41
|
-
const min = Math.min(...keys);
|
|
42
|
-
const max = Math.max(...keys);
|
|
43
|
-
const palette = legend.map((l) => l.color).join(",");
|
|
44
|
-
|
|
45
|
-
return { min, max, palette };
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const getClassifiedImage = (eeImage: any, { legend: legends, params }: EarthEngineOptions) => {
|
|
49
|
-
const legend = legends?.items ?? [];
|
|
50
|
-
if (!params) {
|
|
51
|
-
// Image has classes (e.g. landcover)
|
|
52
|
-
return { eeImage, params: getParamsFromLegend(legend) };
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const min = 0;
|
|
56
|
-
const max = legend.length - 1;
|
|
57
|
-
const { palette } = params;
|
|
58
|
-
let zones;
|
|
59
|
-
|
|
60
|
-
for (let i = min, item; i < max; i++) {
|
|
61
|
-
item = legend[i] as any;
|
|
62
|
-
|
|
63
|
-
if (!zones) {
|
|
64
|
-
zones = eeImage.gt(item.to);
|
|
65
|
-
} else {
|
|
66
|
-
zones = zones.add(eeImage.gt(item.to));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return { eeImage: zones, params: { min, max, palette } };
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const squareMetersToHectares = (value: number) => value / 10000;
|
|
74
|
-
|
|
75
|
-
const squareMetersToAcres = (value: number) => value / 4046.8564224;
|
|
76
|
-
|
|
77
|
-
const classAggregation = ["percentage", "hectares", "acres"];
|
|
78
|
-
|
|
79
|
-
export const hasClasses = (type: string) => classAggregation.includes(type);
|
|
80
|
-
|
|
81
|
-
export const getHistogramStatistics = ({ data, scale, aggregationType, legend }: { data: any; scale: any; aggregationType: string; legend: any }) =>
|
|
82
|
-
data.features.reduce((obj: Record<any, any>, { id, properties }: { id: string; properties: any }) => {
|
|
83
|
-
const { histogram } = properties;
|
|
84
|
-
const sum: number = Object.values(histogram).reduce((a: any, b: any) => a + b, 0) as number;
|
|
85
|
-
obj[id] = legend.reduce((values: any, { id }: { id: string }) => {
|
|
86
|
-
const count = histogram[id] || 0;
|
|
87
|
-
const sqMeters = count * (scale * scale);
|
|
88
|
-
let value;
|
|
89
|
-
switch (aggregationType) {
|
|
90
|
-
case "hectares":
|
|
91
|
-
value = Math.round(squareMetersToHectares(sqMeters));
|
|
92
|
-
break;
|
|
93
|
-
case "acres":
|
|
94
|
-
value = Math.round(squareMetersToAcres(sqMeters));
|
|
95
|
-
break;
|
|
96
|
-
default:
|
|
97
|
-
value = (count / sum) * 100; // percentage
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
values[id] = value;
|
|
101
|
-
|
|
102
|
-
return values;
|
|
103
|
-
}, {});
|
|
104
|
-
return obj;
|
|
105
|
-
}, {});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {IconLaunch16} from "@dhis2/ui";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
export default function LegendCardHeader({ title, collapsible, onCollapse }: { title: string; onCollapse?: () => void; collapsible?: boolean }) {
|
|
5
|
-
return (
|
|
6
|
-
<div className="row w-100 space-between align-items-center">
|
|
7
|
-
<h4 style={{ margin: 0 }} className="legend-header">
|
|
8
|
-
{title}
|
|
9
|
-
</h4>
|
|
10
|
-
{collapsible && (
|
|
11
|
-
<div onClick={onCollapse}>
|
|
12
|
-
<IconLaunch16 />
|
|
13
|
-
</div>
|
|
14
|
-
)}
|
|
15
|
-
</div>
|
|
16
|
-
);
|
|
17
|
-
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import {colors, IconLegend24, Popper, Portal} from "@dhis2/ui";
|
|
2
|
-
import {ControlPosition} from "leaflet";
|
|
3
|
-
import {compact, head} from "lodash";
|
|
4
|
-
import React, {useEffect, useRef, useState} from "react";
|
|
5
|
-
import {MapLegendConfig} from "../../../MapArea/interfaces";
|
|
6
|
-
import {CustomControl} from "../../../MapControls/components/CustomControl";
|
|
7
|
-
import {
|
|
8
|
-
CustomBubbleLayer,
|
|
9
|
-
CustomGoogleEngineLayer,
|
|
10
|
-
CustomPointLayer,
|
|
11
|
-
CustomThematicLayer,
|
|
12
|
-
SUPPORTED_EARTH_ENGINE_LAYERS
|
|
13
|
-
} from "../../interfaces";
|
|
14
|
-
import PointLegend from "../PointLayer/components/PointLegend";
|
|
15
|
-
import BubbleLegend from "../ThematicLayer/components/Bubble/components/BubbleLegend";
|
|
16
|
-
import ChoroplethLegend from "../ThematicLayer/components/Choropleth/components/ChoroplethLegend";
|
|
17
|
-
import EarthEngineLegend from "../GoogleEngineLayer/components/EarthEngineLegend";
|
|
18
|
-
import classes from "./LegendArea.module.css";
|
|
19
|
-
import {usePrintMedia} from "../../../../hooks/map";
|
|
20
|
-
|
|
21
|
-
const TOOLTIP_OFFSET = 4;
|
|
22
|
-
|
|
23
|
-
function getLegendComponent(layer: CustomThematicLayer | CustomPointLayer | CustomGoogleEngineLayer) {
|
|
24
|
-
if (layer.type === "point") {
|
|
25
|
-
return <PointLegend name={layer.label} />;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (SUPPORTED_EARTH_ENGINE_LAYERS.includes(layer.type)) {
|
|
29
|
-
return <EarthEngineLegend name={layer.name ?? ""} layer={layer as CustomGoogleEngineLayer} />;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const { type, enabled, control, dataItem, name, data, legends } = (layer as CustomThematicLayer) ?? {};
|
|
33
|
-
|
|
34
|
-
if (!enabled || !control) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
switch (type) {
|
|
38
|
-
case "bubble":
|
|
39
|
-
return (
|
|
40
|
-
<BubbleLegend
|
|
41
|
-
radius={(layer as CustomBubbleLayer)?.radius ?? { min: 0, max: 50 }}
|
|
42
|
-
legends={legends ?? []}
|
|
43
|
-
name={name ?? dataItem.displayName}
|
|
44
|
-
data={data}
|
|
45
|
-
dataItem={head(data)?.dataItem ?? dataItem}
|
|
46
|
-
/>
|
|
47
|
-
);
|
|
48
|
-
case "choropleth":
|
|
49
|
-
return <ChoroplethLegend legends={legends ?? []} name={name ?? dataItem.displayName} data={data} dataItem={head(data)?.dataItem ?? dataItem} />;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function CollapsedLegendIcon({ onCollapse, name }: { name: string; onCollapse: () => void }) {
|
|
54
|
-
const openDelay = 200;
|
|
55
|
-
const closeDelay = 200;
|
|
56
|
-
const [openTooltip, setOpenTooltip] = useState(false);
|
|
57
|
-
const openTimerRef = useRef<any>(null);
|
|
58
|
-
const closeTimerRef = useRef<any>(null);
|
|
59
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
60
|
-
|
|
61
|
-
const hideModifier = { name: "hide" };
|
|
62
|
-
const offsetModifier = {
|
|
63
|
-
name: "offset",
|
|
64
|
-
options: {
|
|
65
|
-
offset: [0, TOOLTIP_OFFSET],
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const flipModifier = {
|
|
70
|
-
name: "flip",
|
|
71
|
-
options: { altBoundary: true },
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const onMouseOver = () => {
|
|
75
|
-
clearTimeout(closeTimerRef.current);
|
|
76
|
-
|
|
77
|
-
openTimerRef.current = setTimeout(() => {
|
|
78
|
-
setOpenTooltip(true);
|
|
79
|
-
}, openDelay);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const onMouseOut = () => {
|
|
83
|
-
clearTimeout(openTimerRef.current);
|
|
84
|
-
|
|
85
|
-
closeTimerRef.current = setTimeout(() => {
|
|
86
|
-
setOpenTooltip(false);
|
|
87
|
-
}, closeDelay);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
useEffect(
|
|
91
|
-
() => () => {
|
|
92
|
-
clearTimeout(openTimerRef.current);
|
|
93
|
-
clearTimeout(closeTimerRef.current);
|
|
94
|
-
},
|
|
95
|
-
[]
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<div ref={ref} onMouseOver={onMouseOver} onMouseOut={onMouseOut} onClick={onCollapse} style={{ width: 28, height: 28 }} className="legend-card collapsed">
|
|
100
|
-
<IconLegend24 />
|
|
101
|
-
{openTooltip && (
|
|
102
|
-
<Portal className={classes["map-tooltip"]}>
|
|
103
|
-
<Popper className={classes["map-tooltip"]} reference={ref} modifiers={[offsetModifier, flipModifier, hideModifier]}>
|
|
104
|
-
<div
|
|
105
|
-
style={{
|
|
106
|
-
backgroundColor: `${colors.grey900}`,
|
|
107
|
-
borderRadius: 3,
|
|
108
|
-
color: `${colors.white}`,
|
|
109
|
-
padding: "4px 6px",
|
|
110
|
-
}}
|
|
111
|
-
data-test={`content`}>
|
|
112
|
-
{name}
|
|
113
|
-
</div>
|
|
114
|
-
</Popper>
|
|
115
|
-
</Portal>
|
|
116
|
-
)}
|
|
117
|
-
</div>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function Legend({ children, collapsible }: { children: React.ReactElement; collapsible: boolean }) {
|
|
122
|
-
const [collapsed, setCollapsed] = useState(collapsible);
|
|
123
|
-
const inPrintMode = usePrintMedia();
|
|
124
|
-
const onCollapse = () => {
|
|
125
|
-
if (collapsible) {
|
|
126
|
-
setCollapsed((prevState) => !prevState);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const name = head(React.Children.toArray(children) as React.ReactElement[])?.props.name;
|
|
131
|
-
|
|
132
|
-
const shouldCollapse = collapsed && !inPrintMode;
|
|
133
|
-
console.log(inPrintMode);
|
|
134
|
-
|
|
135
|
-
return (
|
|
136
|
-
<div className="w-100">
|
|
137
|
-
{shouldCollapse ? (
|
|
138
|
-
<CollapsedLegendIcon name={name} onCollapse={onCollapse} />
|
|
139
|
-
) : (
|
|
140
|
-
React.Children.map(children, (child) => React.cloneElement(child, { collapsible, onCollapse }))
|
|
141
|
-
)}
|
|
142
|
-
</div>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export default function LegendArea({
|
|
147
|
-
layers,
|
|
148
|
-
legends: legendConfig,
|
|
149
|
-
}: {
|
|
150
|
-
layers: Array<CustomThematicLayer | CustomPointLayer | CustomGoogleEngineLayer>;
|
|
151
|
-
position: ControlPosition;
|
|
152
|
-
legends?: MapLegendConfig;
|
|
153
|
-
}) {
|
|
154
|
-
const legends: JSX.Element[] = compact(layers.filter((layer) => layer.enabled).map(getLegendComponent));
|
|
155
|
-
const { position, collapsible } = legendConfig ?? {};
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<CustomControl position={position}>
|
|
159
|
-
<div className="column gap-16 align-items-end">
|
|
160
|
-
{legends?.map((legend: any, index) => (
|
|
161
|
-
<Legend collapsible={collapsible ?? true} key={`${index}-map-legend`}>
|
|
162
|
-
{legend}
|
|
163
|
-
</Legend>
|
|
164
|
-
))}
|
|
165
|
-
</div>
|
|
166
|
-
</CustomControl>
|
|
167
|
-
);
|
|
168
|
-
}
|