@eodash/eodash 5.0.0-alpha.2.9 → 5.0.0-rc

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 (113) hide show
  1. package/README.md +1 -1
  2. package/core/client/App.vue +13 -1
  3. package/core/client/asWebComponent.js +13 -4
  4. package/core/client/components/DashboardLayout.vue +36 -14
  5. package/core/client/components/Loading.vue +6 -9
  6. package/core/client/components/MobileLayout.vue +16 -14
  7. package/core/client/composables/DefineEodash.js +14 -4
  8. package/core/client/composables/DefineTemplate.js +67 -0
  9. package/core/client/composables/DefineWidgets.js +3 -2
  10. package/core/client/composables/EodashMap.js +360 -0
  11. package/core/client/composables/EodashProcess.js +574 -0
  12. package/core/client/composables/index.js +136 -28
  13. package/core/client/eodash.js +395 -80
  14. package/core/client/eodashSTAC/EodashCollection.js +432 -0
  15. package/core/client/eodashSTAC/createLayers.js +315 -0
  16. package/core/client/eodashSTAC/helpers.js +375 -0
  17. package/core/client/eodashSTAC/triggers.js +43 -0
  18. package/core/client/plugins/axios.js +8 -0
  19. package/core/client/plugins/index.js +2 -1
  20. package/core/client/plugins/vuetify.js +2 -1
  21. package/core/client/store/actions.js +79 -0
  22. package/core/client/store/index.js +4 -18
  23. package/core/client/store/stac.js +99 -9
  24. package/core/client/store/states.js +37 -0
  25. package/core/client/{types.d.ts → types.ts} +66 -20
  26. package/core/client/utils/keys.js +2 -0
  27. package/core/client/utils/states.js +22 -0
  28. package/core/client/views/Dashboard.vue +22 -49
  29. package/core/client/vite-env.d.ts +2 -10
  30. package/dist/client/DashboardLayout-232tRmjz.js +84 -0
  31. package/dist/client/DynamicWebComponent-Cl4LqHU6.js +88 -0
  32. package/dist/client/EodashDatePicker-Pok6bZwU.js +306 -0
  33. package/dist/client/EodashItemFilter-16eMMjTV.js +151 -0
  34. package/dist/client/EodashLayerControl-De7IlCm_.js +120 -0
  35. package/dist/client/EodashLayoutSwitcher-C-3-jjn5.js +52 -0
  36. package/dist/client/EodashMap-CMvbfI6-.js +549 -0
  37. package/dist/client/EodashMapBtns-BeknGDtc.js +107 -0
  38. package/dist/client/EodashProcess-BwKAa9Ee.js +1476 -0
  39. package/dist/client/EodashStacInfo-_BfonNUG.js +85 -0
  40. package/dist/client/EodashTools-PD3XPYuR.js +103 -0
  41. package/dist/client/ExportState-DOrT7M15.js +644 -0
  42. package/dist/client/Footer-CCigxYBo.js +141 -0
  43. package/dist/client/Header-C2cdx4gb.js +437 -0
  44. package/dist/client/IframeWrapper-BgM9aU8f.js +28 -0
  45. package/dist/client/MobileLayout-BdiFjHg7.js +1207 -0
  46. package/dist/client/PopUp--_xn1Cms.js +410 -0
  47. package/dist/client/VImg-9xu2l99m.js +384 -0
  48. package/dist/client/VMain-BUs3kDTd.js +43 -0
  49. package/dist/client/VOverlay-D89omJis.js +1453 -0
  50. package/dist/client/VTooltip-CDu3bErh.js +86 -0
  51. package/dist/client/WidgetsContainer-aFG9yFT6.js +83 -0
  52. package/dist/client/asWebComponent-BRGyP_j5.js +11943 -0
  53. package/dist/client/{style.css → eo-dash.css} +2 -2
  54. package/dist/client/eo-dash.js +2 -6
  55. package/dist/client/forwardRefs-CYrR6bMw.js +245 -0
  56. package/dist/client/index-BZwk0V42.js +199 -0
  57. package/dist/client/ssrBoot-BP7SYRyC.js +22 -0
  58. package/dist/client/transition-DG9nRSW4.js +37 -0
  59. package/dist/node/cli.js +4 -4
  60. package/dist/node/types.d.ts +2 -0
  61. package/package.json +73 -38
  62. package/widgets/EodashDatePicker.vue +176 -134
  63. package/widgets/EodashItemFilter.vue +79 -38
  64. package/widgets/EodashLayerControl.vue +111 -0
  65. package/widgets/EodashLayoutSwitcher.vue +36 -0
  66. package/widgets/EodashMap.vue +108 -133
  67. package/widgets/EodashMapBtns.vue +62 -8
  68. package/widgets/EodashProcess.vue +143 -0
  69. package/widgets/EodashStacInfo.vue +82 -0
  70. package/widgets/EodashTools.vue +83 -0
  71. package/widgets/ExportState.vue +17 -13
  72. package/widgets/PopUp.vue +24 -2
  73. package/core/client/SuspensedDashboard.ce.vue +0 -105
  74. package/core/client/asWebComponent.d.ts +0 -23
  75. package/core/client/store/Actions.js +0 -14
  76. package/core/client/store/States.js +0 -16
  77. package/core/client/utils/eodashSTAC.js +0 -249
  78. package/core/client/utils/helpers.js +0 -38
  79. package/dist/client/DashboardLayout-D0ZF6V2S.js +0 -156
  80. package/dist/client/DynamicWebComponent-CPsMSBHi.js +0 -57
  81. package/dist/client/EodashDatePicker-CBQP7u2X.js +0 -252
  82. package/dist/client/EodashItemFilter-DL2ScI-5.js +0 -7671
  83. package/dist/client/EodashMap-CkKoQlmR.js +0 -86917
  84. package/dist/client/EodashMapBtns-yuO2QmiR.js +0 -36
  85. package/dist/client/ExportState-CCzOhppU.js +0 -558
  86. package/dist/client/Footer-BPAND0yG.js +0 -115
  87. package/dist/client/Header-DLhebNvG.js +0 -350
  88. package/dist/client/IframeWrapper-1GEMHlsW.js +0 -19
  89. package/dist/client/MobileLayout-mGkOYRhu.js +0 -945
  90. package/dist/client/PopUp-1d2bBFjw.js +0 -300
  91. package/dist/client/VImg-DxHcztfM.js +0 -291
  92. package/dist/client/VMain-BLX5vRRn.js +0 -39
  93. package/dist/client/VOverlay-CvrYEmLu.js +0 -967
  94. package/dist/client/WidgetsContainer-CmYjvGm7.js +0 -129
  95. package/dist/client/_commonjsHelpers-DaMA6jEr.js +0 -8
  96. package/dist/client/asWebComponent-B91uK0U7.js +0 -20361
  97. package/dist/client/basedecoder-DHcBySSe-BmCFNFnw.js +0 -88
  98. package/dist/client/decoder-CP4lv0Kb-B6yqkcfC.js +0 -10
  99. package/dist/client/deflate-BXt-9JA_-CWfClgpK.js +0 -10
  100. package/dist/client/eodashSTAC-DBjqe_Ho.js +0 -2788
  101. package/dist/client/eox-stacinfo-l7ALSV90.js +0 -13969
  102. package/dist/client/forwardRefs-BJJiadQP.js +0 -185
  103. package/dist/client/index-Q-bHLjxx.js +0 -153
  104. package/dist/client/jpeg-BAgeD1d3-oeHbFPUL.js +0 -514
  105. package/dist/client/lerc-DzVumYtB-P-KXC0TO.js +0 -1027
  106. package/dist/client/lzw-LAGDNbSC-DkP96qO9.js +0 -84
  107. package/dist/client/packbits-BlDR4Kj5-C66n1-zr.js +0 -24
  108. package/dist/client/pako.esm-CB1uQYY0-DB0PYm1P.js +0 -1081
  109. package/dist/client/raw-CMGvRjfu-BRi6E4i1.js +0 -9
  110. package/dist/client/ssrBoot-yo11mybw.js +0 -17
  111. package/dist/client/transition-CSJhuYGK.js +0 -34
  112. package/dist/client/webfontloader-qotgY98I.js +0 -435
  113. package/dist/client/webimage-BM_pbLN3-L2cGWK5l.js +0 -19
