@eodash/eodash 5.0.0-alpha.1.14 → 5.0.0-alpha.1.15
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/App.vue +17 -2
- package/core/components/DashboardLayout.vue +3 -2
- package/core/components/Footer.vue +11 -3
- package/core/components/MobileLayout.vue +28 -45
- package/core/composables/DefineWidgets.js +1 -1
- package/core/composables/index.js +137 -98
- package/core/eodash.js +53 -61
- package/core/store/stac.js +2 -2
- package/core/types.d.ts +64 -44
- package/core/utils/eodashSTAC.js +74 -39
- package/core/utils/helpers.js +40 -0
- package/core/utils/index.js +0 -20
- package/core/vite-env.d.ts +3 -0
- package/package.json +4 -3
- package/widgets/EodashDatePicker.vue +30 -11
- package/widgets/EodashItemFilter.vue +60 -0
- package/widgets/EodashMap.vue +43 -25
package/core/eodash.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { reactive } from "vue";
|
|
2
|
-
import { currentUrl } from
|
|
2
|
+
import { currentUrl } from "./store/States";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Reactive Edoash Instance Object. provided globally in the app,
|
|
@@ -7,103 +7,95 @@ import { currentUrl } from './store/States';
|
|
|
7
7
|
* @type {import("./types").Eodash}
|
|
8
8
|
*/
|
|
9
9
|
const eodash = reactive({
|
|
10
|
-
id:
|
|
11
|
-
stacEndpoint:
|
|
10
|
+
id: "demo",
|
|
11
|
+
stacEndpoint: "https://esa-eodash.github.io/RACE-catalog/RACE/catalog.json",
|
|
12
12
|
routes: [],
|
|
13
13
|
brand: {
|
|
14
|
-
name:
|
|
14
|
+
name: "Demo",
|
|
15
15
|
font: {
|
|
16
|
-
family:
|
|
16
|
+
family: "Poppins",
|
|
17
17
|
},
|
|
18
18
|
theme: {
|
|
19
19
|
colors: {
|
|
20
|
-
primary:
|
|
21
|
-
secondary:
|
|
20
|
+
primary: "#004170",
|
|
21
|
+
secondary: "#00417044",
|
|
22
22
|
surface: "#f0f0f0f0",
|
|
23
|
-
}
|
|
23
|
+
},
|
|
24
24
|
},
|
|
25
|
-
meta: {}
|
|
25
|
+
meta: {},
|
|
26
|
+
footerText: "Demo configuration of eodash client",
|
|
26
27
|
},
|
|
27
28
|
template: {
|
|
29
|
+
loading: {
|
|
30
|
+
id: Symbol(),
|
|
31
|
+
type: "web-component",
|
|
32
|
+
widget: {
|
|
33
|
+
//https://uiball.com/ldrs/
|
|
34
|
+
link: "https://cdn.jsdelivr.net/npm/ldrs/dist/auto/mirage.js",
|
|
35
|
+
tagName: "l-mirage",
|
|
36
|
+
properties: {
|
|
37
|
+
class: "align-self-center justify-self-center",
|
|
38
|
+
size: "120",
|
|
39
|
+
speed: "2.5",
|
|
40
|
+
color: "#004170"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
28
44
|
background: {
|
|
29
45
|
id: Symbol(),
|
|
30
46
|
type: "internal",
|
|
31
47
|
widget: {
|
|
32
|
-
name:
|
|
33
|
-
}
|
|
48
|
+
name: "EodashMap",
|
|
49
|
+
},
|
|
34
50
|
},
|
|
35
51
|
widgets: [
|
|
36
52
|
{
|
|
37
53
|
id: Symbol(),
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
type: "internal",
|
|
55
|
+
title: "itemfilter",
|
|
56
|
+
layout: { x: 0, y: 0, w: 3, h: 12 },
|
|
57
|
+
slidable: false,
|
|
40
58
|
widget: {
|
|
41
|
-
|
|
59
|
+
name: "EodashItemFilter",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: Symbol(),
|
|
64
|
+
type: "internal",
|
|
65
|
+
title: "datepicker",
|
|
66
|
+
layout: { x: 5, y: 11, w: 2, h: 1 },
|
|
67
|
+
slidable: false,
|
|
68
|
+
widget: {
|
|
69
|
+
name: "EodashDatePicker",
|
|
42
70
|
properties: {
|
|
43
|
-
|
|
44
|
-
titleProperty: "title",
|
|
45
|
-
filterProperties: [
|
|
46
|
-
{
|
|
47
|
-
keys: ["title", "themes"],
|
|
48
|
-
title: "Search",
|
|
49
|
-
type: "text",
|
|
50
|
-
expanded: true,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
key: "themes",
|
|
54
|
-
title: "Theme",
|
|
55
|
-
type: "multiselect",
|
|
56
|
-
featured: true
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
aggregateResults: "themes",
|
|
60
|
-
enableHighlighting: true,
|
|
61
|
-
}
|
|
71
|
+
inline: true,
|
|
62
72
|
},
|
|
63
|
-
onMounted: async function (el, store, _) {
|
|
64
|
-
/**
|
|
65
|
-
* @typedef {object} Item
|
|
66
|
-
* @property {string} href
|
|
67
|
-
* */
|
|
68
|
-
|
|
69
|
-
/** @type {any} */(el).apply(store?.stac);
|
|
70
|
-
/** @type {any} */(el).config.onSelect =
|
|
71
|
-
/**
|
|
72
|
-
* @param {Item} item
|
|
73
|
-
* */
|
|
74
|
-
async (item) => {
|
|
75
|
-
console.log(item);
|
|
76
|
-
await store.loadSelectedSTAC(item.href);
|
|
77
|
-
};
|
|
78
|
-
},
|
|
79
|
-
tagName: 'eox-itemfilter'
|
|
80
73
|
},
|
|
81
|
-
type: 'web-component'
|
|
82
74
|
},
|
|
83
75
|
{
|
|
84
76
|
id: Symbol(),
|
|
85
|
-
title:
|
|
86
|
-
layout: {
|
|
77
|
+
title: "Information",
|
|
78
|
+
layout: { x: 9, y: 0, w: 3, h: 12 },
|
|
87
79
|
widget: {
|
|
88
|
-
link: async () => await import(
|
|
80
|
+
link: async () => await import("@eox/stacinfo"),
|
|
89
81
|
properties: {
|
|
90
82
|
for: currentUrl,
|
|
91
83
|
allowHtml: "true",
|
|
92
|
-
styleOverride:
|
|
84
|
+
styleOverride:
|
|
85
|
+
"#properties li > .value {font-weight: normal !important;}",
|
|
93
86
|
header: "[]",
|
|
94
87
|
|
|
95
88
|
subheader: "[]",
|
|
96
89
|
properties: '["description"]',
|
|
97
90
|
featured: "[]",
|
|
98
|
-
footer: "[]"
|
|
91
|
+
footer: "[]",
|
|
99
92
|
},
|
|
100
|
-
tagName:
|
|
93
|
+
tagName: "eox-stacinfo",
|
|
101
94
|
},
|
|
102
|
-
type:
|
|
95
|
+
type: "web-component",
|
|
103
96
|
},
|
|
104
|
-
]
|
|
105
|
-
}
|
|
97
|
+
],
|
|
98
|
+
},
|
|
106
99
|
});
|
|
107
100
|
|
|
108
|
-
|
|
109
101
|
export default eodash;
|
package/core/store/stac.js
CHANGED
|
@@ -3,7 +3,7 @@ import { inject, ref } from 'vue';
|
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { useAbsoluteUrl } from '@/composables/index';
|
|
5
5
|
import { eodashKey } from '@/store/Keys';
|
|
6
|
-
import {
|
|
6
|
+
import { indicator } from '@/store/States';
|
|
7
7
|
|
|
8
8
|
export const useSTAcStore = defineStore('stac', () => {
|
|
9
9
|
/**
|
|
@@ -55,7 +55,7 @@ export const useSTAcStore = defineStore('stac', () => {
|
|
|
55
55
|
|
|
56
56
|
await axios.get(absoluteUrl.value).then(resp => {
|
|
57
57
|
selectedStac.value = resp.data;
|
|
58
|
-
|
|
58
|
+
indicator.value = selectedStac.value?.id ?? "";
|
|
59
59
|
}).catch(err => console.error(err));
|
|
60
60
|
}
|
|
61
61
|
|
package/core/types.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { useSTAcStore } from "./store/stac"
|
|
2
|
-
import type { Router } from "vue-router";
|
|
3
|
-
import type { StacCatalog, StacCollection, StacItem } from "stac-ts";
|
|
4
|
-
import type { Ref } from "vue"
|
|
5
|
-
import type { ThemeDefinition } from "vuetify/lib/index.mjs";
|
|
6
|
-
import type { Map } from "openlayers";
|
|
7
|
-
|
|
8
1
|
/**
|
|
9
2
|
* @group Eodash
|
|
10
3
|
*/
|
|
11
4
|
export interface WebComponentProps<T extends ExecutionTime = "compiletime"> {
|
|
12
5
|
/**
|
|
13
|
-
* Imports web component file, either using a URL or an import
|
|
6
|
+
* Imports web component file, either using a URL or an import function.
|
|
14
7
|
* @example
|
|
15
8
|
* importing `eox-itemfilter` web component, after installing `@eox/itemfilter` it can be
|
|
16
9
|
* referenced:
|
|
@@ -36,19 +29,19 @@ export interface WebComponentProps<T extends ExecutionTime = "compiletime"> {
|
|
|
36
29
|
* @param el - web component
|
|
37
30
|
* @param store - return value of the core STAC pinia store in `/core/store/stac.ts`
|
|
38
31
|
*/
|
|
39
|
-
onMounted?: (el: Element | null, store: ReturnType<typeof useSTAcStore>, router: Router) => (Promise<void> | void)
|
|
32
|
+
onMounted?: (el: Element | null, store: ReturnType<typeof import("./store/stac").useSTAcStore>, router: import("vue-router").Router) => (Promise<void> | void)
|
|
40
33
|
/**
|
|
41
34
|
* Triggered when the web component is unmounted from the DOM.
|
|
42
35
|
* @param el - web component
|
|
43
36
|
* @param store - return value of the core STAC pinia store in `/core/store/stac.ts`
|
|
44
37
|
*/
|
|
45
|
-
onUnmounted?: (el: Element | null, store: ReturnType<typeof useSTAcStore>, router: Router) => (Promise<void> | void)
|
|
38
|
+
onUnmounted?: (el: Element | null, store: ReturnType<typeof import("./store/stac").useSTAcStore>, router: import("vue-router").Router) => (Promise<void> | void)
|
|
46
39
|
}
|
|
47
40
|
|
|
48
41
|
|
|
49
42
|
/** @ignore */
|
|
50
43
|
export interface WidgetsContainerProps {
|
|
51
|
-
widgets: Omit<Widget, 'layout'>[]
|
|
44
|
+
widgets: Omit<Widget, 'layout' | 'slidable'>[]
|
|
52
45
|
}
|
|
53
46
|
|
|
54
47
|
// eodash types:
|
|
@@ -79,7 +72,11 @@ export interface WebComponentWidget<T extends ExecutionTime = "compiletime"> {
|
|
|
79
72
|
* Height. Integer between 1 and 12
|
|
80
73
|
*/
|
|
81
74
|
h: number
|
|
82
|
-
}
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* Enable/Disable widget sliding.
|
|
78
|
+
*/
|
|
79
|
+
slidable?: boolean
|
|
83
80
|
widget: WebComponentProps<T>
|
|
84
81
|
type: 'web-component'
|
|
85
82
|
}
|
|
@@ -113,16 +110,20 @@ export interface InternalComponentWidget {
|
|
|
113
110
|
*/
|
|
114
111
|
h: number
|
|
115
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Enable/Disable widget sliding.
|
|
115
|
+
*/
|
|
116
|
+
slidable?: boolean
|
|
116
117
|
widget: {
|
|
117
118
|
/**
|
|
118
|
-
* Internal Vue Components inside the [widgets](https://github.com/eodash/eodash/tree/main/widgets) folder
|
|
119
|
-
* using their name without the
|
|
119
|
+
* Internal Vue Components inside the [widgets](https://github.com/eodash/eodash/tree/main/widgets) folder. Referenced
|
|
120
|
+
* using their name without the .vue extention
|
|
120
121
|
*/
|
|
121
122
|
name: string;
|
|
122
123
|
/**
|
|
123
124
|
* Specified Vue component props
|
|
124
125
|
*/
|
|
125
|
-
|
|
126
|
+
properties?: Record<string, unknown>
|
|
126
127
|
}
|
|
127
128
|
type: 'internal'
|
|
128
129
|
}
|
|
@@ -158,6 +159,10 @@ export interface IFrameWidget {
|
|
|
158
159
|
*/
|
|
159
160
|
h: number
|
|
160
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Enable/Disable widget sliding.
|
|
164
|
+
*/
|
|
165
|
+
slidable?: boolean;
|
|
161
166
|
widget: {
|
|
162
167
|
/**
|
|
163
168
|
* The URL of the page to embed
|
|
@@ -172,10 +177,12 @@ export interface IFrameWidget {
|
|
|
172
177
|
export interface FunctionalWidget<T extends ExecutionTime = "compiletime"> {
|
|
173
178
|
/**
|
|
174
179
|
* Provides a functional definition of the widget,
|
|
175
|
-
* gets triggered whenever a
|
|
176
|
-
* @param selectedSTAC -
|
|
180
|
+
* gets triggered whenever a STAC object is selected.
|
|
181
|
+
* @param selectedSTAC - Currently selected STAC object
|
|
177
182
|
*/
|
|
178
|
-
defineWidget: (selectedSTAC: StacCatalog |
|
|
183
|
+
defineWidget: (selectedSTAC: import("stac-ts").StacCatalog |
|
|
184
|
+
import("stac-ts").StacCollection | import("stac-ts").StacItem
|
|
185
|
+
| null) => Omit<StaticWidget<T>, 'layout' | 'slidable'>
|
|
179
186
|
layout: {
|
|
180
187
|
/**
|
|
181
188
|
* Horizontal start position. Integer between 1 and 12
|
|
@@ -194,6 +201,10 @@ export interface FunctionalWidget<T extends ExecutionTime = "compiletime"> {
|
|
|
194
201
|
*/
|
|
195
202
|
h: number
|
|
196
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Enable/Disable widget sliding.
|
|
206
|
+
*/
|
|
207
|
+
slidable?: boolean
|
|
197
208
|
}
|
|
198
209
|
/**
|
|
199
210
|
* @group Eodash
|
|
@@ -208,7 +219,7 @@ export type Widget<T extends ExecutionTime = "compiletime"> = StaticWidget<T> |
|
|
|
208
219
|
/**
|
|
209
220
|
* @group Eodash
|
|
210
221
|
*/
|
|
211
|
-
export type BackgroundWidget<T extends ExecutionTime = "compiletime"> = Omit<WebComponentWidget<T>, 'layout' | 'title'> | Omit<InternalComponentWidget, 'layout' | 'title'> | Omit<IFrameWidget, 'layout' | 'title'> | Omit<FunctionalWidget
|
|
222
|
+
export type BackgroundWidget<T extends ExecutionTime = "compiletime"> = Omit<WebComponentWidget<T>, 'layout' | 'title' | 'slidable'> | Omit<InternalComponentWidget, 'layout' | 'title' | 'slidable'> | Omit<IFrameWidget, 'layout' | 'title' | 'slidable'> | Omit<FunctionalWidget<T>, 'layout' | 'slidable'>
|
|
212
223
|
/**
|
|
213
224
|
* Dashboard rendered widgets specification.
|
|
214
225
|
* 3 types of widgets are supported: `"iframe"`, `"internal"`, and `"web-component"`.
|
|
@@ -220,9 +231,14 @@ export interface Template<T extends ExecutionTime = "compiletime"> {
|
|
|
220
231
|
* Gap between widgets
|
|
221
232
|
*/
|
|
222
233
|
gap?: number;
|
|
234
|
+
/**
|
|
235
|
+
* loading widget
|
|
236
|
+
*/
|
|
237
|
+
loading?: BackgroundWidget<T>
|
|
223
238
|
/**
|
|
224
239
|
* Widget rendered as the dashboard background.
|
|
225
|
-
* Has the same specifications of
|
|
240
|
+
* Has the same specifications of `Widget` without the `title` and `layout` properties
|
|
241
|
+
* @see {@link Widget}
|
|
226
242
|
*/
|
|
227
243
|
background?: BackgroundWidget<T>
|
|
228
244
|
/**
|
|
@@ -238,6 +254,7 @@ export type InternalRoute = `/${string}`
|
|
|
238
254
|
export type StacEndpoint = `${'https://' | 'http://'}${string}/catalog.json`
|
|
239
255
|
|
|
240
256
|
/**
|
|
257
|
+
* @ignore
|
|
241
258
|
* @group Eodash
|
|
242
259
|
*/
|
|
243
260
|
export type ExecutionTime = "runtime" | "compiletime";
|
|
@@ -256,7 +273,7 @@ export interface Eodash<T extends ExecutionTime = "compiletime"> {
|
|
|
256
273
|
**/
|
|
257
274
|
stacEndpoint: StacEndpoint
|
|
258
275
|
/**
|
|
259
|
-
*
|
|
276
|
+
* Renders navigation buttons on the app header.
|
|
260
277
|
**/
|
|
261
278
|
routes?: Array<{
|
|
262
279
|
title: string,
|
|
@@ -272,7 +289,7 @@ export interface Eodash<T extends ExecutionTime = "compiletime"> {
|
|
|
272
289
|
*/
|
|
273
290
|
font?: {
|
|
274
291
|
/**
|
|
275
|
-
* Link to stylesheet that defines font-face.
|
|
292
|
+
* Link to stylesheet that defines font-face. Could be either a relative or absolute URL.
|
|
276
293
|
*/
|
|
277
294
|
link?: string;
|
|
278
295
|
/**
|
|
@@ -285,19 +302,21 @@ export interface Eodash<T extends ExecutionTime = "compiletime"> {
|
|
|
285
302
|
*/
|
|
286
303
|
name: string;
|
|
287
304
|
/**
|
|
288
|
-
*
|
|
305
|
+
* Brand logo
|
|
289
306
|
*/
|
|
290
|
-
|
|
307
|
+
logo?: string;
|
|
291
308
|
/**
|
|
292
|
-
*
|
|
309
|
+
* Dashboard theme as a custom [vuetifyJs theme](https://vuetifyjs.com/en/features/theme/).
|
|
293
310
|
*/
|
|
294
|
-
|
|
311
|
+
theme?: import("vuetify/lib/index.mjs").ThemeDefinition
|
|
295
312
|
/**
|
|
296
|
-
*
|
|
313
|
+
* meta tags configuration, using unhead's [useSeoMeta](https://unhead.unjs.io/usage/composables/use-seo-meta)
|
|
297
314
|
*/
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
315
|
+
meta?: import("@unhead/vue").UseSeoMetaInput;
|
|
316
|
+
/**
|
|
317
|
+
* Text applied to the footer.
|
|
318
|
+
*/
|
|
319
|
+
footerText?: string;
|
|
301
320
|
}
|
|
302
321
|
/**
|
|
303
322
|
* Template configuration
|
|
@@ -318,31 +337,31 @@ export interface EodashStore {
|
|
|
318
337
|
/**
|
|
319
338
|
* Currently selected STAC endpoint
|
|
320
339
|
*/
|
|
321
|
-
currentUrl: Ref<string>
|
|
340
|
+
currentUrl: import("vue").Ref<string>
|
|
322
341
|
/**
|
|
323
342
|
* OpenLayers map instance
|
|
324
343
|
*/
|
|
325
|
-
mapInstance: Ref<Map | null>
|
|
344
|
+
mapInstance: import("vue").Ref<import("openlayers").Map | null>
|
|
326
345
|
/**
|
|
327
346
|
* currently selected datetime
|
|
328
347
|
*/
|
|
329
|
-
datetime: Ref<string>
|
|
348
|
+
datetime: import("vue").Ref<string>
|
|
330
349
|
/**
|
|
331
350
|
* Currently selected indicator
|
|
332
351
|
*/
|
|
333
|
-
indicator: Ref<string>
|
|
352
|
+
indicator: import("vue").Ref<string>
|
|
334
353
|
}
|
|
335
354
|
actions: {};
|
|
336
355
|
/**
|
|
337
356
|
* Pinia store definition used to navigate the root STAC catalog.
|
|
338
357
|
*/
|
|
339
358
|
stac: {
|
|
340
|
-
useSTAcStore: typeof useSTAcStore
|
|
359
|
+
useSTAcStore: typeof import("./store/stac").useSTAcStore
|
|
341
360
|
}
|
|
342
361
|
}
|
|
343
362
|
///////
|
|
344
363
|
/**
|
|
345
|
-
*
|
|
364
|
+
* Extending [Vite's](https://vitejs.dev/) config to configure eodash's server, build and setup.
|
|
346
365
|
* @group EodashConfig
|
|
347
366
|
*/
|
|
348
367
|
export interface EodashConfig {
|
|
@@ -361,31 +380,32 @@ export interface EodashConfig {
|
|
|
361
380
|
open?: boolean
|
|
362
381
|
}
|
|
363
382
|
/**
|
|
364
|
-
*
|
|
383
|
+
* Base public path
|
|
365
384
|
*/
|
|
366
385
|
base?: string;
|
|
367
386
|
/**
|
|
368
|
-
*
|
|
387
|
+
* Build target folder path
|
|
369
388
|
*/
|
|
370
389
|
outDir?: string;
|
|
371
|
-
/**
|
|
372
|
-
*
|
|
390
|
+
/**
|
|
391
|
+
* Path to statically served assets folder, can be set to `false`
|
|
392
|
+
* to disable serving assets statically
|
|
373
393
|
**/
|
|
374
394
|
publicDir?: string | false;
|
|
375
395
|
/**
|
|
376
|
-
*
|
|
396
|
+
* Cache folder
|
|
377
397
|
*/
|
|
378
398
|
cacheDir?: string
|
|
379
|
-
/**
|
|
399
|
+
/** Specifies main entry file, exporting `createEodash`*/
|
|
380
400
|
entryPoint?: string
|
|
381
401
|
/**
|
|
382
|
-
*
|
|
402
|
+
* File exporting eodash client runtime config
|
|
383
403
|
*/
|
|
384
404
|
runtime?: string
|
|
385
405
|
widgets?: string
|
|
386
406
|
}
|
|
387
407
|
/**
|
|
388
|
-
* project entry point should export this function as a default
|
|
408
|
+
* the project's entry point should export this function as a default
|
|
389
409
|
* to instantiate eodash
|
|
390
410
|
*
|
|
391
411
|
* @param configCallback
|
package/core/utils/eodashSTAC.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Collection, Item } from 'stac-js';
|
|
2
2
|
import { toAbsolute } from 'stac-js/src/http.js';
|
|
3
|
+
import { generateFeatures } from './helpers'
|
|
3
4
|
|
|
4
5
|
export class EodashCollection {
|
|
5
6
|
/** @type {string | undefined} */
|
|
@@ -20,32 +21,7 @@ export class EodashCollection {
|
|
|
20
21
|
* @async
|
|
21
22
|
*/
|
|
22
23
|
createLayersJson = async (item = null) => {
|
|
23
|
-
let stacItem;
|
|
24
|
-
if (item instanceof Date) {
|
|
25
|
-
// if collectionStac not yet initialized we do it here
|
|
26
|
-
if (!this.#collectionStac) {
|
|
27
|
-
const response = await fetch(this.#collectionUrl);
|
|
28
|
-
const stac = await response.json();
|
|
29
|
-
this.#collectionStac = new Collection(stac);
|
|
30
|
-
}
|
|
31
|
-
stacItem = this.getItems().sort((a, b) => {
|
|
32
|
-
//@ts-expect-error
|
|
33
|
-
const distanceA = Math.abs(new Date(a.datetime) - item);
|
|
34
|
-
//@ts-expect-error
|
|
35
|
-
const distanceB = Math.abs(new Date(b.datetime) - item);
|
|
36
|
-
return distanceA - distanceB;
|
|
37
|
-
})[0];
|
|
38
|
-
this.selectedItem = stacItem;
|
|
39
|
-
} else {
|
|
40
|
-
stacItem = item;
|
|
41
|
-
}
|
|
42
|
-
const response = await fetch(
|
|
43
|
-
stacItem
|
|
44
|
-
? toAbsolute(stacItem.href, this.#collectionUrl)
|
|
45
|
-
: this.#collectionUrl
|
|
46
|
-
);
|
|
47
|
-
const stac = await response.json();
|
|
48
|
-
|
|
24
|
+
let stacItem, stac;
|
|
49
25
|
// TODO get auxiliary layers from collection
|
|
50
26
|
let layersJson = [
|
|
51
27
|
{
|
|
@@ -58,21 +34,73 @@ export class EodashCollection {
|
|
|
58
34
|
},
|
|
59
35
|
},
|
|
60
36
|
];
|
|
61
|
-
|
|
62
|
-
if (!
|
|
63
|
-
|
|
37
|
+
// Load collectionstac if not yet initialized
|
|
38
|
+
if (!this.#collectionStac) {
|
|
39
|
+
//@ts-expect-error
|
|
40
|
+
const response = await fetch(this.#collectionUrl);
|
|
41
|
+
stac = await response.json();
|
|
64
42
|
this.#collectionStac = new Collection(stac);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if(stac && stac.endpointtype === "GeoDB") {
|
|
46
|
+
// Special handling of point based data
|
|
47
|
+
const allFeatures = generateFeatures(stac.links);
|
|
48
|
+
layersJson.unshift({
|
|
49
|
+
type: "Vector",
|
|
50
|
+
properties: {
|
|
51
|
+
id: stac.id,
|
|
52
|
+
},
|
|
53
|
+
source: {
|
|
54
|
+
type: "Vector",
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
url: "data:," + encodeURIComponent(JSON.stringify(allFeatures)),
|
|
57
|
+
format: "GeoJSON",
|
|
58
|
+
},
|
|
59
|
+
style: {
|
|
60
|
+
"circle-radius": 5,
|
|
61
|
+
"circle-fill-color": "#00417077",
|
|
62
|
+
"circle-stroke-color": "#004170",
|
|
63
|
+
"fill-color": "#00417077",
|
|
64
|
+
"stroke-color": "#004170",
|
|
65
|
+
}
|
|
66
|
+
});
|
|
68
67
|
return layersJson;
|
|
69
68
|
} else {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
if (item instanceof Date) {
|
|
70
|
+
// if collectionStac not yet initialized we do it here
|
|
71
|
+
stacItem = this.getItems().sort((a, b) => {
|
|
72
|
+
//@ts-expect-error
|
|
73
|
+
const distanceA = Math.abs(new Date(a.datetime) - item);
|
|
74
|
+
//@ts-expect-error
|
|
75
|
+
const distanceB = Math.abs(new Date(b.datetime) - item);
|
|
76
|
+
return distanceA - distanceB;
|
|
77
|
+
})[0];
|
|
78
|
+
this.selectedItem = stacItem;
|
|
79
|
+
} else {
|
|
80
|
+
stacItem = item;
|
|
81
|
+
}
|
|
82
|
+
const response = await fetch(
|
|
83
|
+
stacItem
|
|
84
|
+
? toAbsolute(stacItem.href, this.#collectionUrl)
|
|
85
|
+
: this.#collectionUrl
|
|
86
|
+
);
|
|
87
|
+
stac = await response.json();
|
|
88
|
+
|
|
89
|
+
if (!stacItem) {
|
|
90
|
+
// no specific item was requested; render last item
|
|
91
|
+
this.#collectionStac = new Collection(stac);
|
|
92
|
+
const items = this.getItems();
|
|
93
|
+
this.selectedItem = items[items.length - 1];
|
|
94
|
+
layersJson = await this.createLayersJson(this.selectedItem);
|
|
95
|
+
return layersJson;
|
|
96
|
+
} else {
|
|
97
|
+
// specific item was requested
|
|
98
|
+
const item = new Item(stac);
|
|
99
|
+
this.selectedItem = item;
|
|
100
|
+
//@ts-expect-error
|
|
101
|
+
layersJson.unshift(this.buildJson(item));
|
|
102
|
+
return layersJson;
|
|
103
|
+
}
|
|
76
104
|
}
|
|
77
105
|
}
|
|
78
106
|
|
|
@@ -82,12 +110,16 @@ export class EodashCollection {
|
|
|
82
110
|
buildJson(item) {
|
|
83
111
|
let json;
|
|
84
112
|
// TODO implement other types, such as COG
|
|
85
|
-
if (/** @type {import('stac-ts').StacLink[]} */(item.links)
|
|
113
|
+
if (/** @type {import('stac-ts').StacLink[]} */(item.links)
|
|
114
|
+
.find((l) => l.rel === 'wms' || l.rel === 'wmts' || l.rel === 'xyz')) {
|
|
86
115
|
json = {
|
|
87
116
|
type: 'STAC',
|
|
88
117
|
displayWebMapLink: true,
|
|
89
118
|
displayFootprint: false,
|
|
90
119
|
data: item,
|
|
120
|
+
properties: {
|
|
121
|
+
id: item.id,
|
|
122
|
+
},
|
|
91
123
|
};
|
|
92
124
|
} else {
|
|
93
125
|
// fall back to rendering the feature
|
|
@@ -98,6 +130,9 @@ export class EodashCollection {
|
|
|
98
130
|
url: 'data:,' + encodeURIComponent(JSON.stringify(item.geometry)),
|
|
99
131
|
format: 'GeoJSON',
|
|
100
132
|
},
|
|
133
|
+
properties: {
|
|
134
|
+
id: item.id,
|
|
135
|
+
},
|
|
101
136
|
};
|
|
102
137
|
}
|
|
103
138
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @param {import("stac-ts").StacLink[]} links
|
|
4
|
+
*/
|
|
5
|
+
export function generateFeatures(links) {
|
|
6
|
+
/**
|
|
7
|
+
* @type {{
|
|
8
|
+
* type:string;
|
|
9
|
+
* geometry:{
|
|
10
|
+
* type: string;
|
|
11
|
+
* coordinates: [number, number],
|
|
12
|
+
* }
|
|
13
|
+
* }[]}
|
|
14
|
+
*/
|
|
15
|
+
const features = [];
|
|
16
|
+
links.forEach(element => {
|
|
17
|
+
if (element.rel === "item" && "latlng" in element) {
|
|
18
|
+
//@ts-expect-error
|
|
19
|
+
const [lat, lon] = element.latlng.split(",").map((/** @type {string} */it) => Number(it))
|
|
20
|
+
features.push({
|
|
21
|
+
type: 'Feature',
|
|
22
|
+
geometry: {
|
|
23
|
+
type: 'Point',
|
|
24
|
+
coordinates: [lon, lat],
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const geojsonObject = {
|
|
30
|
+
'type': 'FeatureCollection',
|
|
31
|
+
'crs': {
|
|
32
|
+
'type': 'name',
|
|
33
|
+
'properties': {
|
|
34
|
+
'name': 'EPSG:4326',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
features,
|
|
38
|
+
};
|
|
39
|
+
return geojsonObject;
|
|
40
|
+
}
|
package/core/utils/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { indicator } from '@/store/States';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* loads font in the app using `webfontloader`
|
|
5
3
|
* @param {string} [family="Roboto"]
|
|
@@ -28,21 +26,3 @@ export const loadFont = async (family = "Roboto", link) => {
|
|
|
28
26
|
}
|
|
29
27
|
return family;
|
|
30
28
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @param {import('stac-ts').StacCatalog | import('stac-ts').StacCollection | import('stac-ts').StacItem | null} selectedSTAC
|
|
35
|
-
* @see {@link indicator}
|
|
36
|
-
*/
|
|
37
|
-
export const assignIndicator = (selectedSTAC) => {
|
|
38
|
-
const code = /** @type {string | undefined} */ (selectedSTAC?.code);
|
|
39
|
-
const subcode = /** @type {string | string[] | undefined} */ (selectedSTAC?.subcode);
|
|
40
|
-
|
|
41
|
-
if (selectedSTAC?.code || selectedSTAC?.subcode) {
|
|
42
|
-
indicator.value = code ? code :
|
|
43
|
-
Array.isArray(subcode) ? subcode[0] : subcode ?? ""
|
|
44
|
-
} else {
|
|
45
|
-
indicator.value = ""
|
|
46
|
-
}
|
|
47
|
-
console.log(indicator.value,/** @type {string} */(selectedSTAC?.code)),/** @type {string[]} */(selectedSTAC?.subcode)
|
|
48
|
-
}
|
package/core/vite-env.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ declare module '@eox/stacinfo' {
|
|
|
14
14
|
declare module '@eox/map' {
|
|
15
15
|
export const EOxMap: CustomElementConstructor
|
|
16
16
|
}
|
|
17
|
+
declare module '@eox/itemfilter' {
|
|
18
|
+
export const EOxItemFilter: CustomElementConstructor
|
|
19
|
+
}
|
|
17
20
|
declare module 'user:config' {
|
|
18
21
|
const eodash: import("@/types").Eodash | Promise<import("@/types").Eodash>;
|
|
19
22
|
export default eodash
|