@eodash/eodash 5.0.0 → 5.2.0

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 (162) hide show
  1. package/README.md +1 -0
  2. package/core/client/App.vue +8 -2
  3. package/core/client/asWebComponent.js +5 -5
  4. package/core/client/components/DashboardLayout.vue +43 -26
  5. package/core/client/components/EodashOverlay.vue +5 -6
  6. package/core/client/components/ErrorAlert.vue +2 -2
  7. package/core/client/components/Footer.vue +4 -4
  8. package/core/client/components/Header.vue +3 -3
  9. package/core/client/components/MobileLayout.vue +47 -27
  10. package/core/client/composables/DefineEodash.js +38 -43
  11. package/core/client/composables/DefineTemplate.js +4 -2
  12. package/core/client/composables/DefineWidgets.js +14 -8
  13. package/core/client/composables/index.js +273 -23
  14. package/core/client/eodashSTAC/EodashCollection.js +84 -62
  15. package/core/client/eodashSTAC/createLayers.js +30 -0
  16. package/core/client/eodashSTAC/helpers.js +159 -28
  17. package/core/client/eodashSTAC/parquet.js +145 -0
  18. package/core/client/eodashSTAC/triggers.js +6 -3
  19. package/core/client/plugins/index.js +4 -3
  20. package/core/client/plugins/vuetify.js +3 -0
  21. package/core/client/store/actions.js +21 -4
  22. package/core/client/store/stac.js +93 -56
  23. package/core/client/store/states.js +15 -5
  24. package/core/client/types.ts +59 -43
  25. package/core/client/utils/index.js +79 -0
  26. package/core/client/utils/keys.js +2 -2
  27. package/core/client/utils/states.js +30 -5
  28. package/core/client/views/Dashboard.vue +36 -32
  29. package/core/client/vite-env.d.ts +7 -0
  30. package/dist/client/{DashboardLayout-CkWvOMOW.js → DashboardLayout-Dq9Kfe6O.js} +24 -13
  31. package/dist/client/{DynamicWebComponent-DYBbpvUK.js → DynamicWebComponent-DCBMXskE.js} +1 -1
  32. package/dist/client/{EodashDatePicker-CALmW3SI.js → EodashDatePicker-DtngxU6s.js} +59 -32
  33. package/dist/client/{EodashItemFilter-DlQiE713.js → EodashItemFilter-ClQebJQt.js} +20 -10
  34. package/dist/client/{EodashLayerControl-DEzEbft7.js → EodashLayerControl-BLBds28C.js} +29 -16
  35. package/dist/client/EodashLayoutSwitcher-DQ8SfVDd.js +61 -0
  36. package/dist/client/EodashMapBtns-B89_YBDw.js +326 -0
  37. package/dist/client/{EodashStacInfo-DPPxDkF6.js → EodashStacInfo-Dt1nF06x.js} +3 -18
  38. package/dist/client/{EodashTools-CUaL9s4H.js → EodashTools-DV5ykmWc.js} +13 -13
  39. package/dist/client/{ExportState-DjyIZVhl.js → ExportState-B6zZQUmE.js} +57 -52
  40. package/dist/client/{Footer-DyL0JoWt.js → Footer-DNhXs8k6.js} +15 -13
  41. package/dist/client/{Header-B5Dgty9l.js → Header-BjhN5JY4.js} +32 -28
  42. package/dist/client/MobileLayout-JelB6w1G.js +118 -0
  43. package/dist/client/{PopUp-BfB8s_ki.js → PopUp-CgpvNr3o.js} +18 -10
  44. package/dist/client/ProcessList-vecpxThi.js +198 -0
  45. package/dist/client/{VImg-FD1WVphJ.js → VImg-CETuikH2.js} +221 -26
  46. package/dist/client/{VMain-DJKG4SvM.js → VMain-Ci9DyaGU.js} +7 -7
  47. package/dist/client/{VTooltip-CfeefrXI.js → VTooltip-J4ac48X7.js} +12 -10
  48. package/dist/client/{WidgetsContainer-C2TaTdb6.js → WidgetsContainer-CCML4TyV.js} +1 -1
  49. package/dist/client/asWebComponent-ZyEzWOOf.js +19092 -0
  50. package/dist/client/async-B7jIrM53.js +804 -0
  51. package/dist/client/eo-dash.js +1 -1
  52. package/dist/client/{VOverlay-BzOdRu9h.js → forwardRefs-BQclvjMq.js} +332 -28
  53. package/dist/client/handling-BS24aG1q.js +1227 -0
  54. package/dist/client/helpers-wXK7Ywio.js +4556 -0
  55. package/dist/client/index-4UCzZi8B.js +376 -0
  56. package/dist/client/{index-4CT7Tz83.js → index-9KR-G20t.js} +2 -2
  57. package/dist/client/{index-CIHH_3dW.js → index-B2XpdgR6.js} +227 -86
  58. package/dist/client/material-symbols-outlined.woff2 +0 -0
  59. package/dist/client/material-symbols-rounded.woff2 +0 -0
  60. package/dist/client/material-symbols-sharp.woff2 +0 -0
  61. package/dist/client/material-symbols-subset.woff2 +0 -0
  62. package/dist/client/{ssrBoot-BP7SYRyC.js → ssrBoot-Zgc_Ttvi.js} +2 -2
  63. package/dist/client/templates.js +840 -0
  64. package/dist/client/transition-yBii4fu6.js +40 -0
  65. package/dist/node/cli.js +16 -6
  66. package/dist/node/types.d.ts +1 -1
  67. package/dist/types/core/client/App.vue.d.ts +2 -2
  68. package/dist/types/core/client/asWebComponent.d.ts +1 -1
  69. package/dist/types/core/client/components/DynamicWebComponent.vue.d.ts +1 -3
  70. package/dist/types/core/client/components/Footer.vue.d.ts +1 -105
  71. package/dist/types/core/client/components/IframeWrapper.vue.d.ts +1 -1
  72. package/dist/types/core/client/components/MobileLayout.vue.d.ts +1 -324
  73. package/dist/types/core/client/composables/DefineEodash.d.ts +2 -2
  74. package/dist/types/core/client/composables/DefineTemplate.d.ts +1 -1
  75. package/dist/types/core/client/composables/DefineWidgets.d.ts +4 -4
  76. package/dist/types/core/client/composables/index.d.ts +24 -2
  77. package/dist/types/core/client/eodashSTAC/EodashCollection.d.ts +9 -6
  78. package/dist/types/core/client/eodashSTAC/helpers.d.ts +25 -5
  79. package/dist/types/core/client/eodashSTAC/parquet.d.ts +2 -0
  80. package/dist/types/core/client/plugins/vuetify.d.ts +7 -4
  81. package/dist/types/core/client/store/actions.d.ts +3 -2
  82. package/dist/types/core/client/store/stac.d.ts +16 -13
  83. package/dist/types/core/client/store/states.d.ts +14 -4
  84. package/dist/types/core/client/types.d.ts +46 -31
  85. package/dist/types/core/client/utils/index.d.ts +2 -0
  86. package/dist/types/core/client/utils/keys.d.ts +4 -4
  87. package/dist/types/core/client/utils/states.d.ts +59 -47
  88. package/dist/types/core/client/views/Dashboard.vue.d.ts +2 -2
  89. package/dist/types/templates/baseConfig.d.ts +4 -0
  90. package/dist/types/templates/compare.d.ts +185 -0
  91. package/dist/types/templates/expert.d.ts +147 -0
  92. package/dist/types/templates/index.d.ts +6 -0
  93. package/dist/types/templates/light.d.ts +154 -0
  94. package/dist/types/widgets/EodashDatePicker.vue.d.ts +1 -458
  95. package/dist/types/widgets/EodashItemFilter.vue.d.ts +3 -3
  96. package/dist/types/widgets/EodashLayerControl.vue.d.ts +14 -7
  97. package/dist/types/widgets/EodashLayoutSwitcher.vue.d.ts +1 -3
  98. package/dist/types/widgets/{EodashMapBtns.vue.d.ts → EodashMap/EodashMapBtns.vue.d.ts} +12 -8
  99. package/dist/types/widgets/EodashMap/index.vue.d.ts +9 -4
  100. package/dist/types/widgets/EodashProcess/ProcessList.vue.d.ts +8 -1
  101. package/dist/types/widgets/EodashProcess/index.vue.d.ts +8 -4
  102. package/dist/types/widgets/EodashProcess/methods/async.d.ts +19 -18
  103. package/dist/types/widgets/EodashProcess/methods/composables.d.ts +3 -2
  104. package/dist/types/widgets/EodashProcess/methods/custom-endpoints/chart/index.d.ts +1 -0
  105. package/dist/types/widgets/EodashProcess/methods/custom-endpoints/chart/sentinelhub-endpoint.d.ts +6 -0
  106. package/dist/types/widgets/EodashProcess/methods/custom-endpoints/chart/veda-endpoint.d.ts +4 -0
  107. package/dist/types/widgets/EodashProcess/methods/custom-endpoints/layers/eoxhub-workspaces-endpoint.d.ts +5 -0
  108. package/dist/types/widgets/EodashProcess/methods/custom-endpoints/layers/index.d.ts +1 -0
  109. package/dist/types/widgets/EodashProcess/methods/handling.d.ts +12 -5
  110. package/dist/types/widgets/EodashProcess/methods/outputs.d.ts +72 -41
  111. package/dist/types/widgets/EodashProcess/methods/utils.d.ts +41 -21
  112. package/dist/types/widgets/EodashProcess/states.d.ts +11 -0
  113. package/dist/types/widgets/EodashProcess/types.d.ts +41 -0
  114. package/dist/types/widgets/EodashStacInfo.vue.d.ts +14 -14
  115. package/dist/types/widgets/EodashTools.vue.d.ts +3 -3
  116. package/dist/types/widgets/ExportState.vue.d.ts +1 -1
  117. package/dist/types/widgets/PopUp.vue.d.ts +11 -16
  118. package/dist/types/widgets/WidgetsContainer.vue.d.ts +3 -6
  119. package/package.json +55 -45
  120. package/templates/baseConfig.js +68 -0
  121. package/templates/compare.js +142 -0
  122. package/templates/expert.js +124 -0
  123. package/templates/index.js +8 -0
  124. package/templates/light.js +139 -0
  125. package/widgets/EodashDatePicker.vue +80 -31
  126. package/widgets/EodashItemFilter.vue +26 -11
  127. package/widgets/EodashLayerControl.vue +20 -11
  128. package/widgets/EodashLayoutSwitcher.vue +6 -3
  129. package/widgets/EodashMap/EodashMapBtns.vue +269 -0
  130. package/widgets/EodashMap/index.vue +255 -45
  131. package/widgets/EodashMap/methods/create-layers-config.js +4 -3
  132. package/widgets/EodashMap/methods/index.js +33 -23
  133. package/widgets/EodashProcess/ProcessList.vue +47 -11
  134. package/widgets/EodashProcess/index.vue +55 -20
  135. package/widgets/EodashProcess/methods/async.js +99 -60
  136. package/widgets/EodashProcess/methods/composables.js +21 -14
  137. package/widgets/EodashProcess/methods/custom-endpoints/chart/index.js +35 -0
  138. package/widgets/EodashProcess/methods/custom-endpoints/chart/sentinelhub-endpoint.js +275 -0
  139. package/widgets/EodashProcess/methods/custom-endpoints/chart/veda-endpoint.js +132 -0
  140. package/widgets/EodashProcess/methods/custom-endpoints/layers/eoxhub-workspaces-endpoint.js +94 -0
  141. package/widgets/EodashProcess/methods/custom-endpoints/layers/index.js +33 -0
  142. package/widgets/EodashProcess/methods/handling.js +127 -80
  143. package/widgets/EodashProcess/methods/outputs.js +376 -125
  144. package/widgets/EodashProcess/methods/utils.js +442 -10
  145. package/widgets/EodashProcess/states.js +13 -0
  146. package/widgets/EodashProcess/types.ts +46 -0
  147. package/widgets/EodashStacInfo.vue +2 -17
  148. package/widgets/EodashTools.vue +13 -13
  149. package/widgets/WidgetsContainer.vue +1 -1
  150. package/core/client/eodash.js +0 -454
  151. package/dist/client/EodashLayoutSwitcher-CDeCV8F-.js +0 -52
  152. package/dist/client/EodashMapBtns-CktQCfa-.js +0 -131
  153. package/dist/client/MobileLayout-CRsg_5Q4.js +0 -1217
  154. package/dist/client/ProcessList-DTefwQZx.js +0 -484
  155. package/dist/client/asWebComponent-CLhcT715.js +0 -12479
  156. package/dist/client/eo-dash.css +0 -5
  157. package/dist/client/forwardRefs-Bon_Kku1.js +0 -245
  158. package/dist/client/index-Bm9cbtx5.js +0 -201
  159. package/dist/client/index-DiGDvTQU.js +0 -780
  160. package/dist/client/transition-C5I57hn6.js +0 -37
  161. package/dist/types/core/client/eodash.d.ts +0 -8
  162. package/widgets/EodashMapBtns.vue +0 -113
