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

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 (137) hide show
  1. package/README.md +1 -1
  2. package/core/client/App.vue +13 -1
  3. package/core/client/asWebComponent.js +13 -3
  4. package/core/client/components/DashboardLayout.vue +6 -2
  5. package/core/client/composables/DefineEodash.js +1 -1
  6. package/core/client/composables/EodashMap.js +349 -0
  7. package/core/client/composables/EodashProcess.js +575 -0
  8. package/core/client/composables/index.js +107 -24
  9. package/core/client/eodash.js +83 -10
  10. package/core/client/plugins/axios.js +8 -0
  11. package/core/client/plugins/index.js +2 -1
  12. package/core/client/store/Actions.js +63 -12
  13. package/core/client/store/States.js +19 -0
  14. package/core/client/store/stac.js +98 -8
  15. package/core/client/types.d.ts +25 -18
  16. package/core/client/utils/createLayers.js +313 -0
  17. package/core/client/utils/eodashSTAC.js +320 -170
  18. package/core/client/utils/helpers.js +369 -9
  19. package/core/client/utils/keys.js +2 -0
  20. package/core/client/utils/states.js +17 -0
  21. package/core/client/views/Dashboard.vue +17 -46
  22. package/core/client/vite-env.d.ts +1 -9
  23. package/dist/client/DashboardLayout-CVMJ4l8M.js +87 -0
  24. package/dist/client/DynamicWebComponent-Cv8n457T.js +88 -0
  25. package/dist/client/EodashDatePicker-VVkiPmpc.js +394 -0
  26. package/dist/client/EodashItemFilter-CugWNQ86.js +194 -0
  27. package/dist/client/EodashLayerControl-53WghA8G.js +110 -0
  28. package/dist/client/EodashMap-CQnOePpy.js +486 -0
  29. package/dist/client/EodashMapBtns-uaRwFtfB.js +66 -0
  30. package/dist/client/EodashProcess-cF0unIy8.js +1477 -0
  31. package/dist/client/ExportState-BT8MLAW7.js +644 -0
  32. package/dist/client/Footer-C6GUG84G.js +141 -0
  33. package/dist/client/Header-D2dtCWp8.js +437 -0
  34. package/dist/client/IframeWrapper-BgM9aU8f.js +28 -0
  35. package/dist/client/MobileLayout-BAo8Wr8T.js +1210 -0
  36. package/dist/client/PopUp-Bm01q7Ko.js +389 -0
  37. package/dist/client/VImg-B8AbetCE.js +384 -0
  38. package/dist/client/VMain-DnGlQUyr.js +43 -0
  39. package/dist/client/VOverlay-B8Qj7LRG.js +1453 -0
  40. package/dist/client/WidgetsContainer-CwXRRLS1.js +83 -0
  41. package/dist/client/asWebComponent-DUUoR7MZ.js +11621 -0
  42. package/dist/client/eo-dash.js +2 -6
  43. package/dist/client/forwardRefs-CZJhEAKW.js +245 -0
  44. package/dist/client/index-DlIO7sJ3.js +199 -0
  45. package/dist/client/ssrBoot-BP7SYRyC.js +22 -0
  46. package/dist/client/style.css +2 -2
  47. package/dist/client/transition-BiR8wMn1.js +37 -0
  48. package/dist/node/cli.js +4 -4
  49. package/dist/node/types.d.ts +2 -0
  50. package/dist/types/core/client/App.vue.d.ts +7 -0
  51. package/dist/types/core/client/asWebComponent.d.ts +9 -0
  52. package/dist/types/core/client/components/DashboardLayout.vue.d.ts +2 -0
  53. package/dist/types/core/client/components/DynamicWebComponent.vue.d.ts +18 -0
  54. package/dist/types/core/client/components/ErrorAlert.vue.d.ts +2 -0
  55. package/dist/types/core/client/components/Footer.vue.d.ts +2 -0
  56. package/dist/types/core/client/components/Header.vue.d.ts +2 -0
  57. package/dist/types/core/client/components/IframeWrapper.vue.d.ts +7 -0
  58. package/dist/types/core/client/components/Loading.vue.d.ts +2 -0
  59. package/dist/types/core/client/components/MobileLayout.vue.d.ts +2 -0
  60. package/dist/types/core/client/composables/DefineEodash.d.ts +2 -0
  61. package/dist/types/core/client/composables/DefineTemplate.d.ts +15 -0
  62. package/dist/types/core/client/composables/DefineWidgets.d.ts +14 -0
  63. package/dist/types/core/client/composables/EodashMap.d.ts +5 -0
  64. package/dist/types/core/client/composables/index.d.ts +30 -0
  65. package/dist/types/core/client/eodash.d.ts +8 -0
  66. package/dist/types/core/client/main.d.ts +2 -0
  67. package/dist/types/core/client/plugins/axios.d.ts +2 -0
  68. package/dist/types/core/client/plugins/index.d.ts +3 -0
  69. package/dist/types/core/client/plugins/vuetify.d.ts +82 -0
  70. package/dist/types/core/client/render.d.ts +1 -0
  71. package/dist/types/core/client/store/Actions.d.ts +12 -0
  72. package/dist/types/core/client/store/States.d.ts +22 -0
  73. package/dist/types/core/client/store/index.d.ts +2 -0
  74. package/dist/types/core/client/store/stac.d.ts +25 -0
  75. package/dist/types/core/client/types.d.ts +279 -0
  76. package/dist/types/core/client/utils/createLayers.d.ts +45 -0
  77. package/dist/types/core/client/utils/eodashSTAC.d.ts +82 -0
  78. package/dist/types/core/client/utils/helpers.d.ts +84 -0
  79. package/dist/types/core/client/utils/index.d.ts +2 -0
  80. package/dist/types/core/client/utils/keys.d.ts +6 -0
  81. package/dist/types/core/client/utils/states.d.ts +14 -0
  82. package/dist/types/core/client/views/Dashboard.vue.d.ts +9 -0
  83. package/dist/types/widgets/EodashDatePicker.vue.d.ts +7 -0
  84. package/dist/types/widgets/EodashItemFilter.vue.d.ts +42 -0
  85. package/dist/types/widgets/EodashLayerControl.vue.d.ts +11 -0
  86. package/dist/types/widgets/EodashLayoutSwitcher.vue.d.ts +9 -0
  87. package/dist/types/widgets/EodashMap.vue.d.ts +7 -0
  88. package/dist/types/widgets/EodashMapBtns.vue.d.ts +11 -0
  89. package/dist/types/widgets/EodashStacInfo.vue.d.ts +21 -0
  90. package/dist/types/widgets/EodashTools.vue.d.ts +15 -0
  91. package/dist/types/widgets/ExportState.vue.d.ts +7 -0
  92. package/dist/types/widgets/PopUp.vue.d.ts +22 -0
  93. package/dist/types/widgets/WidgetsContainer.vue.d.ts +7 -0
  94. package/package.json +58 -37
  95. package/widgets/EodashDatePicker.vue +128 -100
  96. package/widgets/EodashItemFilter.vue +100 -14
  97. package/widgets/EodashLayerControl.vue +98 -0
  98. package/widgets/EodashMap.vue +98 -122
  99. package/widgets/EodashMapBtns.vue +24 -7
  100. package/widgets/EodashProcess.vue +151 -0
  101. package/widgets/ExportState.vue +15 -11
  102. package/core/client/SuspensedDashboard.ce.vue +0 -105
  103. package/dist/client/DashboardLayout-D0ZF6V2S.js +0 -156
  104. package/dist/client/DynamicWebComponent-CPsMSBHi.js +0 -57
  105. package/dist/client/EodashDatePicker-CBQP7u2X.js +0 -252
  106. package/dist/client/EodashItemFilter-DL2ScI-5.js +0 -7671
  107. package/dist/client/EodashMap-CkKoQlmR.js +0 -86917
  108. package/dist/client/EodashMapBtns-yuO2QmiR.js +0 -36
  109. package/dist/client/ExportState-CCzOhppU.js +0 -558
  110. package/dist/client/Footer-BPAND0yG.js +0 -115
  111. package/dist/client/Header-DLhebNvG.js +0 -350
  112. package/dist/client/IframeWrapper-1GEMHlsW.js +0 -19
  113. package/dist/client/MobileLayout-mGkOYRhu.js +0 -945
  114. package/dist/client/PopUp-1d2bBFjw.js +0 -300
  115. package/dist/client/VImg-DxHcztfM.js +0 -291
  116. package/dist/client/VMain-BLX5vRRn.js +0 -39
  117. package/dist/client/VOverlay-CvrYEmLu.js +0 -967
  118. package/dist/client/WidgetsContainer-CmYjvGm7.js +0 -129
  119. package/dist/client/_commonjsHelpers-DaMA6jEr.js +0 -8
  120. package/dist/client/asWebComponent-B91uK0U7.js +0 -20361
  121. package/dist/client/basedecoder-DHcBySSe-BmCFNFnw.js +0 -88
  122. package/dist/client/decoder-CP4lv0Kb-B6yqkcfC.js +0 -10
  123. package/dist/client/deflate-BXt-9JA_-CWfClgpK.js +0 -10
  124. package/dist/client/eodashSTAC-DBjqe_Ho.js +0 -2788
  125. package/dist/client/eox-stacinfo-l7ALSV90.js +0 -13969
  126. package/dist/client/forwardRefs-BJJiadQP.js +0 -185
  127. package/dist/client/index-Q-bHLjxx.js +0 -153
  128. package/dist/client/jpeg-BAgeD1d3-oeHbFPUL.js +0 -514
  129. package/dist/client/lerc-DzVumYtB-P-KXC0TO.js +0 -1027
  130. package/dist/client/lzw-LAGDNbSC-DkP96qO9.js +0 -84
  131. package/dist/client/packbits-BlDR4Kj5-C66n1-zr.js +0 -24
  132. package/dist/client/pako.esm-CB1uQYY0-DB0PYm1P.js +0 -1081
  133. package/dist/client/raw-CMGvRjfu-BRi6E4i1.js +0 -9
  134. package/dist/client/ssrBoot-yo11mybw.js +0 -17
  135. package/dist/client/transition-CSJhuYGK.js +0 -34
  136. package/dist/client/webfontloader-qotgY98I.js +0 -435
  137. package/dist/client/webimage-BM_pbLN3-L2cGWK5l.js +0 -19
