@eox/layercontrol 0.28.0 → 0.28.2-dev.1736961804.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/dist/eox-layercontrol.js +1125 -1349
- package/dist/eox-layercontrol.umd.cjs +153 -386
- package/package.json +2 -2
- package/src/components/layer-config.js +8 -4
- package/src/components/layer-legend.js +42 -16
- package/src/components/layer-tools.js +4 -4
- package/src/components/layer.js +1 -1
- package/src/enums/index.js +1 -0
- package/src/enums/stories/assets/polaris-style.json +135 -0
- package/src/enums/stories/index.js +159 -0
- package/src/helpers/get-legend-config.js +29 -11
- package/src/methods/layer-config/apply-updated-styles.js +1 -2
- package/types/layercontrol/src/components/layer-config.d.ts +17 -8
- package/types/layercontrol/src/components/layer-config.d.ts.map +1 -1
- package/types/layercontrol/src/components/layer-legend.d.ts +2 -2
- package/types/layercontrol/src/components/layer-legend.d.ts.map +1 -1
- package/types/layercontrol/src/enums/index.d.ts +1 -1
- package/types/layercontrol/src/enums/stories/index.d.ts +222 -110
- package/types/layercontrol/src/enums/stories/index.d.ts.map +1 -1
- package/types/layercontrol/src/helpers/get-legend-config.d.ts +1 -12
- package/types/layercontrol/src/helpers/get-legend-config.d.ts.map +1 -1
- package/types/layercontrol/src/methods/layer-config/apply-updated-styles.d.ts +1 -1
- package/types/layercontrol/src/methods/layer-config/apply-updated-styles.d.ts.map +1 -1
- package/types/map/src/helpers/select.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eox/layercontrol",
|
|
3
|
-
"version": "0.28.0",
|
|
3
|
+
"version": "0.28.2-dev.1736961804.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@eox/map": "^1.16.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"watch": "vite build --watch"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@eox/elements-utils": "^0.1.
|
|
38
|
+
"@eox/elements-utils": "^0.1.5",
|
|
39
39
|
"color-legend-element": "^1.3.0",
|
|
40
40
|
"lit": "^3.2.0",
|
|
41
41
|
"lodash.debounce": "^4.0.8",
|
|
@@ -5,6 +5,13 @@ import { dataChangeMethod, applyUpdatedStyles } from "../methods/layer-config";
|
|
|
5
5
|
import { when } from "lit/directives/when.js";
|
|
6
6
|
import _throttle from "lodash.throttle";
|
|
7
7
|
import "./layer-legend";
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Partial<import("./layer-legend").LegendConfig> & {
|
|
10
|
+
* range:string[];
|
|
11
|
+
* domainProperties:string[]
|
|
12
|
+
* }} layerConfigLegend
|
|
13
|
+
**/
|
|
14
|
+
|
|
8
15
|
/**
|
|
9
16
|
* `EOxLayerControlLayerConfig` is a component that handles configuration options for layers using eox-jsonform.
|
|
10
17
|
* It allows users to input data, modify layer settings, and update the UI based on those settings.
|
|
@@ -76,10 +83,7 @@ export class EOxLayerControlLayerConfig extends LitElement {
|
|
|
76
83
|
* element: string;
|
|
77
84
|
* type?:"tileUrl"|"style";
|
|
78
85
|
* style?:import("ol/layer/WebGLTile").Style
|
|
79
|
-
* legend?:
|
|
80
|
-
* range:string[];
|
|
81
|
-
* domainProperties:string[]
|
|
82
|
-
* }
|
|
86
|
+
* legend?: layerConfigLegend | (layerConfigLegend & { boundTo:{key:string;value:string|number|boolean} })[]
|
|
83
87
|
* }}
|
|
84
88
|
*/
|
|
85
89
|
this.layerConfig = null;
|
|
@@ -52,7 +52,7 @@ export class EOxLayerControlLayerLegend extends LitElement {
|
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Legend configurations
|
|
55
|
-
* @type {LegendConfig}
|
|
55
|
+
* @type {LegendConfig | LegendConfig[]}
|
|
56
56
|
* @see {@link https://clhenrick.github.io/color-legend-element/}
|
|
57
57
|
*/
|
|
58
58
|
this.layerLegend = null;
|
|
@@ -105,21 +105,47 @@ export class EOxLayerControlLayerLegend extends LitElement {
|
|
|
105
105
|
() => html`
|
|
106
106
|
<div class="legend-container">
|
|
107
107
|
<!-- Render color-legend-->
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
108
|
+
${when(
|
|
109
|
+
Array.isArray(this.layerLegend),
|
|
110
|
+
() =>
|
|
111
|
+
/** @type {LegendConfig[]} */ (this.layerLegend).map(
|
|
112
|
+
(legend, idx) => html`
|
|
113
|
+
<color-legend
|
|
114
|
+
id="${this.layer.get("id") + idx}"
|
|
115
|
+
width=${legend.width ?? 325}
|
|
116
|
+
scaleType="${ifDefined(legend.scaleType)}"
|
|
117
|
+
markType="${ifDefined(legend.markType)}"
|
|
118
|
+
titleText="${ifDefined(legend.title)}"
|
|
119
|
+
.range=${legend.range}
|
|
120
|
+
.domain=${legend.domain}
|
|
121
|
+
tickFormat="${ifDefined(legend.tickFormat)}"
|
|
122
|
+
.ticks=${legend.ticks ?? 5}
|
|
123
|
+
.tickValues=${legend.tickValues}
|
|
124
|
+
.marginLeft=${0}
|
|
125
|
+
.marginRight=${0}
|
|
126
|
+
>
|
|
127
|
+
</color-legend>
|
|
128
|
+
<div></div>
|
|
129
|
+
`,
|
|
130
|
+
),
|
|
131
|
+
() => html`
|
|
132
|
+
<color-legend
|
|
133
|
+
id="${this.layer.get("id")}"
|
|
134
|
+
width=${this.layerLegend.width ?? 325}
|
|
135
|
+
scaleType="${ifDefined(this.layerLegend.scaleType)}"
|
|
136
|
+
markType="${ifDefined(this.layerLegend.markType)}"
|
|
137
|
+
titleText="${ifDefined(this.layerLegend.title)}"
|
|
138
|
+
.range=${this.layerLegend.range}
|
|
139
|
+
.domain=${this.layerLegend.domain}
|
|
140
|
+
tickFormat="${ifDefined(this.layerLegend.tickFormat)}"
|
|
141
|
+
.ticks=${this.layerLegend.ticks ?? 5}
|
|
142
|
+
.tickValues=${this.layerLegend.tickValues}
|
|
143
|
+
.marginLeft=${0}
|
|
144
|
+
.marginRight=${0}
|
|
145
|
+
>
|
|
146
|
+
</color-legend>
|
|
147
|
+
`,
|
|
148
|
+
)}
|
|
123
149
|
</div>
|
|
124
150
|
`,
|
|
125
151
|
)}
|
|
@@ -7,10 +7,10 @@ import "./layer-config";
|
|
|
7
7
|
import "./layer-datetime";
|
|
8
8
|
import "./layer-legend";
|
|
9
9
|
import "./tools-items";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
10
|
+
import button from "@eox/elements-utils/styles/dist/button.style";
|
|
11
|
+
import radio from "@eox/elements-utils/styles/dist/radio.style";
|
|
12
|
+
import checkbox from "@eox/elements-utils/styles/dist/checkbox.style";
|
|
13
|
+
import slider from "@eox/elements-utils/styles/dist/slider.style";
|
|
14
14
|
import {
|
|
15
15
|
Button,
|
|
16
16
|
_parseActions,
|
package/src/components/layer.js
CHANGED
|
@@ -2,7 +2,7 @@ import { LitElement, html } from "lit";
|
|
|
2
2
|
import { when } from "lit/directives/when.js";
|
|
3
3
|
import { live } from "lit/directives/live.js";
|
|
4
4
|
import "./layer-tools";
|
|
5
|
-
import
|
|
5
|
+
import checkbox from "@eox/elements-utils/styles/dist/checkbox.style";
|
|
6
6
|
import { firstUpdatedMethod, inputClickMethod } from "../methods/layer";
|
|
7
7
|
|
|
8
8
|
/**
|
package/src/enums/index.js
CHANGED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
{
|
|
2
|
+
"variables": {
|
|
3
|
+
"ship_class": "nis",
|
|
4
|
+
"type_of_ice": "standard",
|
|
5
|
+
"type_of_visualisation": "polaris",
|
|
6
|
+
"combined_prop": "polaris_standard_pc_nis_rio"
|
|
7
|
+
},
|
|
8
|
+
"fill-color": [
|
|
9
|
+
"case",
|
|
10
|
+
["==", ["var", "type_of_visualisation"], "WMO Concentration"],
|
|
11
|
+
[
|
|
12
|
+
"match",
|
|
13
|
+
["get", "wmo_concentration"],
|
|
14
|
+
"Ice Free",
|
|
15
|
+
[0, 100, 255, 1],
|
|
16
|
+
"Open Water (< 1/10 ice)",
|
|
17
|
+
[150, 200, 255, 1],
|
|
18
|
+
"Bergy Water",
|
|
19
|
+
[150, 200, 255, 1],
|
|
20
|
+
"1/10",
|
|
21
|
+
[140, 255, 159, 1],
|
|
22
|
+
"2/10",
|
|
23
|
+
[140, 255, 159, 1],
|
|
24
|
+
"3/10",
|
|
25
|
+
[140, 255, 159, 1],
|
|
26
|
+
"4/10",
|
|
27
|
+
[255, 255, 0, 1],
|
|
28
|
+
"5/10",
|
|
29
|
+
[255, 255, 0, 1],
|
|
30
|
+
"6/10",
|
|
31
|
+
[255, 255, 0, 1],
|
|
32
|
+
"7/10",
|
|
33
|
+
[255, 125, 7, 1],
|
|
34
|
+
"8/10",
|
|
35
|
+
[255, 125, 7, 1],
|
|
36
|
+
"9/10",
|
|
37
|
+
[255, 0, 0, 1],
|
|
38
|
+
"10/10",
|
|
39
|
+
[255, 0, 0, 1],
|
|
40
|
+
"9/10 to 10/10 ice, 9+/10",
|
|
41
|
+
[255, 0, 0, 1],
|
|
42
|
+
"Unknown/Undetermined",
|
|
43
|
+
[255, 255, 255, 1],
|
|
44
|
+
[255, 255, 255, 1]
|
|
45
|
+
],
|
|
46
|
+
["==", ["var", "type_of_visualisation"], "WMO Stage of Development"],
|
|
47
|
+
[
|
|
48
|
+
"match",
|
|
49
|
+
["get", "wmo_stage_of_development"],
|
|
50
|
+
"Ice Free",
|
|
51
|
+
[0, 100, 255, 1],
|
|
52
|
+
"Brash Ice",
|
|
53
|
+
[0, 0, 0, 0],
|
|
54
|
+
"No stage of development",
|
|
55
|
+
[0, 0, 0, 0],
|
|
56
|
+
"New Ice",
|
|
57
|
+
[240, 210, 250, 1],
|
|
58
|
+
"Nilas Ice Rind (<10 cm)",
|
|
59
|
+
[255, 100, 255, 1],
|
|
60
|
+
"Young Ice (10 to 30 cm)",
|
|
61
|
+
[0, 0, 0, 0],
|
|
62
|
+
"Grey Ice",
|
|
63
|
+
[135, 60, 215, 1],
|
|
64
|
+
"Grey-White Ice",
|
|
65
|
+
[220, 80, 235, 1],
|
|
66
|
+
"First Year Ice (>30 cm) or Brash Ice",
|
|
67
|
+
[255, 255, 0, 1],
|
|
68
|
+
"Thin First Year Ice (30 to 70 cm)",
|
|
69
|
+
[155, 210, 0, 1],
|
|
70
|
+
"Medium First Year Ice (70 to 120 cm)",
|
|
71
|
+
[0, 200, 20, 1],
|
|
72
|
+
"Thick First Year Ice (>120 cm)",
|
|
73
|
+
[0, 120, 0, 1],
|
|
74
|
+
"Old Ice",
|
|
75
|
+
[180, 100, 50, 1],
|
|
76
|
+
"Second-Year Ice",
|
|
77
|
+
[255, 120, 10, 1],
|
|
78
|
+
"Multi-Year Ice",
|
|
79
|
+
[200, 0, 0, 1],
|
|
80
|
+
"Bergy Water",
|
|
81
|
+
[255, 255, 255, 1],
|
|
82
|
+
"Unknown/Undetermined",
|
|
83
|
+
[255, 255, 255, 1],
|
|
84
|
+
[0, 0, 0, 0]
|
|
85
|
+
],
|
|
86
|
+
["==", ["var", "type_of_visualisation"], "polaris"],
|
|
87
|
+
[
|
|
88
|
+
"case",
|
|
89
|
+
["==", ["get", "polygon_type"], "Ice Free"],
|
|
90
|
+
[0, 100, 255],
|
|
91
|
+
["==", ["get", ["var", "combined_prop"]], "RIO > 20: Normal Operation"],
|
|
92
|
+
[54, 122, 74, 1],
|
|
93
|
+
[
|
|
94
|
+
"==",
|
|
95
|
+
["get", ["var", "combined_prop"]],
|
|
96
|
+
">= 10 RIO < 20: Normal Operation"
|
|
97
|
+
],
|
|
98
|
+
[62, 150, 85, 1],
|
|
99
|
+
[
|
|
100
|
+
"==",
|
|
101
|
+
["get", ["var", "combined_prop"]],
|
|
102
|
+
">= 0 RIO < 10: Normal Operation"
|
|
103
|
+
],
|
|
104
|
+
[102, 188, 118, 1],
|
|
105
|
+
[
|
|
106
|
+
"==",
|
|
107
|
+
["get", ["var", "combined_prop"]],
|
|
108
|
+
">= -10 RIO < 0: Operation subject to special consideration"
|
|
109
|
+
],
|
|
110
|
+
[252, 251, 1, 1],
|
|
111
|
+
[
|
|
112
|
+
"==",
|
|
113
|
+
["get", ["var", "combined_prop"]],
|
|
114
|
+
">= -20 RIO < -10: Operation subject to special consideration"
|
|
115
|
+
],
|
|
116
|
+
[227, 108, 9, 1],
|
|
117
|
+
[
|
|
118
|
+
"==",
|
|
119
|
+
["get", ["var", "combined_prop"]],
|
|
120
|
+
"RIO < -20: Operation subject to special consideration"
|
|
121
|
+
],
|
|
122
|
+
[188, 1, 6, 1],
|
|
123
|
+
[
|
|
124
|
+
"==",
|
|
125
|
+
["get", ["var", "combined_prop"]],
|
|
126
|
+
"<= -10 RIO < 0: Elevated operational risk"
|
|
127
|
+
],
|
|
128
|
+
[252, 251, 1, 1],
|
|
129
|
+
[0, 0, 0, 1]
|
|
130
|
+
],
|
|
131
|
+
[0, 0, 0, 0]
|
|
132
|
+
],
|
|
133
|
+
"stroke-color": "black",
|
|
134
|
+
"stroke-width": 1
|
|
135
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import FEATURE_COLLECTION_LAYER_CROPOMHUSC from "./assets/cropomhusc-feature-collection.json";
|
|
2
|
+
import POLARIS_STYLE from "./assets/polaris-style.json";
|
|
2
3
|
|
|
3
4
|
const SENTINEL_HUB_URL =
|
|
4
5
|
"https://services.sentinel-hub.com/ogc/wms/0635c213-17a1-48ee-aef7-9d1731695a54";
|
|
@@ -410,6 +411,164 @@ const STYLES_LAYER_SEE = {
|
|
|
410
411
|
],
|
|
411
412
|
};
|
|
412
413
|
|
|
414
|
+
export const STORIES_LAYER_POLARIS = {
|
|
415
|
+
type: "Vector",
|
|
416
|
+
source: {
|
|
417
|
+
type: "FlatGeoBuf",
|
|
418
|
+
url: "https://eox-gtif-public.s3.eu-central-1.amazonaws.com/EOX/polaris/202408131425_CapeFarewell_RIC-processed.fgb",
|
|
419
|
+
format: "GeoJSON",
|
|
420
|
+
},
|
|
421
|
+
properties: {
|
|
422
|
+
id: "Polaris_algorithm_dmi_demo;:;2024-08-13T00:00:00Z;:;0",
|
|
423
|
+
title: "Polaris Results demo",
|
|
424
|
+
layerConfig: {
|
|
425
|
+
schema: {
|
|
426
|
+
type: "object",
|
|
427
|
+
title: "Data configuration",
|
|
428
|
+
properties: {
|
|
429
|
+
type_of_visualisation: {
|
|
430
|
+
title: "Type of Visualisation",
|
|
431
|
+
type: "string",
|
|
432
|
+
enum: [
|
|
433
|
+
"polaris",
|
|
434
|
+
"WMO Concentration",
|
|
435
|
+
"WMO Stage of Development",
|
|
436
|
+
"AIRSS Ice Numeral Go/No Go",
|
|
437
|
+
],
|
|
438
|
+
options: {
|
|
439
|
+
enum_titles: [
|
|
440
|
+
"POLARIS",
|
|
441
|
+
"WMO Concentration",
|
|
442
|
+
"WMO Stage of Development",
|
|
443
|
+
"AIRSS Ice Numeral Go/No Go",
|
|
444
|
+
],
|
|
445
|
+
},
|
|
446
|
+
default: "polaris",
|
|
447
|
+
},
|
|
448
|
+
ship_class: {
|
|
449
|
+
title: "Ship Class",
|
|
450
|
+
type: "string",
|
|
451
|
+
enum: [
|
|
452
|
+
"pc_1",
|
|
453
|
+
"pc_2",
|
|
454
|
+
"pc_3",
|
|
455
|
+
"pc_4",
|
|
456
|
+
"pc_5",
|
|
457
|
+
"pc_6",
|
|
458
|
+
"pc_7",
|
|
459
|
+
"pc_ias",
|
|
460
|
+
"pc_ia",
|
|
461
|
+
"pc_ib",
|
|
462
|
+
"pc_ic",
|
|
463
|
+
"pc_nis",
|
|
464
|
+
],
|
|
465
|
+
options: {
|
|
466
|
+
enum_titles: [
|
|
467
|
+
"PC1",
|
|
468
|
+
"PC2",
|
|
469
|
+
"PC3",
|
|
470
|
+
"PC4",
|
|
471
|
+
"PC5",
|
|
472
|
+
"PC6",
|
|
473
|
+
"PC7",
|
|
474
|
+
"PC IA Super",
|
|
475
|
+
"PC IA",
|
|
476
|
+
"PC IB",
|
|
477
|
+
"PC IC",
|
|
478
|
+
"PC NIS",
|
|
479
|
+
],
|
|
480
|
+
},
|
|
481
|
+
default: "pc_nis",
|
|
482
|
+
},
|
|
483
|
+
type_of_ice: {
|
|
484
|
+
title: "Type of Ice (decayed/standard)",
|
|
485
|
+
type: "string",
|
|
486
|
+
enum: ["standard", "decayed"],
|
|
487
|
+
default: "standard",
|
|
488
|
+
},
|
|
489
|
+
combined_prop: {
|
|
490
|
+
type: "string",
|
|
491
|
+
template: "{{vis}}_{{ice}}_{{ship}}_rio",
|
|
492
|
+
options: {
|
|
493
|
+
hidden: true,
|
|
494
|
+
},
|
|
495
|
+
watch: {
|
|
496
|
+
vis: "type_of_visualisation",
|
|
497
|
+
ice: "type_of_ice",
|
|
498
|
+
ship: "ship_class",
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
type: "style",
|
|
504
|
+
legend: [
|
|
505
|
+
{
|
|
506
|
+
title: "Total concentration colour code standard",
|
|
507
|
+
range: [
|
|
508
|
+
"#367a4a",
|
|
509
|
+
"#3e9655",
|
|
510
|
+
"#66bc76",
|
|
511
|
+
"#fcfb01",
|
|
512
|
+
"#e36c09",
|
|
513
|
+
"#bc0106",
|
|
514
|
+
"#fcfb01",
|
|
515
|
+
],
|
|
516
|
+
domain: [
|
|
517
|
+
"RIO > 20: Normal Operation",
|
|
518
|
+
">= 10 RIO < 20: Normal Operation",
|
|
519
|
+
">= 0 RIO < 10: Normal Operation",
|
|
520
|
+
">= -10 RIO < 0: Operation subject to special consideration",
|
|
521
|
+
">= -20 RIO < -10: Operation subject to special consideration",
|
|
522
|
+
"RIO < -20: Operation subject to special consideration",
|
|
523
|
+
"<= -10 RIO < 0: Elevated operational risk",
|
|
524
|
+
],
|
|
525
|
+
scaleType: "categorical",
|
|
526
|
+
markType: "circle",
|
|
527
|
+
boundTo: {
|
|
528
|
+
key: "type_of_visualisation",
|
|
529
|
+
value: "polaris",
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
title: "WMO Concentration",
|
|
534
|
+
range: ["#8cff9f", "#ffff00", "#ff7d07", "#ff0000"],
|
|
535
|
+
domain: ["1 - 3", "4 - 6", "7 - 9", "10"],
|
|
536
|
+
scaleType: "categorical",
|
|
537
|
+
markType: "circle",
|
|
538
|
+
boundTo: {
|
|
539
|
+
key: "type_of_visualisation",
|
|
540
|
+
value: "WMO Concentration",
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
],
|
|
544
|
+
style: POLARIS_STYLE,
|
|
545
|
+
layerLegend: {
|
|
546
|
+
title: "Total concentration colour code standard",
|
|
547
|
+
range: [
|
|
548
|
+
"#367a4a",
|
|
549
|
+
"#3e9655",
|
|
550
|
+
"#66bc76",
|
|
551
|
+
"#fcfb01",
|
|
552
|
+
"#e36c09",
|
|
553
|
+
"#bc0106",
|
|
554
|
+
"#fcfb01",
|
|
555
|
+
],
|
|
556
|
+
domain: [
|
|
557
|
+
"RIO > 20: Normal Operation",
|
|
558
|
+
">= 10 RIO < 20: Normal Operation",
|
|
559
|
+
">= 0 RIO < 10: Normal Operation",
|
|
560
|
+
">= -10 RIO < 0: Operation subject to special consideration",
|
|
561
|
+
">= -20 RIO < -10: Operation subject to special consideration",
|
|
562
|
+
"RIO < -20: Operation subject to special consideration",
|
|
563
|
+
"<= -10 RIO < 0: Elevated operational risk",
|
|
564
|
+
],
|
|
565
|
+
scaleType: "categorical",
|
|
566
|
+
markType: "circle",
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
},
|
|
570
|
+
};
|
|
571
|
+
|
|
413
572
|
export const STORIES_LAYER_SEE = {
|
|
414
573
|
type: "WebGLTile",
|
|
415
574
|
style: STYLES_LAYER_SEE,
|
|
@@ -7,19 +7,37 @@ import { flattenObject } from "../methods/layer-config";
|
|
|
7
7
|
*/
|
|
8
8
|
const getLegendConfig = (legendConfig, data) => {
|
|
9
9
|
if (!legendConfig) return undefined;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/** @type {import("../components/layer-config").EOxLayerControlLayerConfig["layerConfig"]["legend"]} */
|
|
11
|
+
let activeLegend;
|
|
12
|
+
const flatData = flattenObject(data);
|
|
13
|
+
if (Array.isArray(legendConfig) && legendConfig.length) {
|
|
14
|
+
activeLegend = legendConfig.find((legend) => {
|
|
15
|
+
const propName = legend.boundTo.key;
|
|
16
|
+
const expectedToMatch = legend.boundTo.value;
|
|
17
|
+
return flatData[propName] == expectedToMatch;
|
|
18
|
+
});
|
|
19
|
+
if (!activeLegend) {
|
|
20
|
+
activeLegend = legendConfig;
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
activeLegend = legendConfig;
|
|
24
|
+
}
|
|
25
|
+
if (!Array.isArray(activeLegend)) {
|
|
26
|
+
activeLegend = [activeLegend];
|
|
12
27
|
}
|
|
13
|
-
return
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
legend["domain"] = legendConfig[key].map((k) => flatData_[k]);
|
|
17
|
-
} else {
|
|
18
|
-
// @ts-expect-error TODO
|
|
19
|
-
legend[key] = legendConfig[key];
|
|
28
|
+
return activeLegend.map((lgnd) => {
|
|
29
|
+
if (!("domainProperties" in lgnd) || "domain" in lgnd) {
|
|
30
|
+
return { ...lgnd };
|
|
20
31
|
}
|
|
21
|
-
return legend
|
|
22
|
-
|
|
32
|
+
return Object.keys(lgnd)?.reduce((legend, key) => {
|
|
33
|
+
if (key === "domainProperties") {
|
|
34
|
+
legend["domain"] = lgnd[key].map((k) => flatData[k]);
|
|
35
|
+
} else {
|
|
36
|
+
legend[key] = lgnd[key];
|
|
37
|
+
}
|
|
38
|
+
return legend;
|
|
39
|
+
}, /** @type {import("../components/layer-legend").LegendConfig} */ ({}));
|
|
40
|
+
});
|
|
23
41
|
};
|
|
24
42
|
|
|
25
43
|
export default getLegendConfig;
|
|
@@ -40,7 +40,7 @@ export default function (jsonformOutput, layer, layerConfig) {
|
|
|
40
40
|
export const flattenObject = (obj) => {
|
|
41
41
|
/**
|
|
42
42
|
* the flattened object to be returned
|
|
43
|
-
* @type {Record<string,
|
|
43
|
+
* @type {Record<string,any>} */
|
|
44
44
|
const flat = {};
|
|
45
45
|
// loop through the keys of the object
|
|
46
46
|
for (const key in obj) {
|
|
@@ -82,7 +82,6 @@ function updateVectorLayerStyle(styles) {
|
|
|
82
82
|
for (const key in variables) {
|
|
83
83
|
// ol styles expects numbers to be assigned as typeof number
|
|
84
84
|
if (typeof variables[key] === "number") {
|
|
85
|
-
//@ts-expect-error ol styles expects number values to be assigned as type number
|
|
86
85
|
rawStyle = rawStyle.replaceAll(`["var","${key}"]`, variables[key]);
|
|
87
86
|
} else {
|
|
88
87
|
// replace all styles variables set of the specific key with the variables value
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Partial<import("./layer-legend").LegendConfig> & {
|
|
3
|
+
* range:string[];
|
|
4
|
+
* domainProperties:string[]
|
|
5
|
+
* }} layerConfigLegend
|
|
6
|
+
**/
|
|
1
7
|
/**
|
|
2
8
|
* `EOxLayerControlLayerConfig` is a component that handles configuration options for layers using eox-jsonform.
|
|
3
9
|
* It allows users to input data, modify layer settings, and update the UI based on those settings.
|
|
@@ -48,10 +54,7 @@ export class EOxLayerControlLayerConfig extends LitElement {
|
|
|
48
54
|
* element: string;
|
|
49
55
|
* type?:"tileUrl"|"style";
|
|
50
56
|
* style?:import("ol/layer/WebGLTile").Style
|
|
51
|
-
* legend?:
|
|
52
|
-
* range:string[];
|
|
53
|
-
* domainProperties:string[]
|
|
54
|
-
* }
|
|
57
|
+
* legend?: layerConfigLegend | (layerConfigLegend & { boundTo:{key:string;value:string|number|boolean} })[]
|
|
55
58
|
* }}
|
|
56
59
|
*/
|
|
57
60
|
layerConfig: {
|
|
@@ -59,10 +62,12 @@ export class EOxLayerControlLayerConfig extends LitElement {
|
|
|
59
62
|
element: string;
|
|
60
63
|
type?: "tileUrl" | "style";
|
|
61
64
|
style?: import("ol/layer/WebGLTile").Style;
|
|
62
|
-
legend?:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
legend?: layerConfigLegend | (layerConfigLegend & {
|
|
66
|
+
boundTo: {
|
|
67
|
+
key: string;
|
|
68
|
+
value: string | number | boolean;
|
|
69
|
+
};
|
|
70
|
+
})[];
|
|
66
71
|
};
|
|
67
72
|
/**
|
|
68
73
|
* Throttle #handleDataChange() by 1000 milliseconds
|
|
@@ -78,5 +83,9 @@ export class EOxLayerControlLayerConfig extends LitElement {
|
|
|
78
83
|
render(): import("lit-html").TemplateResult<1>;
|
|
79
84
|
#private;
|
|
80
85
|
}
|
|
86
|
+
export type layerConfigLegend = Partial<import("./layer-legend").LegendConfig> & {
|
|
87
|
+
range: string[];
|
|
88
|
+
domainProperties: string[];
|
|
89
|
+
};
|
|
81
90
|
import { LitElement } from "lit";
|
|
82
91
|
//# sourceMappingURL=layer-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer-config.d.ts","sourceRoot":"","sources":["../../../../src/components/layer-config.js"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH;IAEE;;;;;;;;;;;;;MAKE;IA0BA;;;;;OAKG;IACH,OAHU,OAAO,UAAU,EAAE,KAAK,CAGjB;IAEjB;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,kBAAqB;IAErB
|
|
1
|
+
{"version":3,"file":"layer-config.d.ts","sourceRoot":"","sources":["../../../../src/components/layer-config.js"],"names":[],"mappings":"AAOA;;;;;IAKI;AAEJ;;;;;;;GAOG;AACH;IAEE;;;;;;;;;;;;;MAKE;IA0BA;;;;;OAKG;IACH,OAHU,OAAO,UAAU,EAAE,KAAK,CAGjB;IAEjB;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,kBAAqB;IAErB;;;;;;;;;;OAUG;IACH,aARU;QACT,MAAS,EAAE,OAAO,MAAM,EAAC,GAAG,CAAC,CAAC;QAC9B,OAAU,EAAE,MAAM,CAAC;QACnB,IAAO,CAAC,EAAC,SAAS,GAAC,OAAO,CAAC;QAC3B,KAAQ,CAAC,EAAC,OAAO,oBAAoB,EAAE,KAAK,CAAA;QAC5C,MAAS,CAAC,EAAE,iBAAiB,GAAG,CAAC,iBAAiB,GAAG;YAAE,OAAO,EAAC;gBAAC,GAAG,EAAC,MAAM,CAAC;gBAAA,KAAK,EAAC,MAAM,GAAC,MAAM,GAAC,OAAO,CAAA;aAAC,CAAA;SAAE,CAAC,EAAE,CAAA;KACxG,CAEkB;IAEvB;;OAEG;IACH,8DAqBW;QAAE,MAAM,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;SAAE,CAAC;KAAE,WArBuB;IAsDnE;;OAEG;IACH,+CAgDC;;CAYF;gCA1MY,QAAQ,OAAO,gBAAgB,EAAE,YAAY,CAAC,GAAG;IAC7D,KAAW,EAAC,MAAM,EAAE,CAAC;IACrB,gBAAsB,EAAC,MAAM,EAAE,CAAA;CACzB;2BAX+B,KAAK"}
|
|
@@ -48,10 +48,10 @@ export class EOxLayerControlLayerLegend extends LitElement {
|
|
|
48
48
|
noShadow: boolean;
|
|
49
49
|
/**
|
|
50
50
|
* Legend configurations
|
|
51
|
-
* @type {LegendConfig}
|
|
51
|
+
* @type {LegendConfig | LegendConfig[]}
|
|
52
52
|
* @see {@link https://clhenrick.github.io/color-legend-element/}
|
|
53
53
|
*/
|
|
54
|
-
layerLegend: LegendConfig;
|
|
54
|
+
layerLegend: LegendConfig | LegendConfig[];
|
|
55
55
|
/**
|
|
56
56
|
* The native OL layer
|
|
57
57
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer-legend.d.ts","sourceRoot":"","sources":["../../../../src/components/layer-legend.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;IAcI;AAEJ;;;;;GAKG;AACH;IAEE;;;;;;;;;;;;;MAKE;IAKA;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,aAHU,YAAY,
|
|
1
|
+
{"version":3,"file":"layer-legend.d.ts","sourceRoot":"","sources":["../../../../src/components/layer-legend.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;IAcI;AAEJ;;;;;GAKG;AACH;IAEE;;;;;;;;;;;;;MAKE;IAKA;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,aAHU,YAAY,GAAG,YAAY,EAAE,CAGhB;IAEvB;;;;;OAKG;IACH,OAHU,OAAO,UAAU,EAAE,KAAK,CAGjB;IAUnB,qBAUC;IAED;;OAEG;IACH,+CA8DC;;CAaF;;;;2BA9JY;IACZ,MAAU,EAAC,OAAO,sBAAsB,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAA;IACtE,KAAS,CAAC,EAAC,MAAM,CAAC;IAClB,KAAS,EAAC,MAAM,EAAE,CAAC;IACnB,KAAS,CAAC,EAAC,MAAM,CAAC;IAClB,UAAc,CAAC,EAAC,OAAO,sBAAsB,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAA;IAC/E,KAAS,CAAC,EAAC,OAAO,sBAAsB,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAA;IACrE,UAAc,CAAC,EAAC,OAAO,sBAAsB,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAA;IAC/E,SAAa,CAAC,EAAC,OAAO,sBAAsB,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAA;IAC7E,QAAY,CAAC,EAAC,OAAO,sBAAsB,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAA;CACxE;2BAjBkC,KAAK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { STORIES_LAYER_S2, STORIES_LAYER_OSM, STORIES_LAYER_REGION, STORIES_LAYER_SENTINEL_HUB, STORIES_MAIN_MAP_LAYERS, STORIES_MAP_STYLE, STORIES_LAYER_EOX_CLOUDLESS_2021, STORIES_LAYER_EOX_CLOUDLESS_2020, STORIES_LAYER_EOX_CLOUDLESS_2019, STORIES_LAYER_DEFORESTED_BIOMASS, STORIES_LAYER_TERRAIN_LIGHT, STORIES_LAYER_VESSEL_DENSITY_CARGO, STORIES_LAYER_CROPOMHUSC2, STORIES_LAYER_SEE } from "./stories";
|
|
1
|
+
export { STORIES_LAYER_S2, STORIES_LAYER_OSM, STORIES_LAYER_REGION, STORIES_LAYER_SENTINEL_HUB, STORIES_MAIN_MAP_LAYERS, STORIES_MAP_STYLE, STORIES_LAYER_EOX_CLOUDLESS_2021, STORIES_LAYER_EOX_CLOUDLESS_2020, STORIES_LAYER_EOX_CLOUDLESS_2019, STORIES_LAYER_DEFORESTED_BIOMASS, STORIES_LAYER_TERRAIN_LIGHT, STORIES_LAYER_VESSEL_DENSITY_CARGO, STORIES_LAYER_CROPOMHUSC2, STORIES_LAYER_SEE, STORIES_LAYER_POLARIS } from "./stories";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|