@eox/layercontrol 1.10.1 → 1.11.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 +903 -744
- package/dist/eox-layercontrol.umd.cjs +144 -139
- package/package.json +5 -5
- package/src/components/add-layers.js +6 -6
- package/src/components/layer-config.js +26 -20
- package/src/components/layer-datetime.js +23 -6
- package/src/components/layer-group.js +9 -9
- package/src/components/layer-legend.js +3 -3
- package/src/components/layer-list.js +9 -9
- package/src/components/layer-tools.js +44 -9
- package/src/components/layer.js +38 -15
- package/src/components/optional-list.js +5 -5
- package/src/components/tools-items.js +12 -6
- package/src/helpers/clean-json-input.js +1 -1
- package/src/helpers/create-sortable.js +8 -0
- package/src/helpers/get-legend-config.js +16 -1
- package/src/helpers/handle-datetime-update.js +31 -5
- package/src/helpers/is-layer-visible-based-on-zoom-state.js +2 -2
- package/src/helpers/is-layer-zoom-state-req.js +2 -2
- package/src/helpers/update-geozarr-band.js +18 -126
- package/src/helpers/update-url.js +3 -3
- package/src/main.js +33 -17
- package/src/methods/add-layer/add-layer.js +7 -0
- package/src/methods/add-layer/wms-search-url.js +1 -1
- package/src/methods/layer/first-updated.js +47 -26
- package/src/methods/layer-config/apply-updated-styles.js +8 -5
- package/src/methods/layer-config/data-change.js +1 -1
- package/src/methods/optional-list/add-to-list.js +1 -1
- package/types/components/add-layers.d.ts +6 -6
- package/types/components/add-layers.d.ts.map +1 -1
- package/types/components/layer-config.d.ts +3 -3
- package/types/components/layer-config.d.ts.map +1 -1
- package/types/components/layer-datetime.d.ts +3 -3
- package/types/components/layer-datetime.d.ts.map +1 -1
- package/types/components/layer-group.d.ts +9 -9
- package/types/components/layer-group.d.ts.map +1 -1
- package/types/components/layer-legend.d.ts +3 -3
- package/types/components/layer-legend.d.ts.map +1 -1
- package/types/components/layer-list.d.ts +9 -9
- package/types/components/layer-list.d.ts.map +1 -1
- package/types/components/layer-tools.d.ts +6 -6
- package/types/components/layer-tools.d.ts.map +1 -1
- package/types/components/layer.d.ts +9 -14
- package/types/components/layer.d.ts.map +1 -1
- package/types/components/optional-list.d.ts +5 -5
- package/types/components/optional-list.d.ts.map +1 -1
- package/types/components/tools-items.d.ts +5 -5
- package/types/components/tools-items.d.ts.map +1 -1
- package/types/helpers/clean-json-input.d.ts +1 -1
- package/types/helpers/clean-json-input.d.ts.map +1 -1
- package/types/helpers/create-sortable.d.ts.map +1 -1
- package/types/helpers/get-legend-config.d.ts.map +1 -1
- package/types/helpers/handle-datetime-update.d.ts +5 -2
- package/types/helpers/handle-datetime-update.d.ts.map +1 -1
- package/types/helpers/is-layer-visible-based-on-zoom-state.d.ts +2 -2
- package/types/helpers/is-layer-visible-based-on-zoom-state.d.ts.map +1 -1
- package/types/helpers/is-layer-zoom-state-req.d.ts +2 -2
- package/types/helpers/is-layer-zoom-state-req.d.ts.map +1 -1
- package/types/helpers/update-geozarr-band.d.ts +3 -21
- package/types/helpers/update-geozarr-band.d.ts.map +1 -1
- package/types/helpers/update-url.d.ts +4 -4
- package/types/helpers/update-url.d.ts.map +1 -1
- package/types/main.d.ts +15 -11
- package/types/main.d.ts.map +1 -1
- package/types/methods/add-layer/add-layer.d.ts.map +1 -1
- package/types/methods/add-layer/wms-search-url.d.ts +1 -1
- package/types/methods/add-layer/wms-search-url.d.ts.map +1 -1
- package/types/methods/layer/first-updated.d.ts +3 -2
- package/types/methods/layer/first-updated.d.ts.map +1 -1
- package/types/methods/layer-config/apply-updated-styles.d.ts +2 -2
- package/types/methods/layer-config/apply-updated-styles.d.ts.map +1 -1
- package/types/methods/layer-config/data-change.d.ts +1 -1
package/src/components/layer.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
* This component encapsulates functionalities for handling layers, their properties, and associated tools within the OpenLayers map context.
|
|
17
17
|
*
|
|
18
18
|
* @element eox-layercontrol-layer
|
|
19
|
-
* @
|
|
19
|
+
* @augments LitElement
|
|
20
20
|
*/
|
|
21
21
|
export class EOxLayerControlLayer extends LitElement {
|
|
22
22
|
// Define static properties for the component
|
|
@@ -42,7 +42,7 @@ export class EOxLayerControlLayer extends LitElement {
|
|
|
42
42
|
/**
|
|
43
43
|
* Represents the current layer visibility based on zoom level.
|
|
44
44
|
*
|
|
45
|
-
* @type {
|
|
45
|
+
* @type {boolean}
|
|
46
46
|
*/
|
|
47
47
|
currLayerVisibilityBasedOnZoom = true;
|
|
48
48
|
|
|
@@ -75,14 +75,14 @@ export class EOxLayerControlLayer extends LitElement {
|
|
|
75
75
|
/**
|
|
76
76
|
* The layer title property
|
|
77
77
|
*
|
|
78
|
-
* @type {
|
|
78
|
+
* @type {string}
|
|
79
79
|
*/
|
|
80
80
|
this.titleProperty = "title";
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Show layer state based on zoom level or not
|
|
84
84
|
*
|
|
85
|
-
* @type {
|
|
85
|
+
* @type {boolean}
|
|
86
86
|
*/
|
|
87
87
|
this.showLayerZoomState = false;
|
|
88
88
|
|
|
@@ -96,35 +96,35 @@ export class EOxLayerControlLayer extends LitElement {
|
|
|
96
96
|
/**
|
|
97
97
|
* Render the element without additional styles
|
|
98
98
|
*
|
|
99
|
-
* @type {
|
|
99
|
+
* @type {boolean}
|
|
100
100
|
*/
|
|
101
101
|
this.unstyled = false;
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* Renders the element without a shadow root
|
|
105
105
|
*
|
|
106
|
-
* @type {
|
|
106
|
+
* @type {boolean}
|
|
107
107
|
*/
|
|
108
108
|
this.noShadow = false;
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* If enabled, the tools section will be rendered as list.
|
|
112
112
|
*
|
|
113
|
-
* @type {
|
|
113
|
+
* @type {boolean}
|
|
114
114
|
*/
|
|
115
115
|
this.toolsAsList = false;
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
* If enabled, toggling the layer visibility will also open/close the layer tools.
|
|
119
119
|
*
|
|
120
|
-
* @type {
|
|
120
|
+
* @type {boolean}
|
|
121
121
|
*/
|
|
122
122
|
this.toolsAutoExpand = false;
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* If enabled, exclusive layers (marked with the property `layerControlExclusive`) will be globally exclusive (default: exclusive within their layer group).
|
|
126
126
|
*
|
|
127
|
-
* @type {
|
|
127
|
+
* @type {boolean}
|
|
128
128
|
*/
|
|
129
129
|
this.globallyExclusiveLayers = false;
|
|
130
130
|
|
|
@@ -162,12 +162,35 @@ export class EOxLayerControlLayer extends LitElement {
|
|
|
162
162
|
return this.noShadow ? this : super.createRenderRoot();
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
/**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
165
|
+
/** @type {(() => void) | undefined} */
|
|
166
|
+
#releaseSubscriptions;
|
|
167
|
+
|
|
168
|
+
connectedCallback() {
|
|
169
|
+
super.connectedCallback();
|
|
170
|
+
if (this.hasUpdated) this.#subscribe();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
disconnectedCallback() {
|
|
174
|
+
this.#releaseSubscriptions?.();
|
|
175
|
+
this.#releaseSubscriptions = undefined;
|
|
176
|
+
super.disconnectedCallback();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** @param {import("lit").PropertyValues} changedProperties */
|
|
180
|
+
updated(changedProperties) {
|
|
181
|
+
if (
|
|
182
|
+
this.isConnected &&
|
|
183
|
+
(changedProperties.has("layer") ||
|
|
184
|
+
changedProperties.has("map") ||
|
|
185
|
+
changedProperties.has("showLayerZoomState"))
|
|
186
|
+
) {
|
|
187
|
+
this.#subscribe();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
#subscribe() {
|
|
192
|
+
this.#releaseSubscriptions?.();
|
|
193
|
+
this.#releaseSubscriptions = firstUpdatedMethod(this);
|
|
171
194
|
}
|
|
172
195
|
|
|
173
196
|
/**
|
|
@@ -8,7 +8,7 @@ import { addToListMethod } from "../methods/optional-list";
|
|
|
8
8
|
* It offers the ability to filter layers based on specific properties and provides a method to handle the addition of selected layers to a list.
|
|
9
9
|
*
|
|
10
10
|
* @element eox-layercontrol-optional-list
|
|
11
|
-
* @
|
|
11
|
+
* @augments LitElement
|
|
12
12
|
*/
|
|
13
13
|
export class EOxLayerControlOptionalList extends LitElement {
|
|
14
14
|
// Define static properties for the component
|
|
@@ -26,7 +26,7 @@ export class EOxLayerControlOptionalList extends LitElement {
|
|
|
26
26
|
/**
|
|
27
27
|
* The layer id property
|
|
28
28
|
*
|
|
29
|
-
* @type {
|
|
29
|
+
* @type {string}
|
|
30
30
|
*/
|
|
31
31
|
this.idProperty = "id";
|
|
32
32
|
|
|
@@ -41,21 +41,21 @@ export class EOxLayerControlOptionalList extends LitElement {
|
|
|
41
41
|
/**
|
|
42
42
|
* The layer title property
|
|
43
43
|
*
|
|
44
|
-
* @type {
|
|
44
|
+
* @type {string}
|
|
45
45
|
*/
|
|
46
46
|
this.titleProperty = "title";
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Render the element without additional styles
|
|
50
50
|
*
|
|
51
|
-
* @type {
|
|
51
|
+
* @type {boolean}
|
|
52
52
|
*/
|
|
53
53
|
this.unstyled = false;
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Renders the element without a shadow root
|
|
57
57
|
*
|
|
58
|
-
* @type {
|
|
58
|
+
* @type {boolean}
|
|
59
59
|
*/
|
|
60
60
|
this.noShadow = false;
|
|
61
61
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement, html } from "lit";
|
|
2
|
+
import { emitActivity, findHost } from "@eox/elements-utils";
|
|
2
3
|
import { when } from "lit/directives/when.js";
|
|
3
4
|
import { map } from "lit/directives/map.js";
|
|
4
5
|
import eoxStyle from "@eox/ui/style.css?inline";
|
|
@@ -20,7 +21,7 @@ export class EOxLayerControlTabs extends LitElement {
|
|
|
20
21
|
/**
|
|
21
22
|
* List of action ids
|
|
22
23
|
*
|
|
23
|
-
* @type {Array<
|
|
24
|
+
* @type {Array<string>}
|
|
24
25
|
*/
|
|
25
26
|
this.actions = [];
|
|
26
27
|
|
|
@@ -29,28 +30,28 @@ export class EOxLayerControlTabs extends LitElement {
|
|
|
29
30
|
/**
|
|
30
31
|
* List of tab ids
|
|
31
32
|
*
|
|
32
|
-
* @type {Array<
|
|
33
|
+
* @type {Array<string>}
|
|
33
34
|
*/
|
|
34
35
|
this.tabs = [];
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* Render the element without additional styles
|
|
38
39
|
*
|
|
39
|
-
* @type {
|
|
40
|
+
* @type {boolean}
|
|
40
41
|
*/
|
|
41
42
|
this.unstyled = false;
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
* Renders the element without a shadow root
|
|
45
46
|
*
|
|
46
|
-
* @type {
|
|
47
|
+
* @type {boolean}
|
|
47
48
|
*/
|
|
48
49
|
this.noShadow = false;
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* If enabled, the tools section will be rendered as list.
|
|
52
53
|
*
|
|
53
|
-
* @type {
|
|
54
|
+
* @type {boolean}
|
|
54
55
|
*/
|
|
55
56
|
this.toolsAsList = false;
|
|
56
57
|
}
|
|
@@ -96,7 +97,12 @@ export class EOxLayerControlTabs extends LitElement {
|
|
|
96
97
|
(tab, index) => html`
|
|
97
98
|
<label
|
|
98
99
|
class=${this.#labelHighlightClass(index)}
|
|
99
|
-
@click=${(
|
|
100
|
+
@click=${(/** @type {MouseEvent} */ e) => {
|
|
101
|
+
this.selectedTab = index;
|
|
102
|
+
const root =
|
|
103
|
+
findHost(this, "eox-layercontrol") || this;
|
|
104
|
+
emitActivity(root, "select:tool", { tool: tab }, e);
|
|
105
|
+
}}
|
|
100
106
|
>
|
|
101
107
|
<!-- Customizable icon for each tab -->
|
|
102
108
|
<slot name=${`${tab}-icon`}>${tab}</slot>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Cleans up the input string to ensure valid JSON format and triggers an update.
|
|
3
3
|
*
|
|
4
4
|
* @param {string} json - JSON Input string
|
|
5
|
-
* @
|
|
5
|
+
* @returns {string} - Cleaned and valid JSON string
|
|
6
6
|
*/
|
|
7
7
|
export default function cleanJSONInput(json) {
|
|
8
8
|
// Extracts the value entered in the input field
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Sortable from "sortablejs";
|
|
2
|
+
import { emitActivity, findHost } from "@eox/elements-utils";
|
|
2
3
|
|
|
3
4
|
/** @param {Sortable.SortableEvent} e */
|
|
4
5
|
const onStart = (e) => {
|
|
@@ -67,6 +68,13 @@ const onEnd = (e, that, childNodes, collection, idProperty, related) => {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
|
|
71
|
+
const root = findHost(that, "eox-layercontrol") || that;
|
|
72
|
+
emitActivity(root, "sort:layer", {
|
|
73
|
+
layer: layerId,
|
|
74
|
+
oldIndex: e.oldIndex,
|
|
75
|
+
newIndex: e.newIndex,
|
|
76
|
+
});
|
|
77
|
+
|
|
70
78
|
that.requestUpdate();
|
|
71
79
|
};
|
|
72
80
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { flattenObject } from "../methods/layer-config";
|
|
2
|
+
import { computeLegendTickFormat } from "@eox/elements-utils";
|
|
2
3
|
/**
|
|
3
4
|
* extracts legend configurations from `LayerConfig`
|
|
4
5
|
*
|
|
@@ -68,7 +69,21 @@ const getLegendConfig = (legendConfig, data, colormapRegistry) => {
|
|
|
68
69
|
}
|
|
69
70
|
return Object.keys(activeLegend)?.reduce((legend, key) => {
|
|
70
71
|
if (key === "domainProperties") {
|
|
71
|
-
|
|
72
|
+
const domain = activeLegend[key].map((k) => flatData[k]);
|
|
73
|
+
legend["domain"] = domain;
|
|
74
|
+
if (
|
|
75
|
+
activeLegend.tickFormat === undefined &&
|
|
76
|
+
domain.length === 2 &&
|
|
77
|
+
typeof domain[0] === "number" &&
|
|
78
|
+
typeof domain[1] === "number" &&
|
|
79
|
+
Number.isFinite(domain[0]) &&
|
|
80
|
+
Number.isFinite(domain[1])
|
|
81
|
+
) {
|
|
82
|
+
legend["tickFormat"] = computeLegendTickFormat([
|
|
83
|
+
domain[0],
|
|
84
|
+
domain[1],
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
72
87
|
} else {
|
|
73
88
|
legend[key] = activeLegend[key];
|
|
74
89
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { dispatchElementEvent } from "@eox/elements-utils";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Moves a sliced layer (e.g. GeoZarr) to the time slice mapped to the given datetime
|
|
3
5
|
* @param {import("ol/layer").Layer} layer
|
|
@@ -13,11 +15,35 @@ export function updateLayerSlice(layer, datetime) {
|
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Dispatches datetime updates from layer datetime to the layercontrol
|
|
16
|
-
* @param {CustomEvent} evt
|
|
18
|
+
* @param {CustomEvent & { isUser?: boolean }} evt
|
|
17
19
|
* @param {HTMLElement} element
|
|
20
|
+
* @param {boolean} [activity=false]
|
|
18
21
|
*/
|
|
19
|
-
export function handleDatetimeUpdate(evt, element) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
export function handleDatetimeUpdate(evt, element, activity = false) {
|
|
23
|
+
evt.stopPropagation();
|
|
24
|
+
if (!activity) {
|
|
25
|
+
const event = Object.assign(
|
|
26
|
+
new CustomEvent("datetime:updated", {
|
|
27
|
+
detail: evt.detail,
|
|
28
|
+
bubbles: true,
|
|
29
|
+
composed: true,
|
|
30
|
+
}),
|
|
31
|
+
{ isUser: evt.isUser === true },
|
|
32
|
+
);
|
|
33
|
+
/**
|
|
34
|
+
* Forwards datetime:updated while preserving attribution without child telemetry.
|
|
35
|
+
*/
|
|
36
|
+
element.dispatchEvent(event);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Fires the public datetime:updated event and activity only for user selections.
|
|
41
|
+
*/
|
|
42
|
+
dispatchElementEvent(element, "datetime:updated", {
|
|
43
|
+
detail: evt.detail,
|
|
44
|
+
bubbles: true,
|
|
45
|
+
composed: true,
|
|
46
|
+
activity: evt.isUser === true,
|
|
47
|
+
action: "datetime:updated",
|
|
48
|
+
});
|
|
23
49
|
}
|
|
@@ -6,8 +6,8 @@ import { isLayerZoomStateRequired } from ".";
|
|
|
6
6
|
*
|
|
7
7
|
* @param {import("ol/layer").Layer | import("ol/layer").Group} layer - The layer or layer group to check visibility for.
|
|
8
8
|
* @param {import("ol").Map} map - The map instance to retrieve the current zoom level.
|
|
9
|
-
* @param {
|
|
10
|
-
* @returns {
|
|
9
|
+
* @param {boolean} showLayerZoomState - Flag indicating if zoom-based visibility is enabled.
|
|
10
|
+
* @returns {boolean} - The visibility state of the layer based on zoom levels.
|
|
11
11
|
*/
|
|
12
12
|
export default function isLayerVisibleBasedOnZoomState(
|
|
13
13
|
layer,
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Returns whether zoom layer state be enabled or not for a particular layer
|
|
3
3
|
*
|
|
4
4
|
* @param {import("ol/layer").Layer | import("ol/layer").Group} layer - The layer or layer group to check for zoom-based visibility.
|
|
5
|
-
* @param {
|
|
6
|
-
* @returns {
|
|
5
|
+
* @param {boolean} showLayerZoomState - Flag indicating if zoom-based visibility is requested.
|
|
6
|
+
* @returns {boolean} - Indicates if the zoom-based layer visibility state is required.
|
|
7
7
|
*/
|
|
8
8
|
export default function isLayerZoomStateRequired(layer, showLayerZoomState) {
|
|
9
9
|
// Retrieve minimum and maximum zoom levels set for the layer
|
|
@@ -1,93 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const diff = Math.abs(max - min);
|
|
9
|
-
if (diff === 0) return 0.01;
|
|
10
|
-
if (diff <= 0.01) return 0.0001;
|
|
11
|
-
if (diff <= 0.1) return 0.001;
|
|
12
|
-
if (diff <= 1) return 0.01;
|
|
13
|
-
if (diff <= 10) return 0.1;
|
|
14
|
-
return 1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Builds schema property definitions for min and max controls based on valid_range.
|
|
19
|
-
* If validRange is available, uses number inputs with native incrementing buttons (format: "number").
|
|
20
|
-
* If no validRange is available, uses range sliders (format: "range").
|
|
21
|
-
*
|
|
22
|
-
* @param {number} [min]
|
|
23
|
-
* @param {number} [max]
|
|
24
|
-
* @param {number[] | null | undefined} [validRange]
|
|
25
|
-
* @returns {{ minProp: Record<string, any>, maxProp: Record<string, any> }}
|
|
26
|
-
*/
|
|
27
|
-
export function buildMinMaxProperties(min, max, validRange) {
|
|
28
|
-
const hasValidRange =
|
|
29
|
-
Array.isArray(validRange) &&
|
|
30
|
-
validRange.length === 2 &&
|
|
31
|
-
typeof validRange[0] === "number" &&
|
|
32
|
-
typeof validRange[1] === "number" &&
|
|
33
|
-
!Number.isNaN(validRange[0]) &&
|
|
34
|
-
!Number.isNaN(validRange[1]);
|
|
1
|
+
import {
|
|
2
|
+
computeStep,
|
|
3
|
+
roundRangeBounds,
|
|
4
|
+
buildMinMaxProperties,
|
|
5
|
+
applyMinMaxToSchemaProperties,
|
|
6
|
+
applyLayerStyleVariables,
|
|
7
|
+
} from "@eox/elements-utils";
|
|
35
8
|
|
|
36
|
-
|
|
37
|
-
const rangeMin = validRange[0];
|
|
38
|
-
const rangeMax = validRange[1];
|
|
39
|
-
const step = computeStep(rangeMin, rangeMax);
|
|
40
|
-
const resolvedMin = min !== undefined ? min : rangeMin;
|
|
41
|
-
const resolvedMax = max !== undefined ? max : rangeMax;
|
|
42
|
-
return {
|
|
43
|
-
minProp: {
|
|
44
|
-
type: "number",
|
|
45
|
-
format: "number",
|
|
46
|
-
title: "Min Value",
|
|
47
|
-
default: resolvedMin,
|
|
48
|
-
minimum: rangeMin,
|
|
49
|
-
maximum: rangeMax,
|
|
50
|
-
step,
|
|
51
|
-
},
|
|
52
|
-
maxProp: {
|
|
53
|
-
type: "number",
|
|
54
|
-
format: "number",
|
|
55
|
-
title: "Max Value",
|
|
56
|
-
default: resolvedMax,
|
|
57
|
-
minimum: rangeMin,
|
|
58
|
-
maximum: rangeMax,
|
|
59
|
-
step,
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const resolvedMin = min !== undefined ? min : 0;
|
|
65
|
-
const resolvedMax = max !== undefined ? max : 1;
|
|
66
|
-
const sliderMin = typeof min === "number" ? Math.min(0, min) : 0;
|
|
67
|
-
const sliderMax =
|
|
68
|
-
typeof max === "number" && max > sliderMin ? max : sliderMin + 1;
|
|
69
|
-
const step = computeStep(sliderMin, sliderMax);
|
|
70
|
-
return {
|
|
71
|
-
minProp: {
|
|
72
|
-
type: "number",
|
|
73
|
-
format: "range",
|
|
74
|
-
title: "Min Value",
|
|
75
|
-
default: resolvedMin,
|
|
76
|
-
minimum: sliderMin,
|
|
77
|
-
maximum: sliderMax,
|
|
78
|
-
step,
|
|
79
|
-
},
|
|
80
|
-
maxProp: {
|
|
81
|
-
type: "number",
|
|
82
|
-
format: "range",
|
|
83
|
-
title: "Max Value",
|
|
84
|
-
default: resolvedMax,
|
|
85
|
-
minimum: sliderMin,
|
|
86
|
-
maximum: sliderMax,
|
|
87
|
-
step,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
}
|
|
9
|
+
export { computeStep, buildMinMaxProperties };
|
|
91
10
|
|
|
92
11
|
/**
|
|
93
12
|
* Resolves the target min and max range for a given GeoZarr band.
|
|
@@ -116,8 +35,7 @@ export function getGeoZarrBandRange(layer, band, _layerConfig) {
|
|
|
116
35
|
!Number.isNaN(validRange[0]) &&
|
|
117
36
|
!Number.isNaN(validRange[1])
|
|
118
37
|
) {
|
|
119
|
-
targetMin = validRange[0];
|
|
120
|
-
targetMax = validRange[1];
|
|
38
|
+
[targetMin, targetMax] = roundRangeBounds([validRange[0], validRange[1]]);
|
|
121
39
|
}
|
|
122
40
|
|
|
123
41
|
return {
|
|
@@ -205,11 +123,6 @@ export async function updateGeoZarrBand(layer, newBand) {
|
|
|
205
123
|
? layer.get("_geozarrVariables")
|
|
206
124
|
: layer?._geozarrVariables;
|
|
207
125
|
const validRange = geozarrVars?.[newBand]?.valid_range;
|
|
208
|
-
const { minProp, maxProp } = buildMinMaxProperties(
|
|
209
|
-
targetMin,
|
|
210
|
-
targetMax,
|
|
211
|
-
validRange,
|
|
212
|
-
);
|
|
213
126
|
|
|
214
127
|
// 3. Update layerConfig (bands, min, max)
|
|
215
128
|
let updatedLayerConfig = layerConfig;
|
|
@@ -238,20 +151,14 @@ export async function updateGeoZarrBand(layer, newBand) {
|
|
|
238
151
|
!!props.redMax || !!props.greenMax || !!props.blueMax;
|
|
239
152
|
|
|
240
153
|
if (!isMultiChannel) {
|
|
241
|
-
|
|
242
|
-
props
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
props.max = {
|
|
250
|
-
...(props.max || {}),
|
|
251
|
-
...maxProp,
|
|
252
|
-
default: targetMax,
|
|
253
|
-
};
|
|
254
|
-
}
|
|
154
|
+
applyMinMaxToSchemaProperties(
|
|
155
|
+
props,
|
|
156
|
+
targetMin,
|
|
157
|
+
targetMax,
|
|
158
|
+
validRange,
|
|
159
|
+
isAutofill,
|
|
160
|
+
true,
|
|
161
|
+
);
|
|
255
162
|
}
|
|
256
163
|
}
|
|
257
164
|
|
|
@@ -291,22 +198,7 @@ export async function updateGeoZarrBand(layer, newBand) {
|
|
|
291
198
|
layerConfig?.schema?.properties?.max !== undefined;
|
|
292
199
|
|
|
293
200
|
if (hasMinMaxStyle) {
|
|
294
|
-
|
|
295
|
-
layer.updateStyleVariables({ min: targetMin, max: targetMax });
|
|
296
|
-
}
|
|
297
|
-
if (layer.styleVariables_) {
|
|
298
|
-
layer.styleVariables_.min = targetMin;
|
|
299
|
-
layer.styleVariables_.max = targetMax;
|
|
300
|
-
}
|
|
301
|
-
if (layer.style_?.variables) {
|
|
302
|
-
layer.style_.variables.min = targetMin;
|
|
303
|
-
layer.style_.variables.max = targetMax;
|
|
304
|
-
}
|
|
305
|
-
const styleObj = layer.get?.("style");
|
|
306
|
-
if (styleObj?.variables) {
|
|
307
|
-
styleObj.variables.min = targetMin;
|
|
308
|
-
styleObj.variables.max = targetMax;
|
|
309
|
-
}
|
|
201
|
+
applyLayerStyleVariables(layer, { min: targetMin, max: targetMax });
|
|
310
202
|
}
|
|
311
203
|
|
|
312
204
|
// 5. Update dimensions (time and non-temporal extra dimensions)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Updates the layer's URL using input values and returns the modified URL.
|
|
3
3
|
*
|
|
4
|
-
* @param {
|
|
5
|
-
* @param {
|
|
6
|
-
* @returns {
|
|
4
|
+
* @param {string} url - The original URL to be updated.
|
|
5
|
+
* @param {object} values - The key-value pairs to update in the URL.
|
|
6
|
+
* @returns {string} - The updated URL based on the provided values.
|
|
7
7
|
*/
|
|
8
8
|
export default function updateUrl(url, values) {
|
|
9
9
|
// Create a search params object from the URL
|