@@ -0,0 +1,145 @@
1
+ import { parquetRead } from "hyparquet";
2
+ import WKB from "ol/format/WKB.js";
3
+ import GeoJSON from "ol/format/GeoJSON";
4
+ import log from "loglevel";
5
+
6
+ /**
7
+ * @param {string} url
8
+ */
9
+ export const readParquetItems = async (url) => {
10
+ /** @type {import("stac-ts").StacItem[]} */
11
+ let items = [];
12
+ const response = await fetch(url, {
13
+ method: "GET",
14
+ headers: {
15
+ Accept: "application/octet-stream",
16
+ },
17
+ });
18
+
19
+ if (!response.ok) {
20
+ throw new Error(`Fetch failed: ${response.status} ${response.statusText}`);
21
+ }
22
+ const contentType = response.headers.get("Content-Type") || "";
23
+ if (
24
+ !contentType.includes("application") &&
25
+ !contentType.includes("octet-stream") &&
26
+ !url.endsWith(".parquet")
27
+ ) {
28
+ console.warn(
29
+ "Response may not be a Parquet file. Content-Type:",
30
+ contentType,
31
+ );
32
+ }
33
+ const arrayBuffer = await response.arrayBuffer();
34
+ if (arrayBuffer.byteLength < 8) {
35
+ throw new Error(
36
+ "Downloaded buffer is too small to be a valid Parquet file.",
37
+ );
38
+ }
39
+ await parquetRead({
40
+ file: arrayBuffer,
41
+ rowFormat: "object",
42
+ // set utf8 to false to avoid parsing wkb to string
43
+ utf8: false,
44
+ /*** @param {import("stac-ts").StacItem[]} data */
45
+ //@ts-expect-error rows are expected be array of arrays in hyparquet
46
+ onComplete: (data) => {
47
+ items.push(...(adjustParquetItems(data) ?? []));
48
+ },
49
+ });
50
+ log.debug("Adjusted Parquet items", items);
51
+ return items;
52
+ };
53
+
54
+ /**
55
+ *
56
+ * @param {import("stac-ts").StacItem[]} items
57
+ */
58
+ export const adjustParquetItems = (items) => {
59
+ return items.map((item) => {
60
+ item = moveItemProperties(item);
61
+ item = adjustItemsBigInts(item);
62
+
63
+ return /** @type {import("stac-ts").StacItem} */ ({
64
+ ...item,
65
+ //@ts-expect-error geometry wkb conversion by stac-geoparquet
66
+ geometry: wkbToGeometry(item.geometry),
67
+
68
+ assets: ((assets) => {
69
+ for (const [key, value] of Object.entries(assets)) {
70
+ if (!value || !value.href) {
71
+ delete assets[key];
72
+ }
73
+ }
74
+ return assets;
75
+ })(item.assets),
76
+
77
+ bbox: ((bbox) => {
78
+ //@ts-expect-error bbox conversion by stac-geoparquet
79
+ const { xmax, xmin, ymax, ymin } = bbox;
80
+ return [xmin, ymin, xmax, ymax].map((v) => parseFloat(v));
81
+ })(item.bbox),
82
+ });
83
+ });
84
+ };
85
+ /**
86
+ * @param {Uint8Array} wkb - Well Known Binary
87
+ */
88
+ function wkbToGeometry(wkb) {
89
+ const geoJsonFormatter = new GeoJSON();
90
+ const wkbReader = new WKB();
91
+ const olGeometry = wkbReader.readGeometry(wkb);
92
+ return geoJsonFormatter.writeGeometryObject(olGeometry);
93
+ }
94
+
95
+ /**
96
+ *
97
+ * @param {import("stac-ts").StacItem} item
98
+ */
99
+ function moveItemProperties(item) {
100
+ const stacProperties = [
101
+ "assets",
102
+ "links",
103
+ "bbox",
104
+ "geometry",
105
+ "stac_version",
106
+ "stac_extensions",
107
+ "type",
108
+ "id",
109
+ "collection",
110
+ "properties",
111
+ ];
112
+ for (const key in item) {
113
+ if (!stacProperties.includes(key)) {
114
+ if (!item.properties) {
115
+ item.properties = {};
116
+ }
117
+ item.properties[key] = item[key];
118
+ delete item[key];
119
+ }
120
+ }
121
+ return item;
122
+ }
123
+
124
+ /**
125
+ *
126
+ * @param {import("stac-ts").StacItem} item
127
+ */
128
+ function adjustItemsBigInts(item) {
129
+ /** @param {*} obj */
130
+ const adjustBigInt = (obj) => {
131
+ for (const key in obj ?? {}) {
132
+ if (typeof obj[key] === "bigint") {
133
+ obj[key] = parseFloat(obj[key].toString());
134
+ } else if (typeof obj[key] === "object" && obj[key] !== null) {
135
+ adjustBigInt(obj[key]);
136
+ }
137
+ }
138
+ };
139
+ adjustBigInt(item.links);
140
+ adjustBigInt(item.properties);
141
+ adjustBigInt(item.assets);
142
+ adjustBigInt(item.bbox);
143
+ adjustBigInt(item.geometry);
144
+ return item;
145
+ }
@@ -52,9 +52,12 @@ export function getStyleVariablesState(collectionId, variables) {
52
52
  return variables;
53
53
  }
