@hisptz/dhis2-analytics 1.0.51 → 1.0.52

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.
Files changed (117) hide show
  1. package/LICENSE +29 -0
  2. package/package.json +4 -4
  3. package/.gitignore +0 -5
  4. package/d2.config.js +0 -8
  5. package/i18n/en.pot +0 -439
  6. package/src/components/ChartAnalytics/ChartAnalytics.test.tsx +0 -51
  7. package/src/components/ChartAnalytics/components/DownloadMenu/components/Menu.tsx +0 -48
  8. package/src/components/ChartAnalytics/components/DownloadMenu/constants/menu.ts +0 -38
  9. package/src/components/ChartAnalytics/components/DownloadMenu/index.tsx +0 -65
  10. package/src/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.ts +0 -1
  11. package/src/components/ChartAnalytics/hooks/useChart.ts +0 -35
  12. package/src/components/ChartAnalytics/index.tsx +0 -28
  13. package/src/components/ChartAnalytics/models/bar.ts +0 -20
  14. package/src/components/ChartAnalytics/models/column.ts +0 -52
  15. package/src/components/ChartAnalytics/models/index.ts +0 -111
  16. package/src/components/ChartAnalytics/models/line.ts +0 -31
  17. package/src/components/ChartAnalytics/models/multi-series.ts +0 -115
  18. package/src/components/ChartAnalytics/models/pie.ts +0 -54
  19. package/src/components/ChartAnalytics/services/export.ts +0 -38
  20. package/src/components/ChartAnalytics/styles/custom-highchart.css +0 -48
  21. package/src/components/ChartAnalytics/types/props.tsx +0 -48
  22. package/src/components/ChartAnalytics/utils/chart.ts +0 -128
  23. package/src/components/CircularProgressDashboard/CircularProgressIndicator.test.tsx +0 -9
  24. package/src/components/CircularProgressDashboard/index.tsx +0 -36
  25. package/src/components/CircularProgressDashboard/types/props.tsx +0 -17
  26. package/src/components/CustomPivotTable/components/Table/index.tsx +0 -23
  27. package/src/components/CustomPivotTable/components/TableBody/TableBody.module.css +0 -12
  28. package/src/components/CustomPivotTable/components/TableBody/index.tsx +0 -96
  29. package/src/components/CustomPivotTable/components/TableHeaders/TableHeaders.module.css +0 -10
  30. package/src/components/CustomPivotTable/components/TableHeaders/index.tsx +0 -94
  31. package/src/components/CustomPivotTable/index.tsx +0 -63
  32. package/src/components/CustomPivotTable/interfaces/index.ts +0 -1
  33. package/src/components/CustomPivotTable/services/engine.ts +0 -102
  34. package/src/components/CustomPivotTable/state/engine.tsx +0 -22
  35. package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.tsx +0 -28
  36. package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.tsx +0 -34
  37. package/src/components/Map/components/EarthEngineLayerConfiguration/index.tsx +0 -412
  38. package/src/components/Map/components/MapArea/index.tsx +0 -83
  39. package/src/components/Map/components/MapArea/interfaces/index.ts +0 -39
  40. package/src/components/Map/components/MapControls/components/CustomControl/index.tsx +0 -24
  41. package/src/components/Map/components/MapControls/components/DownloadControl/index.tsx +0 -11
  42. package/src/components/Map/components/MapControls/components/FullscreenControl/index.tsx +0 -7
  43. package/src/components/Map/components/MapControls/index.tsx +0 -24
  44. package/src/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.ts +0 -7
  45. package/src/components/Map/components/MapLayer/components/BoundaryLayer/index.tsx +0 -55
  46. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.tsx +0 -74
  47. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.ts +0 -430
  48. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.ts +0 -34
  49. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/index.tsx +0 -185
  50. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.ts +0 -56
  51. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +0 -34241
  52. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.ts +0 -431
  53. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.ts +0 -105
  54. package/src/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +0 -12
  55. package/src/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.tsx +0 -17
  56. package/src/components/Map/components/MapLayer/components/LegendArea/index.tsx +0 -167
  57. package/src/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.tsx +0 -44
  58. package/src/components/Map/components/MapLayer/components/PointLayer/hooks/index.ts +0 -8
  59. package/src/components/Map/components/MapLayer/components/PointLayer/index.tsx +0 -36
  60. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.tsx +0 -48
  61. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.tsx +0 -150
  62. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.tsx +0 -39
  63. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.tsx +0 -57
  64. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.tsx +0 -43
  65. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx +0 -38
  66. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx +0 -26
  67. package/src/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.ts +0 -10
  68. package/src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx +0 -46
  69. package/src/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +0 -62
  70. package/src/components/Map/components/MapLayer/index.tsx +0 -32
  71. package/src/components/Map/components/MapLayer/interfaces/index.ts +0 -139
  72. package/src/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.tsx +0 -368
  73. package/src/components/Map/components/MapProvider/components/MapLayerProvider/index.tsx +0 -105
  74. package/src/components/Map/components/MapProvider/hooks/index.ts +0 -14
  75. package/src/components/Map/components/MapProvider/index.tsx +0 -93
  76. package/src/components/Map/components/MapUpdater/index.tsx +0 -8
  77. package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.tsx +0 -28
  78. package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.tsx +0 -34
  79. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.tsx +0 -24
  80. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.ts +0 -433
  81. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.tsx +0 -50
  82. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +0 -15
  83. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +0 -12
  84. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.ts +0 -91
  85. package/src/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.tsx +0 -45
  86. package/src/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.tsx +0 -47
  87. package/src/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.tsx +0 -57
  88. package/src/components/Map/components/ThematicLayerConfiguration/index.tsx +0 -248
  89. package/src/components/Map/constants/colors.ts +0 -434
  90. package/src/components/Map/constants/legendSet.ts +0 -19
  91. package/src/components/Map/hooks/map.ts +0 -47
  92. package/src/components/Map/index.tsx +0 -65
  93. package/src/components/Map/interfaces/index.ts +0 -57
  94. package/src/components/Map/state/index.tsx +0 -31
  95. package/src/components/Map/utils/colors.ts +0 -95
  96. package/src/components/Map/utils/helpers.ts +0 -15
  97. package/src/components/Map/utils/map.ts +0 -150
  98. package/src/components/SingleValueContainer/SingleValueContainer.test.tsx +0 -24
  99. package/src/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.tsx +0 -46
  100. package/src/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.tsx +0 -12
  101. package/src/components/SingleValueContainer/index.tsx +0 -37
  102. package/src/components/SingleValueContainer/styles/SingleValueContainer.module.css +0 -39
  103. package/src/components/SingleValueContainer/types/props.tsx +0 -16
  104. package/src/components/Visualization/components/AnalyticsDataProvider/index.tsx +0 -76
  105. package/src/components/Visualization/components/DimensionsProvider/index.tsx +0 -51
  106. package/src/components/Visualization/components/LayoutProvider/index.tsx +0 -34
  107. package/src/components/Visualization/components/VisualizationDimensionSelector/index.tsx +0 -59
  108. package/src/components/Visualization/components/VisualizationProvider/index.tsx +0 -31
  109. package/src/components/Visualization/components/VisualizationSelector/index.tsx +0 -157
  110. package/src/components/Visualization/components/VisualizationTypeProvider/index.tsx +0 -40
  111. package/src/components/Visualization/components/VisualizationTypeSelector/index.tsx +0 -46
  112. package/src/components/Visualization/index.tsx +0 -103
  113. package/src/index.ts +0 -6
  114. package/src/locales/en/translations.json +0 -138
  115. package/src/locales/index.js +0 -16
  116. package/tsconfig.build.json +0 -46
  117. package/tsconfig.json +0 -51