@@ -0,0 +1,360 @@
1
+ import { EodashCollection } from "@/eodashSTAC/EodashCollection";
2
+ import { setMapProjFromCol } from "@/eodashSTAC/triggers";
3
+ import { nextTick, onMounted, onUnmounted, watch } from "vue";
4
+ import log from "loglevel";
5
+ import { useSTAcStore } from "@/store/stac";
6
+ import { storeToRefs } from "pinia";
7
+ import { useEventBus } from "@vueuse/core";
8
+ import { eoxLayersKey } from "@/utils/keys";
9
+ import { posIsSetFromUrl } from "@/utils/states";
10
+ /**
11
+ * Holder for previous compare map view as it is overwritten by sync
12
+ * @type { {map:import("ol").View } | null} mapElement
13
+ */
14
+ let viewHolder = null;
15
+
16
+ /**
17
+ * Handles updating {@link mapPosition} on movement on the map
18
+ *
19
+ * @param {import("vue").Ref<HTMLElement & Record<string,any> & {map:import("ol").Map } | null>} mapElement
20
+ * @param {import("vue").Ref<(number | undefined)[]>} mapPosition
21
+ */
22
+ export const useHandleMapMoveEnd = (mapElement, mapPosition) => {
23
+ /** @type {import("openlayers").EventsListenerFunctionType} */
24
+ const handleMoveEnd = (evt) => {
25
+ const map = /** @type {import("openlayers").Map | undefined} */ (
26
+ /** @type {any} */ (evt).map
27
+ );
28
+ const lonlat = mapElement.value?.lonLatCenter;
29
+ const z = map?.getView().getZoom();
30
+ if (
31
+ lonlat &&
32
+ !Number.isNaN(lonlat[0]) &&
33
+ !Number.isNaN(lonlat[1]) &&
34
+ !Number.isNaN(z)
35
+ ) {
36
+ mapPosition.value = [lonlat[0], lonlat[1], z];
37
+ if (posIsSetFromUrl.value) {
38
+ posIsSetFromUrl.value = false;
39
+ }
40
+ }
41
+ };
42
+
43
+ onMounted(() => {
44
+ /** @type {import('ol/Map').default} */
45
+ (mapElement.value?.map)?.on("moveend", handleMoveEnd);
46
+ });
47
+
48
+ onUnmounted(() => {
49
+ /** @type {import('ol/Map').default} */
50
+ (mapElement.value?.map)?.un("moveend", handleMoveEnd);
51
+ });
52
+ };
53
+
54
+ /**
55
+ * Creates full layer configuration from indicator and time information
56
+ * @param {import("stac-ts").StacCatalog
57
+ * | import("stac-ts").StacCollection
58
+ * | import("stac-ts").StacItem
59
+ * | null
60
+ * } selectedIndicator
61
+ * @param {EodashCollection[]} eodashCols
62
+ * @param {string} [updatedTime]
63
+ */
64
+
65
+ const createLayersConfig = async (
66
+ selectedIndicator,
67
+ eodashCols,
68
+ updatedTime,
69
+ ) => {
70
+ log.debug(
71
+ "Creating layers config",
72
+ selectedIndicator,
73
+ eodashCols,
74
+ updatedTime,
75
+ );
76
+ const layersCollection = [];
77
+ const dataLayers = {
78
+ type: "Group",
79
+ properties: {
80
+ id: "AnalysisGroup",
81
+ title: "Data Layers",
82
+ layerControlExpand: true,
83
+ },
84
+ layers: /** @type {Record<string,any>[]}*/ ([]),
85
+ };
86
+
87
+ for (const ec of eodashCols) {
88
+ let layers;
89
+ if (updatedTime) {
90
+ layers = await ec.createLayersJson(new Date(updatedTime));
91
+ } else {
92
+ layers = await ec.createLayersJson();
93
+ }
94
+ // Add expand to all analysis layers
95
+ layers.forEach((dl) => {
96
+ dl.properties.layerControlExpand = true;
97
+ dl.properties.layerControlToolsExpand = true;
98
+ });
99
+ dataLayers.layers.push(...layers);
100
+ }
101
+
102
+ layersCollection.push(dataLayers);
103
+ const indicatorLayers =
104
+ //@ts-expect-error indicator is collection
105
+ await EodashCollection.getIndicatorLayers(selectedIndicator);
106
+ const geodbLayer = EodashCollection.getGeoDBLayer(eodashCols);
107
+ if (geodbLayer) {
108
+ dataLayers.layers.push(geodbLayer);
109
+ }
110
+ const baseLayers = {
111
+ type: "Group",
112
+ properties: {
113
+ id: "BaseLayersGroup",
114
+ title: "Base Layers",
115
+ },
116
+ layers: /** @type {Record<string,any>[]}*/ ([]),
117
+ };
118
+
119
+ const indicatorBaseLayers = indicatorLayers.filter(
120
+ (l) => l.properties.group === "baselayer",
121
+ );
122
+
123
+ if (indicatorBaseLayers.length) {
124
+ // Only one baselayer can be set to visible, let's first set all to
125
+ // false that have not a dedicated property visible, then check
126
+ // if there are more then one visible and only allow one
127
+ let counter = 0;
128
+ let lastPos = 0;
129
+ for (let indx = 0; indx < indicatorBaseLayers.length; indx++) {
130
+ const bl = indicatorBaseLayers[indx];
131
+ if (!("visible" in bl.properties)) {
132
+ bl.properties.visible = false;
133
+ }
134
+
135
+ if (bl.properties.visible) {
136
+ counter++;
137
+ lastPos = indx;
138
+ }
139
+ }
140
+
141
+ // if none visible set the last one as visible
142
+ if (counter === 0) {
143
+ indicatorBaseLayers[0].properties.visible = true;
144
+ }
145
+
146
+ // disable all apart from last
147
+ if (counter > 0) {
148
+ indicatorBaseLayers.forEach((bl, indx) => {
149
+ if (indx !== lastPos) {
150
+ bl.properties.visible = false;
151
+ } else {
152
+ bl.properties.visible = true;
153
+ }
154
+ });
155
+ }
156
+
157
+ baseLayers.layers.push(...indicatorBaseLayers);
158
+
159
+ // Add exclusive to baselayers and make sure only one is selected
160
+ baseLayers.layers.forEach((bl) => {
161
+ bl.properties.layerControlExclusive = true;
162
+ });
163
+ } else {
164
+ // Default to some baselayer
165
+ baseLayers.layers.push({
166
+ type: "Tile",
167
+ properties: {
168
+ id: "osm",
169
+ title: "Background",
170
+ layerControlExclusive: true,
171
+ },
172
+ source: {
173
+ type: "OSM",
174
+ },
175
+ });
176
+ }
177
+
178
+ if (baseLayers.layers.length) {
179
+ layersCollection.push(baseLayers);
180
+ }
181
+
182
+ const overlayLayers = {
183
+ type: "Group",
184
+ properties: {
185
+ id: "OverlayGroup",
186
+ title: "Overlay Layers",
187
+ },
188
+ layers: /** @type {Record<string,any>[]}*/ ([]),
189
+ };
190
+
191
+ const indicatorOverlays = indicatorLayers.filter(
192
+ (l) => l.properties.group === "overlay",
193
+ );
194
+
195
+ if (indicatorOverlays.length) {
196
+ overlayLayers.layers.push(...indicatorOverlays);
197
+ layersCollection.unshift(overlayLayers);
198
+ }
199
+
200
+ return layersCollection;
201
+ };
202
+
203
+ /**
204
+ * Initializes the map and updates it based on changes in the selected indicator and datetime,
205
+ *
206
+ * @param {import("vue").Ref<HTMLElement & Record<string,any> | null>} mapElement
207
+ * @param {import("vue").Ref<import("stac-ts").StacCollection | null>} selectedIndicator
208
+ * @param {EodashCollection[]} eodashCols
209
+ * @param {import("vue").Ref<string>} datetime
210
+ * @param {import("vue").Ref<Record<string,any>[]>} mapLayers
211
+ * @param {import("vue").Ref<HTMLElement & Record<string,any> | null>} partnerMap
212
+ */
213
+ export const useInitMap = (
214
+ mapElement,
215
+ selectedIndicator,
216
+ eodashCols,
217
+ datetime,
218
+ mapLayers,
219
+ partnerMap,
220
+ ) => {
221
+ log.debug(
222
+ "InitMap",
223
+ mapElement.value,
224
+ selectedIndicator.value,
225
+ eodashCols.values,
226
+ datetime.value,
227
+ );
228
+ const layersEvent = useEventBus(eoxLayersKey);
229
+
230
+ const stopIndicatorWatcher = watch(
231
+ [selectedIndicator, datetime],
232
+ async ([updatedStac, updatedTime], [previousStac, previousTime]) => {
233
+ if (updatedStac) {
234
+ log.debug(
235
+ "Selected Indicator watch triggered",
236
+ updatedStac,
237
+ updatedTime,
238
+ );
239
+
240
+ if (mapElement?.value?.id === "main") {
241
+ // Making sure main map gets the viewer that seems to be
242
+ // removed when the second map is no longer rendered
243
+ if (viewHolder !== null) {
244
+ // Set view to previous compare view
245
+ mapElement?.value?.map.setView(viewHolder);
246
+ viewHolder = null;
247
+ }
248
+ }
249
+ let layersCollection = [];
250
+
251
+ const onlyTimeChanged =
252
+ updatedStac?.id === previousStac?.id && updatedTime !== previousTime;
253
+
254
+ const { selectedCompareStac } = storeToRefs(useSTAcStore());
255
+ if (mapElement?.value?.id === "main") {
256
+ // Main map being initialized
257
+ // Set projection based on indicator level information for both maps
258
+ await setMapProjFromCol(updatedStac);
259
+ } else {
260
+ // Compare map being initialized
261
+ if (selectedCompareStac.value !== null) {
262
+ // save view of compare map
263
+ viewHolder = mapElement?.value?.map.getView();
264
+ /** @type {any} */
265
+ (mapElement.value).sync = partnerMap.value;
266
+ }
267
+ }
268
+
269
+ // We re-crate the configuration if time changed
270
+ if (onlyTimeChanged) {
271
+ layersCollection = await createLayersConfig(
272
+ updatedStac,
273
+ eodashCols,
274
+ updatedTime,
275
+ );
276
+ log.debug(
277
+ "Assigned layers after changing time only",
278
+ JSON.parse(JSON.stringify(layersCollection)),
279
+ );
280
+ mapLayers.value = layersCollection;
281
+ await nextTick(() => {
282
+ layersEvent.emit("time:updated", mapLayers.value);
283
+ });
284
+ return;
285
+ }
286
+
287
+ /** @type {Record<string,any>[]} */
288
+ layersCollection = await createLayersConfig(
289
+ updatedStac,
290
+ eodashCols,
291
+ datetime.value,
292
+ );
293
+
294
+ // We try to set the current time selection to latest extent date
295
+ let endInterval = null;
296
+ const interval = updatedStac?.extent?.temporal?.interval;
297
+ if (interval && interval.length > 0 && interval[0].length > 1) {
298
+ // @ts-expect-error this is the defined STAC structure
299
+ endInterval = new Date(interval[0][1]);
300
+ log.debug(
301
+ "Indicator load: found stac extent, setting time to latest value",
302
+ endInterval,
303
+ );
304
+ }
305
+ if (
306
+ endInterval !== null &&
307
+ endInterval.toISOString() !== datetime.value
308
+ ) {
309
+ datetime.value = endInterval.toISOString();
310
+ }
311
+
312
+ // Try to move map view to extent only when main
313
+ // indicator and map changes
314
+ if (
315
+ mapElement?.value?.id === "main" &&
316
+ updatedStac.extent?.spatial.bbox &&
317
+ !posIsSetFromUrl.value
318
+ ) {
319
+ // Sanitize extent,
320
+ const b = updatedStac.extent?.spatial.bbox[0];
321
+ const sanitizedExtent = [
322
+ b?.[0] > -180 ? b?.[0] : -180,
323
+ b?.[1] > -90 ? b?.[1] : -90,
324
+ b?.[2] < 180 ? b?.[2] : 180,
325
+ b?.[3] < 90 ? b?.[3] : 90,
326
+ ];
327
+
328
+ const reprojExtent = mapElement.value?.transformExtent(
329
+ sanitizedExtent,
330
+ "EPSG:4326",
331
+ mapElement.value?.map?.getView().getProjection(),
332
+ );
333
+ /** @type {import("@eox/map").EOxMap} */
334
+ (mapElement.value).zoomExtent = reprojExtent;
335
+ }
336
+ if (posIsSetFromUrl.value) {
337
+ posIsSetFromUrl.value = false;
338
+ }
339
+
340
+ log.debug(
341
+ "Assigned layers",
342
+ JSON.parse(JSON.stringify(layersCollection)),
343
+ );
344
+
345
+ mapLayers.value = layersCollection;
346
+ // Emit event to update layers
347
+ await nextTick(() => {
348
+ mapElement.value?.updateComplete.then(() => {
349
+ layersEvent.emit("layers:updated", mapLayers.value);
350
+ });
351
+ });
352
+ }
353
+ },
354
+ { immediate: true },
355
+ );
356
+
357
+ onUnmounted(() => {
358
+ stopIndicatorWatcher();
359
+ });
360
+ };