54
54
 
55
- const analysisGroup = mapElement.layers.find(
56
- (layer) => layer.properties?.id === "AnalysisGroup",
57
- );
55
+ const analysisGroup =
56
+ /** @type {import("@eox/map/src/layers").EOxLayerTypeGroup | undefined} */ (
57
+ mapElement.layers.find(
58
+ (layer) => layer.properties?.id === "AnalysisGroup",
59
+ )
60
+ );
58
61
  if (!analysisGroup) {
59
62
  return variables;
60
63
  }
@@ -1,10 +1,10 @@
1
1
  import vuetify from "./vuetify";
2
2
  import { createPinia } from "pinia";
3
- import eodash from "@/eodash";
4
3
  import VCalendar from "v-calendar";
5
- import { eodashKey } from "@/utils/keys";
6
4
  import store from "../store";
7
5
  import log from "loglevel";
6
+ import { eodashKey } from "@/utils/keys";
7
+ import { reactive } from "vue";
8
8
 
9
9
  export const pinia = createPinia();
10
10
 
@@ -17,5 +17,6 @@ export function registerPlugins(app) {
17
17
  .use(pinia)
18
18
  // Use plugin with optional defaults
19
19
  .use(VCalendar, {})
20
- .provide(eodashKey, eodash);
20
+ //@ts-expect-error reactive placeholder for eodash
21
+ .provide(eodashKey, reactive({}));
21
22
  }
