@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,25 +1,37 @@
1
1
  import { registerProjection } from "@/store/Actions";
2
- import { extractRoles, getProjectionCode } from "./helpers";
2
+ import {
3
+ extractRoles,
4
+ getProjectionCode,
5
+ createLayerID,
6
+ createAssetID,
7
+ } from "./helpers";
8
+ import log from "loglevel";
3
9
 
4
10
  /**
5
- * @param {string} id
11
+ * @param {string} collectionId
6
12
  * @param {string} title
7
13
  * @param {Record<string,import("stac-ts").StacAsset>} assets
14
+ * @param {import("stac-ts").StacItem } item
8
15
  * @param {import("ol/layer/WebGLTile").Style} [style]
9
16
  * @param {Record<string, unknown>} [layerConfig]
10
17
  * @param {Record<string, unknown>} [layerDatetime]
11
18
  **/
12
- export async function createLayersFromDataAssets(
13
- id,
19
+ export async function createLayersFromAssets(
20
+ collectionId,
14
21
  title,
15
22
  assets,
23
+ item,
16
24
  style,
17
25
  layerConfig,
18
26
  layerDatetime,
19
27
  ) {
28
+ log.debug("Creating layers from assets");
20
29
  let jsonArray = [];
21
30
  let geoTIFFSources = [];
22
- for (const ast in assets) {
31
+ /** @type {number|null} */
32
+ let geoTIFFIdx = null;
33
+
34
+ for (const [idx, ast] of Object.keys(assets).entries()) {
23
35
  // register projection if exists
24
36
  const assetProjection =
25
37
  /** @type {string | number | {name: string, def: string, extent?:number[]} | undefined} */ (
@@ -28,6 +40,8 @@ export async function createLayersFromDataAssets(
28
40
  await registerProjection(assetProjection);
29
41
 
30
42
  if (assets[ast]?.type === "application/geo+json") {
43
+ const assetId = createAssetID(collectionId, item.id, idx);
44
+ log.debug("Creating Vector layer from GeoJSON", assetId);
31
45
  const layer = {
32
46
  type: "Vector",
33
47
  source: {
@@ -36,7 +50,7 @@ export async function createLayersFromDataAssets(
36
50
  format: "GeoJSON",
37
51
  },
38
52
  properties: {
39
- id,
53
+ id: assetId,
40
54
  title,
41
55
  layerDatetime,
42
56
  ...(layerConfig && {
@@ -48,19 +62,19 @@ export async function createLayersFromDataAssets(
48
62
  },
49
63
  ...(!style?.variables && { style }),
50
64
  };
51
- extractRoles(
52
- layer.properties,
53
- assets[ast]?.roles ?? [],
54
- /** @type {string} */ (assets[ast].id || assets[ast].title || ""),
55
- );
65
+ extractRoles(layer.properties, assets[ast]);
56
66
  jsonArray.push(layer);
57
67
  } else if (assets[ast]?.type === "image/tiff") {
68
+ geoTIFFIdx = idx;
58
69
  geoTIFFSources.push({ url: assets[ast].href });
59
70
  }
60
71
  }
61
72
 
62
- if (geoTIFFSources.length) {
63
- jsonArray.push({
73
+ if (geoTIFFSources.length && typeof geoTIFFIdx === "number") {
74
+ const geotiffSourceID = collectionId + ";:;GeoTIFF";
75
+ log.debug("Creating Vector layer from GeoJSON", geotiffSourceID);
76
+ log.debug("Configured Sources", geoTIFFSources);
77
+ const layer = {
64
78
  type: "WebGLTile",
65
79
  source: {
66
80
  type: "GeoTIFF",
@@ -68,25 +82,32 @@ export async function createLayersFromDataAssets(
68
82
  sources: geoTIFFSources,
69
83
  },
70
84
  properties: {
71
- id,
85
+ id: createAssetID(collectionId, item.id, geoTIFFIdx),
72
86
  title,
73
87
  layerConfig,
74
88
  layerDatetime,
75
89
  },
76
90
  style,
77
- });
91
+ };
92
+ jsonArray.push(layer);
78
93
  }
79
94
 
80
95
  return jsonArray;
81
96
  }
82
97
 
83
98
  /**
99
+ * @param {string} collectionId
84
100
  * @param {import('stac-ts').StacItem} item
85
- * @param {string} id
86
101
  * @param {string} title
87
102
  * @param {Record<string,any>} [layerDatetime]
88
103
  */
89
- export const createLayersFromLinks = async (id, title, item, layerDatetime) => {
104
+ export const createLayersFromLinks = async (
105
+ collectionId,
106
+ title,
107
+ item,
108
+ layerDatetime,
109
+ ) => {
110
+ log.debug("Creating layers from links");
90
111
  /** @type {Record<string,any>[]} */
91
112
  const jsonArray = [];
92
113
  const wmsArray = item.links.filter((l) => l.rel === "wms");
@@ -102,10 +123,17 @@ export const createLayersFromLinks = async (id, title, item, layerDatetime) => {
102
123
 
103
124
  await registerProjection(wmsLinkProjection);
104
125
  const projectionCode = getProjectionCode(wmsLinkProjection || "EPSG:4326");
126
+ const linkId = createLayerID(
127
+ collectionId,
128
+ item.id,
129
+ wmsLink,
130
+ projectionCode,
131
+ );
132
+ log.debug("WMS Layer added", linkId);
105
133
  let json = {
106
134
  type: "Tile",
107
135
  properties: {
108
- id,
136
+ id: linkId,
109
137
  title: wmsLink.title || title || item.id,
110
138
  layerDatetime,
111
139
  },
@@ -113,21 +141,16 @@ export const createLayersFromLinks = async (id, title, item, layerDatetime) => {
113
141
  type: "TileWMS",
114
142
  url: wmsLink.href,
115
143
  projection: projectionCode,
144
+ tileGrid: {
145
+ tileSize: [512, 512],
146
+ },
116
147
  params: {
117
148
  LAYERS: wmsLink["wms:layers"],
118
149
  TILED: true,
119
150
  },
120
151
  },
121
152
  };
122
-
123
- extractRoles(
124
- json.properties,
125
- /** @type {string[]} */ (wmsLink.roles),
126
- /** @type {string} */ (wmsLink.id) ||
127
- /** @type {string} */ (wmsLink.title) ||
128
- "",
129
- );
130
-
153
+ extractRoles(json.properties, wmsLink);
131
154
  if ("wms:dimensions" in wmsLink) {
132
155
  // Expand all dimensions into the params attribute
133
156
  Object.assign(json.source.params, wmsLink["wms:dimensions"]);
@@ -148,11 +171,21 @@ export const createLayersFromLinks = async (id, title, item, layerDatetime) => {
148
171
  // that needs to be removed once catalog and wmts creation from capabilities
149
172
  // combined with custom view projections is solved
150
173
  let json;
174
+ const linkId = createLayerID(
175
+ collectionId,
176
+ item.id,
177
+ wmtsLink,
178
+ projectionCode,
179
+ );
151
180
  if (wmtsLink.title === "wmts capabilities") {
181
+ log.debug(
182
+ "Warning: WMTS Layer from capabilities added, function needs to be updated",
183
+ linkId,
184
+ );
152
185
  json = {
153
186
  type: "Tile",
154
187
  properties: {
155
- id,
188
+ id: linkId,
156
189
  title: title || item.id,
157
190
  layerDatetime,
158
191
  },
@@ -172,10 +205,14 @@ export const createLayersFromLinks = async (id, title, item, layerDatetime) => {
172
205
  },
173
206
  };
174
207
  } else {
208
+ log.debug(
209
+ "Warning: WMTS Layer from capabilities added, function needs to be updated",
210
+ linkId,
211
+ );
175
212
  json = {
176
213
  type: "Tile",
177
214
  properties: {
178
- id,
215
+ id: linkId,
179
216
  title: wmtsLink.title || title || item.id,
180
217
  layerDatetime,
181
218
  },
@@ -187,21 +224,13 @@ export const createLayersFromLinks = async (id, title, item, layerDatetime) => {
187
224
  matrixSet: wmtsLink.matrixSet || "EPSG:3857",
188
225
  projection: projectionCode,
189
226
  tileGrid: {
190
- tileSize: [128, 128],
227
+ tileSize: [512, 512],
191
228
  },
192
229
  dimensions: wmtsLink["wmts:dimensions"],
193
230
  },
194
231
  };
195
232
  }
196
-
197
- extractRoles(
198
- json.properties,
199
- /** @type {string[]} */ (wmtsLink.roles),
200
- /** @type {string} */ (wmtsLink.id) ||
201
- /** @type {string} */ (wmtsLink.title) ||
202
- "",
203
- );
204
-
233
+ extractRoles(json.properties, wmtsLink);
205
234
  jsonArray.push(json);
206
235
  }
207
236
 
@@ -211,12 +240,18 @@ export const createLayersFromLinks = async (id, title, item, layerDatetime) => {
211
240
  (xyzLink?.["proj:epsg"] || xyzLink?.["eodash:proj4_def"]);
212
241
 
213
242
  await registerProjection(xyzLinkProjection);
214
-
215
243
  const projectionCode = getProjectionCode(xyzLinkProjection || "EPSG:3857");
244
+ const linkId = createLayerID(
245
+ collectionId,
246
+ item.id,
247
+ xyzLink,
248
+ projectionCode,
249
+ );
250
+ log.debug("XYZ Layer added", linkId);
216
251
  let json = {
217
252
  type: "Tile",
218
253
  properties: {
219
- id,
254
+ id: linkId,
220
255
  title: xyzLink.title || title || item.id,
221
256
  roles: xyzLink.roles,
222
257
  layerDatetime,
@@ -228,11 +263,7 @@ export const createLayersFromLinks = async (id, title, item, layerDatetime) => {
228
263
  },
229
264
  };
230
265
 
231
- extractRoles(
232
- json.properties,
233
- /** @type {string[]} */ (xyzLink.roles),
234
- /** @type {string} */ (xyzLink.id || xyzLink.title || ""),
235
- );
266
+ extractRoles(json.properties, xyzLink);
236
267
  jsonArray.push(json);
237
268
  }
238
269
  return jsonArray;
@@ -1,7 +1,6 @@
1
1
  import { Collection, Item } from "stac-js";
2
2
  import { toAbsolute } from "stac-js/src/http.js";
3
3
  import {
4
- createLayerID,
5
4
  extractLayerConfig,
6
5
  extractLayerDatetime,
7
6
  extractRoles,
@@ -11,11 +10,9 @@ import {
11
10
  replaceLayer,
12
11
  } from "./helpers";
13
12
  import { getLayers, registerProjection } from "@/store/Actions";
14
- import {
15
- createLayersFromDataAssets,
16
- createLayersFromLinks,
17
- } from "./createLayers";
18
- import axios from "axios";
13
+ import { createLayersFromAssets, createLayersFromLinks } from "./createLayers";
14
+ import axios from "@/plugins/axios";
15
+ import log from "loglevel";
19
16
 
20
17
  export class EodashCollection {
21
18
  #collectionUrl = "";
@@ -114,6 +111,14 @@ export class EodashCollection {
114
111
  * @returns {Promise<Record<string,any>[]>} arrays
115
112
  * */
116
113
  async buildJsonArray(item, itemUrl, title, isGeoDB, itemDatetime) {
114
+ log.debug(
115
+ "Building JSON array",
116
+ item,
117
+ itemUrl,
118
+ title,
119
+ isGeoDB,
120
+ itemDatetime,
121
+ );
117
122
  await this.fetchCollection();
118
123
  // registering top level indicator projection
119
124
  const indicatorProjection =
@@ -133,7 +138,7 @@ export class EodashCollection {
133
138
  {
134
139
  type: "Vector",
135
140
  properties: {
136
- id: createLayerID(this.#collectionStac?.id ?? "", item.id, false),
141
+ id: this.#collectionStac?.id ?? "",
137
142
  title: this.#collectionStac?.title || item.id,
138
143
  },
139
144
  source: {
@@ -179,17 +184,18 @@ export class EodashCollection {
179
184
 
180
185
  if (isSupported) {
181
186
  const links = await createLayersFromLinks(
182
- createLayerID(this.#collectionStac?.id ?? "", item.id, false),
187
+ this.#collectionStac?.id ?? "",
183
188
  title,
184
189
  item,
185
190
  layerDatetime,
186
191
  );
187
192
  jsonArray.push(
188
193
  ...links,
189
- ...(await createLayersFromDataAssets(
190
- createLayerID(this.#collectionStac?.id ?? "", item.id, true),
194
+ ...(await createLayersFromAssets(
195
+ this.#collectionStac?.id ?? "",
191
196
  title || this.#collectionStac?.title || item.id,
192
197
  dataAssets,
198
+ item,
193
199
  style,
194
200
  layerConfig,
195
201
  layerDatetime,
@@ -203,7 +209,7 @@ export class EodashCollection {
203
209
  displayFootprint: false,
204
210
  data: item,
205
211
  properties: {
206
- id: createLayerID(this.#collectionStac?.id ?? "", item.id, false),
212
+ id: this.#collectionStac?.id ?? "",
207
213
  title: title || item.id,
208
214
  layerConfig,
209
215
  },
@@ -211,8 +217,8 @@ export class EodashCollection {
211
217
  };
212
218
  extractRoles(
213
219
  json.properties,
214
- /** @type {string[]} */ (item?.roles),
215
- item.id || /** @type {string} */ (item.title) || "" + " STAC",
220
+ //@ts-expect-error using the item incase no self link is found
221
+ item.links.find((link) => link.rel === "self") ?? item,
216
222
  );
217
223
  jsonArray.push(json);
218
224
  }
@@ -222,6 +228,7 @@ export class EodashCollection {
222
228
 
223
229
  async fetchCollection() {
224
230
  if (!this.#collectionStac) {
231
+ log.debug("Fetching collection file", this.#collectionUrl);
225
232
  const col = await axios
226
233
  .get(this.#collectionUrl)
227
234
  .then((resp) => resp.data);
@@ -260,12 +267,7 @@ export class EodashCollection {
260
267
  }
261
268
 
262
269
  async getExtent() {
263
- if (!this.#collectionStac) {
264
- const stac = await axios
265
- .get(this.#collectionUrl)
266
- .then((resp) => resp.data);
267
- this.#collectionStac = new Collection(stac);
268
- }
270
+ await this.fetchCollection();
269
271
  return this.#collectionStac?.extent;
270
272
  }
271
273
 
@@ -329,4 +331,43 @@ export class EodashCollection {
329
331
 
330
332
  return updatedLayers;
331
333
  }
334
+
335
+ /**
336
+ * Returns base layers and overlay layers of a STAC Collection
337
+ *
338
+ * @param {import("stac-ts").StacCollection} indicator */
339
+ static async getIndicatorLayers(indicator) {
340
+ const indicatorAssets = Object.keys(indicator?.assets ?? {}).reduce(
341
+ (assets, ast) => {
342
+ if (
343
+ indicator.assets?.[ast].roles?.includes("baselayer") ||
344
+ indicator.assets?.[ast].roles?.includes("overlay")
345
+ ) {
346
+ assets[ast] = indicator.assets[ast];
347
+ }
348
+ return assets;
349
+ },
350
+ /** @type {Record<string,import('stac-ts').StacAsset>} */ ({}),
351
+ );
352
+
353
+ return [
354
+ ...(await createLayersFromLinks(
355
+ indicator?.id ?? "",
356
+ indicator?.title || indicator.id,
357
+ //@ts-expect-error indicator instead of item
358
+ indicator,
359
+ // layerDatetime,
360
+ )),
361
+ ...(await createLayersFromAssets(
362
+ indicator?.id ?? "",
363
+ indicator?.title || indicator.id,
364
+ indicatorAssets,
365
+ //@ts-expect-error indicator instead of item
366
+ indicator,
367
+ // style,
368
+ // layerConfig,
369
+ // layerDatetime,
370
+ )),
371
+ ];
372
+ }
332
373
  }
@@ -1,7 +1,8 @@
1
- import { changeMapProjection } from "@/store/Actions";
1
+ import { changeMapProjection, registerProjection } from "@/store/Actions";
2
2
  import { availableMapProjection } from "@/store/States";
3
3
  import { toAbsolute } from "stac-js/src/http.js";
4
- import axios from "axios";
4
+ import axios from "@/plugins/axios";
5
+ import log from "loglevel";
5
6
 
6
7
  /** @param {import("stac-ts").StacLink[]} [links] */
7
8
  export function generateFeatures(links) {
@@ -60,7 +61,7 @@ export function extractLayerConfig(style) {
60
61
  */
61
62
  export const setMapProjFromCol = (STAcCollection) => {
62
63
  // if a projection exists on the collection level
63
-
64
+ log.debug("Checking for available map projection in indicator");
64
65
  const projection =
65
66
  /** @type {number | string | {name: string, def: string} | undefined} */
66
67
  (
@@ -69,17 +70,25 @@ export const setMapProjFromCol = (STAcCollection) => {
69
70
  STAcCollection?.["eodash:proj4_def"]
70
71
  );
71
72
  if (projection) {
73
+ log.debug("Projection found", projection);
74
+ registerProjection(projection);
72
75
  const projectionCode = getProjectionCode(projection);
73
76
  if (
74
77
  availableMapProjection.value &&
75
78
  availableMapProjection.value !== projectionCode
76
79
  ) {
80
+ log.debug(
81
+ "Changing map projection",
82
+ availableMapProjection.value,
83
+ projectionCode,
84
+ );
77
85
  changeMapProjection(projection);
78
86
  }
79
87
  // set it for `EodashMapBtns`
80
88
  availableMapProjection.value = /** @type {string} */ (projectionCode);
81
89
  } else {
82
90
  // reset to default projection
91
+ log.debug("Resetting projection to default");
83
92
  changeMapProjection((availableMapProjection.value = "EPSG:3857"));
84
93
  }
85
94
  };
@@ -117,19 +126,23 @@ export function extractCollectionUrls(stacObject, basepath) {
117
126
  /**
118
127
  * Assign extracted roles to layer properties
119
128
  * @param {Record<string,any>} properties
120
- * @param {string[]} roles
121
- * @param {string} id - unique ID for baselayers and overlays
129
+ * @param {import("stac-ts").StacLink | import("stac-ts").StacAsset} linkOrAsset
122
130
  * */
123
- export const extractRoles = (properties, roles, id) => {
131
+ export const extractRoles = (properties, linkOrAsset) => {
132
+ const roles = /** @type {string[]} */ (linkOrAsset.roles);
124
133
  roles?.forEach((role) => {
125
134
  if (role === "visible") {
126
135
  properties.visible = true;
127
136
  }
128
137
  if (role === "overlay" || role === "baselayer") {
129
138
  properties.group = role;
130
- const [colId, itemId, isAsset, _random] = properties.id.split(";:;");
131
- properties.id = [colId, itemId, isAsset, id].join(";:;");
139
+ //remove all the properties and replace the random ID with baselayer
140
+ // provided ID
141
+ const [_colId, _itemId, _isAsset, _random, proj] =
142
+ properties.id.split(";:;");
143
+ properties.id = ["", "", "", "", linkOrAsset.id, proj].join(";:;");
132
144
  }
145
+
133
146
  return properties;
134
147
  });
135
148
  };
@@ -176,10 +189,10 @@ export const getProjectionCode = (projection) => {
176
189
 
177
190
  /**
178
191
  * @param {import("stac-ts").StacLink[]} [links]
179
- * @param {string|null} [current]
192
+ * @param {string|null} [currentStep]
180
193
  **/
181
- export const extractLayerDatetime = (links, current) => {
182
- if (!current || !links?.length) {
194
+ export const extractLayerDatetime = (links, currentStep) => {
195
+ if (!currentStep || !links?.length) {
183
196
  return undefined;
184
197
  }
185
198
 
@@ -190,9 +203,9 @@ export const extractLayerDatetime = (links, current) => {
190
203
  }
191
204
 
192
205
  /** @type {string[]} */
193
- const values = [];
206
+ const controlValues = [];
194
207
  try {
195
- current = new Date(current).toISOString();
208
+ currentStep = new Date(currentStep).toISOString();
196
209
 
197
210
  links.reduce((vals, link) => {
198
211
  if (link.datetime && link.rel === "item") {
@@ -201,24 +214,24 @@ export const extractLayerDatetime = (links, current) => {
201
214
  );
202
215
  }
203
216
  return vals;
204
- }, values);
217
+ }, controlValues);
205
218
  } catch (e) {
206
219
  console.warn("[eodash] not supported datetime format was provided", e);
207
220
  return undefined;
208
221
  }
209
- // not enough values
210
- if (values.length <= 1) {
222
+ // not enough controlValues
223
+ if (controlValues.length <= 1) {
211
224
  return undefined;
212
225
  }
213
226
 
214
227
  // item datetime is not included in the item links datetime
215
- if (!values.includes(current)) {
228
+ if (!controlValues.includes(currentStep)) {
216
229
  return undefined;
217
230
  }
218
231
 
219
232
  return {
220
- values,
221
- current,
233
+ controlValues,
234
+ currentStep,
222
235
  slider: false,
223
236
  disablePlay: true,
224
237
  };
@@ -279,7 +292,7 @@ export const getColFromLayer = async (indicators, layer) => {
279
292
  const collections = await Promise.all(
280
293
  indicators.map((ind) => ind.fetchCollection()),
281
294
  );
282
- const [collectionId, itemId, _asset, _random] = layer.get("id").split(";:;");
295
+ const [collectionId, itemId, ..._other] = layer.get("id").split(";:;");
283
296
 
284
297
  const chosen = collections.find((col) => {
285
298
  const isInd =
@@ -291,17 +304,72 @@ export const getColFromLayer = async (indicators, layer) => {
291
304
  });
292
305
  return indicators.find((ind) => ind.collectionStac?.id === chosen?.id);
293
306
  };
307
+
294
308
  /**
309
+ * generates layer specific ID, related functions are: {@link assignProjID} & {@link extractRoles}
310
+ * @param {string} collectionId
311
+ * @param {string} itemId
312
+ * @param {import('stac-ts').StacLink} link
313
+ * @param {string} projectionCode
295
314
  *
296
- * @param {string} colId
315
+ */
316
+ export const createLayerID = (collectionId, itemId, link, projectionCode) => {
317
+ const linkId = link.id || link.title || link.href;
318
+ let lId = `${collectionId ?? ""};:;${itemId ?? ""};:;${linkId ?? ""};:;${projectionCode ?? ""}`;
319
+ // If we are looking at base layers and overlays we remove the collection and item part
320
+ // as we want to make sure tiles are not reloaded when switching layers
321
+ if (
322
+ link.roles &&
323
+ // @ts-expect-error it seems roles it not defined for links yet
324
+ link.roles.find((r) => ["baselayer", "overlay"].includes(r))
325
+ ) {
326
+ lId = `${linkId ?? ""};:;${projectionCode ?? ""}`;
327
+ }
328
+ log.debug("Generated Layer ID", lId);
329
+ return lId;
330
+ };
331
+
332
+ /**
333
+ * generates layer specific ID, related functions are: {@link assignProjID} & {@link extractRoles}
334
+ * @param {string} collectionId
297
335
  * @param {string} itemId
298
- * @param {boolean} isAsset
299
- * @returns
336
+ * @param {number} index
337
+ *
300
338
  */
301
- export const createLayerID = (colId, itemId, isAsset) => {
302
- return `${colId ?? ""};:;${itemId ?? ""};:;${isAsset ? "_asset" : ""};:;${Math.random().toString(16).slice(2)}`;
339
+ export const createAssetID = (collectionId, itemId, index) => {
340
+ let lId = `${collectionId ?? ""};:;${itemId ?? ""};:;${index ?? ""}`;
341
+ log.debug("Generated Asset ID", lId);
342
+ return lId;
303
343
  };
304
344
 
345
+ /**
346
+ *
347
+ * @param {import("stac-ts").StacItem} item
348
+ * @param {import("stac-ts").StacLink | import("stac-ts").StacAsset} linkOrAsset
349
+ * @param {string} id - {@link createLayerID} & {@link extractRoles}
350
+ * @param {{ properties:{id:string} & Record<string, any> }& Record<string,any>} layer
351
+ * @returns
352
+ */
353
+ export function assignProjID(item, linkOrAsset, id, layer) {
354
+ const indicatorProjection =
355
+ /** @type { string | undefined} */
356
+ (item?.["proj:epsg"]) ||
357
+ /** @type { {name?: string} | undefined} */
358
+ (item?.["eodash:mapProjection"])?.name ||
359
+ "EPSG:3857";
360
+
361
+ const idArr = id.split(";:;");
362
+
363
+ idArr.pop();
364
+ idArr.push(indicatorProjection);
365
+ const updatedID = idArr.join(";:;");
366
+ layer.properties.id = updatedID;
367
+
368
+ log.debug("Updating layer id", updatedID);
369
+
370
+ return updatedID;
371
+ }
372
+
305
373
  /**
306
374
  * creates a structured clone from the layers and
307
375
  * removes all properties from the clone
@@ -316,7 +384,7 @@ export const removeUnneededProperties = (layers) => {
316
384
  const title = layer.properties.title;
317
385
  layer.properties = { id, title };
318
386
  if (layer["interactions"]) {
319
- delete layer["interactions"]
387
+ delete layer["interactions"];
320
388
  }
321
389
  if (layer.type === "Group") {
322
390
  layer.layers = removeUnneededProperties(layer.layers);
@@ -1,5 +1,5 @@
1
- import { _ as y, x as m, W as x, X as d, $ as t, a0 as r, a1 as l, a9 as _, a3 as n, a6 as u, a2 as c, a4 as p, d as h, a5 as g, F as f, a7 as v, ab as w } from "./asWebComponent-3OsFQJVx.js";
2
- import { V as k } from "./VMain-Ck81LJfb.js";
1
+ import { _ as y, x as m, W as x, X as d, $ as t, a0 as r, a1 as l, a9 as _, a3 as n, a6 as u, a2 as c, a4 as p, d as h, a5 as g, F as f, a7 as v, ab as w } from "./asWebComponent-DhR2_xlP.js";
2
+ import { V as k } from "./VMain-Df5VMG9r.js";
3
3
  class A extends HTMLElement {
4
4
  static get observedAttributes() {
5
5
  return ["gap"];
@@ -1,4 +1,4 @@
1
- import { bL as i, aC as m, r as p, Z as d, aO as f, $ as c, a6 as g, a0 as y, d as _, a4 as k } from "./asWebComponent-3OsFQJVx.js";
1
+ import { bL as i, aD as m, r as p, Z as d, aQ as f, $ as c, a6 as g, a0 as y, d as _, a4 as k } from "./asWebComponent-DhR2_xlP.js";
2
2
  const h = { class: "d-flex flex-column fill-height overflow-auto" }, N = {
3
3
  __name: "DynamicWebComponent",
4
4
  props: {
@@ -38,7 +38,7 @@ const h = { class: "d-flex flex-column fill-height overflow-auto" }, N = {
38
38
  e.onMounted?.(r.value, s);
39
39
  }), f(() => {
40
40
  e.onUnmounted?.(r.value, s);
41
- }), (n, w) => (c(), g("span", h, [
41
+ }), (n, x) => (c(), g("span", h, [
42
42
  (c(), y(
43
43
  k(o.tagName),
44
44
  _(o.properties, {