@eodash/eodash 5.3.2 → 5.4.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/DefineEodash.js +3 -1
- package/core/client/eodashSTAC/EodashCollection.js +29 -43
- package/core/client/eodashSTAC/auth.js +19 -15
- package/core/client/eodashSTAC/createLayers.js +318 -163
- package/core/client/eodashSTAC/helpers.js +64 -42
- package/core/client/eodashSTAC/parquet.js +1 -0
- package/core/client/eodashSTAC/triggers.js +7 -6
- package/core/client/store/states.js +1 -1
- package/core/client/types.ts +15 -9
- package/core/client/utils/states.js +32 -0
- package/dist/client/{DashboardLayout-BHQnHqWW.js → DashboardLayout-CQOGHPW_.js} +2 -2
- package/dist/client/{DynamicWebComponent-B4PdeZ9P.js → DynamicWebComponent-CoLO8FEf.js} +1 -1
- package/dist/client/{EodashDatePicker-Ch_AXVas.js → EodashDatePicker-BZeQ6bcu.js} +3 -3
- package/dist/client/{EodashItemFilter-lTuzCl08.js → EodashItemFilter-CmZkk7GK.js} +1 -1
- package/dist/client/{EodashLayerControl-CBSGRlIi.js → EodashLayerControl-D54fY-bX.js} +2 -2
- package/dist/client/{EodashLayoutSwitcher-DdwQYoI4.js → EodashLayoutSwitcher-BCP3FvDb.js} +3 -3
- package/dist/client/{EodashMapBtns-B910ylV6.js → EodashMapBtns-D-HulIl1.js} +14 -9
- package/dist/client/{EodashStacInfo-CeHGMZ8x.js → EodashStacInfo-BZbmT8vT.js} +1 -1
- package/dist/client/{EodashTimeSlider-BApJJK0u.js → EodashTimeSlider-DIcAJr6D.js} +2 -2
- package/dist/client/{EodashTools-CJVm0k-Q.js → EodashTools-Cz6X6hsF.js} +4 -4
- package/dist/client/{ExportState-NXzNGWYq.js → ExportState-DFVFAgKz.js} +4 -4
- package/dist/client/{Footer-DfXUC8IK.js → Footer-DLzQcjkI.js} +1 -1
- package/dist/client/{Header-BHgaNMEH.js → Header-_D9Z-zFJ.js} +2 -2
- package/dist/client/{MobileLayout-B77RzrNe.js → MobileLayout-3Ko9XSfO.js} +2 -2
- package/dist/client/{PopUp-BJwqRDNq.js → PopUp-DwI8V2gW.js} +2 -2
- package/dist/client/{ProcessList-BFvV4RvS.js → ProcessList-C9eAg2Sb.js} +20 -8
- package/dist/client/{VImg-RGGIQ_yA.js → VImg-COXTnCWE.js} +2 -2
- package/dist/client/{VMain-CniQR94B.js → VMain-C74l1bv-.js} +1 -1
- package/dist/client/{VTooltip-D5dnTfem.js → VTooltip-BLS-cQ9N.js} +2 -2
- package/dist/client/{WidgetsContainer-CvnR4J1T.js → WidgetsContainer-D-VfMRxE.js} +1 -1
- package/dist/client/{asWebComponent-Dptqds6-.js → asWebComponent-Bw03Jutr.js} +390 -220
- package/dist/client/{async-C1hb39Tc.js → async-D4G-FOIc.js} +13 -3
- package/dist/client/eo-dash.js +1 -1
- package/dist/client/{forwardRefs-CiSZZEn2.js → forwardRefs-CRMFoNYN.js} +2 -2
- package/dist/client/{handling-CZ537GCL.js → handling-DTAhQuPh.js} +94 -10
- package/dist/client/{helpers-DoQGyrvY.js → helpers-CsjKHAcK.js} +72 -50
- package/dist/client/{index-4sC2BIcK.js → index-BHilH1qx.js} +17 -13
- package/dist/client/{index-wcTqj0PZ.js → index-BIcmbjr0.js} +55 -16
- package/dist/client/{index--uKz-mt4.js → index-BoCcZ0l4.js} +3 -3
- package/dist/client/{index-DTxo2ysK.js → index-DEmHaCL3.js} +2 -2
- package/dist/client/templates.js +6 -2
- package/dist/client/{transition-CFfv5MCB.js → transition-6MJLK-_H.js} +1 -1
- package/dist/types/core/client/composables/DefineEodash.d.ts +1 -1
- package/dist/types/core/client/eodashSTAC/EodashCollection.d.ts +28 -11
- package/dist/types/core/client/eodashSTAC/auth.d.ts +5 -5
- package/dist/types/core/client/eodashSTAC/createLayers.d.ts +30 -23
- package/dist/types/core/client/eodashSTAC/helpers.d.ts +19 -4
- package/dist/types/core/client/types.d.ts +2 -1
- package/dist/types/core/client/utils/states.d.ts +28 -0
- package/dist/types/templates/index.d.ts +1 -0
- package/dist/types/widgets/EodashMap/EodashMapBtns.vue.d.ts +2 -0
- package/dist/types/widgets/EodashMap/index.vue.d.ts +2 -0
- package/dist/types/widgets/EodashProcess/methods/handling.d.ts +13 -0
- package/dist/types/widgets/EodashProcess/methods/utils.d.ts +1 -0
- package/package.json +2 -2
- package/templates/expert.js +4 -0
- package/templates/index.js +2 -0
- package/widgets/EodashMap/EodashMapBtns.vue +15 -0
- package/widgets/EodashMap/index.vue +17 -4
- package/widgets/EodashMap/methods/create-layers-config.js +23 -0
- package/widgets/EodashMap/methods/index.js +9 -7
- package/widgets/EodashProcess/ProcessList.vue +10 -2
- package/widgets/EodashProcess/index.vue +1 -9
- package/widgets/EodashProcess/methods/composables.js +13 -1
- package/widgets/EodashProcess/methods/custom-endpoints/chart/veda-endpoint.js +15 -6
- package/widgets/EodashProcess/methods/handling.js +77 -0
- package/widgets/EodashProcess/methods/utils.js +10 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { registerProjection } from "@/store/actions";
|
|
2
2
|
import { mapEl } from "@/store/states";
|
|
3
|
+
import axios from "@/plugins/axios";
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
extractRoles,
|
|
@@ -8,6 +9,7 @@ import {
|
|
|
8
9
|
createAssetID,
|
|
9
10
|
mergeGeojsons,
|
|
10
11
|
extractLayerConfig,
|
|
12
|
+
extractEoxLegendLink,
|
|
11
13
|
addTooltipInteraction,
|
|
12
14
|
fetchStyle,
|
|
13
15
|
} from "./helpers";
|
|
@@ -18,9 +20,7 @@ import log from "loglevel";
|
|
|
18
20
|
* @param {string} collectionId
|
|
19
21
|
* @param {string} title
|
|
20
22
|
* @param {Record<string,import("stac-ts").StacAsset>} assets
|
|
21
|
-
* @param {import("stac-ts").StacItem }
|
|
22
|
-
* @param {import("@/types").EodashStyleJson} [style]
|
|
23
|
-
* @param {Record<string, unknown>} [layerConfig]
|
|
23
|
+
* @param {import("stac-ts").StacItem | import("stac-ts").StacCollection } stacObject
|
|
24
24
|
* @param {Record<string, unknown>} [layerDatetime]
|
|
25
25
|
* @param {object | null} [extraProperties]
|
|
26
26
|
**/
|
|
@@ -28,80 +28,40 @@ export async function createLayersFromAssets(
|
|
|
28
28
|
collectionId,
|
|
29
29
|
title,
|
|
30
30
|
assets,
|
|
31
|
-
|
|
32
|
-
style,
|
|
33
|
-
layerConfig,
|
|
31
|
+
stacObject,
|
|
34
32
|
layerDatetime,
|
|
35
33
|
extraProperties,
|
|
36
34
|
) {
|
|
37
35
|
log.debug("Creating layers from assets");
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
let geoTIFFIdx = null;
|
|
42
|
-
|
|
43
|
-
let geoJsonIdx = 0;
|
|
44
|
-
let geoJsonAttributions = [];
|
|
36
|
+
const jsonArray = [];
|
|
37
|
+
const geoTIFFSources = [];
|
|
38
|
+
const geoTIFFIdx = [];
|
|
45
39
|
|
|
46
40
|
const geoJsonSources = [];
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const assetId = createAssetID(collectionId, item.id, idx);
|
|
65
|
-
log.debug(`Creating Vector layer from FlatGeoBuf`, assetId);
|
|
66
|
-
|
|
67
|
-
const layer = {
|
|
68
|
-
type: "Vector",
|
|
69
|
-
source: {
|
|
70
|
-
type: "FlatGeoBuf",
|
|
71
|
-
url: assets[ast].href,
|
|
72
|
-
projection,
|
|
73
|
-
attributions: assets[ast].attribution,
|
|
74
|
-
},
|
|
75
|
-
properties: {
|
|
76
|
-
id: assetId,
|
|
77
|
-
title,
|
|
78
|
-
layerDatetime,
|
|
79
|
-
...(layerConfig && {
|
|
80
|
-
layerConfig: {
|
|
81
|
-
...layerConfig,
|
|
82
|
-
style,
|
|
83
|
-
},
|
|
84
|
-
}),
|
|
85
|
-
},
|
|
86
|
-
...(!style?.variables && { style }),
|
|
87
|
-
interactions: [],
|
|
88
|
-
};
|
|
89
|
-
// add tooltip interaction if style has tooltip
|
|
90
|
-
addTooltipInteraction(layer, style);
|
|
91
|
-
|
|
92
|
-
extractRoles(layer.properties, assets[ast]);
|
|
93
|
-
|
|
94
|
-
layer.properties = { ...layer.properties, ...(extraProperties ?? {}) };
|
|
95
|
-
|
|
96
|
-
jsonArray.push(layer);
|
|
97
|
-
} else if (assets[ast]?.type === "image/tiff") {
|
|
98
|
-
geoTIFFIdx = idx;
|
|
41
|
+
const geoJsonIdx = [];
|
|
42
|
+
|
|
43
|
+
const fgbIdx = [];
|
|
44
|
+
const fgbSources = [];
|
|
45
|
+
const assetIds = [];
|
|
46
|
+
|
|
47
|
+
for (const [idx, assetId] of Object.keys(assets).entries()) {
|
|
48
|
+
assetIds.push(assetId);
|
|
49
|
+
|
|
50
|
+
if (assets[assetId]?.type === "application/geo+json") {
|
|
51
|
+
geoJsonSources.push(assets[assetId].href);
|
|
52
|
+
geoJsonIdx.push(idx);
|
|
53
|
+
} else if (assets[assetId]?.type === "application/vnd.flatgeobuf") {
|
|
54
|
+
fgbSources.push(assets[assetId].href);
|
|
55
|
+
fgbIdx.push(idx);
|
|
56
|
+
} else if (assets[assetId]?.type === "image/tiff") {
|
|
57
|
+
geoTIFFIdx.push(idx);
|
|
99
58
|
geoTIFFSources.push({
|
|
100
|
-
url: assets[
|
|
101
|
-
attributions: assets[
|
|
59
|
+
url: assets[assetId].href,
|
|
60
|
+
attributions: assets[assetId].attribution,
|
|
102
61
|
});
|
|
103
|
-
} else if (assets[
|
|
104
|
-
const responseData = await (await fetch(assets[
|
|
62
|
+
} else if (assets[assetId]?.type === "application/geodb+json") {
|
|
63
|
+
const responseData = await (await fetch(assets[assetId].href)).json();
|
|
64
|
+
geoJsonIdx.push(idx);
|
|
105
65
|
if (
|
|
106
66
|
!responseData ||
|
|
107
67
|
!Array.isArray(responseData) ||
|
|
@@ -117,29 +77,37 @@ export async function createLayersFromAssets(
|
|
|
117
77
|
const features = [];
|
|
118
78
|
responseData.forEach((ftr, i) => {
|
|
119
79
|
const { geometry, ...properties } = ftr;
|
|
120
|
-
if (
|
|
121
|
-
geometry.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
type
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
80
|
+
if (
|
|
81
|
+
geometry.type === "MultiPoint" ||
|
|
82
|
+
geometry.type === "MultiPolygon"
|
|
83
|
+
) {
|
|
84
|
+
geometry.coordinates.forEach(
|
|
85
|
+
(
|
|
86
|
+
/** @type {Record<string,any>[]} */ coordPair,
|
|
87
|
+
/** @type {number} */ j,
|
|
88
|
+
) => {
|
|
89
|
+
const singleGeometry = {
|
|
90
|
+
type: geometry.type === "MultiPoint" ? "Point" : "Polygon",
|
|
91
|
+
coordinates: coordPair,
|
|
92
|
+
};
|
|
93
|
+
features.push({
|
|
94
|
+
type: "Feature",
|
|
95
|
+
id: `${i}_${j}`,
|
|
96
|
+
properties,
|
|
97
|
+
geometry: singleGeometry,
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
);
|
|
133
101
|
} else {
|
|
134
102
|
features.push({
|
|
135
|
-
type:
|
|
103
|
+
type: "Feature",
|
|
136
104
|
properties,
|
|
137
105
|
id: `${i}`,
|
|
138
106
|
geometry: geometry,
|
|
139
107
|
});
|
|
140
108
|
}
|
|
141
109
|
});
|
|
142
|
-
|
|
110
|
+
|
|
143
111
|
const geojson = {
|
|
144
112
|
type: "FeatureCollection",
|
|
145
113
|
features: features,
|
|
@@ -153,61 +121,179 @@ export async function createLayersFromAssets(
|
|
|
153
121
|
}
|
|
154
122
|
|
|
155
123
|
if (geoJsonSources.length) {
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
124
|
+
for (const [i, geoJsonSource] of geoJsonSources.entries()) {
|
|
125
|
+
// fetch styles and separate them by their mapping between links and assets
|
|
126
|
+
const assetName = assetIds[geoJsonIdx[i]];
|
|
127
|
+
const styles = await fetchStyle(stacObject, undefined, assetName);
|
|
128
|
+
// get the correct style which is not attached to a link
|
|
129
|
+
let { layerConfig, style } = extractLayerConfig(collectionId, styles);
|
|
130
|
+
let assetLayerId = createAssetID(
|
|
131
|
+
collectionId,
|
|
132
|
+
stacObject.id,
|
|
133
|
+
geoJsonIdx[i],
|
|
134
|
+
);
|
|
135
|
+
if (
|
|
136
|
+
assets[assetName]?.roles?.includes("overlay") ||
|
|
137
|
+
assets[assetName]?.roles?.includes("baselayer")
|
|
138
|
+
) {
|
|
139
|
+
// to prevent them being removed by date change on main dataset
|
|
140
|
+
assetLayerId = assetName;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
log.debug(`Creating Vector layer from GeoJsons`, assetLayerId);
|
|
144
|
+
// register projection if exists
|
|
145
|
+
const assetProjection =
|
|
146
|
+
/** @type {string | number | {name: string, def: string, extent?:number[]} | undefined} */ (
|
|
147
|
+
assets[assetName]?.["proj:epsg"] ||
|
|
148
|
+
assets[assetName]?.["eodash:proj4_def"]
|
|
149
|
+
);
|
|
150
|
+
await registerProjection(assetProjection);
|
|
151
|
+
const projection = getProjectionCode(assetProjection) || "EPSG:4326";
|
|
152
|
+
const geoJSONURL =
|
|
153
|
+
stacObject?.["eodash:merge_assets"] === false
|
|
154
|
+
? geoJsonSource
|
|
155
|
+
: await mergeGeojsons(geoJsonSources);
|
|
182
156
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
157
|
+
const layer = {
|
|
158
|
+
type: "Vector",
|
|
159
|
+
source: {
|
|
160
|
+
type: "Vector",
|
|
161
|
+
url: geoJSONURL,
|
|
162
|
+
format: { type: "GeoJSON", dataProjection: projection },
|
|
163
|
+
attributions: assets[assetName].attribution,
|
|
164
|
+
},
|
|
165
|
+
properties: {
|
|
166
|
+
id: assetLayerId,
|
|
167
|
+
title: assets[assetName]?.title || title,
|
|
168
|
+
layerDatetime,
|
|
169
|
+
...(layerConfig && {
|
|
170
|
+
layerConfig: {
|
|
171
|
+
...layerConfig,
|
|
172
|
+
style,
|
|
173
|
+
},
|
|
174
|
+
}),
|
|
175
|
+
},
|
|
176
|
+
...(!style?.variables && { style }),
|
|
177
|
+
interactions: [],
|
|
178
|
+
};
|
|
179
|
+
layer.properties = { ...layer.properties, ...(extraProperties ?? {}) };
|
|
180
|
+
extractRoles(layer.properties, assets[assetName]);
|
|
181
|
+
addTooltipInteraction(layer, style);
|
|
182
|
+
jsonArray.push(layer);
|
|
183
|
+
// if we merged assets (default yes), then we can break from this loop
|
|
184
|
+
if (stacObject?.["eodash:merge_assets"] !== false) break;
|
|
185
|
+
}
|
|
186
186
|
}
|
|
187
|
-
if (
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
187
|
+
if (fgbSources.length) {
|
|
188
|
+
for (const [i, fgbSource] of fgbSources.entries()) {
|
|
189
|
+
// fetch styles and separate them by their mapping between links and assets
|
|
190
|
+
const assetName = assetIds[fgbIdx[i]];
|
|
191
|
+
const styles = await fetchStyle(stacObject, undefined, assetName);
|
|
192
|
+
// get the correct style which is not attached to a link
|
|
193
|
+
let { layerConfig, style } = extractLayerConfig(collectionId, styles);
|
|
194
|
+
let assetLayerId = createAssetID(collectionId, stacObject.id, fgbIdx[i]);
|
|
195
|
+
if (
|
|
196
|
+
assets[assetName]?.roles?.includes("overlay") ||
|
|
197
|
+
assets[assetName]?.roles?.includes("baselayer")
|
|
198
|
+
) {
|
|
199
|
+
// to prevent them being removed by date change on main dataset
|
|
200
|
+
assetLayerId = assetName;
|
|
201
|
+
}
|
|
202
|
+
log.debug(`Creating Vector layer from FlatGeoBuf`, assetLayerId);
|
|
203
|
+
// register projection if exists
|
|
204
|
+
const assetProjection =
|
|
205
|
+
/** @type {string | number | {name: string, def: string, extent?:number[]} | undefined} */ (
|
|
206
|
+
assets[assetName]?.["proj:epsg"] ||
|
|
207
|
+
assets[assetName]?.["eodash:proj4_def"]
|
|
208
|
+
);
|
|
209
|
+
await registerProjection(assetProjection);
|
|
210
|
+
const projection = getProjectionCode(assetProjection) || "EPSG:4326";
|
|
211
|
+
// in case we merge them, we pass urls, else just single url
|
|
212
|
+
const urlsObject = {
|
|
213
|
+
url: fgbSource,
|
|
214
|
+
// TODO uncomment this once fgb merging supported on source
|
|
215
|
+
// url: stacObject?.["eodash:merge_assets"] === false ? fgbSource : undefined,
|
|
216
|
+
// urls: stacObject?.["eodash:merge_assets"] !== false ? fgbSources : undefined,
|
|
217
|
+
};
|
|
218
|
+
const layer = {
|
|
219
|
+
type: "Vector",
|
|
220
|
+
source: {
|
|
221
|
+
...urlsObject,
|
|
222
|
+
type: "FlatGeoBuf",
|
|
223
|
+
projection,
|
|
224
|
+
attributions: assets[assetName].attribution,
|
|
225
|
+
},
|
|
226
|
+
properties: {
|
|
227
|
+
id: assetLayerId,
|
|
228
|
+
title: assets[assetName]?.title || title,
|
|
229
|
+
layerDatetime,
|
|
230
|
+
...(layerConfig && {
|
|
231
|
+
layerConfig: {
|
|
232
|
+
...layerConfig,
|
|
233
|
+
style,
|
|
234
|
+
},
|
|
235
|
+
}),
|
|
236
|
+
},
|
|
237
|
+
...(!style?.variables && { style }),
|
|
238
|
+
interactions: [],
|
|
239
|
+
};
|
|
240
|
+
layer.properties = { ...layer.properties, ...(extraProperties ?? {}) };
|
|
241
|
+
extractRoles(layer.properties, assets[assetName]);
|
|
242
|
+
addTooltipInteraction(layer, style);
|
|
243
|
+
jsonArray.push(layer);
|
|
244
|
+
// if we merged assets (default yes), then we can break from this loop
|
|
245
|
+
// TODO uncomment this once fgb merging supported on source
|
|
246
|
+
// if (stacObject?.["eodash:merge_assets"] !== false)
|
|
247
|
+
// break
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (geoTIFFSources.length) {
|
|
252
|
+
for (const [i, geotiffSource] of geoTIFFSources.entries()) {
|
|
253
|
+
const assetName = assetIds[geoTIFFIdx[i]];
|
|
254
|
+
const styles = await fetchStyle(stacObject, undefined, assetName);
|
|
255
|
+
// get the correct style which is not attached to a link
|
|
256
|
+
let { layerConfig, style } = extractLayerConfig(collectionId, styles);
|
|
257
|
+
let assetLayerId = createAssetID(
|
|
258
|
+
collectionId,
|
|
259
|
+
stacObject.id,
|
|
260
|
+
geoTIFFIdx[i],
|
|
261
|
+
);
|
|
262
|
+
if (
|
|
263
|
+
assets[assetName]?.roles?.includes("overlay") ||
|
|
264
|
+
assets[assetName]?.roles?.includes("baselayer")
|
|
265
|
+
) {
|
|
266
|
+
// to prevent them being removed by date change on main dataset
|
|
267
|
+
assetLayerId = assetName;
|
|
268
|
+
}
|
|
269
|
+
log.debug("Creating WebGLTile layer from GeoTIFF", assetLayerId);
|
|
270
|
+
log.debug("Configured Sources", geoTIFFSources);
|
|
271
|
+
const sources =
|
|
272
|
+
stacObject?.["eodash:merge_assets"] !== false ? geoTIFFSources : geotiffSource;
|
|
273
|
+
const layer = {
|
|
274
|
+
type: "WebGLTile",
|
|
275
|
+
source: {
|
|
276
|
+
type: "GeoTIFF",
|
|
277
|
+
normalize: !style,
|
|
278
|
+
interpolate: false,
|
|
279
|
+
sources,
|
|
280
|
+
},
|
|
281
|
+
properties: {
|
|
282
|
+
id: assetLayerId,
|
|
283
|
+
title,
|
|
284
|
+
layerConfig,
|
|
285
|
+
layerDatetime,
|
|
286
|
+
},
|
|
287
|
+
style,
|
|
288
|
+
};
|
|
289
|
+
if (extraProperties) {
|
|
290
|
+
layer.properties = { ...layer.properties, ...extraProperties };
|
|
291
|
+
}
|
|
292
|
+
extractRoles(layer.properties, assets[assetName]);
|
|
293
|
+
addTooltipInteraction(layer, style);
|
|
294
|
+
jsonArray.push(layer);
|
|
295
|
+
if (stacObject?.["eodash:merge_assets"] !== false) break;
|
|
209
296
|
}
|
|
210
|
-
jsonArray.push(layer);
|
|
211
297
|
}
|
|
212
298
|
|
|
213
299
|
return jsonArray;
|
|
@@ -217,17 +303,17 @@ export async function createLayersFromAssets(
|
|
|
217
303
|
* @param {string} collectionId
|
|
218
304
|
* @param {import('stac-ts').StacItem} item
|
|
219
305
|
* @param {string} title
|
|
220
|
-
* @param {string} itemUrl
|
|
221
306
|
* @param {Record<string,any>} [layerDatetime]
|
|
222
307
|
* @param {object | null} [extraProperties]
|
|
308
|
+
* @param {import('stac-ts').StacCollection} [collection]
|
|
223
309
|
*/
|
|
224
310
|
export const createLayersFromLinks = async (
|
|
225
311
|
collectionId,
|
|
226
312
|
title,
|
|
227
313
|
item,
|
|
228
|
-
itemUrl,
|
|
229
314
|
layerDatetime,
|
|
230
315
|
extraProperties,
|
|
316
|
+
collection,
|
|
231
317
|
) => {
|
|
232
318
|
log.debug("Creating layers from links");
|
|
233
319
|
/** @type {Record<string,any>[]} */
|
|
@@ -235,7 +321,8 @@ export const createLayersFromLinks = async (
|
|
|
235
321
|
const wmsArray = item.links.filter((l) => l.rel === "wms");
|
|
236
322
|
const wmtsArray = item.links.filter((l) => l.rel === "wmts");
|
|
237
323
|
const xyzArray = item.links.filter((l) => l.rel === "xyz") ?? [];
|
|
238
|
-
const vectorTileArray =
|
|
324
|
+
const vectorTileArray =
|
|
325
|
+
item.links.filter((l) => l.rel === "vector-tile") ?? [];
|
|
239
326
|
|
|
240
327
|
// Taking projection code from main map view, as main view defines
|
|
241
328
|
// projection for comparison map
|
|
@@ -243,7 +330,6 @@ export const createLayersFromLinks = async (
|
|
|
243
330
|
|
|
244
331
|
for (const wmsLink of wmsArray ?? []) {
|
|
245
332
|
// Registering setting sub wms link projection
|
|
246
|
-
|
|
247
333
|
const wmsLinkProjection =
|
|
248
334
|
/** @type {number | string | {name: string, def: string} | undefined} */
|
|
249
335
|
(wmsLink?.["proj:epsg"] || wmsLink?.["eodash:proj4_def"]);
|
|
@@ -296,8 +382,12 @@ export const createLayersFromLinks = async (
|
|
|
296
382
|
// Expand all dimensions into the params attribute
|
|
297
383
|
Object.assign(json.source.params, wmsLink["wms:dimensions"]);
|
|
298
384
|
}
|
|
385
|
+
if ("wms:styles" in wmsLink) {
|
|
386
|
+
// @ts-expect-error no type for eox-map
|
|
387
|
+
json.source.params["STYLES"] = wmsLink["wms:styles"];
|
|
388
|
+
}
|
|
299
389
|
if (extraProperties !== null) {
|
|
300
|
-
json.properties = { ...json.properties, ...extraProperties };
|
|
390
|
+
json.properties = { ...json.properties, ...extraProperties, ...extractEoxLegendLink(wmsLink) };
|
|
301
391
|
}
|
|
302
392
|
jsonArray.push(json);
|
|
303
393
|
}
|
|
@@ -310,6 +400,12 @@ export const createLayersFromLinks = async (
|
|
|
310
400
|
(wmtsLink?.["proj:epsg"] || wmtsLink?.["eodash:proj4_def"]);
|
|
311
401
|
|
|
312
402
|
await registerProjection(wmtsLinkProjection);
|
|
403
|
+
const key =
|
|
404
|
+
/** @type {string | undefined} */ (wmtsLink["key"]) || undefined;
|
|
405
|
+
|
|
406
|
+
const styles = await fetchStyle(item, key);
|
|
407
|
+
// get the correct style which is attached to a link
|
|
408
|
+
const returnedLayerConfig = extractLayerConfig(collectionId, styles, undefined, "tileUrl");
|
|
313
409
|
const projectionCode = getProjectionCode(wmtsLinkProjection || "EPSG:3857");
|
|
314
410
|
// TODO: WARNING! This is a temporary project specific implementation
|
|
315
411
|
// that needs to be removed once catalog and wmts creation from capabilities
|
|
@@ -327,6 +423,17 @@ export const createLayersFromLinks = async (
|
|
|
327
423
|
let { style, ...dimensionsWithoutStyle } = { ...dimensions };
|
|
328
424
|
let extractedStyle = /** @type { string } */ (style || "default");
|
|
329
425
|
|
|
426
|
+
// TODO, this does not yet work between layer time changes because we do not get
|
|
427
|
+
// updated variables from OL layer due to usage of tileurlfunction
|
|
428
|
+
|
|
429
|
+
// update dimensions with current value of style variables if applicable
|
|
430
|
+
const variables = returnedLayerConfig?.style?.variables;
|
|
431
|
+
if (variables) {
|
|
432
|
+
for (const [kk, vv] of Object.entries(variables)) {
|
|
433
|
+
dimensionsWithoutStyle[kk] = vv;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
330
437
|
if (wmtsLink.title === "wmts capabilities") {
|
|
331
438
|
log.debug(
|
|
332
439
|
"Warning: WMTS Layer from capabilities added, function needs to be updated",
|
|
@@ -338,6 +445,7 @@ export const createLayersFromLinks = async (
|
|
|
338
445
|
id: linkId,
|
|
339
446
|
title: title || item.id,
|
|
340
447
|
layerDatetime,
|
|
448
|
+
layerConfig: returnedLayerConfig.layerConfig,
|
|
341
449
|
},
|
|
342
450
|
source: {
|
|
343
451
|
type: "WMTS",
|
|
@@ -384,7 +492,7 @@ export const createLayersFromLinks = async (
|
|
|
384
492
|
}
|
|
385
493
|
extractRoles(json.properties, wmtsLink);
|
|
386
494
|
if (extraProperties !== null) {
|
|
387
|
-
json.properties = { ...json.properties, ...extraProperties };
|
|
495
|
+
json.properties = { ...json.properties, ...extraProperties, ...extractEoxLegendLink(wmtsLink) };
|
|
388
496
|
}
|
|
389
497
|
jsonArray.push(json);
|
|
390
498
|
}
|
|
@@ -393,7 +501,18 @@ export const createLayersFromLinks = async (
|
|
|
393
501
|
const xyzLinkProjection =
|
|
394
502
|
/** @type {number | string | {name: string, def: string} | undefined} */
|
|
395
503
|
(xyzLink?.["proj:epsg"] || xyzLink?.["eodash:proj4_def"]);
|
|
396
|
-
|
|
504
|
+
const key =
|
|
505
|
+
/** @type {string | undefined} */ (xyzLink["key"]) || undefined;
|
|
506
|
+
const rasterformURL = /** @type {string|undefined} */ (
|
|
507
|
+
collection?.["eodash:rasterform"]
|
|
508
|
+
);
|
|
509
|
+
/** @type {import("@/types").EodashRasterJSONForm|undefined} */
|
|
510
|
+
const rasterForm = rasterformURL
|
|
511
|
+
? await axios.get(rasterformURL).then((resp) => resp.data)
|
|
512
|
+
: undefined;
|
|
513
|
+
const styles = await fetchStyle(item, key);
|
|
514
|
+
// get the correct style which is attached to a link
|
|
515
|
+
let { layerConfig, style } = extractLayerConfig(collectionId, styles, rasterForm, "tileUrl");
|
|
397
516
|
await registerProjection(xyzLinkProjection);
|
|
398
517
|
const projectionCode = getProjectionCode(xyzLinkProjection || "EPSG:3857");
|
|
399
518
|
const linkId = createLayerID(
|
|
@@ -402,6 +521,22 @@ export const createLayersFromLinks = async (
|
|
|
402
521
|
xyzLink,
|
|
403
522
|
viewProjectionCode,
|
|
404
523
|
);
|
|
524
|
+
let xyzUrl = xyzLink.href;
|
|
525
|
+
|
|
526
|
+
// TODO, this does not yet work between layer time changes because we do not get
|
|
527
|
+
// updated variables from OL layer due to usage of tileurlfunction
|
|
528
|
+
|
|
529
|
+
// update url query params with current value of style variables if applicable
|
|
530
|
+
const variables = style?.variables;
|
|
531
|
+
if (variables) {
|
|
532
|
+
const [base, query] = xyzUrl.split("?");
|
|
533
|
+
const params = new URLSearchParams(query);
|
|
534
|
+
for (const [kk, vv] of Object.entries(variables)) {
|
|
535
|
+
params.set(kk, JSON.stringify(vv));
|
|
536
|
+
}
|
|
537
|
+
xyzUrl = `${base}?${params.toString()}`;
|
|
538
|
+
}
|
|
539
|
+
|
|
405
540
|
log.debug("XYZ Layer added", linkId);
|
|
406
541
|
let json = {
|
|
407
542
|
type: "Tile",
|
|
@@ -410,10 +545,11 @@ export const createLayersFromLinks = async (
|
|
|
410
545
|
title: xyzLink.title || title || item.id,
|
|
411
546
|
roles: xyzLink.roles,
|
|
412
547
|
layerDatetime,
|
|
548
|
+
layerConfig,
|
|
413
549
|
},
|
|
414
550
|
source: {
|
|
415
551
|
type: "XYZ",
|
|
416
|
-
url:
|
|
552
|
+
url: xyzUrl,
|
|
417
553
|
projection: projectionCode,
|
|
418
554
|
attributions: xyzLink.attribution,
|
|
419
555
|
},
|
|
@@ -421,7 +557,7 @@ export const createLayersFromLinks = async (
|
|
|
421
557
|
|
|
422
558
|
extractRoles(json.properties, xyzLink);
|
|
423
559
|
if (extraProperties !== null) {
|
|
424
|
-
json.properties = { ...json.properties, ...extraProperties };
|
|
560
|
+
json.properties = { ...json.properties, ...extraProperties, ...extractEoxLegendLink(xyzLink) };
|
|
425
561
|
}
|
|
426
562
|
jsonArray.push(json);
|
|
427
563
|
}
|
|
@@ -432,7 +568,9 @@ export const createLayersFromLinks = async (
|
|
|
432
568
|
(vectorTileLink?.["proj:epsg"] || vectorTileLink?.["eodash:proj4_def"]);
|
|
433
569
|
|
|
434
570
|
await registerProjection(vectorTileLinkProjection);
|
|
435
|
-
const projectionCode = getProjectionCode(
|
|
571
|
+
const projectionCode = getProjectionCode(
|
|
572
|
+
vectorTileLinkProjection || "EPSG:3857",
|
|
573
|
+
);
|
|
436
574
|
const linkId = createLayerID(
|
|
437
575
|
collectionId,
|
|
438
576
|
item.id,
|
|
@@ -440,18 +578,19 @@ export const createLayersFromLinks = async (
|
|
|
440
578
|
viewProjectionCode,
|
|
441
579
|
);
|
|
442
580
|
log.debug("Vector Tile Layer added", linkId);
|
|
443
|
-
const key =
|
|
581
|
+
const key =
|
|
582
|
+
/** @type {string | undefined} */ (vectorTileLink["key"]) || undefined;
|
|
444
583
|
// fetch styles and separate them by their mapping between links and assets
|
|
445
|
-
const styles = await fetchStyle(item,
|
|
584
|
+
const styles = await fetchStyle(item, key);
|
|
446
585
|
// get the correct style which is not attached to a link
|
|
447
|
-
let { layerConfig, style } = extractLayerConfig(
|
|
448
|
-
|
|
449
|
-
styles,
|
|
450
|
-
);
|
|
451
|
-
|
|
586
|
+
let { layerConfig, style } = extractLayerConfig(collectionId, styles);
|
|
587
|
+
|
|
452
588
|
let href = vectorTileLink.href;
|
|
453
589
|
if ("auth:schemes" in item && "auth:refs" in vectorTileLink) {
|
|
454
|
-
href = handleAuthenticationOfLink(
|
|
590
|
+
href = handleAuthenticationOfLink(
|
|
591
|
+
/** @type { import("@/types").StacAuthItem} */ (item),
|
|
592
|
+
/** @type { import("@/types").StacAuthLink} */ (vectorTileLink),
|
|
593
|
+
);
|
|
455
594
|
}
|
|
456
595
|
const json = {
|
|
457
596
|
type: "VectorTile",
|
|
@@ -462,11 +601,11 @@ export const createLayersFromLinks = async (
|
|
|
462
601
|
roles: vectorTileLink.roles,
|
|
463
602
|
layerDatetime,
|
|
464
603
|
...(layerConfig && {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
604
|
+
layerConfig: {
|
|
605
|
+
...layerConfig,
|
|
606
|
+
style,
|
|
607
|
+
},
|
|
608
|
+
}),
|
|
470
609
|
},
|
|
471
610
|
source: {
|
|
472
611
|
type: "VectorTile",
|
|
@@ -485,7 +624,7 @@ export const createLayersFromLinks = async (
|
|
|
485
624
|
addTooltipInteraction(json, style);
|
|
486
625
|
extractRoles(json.properties, vectorTileLink);
|
|
487
626
|
if (extraProperties !== null) {
|
|
488
|
-
json.properties = { ...json.properties, ...extraProperties };
|
|
627
|
+
json.properties = { ...json.properties, ...extraProperties, ...extractEoxLegendLink(vectorTileLink) };
|
|
489
628
|
}
|
|
490
629
|
jsonArray.push(json);
|
|
491
630
|
}
|
|
@@ -497,18 +636,31 @@ export const createLayersFromLinks = async (
|
|
|
497
636
|
* @param {import("stac-ts").StacItem | undefined | null} item
|
|
498
637
|
* @param {string} rasterURL
|
|
499
638
|
* @param {Record<string, any>} [extraProperties]
|
|
500
|
-
* @returns {import("@eox/map/src/layers").EOxLayerType<"Tile","XYZ">[]}
|
|
639
|
+
* @returns {Promise<import("@eox/map/src/layers").EOxLayerType<"Tile","XYZ">[]>}
|
|
501
640
|
*/
|
|
502
|
-
export
|
|
641
|
+
export const createLayerFromRender = async (
|
|
503
642
|
rasterURL,
|
|
504
643
|
collection,
|
|
505
644
|
item,
|
|
506
645
|
extraProperties,
|
|
507
|
-
) {
|
|
646
|
+
) => {
|
|
508
647
|
if (!collection || !collection.renders || !item) {
|
|
509
648
|
return [];
|
|
510
649
|
}
|
|
511
650
|
|
|
651
|
+
const rasterformURL = /** @type {string|undefined} */ (
|
|
652
|
+
collection?.["eodash:rasterform"]
|
|
653
|
+
);
|
|
654
|
+
/** @type {import("@/types").EodashRasterJSONForm|undefined} */
|
|
655
|
+
const rasterForm = rasterformURL
|
|
656
|
+
? await axios.get(rasterformURL).then((resp) => resp.data)
|
|
657
|
+
: undefined;
|
|
658
|
+
let { layerConfig } = extractLayerConfig(
|
|
659
|
+
collection.id,
|
|
660
|
+
await fetchStyle(item),
|
|
661
|
+
rasterForm,
|
|
662
|
+
);
|
|
663
|
+
|
|
512
664
|
const renders = /** @type {Record<string,import("@/types").Render>} */ (
|
|
513
665
|
collection.renders ?? item?.renders
|
|
514
666
|
);
|
|
@@ -559,6 +711,9 @@ export function createLayerFromRender(
|
|
|
559
711
|
title,
|
|
560
712
|
roles: item.roles,
|
|
561
713
|
...extraProperties,
|
|
714
|
+
layerConfig: {
|
|
715
|
+
...layerConfig,
|
|
716
|
+
},
|
|
562
717
|
},
|
|
563
718
|
source: {
|
|
564
719
|
/** @type {"XYZ"} */
|