@eodash/eodash 5.0.0-alpha.2.16 → 5.0.0-alpha.2.17

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 (45) hide show
  1. package/core/client/composables/EodashMap.js +158 -107
  2. package/core/client/composables/index.js +13 -2
  3. package/core/client/eodash.js +6 -0
  4. package/core/client/plugins/axios.js +8 -0
  5. package/core/client/store/Actions.js +2 -1
  6. package/core/client/store/States.js +4 -0
  7. package/core/client/store/stac.js +11 -8
  8. package/core/client/utils/createLayers.js +77 -46
  9. package/core/client/utils/eodashSTAC.js +60 -19
  10. package/core/client/utils/helpers.js +94 -26
  11. package/dist/client/{DashboardLayout-CCtyOil0.js → DashboardLayout-BR1lU9ER.js} +2 -2
  12. package/dist/client/{DynamicWebComponent-But2r1Sj.js → DynamicWebComponent-7z8VFsrZ.js} +2 -2
  13. package/dist/client/EodashDatePicker-o7ZOYIHL.js +259 -0
  14. package/dist/client/EodashItemFilter-lNjVkidr.js +7651 -0
  15. package/dist/client/{EodashLayerControl-BhZL4pYM.js → EodashLayerControl-B0N8_XmX.js} +5162 -5035
  16. package/dist/client/{EodashMap-C5tOgVOv.js → EodashMap-DFT2R2Rk.js} +3575 -3545
  17. package/dist/client/{EodashMapBtns-CdDfVQj0.js → EodashMapBtns-CoGjVl8Y.js} +2 -2
  18. package/dist/client/{ExportState-CKCCN_VI.js → ExportState-Dwv37MRw.js} +133 -126
  19. package/dist/client/{Footer-B9yVgyzx.js → Footer-DuScuHSx.js} +63 -63
  20. package/dist/client/{Header-CPIlUEOq.js → Header-C4Y0u0E5.js} +70 -70
  21. package/dist/client/{IframeWrapper-DRw1kHJm.js → IframeWrapper-D1TfK4xH.js} +1 -1
  22. package/dist/client/{MobileLayout-CPxVee5U.js → MobileLayout-C-b8DIFO.js} +43 -41
  23. package/dist/client/{PopUp-Dca-gx9a.js → PopUp-DBMZX3l3.js} +3 -3
  24. package/dist/client/{VImg-PHLA1nP1.js → VImg-bAMQHnMM.js} +33 -31
  25. package/dist/client/VMain-Df5VMG9r.js +38 -0
  26. package/dist/client/VOverlay-D5GzAYRY.js +973 -0
  27. package/dist/client/{WidgetsContainer-jxk3kw-d.js → WidgetsContainer-yZDmY6_u.js} +1 -1
  28. package/dist/client/{asWebComponent-3OsFQJVx.js → asWebComponent-DhR2_xlP.js} +9844 -8985
  29. package/dist/client/eo-dash.js +1 -1
  30. package/dist/client/{forwardRefs-BxZaq9ml.js → forwardRefs-C0MQxvur.js} +1 -1
  31. package/dist/client/{index-Vul961Xy.js → index-qNWeBhRh.js} +1 -1
  32. package/dist/client/{lerc-B4lXefGh-BESXOHWk.js → lerc-B4lXefGh-CsL-d8wY.js} +1 -1
  33. package/dist/client/{ssrBoot-BFMBrCqY.js → ssrBoot-Xmkz8T49.js} +1 -1
  34. package/dist/client/style.css +2 -2
  35. package/dist/client/{transition-U5aFjJtV.js → transition-DRzZPWIN.js} +1 -1
  36. package/dist/client/{webfontloader-D_JbBwHu.js → webfontloader-CqD-lAx-.js} +1 -1
  37. package/dist/node/cli.js +1 -1
  38. package/package.json +26 -23
  39. package/widgets/EodashDatePicker.vue +100 -88
  40. package/widgets/EodashMap.vue +20 -30
  41. package/widgets/ExportState.vue +4 -2
  42. package/dist/client/EodashDatePicker-jeYiWflv.js +0 -247
  43. package/dist/client/EodashItemFilter-BFlfWeE_.js +0 -10125
  44. package/dist/client/VMain-Ck81LJfb.js +0 -39
  45. package/dist/client/VOverlay-CL4hiJB8.js +0 -972
