@fxi/zartigl 0.14.0 → 0.14.2
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 +17 -1
- package/dist/catalog.d.ts +17 -0
- package/dist/catalog.js +20 -19
- package/dist/{engine-CiDquHYk.js → engine-C8ZNzILO.js} +2 -2
- package/dist/engine.d.ts +56 -2
- package/dist/engine.js +1 -1
- package/dist/{index-Cd7Nk4ve.js → index-B1lj-XR_.js} +169 -147
- package/dist/zartigl.d.ts +50 -1
- package/dist/zartigl.js +605 -558
- package/package.json +10 -4
package/dist/zartigl.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { m as ae, p as
|
|
2
|
-
import { T as
|
|
3
|
-
import { O as
|
|
4
|
-
import { B as
|
|
5
|
-
import { f as
|
|
6
|
-
import { inflate as
|
|
7
|
-
import
|
|
8
|
-
const Ie = 85,
|
|
1
|
+
import { m as ae, p as pt, s as gt, a as qe, b as Bt, r as ze, c as $t, d as he, e as qt, f as vt, g as Wt } from "./index-B1lj-XR_.js";
|
|
2
|
+
import { T as Xt, g as Ht, r as Yt, d as Zt, c as W, a as jt, b as ge, e as Qt, f as J, h as Se, i as O, G as Kt, j as We, F as Jt, s as yt, v as Q, k as K, l as Ge, m as Oe, n as _t, o as Xe, p as Ce, q as ei, t as ke, u as ti, w as xt, x as z, y as He, z as we, A as ii, B as ai, C as si, D as Ye, E as ri, H as Fe, I as ni, J as bt, K as oi, L as li, M as ci, N as hi } from "./engine-C8ZNzILO.js";
|
|
3
|
+
import { O as Na, P as za } from "./engine-C8ZNzILO.js";
|
|
4
|
+
import { B as ui, a as di, b as mi, c as fi, d as St, r as wt, e as pi, g as gi } from "./backdrop-Dceb4d8E.js";
|
|
5
|
+
import { f as Oa, i as Ba } from "./backdrop-Dceb4d8E.js";
|
|
6
|
+
import { inflate as vi } from "pako";
|
|
7
|
+
import yi from "numcodecs/blosc";
|
|
8
|
+
const Ie = 85, _i = 89.9;
|
|
9
9
|
function Ue(s) {
|
|
10
10
|
return Math.max(-Ie, Math.min(Ie, s));
|
|
11
11
|
}
|
|
@@ -16,24 +16,33 @@ function Ze(s) {
|
|
|
16
16
|
function ve(s) {
|
|
17
17
|
return (s + 180) / 360;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function xi(s) {
|
|
20
20
|
return ((s + 180) % 360 + 360) % 360 - 180;
|
|
21
21
|
}
|
|
22
|
+
function Tt(s, e, t, i) {
|
|
23
|
+
const a = (o, l, d) => d > l ? Math.abs(o[d] - o[l]) / (d - l) / 2 : o.length > 1 ? Math.abs(o[1] - o[0]) / 2 : 0, r = a(s, t[0], t[1]), n = a(e, i[0], i[1]);
|
|
24
|
+
return {
|
|
25
|
+
west: s[t[0]] - r,
|
|
26
|
+
east: s[t[1]] + r,
|
|
27
|
+
south: Math.min(e[i[0]], e[i[1]]) - n,
|
|
28
|
+
north: Math.max(e[i[0]], e[i[1]]) + n
|
|
29
|
+
};
|
|
30
|
+
}
|
|
22
31
|
function ye(s, e) {
|
|
23
32
|
if (s.getProjection?.()?.type !== "globe")
|
|
24
33
|
return !1;
|
|
25
34
|
const t = e?.projectionTransition;
|
|
26
35
|
return typeof t == "number" ? t > 0 : !0;
|
|
27
36
|
}
|
|
28
|
-
function
|
|
29
|
-
const t =
|
|
37
|
+
function bi(s, e) {
|
|
38
|
+
const t = xi(s) * Math.PI / 180, i = e * Math.PI / 180, a = Math.cos(i);
|
|
30
39
|
return [
|
|
31
40
|
Math.sin(t) * a,
|
|
32
41
|
Math.sin(i),
|
|
33
42
|
Math.cos(t) * a
|
|
34
43
|
];
|
|
35
44
|
}
|
|
36
|
-
function
|
|
45
|
+
function Si(s) {
|
|
37
46
|
return {
|
|
38
47
|
west: -180,
|
|
39
48
|
east: 180,
|
|
@@ -41,19 +50,19 @@ function xi(s) {
|
|
|
41
50
|
north: Ue(s.getNorth())
|
|
42
51
|
};
|
|
43
52
|
}
|
|
44
|
-
function
|
|
45
|
-
const i = t ?
|
|
53
|
+
function wi(s, e = 1, t = !1) {
|
|
54
|
+
const i = t ? _i : Ie, a = (d) => Math.max(-i, Math.min(i, d)), r = a(s.getSouth()), n = a(s.getNorth()), l = Math.max(0, n - r) * Math.max(0, e);
|
|
46
55
|
return {
|
|
47
56
|
west: -180,
|
|
48
57
|
east: 180,
|
|
49
|
-
south: a(r -
|
|
50
|
-
north: a(n +
|
|
58
|
+
south: a(r - l),
|
|
59
|
+
north: a(n + l)
|
|
51
60
|
};
|
|
52
61
|
}
|
|
53
|
-
function
|
|
62
|
+
function Ti(s, e, t = 1e-6) {
|
|
54
63
|
return s.south <= e.south + t && s.north >= e.north - t;
|
|
55
64
|
}
|
|
56
|
-
function
|
|
65
|
+
function Mi(s, e = !1) {
|
|
57
66
|
const t = s.getWest(), i = s.getEast(), a = ve(t), r = ve(i), n = a - Math.floor(a), o = r - a >= 1 ? { minX: 0, maxX: 1 } : { minX: n, maxX: n + r - a };
|
|
58
67
|
return e ? {
|
|
59
68
|
...o,
|
|
@@ -95,7 +104,7 @@ out vec2 v_tex_coord;
|
|
|
95
104
|
void main() {
|
|
96
105
|
v_tex_coord = a_position * 0.5 + 0.5;
|
|
97
106
|
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
98
|
-
}`,
|
|
107
|
+
}`, Ri = `#version 300 es
|
|
99
108
|
precision highp float;
|
|
100
109
|
|
|
101
110
|
uint pcg(uint v) {
|
|
@@ -365,7 +374,7 @@ void main() {
|
|
|
365
374
|
fract(newPos.y * 255.0)
|
|
366
375
|
);
|
|
367
376
|
#endif
|
|
368
|
-
}`,
|
|
377
|
+
}`, Pi = `precision highp float;
|
|
369
378
|
|
|
370
379
|
attribute float a_index;
|
|
371
380
|
attribute float a_is_curr;
|
|
@@ -597,7 +606,7 @@ void main() {
|
|
|
597
606
|
vec2 worldPos = vec2((pos.x + u_world_offset) * u_world_size, pos.y * u_world_size);
|
|
598
607
|
gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
|
|
599
608
|
}
|
|
600
|
-
}`,
|
|
609
|
+
}`, Ei = `precision mediump float;
|
|
601
610
|
|
|
602
611
|
uniform sampler2D u_color_ramp;
|
|
603
612
|
uniform float u_particle_contrast;
|
|
@@ -636,7 +645,7 @@ void main() {
|
|
|
636
645
|
}
|
|
637
646
|
|
|
638
647
|
gl_FragColor = vec4(color.rgb, color.a * u_opacity);
|
|
639
|
-
}`,
|
|
648
|
+
}`, Li = `#version 300 es
|
|
640
649
|
precision mediump float;
|
|
641
650
|
|
|
642
651
|
uniform sampler2D u_screen;
|
|
@@ -653,7 +662,7 @@ void main() {
|
|
|
653
662
|
float alpha = floor(color.a * 255.0 * u_opacity) / 255.0;
|
|
654
663
|
|
|
655
664
|
o_color = vec4(color.rgb * step(1.0 / 255.0, alpha), alpha);
|
|
656
|
-
}`,
|
|
665
|
+
}`, Di = `#version 300 es
|
|
657
666
|
precision mediump float;
|
|
658
667
|
|
|
659
668
|
uniform sampler2D u_screen;
|
|
@@ -724,7 +733,7 @@ void main() {
|
|
|
724
733
|
}
|
|
725
734
|
vec3 rgb = u_grade_on > 0.5 ? gradeColor(color.rgb, u_grade) : color.rgb;
|
|
726
735
|
o_color = vec4(rgb, color.a);
|
|
727
|
-
}`,
|
|
736
|
+
}`, Ai = `#version 300 es
|
|
728
737
|
precision mediump float;
|
|
729
738
|
|
|
730
739
|
uniform sampler2D u_screen;
|
|
@@ -761,7 +770,7 @@ vec4 addGlow(vec4 trail, sampler2D glowTex, vec2 uv, float gain) {
|
|
|
761
770
|
|
|
762
771
|
void main() {
|
|
763
772
|
o_color = glowGather(u_screen, ivec2(gl_FragCoord.xy));
|
|
764
|
-
}`,
|
|
773
|
+
}`, Mt = `precision highp float;
|
|
765
774
|
|
|
766
775
|
attribute vec2 a_grid_uv;
|
|
767
776
|
|
|
@@ -785,14 +794,17 @@ float latToMercY(float lat) {
|
|
|
785
794
|
}
|
|
786
795
|
|
|
787
796
|
void main() {
|
|
788
|
-
|
|
797
|
+
|
|
798
|
+
float width = u_geo_bounds.z - u_geo_bounds.x;
|
|
799
|
+
float east = width >= 359.0 ? u_geo_bounds.x + 360.0 : u_geo_bounds.z;
|
|
800
|
+
float lng = mix(u_geo_bounds.x, east, a_grid_uv.x);
|
|
789
801
|
float lat = mix(u_geo_bounds.y, u_geo_bounds.w, a_grid_uv.y);
|
|
790
802
|
vec2 merc = vec2(lngToMercX(lng) + u_world_offset, latToMercY(lat));
|
|
791
803
|
vec2 worldPos = merc * u_world_size;
|
|
792
804
|
|
|
793
|
-
v_geo_uv = a_grid_uv;
|
|
805
|
+
v_geo_uv = vec2((lng - u_geo_bounds.x) / width, a_grid_uv.y);
|
|
794
806
|
gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
|
|
795
|
-
}`,
|
|
807
|
+
}`, Ci = `precision mediump float;
|
|
796
808
|
|
|
797
809
|
uniform sampler2D u_field;
|
|
798
810
|
uniform sampler2D u_color_ramp;
|
|
@@ -855,7 +867,8 @@ vec3 sampleVelocityPair(sampler2D field, vec2 uv, vec2 minimum, vec2 maximum) {
|
|
|
855
867
|
}
|
|
856
868
|
|
|
857
869
|
void main() {
|
|
858
|
-
|
|
870
|
+
|
|
871
|
+
if (v_geo_uv.y < 0.0 || v_geo_uv.y > 1.0) {
|
|
859
872
|
discard;
|
|
860
873
|
}
|
|
861
874
|
|
|
@@ -891,7 +904,7 @@ void main() {
|
|
|
891
904
|
vec4 color = texture2D(u_color_ramp, vec2(t, 0.5));
|
|
892
905
|
color.rgb = applyVibrance(color.rgb, u_vibrance);
|
|
893
906
|
gl_FragColor = vec4(color.rgb, color.a * u_opacity);
|
|
894
|
-
}`,
|
|
907
|
+
}`, Rt = `precision highp float;
|
|
895
908
|
|
|
896
909
|
attribute vec2 a_grid_uv;
|
|
897
910
|
|
|
@@ -907,8 +920,15 @@ varying vec2 v_geo_uv;
|
|
|
907
920
|
const float PI = 3.14159265358979323846;
|
|
908
921
|
|
|
909
922
|
void main() {
|
|
910
|
-
|
|
911
|
-
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
float width = u_geo_bounds.z - u_geo_bounds.x;
|
|
928
|
+
float east = width >= 359.0 ? u_geo_bounds.x + 360.0 : u_geo_bounds.z;
|
|
929
|
+
float lng = mix(u_geo_bounds.x, east, a_grid_uv.x);
|
|
930
|
+
|
|
931
|
+
float lat = clamp(mix(u_geo_bounds.y, u_geo_bounds.w, a_grid_uv.y), -90.0, 90.0);
|
|
912
932
|
float lngRad = radians(lng);
|
|
913
933
|
float latRad = radians(lat);
|
|
914
934
|
float cosLat = cos(latRad);
|
|
@@ -918,7 +938,7 @@ void main() {
|
|
|
918
938
|
cos(lngRad) * cosLat
|
|
919
939
|
);
|
|
920
940
|
|
|
921
|
-
v_geo_uv = a_grid_uv;
|
|
941
|
+
v_geo_uv = vec2((lng - u_geo_bounds.x) / width, a_grid_uv.y);
|
|
922
942
|
vec4 position = u_matrix * vec4(ecef, 1.0);
|
|
923
943
|
position.z = (1.0 - (dot(ecef, u_clipping_plane.xyz) + u_clipping_plane.w)) * position.w;
|
|
924
944
|
if (u_projection_transition < 0.999) {
|
|
@@ -934,7 +954,7 @@ void main() {
|
|
|
934
954
|
position.xyw = mix(flatPosition.xyw, position.xyw, u_projection_transition);
|
|
935
955
|
}
|
|
936
956
|
gl_Position = position;
|
|
937
|
-
}`,
|
|
957
|
+
}`, ki = `precision mediump float;
|
|
938
958
|
|
|
939
959
|
uniform sampler2D u_field;
|
|
940
960
|
uniform sampler2D u_color_ramp;
|
|
@@ -1024,8 +1044,8 @@ void main() {
|
|
|
1024
1044
|
color.rgb = applyVibrance(color.rgb, u_vibrance);
|
|
1025
1045
|
gl_FragColor = vec4(color.rgb, color.a * u_opacity);
|
|
1026
1046
|
}`;
|
|
1027
|
-
const Me = [0, 0, 0, 0], B = 512, H = B * B, Y = 128, ee = 64,
|
|
1028
|
-
function
|
|
1047
|
+
const Me = [0, 0, 0, 0], B = 512, H = B * B, Y = 128, ee = 64, Fi = 1, Ii = 0.92, Ui = 0.1, je = 0.98;
|
|
1048
|
+
function Vi(s) {
|
|
1029
1049
|
if (Number.isNaN(s))
|
|
1030
1050
|
return 32256;
|
|
1031
1051
|
if (s === 1 / 0)
|
|
@@ -1042,7 +1062,7 @@ function Ii(s) {
|
|
|
1042
1062
|
const i = Math.floor(Math.log2(t)), a = t / 2 ** i - 1;
|
|
1043
1063
|
return e | i + 15 << 10 | Math.round(a * 1024);
|
|
1044
1064
|
}
|
|
1045
|
-
const
|
|
1065
|
+
const Ni = {
|
|
1046
1066
|
particleDensity: 0.05,
|
|
1047
1067
|
speed: 1,
|
|
1048
1068
|
fadeOpacity: 0.996,
|
|
@@ -1051,26 +1071,26 @@ const Ui = {
|
|
|
1051
1071
|
opacity: 1,
|
|
1052
1072
|
logScale: !1,
|
|
1053
1073
|
vibrance: 0,
|
|
1054
|
-
colorGrade:
|
|
1055
|
-
backdrop:
|
|
1074
|
+
colorGrade: di,
|
|
1075
|
+
backdrop: ui,
|
|
1056
1076
|
glow: 0,
|
|
1057
1077
|
scalarMode: !1,
|
|
1058
1078
|
particleState: "auto",
|
|
1059
1079
|
rgba8MaxParticleZoom: 4
|
|
1060
1080
|
};
|
|
1061
|
-
class
|
|
1081
|
+
class Pt {
|
|
1062
1082
|
constructor(e) {
|
|
1063
|
-
this.numParticles = 0, this.prevBounds = null, this.redistributionBoost = 0, this.frame = Math.floor(Math.random() * 2 ** 30), this.webglInfo = null, this.lastRgba8ParticlesSuppressed = !1, this.screenWidth = 0, this.screenHeight = 0, this.glowTexture = null, this.glowFramebuffer = null, this.rasterGridIndexCount = 0, this.renderMode = "raster+particles", this.params = { ...
|
|
1083
|
+
this.numParticles = 0, this.prevBounds = null, this.redistributionBoost = 0, this.frame = Math.floor(Math.random() * 2 ** 30), this.webglInfo = null, this.lastRgba8ParticlesSuppressed = !1, this.screenWidth = 0, this.screenHeight = 0, this.glowTexture = null, this.glowFramebuffer = null, this.rasterGridIndexCount = 0, this.renderMode = "raster+particles", this.params = { ...Ni, ...e }, this.trailFade = new Xt(this.params.fadeOpacity);
|
|
1064
1084
|
}
|
|
1065
1085
|
init(e) {
|
|
1066
|
-
this.gl = e, this.webglInfo =
|
|
1086
|
+
this.gl = e, this.webglInfo = Ht(e), this.stateFormat = this.params.particleState === "rgba8" ? Yt(e) : Zt(e);
|
|
1067
1087
|
const t = this.stateFormat.kind !== "rgba8-packed" ? `#define USE_FLOAT_STATE 1
|
|
1068
1088
|
` : "";
|
|
1069
1089
|
this.updateProgram = W(
|
|
1070
1090
|
e,
|
|
1071
1091
|
de,
|
|
1072
|
-
|
|
1073
|
-
), this.drawProgram = W(e, t +
|
|
1092
|
+
Ri.replace(/^(#version[^\n]*\n)/, `$1${t}`)
|
|
1093
|
+
), this.drawProgram = W(e, t + Pi, Ei), this.fadeProgram = W(e, de, Li), this.compositeProgram = W(e, de, Di), this.glowProgram = W(e, de, Ai), this.gridProgram = W(e, Mt, Ci), this.gridGlobeProgram = W(e, Rt, ki), this.updateLocs = this.getUniforms(this.updateProgram, [
|
|
1074
1094
|
"u_particles",
|
|
1075
1095
|
...ue,
|
|
1076
1096
|
"u_velocity",
|
|
@@ -1154,7 +1174,7 @@ class Mt {
|
|
|
1154
1174
|
"u_vibrance",
|
|
1155
1175
|
"u_scalar_mode",
|
|
1156
1176
|
"u_solid"
|
|
1157
|
-
]), this.quadBuffer =
|
|
1177
|
+
]), this.quadBuffer = jt(e), this.initRasterGrid(), this.colorRampTexture = ge(e, this.params.colorRamp), this.initParticleState();
|
|
1158
1178
|
}
|
|
1159
1179
|
getUniforms(e, t) {
|
|
1160
1180
|
const i = {};
|
|
@@ -1174,7 +1194,7 @@ class Mt {
|
|
|
1174
1194
|
if (this.stateFormat?.kind === "float16") {
|
|
1175
1195
|
const a = new Uint16Array(t);
|
|
1176
1196
|
for (let r = 0; r < t; r++)
|
|
1177
|
-
a[r] =
|
|
1197
|
+
a[r] = Vi(Math.random());
|
|
1178
1198
|
return a;
|
|
1179
1199
|
}
|
|
1180
1200
|
const i = new Uint8Array(t);
|
|
@@ -1183,7 +1203,7 @@ class Mt {
|
|
|
1183
1203
|
return i;
|
|
1184
1204
|
}
|
|
1185
1205
|
createStateTexture(e) {
|
|
1186
|
-
return
|
|
1206
|
+
return Qt(
|
|
1187
1207
|
this.gl,
|
|
1188
1208
|
this.gl.NEAREST,
|
|
1189
1209
|
e,
|
|
@@ -1196,10 +1216,10 @@ class Mt {
|
|
|
1196
1216
|
initParticleState() {
|
|
1197
1217
|
const e = this.gl, t = this.makeStateData(), i = this.createStateTexture(t), a = this.createStateTexture(t), r = J(e, i), n = J(e, a);
|
|
1198
1218
|
this.particleStateTextures = [i, a], this.particleFramebuffers = [r, n];
|
|
1199
|
-
const o = new Float32Array(H * 2),
|
|
1219
|
+
const o = new Float32Array(H * 2), l = new Float32Array(H * 2);
|
|
1200
1220
|
for (let d = 0; d < H; d++)
|
|
1201
|
-
o[d * 2] = d, o[d * 2 + 1] = d,
|
|
1202
|
-
this.particleIndexBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIndexBuffer), e.bufferData(e.ARRAY_BUFFER, o, e.STATIC_DRAW), this.particleIsCurrBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIsCurrBuffer), e.bufferData(e.ARRAY_BUFFER,
|
|
1221
|
+
o[d * 2] = d, o[d * 2 + 1] = d, l[d * 2] = 0, l[d * 2 + 1] = 1;
|
|
1222
|
+
this.particleIndexBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIndexBuffer), e.bufferData(e.ARRAY_BUFFER, o, e.STATIC_DRAW), this.particleIsCurrBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIsCurrBuffer), e.bufferData(e.ARRAY_BUFFER, l, e.STATIC_DRAW);
|
|
1203
1223
|
}
|
|
1204
1224
|
initRasterGrid() {
|
|
1205
1225
|
const e = this.gl, t = new Float32Array(
|
|
@@ -1207,17 +1227,17 @@ class Mt {
|
|
|
1207
1227
|
);
|
|
1208
1228
|
let i = 0;
|
|
1209
1229
|
for (let o = 0; o <= ee; o++)
|
|
1210
|
-
for (let
|
|
1211
|
-
t[i++] =
|
|
1230
|
+
for (let l = 0; l <= Y; l++)
|
|
1231
|
+
t[i++] = l / Y, t[i++] = o / ee;
|
|
1212
1232
|
const a = new Uint16Array(
|
|
1213
1233
|
Y * ee * 6
|
|
1214
1234
|
);
|
|
1215
1235
|
let r = 0;
|
|
1216
1236
|
const n = Y + 1;
|
|
1217
1237
|
for (let o = 0; o < ee; o++)
|
|
1218
|
-
for (let
|
|
1219
|
-
const d = o * n +
|
|
1220
|
-
a[r++] = d, a[r++] = u, a[r++] =
|
|
1238
|
+
for (let l = 0; l < Y; l++) {
|
|
1239
|
+
const d = o * n + l, c = d + 1, u = d + n, f = u + 1;
|
|
1240
|
+
a[r++] = d, a[r++] = u, a[r++] = c, a[r++] = c, a[r++] = u, a[r++] = f;
|
|
1221
1241
|
}
|
|
1222
1242
|
this.rasterGridBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.rasterGridBuffer), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), this.rasterGridIndexBuffer = e.createBuffer(), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.rasterGridIndexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, a, e.STATIC_DRAW), this.rasterGridIndexCount = a.length;
|
|
1223
1243
|
}
|
|
@@ -1236,14 +1256,14 @@ class Mt {
|
|
|
1236
1256
|
return;
|
|
1237
1257
|
const i = this.gl;
|
|
1238
1258
|
this.screenWidth = e, this.screenHeight = t, this.screenTextures && (i.deleteTexture(this.screenTextures[0]), i.deleteTexture(this.screenTextures[1]), i.deleteFramebuffer(this.screenFramebuffers[0]), i.deleteFramebuffer(this.screenFramebuffers[1])), this.deleteGlowTarget();
|
|
1239
|
-
const a = new Uint8Array(e * t * 4), r = Se(i, i.NEAREST, a, e, t), n = Se(i, i.NEAREST, a, e, t), o = J(i, r),
|
|
1240
|
-
this.screenTextures = [r, n], this.screenFramebuffers = [o,
|
|
1259
|
+
const a = new Uint8Array(e * t * 4), r = Se(i, i.NEAREST, a, e, t), n = Se(i, i.NEAREST, a, e, t), o = J(i, r), l = J(i, n);
|
|
1260
|
+
this.screenTextures = [r, n], this.screenFramebuffers = [o, l];
|
|
1241
1261
|
}
|
|
1242
1262
|
/**
|
|
1243
1263
|
* Run one simulation step: update positions, fade trails, draw particles.
|
|
1244
1264
|
* Must be called within the MapLibre render callback.
|
|
1245
1265
|
*/
|
|
1246
|
-
render(e, t, i, a, r, n, o,
|
|
1266
|
+
render(e, t, i, a, r, n, o, l, d = !1, c = [0, 0, 1], u, f) {
|
|
1247
1267
|
const m = { unit: e, min: t, max: i }, p = f ?? { a: m, b: m, mix: 0 }, h = this.gl;
|
|
1248
1268
|
if (this.screenWidth === 0 || this.screenHeight === 0)
|
|
1249
1269
|
return;
|
|
@@ -1255,12 +1275,12 @@ class Mt {
|
|
|
1255
1275
|
let y = !1;
|
|
1256
1276
|
if (T) {
|
|
1257
1277
|
h.disable(h.BLEND), h.useProgram(this.updateProgram), h.viewport(0, 0, B, B), O(h, this.particleStateTextures[0], 0), h.uniform1i(this.updateLocs.u_particles, 0), Te(h, this.updateLocs, p), h.uniform1i(this.updateLocs.u_velocity, p.a.unit), h.uniform2f(this.updateLocs.u_velocity_min, ...p.a.min), h.uniform2f(this.updateLocs.u_velocity_max, ...p.a.max), h.uniform1f(this.updateLocs.u_speed, this.params.speed), h.uniform1f(this.updateLocs.u_world_size, n), h.uniform1ui(this.updateLocs.u_frame, this.frame), this.frame = this.frame + 1 >>> 0;
|
|
1258
|
-
const
|
|
1278
|
+
const R = r.maxX - r.minX;
|
|
1259
1279
|
if (this.prevBounds) {
|
|
1260
|
-
const F = this.prevBounds.maxX - this.prevBounds.minX,
|
|
1280
|
+
const F = this.prevBounds.maxX - this.prevBounds.minX, L = this.prevBounds.maxY - this.prevBounds.minY, D = 1e-6, b = (r.minX + r.maxX) * 0.5, A = (r.minY + r.maxY) * 0.5, N = (this.prevBounds.minX + this.prevBounds.maxX) * 0.5, C = (this.prevBounds.minY + this.prevBounds.maxY) * 0.5, I = Math.abs(R - F) / Math.max(F, D), w = Math.abs(b - N) / Math.max(F, D) + Math.abs(A - C) / Math.max(L, D), U = Math.min(1, I + w);
|
|
1261
1281
|
this.redistributionBoost = Math.max(
|
|
1262
|
-
this.redistributionBoost *
|
|
1263
|
-
U *
|
|
1282
|
+
this.redistributionBoost * Ii,
|
|
1283
|
+
U * Fi
|
|
1264
1284
|
);
|
|
1265
1285
|
}
|
|
1266
1286
|
this.prevBounds = {
|
|
@@ -1271,7 +1291,7 @@ class Mt {
|
|
|
1271
1291
|
};
|
|
1272
1292
|
const k = Math.min(
|
|
1273
1293
|
this.params.dropRate + this.redistributionBoost,
|
|
1274
|
-
|
|
1294
|
+
Ui
|
|
1275
1295
|
);
|
|
1276
1296
|
h.uniform1f(this.updateLocs.u_drop_rate, k), h.uniform1f(
|
|
1277
1297
|
this.updateLocs.u_drop_rate_bump,
|
|
@@ -1282,12 +1302,12 @@ class Mt {
|
|
|
1282
1302
|
r.minY,
|
|
1283
1303
|
r.maxX,
|
|
1284
1304
|
r.maxY
|
|
1285
|
-
), h.uniform1f(this.updateLocs.u_is_globe, d ? 1 : 0),
|
|
1305
|
+
), h.uniform1f(this.updateLocs.u_is_globe, d ? 1 : 0), l && h.uniform4f(
|
|
1286
1306
|
this.updateLocs.u_geo_bounds,
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1307
|
+
l.west,
|
|
1308
|
+
l.south,
|
|
1309
|
+
l.east,
|
|
1310
|
+
l.north
|
|
1291
1311
|
), h.uniform1f(
|
|
1292
1312
|
this.updateLocs.u_valid_threshold,
|
|
1293
1313
|
je
|
|
@@ -1297,16 +1317,16 @@ class Mt {
|
|
|
1297
1317
|
this.fadeLocs.u_opacity,
|
|
1298
1318
|
this.updateTrailFadeOpacity(performance.now())
|
|
1299
1319
|
), this.drawQuad();
|
|
1300
|
-
const v = (
|
|
1301
|
-
|
|
1320
|
+
const v = (R) => {
|
|
1321
|
+
l && (d && u ? this.renderGridGlobe(
|
|
1302
1322
|
e,
|
|
1303
1323
|
t,
|
|
1304
1324
|
i,
|
|
1305
1325
|
a,
|
|
1306
|
-
|
|
1326
|
+
l,
|
|
1307
1327
|
u,
|
|
1308
1328
|
1,
|
|
1309
|
-
|
|
1329
|
+
R,
|
|
1310
1330
|
p
|
|
1311
1331
|
) : d || this.renderGrid(
|
|
1312
1332
|
e,
|
|
@@ -1315,9 +1335,9 @@ class Mt {
|
|
|
1315
1335
|
a,
|
|
1316
1336
|
n,
|
|
1317
1337
|
o,
|
|
1318
|
-
|
|
1338
|
+
l,
|
|
1319
1339
|
1,
|
|
1320
|
-
|
|
1340
|
+
R,
|
|
1321
1341
|
p
|
|
1322
1342
|
));
|
|
1323
1343
|
};
|
|
@@ -1327,12 +1347,12 @@ class Mt {
|
|
|
1327
1347
|
h.ONE_MINUS_SRC_ALPHA,
|
|
1328
1348
|
h.ONE,
|
|
1329
1349
|
h.ONE_MINUS_SRC_ALPHA
|
|
1330
|
-
), O(h, this.particleStateTextures[1], 0), h.uniform1i(this.drawLocs.u_particles, 0), O(h, this.particleStateTextures[0], 3), h.uniform1i(this.drawLocs.u_prev_particles, 3), Te(h, this.drawLocs, p), h.uniform1i(this.drawLocs.u_velocity, p.a.unit), h.uniform2f(this.drawLocs.u_velocity_min, ...p.a.min), h.uniform2f(this.drawLocs.u_velocity_max, ...p.a.max),
|
|
1350
|
+
), O(h, this.particleStateTextures[1], 0), h.uniform1i(this.drawLocs.u_particles, 0), O(h, this.particleStateTextures[0], 3), h.uniform1i(this.drawLocs.u_prev_particles, 3), Te(h, this.drawLocs, p), h.uniform1i(this.drawLocs.u_velocity, p.a.unit), h.uniform2f(this.drawLocs.u_velocity_min, ...p.a.min), h.uniform2f(this.drawLocs.u_velocity_max, ...p.a.max), l && h.uniform4f(
|
|
1331
1351
|
this.drawLocs.u_geo_bounds,
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1352
|
+
l.west,
|
|
1353
|
+
l.south,
|
|
1354
|
+
l.east,
|
|
1355
|
+
l.north
|
|
1336
1356
|
), h.uniform1f(this.drawLocs.u_particles_res, B), h.uniform1f(this.drawLocs.u_world_size, n), h.uniform1f(this.drawLocs.u_speed, this.params.speed), O(h, this.colorRampTexture, 2), h.uniform1i(this.drawLocs.u_color_ramp, 2), h.uniform1f(
|
|
1337
1357
|
this.drawLocs.u_particle_contrast,
|
|
1338
1358
|
this.renderMode === "raster+particles" ? 1 : 0
|
|
@@ -1344,30 +1364,30 @@ class Mt {
|
|
|
1344
1364
|
je
|
|
1345
1365
|
), h.uniform1f(this.drawLocs.u_is_globe, d ? 1 : 0), h.uniform3f(
|
|
1346
1366
|
this.drawLocs.u_globe_center,
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1367
|
+
c[0],
|
|
1368
|
+
c[1],
|
|
1369
|
+
c[2]
|
|
1350
1370
|
), h.uniformMatrix4fv(
|
|
1351
1371
|
this.drawLocs.u_matrix,
|
|
1352
1372
|
!1,
|
|
1353
1373
|
a instanceof Float32Array ? a : new Float32Array(Array.from(a))
|
|
1354
1374
|
);
|
|
1355
|
-
const
|
|
1356
|
-
h.bindBuffer(h.ARRAY_BUFFER, this.particleIndexBuffer), h.enableVertexAttribArray(
|
|
1375
|
+
const R = h.getAttribLocation(this.drawProgram, "a_index");
|
|
1376
|
+
h.bindBuffer(h.ARRAY_BUFFER, this.particleIndexBuffer), h.enableVertexAttribArray(R), h.vertexAttribPointer(R, 1, h.FLOAT, !1, 0, 0);
|
|
1357
1377
|
const k = h.getAttribLocation(this.drawProgram, "a_is_curr");
|
|
1358
1378
|
h.bindBuffer(h.ARRAY_BUFFER, this.particleIsCurrBuffer), h.enableVertexAttribArray(k), h.vertexAttribPointer(k, 1, h.FLOAT, !1, 0, 0);
|
|
1359
1379
|
for (const F of o)
|
|
1360
1380
|
h.uniform1f(this.drawLocs.u_world_offset, F), h.drawArrays(h.LINES, 0, this.numParticles * 2);
|
|
1361
|
-
h.disableVertexAttribArray(
|
|
1381
|
+
h.disableVertexAttribArray(R), h.disableVertexAttribArray(k), h.disable(h.BLEND);
|
|
1362
1382
|
}
|
|
1363
1383
|
h.bindFramebuffer(h.FRAMEBUFFER, g), h.viewport(0, 0, this.screenWidth, this.screenHeight);
|
|
1364
|
-
const _ =
|
|
1384
|
+
const _ = mi(this.params.backdrop);
|
|
1365
1385
|
_[3] > 0 && v(_);
|
|
1366
|
-
const S = this.params.glow > 0 ? this.renderGlow(g) : null,
|
|
1386
|
+
const S = this.params.glow > 0 ? this.renderGlow(g) : null, E = this.params.colorGrade;
|
|
1367
1387
|
h.useProgram(this.compositeProgram), O(h, this.screenTextures[1], 0), h.uniform1i(this.compositeLocs.u_screen, 0), O(h, S ?? this.screenTextures[1], 1), h.uniform1i(this.compositeLocs.u_glow_tex, 1), h.uniform1f(
|
|
1368
1388
|
this.compositeLocs.u_glow,
|
|
1369
|
-
S ?
|
|
1370
|
-
), h.uniform1f(this.compositeLocs.u_grade_on,
|
|
1389
|
+
S ? Kt * this.params.glow : 0
|
|
1390
|
+
), h.uniform1f(this.compositeLocs.u_grade_on, E.enabled ? 1 : 0), h.uniform4f(this.compositeLocs.u_grade, ...fi(E)), h.enable(h.BLEND), h.blendFunc(h.SRC_ALPHA, h.ONE_MINUS_SRC_ALPHA), this.drawQuad(), h.disable(h.BLEND), y && (this.particleStateTextures.reverse(), this.particleFramebuffers.reverse()), this.screenTextures.reverse(), this.screenFramebuffers.reverse();
|
|
1371
1391
|
}
|
|
1372
1392
|
/**
|
|
1373
1393
|
* Reduce the latest trails into the glow texture (glow.glsl), then rebind
|
|
@@ -1380,16 +1400,16 @@ class Mt {
|
|
|
1380
1400
|
deleteGlowTarget() {
|
|
1381
1401
|
this.glowTexture && (this.gl.deleteTexture(this.glowTexture), this.gl.deleteFramebuffer(this.glowFramebuffer), this.glowTexture = null, this.glowFramebuffer = null);
|
|
1382
1402
|
}
|
|
1383
|
-
renderGrid(e, t, i, a, r, n, o,
|
|
1403
|
+
renderGrid(e, t, i, a, r, n, o, l = 1, d = Me, c) {
|
|
1384
1404
|
const u = this.gl;
|
|
1385
1405
|
u.useProgram(this.gridProgram), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
|
|
1386
1406
|
this.gridLocs,
|
|
1387
1407
|
e,
|
|
1388
1408
|
t,
|
|
1389
1409
|
i,
|
|
1390
|
-
|
|
1410
|
+
l,
|
|
1391
1411
|
d,
|
|
1392
|
-
|
|
1412
|
+
c
|
|
1393
1413
|
), u.uniformMatrix4fv(
|
|
1394
1414
|
this.gridLocs.u_matrix,
|
|
1395
1415
|
!1,
|
|
@@ -1410,15 +1430,15 @@ class Mt {
|
|
|
1410
1430
|
);
|
|
1411
1431
|
this.unbindRasterGrid(this.gridProgram), u.disable(u.BLEND);
|
|
1412
1432
|
}
|
|
1413
|
-
renderGridGlobe(e, t, i, a, r, n, o = 1,
|
|
1433
|
+
renderGridGlobe(e, t, i, a, r, n, o = 1, l = Me, d, c = Jt) {
|
|
1414
1434
|
const u = this.gl;
|
|
1415
|
-
u.useProgram(this.gridGlobeProgram),
|
|
1435
|
+
u.useProgram(this.gridGlobeProgram), yt(u, this.gridGlobeLocs, c), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
|
|
1416
1436
|
this.gridGlobeLocs,
|
|
1417
1437
|
e,
|
|
1418
1438
|
t,
|
|
1419
1439
|
i,
|
|
1420
1440
|
o,
|
|
1421
|
-
|
|
1441
|
+
l,
|
|
1422
1442
|
d
|
|
1423
1443
|
), u.uniformMatrix4fv(
|
|
1424
1444
|
this.gridGlobeLocs.u_matrix,
|
|
@@ -1444,12 +1464,12 @@ class Mt {
|
|
|
1444
1464
|
), this.unbindRasterGrid(this.gridGlobeProgram), u.disable(u.BLEND);
|
|
1445
1465
|
}
|
|
1446
1466
|
setGridFieldUniforms(e, t, i, a, r, n, o) {
|
|
1447
|
-
const
|
|
1448
|
-
Te(
|
|
1467
|
+
const l = this.gl, d = { unit: t, min: i, max: a }, c = o ?? { a: d, b: d, mix: 0 };
|
|
1468
|
+
Te(l, e, c), l.uniform1i(e.u_field, c.a.unit), l.uniform4f(e.u_solid, ...n), O(l, this.colorRampTexture, 2), l.uniform1i(e.u_color_ramp, 2);
|
|
1449
1469
|
const u = Math.sqrt(
|
|
1450
1470
|
Math.max(Math.abs(i[0]), Math.abs(a[0])) ** 2 + Math.max(Math.abs(i[1]), Math.abs(a[1])) ** 2
|
|
1451
1471
|
);
|
|
1452
|
-
|
|
1472
|
+
l.uniform1f(e.u_field_min, 0), l.uniform1f(e.u_field_max, u > 0 ? u : 1), l.uniform1f(e.u_u_min, c.a.min[0]), l.uniform1f(e.u_u_max, c.a.max[0]), l.uniform1f(e.u_v_min, c.a.min[1]), l.uniform1f(e.u_v_max, c.a.max[1]), l.uniform1f(e.u_opacity, this.params.opacity * r), l.uniform1f(e.u_log_scale, this.params.logScale ? 1 : 0), l.uniform1f(e.u_vibrance, this.params.vibrance), l.uniform1f(e.u_scalar_mode, this.params.scalarMode ? 1 : 0);
|
|
1453
1473
|
}
|
|
1454
1474
|
bindRasterGrid(e) {
|
|
1455
1475
|
const t = this.gl, i = t.getAttribLocation(e, "a_grid_uv");
|
|
@@ -1515,11 +1535,11 @@ class Mt {
|
|
|
1515
1535
|
}
|
|
1516
1536
|
/** Partial values take the vibrant preset; see resolveColorGrade. */
|
|
1517
1537
|
setColorGrade(e) {
|
|
1518
|
-
this.params.colorGrade =
|
|
1538
|
+
this.params.colorGrade = St(e);
|
|
1519
1539
|
}
|
|
1520
1540
|
/** Missing values take the defaults; see resolveBackdrop. */
|
|
1521
1541
|
setBackdrop(e) {
|
|
1522
|
-
this.params.backdrop =
|
|
1542
|
+
this.params.backdrop = wt(e);
|
|
1523
1543
|
}
|
|
1524
1544
|
/** Halo strength, clamped to [0, 1]; 0 frees the glow texture. */
|
|
1525
1545
|
setGlow(e) {
|
|
@@ -1604,7 +1624,7 @@ class Mt {
|
|
|
1604
1624
|
e.deleteBuffer(this.quadBuffer), e.deleteBuffer(this.particleIndexBuffer), e.deleteBuffer(this.particleIsCurrBuffer), e.deleteTexture(this.colorRampTexture);
|
|
1605
1625
|
}
|
|
1606
1626
|
}
|
|
1607
|
-
class
|
|
1627
|
+
class Et {
|
|
1608
1628
|
constructor() {
|
|
1609
1629
|
this.gl = null, this.texture = null, this.width = 0, this.height = 0, this.uMin = 0, this.uMax = 0, this.vMin = 0, this.vMax = 0, this.geoBounds = { west: -180, south: -90, east: 180, north: 90 }, this.scalarMode = !1, this.linearFilter = !0;
|
|
1610
1630
|
}
|
|
@@ -1618,17 +1638,17 @@ class Rt {
|
|
|
1618
1638
|
* fields may use a fixed color domain so fragments never decode physical values.
|
|
1619
1639
|
*/
|
|
1620
1640
|
update(e, t = null) {
|
|
1621
|
-
const i = this.gl, { u: a, v: r, width: n, height: o, uMin:
|
|
1622
|
-
this.scalarMode = e.scalarMode ?? !1, this.width = n, this.height = o, this.uMin =
|
|
1623
|
-
const f = this.scalarMode && t ? t[0] :
|
|
1641
|
+
const i = this.gl, { u: a, v: r, width: n, height: o, uMin: l, uMax: d, vMin: c, vMax: u } = e;
|
|
1642
|
+
this.scalarMode = e.scalarMode ?? !1, this.width = n, this.height = o, this.uMin = l, this.uMax = d, this.vMin = c, this.vMax = u, this.geoBounds = e.bounds;
|
|
1643
|
+
const f = this.scalarMode && t ? t[0] : l, p = (this.scalarMode && t ? t[1] : d) - f || 1, h = u - c || 1, g = new Uint8Array(n * o * 4);
|
|
1624
1644
|
for (let y = 0; y < n * o; y++) {
|
|
1625
1645
|
const v = a[y], _ = r[y];
|
|
1626
1646
|
this.scalarMode ? isNaN(v) ? (g[y * 4] = 0, g[y * 4 + 1] = 0, g[y * 4 + 2] = 0, g[y * 4 + 3] = 0) : (g[y * 4] = Math.round(
|
|
1627
1647
|
Math.max(0, Math.min(1, (v - f) / p)) * 255
|
|
1628
1648
|
), g[y * 4 + 1] = 128, g[y * 4 + 2] = 0, g[y * 4 + 3] = 255) : isNaN(v) || isNaN(_) ? (g[y * 4] = 0, g[y * 4 + 1] = 0, g[y * 4 + 2] = 0, g[y * 4 + 3] = 0) : (g[y * 4] = Math.round(
|
|
1629
|
-
Math.max(0, Math.min(1, (v -
|
|
1649
|
+
Math.max(0, Math.min(1, (v - l) / p)) * 255
|
|
1630
1650
|
), g[y * 4 + 1] = Math.round(
|
|
1631
|
-
Math.max(0, Math.min(1, (_ -
|
|
1651
|
+
Math.max(0, Math.min(1, (_ - c) / h)) * 255
|
|
1632
1652
|
), g[y * 4 + 2] = 0, g[y * 4 + 3] = 255);
|
|
1633
1653
|
}
|
|
1634
1654
|
if (e.latDescending) {
|
|
@@ -1642,7 +1662,7 @@ class Rt {
|
|
|
1642
1662
|
console.log(
|
|
1643
1663
|
`[zartigl] Velocity texture: ${n}x${o}, valid=${x} (${(100 * x / (n * o)).toFixed(
|
|
1644
1664
|
1
|
|
1645
|
-
)}%), nodata=${T}, uRange=[${
|
|
1665
|
+
)}%), nodata=${T}, uRange=[${l.toFixed(4)}, ${d.toFixed(4)}], vRange=[${c.toFixed(4)}, ${u.toFixed(4)}]`
|
|
1646
1666
|
), this.texture || (this.texture = i.createTexture());
|
|
1647
1667
|
const M = this.linearFilter ? i.LINEAR : i.NEAREST;
|
|
1648
1668
|
i.bindTexture(i.TEXTURE_2D, this.texture), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, M), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, M), i.pixelStorei(i.UNPACK_ALIGNMENT, 1), i.texImage2D(
|
|
@@ -1682,8 +1702,8 @@ class Rt {
|
|
|
1682
1702
|
this.gl && this.texture && (this.gl.deleteTexture(this.texture), this.texture = null);
|
|
1683
1703
|
}
|
|
1684
1704
|
}
|
|
1685
|
-
function
|
|
1686
|
-
const o = new Float32Array(t * i).fill(NaN),
|
|
1705
|
+
function Lt(s, e, t, i, a, r, n) {
|
|
1706
|
+
const o = new Float32Array(t * i).fill(NaN), l = new Float32Array(t * i).fill(NaN);
|
|
1687
1707
|
for (const m of s)
|
|
1688
1708
|
for (let p = 0; p < m.latSize; p++)
|
|
1689
1709
|
for (let h = 0; h < m.lonSize; h++) {
|
|
@@ -1694,18 +1714,18 @@ function Pt(s, e, t, i, a, r, n) {
|
|
|
1694
1714
|
for (let p = 0; p < m.latSize; p++)
|
|
1695
1715
|
for (let h = 0; h < m.lonSize; h++) {
|
|
1696
1716
|
const g = p * m.lonChunkSize + h, x = (m.latStart + p) * i + (m.lonStart + h);
|
|
1697
|
-
|
|
1717
|
+
l[x] = m.data[g];
|
|
1698
1718
|
}
|
|
1699
|
-
let d = 1 / 0,
|
|
1719
|
+
let d = 1 / 0, c = -1 / 0, u = 1 / 0, f = -1 / 0;
|
|
1700
1720
|
for (let m = 0; m < o.length; m++)
|
|
1701
|
-
isNaN(o[m]) || (o[m] < d && (d = o[m]), o[m] >
|
|
1702
|
-
return isFinite(d) || (d = -1), isFinite(
|
|
1721
|
+
isNaN(o[m]) || (o[m] < d && (d = o[m]), o[m] > c && (c = o[m])), isNaN(l[m]) || (l[m] < u && (u = l[m]), l[m] > f && (f = l[m]));
|
|
1722
|
+
return isFinite(d) || (d = -1), isFinite(c) || (c = 1), isFinite(u) || (u = -1), isFinite(f) || (f = 1), {
|
|
1703
1723
|
u: o,
|
|
1704
|
-
v:
|
|
1724
|
+
v: l,
|
|
1705
1725
|
width: i,
|
|
1706
1726
|
height: t,
|
|
1707
1727
|
uMin: d,
|
|
1708
|
-
uMax:
|
|
1728
|
+
uMax: c,
|
|
1709
1729
|
vMin: u,
|
|
1710
1730
|
vMax: f,
|
|
1711
1731
|
bounds: a ?? { west: -180, south: -90, east: 180, north: 90 },
|
|
@@ -1713,6 +1733,13 @@ function Pt(s, e, t, i, a, r, n) {
|
|
|
1713
1733
|
scalarMode: n
|
|
1714
1734
|
};
|
|
1715
1735
|
}
|
|
1736
|
+
function zi(s, e, t, i) {
|
|
1737
|
+
const a = s.indexOf("time");
|
|
1738
|
+
if (a < 0 || !e[a] || !t[a])
|
|
1739
|
+
return "";
|
|
1740
|
+
const r = Math.floor((e[a] - 1) / t[a]);
|
|
1741
|
+
return i[a] === r ? `t=${e[a]}` : "";
|
|
1742
|
+
}
|
|
1716
1743
|
const Re = [
|
|
1717
1744
|
"depth",
|
|
1718
1745
|
"elevation",
|
|
@@ -1726,8 +1753,25 @@ class Qe extends Error {
|
|
|
1726
1753
|
}
|
|
1727
1754
|
}
|
|
1728
1755
|
class _e {
|
|
1729
|
-
|
|
1730
|
-
|
|
1756
|
+
/**
|
|
1757
|
+
* `options.chunkStore` keeps the compressed chunks across sessions (see
|
|
1758
|
+
* chunkStore.ts); without it, chunks are only kept in memory.
|
|
1759
|
+
*/
|
|
1760
|
+
constructor(e, t = 200, i = {}) {
|
|
1761
|
+
this.meta = null, this.coords = null, this.initPromise = null, this.verticalName = "depth", this.timeUnits = "", this.timeCalendar = "standard", this.cache = /* @__PURE__ */ new Map(), this.abortControllers = /* @__PURE__ */ new Map(), this.bloscCodecCache = /* @__PURE__ */ new Map(), this.root = e.replace(/\/$/, ""), this.maxCacheSize = t, this.chunkStore = i.chunkStore;
|
|
1762
|
+
}
|
|
1763
|
+
/** The URL of a chunk, as fetched and as stored. */
|
|
1764
|
+
chunkUrl(e, t) {
|
|
1765
|
+
return `${this.root}/${e}/${t.join(this.getDimensionSeparator(e))}`;
|
|
1766
|
+
}
|
|
1767
|
+
/** The revision a stored chunk must carry to be current (see chunkRevision). */
|
|
1768
|
+
chunkRevision(e, t) {
|
|
1769
|
+
return zi(
|
|
1770
|
+
this.getDimensions(e),
|
|
1771
|
+
this.getShape(e),
|
|
1772
|
+
this.getChunkShape(e),
|
|
1773
|
+
t
|
|
1774
|
+
);
|
|
1731
1775
|
}
|
|
1732
1776
|
async init() {
|
|
1733
1777
|
if (!this.coords) {
|
|
@@ -1777,7 +1821,7 @@ class _e {
|
|
|
1777
1821
|
let a = t ? i[0] : NaN, r = a;
|
|
1778
1822
|
for (let o = 1; o < i.length; o++)
|
|
1779
1823
|
a = Math.min(a, i[o]), r = Math.max(r, i[o]);
|
|
1780
|
-
const n =
|
|
1824
|
+
const n = $i(i);
|
|
1781
1825
|
return {
|
|
1782
1826
|
min: a,
|
|
1783
1827
|
max: r,
|
|
@@ -1849,7 +1893,7 @@ class _e {
|
|
|
1849
1893
|
throw new Error(
|
|
1850
1894
|
`Unsupported Zarr time units: ${this.timeUnits || "<missing>"}`
|
|
1851
1895
|
);
|
|
1852
|
-
const i =
|
|
1896
|
+
const i = Oi(t[2]);
|
|
1853
1897
|
if (!Number.isFinite(i))
|
|
1854
1898
|
throw new Error(`Invalid Zarr time epoch: ${t[2]}`);
|
|
1855
1899
|
const a = t[1].toLowerCase(), r = a.startsWith("ms") || a.startsWith("milli") ? 1 : a.startsWith("s") ? 1e3 : a.startsWith("min") ? 6e4 : a.startsWith("h") ? 36e5 : 864e5;
|
|
@@ -1862,28 +1906,28 @@ class _e {
|
|
|
1862
1906
|
}
|
|
1863
1907
|
async sampleVariableAt(e, t) {
|
|
1864
1908
|
const i = this.getDimensions(e), a = this.getChunkShape(e), r = this.getShape(e), n = new Array(i.length).fill(0), o = new Array(i.length).fill(0);
|
|
1865
|
-
for (let
|
|
1866
|
-
const u = i[
|
|
1909
|
+
for (let c = 0; c < i.length; c++) {
|
|
1910
|
+
const u = i[c];
|
|
1867
1911
|
let f = 0;
|
|
1868
|
-
u === "time" ? f = t.timeIdx : u === "latitude" ? f = t.latIdx : u === "longitude" ? f = t.lonIdx : (u === this.verticalName || Re.includes(u)) && (f = t.depthIdx), f = Math.max(0, Math.min(r[
|
|
1912
|
+
u === "time" ? f = t.timeIdx : u === "latitude" ? f = t.latIdx : u === "longitude" ? f = t.lonIdx : (u === this.verticalName || Re.includes(u)) && (f = t.depthIdx), f = Math.max(0, Math.min(r[c] - 1, f)), n[c] = Math.floor(f / a[c]), o[c] = f - n[c] * a[c];
|
|
1869
1913
|
}
|
|
1870
|
-
let
|
|
1914
|
+
let l;
|
|
1871
1915
|
try {
|
|
1872
|
-
|
|
1873
|
-
} catch (
|
|
1874
|
-
if (
|
|
1916
|
+
l = await this.fetchChunk(e, n);
|
|
1917
|
+
} catch (c) {
|
|
1918
|
+
if (c instanceof Qe && (c.status === 403 || c.status === 404))
|
|
1875
1919
|
return NaN;
|
|
1876
|
-
throw
|
|
1920
|
+
throw c;
|
|
1877
1921
|
}
|
|
1878
1922
|
const d = this.getFlatOffset(e, o);
|
|
1879
|
-
return d <
|
|
1923
|
+
return d < l.length ? l[d] : NaN;
|
|
1880
1924
|
}
|
|
1881
1925
|
getFlatOffset(e, t) {
|
|
1882
1926
|
const i = this.getArrayMeta(e), a = i.chunks;
|
|
1883
1927
|
if (i.order === "F") {
|
|
1884
1928
|
let n = 0, o = 1;
|
|
1885
|
-
for (let
|
|
1886
|
-
n += t[
|
|
1929
|
+
for (let l = 0; l < t.length; l++)
|
|
1930
|
+
n += t[l] * o, o *= a[l];
|
|
1887
1931
|
return n;
|
|
1888
1932
|
}
|
|
1889
1933
|
let r = 0;
|
|
@@ -1899,13 +1943,13 @@ class _e {
|
|
|
1899
1943
|
const t = this.getCoords(), i = this.findNearestLongitudeIndex(e.longitude), a = this.findNearestIndex(t.latitude, e.latitude), r = this.findDepthIndex(e.depth ?? 0), n = Math.max(0, e.timeStartIndex ?? 0), o = Math.min(
|
|
1900
1944
|
t.time.length - 1,
|
|
1901
1945
|
e.timeEndIndex ?? t.time.length - 1
|
|
1902
|
-
),
|
|
1946
|
+
), l = Math.max(1, Math.floor(e.stride ?? 1)), d = Math.max(
|
|
1903
1947
|
0,
|
|
1904
1948
|
Math.floor(e.stopAfterMissingSamples ?? 0)
|
|
1905
1949
|
);
|
|
1906
|
-
let
|
|
1950
|
+
let c = 0;
|
|
1907
1951
|
const u = [];
|
|
1908
|
-
for (let f = n; f <= o; f +=
|
|
1952
|
+
for (let f = n; f <= o; f += l) {
|
|
1909
1953
|
const m = {};
|
|
1910
1954
|
for (const g of e.variables)
|
|
1911
1955
|
m[g] = await this.sampleVariableAt(g, {
|
|
@@ -1920,9 +1964,9 @@ class _e {
|
|
|
1920
1964
|
time: p,
|
|
1921
1965
|
depth: t.vertical[r],
|
|
1922
1966
|
values: m
|
|
1923
|
-
}),
|
|
1967
|
+
}), c = e.variables.every(
|
|
1924
1968
|
(g) => !Number.isFinite(m[g])
|
|
1925
|
-
) ?
|
|
1969
|
+
) ? c + 1 : 0, d > 0 && c >= d)
|
|
1926
1970
|
break;
|
|
1927
1971
|
}
|
|
1928
1972
|
return {
|
|
@@ -1939,21 +1983,21 @@ class _e {
|
|
|
1939
1983
|
Math.floor(e.stopAfterMissingSamples ?? 0)
|
|
1940
1984
|
);
|
|
1941
1985
|
let o = 0;
|
|
1942
|
-
const
|
|
1986
|
+
const l = [];
|
|
1943
1987
|
let d = Array.from(
|
|
1944
1988
|
{ length: t.vertical.length },
|
|
1945
1989
|
(f, m) => m
|
|
1946
1990
|
).sort(
|
|
1947
1991
|
(f, m) => Math.abs(t.vertical[f]) - Math.abs(t.vertical[m])
|
|
1948
1992
|
);
|
|
1949
|
-
const
|
|
1993
|
+
const c = Math.max(
|
|
1950
1994
|
1,
|
|
1951
1995
|
Math.floor(e.maxDepths ?? d.length)
|
|
1952
1996
|
), u = Math.max(
|
|
1953
1997
|
1,
|
|
1954
|
-
Math.floor(e.stride ?? Math.ceil(d.length /
|
|
1998
|
+
Math.floor(e.stride ?? Math.ceil(d.length / c))
|
|
1955
1999
|
);
|
|
1956
|
-
d = d.filter((f, m) => m % u === 0).slice(0,
|
|
2000
|
+
d = d.filter((f, m) => m % u === 0).slice(0, c);
|
|
1957
2001
|
for (const f of d) {
|
|
1958
2002
|
const m = {};
|
|
1959
2003
|
for (const g of e.variables)
|
|
@@ -1964,7 +2008,7 @@ class _e {
|
|
|
1964
2008
|
lonIdx: i
|
|
1965
2009
|
});
|
|
1966
2010
|
const p = t.vertical[f];
|
|
1967
|
-
if (
|
|
2011
|
+
if (l.push({
|
|
1968
2012
|
axisValue: p,
|
|
1969
2013
|
time: this.zarrTimeToMs(t.time[r]),
|
|
1970
2014
|
depth: p,
|
|
@@ -1978,7 +2022,7 @@ class _e {
|
|
|
1978
2022
|
longitude: t.longitude[i],
|
|
1979
2023
|
latitude: t.latitude[a],
|
|
1980
2024
|
time: this.zarrTimeToMs(t.time[r]),
|
|
1981
|
-
points:
|
|
2025
|
+
points: l
|
|
1982
2026
|
};
|
|
1983
2027
|
}
|
|
1984
2028
|
/** Return the actual name of the vertical dimension ("depth" or "elevation"). */
|
|
@@ -1989,11 +2033,11 @@ class _e {
|
|
|
1989
2033
|
* Get chunk indices that intersect a geographic bounding box.
|
|
1990
2034
|
*/
|
|
1991
2035
|
getChunksForBounds(e, t, i, a) {
|
|
1992
|
-
const r = this.getCoords(), n = this.getChunkShape(e), o = this.getDimensions(e),
|
|
2036
|
+
const r = this.getCoords(), n = this.getChunkShape(e), o = this.getDimensions(e), l = o.indexOf("latitude"), d = o.indexOf("longitude"), c = n[l], u = n[d], f = r.latitude, m = r.longitude, p = this.findNearestIndex(f, a.north), h = this.findNearestIndex(f, a.south), g = this.findNearestIndex(m, a.west), x = this.findNearestIndex(m, a.east), T = Math.min(p, h), M = Math.max(p, h), y = Math.min(g, x), v = Math.max(g, x), _ = Math.floor(T / c), S = Math.floor(M / c), E = Math.floor(y / u), R = Math.floor(v / u), k = this.getShape(e), F = k[l], L = k[d], D = [];
|
|
1993
2037
|
for (let b = _; b <= S; b++)
|
|
1994
|
-
for (let A =
|
|
1995
|
-
const N = b *
|
|
1996
|
-
|
|
2038
|
+
for (let A = E; A <= R; A++) {
|
|
2039
|
+
const N = b * c, C = A * u, I = Math.min(c, F - N), w = Math.min(u, L - C);
|
|
2040
|
+
D.push({
|
|
1997
2041
|
timeIdx: t,
|
|
1998
2042
|
depthIdx: i,
|
|
1999
2043
|
latIdx: b,
|
|
@@ -2004,7 +2048,7 @@ class _e {
|
|
|
2004
2048
|
lonSize: w
|
|
2005
2049
|
});
|
|
2006
2050
|
}
|
|
2007
|
-
return
|
|
2051
|
+
return D;
|
|
2008
2052
|
}
|
|
2009
2053
|
async fetchChunk(e, t) {
|
|
2010
2054
|
return (await this.fetchChunkResult(e, t)).data;
|
|
@@ -2020,7 +2064,7 @@ class _e {
|
|
|
2020
2064
|
throw new Error(
|
|
2021
2065
|
`Variable ${e} must have latitude and longitude dimensions`
|
|
2022
2066
|
);
|
|
2023
|
-
const o = new Array(i.length).fill(0),
|
|
2067
|
+
const o = new Array(i.length).fill(0), l = new Array(i.length).fill(0);
|
|
2024
2068
|
for (let m = 0; m < i.length; m++) {
|
|
2025
2069
|
const p = i[m];
|
|
2026
2070
|
let h = 0;
|
|
@@ -2035,15 +2079,15 @@ class _e {
|
|
|
2035
2079
|
o[m] = t.longitudeChunkIndex;
|
|
2036
2080
|
continue;
|
|
2037
2081
|
}
|
|
2038
|
-
o[m] = Math.floor(h / a[m]),
|
|
2082
|
+
o[m] = Math.floor(h / a[m]), l[m] = h % a[m];
|
|
2039
2083
|
}
|
|
2040
|
-
const d = await this.fetchChunkResult(e, o),
|
|
2084
|
+
const d = await this.fetchChunkResult(e, o), c = a[r], u = a[n], f = new Float32Array(c * u);
|
|
2041
2085
|
f.fill(NaN);
|
|
2042
|
-
for (let m = 0; m <
|
|
2043
|
-
|
|
2086
|
+
for (let m = 0; m < c; m++) {
|
|
2087
|
+
l[r] = m;
|
|
2044
2088
|
for (let p = 0; p < u; p++) {
|
|
2045
|
-
|
|
2046
|
-
const h = this.getFlatOffset(e,
|
|
2089
|
+
l[n] = p;
|
|
2090
|
+
const h = this.getFlatOffset(e, l);
|
|
2047
2091
|
h < d.data.length && (f[m * u + p] = d.data[h]);
|
|
2048
2092
|
}
|
|
2049
2093
|
}
|
|
@@ -2056,23 +2100,32 @@ class _e {
|
|
|
2056
2100
|
this.abortControllers.get(r)?.abort();
|
|
2057
2101
|
const o = new AbortController();
|
|
2058
2102
|
this.abortControllers.set(r, o);
|
|
2059
|
-
const
|
|
2103
|
+
const l = this.getArrayMeta(e), d = this.chunkStore ? this.chunkRevision(e, t) : "";
|
|
2060
2104
|
try {
|
|
2061
|
-
const
|
|
2062
|
-
if (
|
|
2063
|
-
|
|
2105
|
+
const c = await this.chunkStore?.get(n, d);
|
|
2106
|
+
if (c) {
|
|
2107
|
+
const p = Ke(
|
|
2108
|
+
await this.decompress(c, l, e)
|
|
2109
|
+
);
|
|
2110
|
+
return this.cacheChunk(r, p), { data: p, missing: !1, url: n };
|
|
2111
|
+
}
|
|
2112
|
+
const u = await fetch(n, { signal: o.signal });
|
|
2113
|
+
if (!u.ok) {
|
|
2114
|
+
if (u.status === 403 || u.status === 404)
|
|
2064
2115
|
return {
|
|
2065
|
-
data:
|
|
2116
|
+
data: Gi(l),
|
|
2066
2117
|
missing: !0,
|
|
2067
|
-
status:
|
|
2118
|
+
status: u.status,
|
|
2068
2119
|
url: n
|
|
2069
2120
|
};
|
|
2070
|
-
throw new Qe(
|
|
2121
|
+
throw new Qe(u.status, n);
|
|
2071
2122
|
}
|
|
2072
|
-
const
|
|
2073
|
-
|
|
2123
|
+
const f = new Uint8Array(await u.arrayBuffer());
|
|
2124
|
+
this.chunkStore?.put(n, f, d);
|
|
2125
|
+
const m = Ke(
|
|
2126
|
+
await this.decompress(f, l, e)
|
|
2074
2127
|
);
|
|
2075
|
-
return this.cacheChunk(r,
|
|
2128
|
+
return this.cacheChunk(r, m), { data: m, missing: !1, url: n };
|
|
2076
2129
|
} finally {
|
|
2077
2130
|
this.abortControllers.get(r) === o && this.abortControllers.delete(r);
|
|
2078
2131
|
}
|
|
@@ -2092,7 +2145,7 @@ class _e {
|
|
|
2092
2145
|
getBloscCodec(e) {
|
|
2093
2146
|
const t = e.compressor, i = `${t.cname ?? "lz4"}-${t.clevel ?? 5}-${t.shuffle ?? 1}-${t.blocksize ?? 0}`;
|
|
2094
2147
|
let a = this.bloscCodecCache.get(i);
|
|
2095
|
-
return a || (a =
|
|
2148
|
+
return a || (a = yi.fromConfig({
|
|
2096
2149
|
id: "blosc",
|
|
2097
2150
|
cname: t.cname ?? "lz4",
|
|
2098
2151
|
clevel: t.clevel ?? 5,
|
|
@@ -2106,7 +2159,7 @@ class _e {
|
|
|
2106
2159
|
switch (t.compressor.id) {
|
|
2107
2160
|
case "zlib":
|
|
2108
2161
|
case "gzip":
|
|
2109
|
-
a =
|
|
2162
|
+
a = vi(e);
|
|
2110
2163
|
break;
|
|
2111
2164
|
case "blosc": {
|
|
2112
2165
|
a = await this.getBloscCodec(t).decode(e);
|
|
@@ -2132,38 +2185,38 @@ class _e {
|
|
|
2132
2185
|
a.byteLength / 8
|
|
2133
2186
|
);
|
|
2134
2187
|
else if (n === "<i2" || n === "|i2") {
|
|
2135
|
-
const
|
|
2188
|
+
const l = new Int16Array(
|
|
2136
2189
|
a.buffer,
|
|
2137
2190
|
a.byteOffset,
|
|
2138
2191
|
a.byteLength / 2
|
|
2139
2192
|
);
|
|
2140
|
-
r = Float32Array.from(
|
|
2193
|
+
r = Float32Array.from(l);
|
|
2141
2194
|
} else if (n === "<i4" || n === "|i4") {
|
|
2142
|
-
const
|
|
2195
|
+
const l = new Int32Array(
|
|
2143
2196
|
a.buffer,
|
|
2144
2197
|
a.byteOffset,
|
|
2145
2198
|
a.byteLength / 4
|
|
2146
2199
|
);
|
|
2147
|
-
r = Float32Array.from(
|
|
2200
|
+
r = Float32Array.from(l);
|
|
2148
2201
|
} else if (n === "<i8" || n === "|i8") {
|
|
2149
|
-
const
|
|
2202
|
+
const l = new DataView(
|
|
2150
2203
|
a.buffer,
|
|
2151
2204
|
a.byteOffset,
|
|
2152
2205
|
a.byteLength
|
|
2153
2206
|
), d = a.byteLength / 8;
|
|
2154
2207
|
r = new Float64Array(d);
|
|
2155
|
-
for (let
|
|
2156
|
-
r[
|
|
2208
|
+
for (let c = 0; c < d; c++)
|
|
2209
|
+
r[c] = Number(l.getBigInt64(c * 8, !0));
|
|
2157
2210
|
} else
|
|
2158
2211
|
throw new Error(`Unsupported dtype: ${n}`);
|
|
2159
2212
|
const o = t.fill_value;
|
|
2160
2213
|
if (o != null && typeof o == "number" && !isNaN(o))
|
|
2161
|
-
for (let
|
|
2162
|
-
r[
|
|
2214
|
+
for (let l = 0; l < r.length; l++)
|
|
2215
|
+
r[l] === o && (r[l] = NaN);
|
|
2163
2216
|
if (i) {
|
|
2164
|
-
const
|
|
2165
|
-
if (d != null ||
|
|
2166
|
-
const u = d ?? 1, f =
|
|
2217
|
+
const l = this.getAttrs(i), d = l.scale_factor, c = l.add_offset;
|
|
2218
|
+
if (d != null || c != null) {
|
|
2219
|
+
const u = d ?? 1, f = c ?? 0;
|
|
2167
2220
|
for (let m = 0; m < r.length; m++)
|
|
2168
2221
|
isNaN(r[m]) || (r[m] = r[m] * u + f);
|
|
2169
2222
|
}
|
|
@@ -2171,31 +2224,31 @@ class _e {
|
|
|
2171
2224
|
return r;
|
|
2172
2225
|
}
|
|
2173
2226
|
async loadCoordinates() {
|
|
2174
|
-
const e = async (
|
|
2175
|
-
const d = this.getArrayMeta(
|
|
2227
|
+
const e = async (l) => {
|
|
2228
|
+
const d = this.getArrayMeta(l), c = d.shape[0], u = Math.ceil(c / d.chunks[0]), f = [];
|
|
2176
2229
|
for (let g = 0; g < u; g++) {
|
|
2177
|
-
const x = `${this.root}/${
|
|
2230
|
+
const x = `${this.root}/${l}/${g}`, T = await fetch(x);
|
|
2178
2231
|
if (!T.ok)
|
|
2179
|
-
throw new Error(`Failed to fetch coord ${
|
|
2232
|
+
throw new Error(`Failed to fetch coord ${l}/${g}`);
|
|
2180
2233
|
const M = new Uint8Array(await T.arrayBuffer());
|
|
2181
2234
|
f.push(await this.decompress(M, d));
|
|
2182
2235
|
}
|
|
2183
2236
|
if (f.length === 1)
|
|
2184
|
-
return f[0].length >
|
|
2185
|
-
const m = f.some((g) => g instanceof Float64Array) ? Float64Array : Float32Array, p = new m(
|
|
2237
|
+
return f[0].length > c ? f[0].subarray(0, c) : f[0];
|
|
2238
|
+
const m = f.some((g) => g instanceof Float64Array) ? Float64Array : Float32Array, p = new m(c);
|
|
2186
2239
|
let h = 0;
|
|
2187
2240
|
for (const g of f) {
|
|
2188
|
-
const x = Math.min(g.length,
|
|
2189
|
-
if (p.set(g.subarray(0, x), h), h += x, h >=
|
|
2241
|
+
const x = Math.min(g.length, c - h);
|
|
2242
|
+
if (p.set(g.subarray(0, x), h), h += x, h >= c)
|
|
2190
2243
|
break;
|
|
2191
2244
|
}
|
|
2192
2245
|
return p;
|
|
2193
2246
|
};
|
|
2194
2247
|
let t = null;
|
|
2195
|
-
for (const
|
|
2196
|
-
const d = `${
|
|
2248
|
+
for (const l of Re) {
|
|
2249
|
+
const d = `${l}/.zarray`;
|
|
2197
2250
|
if (this.meta.metadata[d] && "dtype" in this.meta.metadata[d]) {
|
|
2198
|
-
t =
|
|
2251
|
+
t = l;
|
|
2199
2252
|
break;
|
|
2200
2253
|
}
|
|
2201
2254
|
}
|
|
@@ -2216,30 +2269,30 @@ class _e {
|
|
|
2216
2269
|
};
|
|
2217
2270
|
}
|
|
2218
2271
|
}
|
|
2219
|
-
function
|
|
2272
|
+
function Ke(s) {
|
|
2220
2273
|
return s instanceof Float32Array ? s : Float32Array.from(s);
|
|
2221
2274
|
}
|
|
2222
|
-
function
|
|
2275
|
+
function Gi(s) {
|
|
2223
2276
|
const e = s.chunks.reduce((i, a) => i * a, 1), t = new Float32Array(e);
|
|
2224
2277
|
return t.fill(NaN), t;
|
|
2225
2278
|
}
|
|
2226
|
-
function
|
|
2279
|
+
function Oi(s) {
|
|
2227
2280
|
const t = s.trim().replace(/\s+\([^)]*\)\s*$/, "").match(
|
|
2228
2281
|
/^(\d{4})-(\d{2})-(\d{2})(?:(?:T|\s+)(\d{2})(?::(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?)?)?(?:\s*(Z|[+-]\d{2}:?\d{2}))?$/i
|
|
2229
2282
|
);
|
|
2230
2283
|
if (!t)
|
|
2231
2284
|
return NaN;
|
|
2232
|
-
const i = Number(t[1]), a = Number(t[2]), r = Number(t[3]), n = Number(t[4] ?? 0), o = Number(t[5] ?? 0),
|
|
2233
|
-
if (a < 1 || a > 12 || n > 23 || o > 59 ||
|
|
2285
|
+
const i = Number(t[1]), a = Number(t[2]), r = Number(t[3]), n = Number(t[4] ?? 0), o = Number(t[5] ?? 0), l = Number(t[6] ?? 0), d = Number((t[7] ?? "").padEnd(3, "0").slice(0, 3)), c = t[8] ?? "Z";
|
|
2286
|
+
if (a < 1 || a > 12 || n > 23 || o > 59 || l > 59)
|
|
2234
2287
|
return NaN;
|
|
2235
2288
|
const u = /* @__PURE__ */ new Date(0);
|
|
2236
|
-
u.setUTCFullYear(i, a - 1, r), u.setUTCHours(n, o,
|
|
2289
|
+
u.setUTCFullYear(i, a - 1, r), u.setUTCHours(n, o, l, d);
|
|
2237
2290
|
const f = u.getTime();
|
|
2238
|
-
if (u.getUTCFullYear() !== i || u.getUTCMonth() !== a - 1 || u.getUTCDate() !== r || u.getUTCHours() !== n || u.getUTCMinutes() !== o || u.getUTCSeconds() !==
|
|
2291
|
+
if (u.getUTCFullYear() !== i || u.getUTCMonth() !== a - 1 || u.getUTCDate() !== r || u.getUTCHours() !== n || u.getUTCMinutes() !== o || u.getUTCSeconds() !== l || u.getUTCMilliseconds() !== d)
|
|
2239
2292
|
return NaN;
|
|
2240
|
-
if (/^z$/i.test(
|
|
2293
|
+
if (/^z$/i.test(c))
|
|
2241
2294
|
return f;
|
|
2242
|
-
const m =
|
|
2295
|
+
const m = c.match(/^([+-])(\d{2}):?(\d{2})$/);
|
|
2243
2296
|
if (!m)
|
|
2244
2297
|
return NaN;
|
|
2245
2298
|
const p = Number(m[2]), h = Number(m[3]);
|
|
@@ -2248,7 +2301,7 @@ function zi(s) {
|
|
|
2248
2301
|
const g = (p * 60 + h) * 6e4;
|
|
2249
2302
|
return f - (m[1] === "+" ? g : -g);
|
|
2250
2303
|
}
|
|
2251
|
-
function
|
|
2304
|
+
function Bi(s) {
|
|
2252
2305
|
if (typeof s != "number" || !Number.isFinite(s) || s <= 0)
|
|
2253
2306
|
return s;
|
|
2254
2307
|
const e = [
|
|
@@ -2270,7 +2323,7 @@ function Gi(s) {
|
|
|
2270
2323
|
return t;
|
|
2271
2324
|
return Math.round(s);
|
|
2272
2325
|
}
|
|
2273
|
-
function
|
|
2326
|
+
function $i(s) {
|
|
2274
2327
|
if (s.length < 2)
|
|
2275
2328
|
return;
|
|
2276
2329
|
const e = s[1] - s[0];
|
|
@@ -2280,7 +2333,7 @@ function Oi(s) {
|
|
|
2280
2333
|
for (let i = 2; i < s.length; i++)
|
|
2281
2334
|
if (Math.abs(s[i] - s[i - 1] - e) > t)
|
|
2282
2335
|
return;
|
|
2283
|
-
return
|
|
2336
|
+
return Bi(e);
|
|
2284
2337
|
}
|
|
2285
2338
|
class xe extends Error {
|
|
2286
2339
|
constructor(e, t, i) {
|
|
@@ -2289,19 +2342,19 @@ class xe extends Error {
|
|
|
2289
2342
|
), this.name = "ZartiglFrameUnavailableError", this.time = e, this.statuses = [...new Set(t)].sort((a, r) => a - r), this.urls = [...new Set(i)];
|
|
2290
2343
|
}
|
|
2291
2344
|
}
|
|
2292
|
-
function
|
|
2345
|
+
function qi(s) {
|
|
2293
2346
|
for (const e of s)
|
|
2294
2347
|
if (Number.isFinite(e))
|
|
2295
2348
|
return !0;
|
|
2296
2349
|
return !1;
|
|
2297
2350
|
}
|
|
2298
|
-
function
|
|
2351
|
+
function Wi(s, e) {
|
|
2299
2352
|
for (let t = 0; t < Math.min(s.length, e.length); t++)
|
|
2300
2353
|
if (Number.isFinite(s[t]) && Number.isFinite(e[t]))
|
|
2301
2354
|
return !0;
|
|
2302
2355
|
return !1;
|
|
2303
2356
|
}
|
|
2304
|
-
function
|
|
2357
|
+
function Dt(s) {
|
|
2305
2358
|
return {
|
|
2306
2359
|
phase: "blocked",
|
|
2307
2360
|
time: s.time,
|
|
@@ -2311,7 +2364,7 @@ function Et(s) {
|
|
|
2311
2364
|
}
|
|
2312
2365
|
class me {
|
|
2313
2366
|
constructor(e) {
|
|
2314
|
-
this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.activeData = null, this.initialized = !1, this.suspended = !1, this.loading = !1, this.reloadQueued = !1, this.generation = 0, this.requestId = 0, this.pendingReadyTime = null, this.frameCache = /* @__PURE__ */ new Map(), this.inflight = /* @__PURE__ */ new Set(), this.listeners = /* @__PURE__ */ new Map(), this.textureUnit = 1, this.moveEndHandler = null, this.id = e.id, this.variable = e.variable, this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.unit = e.unit ?? "", this.colorDomain = Q(e.colorDomain ?? null), this.zarrSource = e.zarrSource ?? new _e(e.source), this.activeField = new
|
|
2367
|
+
this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.activeData = null, this.initialized = !1, this.suspended = !1, this.loading = !1, this.reloadQueued = !1, this.generation = 0, this.requestId = 0, this.pendingReadyTime = null, this.frameCache = /* @__PURE__ */ new Map(), this.inflight = /* @__PURE__ */ new Set(), this.listeners = /* @__PURE__ */ new Map(), this.textureUnit = 1, this.moveEndHandler = null, this.id = e.id, this.variable = e.variable, this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.unit = e.unit ?? "", this.colorDomain = Q(e.colorDomain ?? null), this.zarrSource = e.zarrSource ?? new _e(e.source), this.activeField = new Et(), this.simulation = new Pt({
|
|
2315
2368
|
colorRamp: e.colorRamp,
|
|
2316
2369
|
opacity: e.opacity ?? 1,
|
|
2317
2370
|
logScale: e.logScale ?? !1,
|
|
@@ -2347,8 +2400,8 @@ class me {
|
|
|
2347
2400
|
try {
|
|
2348
2401
|
const r = i.canvas;
|
|
2349
2402
|
this.simulation.resize(r.width, r.height), i.bindFramebuffer(i.FRAMEBUFFER, a.framebuffer), i.viewport(0, 0, r.width, r.height);
|
|
2350
|
-
const n = this.map.getBounds(), o = t.defaultProjectionData,
|
|
2351
|
-
this.activeField.bind(this.textureUnit),
|
|
2403
|
+
const n = this.map.getBounds(), o = t.defaultProjectionData, l = ye(this.map, o), d = 512 * Math.pow(2, this.map.getZoom());
|
|
2404
|
+
this.activeField.bind(this.textureUnit), l ? this.simulation.renderGridGlobe(
|
|
2352
2405
|
this.textureUnit,
|
|
2353
2406
|
[this.activeData.uMin, this.activeData.vMin],
|
|
2354
2407
|
[this.activeData.uMax, this.activeData.vMax],
|
|
@@ -2503,7 +2556,7 @@ class me {
|
|
|
2503
2556
|
const n = r instanceof Error ? r : new Error(String(r));
|
|
2504
2557
|
e === this.generation && t === this.requestId && (this.emit(
|
|
2505
2558
|
"status",
|
|
2506
|
-
n instanceof xe ?
|
|
2559
|
+
n instanceof xe ? Dt(n) : { phase: "error", time: a, error: n }
|
|
2507
2560
|
), this.emit("error", n));
|
|
2508
2561
|
}
|
|
2509
2562
|
} finally {
|
|
@@ -2521,7 +2574,7 @@ class me {
|
|
|
2521
2574
|
r,
|
|
2522
2575
|
n,
|
|
2523
2576
|
a
|
|
2524
|
-
),
|
|
2577
|
+
), l = this.zarrSource.getDimensions(this.variable), d = l.indexOf("latitude"), c = l.indexOf("longitude"), u = this.zarrSource.getChunkShape(this.variable);
|
|
2525
2578
|
let f = 0;
|
|
2526
2579
|
const m = o.length, p = [], h = [];
|
|
2527
2580
|
t?.(f, m);
|
|
@@ -2539,45 +2592,45 @@ class me {
|
|
|
2539
2592
|
return A.missing && (A.status != null && p.push(A.status), h.push(A.url)), f++, t?.(f, m), {
|
|
2540
2593
|
data: A.data,
|
|
2541
2594
|
latStart: b.latIdx * u[d],
|
|
2542
|
-
lonStart: b.lonIdx * u[
|
|
2595
|
+
lonStart: b.lonIdx * u[c],
|
|
2543
2596
|
latSize: b.latSize,
|
|
2544
2597
|
lonSize: b.lonSize,
|
|
2545
|
-
lonChunkSize: u[
|
|
2598
|
+
lonChunkSize: u[c]
|
|
2546
2599
|
};
|
|
2547
2600
|
})
|
|
2548
2601
|
), x = Math.min(...g.map((b) => b.latStart)), T = Math.max(...g.map((b) => b.latStart + b.latSize)), M = Math.min(...g.map((b) => b.lonStart)), y = Math.max(...g.map((b) => b.lonStart + b.lonSize)), v = T - x, _ = y - M, S = g.map((b) => ({
|
|
2549
2602
|
...b,
|
|
2550
2603
|
latStart: b.latStart - x,
|
|
2551
2604
|
lonStart: b.lonStart - M
|
|
2552
|
-
})),
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2605
|
+
})), E = this.zarrSource.getCoords(), R = Math.min(T - 1, E.latitude.length - 1), k = Math.min(y - 1, E.longitude.length - 1), F = Tt(
|
|
2606
|
+
E.longitude,
|
|
2607
|
+
E.latitude,
|
|
2608
|
+
[M, k],
|
|
2609
|
+
[x, R]
|
|
2610
|
+
), L = E.latitude[x] > E.latitude[R], D = Lt(
|
|
2558
2611
|
S,
|
|
2559
2612
|
[],
|
|
2560
2613
|
v,
|
|
2561
2614
|
_,
|
|
2562
2615
|
F,
|
|
2563
|
-
|
|
2616
|
+
L,
|
|
2564
2617
|
!0
|
|
2565
2618
|
);
|
|
2566
|
-
if (!
|
|
2619
|
+
if (!qi(D.u))
|
|
2567
2620
|
throw new xe(
|
|
2568
2621
|
this.timeToMs(e),
|
|
2569
2622
|
p,
|
|
2570
2623
|
h
|
|
2571
2624
|
);
|
|
2572
|
-
return
|
|
2625
|
+
return D;
|
|
2573
2626
|
}
|
|
2574
2627
|
setActive(e, t) {
|
|
2575
2628
|
const i = this.timeToMs(t);
|
|
2576
2629
|
this.emit("status", { phase: "rendering", time: i }), this.activeData = e, this.activeField.update(e, this.colorDomain), this.activeField.setFilter(!1), this.emit("loaded", this.computeFieldMeta(e, t)), this.pendingReadyTime = i, this.map?.triggerRepaint();
|
|
2577
2630
|
}
|
|
2578
2631
|
sampleActiveData(e, t, i) {
|
|
2579
|
-
const { west: a, east: r, south: n, north: o } = e.bounds,
|
|
2580
|
-
if (e.width <= 0 || e.height <= 0 ||
|
|
2632
|
+
const { west: a, east: r, south: n, north: o } = e.bounds, l = r - a, d = o - n;
|
|
2633
|
+
if (e.width <= 0 || e.height <= 0 || l <= 0 || d <= 0)
|
|
2581
2634
|
return {
|
|
2582
2635
|
longitude: t,
|
|
2583
2636
|
latitude: i,
|
|
@@ -2586,8 +2639,8 @@ class me {
|
|
|
2586
2639
|
time: this.timeToMs(this.time),
|
|
2587
2640
|
depth: this.depth
|
|
2588
2641
|
};
|
|
2589
|
-
const
|
|
2590
|
-
if (
|
|
2642
|
+
const c = a + ((t - a) % 360 + 360) % 360;
|
|
2643
|
+
if (c > r && l < 359 || i < n || i > o)
|
|
2591
2644
|
return {
|
|
2592
2645
|
longitude: t,
|
|
2593
2646
|
latitude: i,
|
|
@@ -2596,13 +2649,13 @@ class me {
|
|
|
2596
2649
|
time: this.timeToMs(this.time),
|
|
2597
2650
|
depth: this.depth
|
|
2598
2651
|
};
|
|
2599
|
-
const u = (
|
|
2652
|
+
const u = (c - a) / l, f = e.latDescending ? (o - i) / d : (i - n) / d, m = Math.max(
|
|
2600
2653
|
0,
|
|
2601
|
-
Math.min(e.width - 1, Math.
|
|
2654
|
+
Math.min(e.width - 1, Math.floor(u * e.width))
|
|
2602
2655
|
), p = Math.max(
|
|
2603
2656
|
0,
|
|
2604
|
-
Math.min(e.height - 1, Math.
|
|
2605
|
-
), h = e.u[p * e.width + m] ?? NaN, g = a + m
|
|
2657
|
+
Math.min(e.height - 1, Math.floor(f * e.height))
|
|
2658
|
+
), h = e.u[p * e.width + m] ?? NaN, g = a + (m + 0.5) / e.width * l, x = e.latDescending ? o - (p + 0.5) / e.height * d : n + (p + 0.5) / e.height * d;
|
|
2606
2659
|
return {
|
|
2607
2660
|
longitude: g,
|
|
2608
2661
|
latitude: x,
|
|
@@ -2632,7 +2685,7 @@ class me {
|
|
|
2632
2685
|
a(...t);
|
|
2633
2686
|
}
|
|
2634
2687
|
}
|
|
2635
|
-
function
|
|
2688
|
+
function Xi(s, e, t) {
|
|
2636
2689
|
if (!Number.isFinite(s) || !Number.isFinite(e))
|
|
2637
2690
|
return { u: NaN, v: NaN };
|
|
2638
2691
|
const i = t.direction_convention !== t.output_direction ? 180 : 0, a = (s + i) * Math.PI / 180;
|
|
@@ -2641,15 +2694,15 @@ function qi(s, e, t) {
|
|
|
2641
2694
|
v: e * Math.cos(a)
|
|
2642
2695
|
};
|
|
2643
2696
|
}
|
|
2644
|
-
function
|
|
2697
|
+
function Aa(s) {
|
|
2645
2698
|
return [s.direction_variable, s.magnitude_variable];
|
|
2646
2699
|
}
|
|
2647
|
-
const
|
|
2648
|
-
class
|
|
2700
|
+
const Hi = 0.7;
|
|
2701
|
+
class P {
|
|
2649
2702
|
constructor(e) {
|
|
2650
2703
|
if (this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.initialized = !1, this.suspended = !1, this.loading = !1, this.reloadQueued = !1, this.reloadQueuedResetParticles = !1, this.globeRendering = null, this.generation = 0, this.requestId = 0, this.pendingReadyTime = null, this.velocityTexUnit = 1, this.moveStartHandler = null, this.moveHandler = null, this.moveEndHandler = null, this.frameCache = /* @__PURE__ */ new Map(), this.inflight = /* @__PURE__ */ new Set(), this.listeners = /* @__PURE__ */ new Map(), this.id = e.id, this.geoVideoManifest = e.geoVideo?.manifest, this.geoVideoManifest && this.geoVideoManifest.encoding.kind !== "vector-luma")
|
|
2651
2704
|
throw new Error("Vector GeoVideo requires a vector-luma manifest");
|
|
2652
|
-
this.playback = e.geoVideo ? new
|
|
2705
|
+
this.playback = e.geoVideo ? new _t(
|
|
2653
2706
|
{ ...e.geoVideo, time: e.time },
|
|
2654
2707
|
() => this.map?.triggerRepaint(),
|
|
2655
2708
|
(t, ...i) => {
|
|
@@ -2667,16 +2720,16 @@ class D {
|
|
|
2667
2720
|
}
|
|
2668
2721
|
t === "timeChange" && (this.time = i[0]), this.emit(t, ...i);
|
|
2669
2722
|
}
|
|
2670
|
-
) : null, this.variableU = e.variableU ?? "uo", this.variableV = e.variableV ?? "vo", this.vectorDerivation = e.vectorDerivation, this.unit = e.unit ?? "m/s", this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.zarrSourceValue = this.playback ? null : e.zarrSource ?? new _e(e.source), this.velocityField = new
|
|
2723
|
+
) : null, this.variableU = e.variableU ?? "uo", this.variableV = e.variableV ?? "vo", this.vectorDerivation = e.vectorDerivation, this.unit = e.unit ?? "m/s", this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.zarrSourceValue = this.playback ? null : e.zarrSource ?? new _e(e.source), this.velocityField = new Et(), this.simulation = new Pt({
|
|
2671
2724
|
particleDensity: e.particleDensity ?? 0.05,
|
|
2672
2725
|
speed: e.speed ?? 1,
|
|
2673
|
-
fadeOpacity: Xe(e.fade ??
|
|
2726
|
+
fadeOpacity: Xe(e.fade ?? Hi),
|
|
2674
2727
|
colorRamp: e.colorRamp,
|
|
2675
2728
|
opacity: e.opacity ?? 1,
|
|
2676
2729
|
logScale: e.logScale ?? !1,
|
|
2677
2730
|
vibrance: e.vibrance ?? 0,
|
|
2678
|
-
colorGrade:
|
|
2679
|
-
backdrop:
|
|
2731
|
+
colorGrade: St(e.colorGrade),
|
|
2732
|
+
backdrop: wt(e.backdrop),
|
|
2680
2733
|
glow: e.glow ?? 0,
|
|
2681
2734
|
particleState: e.particleState ?? "auto",
|
|
2682
2735
|
rgba8MaxParticleZoom: e.rgba8MaxParticleZoom ?? 4
|
|
@@ -2724,9 +2777,9 @@ class D {
|
|
|
2724
2777
|
};
|
|
2725
2778
|
}
|
|
2726
2779
|
isViewportCovered() {
|
|
2727
|
-
return !this.map || !this.velocityField.hasData() ? !1 :
|
|
2780
|
+
return !this.map || !this.velocityField.hasData() ? !1 : Ti(
|
|
2728
2781
|
this.velocityField.geoBounds,
|
|
2729
|
-
|
|
2782
|
+
Si(this.map.getBounds())
|
|
2730
2783
|
);
|
|
2731
2784
|
}
|
|
2732
2785
|
reloadIfViewportUncovered() {
|
|
@@ -2743,16 +2796,16 @@ class D {
|
|
|
2743
2796
|
* The map's current viewport is used to determine the lat bounds of the request.
|
|
2744
2797
|
*/
|
|
2745
2798
|
async fetchVelocityData(e, t) {
|
|
2746
|
-
const i = this.map.getBounds(), a = this.globeRendering ?? ye(this.map), r =
|
|
2799
|
+
const i = this.map.getBounds(), a = this.globeRendering ?? ye(this.map), r = wi(i, 1, a), n = this.zarrSource.findTimeIndex(e), o = this.zarrSource.findDepthIndex(this.depth);
|
|
2747
2800
|
console.log(
|
|
2748
2801
|
`[zartigl] Loading velocity: depth=${this.depth} → depthIdx=${o}, actual depth value=${this.zarrSource.getCoords().vertical[o]}, timeIdx=${n}`
|
|
2749
2802
|
);
|
|
2750
|
-
const
|
|
2751
|
-
|
|
2803
|
+
const l = this.vectorDerivation?.direction_variable ?? this.variableU, d = this.zarrSource.getChunksForBounds(
|
|
2804
|
+
l,
|
|
2752
2805
|
n,
|
|
2753
2806
|
o,
|
|
2754
2807
|
r
|
|
2755
|
-
),
|
|
2808
|
+
), c = this.zarrSource.getDimensions(l), u = c.indexOf("latitude"), f = c.indexOf("longitude");
|
|
2756
2809
|
let m = 0;
|
|
2757
2810
|
const p = d.length * 2, h = [], g = [];
|
|
2758
2811
|
t?.(m, p);
|
|
@@ -2773,7 +2826,7 @@ class D {
|
|
|
2773
2826
|
lonSize: U.lonSize,
|
|
2774
2827
|
lonChunkSize: le
|
|
2775
2828
|
};
|
|
2776
|
-
}), [T, M] = this.vectorDerivation ?
|
|
2829
|
+
}), [T, M] = this.vectorDerivation ? Yi(
|
|
2777
2830
|
await Promise.all(
|
|
2778
2831
|
x(this.vectorDerivation.direction_variable)
|
|
2779
2832
|
),
|
|
@@ -2784,7 +2837,7 @@ class D {
|
|
|
2784
2837
|
) : await Promise.all([
|
|
2785
2838
|
Promise.all(x(this.variableU)),
|
|
2786
2839
|
Promise.all(x(this.variableV))
|
|
2787
|
-
]), y = Math.min(...T.map((w) => w.latStart)), v = Math.max(...T.map((w) => w.latStart + w.latSize)), _ = Math.min(...T.map((w) => w.lonStart)), S = Math.max(...T.map((w) => w.lonStart + w.lonSize)),
|
|
2840
|
+
]), y = Math.min(...T.map((w) => w.latStart)), v = Math.max(...T.map((w) => w.latStart + w.latSize)), _ = Math.min(...T.map((w) => w.lonStart)), S = Math.max(...T.map((w) => w.lonStart + w.lonSize)), E = v - y, R = S - _, k = T.map((w) => ({
|
|
2788
2841
|
...w,
|
|
2789
2842
|
latStart: w.latStart - y,
|
|
2790
2843
|
lonStart: w.lonStart - _
|
|
@@ -2792,20 +2845,20 @@ class D {
|
|
|
2792
2845
|
...w,
|
|
2793
2846
|
latStart: w.latStart - y,
|
|
2794
2847
|
lonStart: w.lonStart - _
|
|
2795
|
-
})),
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2848
|
+
})), L = this.zarrSource.getCoords(), D = Math.min(v - 1, L.latitude.length - 1), b = Math.min(S - 1, L.longitude.length - 1), A = Tt(
|
|
2849
|
+
L.longitude,
|
|
2850
|
+
L.latitude,
|
|
2851
|
+
[_, b],
|
|
2852
|
+
[y, D]
|
|
2853
|
+
), N = L.latitude[y] > L.latitude[D], C = Lt(
|
|
2801
2854
|
k,
|
|
2802
2855
|
F,
|
|
2803
|
-
R,
|
|
2804
2856
|
E,
|
|
2857
|
+
R,
|
|
2805
2858
|
A,
|
|
2806
2859
|
N
|
|
2807
2860
|
), I = this.zarrSource.getValueDomain?.();
|
|
2808
|
-
if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I),
|
|
2861
|
+
if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I), !Wi(C.u, C.v))
|
|
2809
2862
|
throw new xe(
|
|
2810
2863
|
this.timeToMs(e),
|
|
2811
2864
|
h,
|
|
@@ -2832,11 +2885,11 @@ class D {
|
|
|
2832
2885
|
else {
|
|
2833
2886
|
const o = await this.fetchVelocityData(
|
|
2834
2887
|
a,
|
|
2835
|
-
(
|
|
2888
|
+
(l, d) => {
|
|
2836
2889
|
t === this.generation && i === this.requestId && this.emit("status", {
|
|
2837
2890
|
phase: "fetching",
|
|
2838
2891
|
time: r,
|
|
2839
|
-
completed:
|
|
2892
|
+
completed: l,
|
|
2840
2893
|
total: d
|
|
2841
2894
|
});
|
|
2842
2895
|
}
|
|
@@ -2853,7 +2906,7 @@ class D {
|
|
|
2853
2906
|
const o = n instanceof Error ? n : new Error(String(n));
|
|
2854
2907
|
console.error("[zartigl] Failed to load velocity:", o), t === this.generation && i === this.requestId && (this.emit(
|
|
2855
2908
|
"status",
|
|
2856
|
-
o instanceof xe ?
|
|
2909
|
+
o instanceof xe ? Dt(o) : { phase: "error", time: r, error: o }
|
|
2857
2910
|
), this.emit("error", o));
|
|
2858
2911
|
}
|
|
2859
2912
|
} finally {
|
|
@@ -2871,7 +2924,7 @@ class D {
|
|
|
2871
2924
|
if (this.playback ? !r || !n : !this.initialized || !this.velocityField.hasData())
|
|
2872
2925
|
return;
|
|
2873
2926
|
n?.setFilter(this.simulation.renderMode !== "raster");
|
|
2874
|
-
const o = n?.manifest.encoding.kind === "vector-luma" ? n.manifest.encoding.valueDomain : 0,
|
|
2927
|
+
const o = n?.manifest.encoding.kind === "vector-luma" ? n.manifest.encoding.valueDomain : 0, l = n ? [-o, -o] : [this.velocityField.uMin, this.velocityField.vMin], d = n ? [o, o] : [this.velocityField.uMax, this.velocityField.vMax], c = n ? {
|
|
2875
2928
|
west: n.bounds[0],
|
|
2876
2929
|
south: n.bounds[1],
|
|
2877
2930
|
east: n.bounds[2],
|
|
@@ -2879,14 +2932,14 @@ class D {
|
|
|
2879
2932
|
} : this.velocityField.geoBounds, u = r ? {
|
|
2880
2933
|
a: {
|
|
2881
2934
|
unit: 1,
|
|
2882
|
-
min:
|
|
2935
|
+
min: l,
|
|
2883
2936
|
max: d,
|
|
2884
2937
|
physical: !0,
|
|
2885
2938
|
northToSouth: !0
|
|
2886
2939
|
},
|
|
2887
2940
|
b: {
|
|
2888
2941
|
unit: 4,
|
|
2889
|
-
min:
|
|
2942
|
+
min: l,
|
|
2890
2943
|
max: d,
|
|
2891
2944
|
physical: !0,
|
|
2892
2945
|
northToSouth: !0
|
|
@@ -2905,20 +2958,20 @@ class D {
|
|
|
2905
2958
|
this.simulation.resetParticles();
|
|
2906
2959
|
}
|
|
2907
2960
|
this.globeRendering = h;
|
|
2908
|
-
const g = this.map.getBounds(), x =
|
|
2961
|
+
const g = this.map.getBounds(), x = Mi(g, h), T = Be(g, h);
|
|
2909
2962
|
i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST);
|
|
2910
2963
|
const M = 512 * Math.pow(2, this.map.getZoom()), y = this.map.getCenter();
|
|
2911
2964
|
this.simulation.render(
|
|
2912
2965
|
this.velocityTexUnit,
|
|
2913
|
-
|
|
2966
|
+
l,
|
|
2914
2967
|
d,
|
|
2915
2968
|
a,
|
|
2916
2969
|
x,
|
|
2917
2970
|
M,
|
|
2918
2971
|
T,
|
|
2919
|
-
|
|
2972
|
+
c,
|
|
2920
2973
|
h,
|
|
2921
|
-
|
|
2974
|
+
bi(y.lng, y.lat),
|
|
2922
2975
|
t.defaultProjectionData.clippingPlane,
|
|
2923
2976
|
...u ? [u] : []
|
|
2924
2977
|
);
|
|
@@ -3106,23 +3159,23 @@ class D {
|
|
|
3106
3159
|
a(...t);
|
|
3107
3160
|
}
|
|
3108
3161
|
}
|
|
3109
|
-
function
|
|
3162
|
+
function Yi(s, e, t) {
|
|
3110
3163
|
const i = [], a = [];
|
|
3111
3164
|
for (let r = 0; r < s.length; r++) {
|
|
3112
|
-
const n = s[r], o = e[r],
|
|
3113
|
-
for (let
|
|
3114
|
-
const u =
|
|
3115
|
-
n.data[
|
|
3116
|
-
o.data[
|
|
3165
|
+
const n = s[r], o = e[r], l = new Float32Array(n.data.length), d = new Float32Array(n.data.length);
|
|
3166
|
+
for (let c = 0; c < n.data.length; c++) {
|
|
3167
|
+
const u = Xi(
|
|
3168
|
+
n.data[c],
|
|
3169
|
+
o.data[c],
|
|
3117
3170
|
t
|
|
3118
3171
|
);
|
|
3119
|
-
c
|
|
3172
|
+
l[c] = u.u, d[c] = u.v;
|
|
3120
3173
|
}
|
|
3121
|
-
i.push({ ...n, data:
|
|
3174
|
+
i.push({ ...n, data: l }), a.push({ ...n, data: d });
|
|
3122
3175
|
}
|
|
3123
3176
|
return [i, a];
|
|
3124
3177
|
}
|
|
3125
|
-
var
|
|
3178
|
+
var Je = `precision mediump float;
|
|
3126
3179
|
|
|
3127
3180
|
uniform sampler2D u_color;
|
|
3128
3181
|
uniform sampler2D u_color_next;
|
|
@@ -3135,7 +3188,6 @@ uniform float u_log_scale;
|
|
|
3135
3188
|
uniform float u_vibrance;
|
|
3136
3189
|
uniform float u_mask_threshold;
|
|
3137
3190
|
uniform vec2 u_color_domain;
|
|
3138
|
-
uniform vec2 u_texel_size;
|
|
3139
3191
|
|
|
3140
3192
|
varying vec2 v_geo_uv;
|
|
3141
3193
|
|
|
@@ -3161,9 +3213,8 @@ float geoVideoScalarValue(float r) {
|
|
|
3161
3213
|
}
|
|
3162
3214
|
|
|
3163
3215
|
void main() {
|
|
3164
|
-
|
|
3165
|
-
vec2
|
|
3166
|
-
vec2 uv = mix(halfTexel, vec2(1.0) - halfTexel, sourceUv);
|
|
3216
|
+
|
|
3217
|
+
vec2 uv = vec2(v_geo_uv.x, 1.0 - v_geo_uv.y);
|
|
3167
3218
|
vec3 media = texture2D(u_color, uv).rgb;
|
|
3168
3219
|
float alpha = texture2D(u_mask, uv).r;
|
|
3169
3220
|
if (alpha <= u_mask_threshold) discard;
|
|
@@ -3184,7 +3235,7 @@ void main() {
|
|
|
3184
3235
|
const Z = 128, te = 64;
|
|
3185
3236
|
class G {
|
|
3186
3237
|
constructor(e) {
|
|
3187
|
-
this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.manifest = null, this.colorRampTexture = null, this.mercatorProgram = null, this.globeProgram = null, this.vertexBuffer = null, this.indexBuffer = null, this.indexCount = 0, this.abortController = null, this.listeners = /* @__PURE__ */ new Map(), this.id = e.id, this.source = e.manifest, this.opacity = e.opacity ?? 1, this.playback = new
|
|
3238
|
+
this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.manifest = null, this.colorRampTexture = null, this.mercatorProgram = null, this.globeProgram = null, this.vertexBuffer = null, this.indexBuffer = null, this.indexCount = 0, this.abortController = null, this.listeners = /* @__PURE__ */ new Map(), this.id = e.id, this.source = e.manifest, this.opacity = e.opacity ?? 1, this.playback = new _t(
|
|
3188
3239
|
e,
|
|
3189
3240
|
() => this.map?.triggerRepaint(),
|
|
3190
3241
|
(t, ...i) => this.emit(t, ...i)
|
|
@@ -3226,66 +3277,62 @@ class G {
|
|
|
3226
3277
|
const n = r.manifest;
|
|
3227
3278
|
if (!a || !r.maskTexture)
|
|
3228
3279
|
return;
|
|
3229
|
-
const o = Ge(i),
|
|
3280
|
+
const o = Ge(i), l = [0, 1, 2, 3].map((d) => (i.activeTexture(i.TEXTURE0 + d), i.getParameter(i.TEXTURE_BINDING_2D)));
|
|
3230
3281
|
try {
|
|
3231
|
-
const d = !!this.map && ye(this.map, t.defaultProjectionData),
|
|
3232
|
-
if (!
|
|
3282
|
+
const d = !!this.map && ye(this.map, t.defaultProjectionData), c = d ? this.globeProgram : this.mercatorProgram;
|
|
3283
|
+
if (!c || !this.map)
|
|
3233
3284
|
return;
|
|
3234
|
-
i.useProgram(
|
|
3235
|
-
i.getUniformLocation(
|
|
3285
|
+
i.useProgram(c), i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST), i.enable(i.BLEND), i.blendFunc(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA), i.activeTexture(i.TEXTURE0), i.bindTexture(i.TEXTURE_2D, a[0]), i.uniform1i(i.getUniformLocation(c, "u_color"), 0), i.activeTexture(i.TEXTURE3), i.bindTexture(i.TEXTURE_2D, a[1]), i.uniform1i(i.getUniformLocation(c, "u_color_next"), 3), i.uniform1f(i.getUniformLocation(c, "u_mix"), a[2]), i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r.maskTexture), i.uniform1i(i.getUniformLocation(c, "u_mask"), 1), i.activeTexture(i.TEXTURE2), i.bindTexture(i.TEXTURE_2D, this.colorRampTexture), i.uniform1i(i.getUniformLocation(c, "u_color_ramp"), 2), i.uniform1f(i.getUniformLocation(c, "u_opacity"), this.opacity), i.uniform1f(i.getUniformLocation(c, "u_scalar_luma"), 1), i.uniform1f(
|
|
3286
|
+
i.getUniformLocation(c, "u_log_scale"),
|
|
3236
3287
|
this.logScale ? 1 : 0
|
|
3237
|
-
), i.uniform1f(i.getUniformLocation(
|
|
3238
|
-
i.getUniformLocation(
|
|
3288
|
+
), i.uniform1f(i.getUniformLocation(c, "u_vibrance"), this.vibrance), i.uniform1f(
|
|
3289
|
+
i.getUniformLocation(c, "u_mask_threshold"),
|
|
3239
3290
|
n.mask.threshold
|
|
3240
3291
|
);
|
|
3241
|
-
const { codeRange: u, valueRange: f, transfer: m } =
|
|
3292
|
+
const { codeRange: u, valueRange: f, transfer: m } = ei(
|
|
3242
3293
|
n.encoding
|
|
3243
3294
|
);
|
|
3244
3295
|
i.uniform1f(
|
|
3245
|
-
i.getUniformLocation(
|
|
3296
|
+
i.getUniformLocation(c, "u_scalar_transfer"),
|
|
3246
3297
|
m
|
|
3247
3298
|
);
|
|
3248
3299
|
const p = this.colorDomain ?? f;
|
|
3249
3300
|
i.uniform2f(
|
|
3250
|
-
i.getUniformLocation(
|
|
3301
|
+
i.getUniformLocation(c, "u_code_range"),
|
|
3251
3302
|
...u
|
|
3252
3303
|
), i.uniform2f(
|
|
3253
|
-
i.getUniformLocation(
|
|
3304
|
+
i.getUniformLocation(c, "u_value_range"),
|
|
3254
3305
|
...f
|
|
3255
3306
|
), i.uniform2f(
|
|
3256
|
-
i.getUniformLocation(
|
|
3307
|
+
i.getUniformLocation(c, "u_color_domain"),
|
|
3257
3308
|
p[0],
|
|
3258
3309
|
p[1]
|
|
3259
|
-
), i.uniform2f(
|
|
3260
|
-
i.getUniformLocation(l, "u_texel_size"),
|
|
3261
|
-
1 / n.media.width,
|
|
3262
|
-
1 / n.media.height
|
|
3263
3310
|
), i.uniformMatrix4fv(
|
|
3264
|
-
i.getUniformLocation(
|
|
3311
|
+
i.getUniformLocation(c, "u_matrix"),
|
|
3265
3312
|
!1,
|
|
3266
3313
|
t.modelViewProjectionMatrix instanceof Float32Array ? t.modelViewProjectionMatrix : new Float32Array(Array.from(t.modelViewProjectionMatrix))
|
|
3267
3314
|
);
|
|
3268
3315
|
const [h, g, x, T] = n.bounds, M = x < h ? x + 360 : x;
|
|
3269
3316
|
if (i.uniform4f(
|
|
3270
|
-
i.getUniformLocation(
|
|
3317
|
+
i.getUniformLocation(c, "u_geo_bounds"),
|
|
3271
3318
|
h,
|
|
3272
3319
|
g,
|
|
3273
3320
|
M,
|
|
3274
3321
|
T
|
|
3275
|
-
), this.bindGrid(i,
|
|
3322
|
+
), this.bindGrid(i, c), d) {
|
|
3276
3323
|
const y = t.defaultProjectionData.clippingPlane;
|
|
3277
3324
|
i.uniform4f(
|
|
3278
|
-
i.getUniformLocation(
|
|
3325
|
+
i.getUniformLocation(c, "u_clipping_plane"),
|
|
3279
3326
|
...y
|
|
3280
|
-
),
|
|
3327
|
+
), yt(
|
|
3281
3328
|
i,
|
|
3282
3329
|
{
|
|
3283
3330
|
u_projection_transition: i.getUniformLocation(
|
|
3284
|
-
|
|
3331
|
+
c,
|
|
3285
3332
|
"u_projection_transition"
|
|
3286
3333
|
),
|
|
3287
3334
|
u_fallback_matrix: i.getUniformLocation(
|
|
3288
|
-
|
|
3335
|
+
c,
|
|
3289
3336
|
"u_fallback_matrix"
|
|
3290
3337
|
)
|
|
3291
3338
|
},
|
|
@@ -3293,20 +3340,20 @@ class G {
|
|
|
3293
3340
|
), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
|
|
3294
3341
|
} else {
|
|
3295
3342
|
const y = 512 * Math.pow(2, this.map.getZoom());
|
|
3296
|
-
i.uniform1f(i.getUniformLocation(
|
|
3343
|
+
i.uniform1f(i.getUniformLocation(c, "u_world_size"), y);
|
|
3297
3344
|
for (const v of Be(
|
|
3298
3345
|
this.map.getBounds(),
|
|
3299
3346
|
!1
|
|
3300
3347
|
))
|
|
3301
3348
|
i.uniform1f(
|
|
3302
|
-
i.getUniformLocation(
|
|
3349
|
+
i.getUniformLocation(c, "u_world_offset"),
|
|
3303
3350
|
v
|
|
3304
3351
|
), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
|
|
3305
3352
|
}
|
|
3306
|
-
this.unbindGrid(i,
|
|
3353
|
+
this.unbindGrid(i, c);
|
|
3307
3354
|
} finally {
|
|
3308
|
-
|
|
3309
|
-
i.activeTexture(i.TEXTURE0 +
|
|
3355
|
+
l.forEach((d, c) => {
|
|
3356
|
+
i.activeTexture(i.TEXTURE0 + c), i.bindTexture(i.TEXTURE_2D, d);
|
|
3310
3357
|
}), Oe(i, o);
|
|
3311
3358
|
}
|
|
3312
3359
|
}
|
|
@@ -3386,7 +3433,7 @@ class G {
|
|
|
3386
3433
|
id: this.id,
|
|
3387
3434
|
initialized: !!e?.currentPair,
|
|
3388
3435
|
playing: this.playback.isPlaying(),
|
|
3389
|
-
currentTime: e ? e.manifest.timeline.kind === "snapshot-loop" ? (this.playback.time - e.times[0]) / 1e3 :
|
|
3436
|
+
currentTime: e ? e.manifest.timeline.kind === "snapshot-loop" ? (this.playback.time - e.times[0]) / 1e3 : ti(e.manifest, this.playback.time) : 0,
|
|
3390
3437
|
manifestId: this.manifest?.id,
|
|
3391
3438
|
mediaUrl: this.manifest?.media.url,
|
|
3392
3439
|
preloadedMediaUrl: this.playback.preloadedMediaUrl,
|
|
@@ -3410,7 +3457,7 @@ class G {
|
|
|
3410
3457
|
return this.listeners.get(e)?.delete(t), this;
|
|
3411
3458
|
}
|
|
3412
3459
|
initGl(e) {
|
|
3413
|
-
this.mercatorProgram = W(e,
|
|
3460
|
+
this.mercatorProgram = W(e, Mt, Je), this.globeProgram = W(e, Rt, Je), this.colorRampTexture = ge(
|
|
3414
3461
|
e,
|
|
3415
3462
|
ke(this.colorRamp)
|
|
3416
3463
|
);
|
|
@@ -3419,15 +3466,15 @@ class G {
|
|
|
3419
3466
|
);
|
|
3420
3467
|
let i = 0;
|
|
3421
3468
|
for (let o = 0; o <= te; o++)
|
|
3422
|
-
for (let
|
|
3423
|
-
t[i++] =
|
|
3469
|
+
for (let l = 0; l <= Z; l++)
|
|
3470
|
+
t[i++] = l / Z, t[i++] = o / te;
|
|
3424
3471
|
const a = new Uint16Array(Z * te * 6);
|
|
3425
3472
|
let r = 0;
|
|
3426
3473
|
const n = Z + 1;
|
|
3427
3474
|
for (let o = 0; o < te; o++)
|
|
3428
|
-
for (let
|
|
3429
|
-
const d = o * n +
|
|
3430
|
-
a[r++] = d, a[r++] = u, a[r++] =
|
|
3475
|
+
for (let l = 0; l < Z; l++) {
|
|
3476
|
+
const d = o * n + l, c = d + 1, u = d + n, f = u + 1;
|
|
3477
|
+
a[r++] = d, a[r++] = u, a[r++] = c, a[r++] = c, a[r++] = u, a[r++] = f;
|
|
3431
3478
|
}
|
|
3432
3479
|
if (this.vertexBuffer = e.createBuffer(), this.indexBuffer = e.createBuffer(), !this.vertexBuffer || !this.indexBuffer)
|
|
3433
3480
|
throw new Error("Failed to create GeoVideo grid");
|
|
@@ -3451,22 +3498,22 @@ function $e(s) {
|
|
|
3451
3498
|
function j(s) {
|
|
3452
3499
|
return encodeURIComponent(String(s));
|
|
3453
3500
|
}
|
|
3454
|
-
function
|
|
3501
|
+
function At(s, e) {
|
|
3455
3502
|
return e === "depth" ? -Math.abs(s) : s;
|
|
3456
3503
|
}
|
|
3457
|
-
function
|
|
3504
|
+
function Zi(s) {
|
|
3458
3505
|
let e = s.template.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}");
|
|
3459
3506
|
return s.tileMatrixSet != null && (e = e.replace(
|
|
3460
3507
|
/\{TileMatrixSet\}/gi,
|
|
3461
3508
|
j(s.tileMatrixSet)
|
|
3462
3509
|
)), s.style != null && (e = e.replace(/\{Style\}/gi, j(s.style))), s.time != null && (e = e.replace(/\{time\}/gi, j($e(s.time)))), s.depth != null && (e = e.replace(
|
|
3463
3510
|
/\{elevation\}/gi,
|
|
3464
|
-
j(
|
|
3511
|
+
j(At(s.depth, s.verticalLabel))
|
|
3465
3512
|
)), [...e.matchAll(/\{([^{}]+)\}/g)].some(
|
|
3466
3513
|
(t) => !/^(?:z|y|x)$/i.test(t[1])
|
|
3467
3514
|
) ? void 0 : e;
|
|
3468
3515
|
}
|
|
3469
|
-
function
|
|
3516
|
+
function et(s) {
|
|
3470
3517
|
const e = [
|
|
3471
3518
|
["SERVICE", "WMTS"],
|
|
3472
3519
|
["VERSION", "1.0.0"],
|
|
@@ -3480,14 +3527,14 @@ function Je(s) {
|
|
|
3480
3527
|
];
|
|
3481
3528
|
s.style && e.push(["STYLE", s.style]), s.time != null && e.push(["time", $e(s.time)]), s.depth != null && e.push([
|
|
3482
3529
|
"elevation",
|
|
3483
|
-
String(
|
|
3530
|
+
String(At(s.depth, s.verticalLabel))
|
|
3484
3531
|
]);
|
|
3485
3532
|
const t = e.map(
|
|
3486
3533
|
([i, a]) => `${i}=${a.startsWith("{") ? a : j(a)}`
|
|
3487
3534
|
).join("&");
|
|
3488
3535
|
return `${s.baseUrl}?${t}`;
|
|
3489
3536
|
}
|
|
3490
|
-
function
|
|
3537
|
+
function ji(s) {
|
|
3491
3538
|
const e = [
|
|
3492
3539
|
["SERVICE", "WMTS"],
|
|
3493
3540
|
["REQUEST", "GetLegend"],
|
|
@@ -3496,38 +3543,38 @@ function Yi(s) {
|
|
|
3496
3543
|
];
|
|
3497
3544
|
return s.style && e.push(["STYLE", s.style]), `${s.baseUrl}?${e.map(([t, i]) => `${t}=${j(i)}`).join("&")}`;
|
|
3498
3545
|
}
|
|
3499
|
-
function
|
|
3546
|
+
function Qi(s) {
|
|
3500
3547
|
return s.sourceConfig.type === "wmts" ? "scalar-wmts" : s.sourceConfig.type === "geovideo" ? s.entry.kind === "vector" ? "vector-geovideo" : "scalar-geovideo" : s.entry.kind === "vector" ? "vector-zarr" : "scalar-zarr";
|
|
3501
3548
|
}
|
|
3502
|
-
function
|
|
3549
|
+
function Ki(s) {
|
|
3503
3550
|
return s.variables.kind === "scalar" ? s.variables.value : "scalar";
|
|
3504
3551
|
}
|
|
3505
|
-
function
|
|
3552
|
+
function Ji(s) {
|
|
3506
3553
|
return s.variables.kind === "vector" ? s.variables.u ?? "uo" : "uo";
|
|
3507
3554
|
}
|
|
3508
|
-
function
|
|
3555
|
+
function ea(s) {
|
|
3509
3556
|
return s.variables.kind === "vector" ? s.variables.v ?? "vo" : "vo";
|
|
3510
3557
|
}
|
|
3511
|
-
function
|
|
3558
|
+
function ta(s) {
|
|
3512
3559
|
return s.variables.kind === "vector" ? s.variables.derivation : void 0;
|
|
3513
3560
|
}
|
|
3514
|
-
class
|
|
3561
|
+
class ia {
|
|
3515
3562
|
constructor(e) {
|
|
3516
|
-
if (this.type = "custom", this.renderingMode = "3d", this.delegate = null, this.map = null, this.suspended = !1, this.listeners = /* @__PURE__ */ new Map(), this.options = e, this.id = e.id, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.backend =
|
|
3563
|
+
if (this.type = "custom", this.renderingMode = "3d", this.delegate = null, this.map = null, this.suspended = !1, this.listeners = /* @__PURE__ */ new Map(), this.options = e, this.id = e.id, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.backend = Qi(e), this.rasterSourceId = `${e.id}-wmts-source`, this.rasterLayerId = `${e.id}-wmts`, this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.opacity = e.opacity ?? 1, this.backend === "vector-zarr") {
|
|
3517
3564
|
const t = e.sourceConfig;
|
|
3518
|
-
this.delegate = new
|
|
3565
|
+
this.delegate = new P({
|
|
3519
3566
|
...e,
|
|
3520
3567
|
source: t.endpoints.field,
|
|
3521
3568
|
zarrSource: e.zarrSource,
|
|
3522
|
-
variableU:
|
|
3523
|
-
variableV:
|
|
3524
|
-
vectorDerivation:
|
|
3569
|
+
variableU: Ji(t),
|
|
3570
|
+
variableV: ea(t),
|
|
3571
|
+
vectorDerivation: ta(t),
|
|
3525
3572
|
unit: e.unit ?? ""
|
|
3526
3573
|
});
|
|
3527
3574
|
} else if (this.backend === "vector-geovideo") {
|
|
3528
3575
|
if (!e.geoVideoManifest)
|
|
3529
3576
|
throw new Error("Vector GeoVideo requires a loaded manifest");
|
|
3530
|
-
this.delegate = new
|
|
3577
|
+
this.delegate = new P({
|
|
3531
3578
|
...e,
|
|
3532
3579
|
source: e.geoVideoManifest.media.url,
|
|
3533
3580
|
geoVideo: {
|
|
@@ -3548,7 +3595,7 @@ class ea {
|
|
|
3548
3595
|
id: e.id,
|
|
3549
3596
|
source: t.endpoints.field,
|
|
3550
3597
|
zarrSource: e.zarrSource,
|
|
3551
|
-
variable:
|
|
3598
|
+
variable: Ki(t),
|
|
3552
3599
|
time: e.time,
|
|
3553
3600
|
depth: e.depth,
|
|
3554
3601
|
colorRamp: e.colorRamp,
|
|
@@ -3579,7 +3626,7 @@ class ea {
|
|
|
3579
3626
|
vibrance: e.vibrance
|
|
3580
3627
|
});
|
|
3581
3628
|
}
|
|
3582
|
-
this.delegate instanceof
|
|
3629
|
+
this.delegate instanceof P && this.backend === "vector-geovideo" && this.delegate.on("timeChange", (t) => {
|
|
3583
3630
|
this.time = t;
|
|
3584
3631
|
});
|
|
3585
3632
|
}
|
|
@@ -3667,16 +3714,16 @@ class ea {
|
|
|
3667
3714
|
}
|
|
3668
3715
|
}
|
|
3669
3716
|
setSpeed(e) {
|
|
3670
|
-
this.delegate instanceof
|
|
3717
|
+
this.delegate instanceof P && this.delegate.setSpeed(e);
|
|
3671
3718
|
}
|
|
3672
3719
|
setFade(e) {
|
|
3673
|
-
this.delegate instanceof
|
|
3720
|
+
this.delegate instanceof P && this.delegate.setFade(e);
|
|
3674
3721
|
}
|
|
3675
3722
|
setParticleDensity(e) {
|
|
3676
|
-
this.delegate instanceof
|
|
3723
|
+
this.delegate instanceof P && this.delegate.setParticleDensity(e);
|
|
3677
3724
|
}
|
|
3678
3725
|
setRenderMode(e) {
|
|
3679
|
-
this.delegate instanceof
|
|
3726
|
+
this.delegate instanceof P && this.delegate.setRenderMode(e);
|
|
3680
3727
|
}
|
|
3681
3728
|
setRgba8MaxParticleZoom(e) {
|
|
3682
3729
|
this.delegate?.setRgba8MaxParticleZoom(e);
|
|
@@ -3692,34 +3739,34 @@ class ea {
|
|
|
3692
3739
|
this.map?.getLayer(this.rasterLayerId) && this.map.setPaintProperty(this.rasterLayerId, "raster-opacity", e);
|
|
3693
3740
|
}
|
|
3694
3741
|
setLogScale(e) {
|
|
3695
|
-
this.delegate instanceof me && this.delegate.setLogScale(e), this.delegate instanceof
|
|
3742
|
+
this.delegate instanceof me && this.delegate.setLogScale(e), this.delegate instanceof P && this.delegate.setLogScale(e), this.delegate instanceof G && this.delegate.setLogScale(e);
|
|
3696
3743
|
}
|
|
3697
3744
|
setVibrance(e) {
|
|
3698
3745
|
this.delegate?.setVibrance(e);
|
|
3699
3746
|
}
|
|
3700
3747
|
/** Particle trails only; rasters ignore it. */
|
|
3701
3748
|
setColorGrade(e) {
|
|
3702
|
-
this.delegate instanceof
|
|
3749
|
+
this.delegate instanceof P && this.delegate.setColorGrade(e);
|
|
3703
3750
|
}
|
|
3704
3751
|
/** Under particle trails only; rasters ignore it. */
|
|
3705
3752
|
setBackdrop(e) {
|
|
3706
|
-
this.delegate instanceof
|
|
3753
|
+
this.delegate instanceof P && this.delegate.setBackdrop(e);
|
|
3707
3754
|
}
|
|
3708
3755
|
/** Particle trails only; rasters ignore it. */
|
|
3709
3756
|
setGlow(e) {
|
|
3710
|
-
this.delegate instanceof
|
|
3757
|
+
this.delegate instanceof P && this.delegate.setGlow(e);
|
|
3711
3758
|
}
|
|
3712
3759
|
setColorDomain(e) {
|
|
3713
3760
|
this.delegate instanceof me && this.delegate.setColorDomain(e), this.delegate instanceof G && this.delegate.setColorDomain(e);
|
|
3714
3761
|
}
|
|
3715
3762
|
async play() {
|
|
3716
|
-
(this.delegate instanceof G || this.delegate instanceof
|
|
3763
|
+
(this.delegate instanceof G || this.delegate instanceof P) && await this.delegate.play();
|
|
3717
3764
|
}
|
|
3718
3765
|
pause() {
|
|
3719
|
-
(this.delegate instanceof G || this.delegate instanceof
|
|
3766
|
+
(this.delegate instanceof G || this.delegate instanceof P) && this.delegate.pause();
|
|
3720
3767
|
}
|
|
3721
3768
|
setLoop(e) {
|
|
3722
|
-
(this.delegate instanceof G || this.delegate instanceof
|
|
3769
|
+
(this.delegate instanceof G || this.delegate instanceof P) && this.delegate.setLoop(e);
|
|
3723
3770
|
}
|
|
3724
3771
|
/** Media rate multiplier of a scalar GeoVideo. */
|
|
3725
3772
|
setPlaybackRate(e) {
|
|
@@ -3727,21 +3774,21 @@ class ea {
|
|
|
3727
3774
|
}
|
|
3728
3775
|
/** Cadence of the continuous vector GeoVideo clock. */
|
|
3729
3776
|
setStepsPerSecond(e) {
|
|
3730
|
-
this.delegate instanceof
|
|
3777
|
+
this.delegate instanceof P && this.delegate.setStepsPerSecond(e);
|
|
3731
3778
|
}
|
|
3732
3779
|
setTimeRange(e) {
|
|
3733
|
-
(this.delegate instanceof G || this.delegate instanceof
|
|
3780
|
+
(this.delegate instanceof G || this.delegate instanceof P) && this.delegate.setTimeRange(e);
|
|
3734
3781
|
}
|
|
3735
3782
|
/**
|
|
3736
3783
|
* Move a GeoVideo to another artifact, such as the next archive
|
|
3737
3784
|
* chunk, without rebuilding the map layer. False when a new layer is needed.
|
|
3738
3785
|
*/
|
|
3739
3786
|
replaceGeoVideoManifest(e, t) {
|
|
3740
|
-
return this.suspended || !(this.delegate instanceof G || this.delegate instanceof
|
|
3787
|
+
return this.suspended || !(this.delegate instanceof G || this.delegate instanceof P) || !this.delegate.replaceManifest(e, t) ? !1 : (t.time != null && (this.time = t.time), !0);
|
|
3741
3788
|
}
|
|
3742
3789
|
/** Load the GeoVideo artifact expected next, such as the next archive chunk. */
|
|
3743
3790
|
preloadGeoVideoManifest(e, t) {
|
|
3744
|
-
return !this.suspended && (this.delegate instanceof G || this.delegate instanceof
|
|
3791
|
+
return !this.suspended && (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.preloadManifest(e, t);
|
|
3745
3792
|
}
|
|
3746
3793
|
async samplePoint(e) {
|
|
3747
3794
|
if (this.delegate instanceof me)
|
|
@@ -3758,14 +3805,14 @@ class ea {
|
|
|
3758
3805
|
return;
|
|
3759
3806
|
this.removeWmts();
|
|
3760
3807
|
const e = this.options.sourceConfig, t = e.tileUrlTemplate ? [
|
|
3761
|
-
|
|
3808
|
+
Zi({
|
|
3762
3809
|
template: e.tileUrlTemplate,
|
|
3763
3810
|
tileMatrixSet: e.tileMatrixSet,
|
|
3764
3811
|
style: e.style,
|
|
3765
3812
|
time: this.time,
|
|
3766
3813
|
depth: this.depth,
|
|
3767
3814
|
verticalLabel: this.options.verticalLabel
|
|
3768
|
-
}) ??
|
|
3815
|
+
}) ?? et({
|
|
3769
3816
|
baseUrl: e.baseUrl ?? new URL(e.capabilitiesUrl).origin,
|
|
3770
3817
|
layer: e.layer,
|
|
3771
3818
|
tileMatrixSet: e.tileMatrixSet ?? "EPSG:3857",
|
|
@@ -3776,7 +3823,7 @@ class ea {
|
|
|
3776
3823
|
verticalLabel: this.options.verticalLabel
|
|
3777
3824
|
})
|
|
3778
3825
|
] : [
|
|
3779
|
-
|
|
3826
|
+
et({
|
|
3780
3827
|
baseUrl: e.baseUrl ?? new URL(e.capabilitiesUrl).origin,
|
|
3781
3828
|
layer: e.layer,
|
|
3782
3829
|
tileMatrixSet: e.tileMatrixSet ?? "EPSG:3857",
|
|
@@ -3832,13 +3879,13 @@ class ea {
|
|
|
3832
3879
|
function Pe(s, e) {
|
|
3833
3880
|
return s.match(new RegExp(`\\b${e}=["']([^"']+)["']`, "i"))?.[1].replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'");
|
|
3834
3881
|
}
|
|
3835
|
-
function
|
|
3882
|
+
function aa(s, e, t) {
|
|
3836
3883
|
const i = s.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}").replace(/\{TileMatrixSet\}/gi, e), a = t == null ? i : i.replace(/\{Style\}/gi, t);
|
|
3837
3884
|
return [...a.matchAll(/\{([^{}]+)\}/g)].some(
|
|
3838
3885
|
(n) => !/^(?:z|y|x|Time|Elevation)$/i.test(n[1])
|
|
3839
3886
|
) ? void 0 : a;
|
|
3840
3887
|
}
|
|
3841
|
-
function
|
|
3888
|
+
function Ct(s) {
|
|
3842
3889
|
return s.replace(/<[^>]+>/g, "").trim();
|
|
3843
3890
|
}
|
|
3844
3891
|
function be(s, e) {
|
|
@@ -3849,30 +3896,30 @@ function be(s, e) {
|
|
|
3849
3896
|
return [...s.matchAll(t)].map((i) => i[1]);
|
|
3850
3897
|
}
|
|
3851
3898
|
function se(s, e) {
|
|
3852
|
-
return be(s, e).map(
|
|
3899
|
+
return be(s, e).map(Ct).find(Boolean);
|
|
3853
3900
|
}
|
|
3854
|
-
function
|
|
3901
|
+
function tt(s, e) {
|
|
3855
3902
|
const t = e.match(
|
|
3856
3903
|
/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/
|
|
3857
3904
|
);
|
|
3858
3905
|
if (!t || !t.slice(1).some((m) => Number(m) > 0))
|
|
3859
3906
|
return;
|
|
3860
|
-
const i = new Date(s), a = i.getUTCFullYear() + Number(t[1] ?? 0), r = i.getUTCMonth() + Number(t[2] ?? 0), n = i.getUTCDate(), o = i.getUTCHours(),
|
|
3861
|
-
Date.UTC(a, r, 1, o,
|
|
3907
|
+
const i = new Date(s), a = i.getUTCFullYear() + Number(t[1] ?? 0), r = i.getUTCMonth() + Number(t[2] ?? 0), n = i.getUTCDate(), o = i.getUTCHours(), l = i.getUTCMinutes(), d = i.getUTCSeconds(), c = i.getUTCMilliseconds(), u = new Date(
|
|
3908
|
+
Date.UTC(a, r, 1, o, l, d, c)
|
|
3862
3909
|
), f = new Date(
|
|
3863
3910
|
Date.UTC(u.getUTCFullYear(), u.getUTCMonth() + 1, 0)
|
|
3864
3911
|
).getUTCDate();
|
|
3865
3912
|
return u.setUTCDate(Math.min(n, f)), u.setUTCDate(u.getUTCDate() + Number(t[3] ?? 0)), u.setUTCHours(u.getUTCHours() + Number(t[4] ?? 0)), u.setUTCMinutes(u.getUTCMinutes() + Number(t[5] ?? 0)), u.setUTCSeconds(u.getUTCSeconds() + Number(t[6] ?? 0)), u.getTime();
|
|
3866
3913
|
}
|
|
3867
|
-
function
|
|
3914
|
+
function sa(s) {
|
|
3868
3915
|
const e = [];
|
|
3869
3916
|
for (const t of s.flatMap((i) => i.split(","))) {
|
|
3870
3917
|
const i = t.trim().split("/");
|
|
3871
3918
|
if (i.length === 3) {
|
|
3872
|
-
const r = Date.parse(i[0]), n = Date.parse(i[1]), o =
|
|
3919
|
+
const r = Date.parse(i[0]), n = Date.parse(i[1]), o = tt(r, i[2]);
|
|
3873
3920
|
if (Number.isFinite(r) && Number.isFinite(n) && o && o > r)
|
|
3874
|
-
for (let
|
|
3875
|
-
e.push(
|
|
3921
|
+
for (let l = r, d = 0; l <= n && d < 1e5; d += 1)
|
|
3922
|
+
e.push(l), l = tt(l, i[2]);
|
|
3876
3923
|
continue;
|
|
3877
3924
|
}
|
|
3878
3925
|
const a = Date.parse(t.trim());
|
|
@@ -3880,13 +3927,13 @@ function ia(s) {
|
|
|
3880
3927
|
}
|
|
3881
3928
|
return [...new Set(e)].sort((t, i) => t - i);
|
|
3882
3929
|
}
|
|
3883
|
-
function
|
|
3930
|
+
function it(s, e) {
|
|
3884
3931
|
for (const t of be(s, "Dimension"))
|
|
3885
3932
|
if (se(t, "Identifier")?.toLowerCase() === e.toLowerCase())
|
|
3886
|
-
return be(t, "Value").map(
|
|
3933
|
+
return be(t, "Value").map(Ct);
|
|
3887
3934
|
return [];
|
|
3888
3935
|
}
|
|
3889
|
-
function
|
|
3936
|
+
function ra(s, e) {
|
|
3890
3937
|
const t = be(s, "Layer").find(
|
|
3891
3938
|
(h) => se(h, "Identifier") === e.layer
|
|
3892
3939
|
);
|
|
@@ -3895,7 +3942,7 @@ function aa(s, e) {
|
|
|
3895
3942
|
const i = e.tileMatrixSet ?? se(t, "TileMatrixSet") ?? "";
|
|
3896
3943
|
if (!/3857|GoogleMapsCompatible/i.test(i))
|
|
3897
3944
|
throw new Error(`Unsupported WMTS tile matrix set: ${i || "missing"}`);
|
|
3898
|
-
const a =
|
|
3945
|
+
const a = sa(it(t, "time")), r = a.length ? {
|
|
3899
3946
|
min: a[0],
|
|
3900
3947
|
max: a[a.length - 1],
|
|
3901
3948
|
size: a.length,
|
|
@@ -3904,13 +3951,13 @@ function aa(s, e) {
|
|
|
3904
3951
|
step: a.length > 1 && a.every(
|
|
3905
3952
|
(h, g) => g === 0 || h - a[g - 1] === a[1] - a[0]
|
|
3906
3953
|
) ? a[1] - a[0] : void 0
|
|
3907
|
-
} : { min: 0, max: 0, size: 1, values: [0], units: "static" }, n =
|
|
3954
|
+
} : { min: 0, max: 0, size: 1, values: [0], units: "static" }, n = it(t, "elevation").flatMap((h) => h.split(",")).map(Number).filter(Number.isFinite), o = n.length ? { name: "elevation", label: "elevation", values: n } : null, l = s.match(
|
|
3908
3955
|
/GetTile[\s\S]*?(?:xlink:href|href)=["']([^"']+)/i
|
|
3909
|
-
)?.[1],
|
|
3956
|
+
)?.[1], c = [
|
|
3910
3957
|
...t.matchAll(/<(?:(?:\w+):)?ResourceURL\b([^>]*)\/?\s*>/gi)
|
|
3911
3958
|
].find(
|
|
3912
3959
|
(h) => Pe(h[1], "resourceType")?.toLowerCase() === "tile"
|
|
3913
|
-
), u =
|
|
3960
|
+
), u = c ? Pe(c[1], "template") : void 0, f = [
|
|
3914
3961
|
...t.matchAll(
|
|
3915
3962
|
/<(?:(?:\w+):)?Style\b([^>]*)>([\s\S]*?)<\/(?:(?:\w+):)?Style>/gi
|
|
3916
3963
|
)
|
|
@@ -3918,8 +3965,8 @@ function aa(s, e) {
|
|
|
3918
3965
|
(h) => Pe(h[1], "isDefault")?.toLowerCase() === "true"
|
|
3919
3966
|
), p = e.style ?? se(m?.[2] ?? f[0]?.[2] ?? "", "Identifier");
|
|
3920
3967
|
return {
|
|
3921
|
-
baseUrl: e.baseUrl ??
|
|
3922
|
-
tileUrlTemplate: e.tileUrlTemplate ?? (u ?
|
|
3968
|
+
baseUrl: e.baseUrl ?? l ?? new URL(e.capabilitiesUrl).origin,
|
|
3969
|
+
tileUrlTemplate: e.tileUrlTemplate ?? (u ? aa(u, i, p) : void 0),
|
|
3923
3970
|
tileMatrixSet: i,
|
|
3924
3971
|
format: e.format ?? se(t, "Format") ?? "image/png",
|
|
3925
3972
|
style: p,
|
|
@@ -3927,15 +3974,15 @@ function aa(s, e) {
|
|
|
3927
3974
|
vertical: o
|
|
3928
3975
|
};
|
|
3929
3976
|
}
|
|
3930
|
-
async function
|
|
3977
|
+
async function na(s, e) {
|
|
3931
3978
|
const t = await fetch(s.capabilitiesUrl, { signal: e });
|
|
3932
3979
|
if (!t.ok)
|
|
3933
3980
|
throw new Error(
|
|
3934
3981
|
`WMTS capabilities request failed (${t.status}): ${s.capabilitiesUrl}`
|
|
3935
3982
|
);
|
|
3936
|
-
return
|
|
3983
|
+
return ra(await t.text(), s);
|
|
3937
3984
|
}
|
|
3938
|
-
const
|
|
3985
|
+
const oa = [
|
|
3939
3986
|
0.25,
|
|
3940
3987
|
0.5,
|
|
3941
3988
|
1,
|
|
@@ -3944,8 +3991,8 @@ const ra = [
|
|
|
3944
3991
|
8,
|
|
3945
3992
|
16,
|
|
3946
3993
|
32
|
|
3947
|
-
],
|
|
3948
|
-
function
|
|
3994
|
+
], at = [0.25, 0.5, 1, 2];
|
|
3995
|
+
function st(s, e) {
|
|
3949
3996
|
if (s.length === 0)
|
|
3950
3997
|
return e;
|
|
3951
3998
|
let t = s[0], i;
|
|
@@ -3953,8 +4000,8 @@ function at(s, e) {
|
|
|
3953
4000
|
a < t && (t = a), a <= e && (i === void 0 || a > i) && (i = a);
|
|
3954
4001
|
return i ?? t;
|
|
3955
4002
|
}
|
|
3956
|
-
function
|
|
3957
|
-
const e = s.map((n) => new Date(n)), t = (n) => n.every((o) => e.every((
|
|
4003
|
+
function la(s) {
|
|
4004
|
+
const e = s.map((n) => new Date(n)), t = (n) => n.every((o) => e.every((l) => o(l) === o(e[0]))), i = [
|
|
3958
4005
|
(n) => n.getUTCHours(),
|
|
3959
4006
|
(n) => n.getUTCMinutes(),
|
|
3960
4007
|
(n) => n.getUTCSeconds(),
|
|
@@ -3965,7 +4012,7 @@ function na(s) {
|
|
|
3965
4012
|
return "year";
|
|
3966
4013
|
if (t([(o) => o.getUTCDate(), ...i]))
|
|
3967
4014
|
return "month";
|
|
3968
|
-
const n = s.slice(1).map((o,
|
|
4015
|
+
const n = s.slice(1).map((o, l) => o - s[l]);
|
|
3969
4016
|
return t(i) && n.every((o) => o % 864e5 === 0) ? "day" : t(i.slice(1)) && n.every((o) => o % 36e5 === 0) ? "hour" : t(i.slice(2)) && n.every((o) => o % 6e4 === 0) ? "minute" : "second";
|
|
3970
4017
|
}
|
|
3971
4018
|
const a = e[0];
|
|
@@ -3974,7 +4021,7 @@ function na(s) {
|
|
|
3974
4021
|
const r = a.getUTCHours() === 0 && a.getUTCMinutes() === 0 && a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0;
|
|
3975
4022
|
return r && a.getUTCMonth() === 0 && a.getUTCDate() === 1 ? "year" : r && a.getUTCDate() === 1 ? "month" : r ? "day" : a.getUTCMinutes() === 0 && a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0 ? "hour" : a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0 ? "minute" : "second";
|
|
3976
4023
|
}
|
|
3977
|
-
function
|
|
4024
|
+
function kt(s) {
|
|
3978
4025
|
if (s.length < 2)
|
|
3979
4026
|
return;
|
|
3980
4027
|
const e = s[1] - s[0];
|
|
@@ -3983,7 +4030,7 @@ function At(s) {
|
|
|
3983
4030
|
) ? e : void 0;
|
|
3984
4031
|
}
|
|
3985
4032
|
function re(s, e) {
|
|
3986
|
-
return e ?
|
|
4033
|
+
return e ? bt(e, [
|
|
3987
4034
|
s.values[0],
|
|
3988
4035
|
s.values[s.values.length - 1]
|
|
3989
4036
|
]) : null;
|
|
@@ -4002,11 +4049,11 @@ function ne(s, e) {
|
|
|
4002
4049
|
min: r[0],
|
|
4003
4050
|
max: r[r.length - 1],
|
|
4004
4051
|
size: r.length,
|
|
4005
|
-
step:
|
|
4052
|
+
step: kt(r),
|
|
4006
4053
|
values: r
|
|
4007
4054
|
};
|
|
4008
4055
|
}
|
|
4009
|
-
function
|
|
4056
|
+
function rt(s, e) {
|
|
4010
4057
|
const { start: t, end: i } = s.temporal ?? {};
|
|
4011
4058
|
return t || i ? ne(e, { start: t, end: i }) : e;
|
|
4012
4059
|
}
|
|
@@ -4020,14 +4067,14 @@ function Ee(s, e) {
|
|
|
4020
4067
|
const t = s.sources.filter(Fe);
|
|
4021
4068
|
return t.find((i) => i.id === e) ?? (e === "geovideo" || e === "auto" ? t[0] : void 0);
|
|
4022
4069
|
}
|
|
4023
|
-
function
|
|
4070
|
+
function Ft(s) {
|
|
4024
4071
|
return [...s].sort((e, t) => {
|
|
4025
4072
|
const i = Math.abs(e), a = Math.abs(t);
|
|
4026
4073
|
return i !== a ? i - a : t - e;
|
|
4027
4074
|
});
|
|
4028
4075
|
}
|
|
4029
4076
|
function Le(s, e) {
|
|
4030
|
-
return s?.values.length ? e == null ?
|
|
4077
|
+
return s?.values.length ? e == null ? Ft(s.values)[0] : V(s.values, e) : e ?? 0;
|
|
4031
4078
|
}
|
|
4032
4079
|
function V(s, e) {
|
|
4033
4080
|
if (s.length === 0)
|
|
@@ -4039,7 +4086,7 @@ function V(s, e) {
|
|
|
4039
4086
|
}
|
|
4040
4087
|
return t;
|
|
4041
4088
|
}
|
|
4042
|
-
function
|
|
4089
|
+
function nt(s) {
|
|
4043
4090
|
for (const [e, t] of [
|
|
4044
4091
|
[s?.playbackRate, "Playback rate"],
|
|
4045
4092
|
[s?.stepsPerSecond, "Steps per second"]
|
|
@@ -4047,14 +4094,14 @@ function rt(s) {
|
|
|
4047
4094
|
if (e != null && (!Number.isFinite(e) || e <= 0))
|
|
4048
4095
|
throw new Error(`${t} must be positive`);
|
|
4049
4096
|
}
|
|
4050
|
-
function
|
|
4097
|
+
function ot(s, e) {
|
|
4051
4098
|
const t = s.surface?.value ?? 0, i = V(
|
|
4052
4099
|
[t, ...s.depths.map((a) => a.value)],
|
|
4053
4100
|
e
|
|
4054
4101
|
);
|
|
4055
4102
|
return i === t ? null : i;
|
|
4056
4103
|
}
|
|
4057
|
-
function
|
|
4104
|
+
function ca(s) {
|
|
4058
4105
|
const e = s.surface ?? s.depths[0];
|
|
4059
4106
|
return {
|
|
4060
4107
|
name: e.name,
|
|
@@ -4066,24 +4113,24 @@ function oa(s) {
|
|
|
4066
4113
|
]
|
|
4067
4114
|
};
|
|
4068
4115
|
}
|
|
4069
|
-
function
|
|
4116
|
+
function lt(s, e) {
|
|
4070
4117
|
return JSON.stringify([
|
|
4071
4118
|
s?.values ?? null,
|
|
4072
4119
|
e ? [e.name, e.units, e.values] : null
|
|
4073
4120
|
]);
|
|
4074
4121
|
}
|
|
4075
|
-
function
|
|
4122
|
+
function ha(s) {
|
|
4076
4123
|
const e = [...new Set(s)].sort((t, i) => t - i);
|
|
4077
4124
|
return {
|
|
4078
4125
|
min: e[0],
|
|
4079
4126
|
max: e[e.length - 1],
|
|
4080
|
-
step:
|
|
4127
|
+
step: kt(e),
|
|
4081
4128
|
size: e.length,
|
|
4082
4129
|
units: "milliseconds since 1970-01-01T00:00:00Z",
|
|
4083
4130
|
values: e
|
|
4084
4131
|
};
|
|
4085
4132
|
}
|
|
4086
|
-
const
|
|
4133
|
+
const ua = 5 * 6e4, da = 6e4, ct = 6;
|
|
4087
4134
|
function pe(s) {
|
|
4088
4135
|
const { particles: e = {}, raster: t = {} } = s, i = {
|
|
4089
4136
|
palette: s.palette,
|
|
@@ -4093,7 +4140,7 @@ function pe(s) {
|
|
|
4093
4140
|
speed: e.speed,
|
|
4094
4141
|
fade: e.fade,
|
|
4095
4142
|
glow: e.glow,
|
|
4096
|
-
colorGrade: e.grade === void 0 ? void 0 :
|
|
4143
|
+
colorGrade: e.grade === void 0 ? void 0 : gi(e.grade),
|
|
4097
4144
|
opacity: t.opacity,
|
|
4098
4145
|
logScale: t.logScale,
|
|
4099
4146
|
vibrance: t.vibrance,
|
|
@@ -4111,25 +4158,25 @@ function Ve(s) {
|
|
|
4111
4158
|
const e = s.alphaFadeLow ?? 0, t = s.alphaFadeHigh ?? 0;
|
|
4112
4159
|
return e > 0 || t > 0 ? { low: e, high: t, curve: s.alphaFadeCurve ?? "linear" } : void 0;
|
|
4113
4160
|
}
|
|
4114
|
-
const
|
|
4115
|
-
|
|
4116
|
-
),
|
|
4161
|
+
const ht = "rdylbu", ma = new Set(
|
|
4162
|
+
xt({ includeDeprecated: !0 }).map((s) => s.id)
|
|
4163
|
+
), ut = /* @__PURE__ */ new Set();
|
|
4117
4164
|
function Ne(s) {
|
|
4118
|
-
return typeof s != "string" ||
|
|
4119
|
-
`[zartigl] palette "${s}" is not in this version: drawn with "${
|
|
4120
|
-
)),
|
|
4165
|
+
return typeof s != "string" || ma.has(s) ? s : (ut.has(s) || (ut.add(s), console.warn(
|
|
4166
|
+
`[zartigl] palette "${s}" is not in this version: drawn with "${ht}"`
|
|
4167
|
+
)), ht);
|
|
4121
4168
|
}
|
|
4122
4169
|
function De(s) {
|
|
4123
4170
|
const { reversePalette: e } = s, t = Ne(s.palette), i = Ve(s);
|
|
4124
4171
|
return t != null && (e || i) ? ke(t, { reverse: e, alphaFade: i }) : t;
|
|
4125
4172
|
}
|
|
4126
|
-
const
|
|
4173
|
+
const fa = [
|
|
4127
4174
|
"palette",
|
|
4128
4175
|
"reversePalette",
|
|
4129
4176
|
"alphaFadeLow",
|
|
4130
4177
|
"alphaFadeHigh",
|
|
4131
4178
|
"alphaFadeCurve"
|
|
4132
|
-
],
|
|
4179
|
+
], It = Object.freeze({
|
|
4133
4180
|
palette: "style.palette",
|
|
4134
4181
|
renderMode: "style.renderMode",
|
|
4135
4182
|
particleDensity: "style.particles.density",
|
|
@@ -4151,13 +4198,13 @@ function Ae(s) {
|
|
|
4151
4198
|
fade: r,
|
|
4152
4199
|
colorGrade: n,
|
|
4153
4200
|
opacity: o,
|
|
4154
|
-
logScale:
|
|
4201
|
+
logScale: l,
|
|
4155
4202
|
vibrance: d,
|
|
4156
|
-
colorDomain:
|
|
4203
|
+
colorDomain: c,
|
|
4157
4204
|
backdrop: u,
|
|
4158
4205
|
...f
|
|
4159
4206
|
} = s ?? {}, m = Object.keys(s ?? {}).filter(
|
|
4160
|
-
(h) => h in
|
|
4207
|
+
(h) => h in It && s[h] !== void 0
|
|
4161
4208
|
);
|
|
4162
4209
|
return {
|
|
4163
4210
|
style: ae({
|
|
@@ -4167,23 +4214,23 @@ function Ae(s) {
|
|
|
4167
4214
|
density: i,
|
|
4168
4215
|
speed: a,
|
|
4169
4216
|
fade: r,
|
|
4170
|
-
grade: n &&
|
|
4217
|
+
grade: n && pi(n),
|
|
4171
4218
|
backdrop: u
|
|
4172
4219
|
},
|
|
4173
|
-
raster: { opacity: o, logScale:
|
|
4220
|
+
raster: { opacity: o, logScale: l, vibrance: d, colorDomain: c }
|
|
4174
4221
|
}),
|
|
4175
4222
|
settings: e === void 0 || typeof e == "string" ? f : { ...f, palette: e },
|
|
4176
4223
|
legacyKeys: m
|
|
4177
4224
|
};
|
|
4178
4225
|
}
|
|
4179
|
-
const
|
|
4180
|
-
function
|
|
4226
|
+
const dt = /* @__PURE__ */ new Set();
|
|
4227
|
+
function mt(s) {
|
|
4181
4228
|
for (const e of s)
|
|
4182
|
-
|
|
4183
|
-
`[zartigl] settings.${e} is deprecated: use ${
|
|
4229
|
+
dt.has(e) || (dt.add(e), console.warn(
|
|
4230
|
+
`[zartigl] settings.${e} is deprecated: use ${It[e]}`
|
|
4184
4231
|
));
|
|
4185
4232
|
}
|
|
4186
|
-
function
|
|
4233
|
+
function Ut(s, e) {
|
|
4187
4234
|
const t = ze(s, e);
|
|
4188
4235
|
return {
|
|
4189
4236
|
...pe(t),
|
|
@@ -4191,23 +4238,23 @@ function Ft(s, e) {
|
|
|
4191
4238
|
colorDomain: Q(t.raster.colorDomain)
|
|
4192
4239
|
};
|
|
4193
4240
|
}
|
|
4194
|
-
function
|
|
4241
|
+
function pa(s) {
|
|
4195
4242
|
return {
|
|
4196
|
-
...
|
|
4243
|
+
...Ut(s),
|
|
4197
4244
|
particleState: "auto",
|
|
4198
4245
|
rgba8MaxParticleZoom: 4
|
|
4199
4246
|
};
|
|
4200
4247
|
}
|
|
4201
|
-
function
|
|
4248
|
+
function ga(s) {
|
|
4202
4249
|
const { palette: e, ...t } = s;
|
|
4203
4250
|
return t;
|
|
4204
4251
|
}
|
|
4205
|
-
function
|
|
4206
|
-
s !== void 0 &&
|
|
4252
|
+
function ft(s, e, t) {
|
|
4253
|
+
s !== void 0 && pt(s, "style", {
|
|
4207
4254
|
kind: e.layers.find((i) => i.id === t)?.kind
|
|
4208
4255
|
});
|
|
4209
4256
|
}
|
|
4210
|
-
class
|
|
4257
|
+
class Ca {
|
|
4211
4258
|
constructor(e) {
|
|
4212
4259
|
if (this.fullTimeMeta = null, this.autoplayPending = !0, this.playing = !1, this.catalogLayer = null, this.catalogSource = null, this.layer = null, this.time = 0, this.pendingTime = null, this.requestedTime = null, this.playbackIntent = 0, this.requestSeq = 0, this.playSeq = 0, this.depth = 0, this.depthRequest = null, this.failedGeoVideo = /* @__PURE__ */ new Set(), this.lastMeta = null, this.timeMeta = null, this.resolvedTimeRange = null, this.verticalMeta = null, this.variableUnit = "", this.geoVideoManifest = null, this.wmtsMetadata = null, this.fieldSources = /* @__PURE__ */ new Map(), this.archiveChunks = /* @__PURE__ */ new Map(), this.chunkTimes = /* @__PURE__ */ new Map(), this.archiveRoots = /* @__PURE__ */ new Map(), this.archiveLevel = null, this.depthLocked = !1, this.chunkLevels = /* @__PURE__ */ new Map(), this.nextChunkManifest = null, this.activeFieldSource = null, this.switchGeneration = 0, this.destroyed = !1, this.initialized = !1, this.initStarted = !1, this.updateQueue = Promise.resolve(), this.suspended = !1, this.attachQueued = !1, this.anchor = null, this.querySources = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Map(), this.onMapReady = () => {
|
|
4213
4260
|
this.attachQueued && this.attachWhenReady();
|
|
@@ -4215,9 +4262,9 @@ class Da {
|
|
|
4215
4262
|
throw new Error("Zartigl requires a layer UUID");
|
|
4216
4263
|
if (e.time != null && z(e.time, "time"), e.depth != null && !Number.isFinite(e.depth))
|
|
4217
4264
|
throw new Error("Depth must be finite");
|
|
4218
|
-
|
|
4265
|
+
nt(e.geoVideo), this.id = e.id ?? "zartigl", this.map = e.map, this.catalog = e.catalog, this.initialLayer = e.layer, this.initialTime = e.time, this.initialDepth = e.depth, this.depthRequest = e.depth ?? null, this.sourcePreference = e.source ?? "auto", this.timeRange = e.timeRange ? { ...e.timeRange } : void 0, this.autoplay = e.geoVideo?.autoplay ?? !0, this.loop = e.geoVideo?.loop ?? !0, this.playbackRate = e.geoVideo?.playbackRate ?? 1, this.stepsPerSecond = e.geoVideo?.stepsPerSecond ?? null, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.before = e.before, this.visible = e.visible ?? !0;
|
|
4219
4266
|
const t = Ae(e.settings);
|
|
4220
|
-
|
|
4267
|
+
mt(t.legacyKeys), this.style = ae(t.style, e.style), ft(this.style, e.catalog, e.layer), this.settings = { ...t.settings, ...pe(this.style) }, this.settings.colorDomain !== void 0 && (this.settings.colorDomain = Q(
|
|
4221
4268
|
this.settings.colorDomain
|
|
4222
4269
|
)), this.colorDomainOverridden = this.settings.colorDomain !== void 0, this.paletteOverridden = this.settings.palette !== void 0, this.map.on("load", this.onMapReady), this.map.on("styledata", this.onMapReady), this.map.on("idle", this.onMapReady);
|
|
4223
4270
|
}
|
|
@@ -4235,15 +4282,15 @@ class Da {
|
|
|
4235
4282
|
async update(e) {
|
|
4236
4283
|
this.assertAlive();
|
|
4237
4284
|
const t = Ae(e.settings);
|
|
4238
|
-
|
|
4285
|
+
mt(t.legacyKeys);
|
|
4239
4286
|
const i = t.legacyKeys.length ? { ...e, settings: t.settings, stylePatch: t.style } : e;
|
|
4240
4287
|
if (!this.initialized)
|
|
4241
4288
|
throw new Error("Call init() before update()");
|
|
4242
4289
|
if (i.depth != null && !Number.isFinite(i.depth))
|
|
4243
4290
|
throw new Error("Depth must be finite");
|
|
4244
|
-
i.time != null && z(i.time, "time"),
|
|
4291
|
+
i.time != null && z(i.time, "time"), nt(i.geoVideo), i.settings?.colorDomain !== void 0 && Q(i.settings.colorDomain);
|
|
4245
4292
|
for (const a of [i.style, i.stylePatch])
|
|
4246
|
-
a !== void 0 &&
|
|
4293
|
+
a !== void 0 && pt(a, "style");
|
|
4247
4294
|
return i.time != null && this.pause(), this.enqueue(i, ++this.requestSeq);
|
|
4248
4295
|
}
|
|
4249
4296
|
/**
|
|
@@ -4265,11 +4312,11 @@ class Da {
|
|
|
4265
4312
|
}
|
|
4266
4313
|
async applyUpdate(e, t, i) {
|
|
4267
4314
|
this.assertAlive(), i != null && e.time != null && this.playSeq !== 0 && this.playSeq < i && this.pause();
|
|
4268
|
-
const a = e.layer != null && e.layer !== this.catalogLayer?.id, r = e.source != null && (a || e.source !== this.sourcePreference), n = !a && e.source === "auto" && this.sourcePreference === "auto", o = { time: e.time, depth: e.depth },
|
|
4269
|
-
|
|
4270
|
-
const f = u ?? (a ?
|
|
4315
|
+
const a = e.layer != null && e.layer !== this.catalogLayer?.id, r = e.source != null && (a || e.source !== this.sourcePreference), n = !a && e.source === "auto" && this.sourcePreference === "auto", o = { time: e.time, depth: e.depth }, l = a ? e.layer : this.catalogLayer?.id, d = e.stylePatch === void 0 ? e.style : e.style === void 0 ? ae(this.style, e.stylePatch) : ae(e.stylePatch, e.style), c = e.settings?.palette, u = d !== void 0 && c !== void 0 && typeof c != "string" && e.style?.palette === void 0 ? ga(d) : d;
|
|
4316
|
+
ft(u, this.catalog, l);
|
|
4317
|
+
const f = u ?? (a ? gt(
|
|
4271
4318
|
this.style,
|
|
4272
|
-
this.catalog.layers.find((m) => m.id ===
|
|
4319
|
+
this.catalog.layers.find((m) => m.id === l)?.kind
|
|
4273
4320
|
) : void 0);
|
|
4274
4321
|
if (a) {
|
|
4275
4322
|
const m = { ...e.settings, ...pe(f) };
|
|
@@ -4316,10 +4363,10 @@ class Da {
|
|
|
4316
4363
|
e.geoVideo && (e.geoVideo.autoplay != null && (this.autoplay = e.geoVideo.autoplay, this.catalogSource?.type === "geovideo" && (this.autoplay ? await this.startPlayback(i ?? ++this.requestSeq) : this.pause())), e.geoVideo.loop != null && this.applyLoop(e.geoVideo.loop), e.geoVideo.stepsPerSecond != null ? (this.stepsPerSecond = e.geoVideo.stepsPerSecond, this.applyPlaybackSpeed()) : e.geoVideo.playbackRate != null && this.applyPlaybackRate(e.geoVideo.playbackRate)), e.time != null && e.depth != null ? this.applyTimeAndDepth(e.time, e.depth) : (e.time != null && this.applyTime(e.time), e.depth != null && this.applyDepth(e.depth)), e.time != null && this.requestedTime === z(e.time, "time") && (this.requestedTime = null), e.visible != null && this.applyVisible(e.visible);
|
|
4317
4364
|
}
|
|
4318
4365
|
async loadLayer(e, t = this.sourcePreference, i, a) {
|
|
4319
|
-
const r = this.getSource(), n =
|
|
4366
|
+
const r = this.getSource(), n = lt(this.timeMeta, this.verticalMeta);
|
|
4320
4367
|
await this.loadSource(e, t, i, a);
|
|
4321
4368
|
const o = this.getSource();
|
|
4322
|
-
o && (o.id !== r?.id || o.type !== r?.type) ? this.emit("sourceChange", o) :
|
|
4369
|
+
o && (o.id !== r?.id || o.type !== r?.type) ? this.emit("sourceChange", o) : lt(this.timeMeta, this.verticalMeta) !== n && this.emit("axesChange");
|
|
4323
4370
|
}
|
|
4324
4371
|
async loadSource(e, t, i, a) {
|
|
4325
4372
|
this.assertAlive();
|
|
@@ -4328,43 +4375,43 @@ class Da {
|
|
|
4328
4375
|
);
|
|
4329
4376
|
if (!r)
|
|
4330
4377
|
throw new Error(`Unknown zartigl catalog entry: ${e}`);
|
|
4331
|
-
const n =
|
|
4378
|
+
const n = pa(r), o = i ? i.timeRange : this.timeRange, l = a ?? ++this.switchGeneration, d = {
|
|
4332
4379
|
...i?.target,
|
|
4333
4380
|
depth: i?.target?.depth ?? this.depthRequest ?? void 0
|
|
4334
|
-
},
|
|
4381
|
+
}, c = await this.selectSource(
|
|
4335
4382
|
r,
|
|
4336
4383
|
t,
|
|
4337
4384
|
o,
|
|
4338
4385
|
d
|
|
4339
4386
|
), u = i?.settings ?? this.settings, f = i?.colorDomainOverridden ?? this.colorDomainOverridden, m = i?.paletteOverridden ?? this.paletteOverridden;
|
|
4340
|
-
if (
|
|
4387
|
+
if (c.type === "geovideo") {
|
|
4341
4388
|
this.emit("status", { phase: "metadata" });
|
|
4342
4389
|
try {
|
|
4343
|
-
if (!
|
|
4390
|
+
if (!c.manifestUrl)
|
|
4344
4391
|
throw new Error(
|
|
4345
|
-
`GeoVideo archive source was not resolved to a chunk: ${
|
|
4392
|
+
`GeoVideo archive source was not resolved to a chunk: ${c.id}`
|
|
4346
4393
|
);
|
|
4347
4394
|
const v = await this.loadChunkManifest(
|
|
4348
|
-
|
|
4395
|
+
c.manifestUrl
|
|
4349
4396
|
), _ = r.sources.find(
|
|
4350
4397
|
(ce) => ce.id === v.provenance.inputSourceId
|
|
4351
4398
|
);
|
|
4352
|
-
if (v.id !==
|
|
4399
|
+
if (v.id !== c.id || v.provenance.catalogEntryId !== r.id || _?.type !== "zarr")
|
|
4353
4400
|
throw new Error(
|
|
4354
|
-
`GeoVideo manifest identity does not match catalog entry/source: ${
|
|
4401
|
+
`GeoVideo manifest identity does not match catalog entry/source: ${c.id}`
|
|
4355
4402
|
);
|
|
4356
|
-
const S = Ee(r,
|
|
4357
|
-
if (S && (
|
|
4403
|
+
const S = Ee(r, c.id), E = S ? this.chunkLevels.get(c.manifestUrl) ?? null : null, R = v.vertical;
|
|
4404
|
+
if (S && (E ? !He(R, E) : R !== void 0))
|
|
4358
4405
|
throw new Error(
|
|
4359
|
-
`GeoVideo manifest level does not match its index: ${
|
|
4406
|
+
`GeoVideo manifest level does not match its index: ${c.manifestUrl}`
|
|
4360
4407
|
);
|
|
4361
|
-
const k =
|
|
4362
|
-
if (
|
|
4408
|
+
const k = E?.value ?? null, F = S ? await this.archiveTimes(r, c.id, k) : null, L = S ? await this.archiveLevels(r, S) : null, D = !!L?.depths.length, b = !D && !!L?.surface, A = D || b ? ca(L) : null;
|
|
4409
|
+
if (l !== this.switchGeneration)
|
|
4363
4410
|
throw new DOMException(
|
|
4364
4411
|
"Layer selection was superseded",
|
|
4365
4412
|
"AbortError"
|
|
4366
4413
|
);
|
|
4367
|
-
const N = we(v), C =
|
|
4414
|
+
const N = we(v), C = ha(F ?? N), I = re(
|
|
4368
4415
|
C,
|
|
4369
4416
|
o
|
|
4370
4417
|
), w = ne(
|
|
@@ -4373,59 +4420,59 @@ class Da {
|
|
|
4373
4420
|
), U = N.filter(
|
|
4374
4421
|
(ce) => ce >= w.min && ce <= w.max
|
|
4375
4422
|
), X = U.length ? U : N, oe = this.catalogLayer?.id === r.id && this.catalogSource?.type === "geovideo", le = this.settings.palette;
|
|
4376
|
-
this.catalogLayer = r, this.catalogSource =
|
|
4377
|
-
const
|
|
4378
|
-
if (this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ?
|
|
4423
|
+
this.catalogLayer = r, this.catalogSource = c, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = v, this.wmtsMetadata = null, this.fullTimeMeta = C, this.resolvedTimeRange = I, this.timeMeta = w, this.verticalMeta = A, this.variableUnit = v.style.unit ?? "", this.variableStandardName = v.provenance.variables[0], this.time = this.pendingTime == null ? X[0] : V(X, this.pendingTime), this.pendingTime = null, this.depthLocked = b, this.archiveLevel = k, this.depth = D ? k ?? L.surface?.value ?? 0 : Le(A, d.depth), D && (this.depthRequest = this.depth);
|
|
4424
|
+
const Ot = u.colorDomain;
|
|
4425
|
+
if (this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? Ot ?? null : v.style.colorDomain, this.settings.palette = m ? this.settings.palette : qe(r.defaults).palette ?? v.style.palette, this.lastMeta = null, oe && this.replaceGeoVideoInPlace(le))
|
|
4379
4426
|
return;
|
|
4380
4427
|
this.detach(), this.attachWhenReady();
|
|
4381
4428
|
return;
|
|
4382
4429
|
} catch (v) {
|
|
4383
|
-
const _ = v instanceof Error ? v : new Error(String(v)), S =
|
|
4384
|
-
if (_.name !== "AbortError" && !(_ instanceof RangeError) && t === "auto" && S && !this.failedGeoVideo.has(S) && this.catalogSource?.id !==
|
|
4385
|
-
return console.warn("[zartigl] GeoVideo unavailable, falling back:", _), this.failedGeoVideo.add(S), this.loadSource(e, t, i,
|
|
4430
|
+
const _ = v instanceof Error ? v : new Error(String(v)), S = c.manifestUrl;
|
|
4431
|
+
if (_.name !== "AbortError" && !(_ instanceof RangeError) && t === "auto" && S && !this.failedGeoVideo.has(S) && this.catalogSource?.id !== c.id)
|
|
4432
|
+
return console.warn("[zartigl] GeoVideo unavailable, falling back:", _), this.failedGeoVideo.add(S), this.loadSource(e, t, i, l);
|
|
4386
4433
|
throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
|
|
4387
4434
|
}
|
|
4388
4435
|
}
|
|
4389
|
-
if (
|
|
4436
|
+
if (c.type === "wmts") {
|
|
4390
4437
|
this.emit("status", { phase: "metadata" });
|
|
4391
4438
|
try {
|
|
4392
|
-
const v = await
|
|
4393
|
-
if (
|
|
4439
|
+
const v = await na(c);
|
|
4440
|
+
if (l !== this.switchGeneration)
|
|
4394
4441
|
throw new DOMException(
|
|
4395
4442
|
"Layer selection was superseded",
|
|
4396
4443
|
"AbortError"
|
|
4397
4444
|
);
|
|
4398
4445
|
const _ = v.time, S = ne(_, o);
|
|
4399
4446
|
this.detach(), this.catalogLayer = r, this.catalogSource = {
|
|
4400
|
-
...
|
|
4447
|
+
...c,
|
|
4401
4448
|
baseUrl: v.baseUrl,
|
|
4402
|
-
tileUrlTemplate:
|
|
4449
|
+
tileUrlTemplate: c.tileUrlTemplate ?? v.tileUrlTemplate,
|
|
4403
4450
|
tileMatrixSet: v.tileMatrixSet,
|
|
4404
4451
|
format: v.format,
|
|
4405
|
-
style:
|
|
4452
|
+
style: c.style ?? v.style
|
|
4406
4453
|
}, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = null, this.wmtsMetadata = v, this.fullTimeMeta = _, this.resolvedTimeRange = re(
|
|
4407
4454
|
_,
|
|
4408
4455
|
o
|
|
4409
|
-
), this.timeMeta = S, this.verticalMeta = v.vertical, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = "", this.variableStandardName =
|
|
4456
|
+
), this.timeMeta = S, this.verticalMeta = v.vertical, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = "", this.variableStandardName = c.layer, this.time = this.pendingTime == null ? st(S.values, Date.now()) : V(S.values, this.pendingTime), this.pendingTime = null, this.depth = Le(v.vertical, d.depth), this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.lastMeta = null, this.attachWhenReady();
|
|
4410
4457
|
return;
|
|
4411
4458
|
} catch (v) {
|
|
4412
4459
|
const _ = v instanceof Error ? v : new Error(String(v));
|
|
4413
4460
|
throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
|
|
4414
4461
|
}
|
|
4415
4462
|
}
|
|
4416
|
-
const p = this.getFieldSource(
|
|
4463
|
+
const p = this.getFieldSource(c.endpoints.field);
|
|
4417
4464
|
let h, g, x, T, M;
|
|
4418
4465
|
this.emit("status", { phase: "metadata" });
|
|
4419
4466
|
try {
|
|
4420
4467
|
await p.init();
|
|
4421
|
-
const v = fe(
|
|
4468
|
+
const v = fe(c);
|
|
4422
4469
|
for (const _ of v)
|
|
4423
4470
|
if (!p.hasVariable(_))
|
|
4424
4471
|
throw new Error(
|
|
4425
4472
|
`Configured variable not found in Zarr store: ${_}`
|
|
4426
4473
|
);
|
|
4427
|
-
if (g =
|
|
4428
|
-
|
|
4474
|
+
if (g = rt(
|
|
4475
|
+
c,
|
|
4429
4476
|
p.getTimeDimension()
|
|
4430
4477
|
), g.values.length === 0)
|
|
4431
4478
|
throw new Error("Zarr time coordinate is empty");
|
|
@@ -4436,9 +4483,9 @@ class Da {
|
|
|
4436
4483
|
const _ = v instanceof Error ? v : new Error(String(v));
|
|
4437
4484
|
throw this.emit("status", { phase: "error", error: _ }), this.emit("error", _), _;
|
|
4438
4485
|
}
|
|
4439
|
-
if (
|
|
4486
|
+
if (l !== this.switchGeneration)
|
|
4440
4487
|
throw new DOMException("Layer selection was superseded", "AbortError");
|
|
4441
|
-
this.detach(), this.catalogLayer = r, this.catalogSource =
|
|
4488
|
+
this.detach(), this.catalogLayer = r, this.catalogSource = c, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = p, this.geoVideoManifest = null, this.wmtsMetadata = null, this.fullTimeMeta = g, this.resolvedTimeRange = x, this.timeMeta = h, this.verticalMeta = T, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = typeof M.units == "string" ? M.units : "", this.variableStandardName = typeof M.standard_name == "string" ? M.standard_name : void 0, this.time = this.pendingTime == null ? st(this.timeMeta.values, Date.now()) : V(this.timeMeta.values, this.pendingTime), this.pendingTime = null, this.depth = Le(T, d.depth);
|
|
4442
4489
|
const y = u.colorDomain;
|
|
4443
4490
|
this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? y ?? null : n.colorDomain ?? null, this.lastMeta = null, this.attachWhenReady();
|
|
4444
4491
|
}
|
|
@@ -4464,8 +4511,8 @@ class Da {
|
|
|
4464
4511
|
const a = this.catalogLayer, r = this.catalogSource;
|
|
4465
4512
|
if (!a || !r || !this.isArchiveChunk(r))
|
|
4466
4513
|
return !1;
|
|
4467
|
-
const n = Ee(a, this.sourcePreference), o = n ? await this.archiveLevels(a, n) : null, d = !!o?.depths.length && t.depth != null &&
|
|
4468
|
-
if ((t.time == null && !i ||
|
|
4514
|
+
const n = Ee(a, this.sourcePreference), o = n ? await this.archiveLevels(a, n) : null, d = !!o?.depths.length && t.depth != null && ot(o, t.depth) !== this.archiveLevel;
|
|
4515
|
+
if ((t.time == null && !i || Bt(r, this.sourceTimeRequest(e, t.time))) && !d)
|
|
4469
4516
|
return !1;
|
|
4470
4517
|
const u = await this.selectSource(
|
|
4471
4518
|
a,
|
|
@@ -4473,7 +4520,7 @@ class Da {
|
|
|
4473
4520
|
e,
|
|
4474
4521
|
t
|
|
4475
4522
|
);
|
|
4476
|
-
return !
|
|
4523
|
+
return !ii(u, r);
|
|
4477
4524
|
}
|
|
4478
4525
|
applyVisible(e) {
|
|
4479
4526
|
this.assertAlive(), this.visible !== e && (this.visible = e, e ? this.attachWhenReady() : this.detach());
|
|
@@ -4546,10 +4593,10 @@ class Da {
|
|
|
4546
4593
|
}
|
|
4547
4594
|
/** Media rate for the loaded artifact: steps per second when set, else the raw multiplier. */
|
|
4548
4595
|
effectivePlaybackRate() {
|
|
4549
|
-
return this.stepsPerSecond != null && this.geoVideoManifest ?
|
|
4596
|
+
return this.stepsPerSecond != null && this.geoVideoManifest ? ai(this.geoVideoManifest, this.stepsPerSecond) : this.playbackRate;
|
|
4550
4597
|
}
|
|
4551
4598
|
playbackSpeeds() {
|
|
4552
|
-
return this.catalogLayer?.kind === "vector" ?
|
|
4599
|
+
return this.catalogLayer?.kind === "vector" ? at : oa;
|
|
4553
4600
|
}
|
|
4554
4601
|
/**
|
|
4555
4602
|
* Steps per second the active source shows. Vector GeoVideo stays inside
|
|
@@ -4557,13 +4604,13 @@ class Da {
|
|
|
4557
4604
|
*/
|
|
4558
4605
|
appliedStepsPerSecond() {
|
|
4559
4606
|
if (this.catalogLayer?.kind === "vector") {
|
|
4560
|
-
const e =
|
|
4607
|
+
const e = at;
|
|
4561
4608
|
return Math.min(
|
|
4562
4609
|
e[e.length - 1],
|
|
4563
4610
|
Math.max(e[0], this.stepsPerSecond ?? 1)
|
|
4564
4611
|
);
|
|
4565
4612
|
}
|
|
4566
|
-
return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate *
|
|
4613
|
+
return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate * si(this.geoVideoManifest) : this.playbackRate;
|
|
4567
4614
|
}
|
|
4568
4615
|
/** Apply or clear a time window without rebuilding source metadata or the map layer. */
|
|
4569
4616
|
applyTimeRange(e) {
|
|
@@ -4597,7 +4644,7 @@ class Da {
|
|
|
4597
4644
|
values: t.values,
|
|
4598
4645
|
units: t.units,
|
|
4599
4646
|
current: this.time,
|
|
4600
|
-
granularity:
|
|
4647
|
+
granularity: la(t.values),
|
|
4601
4648
|
timelineKind: this.geoVideoManifest?.timeline.kind
|
|
4602
4649
|
} : {
|
|
4603
4650
|
min: NaN,
|
|
@@ -4613,7 +4660,7 @@ class Da {
|
|
|
4613
4660
|
return { values: [], label: "depth", current: void 0 };
|
|
4614
4661
|
const e = this.verticalMeta;
|
|
4615
4662
|
return {
|
|
4616
|
-
values:
|
|
4663
|
+
values: Ft(e.values),
|
|
4617
4664
|
name: e.name,
|
|
4618
4665
|
label: e.label,
|
|
4619
4666
|
units: e.units,
|
|
@@ -4634,7 +4681,7 @@ class Da {
|
|
|
4634
4681
|
const i = this.catalogSource;
|
|
4635
4682
|
return {
|
|
4636
4683
|
type: "image",
|
|
4637
|
-
url:
|
|
4684
|
+
url: ji({
|
|
4638
4685
|
baseUrl: i.baseUrl ?? this.wmtsMetadata?.baseUrl ?? new URL(i.capabilitiesUrl).origin,
|
|
4639
4686
|
layer: i.layer,
|
|
4640
4687
|
style: i.style
|
|
@@ -4666,7 +4713,7 @@ class Da {
|
|
|
4666
4713
|
};
|
|
4667
4714
|
}
|
|
4668
4715
|
getPalettes() {
|
|
4669
|
-
return
|
|
4716
|
+
return xt();
|
|
4670
4717
|
}
|
|
4671
4718
|
getSource() {
|
|
4672
4719
|
return this.catalogSource ? { id: this.catalogSource.id, type: this.catalogSource.type } : void 0;
|
|
@@ -4738,7 +4785,7 @@ class Da {
|
|
|
4738
4785
|
devicePixelRatio: typeof window < "u" ? window.devicePixelRatio : void 0,
|
|
4739
4786
|
catalogEntry: this.catalogLayer ? {
|
|
4740
4787
|
id: this.catalogLayer.id,
|
|
4741
|
-
title:
|
|
4788
|
+
title: $t(
|
|
4742
4789
|
this.catalogLayer.title,
|
|
4743
4790
|
this.catalog.defaultLocale,
|
|
4744
4791
|
this.catalog.defaultLocale
|
|
@@ -4763,7 +4810,7 @@ class Da {
|
|
|
4763
4810
|
* color domain of a GeoVideo archive included, as a load sets them.
|
|
4764
4811
|
*/
|
|
4765
4812
|
styledSettings() {
|
|
4766
|
-
const e =
|
|
4813
|
+
const e = Ut(
|
|
4767
4814
|
this.catalogLayer ?? void 0,
|
|
4768
4815
|
this.style
|
|
4769
4816
|
), t = this.catalogSource?.type === "geovideo" ? this.geoVideoManifest : null;
|
|
@@ -4774,7 +4821,7 @@ class Da {
|
|
|
4774
4821
|
const t = e.colorDomain === void 0 ? e : {
|
|
4775
4822
|
...e,
|
|
4776
4823
|
colorDomain: Q(e.colorDomain)
|
|
4777
|
-
}, i =
|
|
4824
|
+
}, i = fa.some(
|
|
4778
4825
|
(r) => t[r] != null && t[r] !== this.settings[r]
|
|
4779
4826
|
), a = t.particleState != null && t.particleState !== this.settings.particleState;
|
|
4780
4827
|
if (t.colorDomain !== void 0 && (this.colorDomainOverridden = !0), t.palette !== void 0 && (this.paletteOverridden = !0), this.settings = { ...this.settings, ...t }, !!this.layer) {
|
|
@@ -4798,7 +4845,7 @@ class Da {
|
|
|
4798
4845
|
);
|
|
4799
4846
|
const a = Math.max(1, Math.floor(e.maxPoints ?? 512)), r = this.getQuerySource(i.endpoints.pointSeries);
|
|
4800
4847
|
await r.init();
|
|
4801
|
-
const n = r.getTimeDimension().values, o =
|
|
4848
|
+
const n = r.getTimeDimension().values, o = rt(
|
|
4802
4849
|
i,
|
|
4803
4850
|
r.getTimeDimension()
|
|
4804
4851
|
);
|
|
@@ -4813,28 +4860,28 @@ class Da {
|
|
|
4813
4860
|
stopAfterMissingSamples: 12
|
|
4814
4861
|
});
|
|
4815
4862
|
}
|
|
4816
|
-
const
|
|
4863
|
+
const l = this.timeRange ? Math.max(
|
|
4817
4864
|
o.min,
|
|
4818
4865
|
this.resolvedTimeRange?.[0] ?? this.timeMeta?.min ?? o.min
|
|
4819
4866
|
) : o.min, d = this.timeRange ? Math.min(
|
|
4820
4867
|
o.max,
|
|
4821
4868
|
this.resolvedTimeRange?.[1] ?? this.timeMeta?.max ?? o.max
|
|
4822
|
-
) : o.max,
|
|
4869
|
+
) : o.max, c = n.findIndex((m) => m >= l);
|
|
4823
4870
|
let u = n.length - 1;
|
|
4824
4871
|
for (; u >= 0 && n[u] > d; )
|
|
4825
4872
|
u--;
|
|
4826
|
-
if (
|
|
4873
|
+
if (c < 0 || u < c)
|
|
4827
4874
|
throw new Error("Time range does not overlap the point-series store");
|
|
4828
4875
|
const f = Math.max(
|
|
4829
4876
|
1,
|
|
4830
|
-
Math.ceil((u -
|
|
4877
|
+
Math.ceil((u - c + 1) / a)
|
|
4831
4878
|
);
|
|
4832
4879
|
return r.sampleTimeSeries({
|
|
4833
4880
|
variables: fe(i),
|
|
4834
4881
|
longitude: e.longitude,
|
|
4835
4882
|
latitude: e.latitude,
|
|
4836
4883
|
depth: e.depth ?? this.depth,
|
|
4837
|
-
timeStartIndex:
|
|
4884
|
+
timeStartIndex: c,
|
|
4838
4885
|
timeEndIndex: u,
|
|
4839
4886
|
stride: f,
|
|
4840
4887
|
stopAfterMissingSamples: 12
|
|
@@ -4872,7 +4919,7 @@ class Da {
|
|
|
4872
4919
|
);
|
|
4873
4920
|
return;
|
|
4874
4921
|
}
|
|
4875
|
-
const e = new
|
|
4922
|
+
const e = new ia({
|
|
4876
4923
|
id: this.id,
|
|
4877
4924
|
entry: this.catalogLayer,
|
|
4878
4925
|
sourceConfig: this.catalogSource,
|
|
@@ -4976,7 +5023,7 @@ class Da {
|
|
|
4976
5023
|
async selectSource(e, t, i, a = {}) {
|
|
4977
5024
|
const r = this.sourceTimeRequest(i, a.time), n = Ee(e, t);
|
|
4978
5025
|
if (n) {
|
|
4979
|
-
const o = await this.archiveLevels(e, n), d = o.depths.length > 0 && a.depth != null ?
|
|
5026
|
+
const o = await this.archiveLevels(e, n), d = o.depths.length > 0 && a.depth != null ? ot(o, a.depth) : this.catalogLayer?.id === e.id && this.catalogSource?.id === n.id ? this.archiveLevel : null, c = await this.resolveArchives(e, d), u = c.sources.filter(
|
|
4980
5027
|
(m) => m.id === n.id
|
|
4981
5028
|
);
|
|
4982
5029
|
if (u.length) {
|
|
@@ -4986,7 +5033,7 @@ class Da {
|
|
|
4986
5033
|
i,
|
|
4987
5034
|
a.time,
|
|
4988
5035
|
d
|
|
4989
|
-
), p =
|
|
5036
|
+
), p = ri(u, { time: m });
|
|
4990
5037
|
if (p && !this.isFailedGeoVideo(p))
|
|
4991
5038
|
return p;
|
|
4992
5039
|
if (t !== "auto" || this.catalogSource?.id === n.id)
|
|
@@ -4999,12 +5046,12 @@ class Da {
|
|
|
4999
5046
|
if (t !== "auto")
|
|
5000
5047
|
throw new Error(`GeoVideo archive unavailable: ${n.id}`);
|
|
5001
5048
|
}
|
|
5002
|
-
const f = he(
|
|
5049
|
+
const f = he(c, ["zarr"], r);
|
|
5003
5050
|
if (f)
|
|
5004
5051
|
return f;
|
|
5005
5052
|
e = {
|
|
5006
|
-
...
|
|
5007
|
-
sources:
|
|
5053
|
+
...c,
|
|
5054
|
+
sources: c.sources.filter(
|
|
5008
5055
|
(m) => m.type !== "geovideo"
|
|
5009
5056
|
)
|
|
5010
5057
|
};
|
|
@@ -5039,7 +5086,7 @@ class Da {
|
|
|
5039
5086
|
if (!e || !t || !this.isArchiveChunk(t))
|
|
5040
5087
|
return null;
|
|
5041
5088
|
const i = this.archiveLevel;
|
|
5042
|
-
return
|
|
5089
|
+
return ni(
|
|
5043
5090
|
(await this.resolveArchives(e, i)).sources,
|
|
5044
5091
|
t,
|
|
5045
5092
|
{
|
|
@@ -5116,12 +5163,12 @@ class Da {
|
|
|
5116
5163
|
const a = (await this.resolveArchives(e, i)).sources.flatMap(
|
|
5117
5164
|
(n) => n.id === t && n.type === "geovideo" && n.manifestUrl ? [n.manifestUrl] : []
|
|
5118
5165
|
), r = a.filter((n) => !this.chunkTimes.has(n));
|
|
5119
|
-
for (let n = 0; n < r.length; n +=
|
|
5120
|
-
const o = r.slice(n, n +
|
|
5166
|
+
for (let n = 0; n < r.length; n += ct) {
|
|
5167
|
+
const o = r.slice(n, n + ct);
|
|
5121
5168
|
(await Promise.allSettled(
|
|
5122
5169
|
o.map((d) => this.loadChunkManifest(d))
|
|
5123
|
-
)).forEach((d,
|
|
5124
|
-
d.status === "fulfilled" ? this.chunkTimes.set(o[
|
|
5170
|
+
)).forEach((d, c) => {
|
|
5171
|
+
d.status === "fulfilled" ? this.chunkTimes.set(o[c], we(d.value)) : console.warn(
|
|
5125
5172
|
"[zartigl] GeoVideo chunk samples unavailable:",
|
|
5126
5173
|
d.reason
|
|
5127
5174
|
);
|
|
@@ -5138,13 +5185,13 @@ class Da {
|
|
|
5138
5185
|
* and the time shown in agreement.
|
|
5139
5186
|
*/
|
|
5140
5187
|
async archiveSample(e, t, i, a, r = null) {
|
|
5141
|
-
const n = await this.archiveTimes(e, t, r), [o,
|
|
5188
|
+
const n = await this.archiveTimes(e, t, r), [o, l] = i && n.length ? bt(i, [n[0], n[n.length - 1]]) : [-1 / 0, 1 / 0], d = n.filter((u) => u >= o && u <= l);
|
|
5142
5189
|
if (d.length === 0)
|
|
5143
5190
|
throw new RangeError(
|
|
5144
5191
|
"Time range does not contain any available timestamps"
|
|
5145
5192
|
);
|
|
5146
|
-
const
|
|
5147
|
-
return
|
|
5193
|
+
const c = this.sourceTimeRequest(void 0, a).time;
|
|
5194
|
+
return c == null ? d[d.length - 1] : V(d, c);
|
|
5148
5195
|
}
|
|
5149
5196
|
/**
|
|
5150
5197
|
* Entry whose archive sources are replaced by one fixed-period source per
|
|
@@ -5169,7 +5216,7 @@ class Da {
|
|
|
5169
5216
|
return n ? this.archiveChunksAt(
|
|
5170
5217
|
e,
|
|
5171
5218
|
a,
|
|
5172
|
-
|
|
5219
|
+
oi(n, a.indexUrl),
|
|
5173
5220
|
n
|
|
5174
5221
|
) : [];
|
|
5175
5222
|
})
|
|
@@ -5190,28 +5237,28 @@ class Da {
|
|
|
5190
5237
|
if (r && r.expires > Date.now())
|
|
5191
5238
|
return r.chunks;
|
|
5192
5239
|
const n = {
|
|
5193
|
-
expires: Date.now() +
|
|
5194
|
-
chunks:
|
|
5240
|
+
expires: Date.now() + ua,
|
|
5241
|
+
chunks: li(i).then((o) => {
|
|
5195
5242
|
if (a ? !He(o.vertical, a) : o.vertical !== void 0)
|
|
5196
5243
|
throw new Error(`GeoVideo index level does not match: ${i}`);
|
|
5197
5244
|
!a && !this.archiveRoots.has(t.indexUrl) && this.archiveRoots.set(t.indexUrl, {
|
|
5198
5245
|
surface: o.surface,
|
|
5199
5246
|
depths: o.depths ?? []
|
|
5200
5247
|
});
|
|
5201
|
-
const
|
|
5248
|
+
const l = ci(
|
|
5202
5249
|
{ ...t, indexUrl: i },
|
|
5203
5250
|
o,
|
|
5204
5251
|
e
|
|
5205
5252
|
);
|
|
5206
|
-
for (const d of
|
|
5253
|
+
for (const d of hi(o, i))
|
|
5207
5254
|
this.chunkLevels.set(d.manifestUrl, a), d.times && this.chunkTimes.set(d.manifestUrl, d.times);
|
|
5208
|
-
return
|
|
5209
|
-
}).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() +
|
|
5255
|
+
return l;
|
|
5256
|
+
}).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() + da, []))
|
|
5210
5257
|
};
|
|
5211
5258
|
return this.archiveChunks.set(i, n), n.chunks;
|
|
5212
5259
|
}
|
|
5213
5260
|
resolveSource(e, t, i) {
|
|
5214
|
-
const a = t === "auto" ?
|
|
5261
|
+
const a = t === "auto" ? qt(e, i) : e.sources.find((r) => r.id === t) ?? he(
|
|
5215
5262
|
e,
|
|
5216
5263
|
[t],
|
|
5217
5264
|
i
|
|
@@ -5272,33 +5319,33 @@ class Da {
|
|
|
5272
5319
|
a(...t);
|
|
5273
5320
|
}
|
|
5274
5321
|
}
|
|
5275
|
-
function
|
|
5322
|
+
function va(s, e) {
|
|
5276
5323
|
const t = new Date(s).toISOString();
|
|
5277
5324
|
return e === "year" ? t.slice(0, 4) : e === "month" ? t.slice(0, 7) : e === "day" ? t.slice(0, 10) : "";
|
|
5278
5325
|
}
|
|
5279
|
-
function
|
|
5326
|
+
function ya(s, e) {
|
|
5280
5327
|
return e === "year" ? Date.UTC(Number(s), 0, 1) : e === "month" ? (/* @__PURE__ */ new Date(`${s}-01T00:00:00Z`)).getTime() : e === "day" ? (/* @__PURE__ */ new Date(`${s}T00:00:00Z`)).getTime() : (/* @__PURE__ */ new Date(`${s}Z`)).getTime();
|
|
5281
5328
|
}
|
|
5282
|
-
function
|
|
5329
|
+
function ka(s, e, t) {
|
|
5283
5330
|
if (!e || s.length === 0)
|
|
5284
5331
|
return;
|
|
5285
5332
|
if (["year", "month", "day"].includes(t)) {
|
|
5286
5333
|
const a = s.find(
|
|
5287
|
-
(r) =>
|
|
5334
|
+
(r) => va(r, t) === e
|
|
5288
5335
|
);
|
|
5289
5336
|
if (a !== void 0)
|
|
5290
5337
|
return a;
|
|
5291
5338
|
}
|
|
5292
|
-
const i =
|
|
5339
|
+
const i = ya(e, t);
|
|
5293
5340
|
if (Number.isFinite(i))
|
|
5294
5341
|
return s.reduce(
|
|
5295
5342
|
(a, r) => Math.abs(r - i) < Math.abs(a - i) ? r : a
|
|
5296
5343
|
);
|
|
5297
5344
|
}
|
|
5298
|
-
const
|
|
5345
|
+
const Vt = vt.devDependencies["maplibre-gl"].replace(
|
|
5299
5346
|
/^[^\d]*/,
|
|
5300
5347
|
""
|
|
5301
|
-
),
|
|
5348
|
+
), _a = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Vt}/+esm`, xa = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Vt}/dist/maplibre-gl.css`, ba = `{
|
|
5302
5349
|
version: 8,
|
|
5303
5350
|
sources: {
|
|
5304
5351
|
"eox-cloudless": {
|
|
@@ -5322,10 +5369,10 @@ const It = gt.devDependencies["maplibre-gl"].replace(
|
|
|
5322
5369
|
function q(s) {
|
|
5323
5370
|
return JSON.stringify(s);
|
|
5324
5371
|
}
|
|
5325
|
-
function
|
|
5372
|
+
function Sa(s) {
|
|
5326
5373
|
return JSON.stringify(s, null, 2);
|
|
5327
5374
|
}
|
|
5328
|
-
function
|
|
5375
|
+
function Nt(s) {
|
|
5329
5376
|
return s instanceof Date ? `new Date(${q(s.toISOString())})` : typeof s == "string" ? `new Date(${q(s)})` : String(s);
|
|
5330
5377
|
}
|
|
5331
5378
|
function ie(s, e = 6) {
|
|
@@ -5333,25 +5380,25 @@ function ie(s, e = 6) {
|
|
|
5333
5380
|
}
|
|
5334
5381
|
function $(s, e) {
|
|
5335
5382
|
const t = " ".repeat(e);
|
|
5336
|
-
return
|
|
5383
|
+
return Sa(s).split(`
|
|
5337
5384
|
`).map((i) => `${t}${i}`).join(`
|
|
5338
5385
|
`).trimStart();
|
|
5339
5386
|
}
|
|
5340
|
-
function
|
|
5387
|
+
function wa(s, e) {
|
|
5341
5388
|
const t = " ".repeat(e);
|
|
5342
5389
|
return s.split(`
|
|
5343
5390
|
`).map((i) => i.length > 0 ? `${t}${i}` : i).join(`
|
|
5344
5391
|
`);
|
|
5345
5392
|
}
|
|
5346
|
-
const
|
|
5393
|
+
const Ta = (s) => {
|
|
5347
5394
|
const e = s.source ?? "auto";
|
|
5348
5395
|
return s.sourceType ?? (e === "wmts" || e === "geovideo" ? e : "zarr");
|
|
5349
5396
|
};
|
|
5350
|
-
function
|
|
5351
|
-
const { layerKind: e, layerDefaults: t } = s, i =
|
|
5397
|
+
function zt(s) {
|
|
5398
|
+
const { layerKind: e, layerDefaults: t } = s, i = gt(s.style ?? {}, e), a = t === void 0 ? i : Wt(i, ze({ kind: e, defaults: t })), r = a.raster?.opacity, n = Ta(s) !== "wmts" ? a : r === void 0 ? {} : { raster: { opacity: r } };
|
|
5352
5399
|
return Object.keys(n).length ? n : void 0;
|
|
5353
5400
|
}
|
|
5354
|
-
function
|
|
5401
|
+
function Gt(s) {
|
|
5355
5402
|
const { particleState: e, rgba8MaxParticleZoom: t } = s.settings ?? {}, i = Object.fromEntries(
|
|
5356
5403
|
Object.entries({ particleState: e, rgba8MaxParticleZoom: t }).filter(
|
|
5357
5404
|
([, a]) => a !== void 0
|
|
@@ -5359,8 +5406,8 @@ function Nt(s) {
|
|
|
5359
5406
|
);
|
|
5360
5407
|
return s.layerKind === "vector" && Object.keys(i).length ? i : void 0;
|
|
5361
5408
|
}
|
|
5362
|
-
function
|
|
5363
|
-
const e = s.source ?? "auto", t =
|
|
5409
|
+
function Fa(s) {
|
|
5410
|
+
const e = s.source ?? "auto", t = zt(s), i = Gt(s), a = [
|
|
5364
5411
|
" idView: widget.opt.view.id,",
|
|
5365
5412
|
" map: widget.opt.map,",
|
|
5366
5413
|
` layer: ${q(s.layerId)},`,
|
|
@@ -5368,7 +5415,7 @@ function Ca(s) {
|
|
|
5368
5415
|
];
|
|
5369
5416
|
for (const r of ["title", "subtitle", "description"])
|
|
5370
5417
|
s[r] != null && a.push(` ${r}: ${$(s[r], 10)},`);
|
|
5371
|
-
return s.entry && a.push(` entry: ${$(s.entry, 10)},`), t && a.push(` style: ${$(t, 10)},`), i && a.push(` settings: ${$(i, 10)},`), s.time != null && a.push(` time: ${
|
|
5418
|
+
return s.entry && a.push(` entry: ${$(s.entry, 10)},`), t && a.push(` style: ${$(t, 10)},`), i && a.push(` settings: ${$(i, 10)},`), s.time != null && a.push(` time: ${Nt(s.time)},`), s.timeRange != null && a.push(
|
|
5372
5419
|
` timeRange: ${$(s.timeRange, 10)},`
|
|
5373
5420
|
), s.geoVideo != null && a.push(
|
|
5374
5421
|
` geoVideo: ${$(s.geoVideo, 10)},`
|
|
@@ -5407,14 +5454,14 @@ ${a.join(`
|
|
|
5407
5454
|
};
|
|
5408
5455
|
}`;
|
|
5409
5456
|
}
|
|
5410
|
-
function
|
|
5411
|
-
const e = s.moduleBaseUrl ?? `https://cdn.jsdelivr.net/npm/@fxi/zartigl@${
|
|
5457
|
+
function Ma(s) {
|
|
5458
|
+
const e = s.moduleBaseUrl ?? `https://cdn.jsdelivr.net/npm/@fxi/zartigl@${vt.version}/dist`, t = s.source ?? "auto", i = zt(s), a = Gt(s), r = s.timeRange == null ? "" : ` timeRange: ${$(s.timeRange, 2)},
|
|
5412
5459
|
`, n = s.geoVideo == null ? "" : ` geoVideo: ${$(s.geoVideo, 2)},
|
|
5413
5460
|
`, o = i == null ? "" : ` style: ${$(i, 2)},
|
|
5414
|
-
`,
|
|
5415
|
-
`, d = s.time == null ? "" : ` time: ${
|
|
5416
|
-
`,
|
|
5417
|
-
`, u = s.center ?? [0, 20], f = s.projection ?? "mercator", m = s.mapStyle == null ?
|
|
5461
|
+
`, l = a == null ? "" : ` settings: ${$(a, 2)},
|
|
5462
|
+
`, d = s.time == null ? "" : ` time: ${Nt(s.time)},
|
|
5463
|
+
`, c = s.depth == null ? "" : ` depth: ${s.depth},
|
|
5464
|
+
`, u = s.center ?? [0, 20], f = s.projection ?? "mercator", m = s.mapStyle == null ? ba : q(s.mapStyle), p = `map.setProjection({ type: ${q(f)} });
|
|
5418
5465
|
map.jumpTo({
|
|
5419
5466
|
center: [${ie(u[0])}, ${ie(u[1])}],
|
|
5420
5467
|
zoom: ${ie(s.zoom ?? 2, 3)},
|
|
@@ -5443,10 +5490,10 @@ const z = new Zartigl({
|
|
|
5443
5490
|
catalog,
|
|
5444
5491
|
layer: ${q(s.layerId)},
|
|
5445
5492
|
source: ${q(t)},
|
|
5446
|
-
${r}${n}${o}${
|
|
5493
|
+
${r}${n}${o}${l}${d}${c}});
|
|
5447
5494
|
|
|
5448
5495
|
await z.init();`;
|
|
5449
|
-
return `import maplibregl from ${q(
|
|
5496
|
+
return `import maplibregl from ${q(_a)};
|
|
5450
5497
|
import { Zartigl } from "${e}/zartigl.js";
|
|
5451
5498
|
import { catalog } from "${e}/catalog.js";
|
|
5452
5499
|
|
|
@@ -5458,18 +5505,18 @@ const map = new maplibregl.Map({
|
|
|
5458
5505
|
});
|
|
5459
5506
|
|
|
5460
5507
|
map.once("style.load", async () => {
|
|
5461
|
-
${
|
|
5508
|
+
${wa(p, 2)}
|
|
5462
5509
|
});`;
|
|
5463
5510
|
}
|
|
5464
|
-
function
|
|
5465
|
-
const e =
|
|
5511
|
+
function Ia(s) {
|
|
5512
|
+
const e = Ma(s);
|
|
5466
5513
|
return `<!doctype html>
|
|
5467
5514
|
<html lang="en">
|
|
5468
5515
|
<head>
|
|
5469
5516
|
<meta charset="UTF-8" />
|
|
5470
5517
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
5471
5518
|
<title>Zartigl demo</title>
|
|
5472
|
-
<link rel="stylesheet" href=${q(
|
|
5519
|
+
<link rel="stylesheet" href=${q(xa)} />
|
|
5473
5520
|
<style>
|
|
5474
5521
|
html, body, #map {
|
|
5475
5522
|
width: 100%;
|
|
@@ -5491,41 +5538,41 @@ ${e}
|
|
|
5491
5538
|
</html>`;
|
|
5492
5539
|
}
|
|
5493
5540
|
export {
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5541
|
+
ui as BACKDROP_OFF,
|
|
5542
|
+
di as COLOR_GRADE_OFF,
|
|
5543
|
+
Oa as COLOR_GRADE_VIBRANT,
|
|
5544
|
+
oa as GEOVIDEO_SPEEDS,
|
|
5498
5545
|
G as GeoVideoLayer,
|
|
5499
|
-
|
|
5500
|
-
|
|
5546
|
+
It as LEGACY_STYLE_SETTINGS,
|
|
5547
|
+
Pt as ParticleSimulation,
|
|
5501
5548
|
me as ScalarLayer,
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5549
|
+
at as VECTOR_GEOVIDEO_SPEEDS,
|
|
5550
|
+
P as VectorLayer,
|
|
5551
|
+
Et as VelocityField,
|
|
5505
5552
|
_e as ZarrSource,
|
|
5506
|
-
|
|
5553
|
+
Ca as Zartigl,
|
|
5507
5554
|
xe as ZartiglFrameUnavailableError,
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5555
|
+
Fa as buildMapxWidgetSnippet,
|
|
5556
|
+
Ia as buildStandaloneDemoHtml,
|
|
5557
|
+
Ma as buildStandaloneDemoSnippet,
|
|
5558
|
+
ji as buildWmtsLegendUrl,
|
|
5559
|
+
et as buildWmtsTileUrl,
|
|
5560
|
+
pi as colorGradeToGrade,
|
|
5561
|
+
Xi as deriveDirectionMagnitudeComponents,
|
|
5515
5562
|
Ye as formatUnit,
|
|
5516
|
-
|
|
5517
|
-
|
|
5563
|
+
ti as geoVideoSecondsForTime,
|
|
5564
|
+
Na as geoVideoTimeForSeconds,
|
|
5518
5565
|
we as geoVideoTimelineValues,
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5566
|
+
xt as getPalettes,
|
|
5567
|
+
Aa as getVectorDerivationVariables,
|
|
5568
|
+
gi as gradeToColorGrade,
|
|
5569
|
+
Ba as isHexColor,
|
|
5523
5570
|
Ce as loadGeoVideoManifest,
|
|
5524
|
-
|
|
5525
|
-
|
|
5571
|
+
wt as resolveBackdrop,
|
|
5572
|
+
St as resolveColorGrade,
|
|
5526
5573
|
ke as resolveColorRamp,
|
|
5527
|
-
|
|
5574
|
+
ka as resolveTimeInputSelection,
|
|
5528
5575
|
Ae as splitLegacySettings,
|
|
5529
|
-
|
|
5530
|
-
|
|
5576
|
+
Lt as stitchVelocityChunks,
|
|
5577
|
+
za as validateGeoVideoManifest
|
|
5531
5578
|
};
|