@@ -1,11 +1,20 @@
1
1
  // functions of this folder can only be consumed inside setup stores,
2
2
  // setup functions or vue composition api components
3
3
 
4
- import { currentUrl, indicator, mapPosition } from "@/store/States";
4
+ import {
5
+ currentCompareUrl,
6
+ currentUrl,
7
+ datetime,
8
+ indicator,
9
+ mapPosition,
10
+ } from "@/store/States";
5
11
  import eodash from "@/eodash";
6
12
  import { useTheme } from "vuetify/lib/framework.mjs";
7
- import { onMounted, watch } from "vue";
13
+ import { onMounted, onUnmounted, watch } from "vue";
8
14
  import { useSTAcStore } from "@/store/stac";
15
+ import log from "loglevel";
16
+ import { useEventBus } from "@vueuse/core";
17
+ import { eoxLayersKey } from "@/utils/keys";
9
18
 
10
19
  /**
11
20
  * Creates an absolute URL from a relative link and assignes it to `currentUrl`
@@ -36,6 +45,35 @@ export const useAbsoluteUrl = (rel = "", base = eodash.stacEndpoint) => {
36
45
  return currentUrl;
37
46
  };
38
47
 
48
+ /**
49
+ * Use the absolute compare URL from a relative link
50
+ *
51
+ * @param {string} [rel=''] Default is `''`
52
+ * @param {string} [base=eodash.stacEndpoint] - Base URL, default value is the
53
+ * root stac catalog. Default is `eodash.stacEndpoint`
54
+ * @returns {import("vue").Ref<string>} - Returns `currentUrl`
55
+ * @see {@link '@/store/States.js'}
56
+ */
57
+ export const useCompareAbsoluteUrl = (rel = "", base = eodash.stacEndpoint) => {
58
+ if (!rel || rel.includes("http")) {
59
+ currentCompareUrl.value = base;
60
+ return currentCompareUrl;
61
+ }
62
+
63
+ const st = base.split("/");
64
+ const arr = rel.split("/");
65
+ st.pop();
66
+
67
+ for (let i = 0; i < arr.length; i++) {
68
+ if (arr[i] == ".") continue;
69
+ if (arr[i] == "..") st.pop();
70
+ else st.push(arr[i]);
71
+ }
72
+
73
+ currentCompareUrl.value = st.join("/");
74
+ return currentCompareUrl;
75
+ };
76
+
39
77
  /**
40
78
  * Updates an existing Vuetify theme. updates only the values provided in the
41
79
  * `ThemeDefinition`
@@ -67,53 +105,82 @@ export const useUpdateTheme = (themeName, themeDefinition = {}) => {
67
105
  };
68
106
 
69
107
  /** Composable that syncs store and URLSearchParameters */