@@ -1,7 +1,7 @@
1
1
  import { EodashCollection } from "@/utils/eodashSTAC";
2
2
  import { setMapProjFromCol } from "@/utils/helpers";
3
3
  import { onMounted, onUnmounted, watch } from "vue";
4
-
4
+ import log from "loglevel";
5
5
  /**
6
6
  * Description placeholder
7
7
  *
@@ -38,32 +38,25 @@ export const useHandleMapMoveEnd = (mapElement, mapPosition) => {
38
38
  };
39
39
 
40
40
  /**
41
+ * Adds data layers extracted from eodash collections to Analysis Group
41
42
  *
42
- * @param {string} indicatorUrl
43
- * @param {import("@/utils/eodashSTAC").EodashCollection[]} eodashCols
44
- * @param {string} updatedTime
45
- * @param {import("stac-ts").StacCatalog
46
- * | import("stac-ts").StacCollection
47
- * | import("stac-ts").StacItem
48
- * | null
49
- * } selectedIndicator
43
+ * @param { Record<string,any>[] | undefined} layersCollection
44
+ * @param {EodashCollection[]} eodashCols
45
+ * @param {string} [updatedTime]
50
46
  */
51
- const createLayersConfig = async (
52
- indicatorUrl,
47
+ const updateLayersConfig = async (
48
+ layersCollection,
53
49
  eodashCols,
54
50
  updatedTime,
55
- selectedIndicator,
56
51
  ) => {
57
- const layersCollection = [];
58
- const dataLayers = {
59
- type: "Group",
60
- properties: {
61
- id: "AnalysisGroup",
62
- title: "Analysis Layers",
63
- layerControlExpand: true,
64
- },
65
- layers: /** @type {Record<string,any>[]}*/ ([]),
66
- };
52
+ log.debug(
53
+ "Updating layer configuration",
54
+ layersCollection,
55
+ eodashCols,
56
+ updatedTime,
57
+ );
58
+ /** @type {Record<string,any>[]} */
59
+ const analysisLayers = [];
67
60
 
68
61
  for (const ec of eodashCols) {
69
62
  let layers;
@@ -72,26 +65,52 @@ const createLayersConfig = async (
72
65
  } else {
73
66
  layers = await ec.createLayersJson();
74
67
  }
68
+
75
69
  if (layers) {
76
- dataLayers.layers.push(...layers);
70
+ analysisLayers.push(...layers);
77
71
  }
78
72
  }
79
73
  // Add expand to all analysis layers
80
- dataLayers.layers.forEach((dl) => {
74
+ analysisLayers.forEach((dl) => {
81
75
  dl.properties.layerControlExpand = true;
82
76
  dl.properties.layerControlToolsExpand = true;
83
77
  });
84
78
 
85
- layersCollection.push(dataLayers);
86
-
87
- const indicator = new EodashCollection(indicatorUrl);
88
- const indicatorLayers = await indicator.buildJsonArray(
89
- //@ts-expect-error we use this function to generate collection level visualization
90
- selectedIndicator,
91
- indicatorUrl,
92
- selectedIndicator?.title ?? "",
93
- selectedIndicator?.endpointtype === "GeoDB",
79
+ const dataLayersGroup = layersCollection?.find(
80
+ (lyr) => lyr?.properties.id === "AnalysisGroup",
94
81
  );
82
+ if (dataLayersGroup) {
83
+ dataLayersGroup.layers = analysisLayers;
84
+ }
85
+
86
+ return layersCollection;
87
+ };
88
+
89
+ /**
90
+ * @param {import("stac-ts").StacCatalog
91
+ * | import("stac-ts").StacCollection
92
+ * | import("stac-ts").StacItem
93
+ * | null
94
+ * } selectedIndicator
95
+ */
96
+
97
+ const createLayersConfig = async (selectedIndicator) => {
98
+ log.debug("Creating layers config", selectedIndicator);
99
+ const layersCollection = [];
100
+ const dataLayers = {
101
+ type: "Group",
102
+ properties: {
103
+ id: "AnalysisGroup",
104
+ title: "Analysis Layers",
105
+ layerControlExpand: true,
106
+ },
107
+ layers: /** @type {Record<string,any>[]}*/ ([]),
108
+ };
109
+
110
+ layersCollection.push(dataLayers);
111
+ const indicatorLayers =
112
+ //@ts-expect-error indicator is collection
113
+ await EodashCollection.getIndicatorLayers(selectedIndicator);
95
114
 
96
115
  const baseLayers = {
97
116
  type: "Group",
@@ -105,34 +124,41 @@ const createLayersConfig = async (
105
124
  const indicatorBaseLayers = indicatorLayers.filter(
106
125
  (l) => l.properties.group === "baselayer",
107
126
  );
108
- // Only one baselayer can be set to visible, let's first set all to
109
- // false that have not a dedicated property visible, then check
110
- // if there are more then one visible and only allow one
111
- let counter = 0;
112
- let lastPos = 0;
113
- indicatorBaseLayers.forEach((bl, indx) => {
114
- if (!("visible" in bl.properties)) {
115
- bl.properties.visible = false;
116
- }
117
- if (bl.properties.visible) {
118
- counter++;
119
- lastPos = indx;
120
- }
121
- });
122
- // if none visible set the last one as visible
123
- if (counter == 0 && indicatorBaseLayers.length > 0) {
124
- indicatorBaseLayers[0].properties.visible = true;
125
- }
126
- // disable all apart from last
127
- if (counter > 1) {
128
- indicatorBaseLayers.forEach((bl, indx) => {
129
- if (indx !== lastPos) {
127
+
128
+ if (indicatorBaseLayers.length) {
129
+ // Only one baselayer can be set to visible, let's first set all to
130
+ // false that have not a dedicated property visible, then check
131
+ // if there are more then one visible and only allow one
132
+ let counter = 0;
133
+ let lastPos = 0;
134
+ for (let indx = 0; indx < indicatorBaseLayers.length; indx++) {
135
+ const bl = indicatorBaseLayers[indx];
136
+ if (!("visible" in bl.properties)) {
130
137
  bl.properties.visible = false;
131
138
  }
132
- });
133
- }
134
139
 
135
- if (indicatorBaseLayers.length) {
140
+ if (bl.properties.visible) {
141
+ counter++;
142
+ lastPos = indx;
143
+ }
144
+ }
145
+
146
+ // if none visible set the last one as visible
147
+ if (counter === 0) {
148
+ indicatorBaseLayers[0].properties.visible = true;
149
+ }
150
+
151
+ // disable all apart from last
152
+ if (counter > 0) {
153
+ indicatorBaseLayers.forEach((bl, indx) => {
154
+ if (indx !== lastPos) {
155
+ bl.properties.visible = false;
156
+ } else {
157
+ bl.properties.visible = true;
158
+ }
159
+ });
160
+ }
161
+
136
162
  baseLayers.layers.push(...indicatorBaseLayers);
137
163
 
138
164
  // Add exclusive to baselayers and make sure only one is selected
@@ -170,6 +196,7 @@ const createLayersConfig = async (
170
196
  const indicatorOverlays = indicatorLayers.filter(
171
197
  (l) => l.properties.group === "overlay",
172
198
  );
199
+
173
200
  if (indicatorOverlays.length) {
174
201
  overlayLayers.layers.push(...indicatorOverlays);
175
202
  layersCollection.unshift(overlayLayers);
@@ -184,62 +211,86 @@ const createLayersConfig = async (
184
211
  * @param {import("vue").Ref<HTMLElement & Record<string,any> | null>} mapElement
185
212
  * @param {import("vue").Ref<import("stac-ts").StacCollection | null>} selectedIndicator
186
213
  * @param {EodashCollection[]} eodashCols
187
- * @param {import("vue").Ref<string>} indicatorUrl
188
214
  * @param {import("vue").Ref<string>} datetime
189
215
  */
190
216
  export const useInitMap = (
191
217
  mapElement,
192
218
  selectedIndicator,
193
219
  eodashCols,
194
- indicatorUrl,
195
220
  datetime,
196
221
  ) => {
197
- onMounted(() => {
198
- watch(
199
- [selectedIndicator, datetime],
200
- async ([updatedStac, updatedTime], [previousSTAC, _previousTime]) => {
201
- if (updatedStac) {
202
- const layersCollection = await createLayersConfig(
203
- indicatorUrl.value,
204
- eodashCols,
205
- updatedTime,
206
- updatedStac,
207
- );
208
- /** @type {any} */
209
- (mapElement.value).layers = layersCollection;
210
-
211
- // only on different indicator selection and not on time change
212
- if (previousSTAC?.id !== updatedStac.id) {
213
- // Set projection based on indicator level information
214
- setMapProjFromCol(
215
- /** @type {import('stac-ts').StacCollection} */
216
- (updatedStac),
217
- );
218
- // Try to move map view to extent
219
- // Make sure for now we are always converting from 4326
220
- // of stac items into current map projection
221
- // TODO: This might change if we decide to use 4326 as default for zoom and extent
222
- // Sanitize extent
223
- // // @ts-expect-error we will need to change the approach to use
224
- // // native eox-map transformation once included
225
- const b = updatedStac.extent?.spatial.bbox[0];
226
- const sanitizedExtent = [
227
- b[0] > -180 ? b[0] : -180,
228
- b[1] > -90 ? b[1] : -90,
229
- b[2] < 180 ? b[2] : 180,
230
- b[3] < 90 ? b[3] : 90,
231
- ];
232
- const reprojExtent = mapElement.value?.transformExtent(
233
- sanitizedExtent,
234
- "EPSG:4326",
235
- mapElement.value?.map?.getView().getProjection(),
236
- );
237
- /** @type {any} */
238
- (mapElement.value).zoomExtent = reprojExtent;
239
- }
240
- }
241
- },
242
- { immediate: true },
243
- );
222
+ log.debug(
223
+ "InitMap",
224
+ mapElement.value,
225
+ selectedIndicator.value,
226
+ eodashCols.values,
227
+ datetime.value,
228
+ );
229
+
230
+ const stopIndicatorWatcher = watch(
231
+ selectedIndicator,
232
+ async (updatedStac) => {
233
+ log.debug(
234
+ "SelectedIndicator watch triggered",
235
+ selectedIndicator,
236
+ updatedStac,
237
+ );
238
+ if (updatedStac) {
239
+ const layersCollection = await createLayersConfig(updatedStac);
240
+
241
+ // updates layersCollection in place
242
+ await updateLayersConfig(layersCollection, eodashCols, datetime.value);
243
+
244
+ // Set projection based on indicator level information
245
+ setMapProjFromCol(updatedStac);
246
+
247
+ // Try to move map view to extent
248
+ // Sanitize extent,
249
+ const b = updatedStac.extent?.spatial.bbox[0];
250
+ const sanitizedExtent = [
251
+ b[0] > -180 ? b[0] : -180,
252
+ b[1] > -90 ? b[1] : -90,
253
+ b[2] < 180 ? b[2] : 180,
254
+ b[3] < 90 ? b[3] : 90,
255
+ ];
256
+ const reprojExtent = mapElement.value?.transformExtent(
257
+ sanitizedExtent,
258
+ "EPSG:4326",
259
+ mapElement.value?.map?.getView().getProjection(),
260
+ );
261
+ /** @type {any} */
262
+ (mapElement.value).zoomExtent = reprojExtent;
263
+
264
+ // TODO: resetting layers to empty array first because smart layer update has issues
265
+ log.debug(
266
+ "WARN: Map configuration being completely, should be changed once smart update of config is reworked",
267
+ );
268
+ /** @type {any} */
269
+ (mapElement.value).layers = [];
270
+ /** @type {any} */
271
+ (mapElement.value).layers = layersCollection;
272
+ }
273
+ },
274
+ { immediate: true },
275
+ );
276
+
277
+ const stopDatetimeWatcher = watch(
278
+ datetime,
279
+ async (updatedTime, previousTime) => {
280
+ if (updatedTime && updatedTime !== previousTime) {
281
+ const layersCollection = await updateLayersConfig(
282
+ [...(mapElement.value?.layers ?? [])],
283
+ eodashCols,
284
+ updatedTime,
285
+ );
286
+ /** @type {any} */
287
+ (mapElement.value).layers = layersCollection?.reverse();
288
+ }
289
+ },
290
+ );
291
+
292
+ onUnmounted(() => {
293
+ stopIndicatorWatcher();
294
+ stopDatetimeWatcher();
244
295
  });
245
296
  };
@@ -12,6 +12,7 @@ import eodash from "@/eodash";
12
12
  import { useTheme } from "vuetify/lib/framework.mjs";
13
13
  import { onMounted, watch } from "vue";
14
14
  import { useSTAcStore } from "@/store/stac";
15
+ import log from "loglevel";
15
16
 
16
17
  /**
17
18
  * Creates an absolute URL from a relative link and assignes it to `currentUrl`
@@ -102,12 +103,12 @@ export const useUpdateTheme = (themeName, themeDefinition = {}) => {
102
103
  };
103
104
 
104
105
  /** Composable that syncs store and URLSearchParameters */
105
-
106
106
  export const useURLSearchParametersSync = () => {
107
107
  onMounted(async () => {
108
108
  // Analyze currently set url params when first loaded and set them in the store
109
109
  if (window.location.search) {
110
110
  const searchParams = new URLSearchParams(window.location.search);
111
+
111
112
  /** @type {number | undefined} */
112
113
  let x,
113
114
  /** @type {number | undefined} */
@@ -117,35 +118,45 @@ export const useURLSearchParametersSync = () => {
117
118
  for (const [key, value] of searchParams) {
118
119
  switch (key) {
119
120
  case "indicator": {
121
+ log.debug("Found indicator key in url");
120
122
  const { loadSelectedSTAC, stac } = useSTAcStore();
121
123
  const match = stac?.find((link) => link.id == value);
122
124
  if (match) {
125
+ log.debug("Found match, loading stac item", match);
123
126
  await loadSelectedSTAC(match.href);
124
127
  }
125
128
  break;
126
129
  }
130
+
127
131
  case "x":
128
132
  x = Number(value);
129
133
  break;
134
+
130
135
  case "y":
131
136
  y = Number(value);
132
137
  break;
138
+
133
139
  case "z":
134
140
  z = Number(value);
135
141
  break;
142
+
136
143
  case "datetime":
137
144
  try {
138
- datetime.value = new Date(value).toISOString();
145
+ const datetimeiso = new Date(value).toISOString();
146
+ log.debug("Valid datetime found", datetimeiso);
147
+ datetime.value = datetimeiso;
139
148
  } catch {
140
149
  datetime.value = new Date().toISOString();
141
150
  }
142
151
  break;
152
+
143
153
  default:
144
154
  break;
145
155
  }
146
156
  }
147
157
 
148
158
  if (x && y && z) {
159
+ log.debug("Coordinates found, applying map poisition", x, y, z);
149
160
  mapPosition.value = [x, y, z];
150
161
  }
151
162
  }
@@ -1,5 +1,9 @@
1
1
  import { reactive } from "vue";
2
2
  import { currentUrl } from "./store/States";
3
+ import log from "loglevel";
4
+
5
+ /* set log level */
6
+ log.setLevel("debug", true);
3
7
 
4
8
  /**
5
9
  * Reactive Edoash Instance Object. provided globally in the app, and used as an
@@ -10,6 +14,8 @@ import { currentUrl } from "./store/States";
10
14
  export const eodash = reactive({
11
15
  id: "demo",
12
16
  stacEndpoint: "https://gtif-cerulean.github.io/catalog/cerulean/catalog.json",
17
+ // stacEndpoint: "https://eodashcatalog.eox.at/test-style/trilateral/catalog.json",
18
+ //stacEndpoint: "https://eurodatacube.github.io/eodash-catalog/RACE/catalog.json",
13
19
  brand: {
14
20
  noLayout: true,
15
21
  name: "Demo",
@@ -0,0 +1,8 @@
1
+ import Axios from "axios";
2
+ import { setupCache } from "axios-cache-interceptor";
3
+
4
+ const instance = Axios.create();
5
+
6
+ export const axios = setupCache(instance, { cacheTakeover: false });
7
+
8
+ export default axios;
@@ -1,5 +1,6 @@
1
1
  import { mapEl, mapCompareEl, registeredProjections } from "@/store/States";
2
2
  import { getProjectionCode } from "@/utils/helpers";
3
+ import log from "loglevel";
3
4
 
4
5
  /**
5
6
  * Returns the current layers of {@link mapEl}
@@ -15,7 +16,7 @@ export const registerProjection = async (projection) => {
15
16
  if (!code || registeredProjections.includes(code)) {
16
17
  return;
17
18
  }
18
-
19
+ log.debug("Unregistered projection found, registering it", code);
19
20
  registeredProjections.push(code);
20
21
  if (typeof projection === "object") {
21
22
  // registering whole projection definition
@@ -1,3 +1,7 @@
1
+ /** setting default log level globally to warning */
2
+ import log from "loglevel";
3
+ log.setLevel(log.levels.WARN, true);
4
+
1
5
  import { ref } from "vue";
2
6
 
3
7
  /** Currently selected STAC endpoint */
@@ -1,12 +1,13 @@
1
1
  import { defineStore } from "pinia";
2
2
  import { inject, ref } from "vue";
3
- import axios from "axios";
3
+ import axios from "@/plugins/axios";
4
4
  import { useAbsoluteUrl, useCompareAbsoluteUrl } from "@/composables/index";
5
5
  import { eodashKey } from "@/utils/keys";
6
6
  import { indicator } from "@/store/States";
7
7
  import { extractCollectionUrls } from "@/utils/helpers";
8
8
  import { eodashCollections, eodashCompareCollections } from "@/utils/states";
9
9
  import { EodashCollection } from "@/utils/eodashSTAC";
10
+ import log from "loglevel";
10
11
 
11
12
  export const useSTAcStore = defineStore("stac", () => {
12
13
  /**
@@ -52,6 +53,7 @@ export const useSTAcStore = defineStore("stac", () => {
52
53
  * @see {@link stac}
53
54
  */
54
55
  async function loadSTAC(url = eodash.stacEndpoint) {
56
+ log.debug("Loading STAC endpoint", url);
55
57
  await axios
56
58
  .get(url)
57
59
  .then((resp) => {
@@ -63,6 +65,7 @@ export const useSTAcStore = defineStore("stac", () => {
63
65
  }
64
66
  return link;
65
67
  });
68
+ log.debug("Setting selected STAC", links);
66
69
  stac.value = links;
67
70
  })
68
71
  .catch((err) => {
@@ -98,13 +101,13 @@ export const useSTAcStore = defineStore("stac", () => {
98
101
  }),
99
102
  ).then((collections) => {
100
103
  // empty array from old collections
101
- eodashCollections.length = 0;
104
+ eodashCollections.splice(0, eodashCollections.length);
102
105
  // update eodashCollections
103
106
  eodashCollections.push(...collections);
104
- });
105
107
 
106
- selectedStac.value = resp.data;
107
- indicator.value = selectedStac.value?.id ?? "";
108
+ selectedStac.value = resp.data;
109
+ indicator.value = selectedStac.value?.id ?? "";
110
+ });
108
111
  })
109
112
  .catch((err) => {
110
113
  throw new Error("error loading the selected STAC", err);
@@ -139,12 +142,12 @@ export const useSTAcStore = defineStore("stac", () => {
139
142
  }),
140
143
  ).then((collections) => {
141
144
  // empty array from old collections
142
- eodashCompareCollections.length = 0;
145
+ eodashCompareCollections.splice(0, eodashCompareCollections.length);
143
146
  // update eodashCompareCollections
144
147
  eodashCompareCollections.push(...collections);
145
- });
146
148
 
147
- selectedCompareStac.value = resp.data;
149
+ selectedCompareStac.value = resp.data;
150
+ });
148
151
  })
149
152
  .catch((err) => {
150
153
  throw new Error("error loading the selected comparison STAC", err);