@@ -1,55 +0,0 @@
1
- import i18n from "@dhis2/d2-i18n";
2
- import {colors} from "@dhis2/ui";
3
- import React from "react";
4
- import {GeoJSON, LayerGroup, LayersControl, Popup, Tooltip} from "react-leaflet";
5
- import {MapOrgUnit} from "../../../../interfaces";
6
- import {highlightFeature, resetHighlight} from "../../../../utils/map";
7
- import {CustomBoundaryLayer as BoundaryLayerInterface} from "../../interfaces";
8
- import {useBoundaryData} from "./hooks/useBoundaryData";
9
-
10
- export const defaultStyle = {
11
- weight: 1,
12
- color: colors.grey900,
13
- fillColor: colors.grey900,
14
- fillOpacity: 0.0,
15
- };
16
- export const highlightStyle = {
17
- weight: 2,
18
- color: colors.grey900,
19
- dashArray: "",
20
- fillOpacity: 0.1,
21
- };
22
-
23
- export default function BoundaryLayer(props: BoundaryLayerInterface) {
24
- const { enabled } = props ?? {};
25
- const orgUnits = useBoundaryData();
26
-
27
- return (
28
- <LayersControl.Overlay checked={enabled} name={i18n.t("Boundaries")}>
29
- <LayerGroup>
30
- {orgUnits?.map((area: MapOrgUnit) => {
31
- return (
32
- <GeoJSON
33
- data={area.geoJSON}
34
- interactive
35
- eventHandlers={{
36
- mouseover: (e) => highlightFeature(e, highlightStyle),
37
- mouseout: (e) => resetHighlight(e, defaultStyle),
38
- }}
39
- key={`${area.id}-polygon`}
40
- pathOptions={defaultStyle}>
41
- <Tooltip>{area.name}</Tooltip>
42
- <Popup minWidth={80}>
43
- <h3>{area.name}</h3>
44
- <div>
45
- <b>Level: </b>
46
- {area.level}
47
- </div>
48
- </Popup>
49
- </GeoJSON>
50
- );
51
- })}
52
- </LayerGroup>
53
- </LayersControl.Overlay>
54
- );
55
- }
@@ -1,74 +0,0 @@
1
- import React, {forwardRef} from "react";
2
- import LegendCardHeader from "../../LegendArea/components/LegendCardHeader";
3
- import {CustomGoogleEngineLayer} from "../../../interfaces";
4
- import {Divider} from "@dhis2/ui";
5
- import i18n from "@dhis2/d2-i18n";
6
- import {isEmpty} from "lodash";
7
-
8
- export function LegendItem({ legend }: { legend: { min: number; max: number; color: string; name?: string } }) {
9
- return (
10
- <div className="legend-item">
11
- <div className="legend-item-color" style={{ backgroundColor: legend.color }} />
12
- {legend.name ? <div className="legend-item-label">{`${legend.name}`}</div> : <div className="legend-item-label">{`${legend.min} - ${legend.max}`}</div>}
13
- </div>
14
- );
15
- }
16
-
17
- function getLegendsFromParams(params?: { min: number; max: number; palette: string | string[] }) {
18
- if (!params) return [];
19
-
20
- const { palette, min, max } = params;
21
- const sanitizedPalette = Array.isArray(palette) ? palette : palette.split(",");
22
- const classes = sanitizedPalette.length;
23
- const difference = max - min;
24
- const interval = Math.round(difference / classes);
25
- const legends = [];
26
- for (let i = 0; i < classes; i++) {
27
- const min = i * interval;
28
- const max = min + interval;
29
-
30
- const name = i === classes - 1 ? `> ${min}` : undefined;
31
-
32
- legends.push({
33
- id: sanitizedPalette[i],
34
- color: sanitizedPalette[i],
35
- min,
36
- max,
37
- name,
38
- });
39
- }
40
-
41
- return legends;
42
- }
43
-
44
- function EarthEngineLegend(
45
- { layer, collapsible, onCollapse, name }: { layer: CustomGoogleEngineLayer; collapsible?: boolean; onCollapse?: () => void; name: string },
46
- ref: React.LegacyRef<HTMLDivElement>
47
- ) {
48
- const { options } = layer;
49
- const legends = options?.legend?.items ?? getLegendsFromParams(options?.params);
50
-
51
- return (
52
- <div style={{ maxWidth: 200, alignItems: "start", gap: 8 }} className="legend-card" ref={ref}>
53
- <LegendCardHeader title={name} collapsible={collapsible} onCollapse={onCollapse} />
54
- <Divider margin={"0"} />
55
- <p style={{ margin: 0 }}>{options?.description ?? ""}</p>
56
- {!isEmpty(legends) && <b>{options?.unit ?? ""}</b>}
57
- <div className="legend-list">
58
- {legends?.map((legend: any) => (
59
- <LegendItem key={`${legend?.color}-legend-list`} legend={legend} />
60
- ))}
61
- </div>
62
- {options?.source && (
63
- <div className="row gap-8">
64
- {i18n.t("Source")}:
65
- <a className="source-url" target="_blank" referrerPolicy="no-referrer" href={options?.sourceUrl}>
66
- {options?.source ?? ""}
67
- </a>
68
- </div>
69
- )}
70
- </div>
71
- );
72
- }
73
-
74
- export default forwardRef(EarthEngineLegend);
@@ -1,430 +0,0 @@
1
- import i18n from "@dhis2/d2-i18n";
2
- import {EarthEngineOptions} from "../interfaces";
3
-
4
- export const EARTH_ENGINE_LAYER = "earthEngine";
5
-
6
- export const EARTH_ENGINE_LAYERS: EarthEngineOptions[] = [
7
- {
8
- layer: EARTH_ENGINE_LAYER,
9
- id: "population",
10
- datasetId: "WorldPop/GP/100m/pop",
11
- type: "ImageCollection",
12
- name: i18n.t("Population"),
13
- unit: i18n.t("people per hectare"),
14
- description: i18n.t("Estimated number of people living in an area."),
15
- source: "WorldPop / Google Earth Engine",
16
- sourceUrl: "https://developers.google.com/earth-engine/datasets/catalog/WorldPop_GP_100m_pop",
17
- img: "images/population.png",
18
- defaultAggregations: ["sum", "mean"],
19
- tokenType: "Bearer",
20
- periodType: "Yearly",
21
- filters: ["period"],
22
- mosaic: true,
23
- params: {
24
- min: 0,
25
- max: 10,
26
- palette: "#fee5d9,#fcbba1,#fc9272,#fb6a4a,#de2d26,#a50f15", // Reds
27
- },
28
- opacity: 0.9,
29
- },
30
- {
31
- layer: EARTH_ENGINE_LAYER,
32
- type: "ImageCollection",
33
- tokenType: "Bearer",
34
- id: "populationAgeGroups",
35
- datasetId: "WorldPop/GP/100m/pop_age_sex_cons_unadj",
36
- name: i18n.t("Population age groups"),
37
- unit: i18n.t("people per hectare"),
38
- description: i18n.t("Estimated number of people living in an area, grouped by age and gender."),
39
- source: "WorldPop / Google Earth Engine",
40
- sourceUrl: "https://developers.google.com/earth-engine/datasets/catalog/WorldPop_GP_100m_pop_age_sex_cons_unadj",
41
- img: "images/population.png",
42
- periodType: "Yearly",
43
- defaultAggregations: ["sum", "mean"],
44
- bands: [
45
- {
46
- id: "M_0",
47
- name: i18n.t("Male 0 - 1 years"),
48
- },
49
- {
50
- id: "M_1",
51
- name: i18n.t("Male 1 - 4 years"),
52
- },
53
- {
54
- id: "M_5",
55
- name: i18n.t("Male 5 - 9 years"),
56
- },
57
- {
58
- id: "M_10",
59
- name: i18n.t("Male 10 - 14 years"),
60
- },
61
- {
62
- id: "M_15",
63
- name: i18n.t("Male 15 - 19 years"),
64
- },
65
- {
66
- id: "M_20",
67
- name: i18n.t("Male 20 - 24 years"),
68
- },
69
- {
70
- id: "M_25",
71
- name: i18n.t("Male 25 - 29 years"),
72
- },
73
- {
74
- id: "M_30",
75
- name: i18n.t("Male 30 - 34 years"),
76
- },
77
- {
78
- id: "M_35",
79
- name: i18n.t("Male 35 - 39 years"),
80
- },
81
- {
82
- id: "M_40",
83
- name: i18n.t("Male 40 - 44 years"),
84
- },
85
- {
86
- id: "M_45",
87
- name: i18n.t("Male 45 - 49 years"),
88
- },
89
- {
90
- id: "M_50",
91
- name: i18n.t("Male 50 - 54 years"),
92
- },
93
- {
94
- id: "M_55",
95
- name: i18n.t("Male 55 - 59 years"),
96
- },
97
- {
98
- id: "M_60",
99
- name: i18n.t("Male 60 - 64 years"),
100
- },
101
- {
102
- id: "M_65",
103
- name: i18n.t("Male 65 - 69 years"),
104
- },
105
- {
106
- id: "M_70",
107
- name: i18n.t("Male 70 - 74 years"),
108
- },
109
- {
110
- id: "M_75",
111
- name: i18n.t("Male 75 - 79 years"),
112
- },
113
- {
114
- id: "M_80",
115
- name: i18n.t("Male 80 years and above"),
116
- },
117
- {
118
- id: "F_0",
119
- name: i18n.t("Female 0 - 1 years"),
120
- },
121
- {
122
- id: "F_1",
123
- name: i18n.t("Female 1 - 4 years"),
124
- },
125
- {
126
- id: "F_5",
127
- name: i18n.t("Female 5 - 9 years"),
128
- },
129
- {
130
- id: "F_10",
131
- name: i18n.t("Female 10 - 14 years"),
132
- },
133
- {
134
- id: "F_15",
135
- name: i18n.t("Female 15 - 19 years"),
136
- },
137
- {
138
- id: "F_20",
139
- name: i18n.t("Female 20 - 24 years"),
140
- },
141
- {
142
- id: "F_25",
143
- name: i18n.t("Female 25 - 29 years"),
144
- },
145
- {
146
- id: "F_30",
147
- name: i18n.t("Female 30 - 34 years"),
148
- },
149
- {
150
- id: "F_35",
151
- name: i18n.t("Female 35 - 39 years"),
152
- },
153
- {
154
- id: "F_40",
155
- name: i18n.t("Female 40 - 44 years"),
156
- },
157
- {
158
- id: "F_45",
159
- name: i18n.t("Female 45 - 49 years"),
160
- },
161
- {
162
- id: "F_50",
163
- name: i18n.t("Female 50 - 54 years"),
164
- },
165
- {
166
- id: "F_55",
167
- name: i18n.t("Female 55 - 59 years"),
168
- },
169
- {
170
- id: "F_60",
171
- name: i18n.t("Female 60 - 64 years"),
172
- },
173
- {
174
- id: "F_65",
175
- name: i18n.t("Female 65 - 69 years"),
176
- },
177
- {
178
- id: "F_70",
179
- name: i18n.t("Female 70 - 74 years"),
180
- multiple: true,
181
- },
182
- {
183
- id: "F_75",
184
- name: i18n.t("Female 75 - 79 years"),
185
- },
186
- {
187
- id: "F_80",
188
- name: i18n.t("Female 80 years and above"),
189
- },
190
- ],
191
- filters: ["period"],
192
- mosaic: true,
193
- params: {
194
- min: 0,
195
- max: 10,
196
- palette: "#fee5d9,#fcbba1,#fc9272,#fb6a4a,#de2d26,#a50f15", // Reds
197
- },
198
- opacity: 0.9,
199
- tileScale: 4,
200
- },
201
- {
202
- layer: EARTH_ENGINE_LAYER,
203
- id: "footprints",
204
- datasetId: "GOOGLE/Research/open-buildings/v1/polygons",
205
- type: "FeatureCollection",
206
- name: i18n.t("Building footprints"),
207
- unit: i18n.t("Number of buildings"),
208
- description: i18n.t("The outlines of buildings derived from high-resolution satellite imagery. Only for the continent of Africa."),
209
- notice: i18n.t("Building counts are only available for smaller organisation unit areas."),
210
- error: i18n.t("Select a smaller area or single organization unit to see the count of buildings."),
211
- source: "NASA / USGS / JPL-Caltech / Google Earth Engine",
212
- sourceUrl: "https://sites.research.google/open-buildings/",
213
- img: "images/buildings.png",
214
- aggregations: ["count"],
215
- defaultAggregations: ["count"],
216
- opacity: 0.9,
217
- tokenType: "Bearer",
218
- },
219
- {
220
- layer: EARTH_ENGINE_LAYER,
221
- id: "elevation",
222
- type: "Image",
223
- tokenType: "Bearer",
224
- datasetId: "USGS/SRTMGL1_003",
225
- name: i18n.t("Elevation"),
226
- unit: i18n.t("meters"),
227
- description: i18n.t("Elevation above sea-level."),
228
- source: "NASA / USGS / JPL-Caltech / Google Earth Engine",
229
- sourceUrl: "https://explorer.earthengine.google.com/#detail/USGS%2FSRTMGL1_003",
230
- img: "images/elevation.png",
231
- aggregations: ["min", "max", "mean", "median", "stdDev", "variance"],
232
- defaultAggregations: ["mean", "min", "max"],
233
- selectedBands: ["elevation"],
234
- params: {
235
- min: 0,
236
- max: 1500,
237
- palette: "#ffffd4,#fee391,#fec44f,#fe9929,#d95f0e,#993404", // YlOrBr
238
- },
239
- opacity: 0.9,
240
- },
241
- {
242
- layer: EARTH_ENGINE_LAYER,
243
- datasetId: "UCSB-CHG/CHIRPS/PENTAD",
244
- id: "precipitation",
245
- type: "ImageCollection",
246
- tokenType: "Bearer",
247
- name: i18n.t("Precipitation"),
248
- unit: i18n.t("millimeter"),
249
- description: i18n.t(
250
- "Precipitation collected from satellite and weather stations on the ground. The values are in millimeters within 5 days periods. Updated monthly, during the 3rd week of the following month."
251
- ),
252
- source: "UCSB / CHG / Google Earth Engine",
253
- sourceUrl: "https://explorer.earthengine.google.com/#detail/UCSB-CHG%2FCHIRPS%2FPENTAD",
254
- periodType: "Custom",
255
- selectedBands: ["precipitation"],
256
- aggregations: ["min", "max", "mean", "median", "stdDev", "variance"],
257
- defaultAggregations: ["mean", "min", "max"],
258
- mask: true,
259
- img: "images/precipitation.png",
260
- params: {
261
- min: 0,
262
- max: 100,
263
- palette: "#eff3ff,#c6dbef,#9ecae1,#6baed6,#3182bd,#08519c", // Blues
264
- },
265
- opacity: 0.9,
266
- },
267
- {
268
- layer: EARTH_ENGINE_LAYER,
269
- datasetId: "MODIS/006/MOD11A2",
270
- id: "temperature",
271
- type: "ImageCollection",
272
- tokenType: "Bearer",
273
- name: i18n.t("Temperature"),
274
- unit: i18n.t("°C during daytime"),
275
- description: i18n.t("Land surface temperatures collected from satellite. Blank spots will appear in areas with a persistent cloud cover."),
276
- source: "NASA LP DAAC / Google Earth Engine",
277
- sourceUrl: "https://explorer.earthengine.google.com/#detail/MODIS%2FMOD11A2",
278
- img: "images/temperature.png",
279
- aggregations: ["min", "max", "mean", "median", "stdDev", "variance"],
280
- defaultAggregations: ["mean", "min", "max"],
281
- periodType: "Custom",
282
- selectedBands: ["LST_Day_1km"],
283
- mask: true,
284
- methods: {
285
- toFloat: [],
286
- multiply: [0.02],
287
- subtract: [273.15],
288
- },
289
- params: {
290
- min: 0,
291
- max: 40,
292
- palette: "#fff5f0,#fee0d2,#fcbba1,#fc9272,#fb6a4a,#ef3b2c,#cb181d,#a50f15,#67000d", // Reds
293
- },
294
- opacity: 0.9,
295
- },
296
- {
297
- layer: EARTH_ENGINE_LAYER,
298
- type: "ImageCollection",
299
- tokenType: "Bearer",
300
- id: "landCover",
301
- datasetId: "MODIS/006/MCD12Q1", // No longer in use: 'MODIS/051/MCD12Q1',
302
- name: i18n.t("Landcover"),
303
- description: i18n.t("Distinct landcover types collected from satellites."),
304
- source: "NASA LP DAAC / Google Earth Engine",
305
- sourceUrl: "https://developers.google.com/earth-engine/datasets/catalog/MODIS_006_MCD12Q1",
306
- periodType: "Yearly",
307
- filters: ["period"],
308
- selectedBands: ["LC_Type1"],
309
- defaultAggregations: ["percentage", "hectares", "acres"],
310
- maxAggregations: 1,
311
- legend: {
312
- items: [
313
- // http://www.eomf.ou.edu/static/IGBP.pdf
314
- {
315
- id: 1,
316
- name: i18n.t("Evergreen Needleleaf forest"),
317
- color: "#162103",
318
- },
319
- {
320
- id: 2,
321
- name: i18n.t("Evergreen Broadleaf forest"),
322
- color: "#235123",
323
- },
324
- {
325
- id: 3,
326
- name: i18n.t("Deciduous Needleleaf forest"),
327
- color: "#399b38",
328
- },
329
- {
330
- id: 4,
331
- name: i18n.t("Deciduous Broadleaf forest"),
332
- color: "#38eb38",
333
- },
334
- {
335
- id: 5,
336
- name: i18n.t("Mixed forest"),
337
- color: "#39723b",
338
- },
339
- {
340
- id: 6,
341
- name: i18n.t("Closed shrublands"),
342
- color: "#6a2424",
343
- },
344
- {
345
- id: 7,
346
- name: i18n.t("Open shrublands"),
347
- color: "#c3a55f",
348
- },
349
- {
350
- id: 8,
351
- name: i18n.t("Woody savannas"),
352
- color: "#b76124",
353
- },
354
- {
355
- id: 9,
356
- name: i18n.t("Savannas"),
357
- color: "#d99125",
358
- },
359
- {
360
- id: 10,
361
- name: i18n.t("Grasslands"),
362
- color: "#92af1f",
363
- },
364
- {
365
- id: 11,
366
- name: i18n.t("Permanent wetlands"),
367
- color: "#10104c",
368
- },
369
- {
370
- id: 12,
371
- name: i18n.t("Croplands"),
372
- color: "#cdb400",
373
- },
374
- {
375
- id: 13,
376
- name: i18n.t("Urban and built-up"),
377
- color: "#cc0202",
378
- },
379
- {
380
- id: 14,
381
- name: i18n.t("Cropland/Natural vegetation mosaic"),
382
- color: "#332808",
383
- },
384
- {
385
- id: 15,
386
- name: i18n.t("Snow and ice"),
387
- color: "#d7cdcc",
388
- },
389
- {
390
- id: 16,
391
- name: i18n.t("Barren or sparsely vegetated"),
392
- color: "#f7e174",
393
- },
394
- {
395
- id: 17,
396
- name: i18n.t("Water"),
397
- color: "#aec3d6",
398
- },
399
- ],
400
- },
401
- mask: false,
402
- img: "images/landcover.png",
403
- opacity: 0.9,
404
- },
405
- {
406
- layer: EARTH_ENGINE_LAYER,
407
- id: "nightLights",
408
- type: "ImageCollection",
409
- tokenType: "Bearer",
410
- legacy: true, // Kept for backward compability
411
- datasetId: "NOAA/DMSP-OLS/NIGHTTIME_LIGHTS",
412
- name: i18n.t("Nighttime lights"),
413
- unit: i18n.t("light intensity"),
414
- description: i18n.t("Light intensity from cities, towns, and other sites with persistent lighting, including gas flares."),
415
- source: "NOAA / Google Earth Engine",
416
- sourceUrl: "https://explorer.earthengine.google.com/#detail/NOAA%2FDMSP-OLS%2FNIGHTTIME_LIGHTS",
417
- periodType: "Yearly",
418
- selectedBands: ["stable_lights"],
419
- mask: true,
420
- img: "images/nighttime.png",
421
- params: {
422
- min: 0,
423
- max: 63,
424
- palette: "#ffffd4,#fee391,#fec44f,#fe9929,#ec7014,#cc4c02,#8c2d04", // YlOrBr
425
- },
426
- opacity: 0.9,
427
- },
428
- ];
429
-
430
- export const SUPPORTED_EARTH_ENGINE_LAYERS = ["population", "landCover", "footprints"];
@@ -1,34 +0,0 @@
1
- import {useDataEngine} from "@dhis2/app-runtime";
2
- import {find} from "lodash";
3
- import {useMapLayers} from "../../../../MapProvider/hooks";
4
- import {CustomGoogleEngineLayer} from "../../../interfaces";
5
- import {EarthEngineToken} from "../interfaces";
6
- import {useState} from "react";
7
-
8
- const googleEngineKeyQuery = {
9
- token: {
10
- resource: "tokens/google",
11
- },
12
- };
13
-
14
- export function useGoogleEngineToken() {
15
- const engine = useDataEngine();
16
- const [loading, setLoading] = useState(false);
17
-
18
- const getToken = async () => {
19
- setLoading(true);
20
- const token = await engine.query(googleEngineKeyQuery);
21
- setLoading(false);
22
- return token;
23
- };
24
-
25
- return {
26
- refresh: getToken as unknown as () => Promise<{ token: EarthEngineToken }>,
27
- loading,
28
- };
29
- }
30
-
31
- export default function useGoogleEngineLayer(layerId: string): CustomGoogleEngineLayer | undefined {
32
- const { layers } = useMapLayers();
33
- return find(layers as CustomGoogleEngineLayer[], ["id", layerId]);
34
- }