70
-
71
108
  export const useURLSearchParametersSync = () => {
72
109
  onMounted(async () => {
73
110
  // Analyze currently set url params when first loaded and set them in the store
74
- if ("URLSearchParams" in window) {
111
+ if (window.location.search) {
75
112
  const searchParams = new URLSearchParams(window.location.search);
113
+
76
114
  /** @type {number | undefined} */
77
115
  let x,
78
116
  /** @type {number | undefined} */
79
117
  y,
80
118
  /** @type {number | undefined} */
81
119
  z;
82
- searchParams.forEach(async (value, key) => {
83
- if (key === "indicator") {
84
- const { loadSelectedSTAC, stac } = useSTAcStore();
85
- const match = stac?.find((link) => link.id == value);
86
- if (match) {
87
- await loadSelectedSTAC(match.href);
120
+ for (const [key, value] of searchParams) {
121
+ switch (key) {
122
+ case "indicator": {
123
+ log.debug("Found indicator key in url");
124
+ const { loadSelectedSTAC, stac } = useSTAcStore();
125
+ const match = stac?.find((link) => link.id == value);
126
+ if (match) {
127
+ log.debug("Found match, loading stac item", match);
128
+ await loadSelectedSTAC(match.href);
129
+ }
130
+ break;
88
131
  }
132
+
133
+ case "x":
134
+ x = Number(value);
135
+ break;
136
+
137
+ case "y":
138
+ y = Number(value);
139
+ break;
140
+
141
+ case "z":
142
+ z = Number(value);
143
+ break;
144
+
145
+ case "datetime":
146
+ try {
147
+ const datetimeiso = new Date(value).toISOString();
148
+ log.debug("Valid datetime found", datetimeiso);
149
+ datetime.value = datetimeiso;
150
+ } catch {
151
+ datetime.value = new Date().toISOString();
152
+ }
153
+ break;
154
+
155
+ default:
156
+ break;
89
157
  }
90
- if (key === "x") {
91
- x = Number(value);
92
- }
93
- if (key === "y") {
94
- y = Number(value);
95
- }
96
- if (key === "z") {
97
- z = Number(value);
98
- }
99
- });
158
+ }
159
+
100
160
  if (x && y && z) {
161
+ log.debug("Coordinates found, applying map poisition", x, y, z);
101
162
  mapPosition.value = [x, y, z];
102
163
  }
103
164
  }
165
+
104
166
  watch(
105
- [indicator, mapPosition],
106
- ([updatedIndicator, updatedMapPosition]) => {
167
+ [indicator, mapPosition, datetime],
168
+ ([updatedIndicator, updatedMapPosition, updatedDatetime]) => {
107
169
  if ("URLSearchParams" in window) {
108
170
  const searchParams = new URLSearchParams(window.location.search);
109
171
  if (updatedIndicator !== "") {
110
172
  searchParams.set("indicator", updatedIndicator);
111
173
  }
174
+
112
175
  if (updatedMapPosition && updatedMapPosition.length === 3) {
113
176
  searchParams.set("x", updatedMapPosition[0]?.toFixed(4) ?? "");
114
177
  searchParams.set("y", updatedMapPosition[1]?.toFixed(4) ?? "");
115
178
  searchParams.set("z", updatedMapPosition[2]?.toFixed(4) ?? "");
116
179
  }
180
+
181
+ if (updatedDatetime) {
182
+ searchParams.set("datetime", updatedDatetime.split("T")?.[0] ?? "");
183
+ }
117
184
  const newRelativePathQuery =
118
185
  window.location.pathname + "?" + searchParams.toString();
119
186
  history.pushState(null, "", newRelativePathQuery);
@@ -129,8 +196,24 @@ export const makePanelTransparent = (root) => {
129
196
  const eoxItem = root.value?.parentElement;
130
197
  if (eoxItem?.tagName === "EOX-LAYOUT-ITEM") {
131
198
  eoxItem.classList.remove("bg-surface");
132
- eoxItem.style.background = "transparent";
133
- eoxItem.style.border = "transparent";
134
199
  }
135
200
  });
136
201
  };
202
+
203
+ /**
204
+ * Listens to the `layers:updated` and `time:updated` events and calls
205
+ *
206
+ * @param {import("@vueuse/core").EventBusListener<
207
+ * "layers:updated"|"time:updated",
208
+ * {layers:Record<string,any>[]| undefined}
209
+ * >} listener
210
+ */
211
+ export const useOnLayersUpdate = (listener) => {
212
+ const layersEvents = useEventBus(eoxLayersKey);
213
+
214
+ const unsubscribe = layersEvents.on(listener);
215
+
216
+ onUnmounted(() => {
217
+ unsubscribe();
218
+ });
219
+ };
@@ -1,5 +1,6 @@
1
1
  import { reactive } from "vue";
2
2
  import { currentUrl } from "./store/States";
3
+
3
4
  /**
4
5
  * Reactive Edoash Instance Object. provided globally in the app, and used as an
5
6
  * intermediate object to make user defined instances config reactive.
@@ -8,7 +9,10 @@ import { currentUrl } from "./store/States";
8
9
  */
9
10
  export const eodash = reactive({
10
11
  id: "demo",
11
- stacEndpoint: "https://gtif-cerulean.github.io/catalog/cerulean/catalog.json",
12
+ stacEndpoint:
13
+ // "https://eodashcatalog.eox.at/test-style/trilateral/catalog.json",
14
+ // "https://gtif-cerulean.github.io/catalog/cerulean/catalog.json",
15
+ "https://santilland.github.io/process_example/catalog.json",
12
16
  brand: {
13
17
  noLayout: true,
14
18
  name: "Demo",
@@ -42,6 +46,9 @@ export const eodash = reactive({
42
46
  type: "internal",
43
47
  widget: {
44
48
  name: "EodashMap",
49
+ properties: {
50
+ enableCompare: true,
51
+ },
45
52
  },
46
53
  },
47
54
  widgets: [
@@ -49,31 +56,78 @@ export const eodash = reactive({
49
56
  id: Symbol(),
50
57
  type: "internal",
51
58
  title: "Indicators",
52
- layout: { x: 0, y: 0, w: 2, h: 12 },
59
+ layout: { x: 0, y: 0, w: 3, h: 6 },
53
60
  widget: {
54
61
  name: "EodashItemFilter",
62
+ properties: {
63
+ enableCompare: true,
64
+ aggregateResults: "collection_group",
65
+ },
66
+ },
67
+ },
68
+ {
69
+ id: Symbol(),
70
+ type: "internal",
71
+ title: "Layer Control",
72
+ layout: { x: 0, y: 6, w: 3, h: 6 },
73
+ widget: {
74
+ name: "EodashLayerControl",
55
75
  },
56
76
  },
77
+ /*
78
+ {
79
+ defineWidget: (selectedCompareStac) => {
80
+ return selectedCompareStac
81
+ ? {
82
+ id: Symbol(),
83
+ title: "Layer Control Comparison",
84
+ layout: { x: 9, y: 6, w: 3, h: 6 },
85
+ type: "internal",
86
+ widget: {
87
+ name: "EodashLayerControl",
88
+ properties: {
89
+ map: "second",
90
+ },
91
+ },
92
+ }
93
+ : null;
94
+ },
95
+ },
96
+ */
57
97
  {
58
98
  defineWidget: (selectedSTAC) => {
59
99
  return selectedSTAC
60
100
  ? {
61
101
  id: "Information",
62
102
  title: "Information",
63
- layout: { x: 9, y: 0, w: 3, h: 12 },
103
+ layout: { x: 9, y: 0, w: 3, h: 6 },
64
104
  type: "web-component",
65
105
  widget: {
66
106
  link: async () => await import("@eox/stacinfo"),
67
107
  properties: {
68
108
  for: currentUrl,
69
109
  allowHtml: "true",
70
- styleOverride:
71
- "#properties li > .value {font-weight: normal !important;}",
72
- header: "[]",
110
+ styleOverride: `.single-property {columns: 1!important;}
111
+ h1 {margin:0px!important;font-size:16px!important;}
112
+ header h1:after {
113
+ content:' ';
114
+ display:block;
115
+ border:1px solid #d0d0d0;
116
+ }
117
+ h2 {font-size:15px}
118
+ h3 {font-size:14px}
119
+ summary {cursor: pointer;}
120
+ #properties li > .value { font-weight: normal !important;}
121
+ main {padding-bottom: 10px;}
122
+ .footer-container {line-height:1;}
123
+ .footer-container button {margin-top: -10px;}
124
+ .footer-container small {font-size:10px;line-height:1;}`,
125
+ header: '["title"]',
126
+ tags: '["themes"]',
73
127
  subheader: "[]",
74
- properties: '["description"]',
75
- featured: "[]",
76
- footer: "[]",
128
+ properties: '["satellite","sensor","agency","extent"]',
129
+ featured: '["description","providers","assets","links"]',
130
+ footer: '["sci:citation"]',
77
131
  },
78
132
  tagName: "eox-stacinfo",
79
133
  },
@@ -91,6 +145,10 @@ export const eodash = reactive({
91
145
  title: "Datepicker",
92
146
  widget: {
93
147
  name: "EodashDatePicker",
148
+ properties: {
149
+ hintText: `<b>Hint:</b> closest available date is displayed <br />
150
+ on map (see Analysis Layers)`,
151
+ },
94
152
  },
95
153
  }
96
154
  : null;
@@ -100,7 +158,7 @@ export const eodash = reactive({
100
158
  defineWidget: (selected) => {
101
159
  return selected
102
160
  ? {
103
- id: Symbol(),
161
+ id: "Buttons",
104
162
  layout: { x: 8, y: 0, w: 1, h: 1 },
105
163
  title: "Buttons",
106
164
  type: "internal",
@@ -111,6 +169,21 @@ export const eodash = reactive({
111
169
  : null;
112
170
  },
113
171
  },
172
+ {
173
+ defineWidget: (indicator) => {
174
+ return indicator
175
+ ? {
176
+ id: "process",
177
+ layout: { x: 9, y: 6, w: 3, h: 6 },
178
+ title: "Process",
179
+ type: "internal",
180
+ widget: {
181
+ name: "EodashProcess",
182
+ },
183
+ }
184
+ : null;
185
+ },
186
+ },
114
187
  ],
115
188
  },
116
189
  });
@@ -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;
@@ -4,13 +4,14 @@ import eodash from "@/eodash";
4
4
  import VCalendar from "v-calendar";
5
5
  import { eodashKey } from "@/utils/keys";
6
6
  import store from "../store";
7
+ import log from "loglevel";
7
8
 
8
9
  export const pinia = createPinia();
9
10
 
10
11
  /** @param {import("vue").App} app */
11
12
  export function registerPlugins(app) {
12
13
  window.eodashStore = store;
13
-
14
+ window.setEodashLoglevel = log.setLevel;
14
15
  app
15
16
  .use(vuetify)
16
17
  .use(pinia)
@@ -1,14 +1,65 @@
1
+ import { mapEl, mapCompareEl, registeredProjections } from "@/store/States";
2
+ import { getProjectionCode } from "@/utils/helpers";
3
+ import log from "loglevel";
4
+
1
5
  /**
2
- * Returns the current layers of the `eox-map`
3
- * @param {string} [el="eox-map"] - `eox-map` element selector
4
- * @returns {object[]}
6
+ * Returns the current layers of {@link mapEl}
7
+ * @returns {Record<string,any>[]}
5
8
  */
6
- export const getLayers = (el = "eox-map") =>
7
- customElements.get("eo-dash")
8
- ? document
9
- .querySelector("eo-dash")
10
- ?.shadowRoot?.querySelector(el)
11
- //@ts-expect-error `layers` doesn't exist on type element
12
- ?.layers.toReversed()
13
- : //@ts-expect-error `layers` doesn't exist on type element
14
- document.querySelector(el)?.layers.toReversed();
9
+ export const getLayers = () => mapEl.value?.layers.toReversed();
10
+
11
+ /**
12
+ * Returns the current layers of {@link mapCompareEl}
13
+ * @returns {Record<string,any>[]}
14
+ */
15
+ export const getCompareLayers = () => mapCompareEl.value?.layers.toReversed();
16
+
17
+ /**
18
+ * Register EPSG projection in `eox-map`
19
+ * @param {string|number|{name: string, def: string, extent?:number[]}} [projection]*/
20
+ export const registerProjection = async (projection) => {
21
+ let code = getProjectionCode(projection);
22
+ if (!code || registeredProjections.includes(code)) {
23
+ return;
24
+ }
25
+ log.debug("Unregistered projection found, registering it", code);
26
+ registeredProjections.push(code);
27
+ if (typeof projection === "object") {
28
+ // registering whole projection definition
29
+ await mapEl.value?.registerProjection(
30
+ code,
31
+ projection.def,
32
+ projection.extent,
33
+ );
34
+ // also registering for comparison map
35
+ await mapCompareEl.value?.registerProjection(
36
+ code,
37
+ projection.def,
38
+ projection.extent,
39
+ );
40
+ } else {
41
+ await mapEl.value?.registerProjectionFromCode(code);
42
+ // also registering for comparison map
43
+ await mapCompareEl.value?.registerProjectionFromCode(code);
44
+ }
45
+ };
46
+ /**
47
+ * Change `eox-map` projection from an `EPSG` projection
48
+ * @param {string|number|{name: string, def: string}} [projection]*/
49
+ export const changeMapProjection = async (projection) => {
50
+ let code = getProjectionCode(projection);
51
+
52
+ if (!code) {
53
+ mapEl.value?.setAttribute("projection", "EPSG:3857");
54
+ mapCompareEl.value?.setAttribute("projection", "EPSG:3857");
55
+ return;
56
+ }
57
+
58
+ if (!registeredProjections.includes(code)) {
59
+ await registerProjection(projection);
60
+ }
61
+
62
+ code = mapEl.value?.getAttribute("projection") === code ? "EPSG:3857" : code;
63
+ mapEl.value?.setAttribute("projection", code);
64
+ mapCompareEl.value?.setAttribute("projection", code);
65
+ };
@@ -1,7 +1,15 @@
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 */
4
8
  export const currentUrl = ref("");
9
+
10
+ /** Currently selected compare STAC endpoint */
11
+ export const currentCompareUrl = ref("");
12
+
5
13
  /** Currently selected datetime */
6
14
  export const datetime = ref(new Date().toISOString());
7
15
 
@@ -14,3 +22,14 @@ export const indicator = ref("");
14
22
  * @type {import("vue").Ref<(number | undefined)[]>}
15
23
  */
16
24
  export const mapPosition = ref([]);
25
+
26
+ export const registeredProjections = ["EPSG:4326", "EPSG:3857"];
27
+
28
+ /** available projection to be rendered by `EodashMap` */
29
+ export const availableMapProjection = ref("EPSG:3857");
30
+
31
+ /** @type {import("vue").Ref<HTMLElement & Record<string,any> | null>} */
32
+ export const mapEl = ref(null);
33
+
34
+ /** @type {import("vue").Ref<HTMLElement & Record<string,any> | null>} */
35
+ export const mapCompareEl = ref(null);
@@ -1,9 +1,13 @@
1
1
  import { defineStore } from "pinia";
2
2
  import { inject, ref } from "vue";
3
- import axios from "axios";
4
- import { useAbsoluteUrl } from "@/composables/index";
3
+ import axios from "@/plugins/axios";
4
+ import { useAbsoluteUrl, useCompareAbsoluteUrl } from "@/composables/index";
5
5
  import { eodashKey } from "@/utils/keys";
6
6
  import { indicator } from "@/store/States";
7
+ import { extractCollectionUrls } from "@/utils/helpers";
8
+ import { eodashCollections, eodashCompareCollections } from "@/utils/states";
9
+ import { EodashCollection } from "@/utils/eodashSTAC";
10
+ import log from "loglevel";
7
11
 
8
12
  export const useSTAcStore = defineStore("stac", () => {
9
13
  /**
@@ -25,18 +29,30 @@ export const useSTAcStore = defineStore("stac", () => {
25
29
  */
26
30
  const selectedStac = ref(null);
27
31
 
32
+ /**
33
+ * Selected STAC object.
34
+ *
35
+ * @type {import("vue").Ref<
36
+ * | import("stac-ts").StacCatalog
37
+ * | import("stac-ts").StacCollection
38
+ * | import("stac-ts").StacItem
39
+ * | null
40
+ * >}
41
+ */
42
+ const selectedCompareStac = ref(null);
43
+
28
44
  const eodash = /** @type {import("@/types").Eodash} */ (inject(eodashKey));
29
45
 
30
46
  /**
31
47
  * Fetches root stac catalog and assign it to `stac`
32
48
  *
33
- * @async
34
49
  * @param {import("@/types").StacEndpoint} [url=eodash.stacEndpoint] Default
35
50
  * is `eodash.stacEndpoint`
36
51
  * @returns {Promise<void>}
37
52
  * @see {@link stac}
38
53
  */
39
54
  async function loadSTAC(url = eodash.stacEndpoint) {
55
+ log.debug("Loading STAC endpoint", url);
40
56
  await axios
41
57
  .get(url)
42
58
  .then((resp) => {
@@ -48,6 +64,7 @@ export const useSTAcStore = defineStore("stac", () => {
48
64
  }
49
65
  return link;
50
66
  });
67
+ log.debug("Setting selected STAC", links);
51
68
  stac.value = links;
52
69
  })
53
70
  .catch((err) => {
@@ -58,7 +75,6 @@ export const useSTAcStore = defineStore("stac", () => {
58
75
  /**
59
76
  * Fetches selected stac object and assign it to `selectedStac`
60
77
  *
61
- * @async
62
78
  * @param {string} relativePath - Stac link href
63
79
  * @returns {Promise<void>}
64
80
  * @see {@link selectedStac}
@@ -68,14 +84,88 @@ export const useSTAcStore = defineStore("stac", () => {
68
84
 
69
85
  await axios
70
86
  .get(absoluteUrl.value)
71
- .then((resp) => {
72
- selectedStac.value = resp.data;
73
- indicator.value = selectedStac.value?.id ?? "";
87
+ .then(async (resp) => {
88
+ // init eodash collections
89
+ const collectionUrls = extractCollectionUrls(
90
+ resp.data,
91
+ absoluteUrl.value,
92
+ );
93
+
94
+ await Promise.all(
95
+ collectionUrls.map((cu) => {
96
+ const ec = new EodashCollection(cu);
97
+ ec.fetchCollection();
98
+ return ec;
99
+ }),
100
+ ).then((collections) => {
101
+ // empty array from old collections
102
+ eodashCollections.splice(0, eodashCollections.length);
103
+ // update eodashCollections
104
+ eodashCollections.push(...collections);
105
+
106
+ selectedStac.value = resp.data;
107
+ indicator.value = selectedStac.value?.id ?? "";
108
+ });
74
109
  })
75
110
  .catch((err) => {
76
111
  throw new Error("error loading the selected STAC", err);
77
112
  });
78
113
  }
79
114
 
80
- return { stac, loadSTAC, loadSelectedSTAC, selectedStac };
115
+ /**
116
+ * Fetches selected stac object and assign it to `selectedCompareStac`
117
+ *
118
+ * @param {string} relativePath - Stac link href
119
+ * @returns {Promise<void>}
120
+ * @see {@link selectedCompareStac}
121
+ */
122
+ async function loadSelectedCompareSTAC(relativePath = "") {
123
+ const absoluteUrl = useCompareAbsoluteUrl(relativePath);
124
+
125
+ await axios
126
+ .get(absoluteUrl.value)
127
+ .then(async (resp) => {
128
+ // init eodash collections
129
+ const collectionUrls = extractCollectionUrls(
130
+ resp.data,
131
+ absoluteUrl.value,
132
+ );
133
+
134
+ await Promise.all(
135
+ collectionUrls.map((cu) => {
136
+ const ec = new EodashCollection(cu);
137
+ ec.fetchCollection();
138
+ return ec;
139
+ }),
140
+ ).then((collections) => {
141
+ // empty array from old collections
142
+ eodashCompareCollections.splice(0, eodashCompareCollections.length);
143
+ // update eodashCompareCollections
144
+ eodashCompareCollections.push(...collections);
145
+
146
+ selectedCompareStac.value = resp.data;
147
+ });
148
+ })
149
+ .catch((err) => {
150
+ throw new Error("error loading the selected comparison STAC", err);
151
+ });
152
+ }
153
+
154
+ /**
155
+ * Reset selected compare stac object
156
+ *
157
+ */
158
+ async function resetSelectedCompareSTAC() {
159
+ selectedCompareStac.value = null;
160
+ }
161
+
162
+ return {
163
+ stac,
164
+ loadSTAC,
165
+ loadSelectedSTAC,
166
+ loadSelectedCompareSTAC,
167
+ resetSelectedCompareSTAC,
168
+ selectedStac,
169
+ selectedCompareStac,
170
+ };
81
171
  });