@@ -6,11 +6,14 @@
6
6
 
7
7
  // Styles
8
8
  import "vuetify/styles";
9
+ import "@eox/ui/vuetify/style.css";
10
+ import { eox } from "@eox/ui/vuetify/blueprint.js";
9
11
 
10
12
  import { createVuetify } from "vuetify";
11
13
  import { mdiChevronLeft, mdiChevronRight, mdiMenuDown, mdiPlus } from "@mdi/js";
12
14
 
13
15
  const vuetify = createVuetify({
16
+ blueprint: eox,
14
17
  icons: {
15
18
  aliases: {
16
19
  // mapping v-date-picker and v-tabs default icons to `@mdi/js`
@@ -3,21 +3,24 @@ import {
3
3
  mapCompareEl,
4
4
  registeredProjections,
5
5
  activeTemplate,
6
+ poi,
7
+ comparePoi,
6
8
  } from "@/store/states";
7
9
  import { getProjectionCode } from "@/eodashSTAC/helpers";
8
10
  import log from "loglevel";
9
11
 
10
12
  /**
11
13
  * Returns the current layers of {@link mapEl}
12
- * @returns {Record<string,any>[]}
14
+ * @returns {import("@eox/map").EoxLayer[]}
13
15
  */
14
- export const getLayers = () => mapEl.value?.layers.toReversed();
16
+ export const getLayers = () => mapEl.value?.layers.toReversed() ?? [];
15
17
 
16
18
  /**
17
19
  * Returns the current layers of {@link mapCompareEl}
18
- * @returns {Record<string,any>[]}
20
+ * * @returns {import("@eox/map").EoxLayer[]}
19
21
  */
20
- export const getCompareLayers = () => mapCompareEl.value?.layers.toReversed();
22
+ export const getCompareLayers = () =>
23
+ mapCompareEl.value?.layers.toReversed() ?? [];
21
24
 
22
25
  /**
23
26
  * Register EPSG projection in `eox-map`
@@ -77,3 +80,17 @@ export const setActiveTemplate = (template) => {
77
80
  activeTemplate.value = template;
78
81
  log.debug("Setting active template to", template);
79
82
  };
83
+
84
+ /**
85
+ * Check whether the collection needs an EodashProcess Widget
86
+ * @param {import("stac-ts").StacCollection | null | undefined} collection
87
+ * @param {boolean} [compare=false] - Whether to check for compare collection
88
+ * @returns
89
+ */
90
+ export const includesProcess = (collection, compare = false) => {
91
+ const isPoiAlive = compare ? !!comparePoi.value : !!poi.value;
92
+
93
+ return (
94
+ collection?.links?.some((link) => link.rel === "service") || isPoiAlive
95
+ );
96
+ };
@@ -1,20 +1,28 @@
1
1
  import { defineStore } from "pinia";
2
- import { inject, ref } from "vue";
2
+ import { ref } from "vue";
3
3
  import axios from "@/plugins/axios";
4
- import { useAbsoluteUrl, useCompareAbsoluteUrl } from "@/composables/index";
5
- import { eodashKey } from "@/utils/keys";
6
- import { indicator } from "@/store/states";
7
- import { extractCollectionUrls } from "@/eodashSTAC/helpers";
4
+ import {
5
+ useAbsoluteUrl,
6
+ useCompareAbsoluteUrl,
7
+ useGetSubCodeId,
8
+ } from "@/composables/index";
9
+ import { compareIndicator, comparePoi, indicator, poi } from "@/store/states";
8
10
  import {
9
11
  eodashCollections,
10
12
  eodashCompareCollections,
11
13
  collectionsPalette,
12
- switchToCompare,
13
14
  } from "@/utils/states";
14
- import { EodashCollection } from "@/eodashSTAC/EodashCollection";
15
15
  import log from "loglevel";
16
+ import { toAbsolute } from "stac-js/src/http.js";
17
+ import { updateEodashCollections } from "@/utils";
16
18
 
17
19
  export const useSTAcStore = defineStore("stac", () => {
20
+ /**
21
+ * STAC catalog endpoint URL
22
+ * @type {import("vue").Ref<import("@/types").StacEndpoint | null>}
23
+ */
24
+ const stacEndpoint = ref(null);
25
+
18
26
  /**
19
27
  * Links of the root STAC catalog
20
28
  *
@@ -26,9 +34,7 @@ export const useSTAcStore = defineStore("stac", () => {
26
34
  * Selected STAC object.
27
35
  *
28
36
  * @type {import("vue").Ref<
29
- * | import("stac-ts").StacCatalog
30
37
  * | import("stac-ts").StacCollection
31
- * | import("stac-ts").StacItem
32
38
  * | null
33
39
  * >}
34
40
  */
@@ -38,15 +44,19 @@ export const useSTAcStore = defineStore("stac", () => {
38
44
  * Selected STAC object.
39
45
  *
40
46
  * @type {import("vue").Ref<
41
- * | import("stac-ts").StacCatalog
42
47
  * | import("stac-ts").StacCollection
43
- * | import("stac-ts").StacItem
44
48
  * | null
45
49
  * >}
46
50
  */
47
51
  const selectedCompareStac = ref(null);
48
52
 
49
- const eodash = /** @type {import("@/types").Eodash} */ (inject(eodashKey));
53
+ /**
54
+ * Initializes the store by assigning the STAC endpoint.
55
+ * @param {import("@/types").StacEndpoint} endpoint
56
+ */
57
+ function init(endpoint) {
58
+ stacEndpoint.value = endpoint;
59
+ }
50
60
 
51
61
  /**
52
62
  * Fetches root stac catalog and assign it to `stac`
@@ -56,7 +66,19 @@ export const useSTAcStore = defineStore("stac", () => {
56
66
  * @returns {Promise<void>}
57
67
  * @see {@link stac}
58
68
  */
59
- async function loadSTAC(url = eodash.stacEndpoint) {
69
+ async function loadSTAC(url) {
70
+ if (!url) {
71
+ if (!stacEndpoint.value) {
72
+ throw new Error("STAC endpoint is not defined in eodash configuration");
73
+ }
74
+ url = stacEndpoint.value;
75
+ }
76
+
77
+ if (!url) {
78
+ stac.value = null;
79
+ return;
80
+ }
81
+
60
82
  log.debug("Loading STAC endpoint", url);
61
83
  await axios
62
84
  .get(url)
@@ -81,44 +103,40 @@ export const useSTAcStore = defineStore("stac", () => {
81
103
  * Fetches selected stac object and assign it to `selectedStac`
82
104
  *
83
105
  * @param {string} relativePath - Stac link href
106
+ * @param {boolean} [isPoi=false] - If true, the STAC is loaded for a point of interest
84
107
  * @returns {Promise<void>}
85
108
  * @see {@link selectedStac}
86
109
  */
87
- async function loadSelectedSTAC(relativePath = "") {
88
- const absoluteUrl = useAbsoluteUrl(relativePath);
110
+ async function loadSelectedSTAC(relativePath = "", isPoi = false) {
111
+ if (!stacEndpoint.value) {
112
+ return Promise.reject(new Error("STAC endpoint is not defined"));
113
+ }
114
+ const absoluteUrl = useAbsoluteUrl(relativePath, stacEndpoint.value);
115
+ if (isPoi) {
116
+ // construct absolute URL of a poi
117
+ absoluteUrl.value = constructPoiUrl(relativePath, indicator.value);
118
+ }
89
119
 
90
120
  await axios
91
121
  .get(absoluteUrl.value)
92
122
  .then(async (resp) => {
93
- // init eodash collections
94
- const collectionUrls = extractCollectionUrls(
123
+ await updateEodashCollections(
124
+ eodashCollections,
95
125
  resp.data,
96
126
  absoluteUrl.value,
127
+ collectionsPalette,
97
128
  );
98
-
99
- await Promise.all(
100
- collectionUrls.map((cu, idx) => {
101
- const ec = new EodashCollection(cu);
102
- ec.fetchCollection();
103
- ec.color = collectionsPalette[idx % collectionsPalette.length];
104
- return ec;
105
- }),
106
- ).then((collections) => {
107
- // empty array from old collections
108
- eodashCollections.splice(0, eodashCollections.length);
109
- // update eodashCollections
110
- eodashCollections.push(...collections);
111
-
112
- selectedStac.value = resp.data;
113
- indicator.value = selectedStac.value?.id ?? "";
114
- switchToCompare.value = true;
115
- });
129
+ selectedStac.value = resp.data;
130
+ // set indicator and poi
131
+ indicator.value = isPoi
132
+ ? indicator.value
133
+ : useGetSubCodeId(selectedStac.value);
134
+ poi.value = isPoi ? (selectedStac.value?.id ?? "") : "";
116
135
  })
117
136
  .catch((err) => {
118
137
  throw new Error("error loading the selected STAC", err);
119
138
  });
120
139
  }
121
-
122
140
  /**
123
141
  * Fetches selected stac object and assign it to `selectedCompareStac`
124
142
  *
@@ -126,32 +144,31 @@ export const useSTAcStore = defineStore("stac", () => {
126
144
  * @returns {Promise<void>}
127
145
  * @see {@link selectedCompareStac}
128
146
  */
129
- async function loadSelectedCompareSTAC(relativePath = "") {
130
- const absoluteUrl = useCompareAbsoluteUrl(relativePath);
147
+ async function loadSelectedCompareSTAC(relativePath = "", isPOI = false) {
148
+ if (!stacEndpoint.value) {
149
+ return Promise.reject(
150
+ new Error("STAC endpoint is not defined in eodash configuration"),
151
+ );
152
+ }
153
+ const absoluteUrl = useCompareAbsoluteUrl(relativePath, stacEndpoint.value);
154
+ if (isPOI) {
155
+ // construct absolute URL of a poi
156
+ absoluteUrl.value = constructPoiUrl(relativePath, compareIndicator.value);
157
+ }
131
158
  await axios
132
159
  .get(absoluteUrl.value)
133
160
  .then(async (resp) => {
134
- // init eodash collections
135
- const collectionUrls = await extractCollectionUrls(
161
+ await updateEodashCollections(
162
+ eodashCompareCollections,
136
163
  resp.data,
137
164
  absoluteUrl.value,
165
+ [...collectionsPalette].reverse(),
138
166
  );
139
-
140
- await Promise.all(
141
- collectionUrls.map((cu) => {
142
- const ec = new EodashCollection(cu);
143
- ec.fetchCollection();
144
- return ec;
145
- }),
146
- ).then((collections) => {
147
- // empty array from old collections
148
- eodashCompareCollections.splice(0, eodashCompareCollections.length);
149
- // update eodashCompareCollections
150
- eodashCompareCollections.push(...collections);
151
-
152
- selectedCompareStac.value = resp.data;
153
- switchToCompare.value = false;
154
- });
167
+ selectedCompareStac.value = resp.data;
168
+ compareIndicator.value = isPOI
169
+ ? compareIndicator.value
170
+ : useGetSubCodeId(selectedCompareStac.value);
171
+ comparePoi.value = isPOI ? (selectedCompareStac.value?.id ?? "") : "";
155
172
  })
156
173
  .catch((err) => {
157
174
  throw new Error("error loading the selected comparison STAC", err);
@@ -163,11 +180,31 @@ export const useSTAcStore = defineStore("stac", () => {
163
180
  *
164
181
  */
165
182
  async function resetSelectedCompareSTAC() {
183
+ eodashCompareCollections.splice(0, eodashCompareCollections.length);
166
184
  selectedCompareStac.value = null;
167
185
  }
168
186
 
187
+ /**
188
+ * Construct absolute URL of a point of interest (POI)
189
+ *
190
+ * @param {string} relativePath - The relative path to the POI
191
+ * @param {string} indicatorStr - selected indicator id or subcode
192
+ */
193
+ function constructPoiUrl(relativePath, indicatorStr) {
194
+ if (!stacEndpoint.value) {
195
+ throw new Error("STAC endpoint is not defined in eodash configuration");
196
+ }
197
+ // construct absolute URL of a poi
198
+ const indicatorUrl =
199
+ stac.value?.find((link) => useGetSubCodeId(link) === indicatorStr)
200
+ ?.href ?? "";
201
+ const absoluteIndicatorUrl = toAbsolute(indicatorUrl, stacEndpoint.value);
202
+ return toAbsolute(relativePath, absoluteIndicatorUrl);
203
+ }
204
+
169
205
  return {
170
206
  stac,
207
+ init,
171
208
  loadSTAC,
172
209
  loadSelectedSTAC,
173
210
  loadSelectedCompareSTAC,
@@ -2,7 +2,7 @@
2
2
  import log from "loglevel";
3
3
  log.setLevel(log.levels.WARN, true);
4
4
 
5
- import { ref } from "vue";
5
+ import { ref, shallowRef } from "vue";
6
6
 
7
7
  /** Currently selected STAC endpoint */
8
8
  export const currentUrl = ref("");
@@ -15,6 +15,8 @@ export const datetime = ref(new Date().toISOString());
15
15
 
16
16
  /** Currently selected indicator */
17
17
  export const indicator = ref("");
18
+ /** Currently selected compare indicator */
19
+ export const compareIndicator = ref("");
18
20
 
19
21
  /**
20
22
  * Current map position
@@ -28,10 +30,18 @@ export const registeredProjections = ["EPSG:4326", "EPSG:3857"];
28
30
  /** available projection to be rendered by `EodashMap` */
29
31
  export const availableMapProjection = ref("EPSG:3857");
30
32
 
31
- /** @type {import("vue").Ref<HTMLElement & Record<string,any> | null>} */
32
- export const mapEl = ref(null);
33
+ /** @type {import("vue").Ref<import("@eox/map").EOxMap | null>} */
34
+ export const mapEl = shallowRef(null);
33
35
 
34
- /** @type {import("vue").Ref<HTMLElement & Record<string,any> | null>} */
35
- export const mapCompareEl = ref(null);
36
+ /** @type {import("vue").Ref<import("@eox/map").EOxMap | null>} */
37
+ export const mapCompareEl = shallowRef(null);
36
38
 
37
39
  export const activeTemplate = ref("");
40
+ /**
41
+ * Selected point of interest, used for location collections
42
+ */
43
+ export const poi = ref("");
44
+ /**
45
+ * Selected point of interest for comparison, used for location collections
46
+ */
47
+ export const comparePoi = ref("");