@eodash/eodash 5.0.0-alpha.2.15 → 5.0.0-alpha.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/core/client/composables/EodashMap.js +296 -0
- package/core/client/composables/index.js +15 -4
- package/core/client/eodash.js +7 -2
- package/core/client/plugins/axios.js +8 -0
- package/core/client/store/Actions.js +32 -11
- package/core/client/store/States.js +8 -1
- package/core/client/store/stac.js +59 -6
- package/core/client/types.d.ts +6 -2
- package/core/client/utils/createLayers.js +187 -49
- package/core/client/utils/eodashSTAC.js +147 -31
- package/core/client/utils/helpers.js +259 -13
- package/core/client/utils/states.js +17 -0
- package/dist/client/{DashboardLayout-DQE4aB6e.js → DashboardLayout-BR1lU9ER.js} +2 -2
- package/dist/client/{DynamicWebComponent-TrDsJuF8.js → DynamicWebComponent-7z8VFsrZ.js} +1 -1
- package/dist/client/EodashDatePicker-o7ZOYIHL.js +259 -0
- package/dist/client/EodashItemFilter-lNjVkidr.js +7651 -0
- package/dist/client/EodashLayerControl-B0N8_XmX.js +24485 -0
- package/dist/client/{EodashMap--2y6XErO.js → EodashMap-DFT2R2Rk.js} +22298 -24006
- package/dist/client/{EodashMapBtns-BSf3iUAb.js → EodashMapBtns-CoGjVl8Y.js} +2 -2
- package/dist/client/{ExportState-BTONkMIz.js → ExportState-Dwv37MRw.js} +171 -158
- package/dist/client/{Footer-B7JDXdxT.js → Footer-DuScuHSx.js} +59 -57
- package/dist/client/{Header-Dlumetq0.js → Header-C4Y0u0E5.js} +70 -70
- package/dist/client/{IframeWrapper-DRjSqhFx.js → IframeWrapper-D1TfK4xH.js} +1 -1
- package/dist/client/{MobileLayout-9z2X_rmU.js → MobileLayout-C-b8DIFO.js} +43 -41
- package/dist/client/{PopUp-CXbMBYGh.js → PopUp-DBMZX3l3.js} +5 -5
- package/dist/client/{VImg-Dgk5tryv.js → VImg-bAMQHnMM.js} +33 -31
- package/dist/client/VMain-Df5VMG9r.js +38 -0
- package/dist/client/VOverlay-D5GzAYRY.js +973 -0
- package/dist/client/{WidgetsContainer-CHK_3dlD.js → WidgetsContainer-yZDmY6_u.js} +1 -1
- package/dist/client/asWebComponent-DhR2_xlP.js +24492 -0
- package/dist/client/eo-dash.js +1 -1
- package/dist/client/{forwardRefs-OX_5lLJW.js → forwardRefs-C0MQxvur.js} +1 -1
- package/dist/client/{index-B_KfD-iF.js → index-qNWeBhRh.js} +23 -23
- package/dist/client/{lerc-B4lXefGh-CplqAh1B.js → lerc-B4lXefGh-CsL-d8wY.js} +1 -1
- package/dist/client/{ssrBoot-BZTPJZkq.js → ssrBoot-Xmkz8T49.js} +1 -1
- package/dist/client/style.css +2 -2
- package/dist/client/{transition-Dq8XIV_D.js → transition-DRzZPWIN.js} +1 -1
- package/dist/client/{webfontloader-qotgY98I.js → webfontloader-CqD-lAx-.js} +1 -1
- package/dist/node/cli.js +1 -1
- package/package.json +27 -22
- package/widgets/EodashDatePicker.vue +104 -100
- package/widgets/EodashItemFilter.vue +2 -0
- package/widgets/EodashLayerControl.vue +69 -2
- package/widgets/EodashMap.vue +31 -214
- package/widgets/ExportState.vue +12 -9
- package/dist/client/EodashDatePicker-CkA9rHp6.js +0 -252
- package/dist/client/EodashItemFilter-Bp0lcvbI.js +0 -10121
- package/dist/client/EodashLayerControl-lfLYqyeU.js +0 -20963
- package/dist/client/VMain-Ubv9jyyL.js +0 -39
- package/dist/client/VOverlay-CqZC2CbA.js +0 -972
- package/dist/client/_commonjsHelpers-DaMA6jEr.js +0 -8
- package/dist/client/asWebComponent-Ddg71BJk.js +0 -20451
- package/dist/client/helpers-BCawTwFg.js +0 -1390
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A package for creating earth observation dashboards. To learn more about eodash
|
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
Checkout the [documentation](https://eodash.github.io/eodash/
|
|
7
|
+
Checkout the [documentation](https://eodash.github.io/eodash/) for a detailed guide.
|
|
8
8
|
|
|
9
9
|
## Get Started
|
|
10
10
|
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { EodashCollection } from "@/utils/eodashSTAC";
|
|
2
|
+
import { setMapProjFromCol } from "@/utils/helpers";
|
|
3
|
+
import { onMounted, onUnmounted, watch } from "vue";
|
|
4
|
+
import log from "loglevel";
|
|
5
|
+
/**
|
|
6
|
+
* Description placeholder
|
|
7
|
+
*
|
|
8
|
+
* @param {import("vue").Ref<HTMLElement & Record<string,any> & {map:import("ol").Map } | null>} mapElement
|
|
9
|
+
* @param {import("vue").Ref<(number | undefined)[]>} mapPosition
|
|
10
|
+
*/
|
|
11
|
+
export const useHandleMapMoveEnd = (mapElement, mapPosition) => {
|
|
12
|
+
/** @type {import("openlayers").EventsListenerFunctionType} */
|
|
13
|
+
const handleMoveEnd = (evt) => {
|
|
14
|
+
const map = /** @type {import("openlayers").Map | undefined} */ (
|
|
15
|
+
/** @type {any} */ (evt).map
|
|
16
|
+
);
|
|
17
|
+
const lonlat = mapElement.value?.lonLatCenter;
|
|
18
|
+
const z = map?.getView().getZoom();
|
|
19
|
+
if (
|
|
20
|
+
lonlat &&
|
|
21
|
+
!Number.isNaN(lonlat[0]) &&
|
|
22
|
+
!Number.isNaN(lonlat[1]) &&
|
|
23
|
+
!Number.isNaN(z)
|
|
24
|
+
) {
|
|
25
|
+
mapPosition.value = [lonlat[0], lonlat[1], z];
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
onMounted(() => {
|
|
30
|
+
/** @type {import('ol/Map').default} */
|
|
31
|
+
(mapElement.value?.map)?.on("moveend", handleMoveEnd);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
onUnmounted(() => {
|
|
35
|
+
/** @type {import('ol/Map').default} */
|
|
36
|
+
(mapElement.value?.map)?.un("moveend", handleMoveEnd);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Adds data layers extracted from eodash collections to Analysis Group
|
|
42
|
+
*
|
|
43
|
+
* @param { Record<string,any>[] | undefined} layersCollection
|
|
44
|
+
* @param {EodashCollection[]} eodashCols
|
|
45
|
+
* @param {string} [updatedTime]
|
|
46
|
+
*/
|
|
47
|
+
const updateLayersConfig = async (
|
|
48
|
+
layersCollection,
|
|
49
|
+
eodashCols,
|
|
50
|
+
updatedTime,
|
|
51
|
+
) => {
|
|
52
|
+
log.debug(
|
|
53
|
+
"Updating layer configuration",
|
|
54
|
+
layersCollection,
|
|
55
|
+
eodashCols,
|
|
56
|
+
updatedTime,
|
|
57
|
+
);
|
|
58
|
+
/** @type {Record<string,any>[]} */
|
|
59
|
+
const analysisLayers = [];
|
|
60
|
+
|
|
61
|
+
for (const ec of eodashCols) {
|
|
62
|
+
let layers;
|
|
63
|
+
if (updatedTime) {
|
|
64
|
+
layers = await ec.createLayersJson(new Date(updatedTime));
|
|
65
|
+
} else {
|
|
66
|
+
layers = await ec.createLayersJson();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (layers) {
|
|
70
|
+
analysisLayers.push(...layers);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Add expand to all analysis layers
|
|
74
|
+
analysisLayers.forEach((dl) => {
|
|
75
|
+
dl.properties.layerControlExpand = true;
|
|
76
|
+
dl.properties.layerControlToolsExpand = true;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const dataLayersGroup = layersCollection?.find(
|
|
80
|
+
(lyr) => lyr?.properties.id === "AnalysisGroup",
|
|
81
|
+
);
|
|
82
|
+
if (dataLayersGroup) {
|
|
83
|
+
dataLayersGroup.layers = analysisLayers;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return layersCollection;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param {import("stac-ts").StacCatalog
|
|
91
|
+
* | import("stac-ts").StacCollection
|
|
92
|
+
* | import("stac-ts").StacItem
|
|
93
|
+
* | null
|
|
94
|
+
* } selectedIndicator
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
const createLayersConfig = async (selectedIndicator) => {
|
|
98
|
+
log.debug("Creating layers config", selectedIndicator);
|
|
99
|
+
const layersCollection = [];
|
|
100
|
+
const dataLayers = {
|
|
101
|
+
type: "Group",
|
|
102
|
+
properties: {
|
|
103
|
+
id: "AnalysisGroup",
|
|
104
|
+
title: "Analysis Layers",
|
|
105
|
+
layerControlExpand: true,
|
|
106
|
+
},
|
|
107
|
+
layers: /** @type {Record<string,any>[]}*/ ([]),
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
layersCollection.push(dataLayers);
|
|
111
|
+
const indicatorLayers =
|
|
112
|
+
//@ts-expect-error indicator is collection
|
|
113
|
+
await EodashCollection.getIndicatorLayers(selectedIndicator);
|
|
114
|
+
|
|
115
|
+
const baseLayers = {
|
|
116
|
+
type: "Group",
|
|
117
|
+
properties: {
|
|
118
|
+
id: "BaseLayersGroup",
|
|
119
|
+
title: "Base Layers",
|
|
120
|
+
},
|
|
121
|
+
layers: /** @type {Record<string,any>[]}*/ ([]),
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const indicatorBaseLayers = indicatorLayers.filter(
|
|
125
|
+
(l) => l.properties.group === "baselayer",
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
if (indicatorBaseLayers.length) {
|
|
129
|
+
// Only one baselayer can be set to visible, let's first set all to
|
|
130
|
+
// false that have not a dedicated property visible, then check
|
|
131
|
+
// if there are more then one visible and only allow one
|
|
132
|
+
let counter = 0;
|
|
133
|
+
let lastPos = 0;
|
|
134
|
+
for (let indx = 0; indx < indicatorBaseLayers.length; indx++) {
|
|
135
|
+
const bl = indicatorBaseLayers[indx];
|
|
136
|
+
if (!("visible" in bl.properties)) {
|
|
137
|
+
bl.properties.visible = false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (bl.properties.visible) {
|
|
141
|
+
counter++;
|
|
142
|
+
lastPos = indx;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// if none visible set the last one as visible
|
|
147
|
+
if (counter === 0) {
|
|
148
|
+
indicatorBaseLayers[0].properties.visible = true;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// disable all apart from last
|
|
152
|
+
if (counter > 0) {
|
|
153
|
+
indicatorBaseLayers.forEach((bl, indx) => {
|
|
154
|
+
if (indx !== lastPos) {
|
|
155
|
+
bl.properties.visible = false;
|
|
156
|
+
} else {
|
|
157
|
+
bl.properties.visible = true;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
baseLayers.layers.push(...indicatorBaseLayers);
|
|
163
|
+
|
|
164
|
+
// Add exclusive to baselayers and make sure only one is selected
|
|
165
|
+
baseLayers.layers.forEach((bl) => {
|
|
166
|
+
bl.properties.layerControlExclusive = true;
|
|
167
|
+
});
|
|
168
|
+
} else {
|
|
169
|
+
// Default to some baselayer
|
|
170
|
+
baseLayers.layers.push({
|
|
171
|
+
type: "Tile",
|
|
172
|
+
properties: {
|
|
173
|
+
id: "osm",
|
|
174
|
+
title: "Background",
|
|
175
|
+
layerControlExclusive: true,
|
|
176
|
+
},
|
|
177
|
+
source: {
|
|
178
|
+
type: "OSM",
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (baseLayers.layers.length) {
|
|
184
|
+
layersCollection.push(baseLayers);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const overlayLayers = {
|
|
188
|
+
type: "Group",
|
|
189
|
+
properties: {
|
|
190
|
+
id: "OverlayGroup",
|
|
191
|
+
title: "Overlay Layers",
|
|
192
|
+
},
|
|
193
|
+
layers: /** @type {Record<string,any>[]}*/ ([]),
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const indicatorOverlays = indicatorLayers.filter(
|
|
197
|
+
(l) => l.properties.group === "overlay",
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
if (indicatorOverlays.length) {
|
|
201
|
+
overlayLayers.layers.push(...indicatorOverlays);
|
|
202
|
+
layersCollection.unshift(overlayLayers);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return layersCollection;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Description placeholder
|
|
210
|
+
*
|
|
211
|
+
* @param {import("vue").Ref<HTMLElement & Record<string,any> | null>} mapElement
|
|
212
|
+
* @param {import("vue").Ref<import("stac-ts").StacCollection | null>} selectedIndicator
|
|
213
|
+
* @param {EodashCollection[]} eodashCols
|
|
214
|
+
* @param {import("vue").Ref<string>} datetime
|
|
215
|
+
*/
|
|
216
|
+
export const useInitMap = (
|
|
217
|
+
mapElement,
|
|
218
|
+
selectedIndicator,
|
|
219
|
+
eodashCols,
|
|
220
|
+
datetime,
|
|
221
|
+
) => {
|
|
222
|
+
log.debug(
|
|
223
|
+
"InitMap",
|
|
224
|
+
mapElement.value,
|
|
225
|
+
selectedIndicator.value,
|
|
226
|
+
eodashCols.values,
|
|
227
|
+
datetime.value,
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
const stopIndicatorWatcher = watch(
|
|
231
|
+
selectedIndicator,
|
|
232
|
+
async (updatedStac) => {
|
|
233
|
+
log.debug(
|
|
234
|
+
"SelectedIndicator watch triggered",
|
|
235
|
+
selectedIndicator,
|
|
236
|
+
updatedStac,
|
|
237
|
+
);
|
|
238
|
+
if (updatedStac) {
|
|
239
|
+
const layersCollection = await createLayersConfig(updatedStac);
|
|
240
|
+
|
|
241
|
+
// updates layersCollection in place
|
|
242
|
+
await updateLayersConfig(layersCollection, eodashCols, datetime.value);
|
|
243
|
+
|
|
244
|
+
// Set projection based on indicator level information
|
|
245
|
+
setMapProjFromCol(updatedStac);
|
|
246
|
+
|
|
247
|
+
// Try to move map view to extent
|
|
248
|
+
// Sanitize extent,
|
|
249
|
+
const b = updatedStac.extent?.spatial.bbox[0];
|
|
250
|
+
const sanitizedExtent = [
|
|
251
|
+
b[0] > -180 ? b[0] : -180,
|
|
252
|
+
b[1] > -90 ? b[1] : -90,
|
|
253
|
+
b[2] < 180 ? b[2] : 180,
|
|
254
|
+
b[3] < 90 ? b[3] : 90,
|
|
255
|
+
];
|
|
256
|
+
const reprojExtent = mapElement.value?.transformExtent(
|
|
257
|
+
sanitizedExtent,
|
|
258
|
+
"EPSG:4326",
|
|
259
|
+
mapElement.value?.map?.getView().getProjection(),
|
|
260
|
+
);
|
|
261
|
+
/** @type {any} */
|
|
262
|
+
(mapElement.value).zoomExtent = reprojExtent;
|
|
263
|
+
|
|
264
|
+
// TODO: resetting layers to empty array first because smart layer update has issues
|
|
265
|
+
log.debug(
|
|
266
|
+
"WARN: Map configuration being completely, should be changed once smart update of config is reworked",
|
|
267
|
+
);
|
|
268
|
+
/** @type {any} */
|
|
269
|
+
(mapElement.value).layers = [];
|
|
270
|
+
/** @type {any} */
|
|
271
|
+
(mapElement.value).layers = layersCollection;
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
{ immediate: true },
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
const stopDatetimeWatcher = watch(
|
|
278
|
+
datetime,
|
|
279
|
+
async (updatedTime, previousTime) => {
|
|
280
|
+
if (updatedTime && updatedTime !== previousTime) {
|
|
281
|
+
const layersCollection = await updateLayersConfig(
|
|
282
|
+
[...(mapElement.value?.layers ?? [])],
|
|
283
|
+
eodashCols,
|
|
284
|
+
updatedTime,
|
|
285
|
+
);
|
|
286
|
+
/** @type {any} */
|
|
287
|
+
(mapElement.value).layers = layersCollection?.reverse();
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
onUnmounted(() => {
|
|
293
|
+
stopIndicatorWatcher();
|
|
294
|
+
stopDatetimeWatcher();
|
|
295
|
+
});
|
|
296
|
+
};
|
|
@@ -12,6 +12,7 @@ import eodash from "@/eodash";
|
|
|
12
12
|
import { useTheme } from "vuetify/lib/framework.mjs";
|
|
13
13
|
import { onMounted, watch } from "vue";
|
|
14
14
|
import { useSTAcStore } from "@/store/stac";
|
|
15
|
+
import log from "loglevel";
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Creates an absolute URL from a relative link and assignes it to `currentUrl`
|
|
@@ -102,50 +103,60 @@ export const useUpdateTheme = (themeName, themeDefinition = {}) => {
|
|
|
102
103
|
};
|
|
103
104
|
|
|
104
105
|
/** Composable that syncs store and URLSearchParameters */
|
|
105
|
-
|
|
106
106
|
export const useURLSearchParametersSync = () => {
|
|
107
107
|
onMounted(async () => {
|
|
108
108
|
// Analyze currently set url params when first loaded and set them in the store
|
|
109
109
|
if (window.location.search) {
|
|
110
110
|
const searchParams = new URLSearchParams(window.location.search);
|
|
111
|
+
|
|
111
112
|
/** @type {number | undefined} */
|
|
112
113
|
let x,
|
|
113
114
|
/** @type {number | undefined} */
|
|
114
115
|
y,
|
|
115
116
|
/** @type {number | undefined} */
|
|
116
117
|
z;
|
|
117
|
-
|
|
118
|
+
for (const [key, value] of searchParams) {
|
|
118
119
|
switch (key) {
|
|
119
120
|
case "indicator": {
|
|
121
|
+
log.debug("Found indicator key in url");
|
|
120
122
|
const { loadSelectedSTAC, stac } = useSTAcStore();
|
|
121
123
|
const match = stac?.find((link) => link.id == value);
|
|
122
124
|
if (match) {
|
|
125
|
+
log.debug("Found match, loading stac item", match);
|
|
123
126
|
await loadSelectedSTAC(match.href);
|
|
124
127
|
}
|
|
125
128
|
break;
|
|
126
129
|
}
|
|
130
|
+
|
|
127
131
|
case "x":
|
|
128
132
|
x = Number(value);
|
|
129
133
|
break;
|
|
134
|
+
|
|
130
135
|
case "y":
|
|
131
136
|
y = Number(value);
|
|
132
137
|
break;
|
|
138
|
+
|
|
133
139
|
case "z":
|
|
134
140
|
z = Number(value);
|
|
135
141
|
break;
|
|
142
|
+
|
|
136
143
|
case "datetime":
|
|
137
144
|
try {
|
|
138
|
-
|
|
145
|
+
const datetimeiso = new Date(value).toISOString();
|
|
146
|
+
log.debug("Valid datetime found", datetimeiso);
|
|
147
|
+
datetime.value = datetimeiso;
|
|
139
148
|
} catch {
|
|
140
149
|
datetime.value = new Date().toISOString();
|
|
141
150
|
}
|
|
142
151
|
break;
|
|
152
|
+
|
|
143
153
|
default:
|
|
144
154
|
break;
|
|
145
155
|
}
|
|
146
|
-
}
|
|
156
|
+
}
|
|
147
157
|
|
|
148
158
|
if (x && y && z) {
|
|
159
|
+
log.debug("Coordinates found, applying map poisition", x, y, z);
|
|
149
160
|
mapPosition.value = [x, y, z];
|
|
150
161
|
}
|
|
151
162
|
}
|
package/core/client/eodash.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { reactive } from "vue";
|
|
2
2
|
import { currentUrl } from "./store/States";
|
|
3
|
+
import log from "loglevel";
|
|
4
|
+
|
|
5
|
+
/* set log level */
|
|
6
|
+
log.setLevel("debug", true);
|
|
3
7
|
|
|
4
8
|
/**
|
|
5
9
|
* Reactive Edoash Instance Object. provided globally in the app, and used as an
|
|
@@ -9,8 +13,9 @@ import { currentUrl } from "./store/States";
|
|
|
9
13
|
*/
|
|
10
14
|
export const eodash = reactive({
|
|
11
15
|
id: "demo",
|
|
12
|
-
stacEndpoint:
|
|
13
|
-
|
|
16
|
+
stacEndpoint: "https://gtif-cerulean.github.io/catalog/cerulean/catalog.json",
|
|
17
|
+
// stacEndpoint: "https://eodashcatalog.eox.at/test-style/trilateral/catalog.json",
|
|
18
|
+
//stacEndpoint: "https://eurodatacube.github.io/eodash-catalog/RACE/catalog.json",
|
|
14
19
|
brand: {
|
|
15
20
|
noLayout: true,
|
|
16
21
|
name: "Demo",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { mapEl, registeredProjections } from "@/store/States";
|
|
1
|
+
import { mapEl, mapCompareEl, registeredProjections } from "@/store/States";
|
|
2
|
+
import { getProjectionCode } from "@/utils/helpers";
|
|
3
|
+
import log from "loglevel";
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Returns the current layers of {@link mapEl}
|
|
@@ -8,31 +10,50 @@ export const getLayers = () => mapEl.value?.layers.toReversed();
|
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Register EPSG projection in `eox-map`
|
|
11
|
-
* @param {string|number} [
|
|
12
|
-
export const registerProjection = async (
|
|
13
|
-
code =
|
|
13
|
+
* @param {string|number|{name: string, def: string, extent?:number[]}} [projection]*/
|
|
14
|
+
export const registerProjection = async (projection) => {
|
|
15
|
+
let code = getProjectionCode(projection);
|
|
14
16
|
if (!code || registeredProjections.includes(code)) {
|
|
15
17
|
return;
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
log.debug("Unregistered projection found, registering it", code);
|
|
18
20
|
registeredProjections.push(code);
|
|
19
|
-
|
|
21
|
+
if (typeof projection === "object") {
|
|
22
|
+
// registering whole projection definition
|
|
23
|
+
await mapEl.value?.registerProjection(
|
|
24
|
+
code,
|
|
25
|
+
projection.def,
|
|
26
|
+
projection.extent,
|
|
27
|
+
);
|
|
28
|
+
// also registering for comparison map
|
|
29
|
+
await mapCompareEl.value?.registerProjection(
|
|
30
|
+
code,
|
|
31
|
+
projection.def,
|
|
32
|
+
projection.extent,
|
|
33
|
+
);
|
|
34
|
+
} else {
|
|
35
|
+
await mapEl.value?.registerProjectionFromCode(code);
|
|
36
|
+
// also registering for comparison map
|
|
37
|
+
await mapCompareEl.value?.registerProjectionFromCode(code);
|
|
38
|
+
}
|
|
20
39
|
};
|
|
21
40
|
/**
|
|
22
|
-
* Change `eox-map` projection from an `EPSG`
|
|
23
|
-
* @param {string|number} [
|
|
24
|
-
export const changeMapProjection = async (
|
|
25
|
-
code =
|
|
41
|
+
* Change `eox-map` projection from an `EPSG` projection
|
|
42
|
+
* @param {string|number|{name: string, def: string}} [projection]*/
|
|
43
|
+
export const changeMapProjection = async (projection) => {
|
|
44
|
+
let code = getProjectionCode(projection);
|
|
26
45
|
|
|
27
46
|
if (!code) {
|
|
28
47
|
mapEl.value?.setAttribute("projection", "EPSG:3857");
|
|
48
|
+
mapCompareEl.value?.setAttribute("projection", "EPSG:3857");
|
|
29
49
|
return;
|
|
30
50
|
}
|
|
31
51
|
|
|
32
52
|
if (!registeredProjections.includes(code)) {
|
|
33
|
-
await registerProjection(
|
|
53
|
+
await registerProjection(projection);
|
|
34
54
|
}
|
|
35
55
|
|
|
36
56
|
code = mapEl.value?.getAttribute("projection") === code ? "EPSG:3857" : code;
|
|
37
57
|
mapEl.value?.setAttribute("projection", code);
|
|
58
|
+
mapCompareEl.value?.setAttribute("projection", code);
|
|
38
59
|
};
|
|
@@ -1,3 +1,7 @@
|
|
|
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 */
|
|
@@ -22,7 +26,10 @@ export const mapPosition = ref([]);
|
|
|
22
26
|
export const registeredProjections = ["EPSG:4326", "EPSG:3857"];
|
|
23
27
|
|
|
24
28
|
/** available projection to be rendered by `EodashMap` */
|
|
25
|
-
export const availableMapProjection = ref("");
|
|
29
|
+
export const availableMapProjection = ref("EPSG:3857");
|
|
26
30
|
|
|
27
31
|
/** @type {import("vue").Ref<HTMLElement & Record<string,any> | null>} */
|
|
28
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";
|
|
3
|
+
import axios from "@/plugins/axios";
|
|
4
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
|
/**
|
|
@@ -49,6 +53,7 @@ export const useSTAcStore = defineStore("stac", () => {
|
|
|
49
53
|
* @see {@link stac}
|
|
50
54
|
*/
|
|
51
55
|
async function loadSTAC(url = eodash.stacEndpoint) {
|
|
56
|
+
log.debug("Loading STAC endpoint", url);
|
|
52
57
|
await axios
|
|
53
58
|
.get(url)
|
|
54
59
|
.then((resp) => {
|
|
@@ -60,6 +65,7 @@ export const useSTAcStore = defineStore("stac", () => {
|
|
|
60
65
|
}
|
|
61
66
|
return link;
|
|
62
67
|
});
|
|
68
|
+
log.debug("Setting selected STAC", links);
|
|
63
69
|
stac.value = links;
|
|
64
70
|
})
|
|
65
71
|
.catch((err) => {
|
|
@@ -80,9 +86,28 @@ export const useSTAcStore = defineStore("stac", () => {
|
|
|
80
86
|
|
|
81
87
|
await axios
|
|
82
88
|
.get(absoluteUrl.value)
|
|
83
|
-
.then((resp) => {
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
.then(async (resp) => {
|
|
90
|
+
// init eodash collections
|
|
91
|
+
const collectionUrls = extractCollectionUrls(
|
|
92
|
+
resp.data,
|
|
93
|
+
absoluteUrl.value,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
await Promise.all(
|
|
97
|
+
collectionUrls.map((cu) => {
|
|
98
|
+
const ec = new EodashCollection(cu);
|
|
99
|
+
ec.fetchCollection();
|
|
100
|
+
return ec;
|
|
101
|
+
}),
|
|
102
|
+
).then((collections) => {
|
|
103
|
+
// empty array from old collections
|
|
104
|
+
eodashCollections.splice(0, eodashCollections.length);
|
|
105
|
+
// update eodashCollections
|
|
106
|
+
eodashCollections.push(...collections);
|
|
107
|
+
|
|
108
|
+
selectedStac.value = resp.data;
|
|
109
|
+
indicator.value = selectedStac.value?.id ?? "";
|
|
110
|
+
});
|
|
86
111
|
})
|
|
87
112
|
.catch((err) => {
|
|
88
113
|
throw new Error("error loading the selected STAC", err);
|
|
@@ -102,19 +127,47 @@ export const useSTAcStore = defineStore("stac", () => {
|
|
|
102
127
|
|
|
103
128
|
await axios
|
|
104
129
|
.get(absoluteUrl.value)
|
|
105
|
-
.then((resp) => {
|
|
106
|
-
|
|
130
|
+
.then(async (resp) => {
|
|
131
|
+
// init eodash collections
|
|
132
|
+
const collectionUrls = extractCollectionUrls(
|
|
133
|
+
resp.data,
|
|
134
|
+
absoluteUrl.value,
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
await Promise.all(
|
|
138
|
+
collectionUrls.map((cu) => {
|
|
139
|
+
const ec = new EodashCollection(cu);
|
|
140
|
+
ec.fetchCollection();
|
|
141
|
+
return ec;
|
|
142
|
+
}),
|
|
143
|
+
).then((collections) => {
|
|
144
|
+
// empty array from old collections
|
|
145
|
+
eodashCompareCollections.splice(0, eodashCompareCollections.length);
|
|
146
|
+
// update eodashCompareCollections
|
|
147
|
+
eodashCompareCollections.push(...collections);
|
|
148
|
+
|
|
149
|
+
selectedCompareStac.value = resp.data;
|
|
150
|
+
});
|
|
107
151
|
})
|
|
108
152
|
.catch((err) => {
|
|
109
153
|
throw new Error("error loading the selected comparison STAC", err);
|
|
110
154
|
});
|
|
111
155
|
}
|
|
112
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Reset selected compare stac object
|
|
159
|
+
*
|
|
160
|
+
*/
|
|
161
|
+
async function resetSelectedCompareSTAC() {
|
|
162
|
+
selectedCompareStac.value = null;
|
|
163
|
+
}
|
|
164
|
+
|
|
113
165
|
return {
|
|
114
166
|
stac,
|
|
115
167
|
loadSTAC,
|
|
116
168
|
loadSelectedSTAC,
|
|
117
169
|
loadSelectedCompareSTAC,
|
|
170
|
+
resetSelectedCompareSTAC,
|
|
118
171
|
selectedStac,
|
|
119
172
|
selectedCompareStac,
|
|
120
173
|
};
|
package/core/client/types.d.ts
CHANGED
|
@@ -260,10 +260,14 @@ export interface EodashStore {
|
|
|
260
260
|
/**
|
|
261
261
|
* Register EPSG projection in `eox-map` and adds it to {@link EodashStore.states.availableMapProjection `availableMapProjection`` }
|
|
262
262
|
* */
|
|
263
|
-
registerProjection: (
|
|
263
|
+
registerProjection: (
|
|
264
|
+
code?: number | string | { name: string; def: string },
|
|
265
|
+
) => Promise<void>;
|
|
264
266
|
|
|
265
267
|
/** Change `eox-map` projection from an `EPSG` code */
|
|
266
|
-
changeMapProjection: (
|
|
268
|
+
changeMapProjection: (
|
|
269
|
+
code?: number | string | { name: string; def: string },
|
|
270
|
+
) => Promise<void>;
|
|
267
271
|
};
|
|
268
272
|
|
|
269
273
|
/** Pinia store definition used to navigate the root STAC catalog. */
|