@eodash/eodash 5.0.0-rc.2.5 → 5.0.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.
- package/core/client/composables/DefineWidgets.js +8 -1
- package/core/client/eodash.js +9 -9
- package/core/client/eodashSTAC/createLayers.js +4 -18
- package/core/client/eodashSTAC/helpers.js +23 -0
- package/core/client/store/stac.js +3 -1
- package/core/client/types.ts +125 -19
- package/core/client/utils/states.js +9 -0
- package/dist/client/{DashboardLayout-BX3Sm_Vx.js → DashboardLayout-CkWvOMOW.js} +2 -2
- package/dist/client/{DynamicWebComponent-BqoHM1np.js → DynamicWebComponent-DYBbpvUK.js} +1 -1
- package/dist/client/{EodashDatePicker-BoWV2vc8.js → EodashDatePicker-CALmW3SI.js} +3 -83
- package/dist/client/{EodashItemFilter-127fZLyK.js → EodashItemFilter-DlQiE713.js} +1 -1
- package/dist/client/{EodashLayerControl-B-pZaizw.js → EodashLayerControl-DEzEbft7.js} +8 -2
- package/dist/client/{EodashLayoutSwitcher-DwexHfOD.js → EodashLayoutSwitcher-CDeCV8F-.js} +2 -2
- package/dist/client/{EodashMapBtns-Jfn3bpWD.js → EodashMapBtns-CktQCfa-.js} +36 -12
- package/dist/client/{EodashStacInfo-STq_bW7S.js → EodashStacInfo-DPPxDkF6.js} +7 -1
- package/dist/client/{EodashTools-uxSuJhVJ.js → EodashTools-CUaL9s4H.js} +5 -4
- package/dist/client/{ExportState-Ckcb6u01.js → ExportState-DjyIZVhl.js} +27 -12
- package/dist/client/{Footer-C8JP-coH.js → Footer-DyL0JoWt.js} +1 -1
- package/dist/client/{Header-Dxx7q9FW.js → Header-B5Dgty9l.js} +3 -3
- package/dist/client/{MobileLayout-BE19Peep.js → MobileLayout-CRsg_5Q4.js} +5 -5
- package/dist/client/{PopUp-D3IyjsN4.js → PopUp-BfB8s_ki.js} +3 -3
- package/dist/client/ProcessList-DTefwQZx.js +484 -0
- package/dist/client/{VImg-BmCNSu3X.js → VImg-FD1WVphJ.js} +2 -2
- package/dist/client/{VMain-eZDKIfmJ.js → VMain-DJKG4SvM.js} +1 -1
- package/dist/client/{VOverlay-BS-E4Z6g.js → VOverlay-BzOdRu9h.js} +15 -6
- package/dist/client/{VTooltip-BMsliOuh.js → VTooltip-CfeefrXI.js} +3 -3
- package/dist/client/{WidgetsContainer-Cl6M5R5c.js → WidgetsContainer-C2TaTdb6.js} +1 -1
- package/dist/client/{asWebComponent-Df8nUiLs.js → asWebComponent-CLhcT715.js} +100 -96
- package/dist/client/eo-dash.css +2 -2
- package/dist/client/eo-dash.js +1 -1
- package/dist/client/{forwardRefs-lhDuXD-N.js → forwardRefs-Bon_Kku1.js} +9 -9
- package/dist/client/index-4CT7Tz83.js +85 -0
- package/dist/client/{index-Bt5GEGxl.js → index-Bm9cbtx5.js} +1 -1
- package/dist/client/{EodashMap-BSR7_wRA.js → index-CIHH_3dW.js} +101 -80
- package/dist/client/{EodashProcess-CpbZPYBp.js → index-DiGDvTQU.js} +346 -468
- package/dist/client/{transition-DHEuQX4I.js → transition-C5I57hn6.js} +1 -1
- package/dist/types/core/client/components/MobileLayout.vue.d.ts +9 -9
- package/dist/types/core/client/eodashSTAC/helpers.d.ts +3 -2
- package/dist/types/core/client/types.d.ts +83 -17
- package/dist/types/core/client/utils/states.d.ts +7 -0
- package/dist/types/widgets/EodashDatePicker.vue.d.ts +4 -4
- package/dist/types/widgets/EodashItemFilter.vue.d.ts +18 -18
- package/dist/types/widgets/EodashLayerControl.vue.d.ts +2 -2
- package/dist/types/widgets/EodashLayoutSwitcher.vue.d.ts +2 -2
- package/dist/types/widgets/EodashMap/methods/create-layers-config.d.ts +9 -0
- package/dist/types/widgets/EodashMap/methods/index.d.ts +5 -0
- package/dist/types/widgets/EodashMapBtns.vue.d.ts +8 -2
- package/dist/types/widgets/EodashProcess/ProcessList.vue.d.ts +2 -0
- package/dist/types/widgets/EodashProcess/methods/async.d.ts +45 -0
- package/dist/types/widgets/EodashProcess/methods/composables.d.ts +19 -0
- package/dist/types/widgets/EodashProcess/methods/handling.d.ts +78 -0
- package/dist/types/widgets/EodashProcess/methods/outputs.d.ts +54 -0
- package/dist/types/widgets/EodashProcess/methods/utils.d.ts +42 -0
- package/dist/types/widgets/EodashStacInfo.vue.d.ts +12 -12
- package/dist/types/widgets/EodashTools.vue.d.ts +44 -6
- package/dist/types/widgets/PopUp.vue.d.ts +4 -4
- package/package.json +27 -27
- package/widgets/EodashLayerControl.vue +8 -1
- package/widgets/{EodashMap.vue → EodashMap/index.vue} +51 -31
- package/widgets/EodashMap/methods/create-layers-config.js +151 -0
- package/{core/client/composables/EodashMap.js → widgets/EodashMap/methods/index.js} +4 -153
- package/widgets/EodashMapBtns.vue +33 -7
- package/widgets/EodashProcess/ProcessList.vue +82 -0
- package/widgets/EodashProcess/index.vue +186 -0
- package/widgets/EodashProcess/methods/async.js +209 -0
- package/widgets/EodashProcess/methods/composables.js +129 -0
- package/widgets/EodashProcess/methods/handling.js +254 -0
- package/widgets/EodashProcess/methods/outputs.js +216 -0
- package/widgets/EodashProcess/methods/utils.js +138 -0
- package/widgets/EodashStacInfo.vue +6 -0
- package/widgets/EodashTools.vue +1 -0
- package/core/client/composables/EodashProcess.js +0 -654
- package/dist/types/core/client/composables/EodashMap.d.ts +0 -6
- package/dist/types/core/client/composables/EodashProcess.d.ts +0 -162
- package/widgets/EodashProcess.vue +0 -206
- /package/dist/types/widgets/{EodashMap.vue.d.ts → EodashMap/index.vue.d.ts} +0 -0
- /package/dist/types/widgets/{EodashProcess.vue.d.ts → EodashProcess/index.vue.d.ts} +0 -0
|
@@ -1,654 +0,0 @@
|
|
|
1
|
-
import { isMulti } from "@eox/jsonform/src/custom-inputs/spatial/utils";
|
|
2
|
-
import { nextTick, onMounted, watch } from "vue";
|
|
3
|
-
import mustache from "mustache";
|
|
4
|
-
import axios from "axios";
|
|
5
|
-
import { extractLayerConfig } from "@/eodashSTAC/helpers";
|
|
6
|
-
import log from "loglevel";
|
|
7
|
-
import { getLayers } from "@/store/actions";
|
|
8
|
-
import { mapEl } from "@/store/states";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Polls the process status and fetches a result item when the process is successful.
|
|
12
|
-
*
|
|
13
|
-
* @param {Object} params - Parameters for polling the process status.
|
|
14
|
-
* @param {string} params.processUrl - The URL of the process JSON report.
|
|
15
|
-
* @param {import("vue").Ref<boolean>} params.isPolling - checks wether the polling should continue
|
|
16
|
-
* @param {number} [params.pollInterval=5000] - The interval (in milliseconds) between polling attempts.
|
|
17
|
-
* @param {number} [params.maxRetries=60] - The maximum number of polling attempts.
|
|
18
|
-
* @returns {Promise<JSON>} The fetched results JSON.
|
|
19
|
-
* @throws {Error} If the process does not complete successfully within the maximum retries.
|
|
20
|
-
*/
|
|
21
|
-
export async function pollProcessStatus({
|
|
22
|
-
processUrl,
|
|
23
|
-
isPolling,
|
|
24
|
-
pollInterval = 5000,
|
|
25
|
-
maxRetries = 60,
|
|
26
|
-
}) {
|
|
27
|
-
let retries = 0;
|
|
28
|
-
isPolling.value = true;
|
|
29
|
-
while (retries < maxRetries && isPolling.value) {
|
|
30
|
-
try {
|
|
31
|
-
// Fetch the process JSON report
|
|
32
|
-
const cacheBuster = new Date().getTime(); // Add a timestamp for cache busting
|
|
33
|
-
const response = await axios.get(`${processUrl}?t=${cacheBuster}`);
|
|
34
|
-
const processReport = response.data;
|
|
35
|
-
|
|
36
|
-
// Check if the status is "successful"
|
|
37
|
-
if (processReport.status === "successful") {
|
|
38
|
-
console.log("Process completed successfully. Fetching result item...");
|
|
39
|
-
|
|
40
|
-
// Extract the result item URL
|
|
41
|
-
const resultsUrl = processReport.links[1].href;
|
|
42
|
-
if (!resultsUrl) {
|
|
43
|
-
throw new Error(`Result links not found in the process report.`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Fetch the result item
|
|
47
|
-
const resultResponse = await axios.get(resultsUrl);
|
|
48
|
-
console.log("Result file fetched successfully:", resultResponse.data);
|
|
49
|
-
return resultResponse.data; // Return the json result list
|
|
50
|
-
}
|
|
51
|
-
if (processReport.status === "failed") {
|
|
52
|
-
isPolling.value = false;
|
|
53
|
-
throw new Error("Process failed.", processReport);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Log the current status if not successful
|
|
57
|
-
console.log(
|
|
58
|
-
`Status: ${processReport.status}. Retrying in ${pollInterval / 1000} seconds...`,
|
|
59
|
-
);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
if (error instanceof Error) {
|
|
62
|
-
console.error("Error while polling process status:", error.message);
|
|
63
|
-
} else {
|
|
64
|
-
console.error("Unknown error occurred:", error);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Wait for the next poll
|
|
69
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
70
|
-
retries++;
|
|
71
|
-
}
|
|
72
|
-
if (!isPolling.value) {
|
|
73
|
-
console.warn("Polling was stopped before the process was completed.");
|
|
74
|
-
return JSON.parse("{}");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
throw new Error(
|
|
78
|
-
"Max retries reached. Process did not complete successfully.",
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Auto execute the process when the jsonform has the execute option
|
|
84
|
-
*
|
|
85
|
-
* @param {import("vue").Ref<boolean>} autoExec
|
|
86
|
-
* @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} jsonformEl
|
|
87
|
-
* @param {import("vue").Ref<Record<string,any> | null>} jsonformSchema
|
|
88
|
-
* @param {() => Promise<void>} startProcess
|
|
89
|
-
**/
|
|
90
|
-
export function useAutoExec(
|
|
91
|
-
autoExec,
|
|
92
|
-
jsonformEl,
|
|
93
|
-
jsonformSchema,
|
|
94
|
-
startProcess,
|
|
95
|
-
) {
|
|
96
|
-
/**
|
|
97
|
-
* @param {CustomEvent} _e
|
|
98
|
-
**/
|
|
99
|
-
const onJsonFormChange = async (_e) => {
|
|
100
|
-
await startProcess();
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const addEventListener = async () => {
|
|
104
|
-
await nextTick(() => {
|
|
105
|
-
//@ts-expect-error TODO
|
|
106
|
-
jsonformEl.value?.addEventListener("change", onJsonFormChange);
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
const removeEventListener = () => {
|
|
110
|
-
//@ts-expect-error TODO
|
|
111
|
-
jsonformEl.value?.removeEventListener("change", onJsonFormChange);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
watch(jsonformSchema, (updatedSchema) => {
|
|
115
|
-
autoExec.value = updatedSchema?.options?.["execute"] || false;
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
onMounted(() => {
|
|
119
|
-
watch(
|
|
120
|
-
autoExec,
|
|
121
|
-
async (exec) => {
|
|
122
|
-
if (exec) {
|
|
123
|
-
await addEventListener();
|
|
124
|
-
} else {
|
|
125
|
-
removeEventListener();
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
{ immediate: true },
|
|
129
|
-
);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* @param {Record<string,any> |null} [jsonformSchema]
|
|
135
|
-
**/
|
|
136
|
-
export function getBboxProperty(jsonformSchema) {
|
|
137
|
-
return /** @type {string} */ (
|
|
138
|
-
Object.keys(jsonformSchema?.properties ?? {}).find(
|
|
139
|
-
(key) => jsonformSchema?.properties[key].format === "bounding-box",
|
|
140
|
-
)
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Extracts the keys of type "geojson" from the jsonform schema
|
|
146
|
-
* @param {Record<string,any> |null} [jsonformSchema]
|
|
147
|
-
**/
|
|
148
|
-
export function getGeoJsonProperties(jsonformSchema) {
|
|
149
|
-
return /** @type {string[]} */ (
|
|
150
|
-
Object.keys(jsonformSchema?.properties ?? {}).filter(
|
|
151
|
-
(key) => jsonformSchema?.properties[key].type === "geojson",
|
|
152
|
-
)
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Converts jsonform geojson values to stringified geometries
|
|
158
|
-
* @param {Record<string,any> |null} [jsonformSchema]
|
|
159
|
-
* @param {Record<string,any>} jsonformValue
|
|
160
|
-
**/
|
|
161
|
-
export function extractGeometries(jsonformValue, jsonformSchema) {
|
|
162
|
-
const geojsonKeys = getGeoJsonProperties(jsonformSchema);
|
|
163
|
-
|
|
164
|
-
for (const key of geojsonKeys) {
|
|
165
|
-
if (!jsonformValue[key]) {
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (isMulti(jsonformSchema?.properties[key])) {
|
|
170
|
-
// jsonformValue[key] is a feature collection
|
|
171
|
-
jsonformValue[key] =
|
|
172
|
-
/** @type {import("ol/format/GeoJSON").GeoJSONFeatureCollection} */ (
|
|
173
|
-
jsonformValue[key]
|
|
174
|
-
).features.map((feature) => JSON.stringify(feature.geometry));
|
|
175
|
-
} else {
|
|
176
|
-
// jsonformValue[key] is a single feature
|
|
177
|
-
jsonformValue[key] = JSON.stringify(jsonformValue[key].geometry);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Injects CSS to remove the borders of the jsonform from inside the shadowRoot
|
|
184
|
-
* @param {import("@eox/jsonform").EOxJSONForm | null} jsonFormEl
|
|
185
|
-
**/
|
|
186
|
-
export function injectJsonformCSS(jsonFormEl) {
|
|
187
|
-
if (!jsonFormEl?.shadowRoot) {
|
|
188
|
-
console.error("jsonform has no shadowRoot");
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
const stylesheet = new CSSStyleSheet();
|
|
192
|
-
stylesheet.replaceSync(`.je-indented-panel {
|
|
193
|
-
border: none !important;
|
|
194
|
-
}`);
|
|
195
|
-
jsonFormEl.shadowRoot.adoptedStyleSheets = [stylesheet];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* @param {import("stac-ts").StacLink[] | undefined} links
|
|
200
|
-
* @param {Record<string,any>|undefined} jsonformValue
|
|
201
|
-
* @param {number[]} origBbox
|
|
202
|
-
*/
|
|
203
|
-
export function processImage(links, jsonformValue, origBbox) {
|
|
204
|
-
if (!links) return;
|
|
205
|
-
const imageLinks = links.filter(
|
|
206
|
-
(link) => link.rel === "service" && link.type === "image/png",
|
|
207
|
-
);
|
|
208
|
-
const layers = [];
|
|
209
|
-
for (const link of imageLinks) {
|
|
210
|
-
layers.push({
|
|
211
|
-
type: "Image",
|
|
212
|
-
properties: {
|
|
213
|
-
id: link.id,
|
|
214
|
-
title: "Results " + link.id,
|
|
215
|
-
},
|
|
216
|
-
source: {
|
|
217
|
-
type: "ImageStatic",
|
|
218
|
-
imageExtent: origBbox,
|
|
219
|
-
url: mustache.render(link.href, {
|
|
220
|
-
...(jsonformValue ?? {}),
|
|
221
|
-
}),
|
|
222
|
-
},
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
return layers;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* @param {import("stac-ts").StacLink[] | undefined} links
|
|
230
|
-
* @param {Record<string,any> | undefined} jsonformValue
|
|
231
|
-
* @param {string} layerId
|
|
232
|
-
*/
|
|
233
|
-
export async function processVector(links, jsonformValue, layerId) {
|
|
234
|
-
if (!links) return;
|
|
235
|
-
/** @type {Record<string,any>[]} */
|
|
236
|
-
const layers = [];
|
|
237
|
-
const vectorLinks = links.filter(
|
|
238
|
-
(link) => link.rel === "service" && link.type === "application/geo+json",
|
|
239
|
-
);
|
|
240
|
-
if (vectorLinks.length === 0) return layers;
|
|
241
|
-
|
|
242
|
-
let flatStyleJSON = null;
|
|
243
|
-
|
|
244
|
-
for (const link of vectorLinks) {
|
|
245
|
-
if ("eox:flatstyle" in (link ?? {})) {
|
|
246
|
-
flatStyleJSON = await axios
|
|
247
|
-
.get(/** @type {string} */ (link["eox:flatstyle"]))
|
|
248
|
-
.then((resp) => resp.data);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/** @type {Record<string,any>|undefined} */
|
|
252
|
-
let layerConfig;
|
|
253
|
-
/** @type {Record<string,any>|undefined} */
|
|
254
|
-
let style;
|
|
255
|
-
if (flatStyleJSON) {
|
|
256
|
-
const extracted = extractLayerConfig(flatStyleJSON);
|
|
257
|
-
layerConfig = extracted.layerConfig;
|
|
258
|
-
style = extracted.style;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
layers.push({
|
|
262
|
-
type: "Vector",
|
|
263
|
-
source: {
|
|
264
|
-
type: "Vector",
|
|
265
|
-
url: mustache.render(link.href, {
|
|
266
|
-
...(jsonformValue ?? {}),
|
|
267
|
-
}),
|
|
268
|
-
format: "GeoJSON",
|
|
269
|
-
},
|
|
270
|
-
properties: {
|
|
271
|
-
id: layerId + "_vector_process",
|
|
272
|
-
title: "Results " + layerId,
|
|
273
|
-
...(layerConfig && { ...layerConfig, ...(style && { style: style }) }),
|
|
274
|
-
},
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
return layers;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* @param {import("stac-ts").StacLink[] | undefined} links
|
|
282
|
-
* @param {Record<string,any> | undefined} jsonformValue
|
|
283
|
-
* @param {import("vue").Ref<boolean>} isPolling
|
|
284
|
-
* @param {string} layerId
|
|
285
|
-
*/
|
|
286
|
-
export async function processGeoTiff(links, jsonformValue, layerId, isPolling) {
|
|
287
|
-
if (!links) return;
|
|
288
|
-
const geotiffLinks = links.filter(
|
|
289
|
-
(link) => link.rel === "service" && link.type === "image/tiff",
|
|
290
|
-
);
|
|
291
|
-
let urls = [];
|
|
292
|
-
let flatStyleJSON = null;
|
|
293
|
-
for (const link of geotiffLinks ?? []) {
|
|
294
|
-
if (link.endpoint === "eoxhub_workspaces") {
|
|
295
|
-
// TODO: prove of concept, needs to be reworked for sure
|
|
296
|
-
// Special handling for eoxhub workspace process endpoints
|
|
297
|
-
const postBody = await axios
|
|
298
|
-
.get(/** @type {string} */ (link["body"]), { responseType: "text" })
|
|
299
|
-
.then((resp) => resp.data);
|
|
300
|
-
const jsonData = JSON.parse(
|
|
301
|
-
mustache.render(postBody, { ...(jsonformValue ?? {}) }),
|
|
302
|
-
);
|
|
303
|
-
try {
|
|
304
|
-
const responseProcess = await axios.post(link.href, jsonData, {
|
|
305
|
-
headers: {
|
|
306
|
-
"Content-Type": "application/json",
|
|
307
|
-
},
|
|
308
|
-
});
|
|
309
|
-
console.log(responseProcess.headers.location);
|
|
310
|
-
await pollProcessStatus({
|
|
311
|
-
processUrl: responseProcess.headers.location,
|
|
312
|
-
isPolling,
|
|
313
|
-
})
|
|
314
|
-
.then((resultItem) => {
|
|
315
|
-
// @ts-expect-error we have currently no definition of what is allowed as response
|
|
316
|
-
const resultUrls = resultItem?.urls;
|
|
317
|
-
if (!resultUrls?.length) {
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
urls.push(resultUrls[0]);
|
|
322
|
-
})
|
|
323
|
-
.catch((error) => {
|
|
324
|
-
if (error instanceof Error) {
|
|
325
|
-
console.error("Polling failed:", error.message);
|
|
326
|
-
} else {
|
|
327
|
-
console.error("Unknown error occurred during polling:", error);
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
} catch (error) {
|
|
331
|
-
if (error instanceof Error) {
|
|
332
|
-
console.error("Error sending POST request:", error.message);
|
|
333
|
-
} else {
|
|
334
|
-
console.error("Unknown error occurred:", error);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
} else {
|
|
338
|
-
urls.push(mustache.render(link.href, { ...(jsonformValue ?? {}) }));
|
|
339
|
-
}
|
|
340
|
-
if ("eox:flatstyle" in (link ?? {})) {
|
|
341
|
-
flatStyleJSON = await axios
|
|
342
|
-
.get(/** @type {string} */ (link["eox:flatstyle"]))
|
|
343
|
-
.then((resp) => resp.data);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
/** @type {Record<string,any>|undefined} */
|
|
347
|
-
let layerConfig;
|
|
348
|
-
/** @type {Record<string,any>|undefined} */
|
|
349
|
-
let style;
|
|
350
|
-
if (flatStyleJSON) {
|
|
351
|
-
const extracted = extractLayerConfig(layerId ?? "", flatStyleJSON);
|
|
352
|
-
layerConfig = extracted.layerConfig;
|
|
353
|
-
style = extracted.style;
|
|
354
|
-
}
|
|
355
|
-
return urls.length
|
|
356
|
-
? {
|
|
357
|
-
type: "WebGLTile",
|
|
358
|
-
source: {
|
|
359
|
-
type: "GeoTIFF",
|
|
360
|
-
normalize: !style,
|
|
361
|
-
sources: urls.map((url) => ({ url })),
|
|
362
|
-
},
|
|
363
|
-
properties: {
|
|
364
|
-
id: layerId + "_geotiff_process",
|
|
365
|
-
title: "Results " + layerId,
|
|
366
|
-
...(layerConfig && { layerConfig: layerConfig }),
|
|
367
|
-
},
|
|
368
|
-
...(style && { style: style }),
|
|
369
|
-
}
|
|
370
|
-
: undefined;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* @param {import("stac-ts").StacLink[] | undefined} links
|
|
375
|
-
* @param {Record<string,any> | undefined} jsonformValue
|
|
376
|
-
* @param {string} specUrl
|
|
377
|
-
* @returns {Promise<[import("@eox/chart").EOxChart["spec"] | null,Record<string,any>|null]>}
|
|
378
|
-
**/
|
|
379
|
-
export async function getChartValues(links, jsonformValue, specUrl) {
|
|
380
|
-
if (!specUrl || !links) return [null, null];
|
|
381
|
-
/** @type {import("vega").Spec} */
|
|
382
|
-
const spec = await axios.get(specUrl).then((resp) => {
|
|
383
|
-
return resp.data;
|
|
384
|
-
});
|
|
385
|
-
// //@ts-expect-error NamedData
|
|
386
|
-
// const dataName = spec?.data?.name;
|
|
387
|
-
const dataLinks = links.filter(
|
|
388
|
-
(link) => link.rel === "service", // && dataName && link.id === dataName,
|
|
389
|
-
);
|
|
390
|
-
|
|
391
|
-
/** @type {Record<string,any>} */
|
|
392
|
-
const dataValues = {};
|
|
393
|
-
for (const link of dataLinks ?? []) {
|
|
394
|
-
if (link.type && ["application/json", "text/csv"].includes(link.type)) {
|
|
395
|
-
const dataUrl = mustache.render(link.href, {
|
|
396
|
-
...(jsonformValue ?? {}),
|
|
397
|
-
...(link["eox:flatstyle"] ?? {}),
|
|
398
|
-
});
|
|
399
|
-
// Wait for data to be retrieved
|
|
400
|
-
const data = await axios.get(dataUrl).then((resp) => {
|
|
401
|
-
return resp.data;
|
|
402
|
-
});
|
|
403
|
-
// @ts-expect-error we assume data to exist in spec
|
|
404
|
-
spec.data.values = data;
|
|
405
|
-
continue;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
dataValues[/** @type {string} */ (link.id)] = await axios
|
|
409
|
-
.get(
|
|
410
|
-
mustache.render(link.href, {
|
|
411
|
-
...(jsonformValue ?? {}),
|
|
412
|
-
...(link["eox:flatstyle"] ?? {}),
|
|
413
|
-
}),
|
|
414
|
-
)
|
|
415
|
-
.then((resp) => resp.data);
|
|
416
|
-
}
|
|
417
|
-
return [spec, dataValues];
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* @param {Object} params
|
|
422
|
-
* @param {import("vue").Ref<boolean>} params.loading
|
|
423
|
-
* @param {import("vue").Ref<import("stac-ts").StacCollection | null>} params.selectedStac
|
|
424
|
-
* @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
|
|
425
|
-
* @param {import("vue").Ref<Record<string,any>|null>} params.jsonformSchema
|
|
426
|
-
* @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"] | null>} params.chartSpec
|
|
427
|
-
* @param {import("vue").Ref<Record<string, any> | null>} params.chartData
|
|
428
|
-
* @param {import("vue").Ref<boolean>} params.isPolling
|
|
429
|
-
* @param {import("vue").Ref<any[]>} params.processResults
|
|
430
|
-
*/
|
|
431
|
-
export async function handleProcesses({
|
|
432
|
-
loading,
|
|
433
|
-
selectedStac,
|
|
434
|
-
jsonformEl,
|
|
435
|
-
jsonformSchema,
|
|
436
|
-
chartSpec,
|
|
437
|
-
chartData,
|
|
438
|
-
isPolling,
|
|
439
|
-
processResults,
|
|
440
|
-
}) {
|
|
441
|
-
if (!jsonformEl.value || !jsonformSchema.value || !selectedStac.value) {
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
log.debug("Processing...");
|
|
445
|
-
loading.value = true;
|
|
446
|
-
try {
|
|
447
|
-
const serviceLinks = selectedStac.value?.links?.filter(
|
|
448
|
-
(l) => l.rel === "service",
|
|
449
|
-
);
|
|
450
|
-
const bboxProperty = getBboxProperty(jsonformSchema.value);
|
|
451
|
-
const jsonformValue = /** @type {Record<string,any>} */ (
|
|
452
|
-
jsonformEl.value?.value
|
|
453
|
-
);
|
|
454
|
-
|
|
455
|
-
extractGeometries(jsonformValue, jsonformSchema.value);
|
|
456
|
-
|
|
457
|
-
const origBbox = jsonformValue[bboxProperty];
|
|
458
|
-
|
|
459
|
-
const specUrl = /** @type {string} */ (
|
|
460
|
-
selectedStac.value?.["eodash:vegadefinition"]
|
|
461
|
-
);
|
|
462
|
-
|
|
463
|
-
[chartSpec.value, chartData.value] = await getChartValues(
|
|
464
|
-
serviceLinks,
|
|
465
|
-
{ ...(jsonformValue ?? {}) },
|
|
466
|
-
specUrl,
|
|
467
|
-
);
|
|
468
|
-
if (Object.keys(chartData.value ?? {}).length) {
|
|
469
|
-
processResults.value.push(chartData.value);
|
|
470
|
-
}
|
|
471
|
-
//@ts-expect-error we assume that the spec data is of type InlineData
|
|
472
|
-
if (chartSpec.value?.data?.values?.length) {
|
|
473
|
-
//@ts-expect-error we assume that the spec data is of type InlineData
|
|
474
|
-
processResults.value.push(chartSpec.value?.data.values);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
if (chartSpec.value && !("background" in chartSpec.value)) {
|
|
478
|
-
chartSpec.value["background"] = "transparent";
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
const geotiffLayer = await processGeoTiff(
|
|
482
|
-
serviceLinks,
|
|
483
|
-
jsonformValue,
|
|
484
|
-
selectedStac.value?.id ?? "",
|
|
485
|
-
isPolling,
|
|
486
|
-
);
|
|
487
|
-
|
|
488
|
-
if (geotiffLayer && geotiffLayer.source?.sources.length) {
|
|
489
|
-
processResults.value.push(
|
|
490
|
-
...(geotiffLayer.source?.sources?.map((source) => source.url) ?? []),
|
|
491
|
-
);
|
|
492
|
-
}
|
|
493
|
-
// 3. vector geojson
|
|
494
|
-
const vectorLayers = await processVector(
|
|
495
|
-
serviceLinks,
|
|
496
|
-
jsonformValue,
|
|
497
|
-
selectedStac.value?.id ?? "",
|
|
498
|
-
);
|
|
499
|
-
|
|
500
|
-
if (vectorLayers?.length) {
|
|
501
|
-
processResults.value.push(
|
|
502
|
-
...vectorLayers.map((layer) => layer.source?.url),
|
|
503
|
-
);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
const imageLayers = processImage(serviceLinks, jsonformValue, origBbox);
|
|
507
|
-
if (imageLayers?.length) {
|
|
508
|
-
processResults.value.push(
|
|
509
|
-
...imageLayers.map((layer) => layer.source?.url),
|
|
510
|
-
);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
log.debug(
|
|
514
|
-
"rendered layers after processing:",
|
|
515
|
-
geotiffLayer,
|
|
516
|
-
vectorLayers,
|
|
517
|
-
imageLayers,
|
|
518
|
-
);
|
|
519
|
-
|
|
520
|
-
if (geotiffLayer || vectorLayers?.length || imageLayers?.length) {
|
|
521
|
-
const layers = [
|
|
522
|
-
...(geotiffLayer ? [geotiffLayer] : []),
|
|
523
|
-
...(vectorLayers ?? []),
|
|
524
|
-
...(imageLayers ?? []),
|
|
525
|
-
];
|
|
526
|
-
let currentLayers = [...getLayers()];
|
|
527
|
-
let analysisGroup = currentLayers.find((l) =>
|
|
528
|
-
l.properties.id.includes("AnalysisGroup"),
|
|
529
|
-
);
|
|
530
|
-
analysisGroup?.layers.push(...layers);
|
|
531
|
-
|
|
532
|
-
if (mapEl.value) {
|
|
533
|
-
mapEl.value.layers = [...currentLayers];
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
loading.value = false;
|
|
537
|
-
} catch (error) {
|
|
538
|
-
console.error("[eodash] Error while running process:", error);
|
|
539
|
-
loading.value = false;
|
|
540
|
-
throw error;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Reset the process state
|
|
546
|
-
* @param {Object} params
|
|
547
|
-
* @param {import("vue").Ref<boolean>} params.loading
|
|
548
|
-
* @param {import("vue").Ref<boolean>} params.isProcessed
|
|
549
|
-
* @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"] | null>} params.chartSpec
|
|
550
|
-
* @param {import("vue").Ref<boolean>} params.isPolling
|
|
551
|
-
* @param {import("vue").Ref<any[]>} params.processResults
|
|
552
|
-
* @param {import("vue").Ref<Record<string,any>|null>} params.jsonformSchema
|
|
553
|
-
*/
|
|
554
|
-
export function resetProcess({
|
|
555
|
-
loading,
|
|
556
|
-
isProcessed,
|
|
557
|
-
chartSpec,
|
|
558
|
-
jsonformSchema,
|
|
559
|
-
processResults,
|
|
560
|
-
isPolling,
|
|
561
|
-
}) {
|
|
562
|
-
loading.value = false;
|
|
563
|
-
isProcessed.value = false;
|
|
564
|
-
isPolling.value = false;
|
|
565
|
-
chartSpec.value = null;
|
|
566
|
-
processResults.value = [];
|
|
567
|
-
jsonformSchema.value = null;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* Description placeholder
|
|
572
|
-
*
|
|
573
|
-
* @export
|
|
574
|
-
* @async
|
|
575
|
-
* @param {Object} params
|
|
576
|
-
* @param {import("vue").Ref<import("stac-ts").StacCollection>} params.selectedStac
|
|
577
|
-
* @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
|
|
578
|
-
* @param {import("vue").Ref<Record<string,any> | null>} params.jsonformSchema
|
|
579
|
-
* @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"] | null>} params.chartSpec
|
|
580
|
-
* @param {import("vue").Ref<any[]>} params.processResults
|
|
581
|
-
* @param {import("vue").Ref<boolean>} params.isProcessed
|
|
582
|
-
* @param {import("vue").Ref<boolean>} params.loading
|
|
583
|
-
* @param {import("vue").Ref<boolean>} params.isPolling
|
|
584
|
-
*/
|
|
585
|
-
export async function initProcess({
|
|
586
|
-
selectedStac,
|
|
587
|
-
jsonformEl,
|
|
588
|
-
jsonformSchema,
|
|
589
|
-
chartSpec,
|
|
590
|
-
isProcessed,
|
|
591
|
-
processResults,
|
|
592
|
-
loading,
|
|
593
|
-
isPolling,
|
|
594
|
-
}) {
|
|
595
|
-
if (!selectedStac.value) {
|
|
596
|
-
return;
|
|
597
|
-
}
|
|
598
|
-
resetProcess({
|
|
599
|
-
loading,
|
|
600
|
-
isProcessed,
|
|
601
|
-
chartSpec,
|
|
602
|
-
jsonformSchema,
|
|
603
|
-
isPolling,
|
|
604
|
-
processResults,
|
|
605
|
-
});
|
|
606
|
-
if (selectedStac.value["eodash:jsonform"]) {
|
|
607
|
-
jsonformEl.value?.editor.destroy();
|
|
608
|
-
// wait for the layers to be rendered
|
|
609
|
-
jsonformSchema.value = await axios
|
|
610
|
-
//@ts-expect-error eodash extention
|
|
611
|
-
.get(selectedStac.value["eodash:jsonform"])
|
|
612
|
-
.then((resp) => resp.data);
|
|
613
|
-
// jsonformSchema.value = {
|
|
614
|
-
// "options": {
|
|
615
|
-
// "execute": true
|
|
616
|
-
// },
|
|
617
|
-
// "type": "object",
|
|
618
|
-
// "properties": {
|
|
619
|
-
// "feature": {
|
|
620
|
-
// "type": "string",
|
|
621
|
-
// "title": "Select feature on map",
|
|
622
|
-
// "options": {
|
|
623
|
-
// drawtools:{
|
|
624
|
-
// "for": "eox-map#main",
|
|
625
|
-
// "layerId": "geodb-collection",
|
|
626
|
-
// featureStyles:{
|
|
627
|
-
// /** @type {import("ol/")} */
|
|
628
|
-
// layer: {
|
|
629
|
-
|
|
630
|
-
// },
|
|
631
|
-
// // hover:{},
|
|
632
|
-
// click:{
|
|
633
|
-
// "stroke-width": 2,
|
|
634
|
-
// "stroke-color": "red",
|
|
635
|
-
// }
|
|
636
|
-
// }
|
|
637
|
-
// },
|
|
638
|
-
// "featureProperty": "id"
|
|
639
|
-
// },
|
|
640
|
-
// "format": "feature"
|
|
641
|
-
// }
|
|
642
|
-
// }
|
|
643
|
-
// }
|
|
644
|
-
// remove borders from jsonform
|
|
645
|
-
await nextTick(() => {
|
|
646
|
-
injectJsonformCSS(jsonformEl.value);
|
|
647
|
-
});
|
|
648
|
-
} else {
|
|
649
|
-
if (!jsonformSchema.value) {
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
jsonformSchema.value = null;
|
|
653
|
-
}
|
|
654
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export function useHandleMapMoveEnd(mapElement: import("vue").Ref<(HTMLElement & Record<string, any> & {
|
|
2
|
-
map: import("ol").Map;
|
|
3
|
-
}) | null>, mapPosition: import("vue").Ref<(number | undefined)[]>): void;
|
|
4
|
-
export function useInitMap(mapElement: import("vue").Ref<import("@eox/map").EOxMap | null>, selectedIndicator: import("vue").Ref<import("stac-ts").StacCollection | null>, eodashCols: EodashCollection[], datetime: import("vue").Ref<string>, mapLayers: import("vue").Ref<Record<string, any>[]>, partnerMap: import("vue").Ref<import("@eox/map").EOxMap | null>, zoomToExtent: boolean): void;
|
|
5
|
-
export function useUpdateTooltipProperties(eodashCols: EodashCollection[], tooltipProperties: import("vue").Ref<Exclude<import("../types").EodashStyleJson["tooltip"], undefined>>): void;
|
|
6
|
-
import { EodashCollection } from "../eodashSTAC/EodashCollection";
|