@fxi/zartigl 0.13.1 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog.js +1 -1
- package/dist/{engine-Bhb-WayM.js → engine-C8ZNzILO.js} +317 -284
- package/dist/engine.d.ts +6 -1
- package/dist/engine.js +31 -31
- package/dist/{index-DsKvU_FK.js → index-BDIf6Jc0.js} +125 -122
- package/dist/zartigl.d.ts +11 -1
- package/dist/zartigl.js +801 -737
- package/package.json +2 -2
package/dist/zartigl.js
CHANGED
|
@@ -1,53 +1,68 @@
|
|
|
1
|
-
import { m as ae, p as
|
|
2
|
-
import { T as
|
|
3
|
-
import {
|
|
4
|
-
import { B as
|
|
5
|
-
import { f as
|
|
6
|
-
import { inflate as
|
|
7
|
-
import
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
return Math.max(-
|
|
11
|
-
}
|
|
12
|
-
function
|
|
13
|
-
const e =
|
|
1
|
+
import { m as ae, p as ft, s as pt, a as qe, b as Ot, r as ze, c as Bt, d as he, e as $t, f as gt, g as qt } from "./index-BDIf6Jc0.js";
|
|
2
|
+
import { T as Wt, g as Xt, r as Ht, d as Yt, c as W, a as Zt, b as ge, e as jt, f as J, h as Se, i as O, G as Qt, j as We, F as Kt, s as vt, v as Q, k as K, l as Ge, m as Oe, n as yt, o as Xe, p as Ce, q as Jt, t as ke, u as ei, w as _t, x as z, y as He, z as we, A as ti, B as ii, C as ai, D as Ye, E as si, H as Fe, I as ri, J as xt, K as ni, L as oi, M as li, N as ci } from "./engine-C8ZNzILO.js";
|
|
3
|
+
import { O as Ua, P as Na } from "./engine-C8ZNzILO.js";
|
|
4
|
+
import { B as hi, a as ui, b as di, c as mi, d as bt, r as St, e as fi, g as pi } from "./backdrop-Dceb4d8E.js";
|
|
5
|
+
import { f as Ga, i as Oa } from "./backdrop-Dceb4d8E.js";
|
|
6
|
+
import { inflate as gi } from "pako";
|
|
7
|
+
import vi from "numcodecs/blosc";
|
|
8
|
+
const Ie = 85, yi = 89.9;
|
|
9
|
+
function Ve(s) {
|
|
10
|
+
return Math.max(-Ie, Math.min(Ie, s));
|
|
11
|
+
}
|
|
12
|
+
function Ze(s) {
|
|
13
|
+
const e = Ve(s), t = Math.sin(e * Math.PI / 180);
|
|
14
14
|
return 0.5 - Math.log((1 + t) / (1 - t)) / (4 * Math.PI);
|
|
15
15
|
}
|
|
16
16
|
function ve(s) {
|
|
17
17
|
return (s + 180) / 360;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function _i(s) {
|
|
20
20
|
return ((s + 180) % 360 + 360) % 360 - 180;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
22
|
+
function wt(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
|
+
}
|
|
31
|
+
function ye(s, e) {
|
|
32
|
+
if (s.getProjection?.()?.type !== "globe")
|
|
33
|
+
return !1;
|
|
34
|
+
const t = e?.projectionTransition;
|
|
35
|
+
return typeof t == "number" ? t > 0 : !0;
|
|
36
|
+
}
|
|
37
|
+
function xi(s, e) {
|
|
38
|
+
const t = _i(s) * Math.PI / 180, i = e * Math.PI / 180, a = Math.cos(i);
|
|
24
39
|
return [
|
|
25
40
|
Math.sin(t) * a,
|
|
26
41
|
Math.sin(i),
|
|
27
42
|
Math.cos(t) * a
|
|
28
43
|
];
|
|
29
44
|
}
|
|
30
|
-
function
|
|
45
|
+
function bi(s) {
|
|
31
46
|
return {
|
|
32
47
|
west: -180,
|
|
33
48
|
east: 180,
|
|
34
|
-
south:
|
|
35
|
-
north:
|
|
49
|
+
south: Ve(s.getSouth()),
|
|
50
|
+
north: Ve(s.getNorth())
|
|
36
51
|
};
|
|
37
52
|
}
|
|
38
|
-
function
|
|
39
|
-
const i = t ?
|
|
53
|
+
function Si(s, e = 1, t = !1) {
|
|
54
|
+
const i = t ? yi : 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);
|
|
40
55
|
return {
|
|
41
56
|
west: -180,
|
|
42
57
|
east: 180,
|
|
43
|
-
south: a(r -
|
|
44
|
-
north: a(n +
|
|
58
|
+
south: a(r - l),
|
|
59
|
+
north: a(n + l)
|
|
45
60
|
};
|
|
46
61
|
}
|
|
47
|
-
function
|
|
62
|
+
function wi(s, e, t = 1e-6) {
|
|
48
63
|
return s.south <= e.south + t && s.north >= e.north - t;
|
|
49
64
|
}
|
|
50
|
-
function
|
|
65
|
+
function Ti(s, e = !1) {
|
|
51
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 };
|
|
52
67
|
return e ? {
|
|
53
68
|
...o,
|
|
@@ -55,11 +70,11 @@ function xi(s, e = !1) {
|
|
|
55
70
|
maxY: (Math.min(s.getNorth(), 90) + 90) / 180
|
|
56
71
|
} : {
|
|
57
72
|
...o,
|
|
58
|
-
minY:
|
|
59
|
-
maxY:
|
|
73
|
+
minY: Ze(s.getNorth()),
|
|
74
|
+
maxY: Ze(s.getSouth())
|
|
60
75
|
};
|
|
61
76
|
}
|
|
62
|
-
function
|
|
77
|
+
function Be(s, e) {
|
|
63
78
|
if (e)
|
|
64
79
|
return [0];
|
|
65
80
|
const t = ve(s.getWest()), i = ve(s.getEast()), a = [];
|
|
@@ -77,7 +92,7 @@ const ue = [
|
|
|
77
92
|
"u_velocity_flip_y",
|
|
78
93
|
"u_velocity_next_flip_y"
|
|
79
94
|
];
|
|
80
|
-
function
|
|
95
|
+
function Te(s, e, t) {
|
|
81
96
|
s.uniform1i(e.u_velocity_next, t.b.unit), s.uniform2f(e.u_velocity_next_min, ...t.b.min), s.uniform2f(e.u_velocity_next_max, ...t.b.max), s.uniform1f(e.u_velocity_mix, t.mix), s.uniform1f(e.u_velocity_physical, t.a.physical ? 1 : 0), s.uniform1f(e.u_velocity_next_physical, t.b.physical ? 1 : 0), s.uniform1f(e.u_velocity_flip_y, t.a.northToSouth ? 1 : 0), s.uniform1f(e.u_velocity_next_flip_y, t.b.northToSouth ? 1 : 0);
|
|
82
97
|
}
|
|
83
98
|
var de = `#version 300 es
|
|
@@ -89,7 +104,7 @@ out vec2 v_tex_coord;
|
|
|
89
104
|
void main() {
|
|
90
105
|
v_tex_coord = a_position * 0.5 + 0.5;
|
|
91
106
|
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
92
|
-
}`,
|
|
107
|
+
}`, Mi = `#version 300 es
|
|
93
108
|
precision highp float;
|
|
94
109
|
|
|
95
110
|
uint pcg(uint v) {
|
|
@@ -359,7 +374,7 @@ void main() {
|
|
|
359
374
|
fract(newPos.y * 255.0)
|
|
360
375
|
);
|
|
361
376
|
#endif
|
|
362
|
-
}`,
|
|
377
|
+
}`, Ri = `precision highp float;
|
|
363
378
|
|
|
364
379
|
attribute float a_index;
|
|
365
380
|
attribute float a_is_curr;
|
|
@@ -591,7 +606,7 @@ void main() {
|
|
|
591
606
|
vec2 worldPos = vec2((pos.x + u_world_offset) * u_world_size, pos.y * u_world_size);
|
|
592
607
|
gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
|
|
593
608
|
}
|
|
594
|
-
}`,
|
|
609
|
+
}`, Pi = `precision mediump float;
|
|
595
610
|
|
|
596
611
|
uniform sampler2D u_color_ramp;
|
|
597
612
|
uniform float u_particle_contrast;
|
|
@@ -630,7 +645,7 @@ void main() {
|
|
|
630
645
|
}
|
|
631
646
|
|
|
632
647
|
gl_FragColor = vec4(color.rgb, color.a * u_opacity);
|
|
633
|
-
}`,
|
|
648
|
+
}`, Ei = `#version 300 es
|
|
634
649
|
precision mediump float;
|
|
635
650
|
|
|
636
651
|
uniform sampler2D u_screen;
|
|
@@ -647,7 +662,7 @@ void main() {
|
|
|
647
662
|
float alpha = floor(color.a * 255.0 * u_opacity) / 255.0;
|
|
648
663
|
|
|
649
664
|
o_color = vec4(color.rgb * step(1.0 / 255.0, alpha), alpha);
|
|
650
|
-
}`,
|
|
665
|
+
}`, Li = `#version 300 es
|
|
651
666
|
precision mediump float;
|
|
652
667
|
|
|
653
668
|
uniform sampler2D u_screen;
|
|
@@ -718,7 +733,7 @@ void main() {
|
|
|
718
733
|
}
|
|
719
734
|
vec3 rgb = u_grade_on > 0.5 ? gradeColor(color.rgb, u_grade) : color.rgb;
|
|
720
735
|
o_color = vec4(rgb, color.a);
|
|
721
|
-
}`,
|
|
736
|
+
}`, Di = `#version 300 es
|
|
722
737
|
precision mediump float;
|
|
723
738
|
|
|
724
739
|
uniform sampler2D u_screen;
|
|
@@ -755,7 +770,7 @@ vec4 addGlow(vec4 trail, sampler2D glowTex, vec2 uv, float gain) {
|
|
|
755
770
|
|
|
756
771
|
void main() {
|
|
757
772
|
o_color = glowGather(u_screen, ivec2(gl_FragCoord.xy));
|
|
758
|
-
}`,
|
|
773
|
+
}`, Tt = `precision highp float;
|
|
759
774
|
|
|
760
775
|
attribute vec2 a_grid_uv;
|
|
761
776
|
|
|
@@ -779,14 +794,17 @@ float latToMercY(float lat) {
|
|
|
779
794
|
}
|
|
780
795
|
|
|
781
796
|
void main() {
|
|
782
|
-
|
|
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);
|
|
783
801
|
float lat = mix(u_geo_bounds.y, u_geo_bounds.w, a_grid_uv.y);
|
|
784
802
|
vec2 merc = vec2(lngToMercX(lng) + u_world_offset, latToMercY(lat));
|
|
785
803
|
vec2 worldPos = merc * u_world_size;
|
|
786
804
|
|
|
787
|
-
v_geo_uv = a_grid_uv;
|
|
805
|
+
v_geo_uv = vec2((lng - u_geo_bounds.x) / width, a_grid_uv.y);
|
|
788
806
|
gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
|
|
789
|
-
}`,
|
|
807
|
+
}`, Ai = `precision mediump float;
|
|
790
808
|
|
|
791
809
|
uniform sampler2D u_field;
|
|
792
810
|
uniform sampler2D u_color_ramp;
|
|
@@ -849,7 +867,8 @@ vec3 sampleVelocityPair(sampler2D field, vec2 uv, vec2 minimum, vec2 maximum) {
|
|
|
849
867
|
}
|
|
850
868
|
|
|
851
869
|
void main() {
|
|
852
|
-
|
|
870
|
+
|
|
871
|
+
if (v_geo_uv.y < 0.0 || v_geo_uv.y > 1.0) {
|
|
853
872
|
discard;
|
|
854
873
|
}
|
|
855
874
|
|
|
@@ -885,7 +904,7 @@ void main() {
|
|
|
885
904
|
vec4 color = texture2D(u_color_ramp, vec2(t, 0.5));
|
|
886
905
|
color.rgb = applyVibrance(color.rgb, u_vibrance);
|
|
887
906
|
gl_FragColor = vec4(color.rgb, color.a * u_opacity);
|
|
888
|
-
}`,
|
|
907
|
+
}`, Mt = `precision highp float;
|
|
889
908
|
|
|
890
909
|
attribute vec2 a_grid_uv;
|
|
891
910
|
|
|
@@ -893,11 +912,23 @@ uniform mat4 u_matrix;
|
|
|
893
912
|
uniform vec4 u_geo_bounds;
|
|
894
913
|
uniform vec4 u_clipping_plane;
|
|
895
914
|
|
|
915
|
+
uniform float u_projection_transition;
|
|
916
|
+
uniform mat4 u_fallback_matrix;
|
|
917
|
+
|
|
896
918
|
varying vec2 v_geo_uv;
|
|
897
919
|
|
|
920
|
+
const float PI = 3.14159265358979323846;
|
|
921
|
+
|
|
898
922
|
void main() {
|
|
899
|
-
|
|
900
|
-
|
|
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);
|
|
901
932
|
float lngRad = radians(lng);
|
|
902
933
|
float latRad = radians(lat);
|
|
903
934
|
float cosLat = cos(latRad);
|
|
@@ -907,11 +938,23 @@ void main() {
|
|
|
907
938
|
cos(lngRad) * cosLat
|
|
908
939
|
);
|
|
909
940
|
|
|
910
|
-
v_geo_uv = a_grid_uv;
|
|
941
|
+
v_geo_uv = vec2((lng - u_geo_bounds.x) / width, a_grid_uv.y);
|
|
911
942
|
vec4 position = u_matrix * vec4(ecef, 1.0);
|
|
912
943
|
position.z = (1.0 - (dot(ecef, u_clipping_plane.xyz) + u_clipping_plane.w)) * position.w;
|
|
944
|
+
if (u_projection_transition < 0.999) {
|
|
945
|
+
|
|
946
|
+
float sinLat = sin(radians(clamp(lat, -85.0, 85.0)));
|
|
947
|
+
vec2 merc = vec2(
|
|
948
|
+
(lng + 180.0) / 360.0,
|
|
949
|
+
0.5 - log((1.0 + sinLat) / (1.0 - sinLat)) / (4.0 * PI)
|
|
950
|
+
);
|
|
951
|
+
vec4 flatPosition = u_fallback_matrix * vec4(merc, 0.0, 1.0);
|
|
952
|
+
float globeness = clamp((u_projection_transition - 0.2) / 0.8, 0.0, 1.0);
|
|
953
|
+
position.z = mix(0.0, position.z, globeness);
|
|
954
|
+
position.xyw = mix(flatPosition.xyw, position.xyw, u_projection_transition);
|
|
955
|
+
}
|
|
913
956
|
gl_Position = position;
|
|
914
|
-
}`,
|
|
957
|
+
}`, Ci = `precision mediump float;
|
|
915
958
|
|
|
916
959
|
uniform sampler2D u_field;
|
|
917
960
|
uniform sampler2D u_color_ramp;
|
|
@@ -1001,8 +1044,8 @@ void main() {
|
|
|
1001
1044
|
color.rgb = applyVibrance(color.rgb, u_vibrance);
|
|
1002
1045
|
gl_FragColor = vec4(color.rgb, color.a * u_opacity);
|
|
1003
1046
|
}`;
|
|
1004
|
-
const
|
|
1005
|
-
function
|
|
1047
|
+
const Me = [0, 0, 0, 0], B = 512, H = B * B, Y = 128, ee = 64, ki = 1, Fi = 0.92, Ii = 0.1, je = 0.98;
|
|
1048
|
+
function Vi(s) {
|
|
1006
1049
|
if (Number.isNaN(s))
|
|
1007
1050
|
return 32256;
|
|
1008
1051
|
if (s === 1 / 0)
|
|
@@ -1019,7 +1062,7 @@ function Ci(s) {
|
|
|
1019
1062
|
const i = Math.floor(Math.log2(t)), a = t / 2 ** i - 1;
|
|
1020
1063
|
return e | i + 15 << 10 | Math.round(a * 1024);
|
|
1021
1064
|
}
|
|
1022
|
-
const
|
|
1065
|
+
const Ui = {
|
|
1023
1066
|
particleDensity: 0.05,
|
|
1024
1067
|
speed: 1,
|
|
1025
1068
|
fadeOpacity: 0.996,
|
|
@@ -1028,26 +1071,26 @@ const ki = {
|
|
|
1028
1071
|
opacity: 1,
|
|
1029
1072
|
logScale: !1,
|
|
1030
1073
|
vibrance: 0,
|
|
1031
|
-
colorGrade:
|
|
1032
|
-
backdrop:
|
|
1074
|
+
colorGrade: ui,
|
|
1075
|
+
backdrop: hi,
|
|
1033
1076
|
glow: 0,
|
|
1034
1077
|
scalarMode: !1,
|
|
1035
1078
|
particleState: "auto",
|
|
1036
1079
|
rgba8MaxParticleZoom: 4
|
|
1037
1080
|
};
|
|
1038
|
-
class
|
|
1081
|
+
class Rt {
|
|
1039
1082
|
constructor(e) {
|
|
1040
|
-
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 = { ...Ui, ...e }, this.trailFade = new Wt(this.params.fadeOpacity);
|
|
1041
1084
|
}
|
|
1042
1085
|
init(e) {
|
|
1043
|
-
this.gl = e, this.webglInfo =
|
|
1086
|
+
this.gl = e, this.webglInfo = Xt(e), this.stateFormat = this.params.particleState === "rgba8" ? Ht(e) : Yt(e);
|
|
1044
1087
|
const t = this.stateFormat.kind !== "rgba8-packed" ? `#define USE_FLOAT_STATE 1
|
|
1045
1088
|
` : "";
|
|
1046
1089
|
this.updateProgram = W(
|
|
1047
1090
|
e,
|
|
1048
1091
|
de,
|
|
1049
|
-
|
|
1050
|
-
), this.drawProgram = W(e, t +
|
|
1092
|
+
Mi.replace(/^(#version[^\n]*\n)/, `$1${t}`)
|
|
1093
|
+
), this.drawProgram = W(e, t + Ri, Pi), this.fadeProgram = W(e, de, Ei), this.compositeProgram = W(e, de, Li), this.glowProgram = W(e, de, Di), this.gridProgram = W(e, Tt, Ai), this.gridGlobeProgram = W(e, Mt, Ci), this.updateLocs = this.getUniforms(this.updateProgram, [
|
|
1051
1094
|
"u_particles",
|
|
1052
1095
|
...ue,
|
|
1053
1096
|
"u_velocity",
|
|
@@ -1118,6 +1161,8 @@ class wt {
|
|
|
1118
1161
|
"u_matrix",
|
|
1119
1162
|
"u_geo_bounds",
|
|
1120
1163
|
"u_clipping_plane",
|
|
1164
|
+
"u_projection_transition",
|
|
1165
|
+
"u_fallback_matrix",
|
|
1121
1166
|
"u_field_min",
|
|
1122
1167
|
"u_field_max",
|
|
1123
1168
|
"u_u_min",
|
|
@@ -1129,7 +1174,7 @@ class wt {
|
|
|
1129
1174
|
"u_vibrance",
|
|
1130
1175
|
"u_scalar_mode",
|
|
1131
1176
|
"u_solid"
|
|
1132
|
-
]), this.quadBuffer =
|
|
1177
|
+
]), this.quadBuffer = Zt(e), this.initRasterGrid(), this.colorRampTexture = ge(e, this.params.colorRamp), this.initParticleState();
|
|
1133
1178
|
}
|
|
1134
1179
|
getUniforms(e, t) {
|
|
1135
1180
|
const i = {};
|
|
@@ -1149,7 +1194,7 @@ class wt {
|
|
|
1149
1194
|
if (this.stateFormat?.kind === "float16") {
|
|
1150
1195
|
const a = new Uint16Array(t);
|
|
1151
1196
|
for (let r = 0; r < t; r++)
|
|
1152
|
-
a[r] =
|
|
1197
|
+
a[r] = Vi(Math.random());
|
|
1153
1198
|
return a;
|
|
1154
1199
|
}
|
|
1155
1200
|
const i = new Uint8Array(t);
|
|
@@ -1158,7 +1203,7 @@ class wt {
|
|
|
1158
1203
|
return i;
|
|
1159
1204
|
}
|
|
1160
1205
|
createStateTexture(e) {
|
|
1161
|
-
return
|
|
1206
|
+
return jt(
|
|
1162
1207
|
this.gl,
|
|
1163
1208
|
this.gl.NEAREST,
|
|
1164
1209
|
e,
|
|
@@ -1171,10 +1216,10 @@ class wt {
|
|
|
1171
1216
|
initParticleState() {
|
|
1172
1217
|
const e = this.gl, t = this.makeStateData(), i = this.createStateTexture(t), a = this.createStateTexture(t), r = J(e, i), n = J(e, a);
|
|
1173
1218
|
this.particleStateTextures = [i, a], this.particleFramebuffers = [r, n];
|
|
1174
|
-
const o = new Float32Array(H * 2),
|
|
1175
|
-
for (let
|
|
1176
|
-
o[
|
|
1177
|
-
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,
|
|
1219
|
+
const o = new Float32Array(H * 2), l = new Float32Array(H * 2);
|
|
1220
|
+
for (let d = 0; d < H; d++)
|
|
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);
|
|
1178
1223
|
}
|
|
1179
1224
|
initRasterGrid() {
|
|
1180
1225
|
const e = this.gl, t = new Float32Array(
|
|
@@ -1182,17 +1227,17 @@ class wt {
|
|
|
1182
1227
|
);
|
|
1183
1228
|
let i = 0;
|
|
1184
1229
|
for (let o = 0; o <= ee; o++)
|
|
1185
|
-
for (let
|
|
1186
|
-
t[i++] =
|
|
1230
|
+
for (let l = 0; l <= Y; l++)
|
|
1231
|
+
t[i++] = l / Y, t[i++] = o / ee;
|
|
1187
1232
|
const a = new Uint16Array(
|
|
1188
1233
|
Y * ee * 6
|
|
1189
1234
|
);
|
|
1190
1235
|
let r = 0;
|
|
1191
1236
|
const n = Y + 1;
|
|
1192
1237
|
for (let o = 0; o < ee; o++)
|
|
1193
|
-
for (let
|
|
1194
|
-
const
|
|
1195
|
-
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;
|
|
1196
1241
|
}
|
|
1197
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;
|
|
1198
1243
|
}
|
|
@@ -1211,14 +1256,14 @@ class wt {
|
|
|
1211
1256
|
return;
|
|
1212
1257
|
const i = this.gl;
|
|
1213
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();
|
|
1214
|
-
const a = new Uint8Array(e * t * 4), r =
|
|
1215
|
-
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];
|
|
1216
1261
|
}
|
|
1217
1262
|
/**
|
|
1218
1263
|
* Run one simulation step: update positions, fade trails, draw particles.
|
|
1219
1264
|
* Must be called within the MapLibre render callback.
|
|
1220
1265
|
*/
|
|
1221
|
-
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) {
|
|
1222
1267
|
const m = { unit: e, min: t, max: i }, p = f ?? { a: m, b: m, mix: 0 }, h = this.gl;
|
|
1223
1268
|
if (this.screenWidth === 0 || this.screenHeight === 0)
|
|
1224
1269
|
return;
|
|
@@ -1229,13 +1274,13 @@ class wt {
|
|
|
1229
1274
|
const T = !x && (this.renderMode === "particles" || this.renderMode === "raster+particles"), M = x || this.renderMode === "raster" || this.renderMode === "raster+particles";
|
|
1230
1275
|
let y = !1;
|
|
1231
1276
|
if (T) {
|
|
1232
|
-
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),
|
|
1233
|
-
const
|
|
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;
|
|
1278
|
+
const R = r.maxX - r.minX;
|
|
1234
1279
|
if (this.prevBounds) {
|
|
1235
|
-
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), V = Math.min(1, I + w);
|
|
1236
1281
|
this.redistributionBoost = Math.max(
|
|
1237
|
-
this.redistributionBoost *
|
|
1238
|
-
|
|
1282
|
+
this.redistributionBoost * Fi,
|
|
1283
|
+
V * ki
|
|
1239
1284
|
);
|
|
1240
1285
|
}
|
|
1241
1286
|
this.prevBounds = {
|
|
@@ -1246,7 +1291,7 @@ class wt {
|
|
|
1246
1291
|
};
|
|
1247
1292
|
const k = Math.min(
|
|
1248
1293
|
this.params.dropRate + this.redistributionBoost,
|
|
1249
|
-
|
|
1294
|
+
Ii
|
|
1250
1295
|
);
|
|
1251
1296
|
h.uniform1f(this.updateLocs.u_drop_rate, k), h.uniform1f(
|
|
1252
1297
|
this.updateLocs.u_drop_rate_bump,
|
|
@@ -1257,57 +1302,57 @@ class wt {
|
|
|
1257
1302
|
r.minY,
|
|
1258
1303
|
r.maxX,
|
|
1259
1304
|
r.maxY
|
|
1260
|
-
), h.uniform1f(this.updateLocs.u_is_globe,
|
|
1305
|
+
), h.uniform1f(this.updateLocs.u_is_globe, d ? 1 : 0), l && h.uniform4f(
|
|
1261
1306
|
this.updateLocs.u_geo_bounds,
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1307
|
+
l.west,
|
|
1308
|
+
l.south,
|
|
1309
|
+
l.east,
|
|
1310
|
+
l.north
|
|
1266
1311
|
), h.uniform1f(
|
|
1267
1312
|
this.updateLocs.u_valid_threshold,
|
|
1268
|
-
|
|
1313
|
+
je
|
|
1269
1314
|
), h.bindFramebuffer(h.FRAMEBUFFER, this.particleFramebuffers[1]), this.drawQuad(), y = !0;
|
|
1270
1315
|
}
|
|
1271
1316
|
h.viewport(0, 0, this.screenWidth, this.screenHeight), h.bindFramebuffer(h.FRAMEBUFFER, this.screenFramebuffers[1]), h.useProgram(this.fadeProgram), h.disable(h.BLEND), O(h, this.screenTextures[0], 0), h.uniform1i(this.fadeLocs.u_screen, 0), h.uniform1f(
|
|
1272
1317
|
this.fadeLocs.u_opacity,
|
|
1273
1318
|
this.updateTrailFadeOpacity(performance.now())
|
|
1274
1319
|
), this.drawQuad();
|
|
1275
|
-
const v = (
|
|
1276
|
-
|
|
1320
|
+
const v = (R) => {
|
|
1321
|
+
l && (d && u ? this.renderGridGlobe(
|
|
1277
1322
|
e,
|
|
1278
1323
|
t,
|
|
1279
1324
|
i,
|
|
1280
1325
|
a,
|
|
1281
|
-
|
|
1282
|
-
|
|
1326
|
+
l,
|
|
1327
|
+
u,
|
|
1283
1328
|
1,
|
|
1284
|
-
|
|
1329
|
+
R,
|
|
1285
1330
|
p
|
|
1286
|
-
) :
|
|
1331
|
+
) : d || this.renderGrid(
|
|
1287
1332
|
e,
|
|
1288
1333
|
t,
|
|
1289
1334
|
i,
|
|
1290
1335
|
a,
|
|
1291
1336
|
n,
|
|
1292
1337
|
o,
|
|
1293
|
-
|
|
1338
|
+
l,
|
|
1294
1339
|
1,
|
|
1295
|
-
|
|
1340
|
+
R,
|
|
1296
1341
|
p
|
|
1297
1342
|
));
|
|
1298
1343
|
};
|
|
1299
|
-
if (M && v(
|
|
1344
|
+
if (M && v(Me), T) {
|
|
1300
1345
|
h.useProgram(this.drawProgram), h.enable(h.BLEND), h.blendFuncSeparate(
|
|
1301
1346
|
h.SRC_ALPHA,
|
|
1302
1347
|
h.ONE_MINUS_SRC_ALPHA,
|
|
1303
1348
|
h.ONE,
|
|
1304
1349
|
h.ONE_MINUS_SRC_ALPHA
|
|
1305
|
-
), 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),
|
|
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(
|
|
1306
1351
|
this.drawLocs.u_geo_bounds,
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1352
|
+
l.west,
|
|
1353
|
+
l.south,
|
|
1354
|
+
l.east,
|
|
1355
|
+
l.north
|
|
1311
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(
|
|
1312
1357
|
this.drawLocs.u_particle_contrast,
|
|
1313
1358
|
this.renderMode === "raster+particles" ? 1 : 0
|
|
@@ -1316,115 +1361,115 @@ class wt {
|
|
|
1316
1361
|
this.params.logScale ? 1 : 0
|
|
1317
1362
|
), h.uniform1f(this.drawLocs.u_vibrance, this.params.vibrance), h.uniform1f(
|
|
1318
1363
|
this.drawLocs.u_valid_threshold,
|
|
1319
|
-
|
|
1320
|
-
), h.uniform1f(this.drawLocs.u_is_globe,
|
|
1364
|
+
je
|
|
1365
|
+
), h.uniform1f(this.drawLocs.u_is_globe, d ? 1 : 0), h.uniform3f(
|
|
1321
1366
|
this.drawLocs.u_globe_center,
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1367
|
+
c[0],
|
|
1368
|
+
c[1],
|
|
1369
|
+
c[2]
|
|
1325
1370
|
), h.uniformMatrix4fv(
|
|
1326
1371
|
this.drawLocs.u_matrix,
|
|
1327
1372
|
!1,
|
|
1328
1373
|
a instanceof Float32Array ? a : new Float32Array(Array.from(a))
|
|
1329
1374
|
);
|
|
1330
|
-
const
|
|
1331
|
-
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);
|
|
1332
1377
|
const k = h.getAttribLocation(this.drawProgram, "a_is_curr");
|
|
1333
1378
|
h.bindBuffer(h.ARRAY_BUFFER, this.particleIsCurrBuffer), h.enableVertexAttribArray(k), h.vertexAttribPointer(k, 1, h.FLOAT, !1, 0, 0);
|
|
1334
1379
|
for (const F of o)
|
|
1335
1380
|
h.uniform1f(this.drawLocs.u_world_offset, F), h.drawArrays(h.LINES, 0, this.numParticles * 2);
|
|
1336
|
-
h.disableVertexAttribArray(
|
|
1381
|
+
h.disableVertexAttribArray(R), h.disableVertexAttribArray(k), h.disable(h.BLEND);
|
|
1337
1382
|
}
|
|
1338
1383
|
h.bindFramebuffer(h.FRAMEBUFFER, g), h.viewport(0, 0, this.screenWidth, this.screenHeight);
|
|
1339
|
-
const _ =
|
|
1384
|
+
const _ = di(this.params.backdrop);
|
|
1340
1385
|
_[3] > 0 && v(_);
|
|
1341
|
-
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;
|
|
1342
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(
|
|
1343
1388
|
this.compositeLocs.u_glow,
|
|
1344
|
-
S ?
|
|
1345
|
-
), h.uniform1f(this.compositeLocs.u_grade_on,
|
|
1389
|
+
S ? Qt * this.params.glow : 0
|
|
1390
|
+
), h.uniform1f(this.compositeLocs.u_grade_on, E.enabled ? 1 : 0), h.uniform4f(this.compositeLocs.u_grade, ...mi(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();
|
|
1346
1391
|
}
|
|
1347
1392
|
/**
|
|
1348
1393
|
* Reduce the latest trails into the glow texture (glow.glsl), then rebind
|
|
1349
1394
|
* `framebuffer` with the full viewport.
|
|
1350
1395
|
*/
|
|
1351
1396
|
renderGlow(e) {
|
|
1352
|
-
const t = this.gl, i = Math.ceil(this.screenWidth /
|
|
1353
|
-
return this.glowTexture || (this.glowTexture =
|
|
1397
|
+
const t = this.gl, i = Math.ceil(this.screenWidth / We), a = Math.ceil(this.screenHeight / We);
|
|
1398
|
+
return this.glowTexture || (this.glowTexture = Se(t, t.LINEAR, null, i, a), this.glowFramebuffer = J(t, this.glowTexture)), t.bindFramebuffer(t.FRAMEBUFFER, this.glowFramebuffer), t.viewport(0, 0, i, a), t.disable(t.BLEND), t.useProgram(this.glowProgram), O(t, this.screenTextures[1], 0), t.uniform1i(this.glowLocs.u_screen, 0), this.drawQuad(), t.bindFramebuffer(t.FRAMEBUFFER, e), t.viewport(0, 0, this.screenWidth, this.screenHeight), this.glowTexture;
|
|
1354
1399
|
}
|
|
1355
1400
|
deleteGlowTarget() {
|
|
1356
1401
|
this.glowTexture && (this.gl.deleteTexture(this.glowTexture), this.gl.deleteFramebuffer(this.glowFramebuffer), this.glowTexture = null, this.glowFramebuffer = null);
|
|
1357
1402
|
}
|
|
1358
|
-
renderGrid(e, t, i, a, r, n, o,
|
|
1359
|
-
const
|
|
1360
|
-
|
|
1403
|
+
renderGrid(e, t, i, a, r, n, o, l = 1, d = Me, c) {
|
|
1404
|
+
const u = this.gl;
|
|
1405
|
+
u.useProgram(this.gridProgram), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
|
|
1361
1406
|
this.gridLocs,
|
|
1362
1407
|
e,
|
|
1363
1408
|
t,
|
|
1364
1409
|
i,
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
),
|
|
1410
|
+
l,
|
|
1411
|
+
d,
|
|
1412
|
+
c
|
|
1413
|
+
), u.uniformMatrix4fv(
|
|
1369
1414
|
this.gridLocs.u_matrix,
|
|
1370
1415
|
!1,
|
|
1371
1416
|
a instanceof Float32Array ? a : new Float32Array(Array.from(a))
|
|
1372
|
-
),
|
|
1417
|
+
), u.uniform4f(
|
|
1373
1418
|
this.gridLocs.u_geo_bounds,
|
|
1374
1419
|
o.west,
|
|
1375
1420
|
o.south,
|
|
1376
1421
|
o.east,
|
|
1377
1422
|
o.north
|
|
1378
|
-
),
|
|
1423
|
+
), u.uniform1f(this.gridLocs.u_world_size, r), u.enable(u.BLEND), u.blendFunc(u.SRC_ALPHA, u.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridProgram);
|
|
1379
1424
|
for (const f of n)
|
|
1380
|
-
|
|
1381
|
-
|
|
1425
|
+
u.uniform1f(this.gridLocs.u_world_offset, f), u.drawElements(
|
|
1426
|
+
u.TRIANGLES,
|
|
1382
1427
|
this.rasterGridIndexCount,
|
|
1383
|
-
|
|
1428
|
+
u.UNSIGNED_SHORT,
|
|
1384
1429
|
0
|
|
1385
1430
|
);
|
|
1386
|
-
this.unbindRasterGrid(this.gridProgram),
|
|
1431
|
+
this.unbindRasterGrid(this.gridProgram), u.disable(u.BLEND);
|
|
1387
1432
|
}
|
|
1388
|
-
renderGridGlobe(e, t, i, a, r, n, o = 1,
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1433
|
+
renderGridGlobe(e, t, i, a, r, n, o = 1, l = Me, d, c = Kt) {
|
|
1434
|
+
const u = this.gl;
|
|
1435
|
+
u.useProgram(this.gridGlobeProgram), vt(u, this.gridGlobeLocs, c), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
|
|
1391
1436
|
this.gridGlobeLocs,
|
|
1392
1437
|
e,
|
|
1393
1438
|
t,
|
|
1394
1439
|
i,
|
|
1395
1440
|
o,
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
),
|
|
1441
|
+
l,
|
|
1442
|
+
d
|
|
1443
|
+
), u.uniformMatrix4fv(
|
|
1399
1444
|
this.gridGlobeLocs.u_matrix,
|
|
1400
1445
|
!1,
|
|
1401
1446
|
a instanceof Float32Array ? a : new Float32Array(Array.from(a))
|
|
1402
|
-
),
|
|
1447
|
+
), u.uniform4f(
|
|
1403
1448
|
this.gridGlobeLocs.u_geo_bounds,
|
|
1404
1449
|
r.west,
|
|
1405
1450
|
r.south,
|
|
1406
1451
|
r.east,
|
|
1407
1452
|
r.north
|
|
1408
|
-
),
|
|
1453
|
+
), u.uniform4f(
|
|
1409
1454
|
this.gridGlobeLocs.u_clipping_plane,
|
|
1410
1455
|
n[0],
|
|
1411
1456
|
n[1],
|
|
1412
1457
|
n[2],
|
|
1413
1458
|
n[3]
|
|
1414
|
-
),
|
|
1415
|
-
|
|
1459
|
+
), u.enable(u.BLEND), u.blendFunc(u.SRC_ALPHA, u.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridGlobeProgram), u.drawElements(
|
|
1460
|
+
u.TRIANGLES,
|
|
1416
1461
|
this.rasterGridIndexCount,
|
|
1417
|
-
|
|
1462
|
+
u.UNSIGNED_SHORT,
|
|
1418
1463
|
0
|
|
1419
|
-
), this.unbindRasterGrid(this.gridGlobeProgram),
|
|
1464
|
+
), this.unbindRasterGrid(this.gridGlobeProgram), u.disable(u.BLEND);
|
|
1420
1465
|
}
|
|
1421
1466
|
setGridFieldUniforms(e, t, i, a, r, n, o) {
|
|
1422
|
-
const
|
|
1423
|
-
|
|
1424
|
-
const
|
|
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);
|
|
1469
|
+
const u = Math.sqrt(
|
|
1425
1470
|
Math.max(Math.abs(i[0]), Math.abs(a[0])) ** 2 + Math.max(Math.abs(i[1]), Math.abs(a[1])) ** 2
|
|
1426
1471
|
);
|
|
1427
|
-
|
|
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);
|
|
1428
1473
|
}
|
|
1429
1474
|
bindRasterGrid(e) {
|
|
1430
1475
|
const t = this.gl, i = t.getAttribLocation(e, "a_grid_uv");
|
|
@@ -1490,11 +1535,11 @@ class wt {
|
|
|
1490
1535
|
}
|
|
1491
1536
|
/** Partial values take the vibrant preset; see resolveColorGrade. */
|
|
1492
1537
|
setColorGrade(e) {
|
|
1493
|
-
this.params.colorGrade =
|
|
1538
|
+
this.params.colorGrade = bt(e);
|
|
1494
1539
|
}
|
|
1495
1540
|
/** Missing values take the defaults; see resolveBackdrop. */
|
|
1496
1541
|
setBackdrop(e) {
|
|
1497
|
-
this.params.backdrop =
|
|
1542
|
+
this.params.backdrop = St(e);
|
|
1498
1543
|
}
|
|
1499
1544
|
/** Halo strength, clamped to [0, 1]; 0 frees the glow texture. */
|
|
1500
1545
|
setGlow(e) {
|
|
@@ -1579,7 +1624,7 @@ class wt {
|
|
|
1579
1624
|
e.deleteBuffer(this.quadBuffer), e.deleteBuffer(this.particleIndexBuffer), e.deleteBuffer(this.particleIsCurrBuffer), e.deleteTexture(this.colorRampTexture);
|
|
1580
1625
|
}
|
|
1581
1626
|
}
|
|
1582
|
-
class
|
|
1627
|
+
class Pt {
|
|
1583
1628
|
constructor() {
|
|
1584
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;
|
|
1585
1630
|
}
|
|
@@ -1593,17 +1638,17 @@ class Tt {
|
|
|
1593
1638
|
* fields may use a fixed color domain so fragments never decode physical values.
|
|
1594
1639
|
*/
|
|
1595
1640
|
update(e, t = null) {
|
|
1596
|
-
const i = this.gl, { u: a, v: r, width: n, height: o, uMin:
|
|
1597
|
-
this.scalarMode = e.scalarMode ?? !1, this.width = n, this.height = o, this.uMin =
|
|
1598
|
-
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);
|
|
1599
1644
|
for (let y = 0; y < n * o; y++) {
|
|
1600
1645
|
const v = a[y], _ = r[y];
|
|
1601
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(
|
|
1602
1647
|
Math.max(0, Math.min(1, (v - f) / p)) * 255
|
|
1603
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(
|
|
1604
|
-
Math.max(0, Math.min(1, (v -
|
|
1649
|
+
Math.max(0, Math.min(1, (v - l) / p)) * 255
|
|
1605
1650
|
), g[y * 4 + 1] = Math.round(
|
|
1606
|
-
Math.max(0, Math.min(1, (_ -
|
|
1651
|
+
Math.max(0, Math.min(1, (_ - c) / h)) * 255
|
|
1607
1652
|
), g[y * 4 + 2] = 0, g[y * 4 + 3] = 255);
|
|
1608
1653
|
}
|
|
1609
1654
|
if (e.latDescending) {
|
|
@@ -1617,7 +1662,7 @@ class Tt {
|
|
|
1617
1662
|
console.log(
|
|
1618
1663
|
`[zartigl] Velocity texture: ${n}x${o}, valid=${x} (${(100 * x / (n * o)).toFixed(
|
|
1619
1664
|
1
|
|
1620
|
-
)}%), nodata=${T}, uRange=[${
|
|
1665
|
+
)}%), nodata=${T}, uRange=[${l.toFixed(4)}, ${d.toFixed(4)}], vRange=[${c.toFixed(4)}, ${u.toFixed(4)}]`
|
|
1621
1666
|
), this.texture || (this.texture = i.createTexture());
|
|
1622
1667
|
const M = this.linearFilter ? i.LINEAR : i.NEAREST;
|
|
1623
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(
|
|
@@ -1657,8 +1702,8 @@ class Tt {
|
|
|
1657
1702
|
this.gl && this.texture && (this.gl.deleteTexture(this.texture), this.texture = null);
|
|
1658
1703
|
}
|
|
1659
1704
|
}
|
|
1660
|
-
function
|
|
1661
|
-
const o = new Float32Array(t * i).fill(NaN),
|
|
1705
|
+
function Et(s, e, t, i, a, r, n) {
|
|
1706
|
+
const o = new Float32Array(t * i).fill(NaN), l = new Float32Array(t * i).fill(NaN);
|
|
1662
1707
|
for (const m of s)
|
|
1663
1708
|
for (let p = 0; p < m.latSize; p++)
|
|
1664
1709
|
for (let h = 0; h < m.lonSize; h++) {
|
|
@@ -1669,38 +1714,38 @@ function Mt(s, e, t, i, a, r, n) {
|
|
|
1669
1714
|
for (let p = 0; p < m.latSize; p++)
|
|
1670
1715
|
for (let h = 0; h < m.lonSize; h++) {
|
|
1671
1716
|
const g = p * m.lonChunkSize + h, x = (m.latStart + p) * i + (m.lonStart + h);
|
|
1672
|
-
|
|
1717
|
+
l[x] = m.data[g];
|
|
1673
1718
|
}
|
|
1674
|
-
let
|
|
1719
|
+
let d = 1 / 0, c = -1 / 0, u = 1 / 0, f = -1 / 0;
|
|
1675
1720
|
for (let m = 0; m < o.length; m++)
|
|
1676
|
-
isNaN(o[m]) || (o[m] <
|
|
1677
|
-
return 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), {
|
|
1678
1723
|
u: o,
|
|
1679
|
-
v:
|
|
1724
|
+
v: l,
|
|
1680
1725
|
width: i,
|
|
1681
1726
|
height: t,
|
|
1682
|
-
uMin:
|
|
1683
|
-
uMax:
|
|
1684
|
-
vMin:
|
|
1727
|
+
uMin: d,
|
|
1728
|
+
uMax: c,
|
|
1729
|
+
vMin: u,
|
|
1685
1730
|
vMax: f,
|
|
1686
1731
|
bounds: a ?? { west: -180, south: -90, east: 180, north: 90 },
|
|
1687
1732
|
latDescending: r,
|
|
1688
1733
|
scalarMode: n
|
|
1689
1734
|
};
|
|
1690
1735
|
}
|
|
1691
|
-
const
|
|
1736
|
+
const Re = [
|
|
1692
1737
|
"depth",
|
|
1693
1738
|
"elevation",
|
|
1694
1739
|
"level",
|
|
1695
1740
|
"altitude",
|
|
1696
1741
|
"pressure_level"
|
|
1697
1742
|
];
|
|
1698
|
-
class
|
|
1743
|
+
class Qe extends Error {
|
|
1699
1744
|
constructor(e, t) {
|
|
1700
1745
|
super(`Chunk fetch failed: ${e} ${t}`), this.name = "ZarrChunkFetchError", this.status = e, this.url = t;
|
|
1701
1746
|
}
|
|
1702
1747
|
}
|
|
1703
|
-
class
|
|
1748
|
+
class _e {
|
|
1704
1749
|
constructor(e, t = 200) {
|
|
1705
1750
|
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;
|
|
1706
1751
|
}
|
|
@@ -1752,7 +1797,7 @@ class ye {
|
|
|
1752
1797
|
let a = t ? i[0] : NaN, r = a;
|
|
1753
1798
|
for (let o = 1; o < i.length; o++)
|
|
1754
1799
|
a = Math.min(a, i[o]), r = Math.max(r, i[o]);
|
|
1755
|
-
const n =
|
|
1800
|
+
const n = Bi(i);
|
|
1756
1801
|
return {
|
|
1757
1802
|
min: a,
|
|
1758
1803
|
max: r,
|
|
@@ -1824,7 +1869,7 @@ class ye {
|
|
|
1824
1869
|
throw new Error(
|
|
1825
1870
|
`Unsupported Zarr time units: ${this.timeUnits || "<missing>"}`
|
|
1826
1871
|
);
|
|
1827
|
-
const i =
|
|
1872
|
+
const i = Gi(t[2]);
|
|
1828
1873
|
if (!Number.isFinite(i))
|
|
1829
1874
|
throw new Error(`Invalid Zarr time epoch: ${t[2]}`);
|
|
1830
1875
|
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;
|
|
@@ -1837,28 +1882,28 @@ class ye {
|
|
|
1837
1882
|
}
|
|
1838
1883
|
async sampleVariableAt(e, t) {
|
|
1839
1884
|
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);
|
|
1840
|
-
for (let
|
|
1841
|
-
const
|
|
1885
|
+
for (let c = 0; c < i.length; c++) {
|
|
1886
|
+
const u = i[c];
|
|
1842
1887
|
let f = 0;
|
|
1843
|
-
|
|
1888
|
+
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];
|
|
1844
1889
|
}
|
|
1845
|
-
let
|
|
1890
|
+
let l;
|
|
1846
1891
|
try {
|
|
1847
|
-
|
|
1848
|
-
} catch (
|
|
1849
|
-
if (
|
|
1892
|
+
l = await this.fetchChunk(e, n);
|
|
1893
|
+
} catch (c) {
|
|
1894
|
+
if (c instanceof Qe && (c.status === 403 || c.status === 404))
|
|
1850
1895
|
return NaN;
|
|
1851
|
-
throw
|
|
1896
|
+
throw c;
|
|
1852
1897
|
}
|
|
1853
|
-
const
|
|
1854
|
-
return
|
|
1898
|
+
const d = this.getFlatOffset(e, o);
|
|
1899
|
+
return d < l.length ? l[d] : NaN;
|
|
1855
1900
|
}
|
|
1856
1901
|
getFlatOffset(e, t) {
|
|
1857
1902
|
const i = this.getArrayMeta(e), a = i.chunks;
|
|
1858
1903
|
if (i.order === "F") {
|
|
1859
1904
|
let n = 0, o = 1;
|
|
1860
|
-
for (let
|
|
1861
|
-
n += t[
|
|
1905
|
+
for (let l = 0; l < t.length; l++)
|
|
1906
|
+
n += t[l] * o, o *= a[l];
|
|
1862
1907
|
return n;
|
|
1863
1908
|
}
|
|
1864
1909
|
let r = 0;
|
|
@@ -1874,13 +1919,13 @@ class ye {
|
|
|
1874
1919
|
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(
|
|
1875
1920
|
t.time.length - 1,
|
|
1876
1921
|
e.timeEndIndex ?? t.time.length - 1
|
|
1877
|
-
),
|
|
1922
|
+
), l = Math.max(1, Math.floor(e.stride ?? 1)), d = Math.max(
|
|
1878
1923
|
0,
|
|
1879
1924
|
Math.floor(e.stopAfterMissingSamples ?? 0)
|
|
1880
1925
|
);
|
|
1881
|
-
let
|
|
1882
|
-
const
|
|
1883
|
-
for (let f = n; f <= o; f +=
|
|
1926
|
+
let c = 0;
|
|
1927
|
+
const u = [];
|
|
1928
|
+
for (let f = n; f <= o; f += l) {
|
|
1884
1929
|
const m = {};
|
|
1885
1930
|
for (const g of e.variables)
|
|
1886
1931
|
m[g] = await this.sampleVariableAt(g, {
|
|
@@ -1890,21 +1935,21 @@ class ye {
|
|
|
1890
1935
|
lonIdx: i
|
|
1891
1936
|
});
|
|
1892
1937
|
const p = this.zarrTimeToMs(t.time[f]);
|
|
1893
|
-
if (
|
|
1938
|
+
if (u.push({
|
|
1894
1939
|
axisValue: p,
|
|
1895
1940
|
time: p,
|
|
1896
1941
|
depth: t.vertical[r],
|
|
1897
1942
|
values: m
|
|
1898
|
-
}),
|
|
1943
|
+
}), c = e.variables.every(
|
|
1899
1944
|
(g) => !Number.isFinite(m[g])
|
|
1900
|
-
) ?
|
|
1945
|
+
) ? c + 1 : 0, d > 0 && c >= d)
|
|
1901
1946
|
break;
|
|
1902
1947
|
}
|
|
1903
1948
|
return {
|
|
1904
1949
|
longitude: t.longitude[i],
|
|
1905
1950
|
latitude: t.latitude[a],
|
|
1906
1951
|
depth: t.vertical[r],
|
|
1907
|
-
points:
|
|
1952
|
+
points: u
|
|
1908
1953
|
};
|
|
1909
1954
|
}
|
|
1910
1955
|
async sampleVerticalProfile(e) {
|
|
@@ -1914,22 +1959,22 @@ class ye {
|
|
|
1914
1959
|
Math.floor(e.stopAfterMissingSamples ?? 0)
|
|
1915
1960
|
);
|
|
1916
1961
|
let o = 0;
|
|
1917
|
-
const
|
|
1918
|
-
let
|
|
1962
|
+
const l = [];
|
|
1963
|
+
let d = Array.from(
|
|
1919
1964
|
{ length: t.vertical.length },
|
|
1920
1965
|
(f, m) => m
|
|
1921
1966
|
).sort(
|
|
1922
1967
|
(f, m) => Math.abs(t.vertical[f]) - Math.abs(t.vertical[m])
|
|
1923
1968
|
);
|
|
1924
|
-
const
|
|
1969
|
+
const c = Math.max(
|
|
1925
1970
|
1,
|
|
1926
|
-
Math.floor(e.maxDepths ??
|
|
1927
|
-
),
|
|
1971
|
+
Math.floor(e.maxDepths ?? d.length)
|
|
1972
|
+
), u = Math.max(
|
|
1928
1973
|
1,
|
|
1929
|
-
Math.floor(e.stride ?? Math.ceil(
|
|
1974
|
+
Math.floor(e.stride ?? Math.ceil(d.length / c))
|
|
1930
1975
|
);
|
|
1931
|
-
|
|
1932
|
-
for (const f of
|
|
1976
|
+
d = d.filter((f, m) => m % u === 0).slice(0, c);
|
|
1977
|
+
for (const f of d) {
|
|
1933
1978
|
const m = {};
|
|
1934
1979
|
for (const g of e.variables)
|
|
1935
1980
|
m[g] = await this.sampleVariableAt(g, {
|
|
@@ -1939,7 +1984,7 @@ class ye {
|
|
|
1939
1984
|
lonIdx: i
|
|
1940
1985
|
});
|
|
1941
1986
|
const p = t.vertical[f];
|
|
1942
|
-
if (
|
|
1987
|
+
if (l.push({
|
|
1943
1988
|
axisValue: p,
|
|
1944
1989
|
time: this.zarrTimeToMs(t.time[r]),
|
|
1945
1990
|
depth: p,
|
|
@@ -1953,7 +1998,7 @@ class ye {
|
|
|
1953
1998
|
longitude: t.longitude[i],
|
|
1954
1999
|
latitude: t.latitude[a],
|
|
1955
2000
|
time: this.zarrTimeToMs(t.time[r]),
|
|
1956
|
-
points:
|
|
2001
|
+
points: l
|
|
1957
2002
|
};
|
|
1958
2003
|
}
|
|
1959
2004
|
/** Return the actual name of the vertical dimension ("depth" or "elevation"). */
|
|
@@ -1964,11 +2009,11 @@ class ye {
|
|
|
1964
2009
|
* Get chunk indices that intersect a geographic bounding box.
|
|
1965
2010
|
*/
|
|
1966
2011
|
getChunksForBounds(e, t, i, a) {
|
|
1967
|
-
const r = this.getCoords(), n = this.getChunkShape(e), o = this.getDimensions(e),
|
|
2012
|
+
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 = [];
|
|
1968
2013
|
for (let b = _; b <= S; b++)
|
|
1969
|
-
for (let A =
|
|
1970
|
-
const N = b *
|
|
1971
|
-
|
|
2014
|
+
for (let A = E; A <= R; A++) {
|
|
2015
|
+
const N = b * c, C = A * u, I = Math.min(c, F - N), w = Math.min(u, L - C);
|
|
2016
|
+
D.push({
|
|
1972
2017
|
timeIdx: t,
|
|
1973
2018
|
depthIdx: i,
|
|
1974
2019
|
latIdx: b,
|
|
@@ -1979,7 +2024,7 @@ class ye {
|
|
|
1979
2024
|
lonSize: w
|
|
1980
2025
|
});
|
|
1981
2026
|
}
|
|
1982
|
-
return
|
|
2027
|
+
return D;
|
|
1983
2028
|
}
|
|
1984
2029
|
async fetchChunk(e, t) {
|
|
1985
2030
|
return (await this.fetchChunkResult(e, t)).data;
|
|
@@ -1995,13 +2040,13 @@ class ye {
|
|
|
1995
2040
|
throw new Error(
|
|
1996
2041
|
`Variable ${e} must have latitude and longitude dimensions`
|
|
1997
2042
|
);
|
|
1998
|
-
const o = new Array(i.length).fill(0),
|
|
2043
|
+
const o = new Array(i.length).fill(0), l = new Array(i.length).fill(0);
|
|
1999
2044
|
for (let m = 0; m < i.length; m++) {
|
|
2000
2045
|
const p = i[m];
|
|
2001
2046
|
let h = 0;
|
|
2002
2047
|
if (p === "time")
|
|
2003
2048
|
h = t.timeIndex;
|
|
2004
|
-
else if (p === this.verticalName ||
|
|
2049
|
+
else if (p === this.verticalName || Re.includes(p))
|
|
2005
2050
|
h = t.verticalIndex;
|
|
2006
2051
|
else if (p === "latitude") {
|
|
2007
2052
|
o[m] = t.latitudeChunkIndex;
|
|
@@ -2010,19 +2055,19 @@ class ye {
|
|
|
2010
2055
|
o[m] = t.longitudeChunkIndex;
|
|
2011
2056
|
continue;
|
|
2012
2057
|
}
|
|
2013
|
-
o[m] = Math.floor(h / a[m]),
|
|
2058
|
+
o[m] = Math.floor(h / a[m]), l[m] = h % a[m];
|
|
2014
2059
|
}
|
|
2015
|
-
const
|
|
2060
|
+
const d = await this.fetchChunkResult(e, o), c = a[r], u = a[n], f = new Float32Array(c * u);
|
|
2016
2061
|
f.fill(NaN);
|
|
2017
|
-
for (let m = 0; m <
|
|
2018
|
-
|
|
2019
|
-
for (let p = 0; p <
|
|
2020
|
-
|
|
2021
|
-
const h = this.getFlatOffset(e,
|
|
2022
|
-
h <
|
|
2062
|
+
for (let m = 0; m < c; m++) {
|
|
2063
|
+
l[r] = m;
|
|
2064
|
+
for (let p = 0; p < u; p++) {
|
|
2065
|
+
l[n] = p;
|
|
2066
|
+
const h = this.getFlatOffset(e, l);
|
|
2067
|
+
h < d.data.length && (f[m * u + p] = d.data[h]);
|
|
2023
2068
|
}
|
|
2024
2069
|
}
|
|
2025
|
-
return { ...
|
|
2070
|
+
return { ...d, data: f };
|
|
2026
2071
|
}
|
|
2027
2072
|
async fetchChunkResult(e, t) {
|
|
2028
2073
|
const i = this.getDimensionSeparator(e), a = t.join(i), r = `${e}/${a}`, n = `${this.root}/${e}/${a}`;
|
|
@@ -2031,23 +2076,23 @@ class ye {
|
|
|
2031
2076
|
this.abortControllers.get(r)?.abort();
|
|
2032
2077
|
const o = new AbortController();
|
|
2033
2078
|
this.abortControllers.set(r, o);
|
|
2034
|
-
const
|
|
2079
|
+
const l = this.getArrayMeta(e);
|
|
2035
2080
|
try {
|
|
2036
|
-
const
|
|
2037
|
-
if (!
|
|
2038
|
-
if (
|
|
2081
|
+
const d = await fetch(n, { signal: o.signal });
|
|
2082
|
+
if (!d.ok) {
|
|
2083
|
+
if (d.status === 403 || d.status === 404)
|
|
2039
2084
|
return {
|
|
2040
|
-
data:
|
|
2085
|
+
data: zi(l),
|
|
2041
2086
|
missing: !0,
|
|
2042
|
-
status:
|
|
2087
|
+
status: d.status,
|
|
2043
2088
|
url: n
|
|
2044
2089
|
};
|
|
2045
|
-
throw new
|
|
2090
|
+
throw new Qe(d.status, n);
|
|
2046
2091
|
}
|
|
2047
|
-
const
|
|
2048
|
-
await this.decompress(
|
|
2092
|
+
const c = new Uint8Array(await d.arrayBuffer()), u = Ni(
|
|
2093
|
+
await this.decompress(c, l, e)
|
|
2049
2094
|
);
|
|
2050
|
-
return this.cacheChunk(r,
|
|
2095
|
+
return this.cacheChunk(r, u), { data: u, missing: !1, url: n };
|
|
2051
2096
|
} finally {
|
|
2052
2097
|
this.abortControllers.get(r) === o && this.abortControllers.delete(r);
|
|
2053
2098
|
}
|
|
@@ -2067,7 +2112,7 @@ class ye {
|
|
|
2067
2112
|
getBloscCodec(e) {
|
|
2068
2113
|
const t = e.compressor, i = `${t.cname ?? "lz4"}-${t.clevel ?? 5}-${t.shuffle ?? 1}-${t.blocksize ?? 0}`;
|
|
2069
2114
|
let a = this.bloscCodecCache.get(i);
|
|
2070
|
-
return a || (a =
|
|
2115
|
+
return a || (a = vi.fromConfig({
|
|
2071
2116
|
id: "blosc",
|
|
2072
2117
|
cname: t.cname ?? "lz4",
|
|
2073
2118
|
clevel: t.clevel ?? 5,
|
|
@@ -2081,7 +2126,7 @@ class ye {
|
|
|
2081
2126
|
switch (t.compressor.id) {
|
|
2082
2127
|
case "zlib":
|
|
2083
2128
|
case "gzip":
|
|
2084
|
-
a =
|
|
2129
|
+
a = gi(e);
|
|
2085
2130
|
break;
|
|
2086
2131
|
case "blosc": {
|
|
2087
2132
|
a = await this.getBloscCodec(t).decode(e);
|
|
@@ -2107,70 +2152,70 @@ class ye {
|
|
|
2107
2152
|
a.byteLength / 8
|
|
2108
2153
|
);
|
|
2109
2154
|
else if (n === "<i2" || n === "|i2") {
|
|
2110
|
-
const
|
|
2155
|
+
const l = new Int16Array(
|
|
2111
2156
|
a.buffer,
|
|
2112
2157
|
a.byteOffset,
|
|
2113
2158
|
a.byteLength / 2
|
|
2114
2159
|
);
|
|
2115
|
-
r = Float32Array.from(
|
|
2160
|
+
r = Float32Array.from(l);
|
|
2116
2161
|
} else if (n === "<i4" || n === "|i4") {
|
|
2117
|
-
const
|
|
2162
|
+
const l = new Int32Array(
|
|
2118
2163
|
a.buffer,
|
|
2119
2164
|
a.byteOffset,
|
|
2120
2165
|
a.byteLength / 4
|
|
2121
2166
|
);
|
|
2122
|
-
r = Float32Array.from(
|
|
2167
|
+
r = Float32Array.from(l);
|
|
2123
2168
|
} else if (n === "<i8" || n === "|i8") {
|
|
2124
|
-
const
|
|
2169
|
+
const l = new DataView(
|
|
2125
2170
|
a.buffer,
|
|
2126
2171
|
a.byteOffset,
|
|
2127
2172
|
a.byteLength
|
|
2128
|
-
),
|
|
2129
|
-
r = new Float64Array(
|
|
2130
|
-
for (let
|
|
2131
|
-
r[
|
|
2173
|
+
), d = a.byteLength / 8;
|
|
2174
|
+
r = new Float64Array(d);
|
|
2175
|
+
for (let c = 0; c < d; c++)
|
|
2176
|
+
r[c] = Number(l.getBigInt64(c * 8, !0));
|
|
2132
2177
|
} else
|
|
2133
2178
|
throw new Error(`Unsupported dtype: ${n}`);
|
|
2134
2179
|
const o = t.fill_value;
|
|
2135
2180
|
if (o != null && typeof o == "number" && !isNaN(o))
|
|
2136
|
-
for (let
|
|
2137
|
-
r[
|
|
2181
|
+
for (let l = 0; l < r.length; l++)
|
|
2182
|
+
r[l] === o && (r[l] = NaN);
|
|
2138
2183
|
if (i) {
|
|
2139
|
-
const
|
|
2140
|
-
if (
|
|
2141
|
-
const
|
|
2184
|
+
const l = this.getAttrs(i), d = l.scale_factor, c = l.add_offset;
|
|
2185
|
+
if (d != null || c != null) {
|
|
2186
|
+
const u = d ?? 1, f = c ?? 0;
|
|
2142
2187
|
for (let m = 0; m < r.length; m++)
|
|
2143
|
-
isNaN(r[m]) || (r[m] = r[m] *
|
|
2188
|
+
isNaN(r[m]) || (r[m] = r[m] * u + f);
|
|
2144
2189
|
}
|
|
2145
2190
|
}
|
|
2146
2191
|
return r;
|
|
2147
2192
|
}
|
|
2148
2193
|
async loadCoordinates() {
|
|
2149
|
-
const e = async (
|
|
2150
|
-
const
|
|
2151
|
-
for (let g = 0; g <
|
|
2152
|
-
const x = `${this.root}/${
|
|
2194
|
+
const e = async (l) => {
|
|
2195
|
+
const d = this.getArrayMeta(l), c = d.shape[0], u = Math.ceil(c / d.chunks[0]), f = [];
|
|
2196
|
+
for (let g = 0; g < u; g++) {
|
|
2197
|
+
const x = `${this.root}/${l}/${g}`, T = await fetch(x);
|
|
2153
2198
|
if (!T.ok)
|
|
2154
|
-
throw new Error(`Failed to fetch coord ${
|
|
2199
|
+
throw new Error(`Failed to fetch coord ${l}/${g}`);
|
|
2155
2200
|
const M = new Uint8Array(await T.arrayBuffer());
|
|
2156
|
-
f.push(await this.decompress(M,
|
|
2201
|
+
f.push(await this.decompress(M, d));
|
|
2157
2202
|
}
|
|
2158
2203
|
if (f.length === 1)
|
|
2159
|
-
return f[0].length >
|
|
2160
|
-
const m = f.some((g) => g instanceof Float64Array) ? Float64Array : Float32Array, p = new m(
|
|
2204
|
+
return f[0].length > c ? f[0].subarray(0, c) : f[0];
|
|
2205
|
+
const m = f.some((g) => g instanceof Float64Array) ? Float64Array : Float32Array, p = new m(c);
|
|
2161
2206
|
let h = 0;
|
|
2162
2207
|
for (const g of f) {
|
|
2163
|
-
const x = Math.min(g.length,
|
|
2164
|
-
if (p.set(g.subarray(0, x), h), h += x, h >=
|
|
2208
|
+
const x = Math.min(g.length, c - h);
|
|
2209
|
+
if (p.set(g.subarray(0, x), h), h += x, h >= c)
|
|
2165
2210
|
break;
|
|
2166
2211
|
}
|
|
2167
2212
|
return p;
|
|
2168
2213
|
};
|
|
2169
2214
|
let t = null;
|
|
2170
|
-
for (const
|
|
2171
|
-
const
|
|
2172
|
-
if (this.meta.metadata[
|
|
2173
|
-
t =
|
|
2215
|
+
for (const l of Re) {
|
|
2216
|
+
const d = `${l}/.zarray`;
|
|
2217
|
+
if (this.meta.metadata[d] && "dtype" in this.meta.metadata[d]) {
|
|
2218
|
+
t = l;
|
|
2174
2219
|
break;
|
|
2175
2220
|
}
|
|
2176
2221
|
}
|
|
@@ -2191,30 +2236,30 @@ class ye {
|
|
|
2191
2236
|
};
|
|
2192
2237
|
}
|
|
2193
2238
|
}
|
|
2194
|
-
function
|
|
2239
|
+
function Ni(s) {
|
|
2195
2240
|
return s instanceof Float32Array ? s : Float32Array.from(s);
|
|
2196
2241
|
}
|
|
2197
|
-
function
|
|
2242
|
+
function zi(s) {
|
|
2198
2243
|
const e = s.chunks.reduce((i, a) => i * a, 1), t = new Float32Array(e);
|
|
2199
2244
|
return t.fill(NaN), t;
|
|
2200
2245
|
}
|
|
2201
|
-
function
|
|
2246
|
+
function Gi(s) {
|
|
2202
2247
|
const t = s.trim().replace(/\s+\([^)]*\)\s*$/, "").match(
|
|
2203
2248
|
/^(\d{4})-(\d{2})-(\d{2})(?:(?:T|\s+)(\d{2})(?::(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?)?)?(?:\s*(Z|[+-]\d{2}:?\d{2}))?$/i
|
|
2204
2249
|
);
|
|
2205
2250
|
if (!t)
|
|
2206
2251
|
return NaN;
|
|
2207
|
-
const i = Number(t[1]), a = Number(t[2]), r = Number(t[3]), n = Number(t[4] ?? 0), o = Number(t[5] ?? 0),
|
|
2208
|
-
if (a < 1 || a > 12 || n > 23 || o > 59 ||
|
|
2252
|
+
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";
|
|
2253
|
+
if (a < 1 || a > 12 || n > 23 || o > 59 || l > 59)
|
|
2209
2254
|
return NaN;
|
|
2210
|
-
const
|
|
2211
|
-
|
|
2212
|
-
const f =
|
|
2213
|
-
if (
|
|
2255
|
+
const u = /* @__PURE__ */ new Date(0);
|
|
2256
|
+
u.setUTCFullYear(i, a - 1, r), u.setUTCHours(n, o, l, d);
|
|
2257
|
+
const f = u.getTime();
|
|
2258
|
+
if (u.getUTCFullYear() !== i || u.getUTCMonth() !== a - 1 || u.getUTCDate() !== r || u.getUTCHours() !== n || u.getUTCMinutes() !== o || u.getUTCSeconds() !== l || u.getUTCMilliseconds() !== d)
|
|
2214
2259
|
return NaN;
|
|
2215
|
-
if (/^z$/i.test(
|
|
2260
|
+
if (/^z$/i.test(c))
|
|
2216
2261
|
return f;
|
|
2217
|
-
const m =
|
|
2262
|
+
const m = c.match(/^([+-])(\d{2}):?(\d{2})$/);
|
|
2218
2263
|
if (!m)
|
|
2219
2264
|
return NaN;
|
|
2220
2265
|
const p = Number(m[2]), h = Number(m[3]);
|
|
@@ -2223,7 +2268,7 @@ function Ui(s) {
|
|
|
2223
2268
|
const g = (p * 60 + h) * 6e4;
|
|
2224
2269
|
return f - (m[1] === "+" ? g : -g);
|
|
2225
2270
|
}
|
|
2226
|
-
function
|
|
2271
|
+
function Oi(s) {
|
|
2227
2272
|
if (typeof s != "number" || !Number.isFinite(s) || s <= 0)
|
|
2228
2273
|
return s;
|
|
2229
2274
|
const e = [
|
|
@@ -2245,7 +2290,7 @@ function Vi(s) {
|
|
|
2245
2290
|
return t;
|
|
2246
2291
|
return Math.round(s);
|
|
2247
2292
|
}
|
|
2248
|
-
function
|
|
2293
|
+
function Bi(s) {
|
|
2249
2294
|
if (s.length < 2)
|
|
2250
2295
|
return;
|
|
2251
2296
|
const e = s[1] - s[0];
|
|
@@ -2255,28 +2300,28 @@ function Ni(s) {
|
|
|
2255
2300
|
for (let i = 2; i < s.length; i++)
|
|
2256
2301
|
if (Math.abs(s[i] - s[i - 1] - e) > t)
|
|
2257
2302
|
return;
|
|
2258
|
-
return
|
|
2303
|
+
return Oi(e);
|
|
2259
2304
|
}
|
|
2260
|
-
class
|
|
2305
|
+
class xe extends Error {
|
|
2261
2306
|
constructor(e, t, i) {
|
|
2262
2307
|
super(
|
|
2263
2308
|
t.length > 0 ? "Remote data is not available yet; the selected frame may still be publishing." : "The selected frame contains no renderable data."
|
|
2264
2309
|
), this.name = "ZartiglFrameUnavailableError", this.time = e, this.statuses = [...new Set(t)].sort((a, r) => a - r), this.urls = [...new Set(i)];
|
|
2265
2310
|
}
|
|
2266
2311
|
}
|
|
2267
|
-
function
|
|
2312
|
+
function $i(s) {
|
|
2268
2313
|
for (const e of s)
|
|
2269
2314
|
if (Number.isFinite(e))
|
|
2270
2315
|
return !0;
|
|
2271
2316
|
return !1;
|
|
2272
2317
|
}
|
|
2273
|
-
function
|
|
2318
|
+
function qi(s, e) {
|
|
2274
2319
|
for (let t = 0; t < Math.min(s.length, e.length); t++)
|
|
2275
2320
|
if (Number.isFinite(s[t]) && Number.isFinite(e[t]))
|
|
2276
2321
|
return !0;
|
|
2277
2322
|
return !1;
|
|
2278
2323
|
}
|
|
2279
|
-
function
|
|
2324
|
+
function Lt(s) {
|
|
2280
2325
|
return {
|
|
2281
2326
|
phase: "blocked",
|
|
2282
2327
|
time: s.time,
|
|
@@ -2286,7 +2331,7 @@ function Rt(s) {
|
|
|
2286
2331
|
}
|
|
2287
2332
|
class me {
|
|
2288
2333
|
constructor(e) {
|
|
2289
|
-
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
|
|
2334
|
+
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 Pt(), this.simulation = new Rt({
|
|
2290
2335
|
colorRamp: e.colorRamp,
|
|
2291
2336
|
opacity: e.opacity ?? 1,
|
|
2292
2337
|
logScale: e.logScale ?? !1,
|
|
@@ -2318,31 +2363,34 @@ class me {
|
|
|
2318
2363
|
const i = K(e);
|
|
2319
2364
|
if (this.suspended || !this.map || !this.activeData || !this.activeField.hasData())
|
|
2320
2365
|
return;
|
|
2321
|
-
const a =
|
|
2366
|
+
const a = Ge(i);
|
|
2322
2367
|
try {
|
|
2323
2368
|
const r = i.canvas;
|
|
2324
2369
|
this.simulation.resize(r.width, r.height), i.bindFramebuffer(i.FRAMEBUFFER, a.framebuffer), i.viewport(0, 0, r.width, r.height);
|
|
2325
|
-
const n = this.map.getBounds(), o = this.map
|
|
2326
|
-
this.activeField.bind(this.textureUnit),
|
|
2370
|
+
const n = this.map.getBounds(), o = t.defaultProjectionData, l = ye(this.map, o), d = 512 * Math.pow(2, this.map.getZoom());
|
|
2371
|
+
this.activeField.bind(this.textureUnit), l ? this.simulation.renderGridGlobe(
|
|
2327
2372
|
this.textureUnit,
|
|
2328
2373
|
[this.activeData.uMin, this.activeData.vMin],
|
|
2329
2374
|
[this.activeData.uMax, this.activeData.vMax],
|
|
2330
2375
|
t.modelViewProjectionMatrix,
|
|
2331
2376
|
this.activeField.geoBounds,
|
|
2332
|
-
|
|
2333
|
-
1
|
|
2377
|
+
o.clippingPlane,
|
|
2378
|
+
1,
|
|
2379
|
+
void 0,
|
|
2380
|
+
void 0,
|
|
2381
|
+
o
|
|
2334
2382
|
) : this.simulation.renderGrid(
|
|
2335
2383
|
this.textureUnit,
|
|
2336
2384
|
[this.activeData.uMin, this.activeData.vMin],
|
|
2337
2385
|
[this.activeData.uMax, this.activeData.vMax],
|
|
2338
2386
|
t.modelViewProjectionMatrix,
|
|
2339
|
-
|
|
2340
|
-
|
|
2387
|
+
d,
|
|
2388
|
+
Be(n, !1),
|
|
2341
2389
|
this.activeField.geoBounds,
|
|
2342
2390
|
1
|
|
2343
2391
|
);
|
|
2344
2392
|
} finally {
|
|
2345
|
-
|
|
2393
|
+
Oe(i, a);
|
|
2346
2394
|
}
|
|
2347
2395
|
if (this.pendingReadyTime != null) {
|
|
2348
2396
|
const r = this.pendingReadyTime;
|
|
@@ -2475,7 +2523,7 @@ class me {
|
|
|
2475
2523
|
const n = r instanceof Error ? r : new Error(String(r));
|
|
2476
2524
|
e === this.generation && t === this.requestId && (this.emit(
|
|
2477
2525
|
"status",
|
|
2478
|
-
n instanceof
|
|
2526
|
+
n instanceof xe ? Lt(n) : { phase: "error", time: a, error: n }
|
|
2479
2527
|
), this.emit("error", n));
|
|
2480
2528
|
}
|
|
2481
2529
|
} finally {
|
|
@@ -2493,7 +2541,7 @@ class me {
|
|
|
2493
2541
|
r,
|
|
2494
2542
|
n,
|
|
2495
2543
|
a
|
|
2496
|
-
),
|
|
2544
|
+
), l = this.zarrSource.getDimensions(this.variable), d = l.indexOf("latitude"), c = l.indexOf("longitude"), u = this.zarrSource.getChunkShape(this.variable);
|
|
2497
2545
|
let f = 0;
|
|
2498
2546
|
const m = o.length, p = [], h = [];
|
|
2499
2547
|
t?.(f, m);
|
|
@@ -2510,46 +2558,46 @@ class me {
|
|
|
2510
2558
|
);
|
|
2511
2559
|
return A.missing && (A.status != null && p.push(A.status), h.push(A.url)), f++, t?.(f, m), {
|
|
2512
2560
|
data: A.data,
|
|
2513
|
-
latStart: b.latIdx * d
|
|
2514
|
-
lonStart: b.lonIdx *
|
|
2561
|
+
latStart: b.latIdx * u[d],
|
|
2562
|
+
lonStart: b.lonIdx * u[c],
|
|
2515
2563
|
latSize: b.latSize,
|
|
2516
2564
|
lonSize: b.lonSize,
|
|
2517
|
-
lonChunkSize:
|
|
2565
|
+
lonChunkSize: u[c]
|
|
2518
2566
|
};
|
|
2519
2567
|
})
|
|
2520
2568
|
), 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) => ({
|
|
2521
2569
|
...b,
|
|
2522
2570
|
latStart: b.latStart - x,
|
|
2523
2571
|
lonStart: b.lonStart - M
|
|
2524
|
-
})),
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2572
|
+
})), E = this.zarrSource.getCoords(), R = Math.min(T - 1, E.latitude.length - 1), k = Math.min(y - 1, E.longitude.length - 1), F = wt(
|
|
2573
|
+
E.longitude,
|
|
2574
|
+
E.latitude,
|
|
2575
|
+
[M, k],
|
|
2576
|
+
[x, R]
|
|
2577
|
+
), L = E.latitude[x] > E.latitude[R], D = Et(
|
|
2530
2578
|
S,
|
|
2531
2579
|
[],
|
|
2532
2580
|
v,
|
|
2533
2581
|
_,
|
|
2534
2582
|
F,
|
|
2535
|
-
|
|
2583
|
+
L,
|
|
2536
2584
|
!0
|
|
2537
2585
|
);
|
|
2538
|
-
if (
|
|
2539
|
-
throw new
|
|
2586
|
+
if (!$i(D.u))
|
|
2587
|
+
throw new xe(
|
|
2540
2588
|
this.timeToMs(e),
|
|
2541
2589
|
p,
|
|
2542
2590
|
h
|
|
2543
2591
|
);
|
|
2544
|
-
return
|
|
2592
|
+
return D;
|
|
2545
2593
|
}
|
|
2546
2594
|
setActive(e, t) {
|
|
2547
2595
|
const i = this.timeToMs(t);
|
|
2548
2596
|
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();
|
|
2549
2597
|
}
|
|
2550
2598
|
sampleActiveData(e, t, i) {
|
|
2551
|
-
const { west: a, east: r, south: n, north: o } = e.bounds,
|
|
2552
|
-
if (e.width <= 0 || e.height <= 0 ||
|
|
2599
|
+
const { west: a, east: r, south: n, north: o } = e.bounds, l = r - a, d = o - n;
|
|
2600
|
+
if (e.width <= 0 || e.height <= 0 || l <= 0 || d <= 0)
|
|
2553
2601
|
return {
|
|
2554
2602
|
longitude: t,
|
|
2555
2603
|
latitude: i,
|
|
@@ -2558,8 +2606,8 @@ class me {
|
|
|
2558
2606
|
time: this.timeToMs(this.time),
|
|
2559
2607
|
depth: this.depth
|
|
2560
2608
|
};
|
|
2561
|
-
const
|
|
2562
|
-
if (
|
|
2609
|
+
const c = a + ((t - a) % 360 + 360) % 360;
|
|
2610
|
+
if (c > r && l < 359 || i < n || i > o)
|
|
2563
2611
|
return {
|
|
2564
2612
|
longitude: t,
|
|
2565
2613
|
latitude: i,
|
|
@@ -2568,13 +2616,13 @@ class me {
|
|
|
2568
2616
|
time: this.timeToMs(this.time),
|
|
2569
2617
|
depth: this.depth
|
|
2570
2618
|
};
|
|
2571
|
-
const
|
|
2619
|
+
const u = (c - a) / l, f = e.latDescending ? (o - i) / d : (i - n) / d, m = Math.max(
|
|
2572
2620
|
0,
|
|
2573
|
-
Math.min(e.width - 1, Math.
|
|
2621
|
+
Math.min(e.width - 1, Math.floor(u * e.width))
|
|
2574
2622
|
), p = Math.max(
|
|
2575
2623
|
0,
|
|
2576
|
-
Math.min(e.height - 1, Math.
|
|
2577
|
-
), h = e.u[p * e.width + m] ?? NaN, g = a + m
|
|
2624
|
+
Math.min(e.height - 1, Math.floor(f * e.height))
|
|
2625
|
+
), 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;
|
|
2578
2626
|
return {
|
|
2579
2627
|
longitude: g,
|
|
2580
2628
|
latitude: x,
|
|
@@ -2604,7 +2652,7 @@ class me {
|
|
|
2604
2652
|
a(...t);
|
|
2605
2653
|
}
|
|
2606
2654
|
}
|
|
2607
|
-
function
|
|
2655
|
+
function Wi(s, e, t) {
|
|
2608
2656
|
if (!Number.isFinite(s) || !Number.isFinite(e))
|
|
2609
2657
|
return { u: NaN, v: NaN };
|
|
2610
2658
|
const i = t.direction_convention !== t.output_direction ? 180 : 0, a = (s + i) * Math.PI / 180;
|
|
@@ -2613,15 +2661,15 @@ function Oi(s, e, t) {
|
|
|
2613
2661
|
v: e * Math.cos(a)
|
|
2614
2662
|
};
|
|
2615
2663
|
}
|
|
2616
|
-
function
|
|
2664
|
+
function Da(s) {
|
|
2617
2665
|
return [s.direction_variable, s.magnitude_variable];
|
|
2618
2666
|
}
|
|
2619
|
-
const
|
|
2620
|
-
class
|
|
2667
|
+
const Xi = 0.7;
|
|
2668
|
+
class P {
|
|
2621
2669
|
constructor(e) {
|
|
2622
|
-
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.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")
|
|
2670
|
+
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")
|
|
2623
2671
|
throw new Error("Vector GeoVideo requires a vector-luma manifest");
|
|
2624
|
-
this.playback = e.geoVideo ? new
|
|
2672
|
+
this.playback = e.geoVideo ? new yt(
|
|
2625
2673
|
{ ...e.geoVideo, time: e.time },
|
|
2626
2674
|
() => this.map?.triggerRepaint(),
|
|
2627
2675
|
(t, ...i) => {
|
|
@@ -2639,16 +2687,16 @@ class D {
|
|
|
2639
2687
|
}
|
|
2640
2688
|
t === "timeChange" && (this.time = i[0]), this.emit(t, ...i);
|
|
2641
2689
|
}
|
|
2642
|
-
) : 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
|
|
2690
|
+
) : 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 Pt(), this.simulation = new Rt({
|
|
2643
2691
|
particleDensity: e.particleDensity ?? 0.05,
|
|
2644
2692
|
speed: e.speed ?? 1,
|
|
2645
|
-
fadeOpacity:
|
|
2693
|
+
fadeOpacity: Xe(e.fade ?? Xi),
|
|
2646
2694
|
colorRamp: e.colorRamp,
|
|
2647
2695
|
opacity: e.opacity ?? 1,
|
|
2648
2696
|
logScale: e.logScale ?? !1,
|
|
2649
2697
|
vibrance: e.vibrance ?? 0,
|
|
2650
|
-
colorGrade:
|
|
2651
|
-
backdrop:
|
|
2698
|
+
colorGrade: bt(e.colorGrade),
|
|
2699
|
+
backdrop: St(e.backdrop),
|
|
2652
2700
|
glow: e.glow ?? 0,
|
|
2653
2701
|
particleState: e.particleState ?? "auto",
|
|
2654
2702
|
rgba8MaxParticleZoom: e.rgba8MaxParticleZoom ?? 4
|
|
@@ -2696,9 +2744,9 @@ class D {
|
|
|
2696
2744
|
};
|
|
2697
2745
|
}
|
|
2698
2746
|
isViewportCovered() {
|
|
2699
|
-
return !this.map || !this.velocityField.hasData() ? !1 :
|
|
2747
|
+
return !this.map || !this.velocityField.hasData() ? !1 : wi(
|
|
2700
2748
|
this.velocityField.geoBounds,
|
|
2701
|
-
|
|
2749
|
+
bi(this.map.getBounds())
|
|
2702
2750
|
);
|
|
2703
2751
|
}
|
|
2704
2752
|
reloadIfViewportUncovered() {
|
|
@@ -2715,37 +2763,37 @@ class D {
|
|
|
2715
2763
|
* The map's current viewport is used to determine the lat bounds of the request.
|
|
2716
2764
|
*/
|
|
2717
2765
|
async fetchVelocityData(e, t) {
|
|
2718
|
-
const i = this.map.getBounds(), a = this.map
|
|
2766
|
+
const i = this.map.getBounds(), a = this.globeRendering ?? ye(this.map), r = Si(i, 1, a), n = this.zarrSource.findTimeIndex(e), o = this.zarrSource.findDepthIndex(this.depth);
|
|
2719
2767
|
console.log(
|
|
2720
2768
|
`[zartigl] Loading velocity: depth=${this.depth} → depthIdx=${o}, actual depth value=${this.zarrSource.getCoords().vertical[o]}, timeIdx=${n}`
|
|
2721
2769
|
);
|
|
2722
|
-
const
|
|
2723
|
-
|
|
2770
|
+
const l = this.vectorDerivation?.direction_variable ?? this.variableU, d = this.zarrSource.getChunksForBounds(
|
|
2771
|
+
l,
|
|
2724
2772
|
n,
|
|
2725
2773
|
o,
|
|
2726
2774
|
r
|
|
2727
|
-
),
|
|
2775
|
+
), c = this.zarrSource.getDimensions(l), u = c.indexOf("latitude"), f = c.indexOf("longitude");
|
|
2728
2776
|
let m = 0;
|
|
2729
|
-
const p =
|
|
2777
|
+
const p = d.length * 2, h = [], g = [];
|
|
2730
2778
|
t?.(m, p);
|
|
2731
|
-
const x = (w) =>
|
|
2779
|
+
const x = (w) => d.map(async (V) => {
|
|
2732
2780
|
const X = await this.zarrSource.fetchSpatialChunkResult(w, {
|
|
2733
|
-
timeIndex:
|
|
2734
|
-
verticalIndex:
|
|
2735
|
-
latitudeChunkIndex:
|
|
2736
|
-
longitudeChunkIndex:
|
|
2781
|
+
timeIndex: V.timeIdx,
|
|
2782
|
+
verticalIndex: V.depthIdx,
|
|
2783
|
+
latitudeChunkIndex: V.latIdx,
|
|
2784
|
+
longitudeChunkIndex: V.lonIdx
|
|
2737
2785
|
});
|
|
2738
2786
|
X.missing && (X.status != null && h.push(X.status), g.push(X.url)), m++, t?.(m, p);
|
|
2739
2787
|
const oe = this.zarrSource.getChunkShape(w), le = oe[f];
|
|
2740
2788
|
return {
|
|
2741
2789
|
data: X.data,
|
|
2742
|
-
latStart:
|
|
2743
|
-
lonStart:
|
|
2744
|
-
latSize:
|
|
2745
|
-
lonSize:
|
|
2790
|
+
latStart: V.latIdx * oe[u],
|
|
2791
|
+
lonStart: V.lonIdx * le,
|
|
2792
|
+
latSize: V.latSize,
|
|
2793
|
+
lonSize: V.lonSize,
|
|
2746
2794
|
lonChunkSize: le
|
|
2747
2795
|
};
|
|
2748
|
-
}), [T, M] = this.vectorDerivation ?
|
|
2796
|
+
}), [T, M] = this.vectorDerivation ? Hi(
|
|
2749
2797
|
await Promise.all(
|
|
2750
2798
|
x(this.vectorDerivation.direction_variable)
|
|
2751
2799
|
),
|
|
@@ -2756,7 +2804,7 @@ class D {
|
|
|
2756
2804
|
) : await Promise.all([
|
|
2757
2805
|
Promise.all(x(this.variableU)),
|
|
2758
2806
|
Promise.all(x(this.variableV))
|
|
2759
|
-
]), 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)),
|
|
2807
|
+
]), 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) => ({
|
|
2760
2808
|
...w,
|
|
2761
2809
|
latStart: w.latStart - y,
|
|
2762
2810
|
lonStart: w.lonStart - _
|
|
@@ -2764,21 +2812,21 @@ class D {
|
|
|
2764
2812
|
...w,
|
|
2765
2813
|
latStart: w.latStart - y,
|
|
2766
2814
|
lonStart: w.lonStart - _
|
|
2767
|
-
})),
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2815
|
+
})), L = this.zarrSource.getCoords(), D = Math.min(v - 1, L.latitude.length - 1), b = Math.min(S - 1, L.longitude.length - 1), A = wt(
|
|
2816
|
+
L.longitude,
|
|
2817
|
+
L.latitude,
|
|
2818
|
+
[_, b],
|
|
2819
|
+
[y, D]
|
|
2820
|
+
), N = L.latitude[y] > L.latitude[D], C = Et(
|
|
2773
2821
|
k,
|
|
2774
2822
|
F,
|
|
2775
|
-
R,
|
|
2776
2823
|
E,
|
|
2824
|
+
R,
|
|
2777
2825
|
A,
|
|
2778
2826
|
N
|
|
2779
2827
|
), I = this.zarrSource.getValueDomain?.();
|
|
2780
|
-
if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I), !
|
|
2781
|
-
throw new
|
|
2828
|
+
if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I), !qi(C.u, C.v))
|
|
2829
|
+
throw new xe(
|
|
2782
2830
|
this.timeToMs(e),
|
|
2783
2831
|
h,
|
|
2784
2832
|
g
|
|
@@ -2804,12 +2852,12 @@ class D {
|
|
|
2804
2852
|
else {
|
|
2805
2853
|
const o = await this.fetchVelocityData(
|
|
2806
2854
|
a,
|
|
2807
|
-
(
|
|
2855
|
+
(l, d) => {
|
|
2808
2856
|
t === this.generation && i === this.requestId && this.emit("status", {
|
|
2809
2857
|
phase: "fetching",
|
|
2810
2858
|
time: r,
|
|
2811
|
-
completed:
|
|
2812
|
-
total:
|
|
2859
|
+
completed: l,
|
|
2860
|
+
total: d
|
|
2813
2861
|
});
|
|
2814
2862
|
}
|
|
2815
2863
|
);
|
|
@@ -2825,7 +2873,7 @@ class D {
|
|
|
2825
2873
|
const o = n instanceof Error ? n : new Error(String(n));
|
|
2826
2874
|
console.error("[zartigl] Failed to load velocity:", o), t === this.generation && i === this.requestId && (this.emit(
|
|
2827
2875
|
"status",
|
|
2828
|
-
o instanceof
|
|
2876
|
+
o instanceof xe ? Lt(o) : { phase: "error", time: r, error: o }
|
|
2829
2877
|
), this.emit("error", o));
|
|
2830
2878
|
}
|
|
2831
2879
|
} finally {
|
|
@@ -2843,52 +2891,61 @@ class D {
|
|
|
2843
2891
|
if (this.playback ? !r || !n : !this.initialized || !this.velocityField.hasData())
|
|
2844
2892
|
return;
|
|
2845
2893
|
n?.setFilter(this.simulation.renderMode !== "raster");
|
|
2846
|
-
const o = n?.manifest.encoding.kind === "vector-luma" ? n.manifest.encoding.valueDomain : 0,
|
|
2894
|
+
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 ? {
|
|
2847
2895
|
west: n.bounds[0],
|
|
2848
2896
|
south: n.bounds[1],
|
|
2849
2897
|
east: n.bounds[2],
|
|
2850
2898
|
north: n.bounds[3]
|
|
2851
|
-
} : this.velocityField.geoBounds,
|
|
2899
|
+
} : this.velocityField.geoBounds, u = r ? {
|
|
2852
2900
|
a: {
|
|
2853
2901
|
unit: 1,
|
|
2854
|
-
min:
|
|
2855
|
-
max:
|
|
2902
|
+
min: l,
|
|
2903
|
+
max: d,
|
|
2856
2904
|
physical: !0,
|
|
2857
2905
|
northToSouth: !0
|
|
2858
2906
|
},
|
|
2859
2907
|
b: {
|
|
2860
2908
|
unit: 4,
|
|
2861
|
-
min:
|
|
2862
|
-
max:
|
|
2909
|
+
min: l,
|
|
2910
|
+
max: d,
|
|
2863
2911
|
physical: !0,
|
|
2864
2912
|
northToSouth: !0
|
|
2865
2913
|
},
|
|
2866
2914
|
mix: r[2]
|
|
2867
|
-
} : void 0, f =
|
|
2915
|
+
} : void 0, f = Ge(i), m = r ? [1, 4].map((p) => (i.activeTexture(i.TEXTURE0 + p), i.getParameter(i.TEXTURE_BINDING_2D))) : [];
|
|
2868
2916
|
try {
|
|
2869
2917
|
const p = i.canvas;
|
|
2870
2918
|
this.simulation.resize(p.width, p.height), i.bindFramebuffer(i.FRAMEBUFFER, f.framebuffer), r ? (i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r[0]), i.activeTexture(i.TEXTURE4), i.bindTexture(i.TEXTURE_2D, r[1])) : this.velocityField.bind(this.velocityTexUnit);
|
|
2871
|
-
const h = this.map
|
|
2919
|
+
const h = ye(this.map, t.defaultProjectionData);
|
|
2920
|
+
if (this.globeRendering !== null && this.globeRendering !== h) {
|
|
2921
|
+
if (this.globeRendering = h, !this.playback) {
|
|
2922
|
+
this.loadViewportVelocity({ resetParticles: !0 });
|
|
2923
|
+
return;
|
|
2924
|
+
}
|
|
2925
|
+
this.simulation.resetParticles();
|
|
2926
|
+
}
|
|
2927
|
+
this.globeRendering = h;
|
|
2928
|
+
const g = this.map.getBounds(), x = Ti(g, h), T = Be(g, h);
|
|
2872
2929
|
i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST);
|
|
2873
2930
|
const M = 512 * Math.pow(2, this.map.getZoom()), y = this.map.getCenter();
|
|
2874
2931
|
this.simulation.render(
|
|
2875
2932
|
this.velocityTexUnit,
|
|
2876
|
-
|
|
2877
|
-
|
|
2933
|
+
l,
|
|
2934
|
+
d,
|
|
2878
2935
|
a,
|
|
2879
2936
|
x,
|
|
2880
2937
|
M,
|
|
2881
2938
|
T,
|
|
2882
|
-
|
|
2939
|
+
c,
|
|
2883
2940
|
h,
|
|
2884
|
-
|
|
2941
|
+
xi(y.lng, y.lat),
|
|
2885
2942
|
t.defaultProjectionData.clippingPlane,
|
|
2886
|
-
...
|
|
2943
|
+
...u ? [u] : []
|
|
2887
2944
|
);
|
|
2888
2945
|
} finally {
|
|
2889
2946
|
m.forEach((p, h) => {
|
|
2890
2947
|
i.activeTexture(i.TEXTURE0 + (h === 0 ? 1 : 4)), i.bindTexture(i.TEXTURE_2D, p);
|
|
2891
|
-
}),
|
|
2948
|
+
}), Oe(i, f);
|
|
2892
2949
|
}
|
|
2893
2950
|
if (this.pendingReadyTime != null) {
|
|
2894
2951
|
const p = this.pendingReadyTime;
|
|
@@ -3010,7 +3067,7 @@ class D {
|
|
|
3010
3067
|
this.simulation.setSpeed(e);
|
|
3011
3068
|
}
|
|
3012
3069
|
setFade(e) {
|
|
3013
|
-
this.simulation.setFadeOpacity(
|
|
3070
|
+
this.simulation.setFadeOpacity(Xe(e));
|
|
3014
3071
|
}
|
|
3015
3072
|
setParticleDensity(e) {
|
|
3016
3073
|
this.simulation.setParticleDensity(e);
|
|
@@ -3069,23 +3126,23 @@ class D {
|
|
|
3069
3126
|
a(...t);
|
|
3070
3127
|
}
|
|
3071
3128
|
}
|
|
3072
|
-
function
|
|
3129
|
+
function Hi(s, e, t) {
|
|
3073
3130
|
const i = [], a = [];
|
|
3074
3131
|
for (let r = 0; r < s.length; r++) {
|
|
3075
|
-
const n = s[r], o = e[r],
|
|
3076
|
-
for (let
|
|
3077
|
-
const
|
|
3078
|
-
n.data[
|
|
3079
|
-
o.data[
|
|
3132
|
+
const n = s[r], o = e[r], l = new Float32Array(n.data.length), d = new Float32Array(n.data.length);
|
|
3133
|
+
for (let c = 0; c < n.data.length; c++) {
|
|
3134
|
+
const u = Wi(
|
|
3135
|
+
n.data[c],
|
|
3136
|
+
o.data[c],
|
|
3080
3137
|
t
|
|
3081
3138
|
);
|
|
3082
|
-
c
|
|
3139
|
+
l[c] = u.u, d[c] = u.v;
|
|
3083
3140
|
}
|
|
3084
|
-
i.push({ ...n, data:
|
|
3141
|
+
i.push({ ...n, data: l }), a.push({ ...n, data: d });
|
|
3085
3142
|
}
|
|
3086
3143
|
return [i, a];
|
|
3087
3144
|
}
|
|
3088
|
-
var
|
|
3145
|
+
var Ke = `precision mediump float;
|
|
3089
3146
|
|
|
3090
3147
|
uniform sampler2D u_color;
|
|
3091
3148
|
uniform sampler2D u_color_next;
|
|
@@ -3098,7 +3155,6 @@ uniform float u_log_scale;
|
|
|
3098
3155
|
uniform float u_vibrance;
|
|
3099
3156
|
uniform float u_mask_threshold;
|
|
3100
3157
|
uniform vec2 u_color_domain;
|
|
3101
|
-
uniform vec2 u_texel_size;
|
|
3102
3158
|
|
|
3103
3159
|
varying vec2 v_geo_uv;
|
|
3104
3160
|
|
|
@@ -3124,9 +3180,8 @@ float geoVideoScalarValue(float r) {
|
|
|
3124
3180
|
}
|
|
3125
3181
|
|
|
3126
3182
|
void main() {
|
|
3127
|
-
|
|
3128
|
-
vec2
|
|
3129
|
-
vec2 uv = mix(halfTexel, vec2(1.0) - halfTexel, sourceUv);
|
|
3183
|
+
|
|
3184
|
+
vec2 uv = vec2(v_geo_uv.x, 1.0 - v_geo_uv.y);
|
|
3130
3185
|
vec3 media = texture2D(u_color, uv).rgb;
|
|
3131
3186
|
float alpha = texture2D(u_mask, uv).r;
|
|
3132
3187
|
if (alpha <= u_mask_threshold) discard;
|
|
@@ -3147,7 +3202,7 @@ void main() {
|
|
|
3147
3202
|
const Z = 128, te = 64;
|
|
3148
3203
|
class G {
|
|
3149
3204
|
constructor(e) {
|
|
3150
|
-
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
|
|
3205
|
+
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 yt(
|
|
3151
3206
|
e,
|
|
3152
3207
|
() => this.map?.triggerRepaint(),
|
|
3153
3208
|
(t, ...i) => this.emit(t, ...i)
|
|
@@ -3157,7 +3212,7 @@ class G {
|
|
|
3157
3212
|
const i = K(t);
|
|
3158
3213
|
this.map = e, this.gl = i, this.abortController = new AbortController(), this.emit("loading"), this.emit("status", { phase: "metadata" });
|
|
3159
3214
|
try {
|
|
3160
|
-
if (this.manifest = await
|
|
3215
|
+
if (this.manifest = await Ce(
|
|
3161
3216
|
this.source,
|
|
3162
3217
|
this.abortController.signal
|
|
3163
3218
|
), this.abortController?.signal.aborted || !this.map)
|
|
@@ -3189,75 +3244,84 @@ class G {
|
|
|
3189
3244
|
const n = r.manifest;
|
|
3190
3245
|
if (!a || !r.maskTexture)
|
|
3191
3246
|
return;
|
|
3192
|
-
const o =
|
|
3247
|
+
const o = Ge(i), l = [0, 1, 2, 3].map((d) => (i.activeTexture(i.TEXTURE0 + d), i.getParameter(i.TEXTURE_BINDING_2D)));
|
|
3193
3248
|
try {
|
|
3194
|
-
const
|
|
3195
|
-
if (!
|
|
3249
|
+
const d = !!this.map && ye(this.map, t.defaultProjectionData), c = d ? this.globeProgram : this.mercatorProgram;
|
|
3250
|
+
if (!c || !this.map)
|
|
3196
3251
|
return;
|
|
3197
|
-
i.useProgram(
|
|
3198
|
-
i.getUniformLocation(
|
|
3252
|
+
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(
|
|
3253
|
+
i.getUniformLocation(c, "u_log_scale"),
|
|
3199
3254
|
this.logScale ? 1 : 0
|
|
3200
|
-
), i.uniform1f(i.getUniformLocation(
|
|
3201
|
-
i.getUniformLocation(
|
|
3255
|
+
), i.uniform1f(i.getUniformLocation(c, "u_vibrance"), this.vibrance), i.uniform1f(
|
|
3256
|
+
i.getUniformLocation(c, "u_mask_threshold"),
|
|
3202
3257
|
n.mask.threshold
|
|
3203
3258
|
);
|
|
3204
|
-
const { codeRange:
|
|
3259
|
+
const { codeRange: u, valueRange: f, transfer: m } = Jt(
|
|
3205
3260
|
n.encoding
|
|
3206
3261
|
);
|
|
3207
3262
|
i.uniform1f(
|
|
3208
|
-
i.getUniformLocation(
|
|
3263
|
+
i.getUniformLocation(c, "u_scalar_transfer"),
|
|
3209
3264
|
m
|
|
3210
3265
|
);
|
|
3211
3266
|
const p = this.colorDomain ?? f;
|
|
3212
3267
|
i.uniform2f(
|
|
3213
|
-
i.getUniformLocation(
|
|
3214
|
-
...
|
|
3268
|
+
i.getUniformLocation(c, "u_code_range"),
|
|
3269
|
+
...u
|
|
3215
3270
|
), i.uniform2f(
|
|
3216
|
-
i.getUniformLocation(
|
|
3271
|
+
i.getUniformLocation(c, "u_value_range"),
|
|
3217
3272
|
...f
|
|
3218
3273
|
), i.uniform2f(
|
|
3219
|
-
i.getUniformLocation(
|
|
3274
|
+
i.getUniformLocation(c, "u_color_domain"),
|
|
3220
3275
|
p[0],
|
|
3221
3276
|
p[1]
|
|
3222
|
-
), i.uniform2f(
|
|
3223
|
-
i.getUniformLocation(l, "u_texel_size"),
|
|
3224
|
-
1 / n.media.width,
|
|
3225
|
-
1 / n.media.height
|
|
3226
3277
|
), i.uniformMatrix4fv(
|
|
3227
|
-
i.getUniformLocation(
|
|
3278
|
+
i.getUniformLocation(c, "u_matrix"),
|
|
3228
3279
|
!1,
|
|
3229
3280
|
t.modelViewProjectionMatrix instanceof Float32Array ? t.modelViewProjectionMatrix : new Float32Array(Array.from(t.modelViewProjectionMatrix))
|
|
3230
3281
|
);
|
|
3231
3282
|
const [h, g, x, T] = n.bounds, M = x < h ? x + 360 : x;
|
|
3232
3283
|
if (i.uniform4f(
|
|
3233
|
-
i.getUniformLocation(
|
|
3284
|
+
i.getUniformLocation(c, "u_geo_bounds"),
|
|
3234
3285
|
h,
|
|
3235
3286
|
g,
|
|
3236
3287
|
M,
|
|
3237
3288
|
T
|
|
3238
|
-
), this.bindGrid(i,
|
|
3289
|
+
), this.bindGrid(i, c), d) {
|
|
3239
3290
|
const y = t.defaultProjectionData.clippingPlane;
|
|
3240
3291
|
i.uniform4f(
|
|
3241
|
-
i.getUniformLocation(
|
|
3292
|
+
i.getUniformLocation(c, "u_clipping_plane"),
|
|
3242
3293
|
...y
|
|
3294
|
+
), vt(
|
|
3295
|
+
i,
|
|
3296
|
+
{
|
|
3297
|
+
u_projection_transition: i.getUniformLocation(
|
|
3298
|
+
c,
|
|
3299
|
+
"u_projection_transition"
|
|
3300
|
+
),
|
|
3301
|
+
u_fallback_matrix: i.getUniformLocation(
|
|
3302
|
+
c,
|
|
3303
|
+
"u_fallback_matrix"
|
|
3304
|
+
)
|
|
3305
|
+
},
|
|
3306
|
+
t.defaultProjectionData
|
|
3243
3307
|
), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
|
|
3244
3308
|
} else {
|
|
3245
3309
|
const y = 512 * Math.pow(2, this.map.getZoom());
|
|
3246
|
-
i.uniform1f(i.getUniformLocation(
|
|
3247
|
-
for (const v of
|
|
3310
|
+
i.uniform1f(i.getUniformLocation(c, "u_world_size"), y);
|
|
3311
|
+
for (const v of Be(
|
|
3248
3312
|
this.map.getBounds(),
|
|
3249
3313
|
!1
|
|
3250
3314
|
))
|
|
3251
3315
|
i.uniform1f(
|
|
3252
|
-
i.getUniformLocation(
|
|
3316
|
+
i.getUniformLocation(c, "u_world_offset"),
|
|
3253
3317
|
v
|
|
3254
3318
|
), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
|
|
3255
3319
|
}
|
|
3256
|
-
this.unbindGrid(i,
|
|
3320
|
+
this.unbindGrid(i, c);
|
|
3257
3321
|
} finally {
|
|
3258
|
-
|
|
3259
|
-
i.activeTexture(i.TEXTURE0 +
|
|
3260
|
-
}),
|
|
3322
|
+
l.forEach((d, c) => {
|
|
3323
|
+
i.activeTexture(i.TEXTURE0 + c), i.bindTexture(i.TEXTURE_2D, d);
|
|
3324
|
+
}), Oe(i, o);
|
|
3261
3325
|
}
|
|
3262
3326
|
}
|
|
3263
3327
|
onRemove() {
|
|
@@ -3296,7 +3360,7 @@ class G {
|
|
|
3296
3360
|
setColorRamp(e) {
|
|
3297
3361
|
this.colorRamp = e, this.gl && (this.colorRampTexture && this.gl.deleteTexture(this.colorRampTexture), this.colorRampTexture = ge(
|
|
3298
3362
|
this.gl,
|
|
3299
|
-
|
|
3363
|
+
ke(e)
|
|
3300
3364
|
)), this.map?.triggerRepaint();
|
|
3301
3365
|
}
|
|
3302
3366
|
setLogScale(e) {
|
|
@@ -3336,7 +3400,7 @@ class G {
|
|
|
3336
3400
|
id: this.id,
|
|
3337
3401
|
initialized: !!e?.currentPair,
|
|
3338
3402
|
playing: this.playback.isPlaying(),
|
|
3339
|
-
currentTime: e ? e.manifest.timeline.kind === "snapshot-loop" ? (this.playback.time - e.times[0]) / 1e3 :
|
|
3403
|
+
currentTime: e ? e.manifest.timeline.kind === "snapshot-loop" ? (this.playback.time - e.times[0]) / 1e3 : ei(e.manifest, this.playback.time) : 0,
|
|
3340
3404
|
manifestId: this.manifest?.id,
|
|
3341
3405
|
mediaUrl: this.manifest?.media.url,
|
|
3342
3406
|
preloadedMediaUrl: this.playback.preloadedMediaUrl,
|
|
@@ -3360,24 +3424,24 @@ class G {
|
|
|
3360
3424
|
return this.listeners.get(e)?.delete(t), this;
|
|
3361
3425
|
}
|
|
3362
3426
|
initGl(e) {
|
|
3363
|
-
this.mercatorProgram = W(e,
|
|
3427
|
+
this.mercatorProgram = W(e, Tt, Ke), this.globeProgram = W(e, Mt, Ke), this.colorRampTexture = ge(
|
|
3364
3428
|
e,
|
|
3365
|
-
|
|
3429
|
+
ke(this.colorRamp)
|
|
3366
3430
|
);
|
|
3367
3431
|
const t = new Float32Array(
|
|
3368
3432
|
(Z + 1) * (te + 1) * 2
|
|
3369
3433
|
);
|
|
3370
3434
|
let i = 0;
|
|
3371
3435
|
for (let o = 0; o <= te; o++)
|
|
3372
|
-
for (let
|
|
3373
|
-
t[i++] =
|
|
3436
|
+
for (let l = 0; l <= Z; l++)
|
|
3437
|
+
t[i++] = l / Z, t[i++] = o / te;
|
|
3374
3438
|
const a = new Uint16Array(Z * te * 6);
|
|
3375
3439
|
let r = 0;
|
|
3376
3440
|
const n = Z + 1;
|
|
3377
3441
|
for (let o = 0; o < te; o++)
|
|
3378
|
-
for (let
|
|
3379
|
-
const
|
|
3380
|
-
a[r++] =
|
|
3442
|
+
for (let l = 0; l < Z; l++) {
|
|
3443
|
+
const d = o * n + l, c = d + 1, u = d + n, f = u + 1;
|
|
3444
|
+
a[r++] = d, a[r++] = u, a[r++] = c, a[r++] = c, a[r++] = u, a[r++] = f;
|
|
3381
3445
|
}
|
|
3382
3446
|
if (this.vertexBuffer = e.createBuffer(), this.indexBuffer = e.createBuffer(), !this.vertexBuffer || !this.indexBuffer)
|
|
3383
3447
|
throw new Error("Failed to create GeoVideo grid");
|
|
@@ -3395,28 +3459,28 @@ class G {
|
|
|
3395
3459
|
i(...t);
|
|
3396
3460
|
}
|
|
3397
3461
|
}
|
|
3398
|
-
function
|
|
3462
|
+
function $e(s) {
|
|
3399
3463
|
return typeof s == "string" ? s : new Date(s).toISOString();
|
|
3400
3464
|
}
|
|
3401
3465
|
function j(s) {
|
|
3402
3466
|
return encodeURIComponent(String(s));
|
|
3403
3467
|
}
|
|
3404
|
-
function
|
|
3468
|
+
function Dt(s, e) {
|
|
3405
3469
|
return e === "depth" ? -Math.abs(s) : s;
|
|
3406
3470
|
}
|
|
3407
|
-
function
|
|
3471
|
+
function Yi(s) {
|
|
3408
3472
|
let e = s.template.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}");
|
|
3409
3473
|
return s.tileMatrixSet != null && (e = e.replace(
|
|
3410
3474
|
/\{TileMatrixSet\}/gi,
|
|
3411
3475
|
j(s.tileMatrixSet)
|
|
3412
|
-
)), s.style != null && (e = e.replace(/\{Style\}/gi, j(s.style))), s.time != null && (e = e.replace(/\{time\}/gi, j(
|
|
3476
|
+
)), 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(
|
|
3413
3477
|
/\{elevation\}/gi,
|
|
3414
|
-
j(
|
|
3478
|
+
j(Dt(s.depth, s.verticalLabel))
|
|
3415
3479
|
)), [...e.matchAll(/\{([^{}]+)\}/g)].some(
|
|
3416
3480
|
(t) => !/^(?:z|y|x)$/i.test(t[1])
|
|
3417
3481
|
) ? void 0 : e;
|
|
3418
3482
|
}
|
|
3419
|
-
function
|
|
3483
|
+
function Je(s) {
|
|
3420
3484
|
const e = [
|
|
3421
3485
|
["SERVICE", "WMTS"],
|
|
3422
3486
|
["VERSION", "1.0.0"],
|
|
@@ -3428,16 +3492,16 @@ function Ke(s) {
|
|
|
3428
3492
|
["TILEROW", "{y}"],
|
|
3429
3493
|
["TILECOL", "{x}"]
|
|
3430
3494
|
];
|
|
3431
|
-
s.style && e.push(["STYLE", s.style]), s.time != null && e.push(["time",
|
|
3495
|
+
s.style && e.push(["STYLE", s.style]), s.time != null && e.push(["time", $e(s.time)]), s.depth != null && e.push([
|
|
3432
3496
|
"elevation",
|
|
3433
|
-
String(
|
|
3497
|
+
String(Dt(s.depth, s.verticalLabel))
|
|
3434
3498
|
]);
|
|
3435
3499
|
const t = e.map(
|
|
3436
3500
|
([i, a]) => `${i}=${a.startsWith("{") ? a : j(a)}`
|
|
3437
3501
|
).join("&");
|
|
3438
3502
|
return `${s.baseUrl}?${t}`;
|
|
3439
3503
|
}
|
|
3440
|
-
function
|
|
3504
|
+
function Zi(s) {
|
|
3441
3505
|
const e = [
|
|
3442
3506
|
["SERVICE", "WMTS"],
|
|
3443
3507
|
["REQUEST", "GetLegend"],
|
|
@@ -3446,38 +3510,38 @@ function Wi(s) {
|
|
|
3446
3510
|
];
|
|
3447
3511
|
return s.style && e.push(["STYLE", s.style]), `${s.baseUrl}?${e.map(([t, i]) => `${t}=${j(i)}`).join("&")}`;
|
|
3448
3512
|
}
|
|
3449
|
-
function
|
|
3513
|
+
function ji(s) {
|
|
3450
3514
|
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";
|
|
3451
3515
|
}
|
|
3452
|
-
function
|
|
3516
|
+
function Qi(s) {
|
|
3453
3517
|
return s.variables.kind === "scalar" ? s.variables.value : "scalar";
|
|
3454
3518
|
}
|
|
3455
|
-
function
|
|
3519
|
+
function Ki(s) {
|
|
3456
3520
|
return s.variables.kind === "vector" ? s.variables.u ?? "uo" : "uo";
|
|
3457
3521
|
}
|
|
3458
|
-
function
|
|
3522
|
+
function Ji(s) {
|
|
3459
3523
|
return s.variables.kind === "vector" ? s.variables.v ?? "vo" : "vo";
|
|
3460
3524
|
}
|
|
3461
|
-
function
|
|
3525
|
+
function ea(s) {
|
|
3462
3526
|
return s.variables.kind === "vector" ? s.variables.derivation : void 0;
|
|
3463
3527
|
}
|
|
3464
|
-
class
|
|
3528
|
+
class ta {
|
|
3465
3529
|
constructor(e) {
|
|
3466
|
-
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 =
|
|
3530
|
+
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 = ji(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") {
|
|
3467
3531
|
const t = e.sourceConfig;
|
|
3468
|
-
this.delegate = new
|
|
3532
|
+
this.delegate = new P({
|
|
3469
3533
|
...e,
|
|
3470
3534
|
source: t.endpoints.field,
|
|
3471
3535
|
zarrSource: e.zarrSource,
|
|
3472
|
-
variableU:
|
|
3473
|
-
variableV:
|
|
3474
|
-
vectorDerivation:
|
|
3536
|
+
variableU: Ki(t),
|
|
3537
|
+
variableV: Ji(t),
|
|
3538
|
+
vectorDerivation: ea(t),
|
|
3475
3539
|
unit: e.unit ?? ""
|
|
3476
3540
|
});
|
|
3477
3541
|
} else if (this.backend === "vector-geovideo") {
|
|
3478
3542
|
if (!e.geoVideoManifest)
|
|
3479
3543
|
throw new Error("Vector GeoVideo requires a loaded manifest");
|
|
3480
|
-
this.delegate = new
|
|
3544
|
+
this.delegate = new P({
|
|
3481
3545
|
...e,
|
|
3482
3546
|
source: e.geoVideoManifest.media.url,
|
|
3483
3547
|
geoVideo: {
|
|
@@ -3498,7 +3562,7 @@ class Qi {
|
|
|
3498
3562
|
id: e.id,
|
|
3499
3563
|
source: t.endpoints.field,
|
|
3500
3564
|
zarrSource: e.zarrSource,
|
|
3501
|
-
variable:
|
|
3565
|
+
variable: Qi(t),
|
|
3502
3566
|
time: e.time,
|
|
3503
3567
|
depth: e.depth,
|
|
3504
3568
|
colorRamp: e.colorRamp,
|
|
@@ -3529,7 +3593,7 @@ class Qi {
|
|
|
3529
3593
|
vibrance: e.vibrance
|
|
3530
3594
|
});
|
|
3531
3595
|
}
|
|
3532
|
-
this.delegate instanceof
|
|
3596
|
+
this.delegate instanceof P && this.backend === "vector-geovideo" && this.delegate.on("timeChange", (t) => {
|
|
3533
3597
|
this.time = t;
|
|
3534
3598
|
});
|
|
3535
3599
|
}
|
|
@@ -3617,16 +3681,16 @@ class Qi {
|
|
|
3617
3681
|
}
|
|
3618
3682
|
}
|
|
3619
3683
|
setSpeed(e) {
|
|
3620
|
-
this.delegate instanceof
|
|
3684
|
+
this.delegate instanceof P && this.delegate.setSpeed(e);
|
|
3621
3685
|
}
|
|
3622
3686
|
setFade(e) {
|
|
3623
|
-
this.delegate instanceof
|
|
3687
|
+
this.delegate instanceof P && this.delegate.setFade(e);
|
|
3624
3688
|
}
|
|
3625
3689
|
setParticleDensity(e) {
|
|
3626
|
-
this.delegate instanceof
|
|
3690
|
+
this.delegate instanceof P && this.delegate.setParticleDensity(e);
|
|
3627
3691
|
}
|
|
3628
3692
|
setRenderMode(e) {
|
|
3629
|
-
this.delegate instanceof
|
|
3693
|
+
this.delegate instanceof P && this.delegate.setRenderMode(e);
|
|
3630
3694
|
}
|
|
3631
3695
|
setRgba8MaxParticleZoom(e) {
|
|
3632
3696
|
this.delegate?.setRgba8MaxParticleZoom(e);
|
|
@@ -3642,34 +3706,34 @@ class Qi {
|
|
|
3642
3706
|
this.map?.getLayer(this.rasterLayerId) && this.map.setPaintProperty(this.rasterLayerId, "raster-opacity", e);
|
|
3643
3707
|
}
|
|
3644
3708
|
setLogScale(e) {
|
|
3645
|
-
this.delegate instanceof me && this.delegate.setLogScale(e), this.delegate instanceof
|
|
3709
|
+
this.delegate instanceof me && this.delegate.setLogScale(e), this.delegate instanceof P && this.delegate.setLogScale(e), this.delegate instanceof G && this.delegate.setLogScale(e);
|
|
3646
3710
|
}
|
|
3647
3711
|
setVibrance(e) {
|
|
3648
3712
|
this.delegate?.setVibrance(e);
|
|
3649
3713
|
}
|
|
3650
3714
|
/** Particle trails only; rasters ignore it. */
|
|
3651
3715
|
setColorGrade(e) {
|
|
3652
|
-
this.delegate instanceof
|
|
3716
|
+
this.delegate instanceof P && this.delegate.setColorGrade(e);
|
|
3653
3717
|
}
|
|
3654
3718
|
/** Under particle trails only; rasters ignore it. */
|
|
3655
3719
|
setBackdrop(e) {
|
|
3656
|
-
this.delegate instanceof
|
|
3720
|
+
this.delegate instanceof P && this.delegate.setBackdrop(e);
|
|
3657
3721
|
}
|
|
3658
3722
|
/** Particle trails only; rasters ignore it. */
|
|
3659
3723
|
setGlow(e) {
|
|
3660
|
-
this.delegate instanceof
|
|
3724
|
+
this.delegate instanceof P && this.delegate.setGlow(e);
|
|
3661
3725
|
}
|
|
3662
3726
|
setColorDomain(e) {
|
|
3663
3727
|
this.delegate instanceof me && this.delegate.setColorDomain(e), this.delegate instanceof G && this.delegate.setColorDomain(e);
|
|
3664
3728
|
}
|
|
3665
3729
|
async play() {
|
|
3666
|
-
(this.delegate instanceof G || this.delegate instanceof
|
|
3730
|
+
(this.delegate instanceof G || this.delegate instanceof P) && await this.delegate.play();
|
|
3667
3731
|
}
|
|
3668
3732
|
pause() {
|
|
3669
|
-
(this.delegate instanceof G || this.delegate instanceof
|
|
3733
|
+
(this.delegate instanceof G || this.delegate instanceof P) && this.delegate.pause();
|
|
3670
3734
|
}
|
|
3671
3735
|
setLoop(e) {
|
|
3672
|
-
(this.delegate instanceof G || this.delegate instanceof
|
|
3736
|
+
(this.delegate instanceof G || this.delegate instanceof P) && this.delegate.setLoop(e);
|
|
3673
3737
|
}
|
|
3674
3738
|
/** Media rate multiplier of a scalar GeoVideo. */
|
|
3675
3739
|
setPlaybackRate(e) {
|
|
@@ -3677,21 +3741,21 @@ class Qi {
|
|
|
3677
3741
|
}
|
|
3678
3742
|
/** Cadence of the continuous vector GeoVideo clock. */
|
|
3679
3743
|
setStepsPerSecond(e) {
|
|
3680
|
-
this.delegate instanceof
|
|
3744
|
+
this.delegate instanceof P && this.delegate.setStepsPerSecond(e);
|
|
3681
3745
|
}
|
|
3682
3746
|
setTimeRange(e) {
|
|
3683
|
-
(this.delegate instanceof G || this.delegate instanceof
|
|
3747
|
+
(this.delegate instanceof G || this.delegate instanceof P) && this.delegate.setTimeRange(e);
|
|
3684
3748
|
}
|
|
3685
3749
|
/**
|
|
3686
3750
|
* Move a GeoVideo to another artifact, such as the next archive
|
|
3687
3751
|
* chunk, without rebuilding the map layer. False when a new layer is needed.
|
|
3688
3752
|
*/
|
|
3689
3753
|
replaceGeoVideoManifest(e, t) {
|
|
3690
|
-
return this.suspended || !(this.delegate instanceof G || this.delegate instanceof
|
|
3754
|
+
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);
|
|
3691
3755
|
}
|
|
3692
3756
|
/** Load the GeoVideo artifact expected next, such as the next archive chunk. */
|
|
3693
3757
|
preloadGeoVideoManifest(e, t) {
|
|
3694
|
-
return !this.suspended && (this.delegate instanceof G || this.delegate instanceof
|
|
3758
|
+
return !this.suspended && (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.preloadManifest(e, t);
|
|
3695
3759
|
}
|
|
3696
3760
|
async samplePoint(e) {
|
|
3697
3761
|
if (this.delegate instanceof me)
|
|
@@ -3708,14 +3772,14 @@ class Qi {
|
|
|
3708
3772
|
return;
|
|
3709
3773
|
this.removeWmts();
|
|
3710
3774
|
const e = this.options.sourceConfig, t = e.tileUrlTemplate ? [
|
|
3711
|
-
|
|
3775
|
+
Yi({
|
|
3712
3776
|
template: e.tileUrlTemplate,
|
|
3713
3777
|
tileMatrixSet: e.tileMatrixSet,
|
|
3714
3778
|
style: e.style,
|
|
3715
3779
|
time: this.time,
|
|
3716
3780
|
depth: this.depth,
|
|
3717
3781
|
verticalLabel: this.options.verticalLabel
|
|
3718
|
-
}) ??
|
|
3782
|
+
}) ?? Je({
|
|
3719
3783
|
baseUrl: e.baseUrl ?? new URL(e.capabilitiesUrl).origin,
|
|
3720
3784
|
layer: e.layer,
|
|
3721
3785
|
tileMatrixSet: e.tileMatrixSet ?? "EPSG:3857",
|
|
@@ -3726,7 +3790,7 @@ class Qi {
|
|
|
3726
3790
|
verticalLabel: this.options.verticalLabel
|
|
3727
3791
|
})
|
|
3728
3792
|
] : [
|
|
3729
|
-
|
|
3793
|
+
Je({
|
|
3730
3794
|
baseUrl: e.baseUrl ?? new URL(e.capabilitiesUrl).origin,
|
|
3731
3795
|
layer: e.layer,
|
|
3732
3796
|
tileMatrixSet: e.tileMatrixSet ?? "EPSG:3857",
|
|
@@ -3760,7 +3824,7 @@ class Qi {
|
|
|
3760
3824
|
min: 0,
|
|
3761
3825
|
max: 0,
|
|
3762
3826
|
unit: this.options.unit ?? "",
|
|
3763
|
-
time:
|
|
3827
|
+
time: $e(this.time),
|
|
3764
3828
|
depth: this.depth
|
|
3765
3829
|
}), this.emit("status", { phase: "ready", time: e });
|
|
3766
3830
|
}
|
|
@@ -3779,19 +3843,19 @@ class Qi {
|
|
|
3779
3843
|
return i && this.map?.getLayer(i) ? i : void 0;
|
|
3780
3844
|
}
|
|
3781
3845
|
}
|
|
3782
|
-
function
|
|
3846
|
+
function Pe(s, e) {
|
|
3783
3847
|
return s.match(new RegExp(`\\b${e}=["']([^"']+)["']`, "i"))?.[1].replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'");
|
|
3784
3848
|
}
|
|
3785
|
-
function
|
|
3849
|
+
function ia(s, e, t) {
|
|
3786
3850
|
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);
|
|
3787
3851
|
return [...a.matchAll(/\{([^{}]+)\}/g)].some(
|
|
3788
3852
|
(n) => !/^(?:z|y|x|Time|Elevation)$/i.test(n[1])
|
|
3789
3853
|
) ? void 0 : a;
|
|
3790
3854
|
}
|
|
3791
|
-
function
|
|
3855
|
+
function At(s) {
|
|
3792
3856
|
return s.replace(/<[^>]+>/g, "").trim();
|
|
3793
3857
|
}
|
|
3794
|
-
function
|
|
3858
|
+
function be(s, e) {
|
|
3795
3859
|
const t = new RegExp(
|
|
3796
3860
|
`<(?:(?:\\w+):)?${e}\\b[^>]*>([\\s\\S]*?)<\\/(?:(?:\\w+):)?${e}>`,
|
|
3797
3861
|
"gi"
|
|
@@ -3799,30 +3863,30 @@ function xe(s, e) {
|
|
|
3799
3863
|
return [...s.matchAll(t)].map((i) => i[1]);
|
|
3800
3864
|
}
|
|
3801
3865
|
function se(s, e) {
|
|
3802
|
-
return
|
|
3866
|
+
return be(s, e).map(At).find(Boolean);
|
|
3803
3867
|
}
|
|
3804
|
-
function
|
|
3868
|
+
function et(s, e) {
|
|
3805
3869
|
const t = e.match(
|
|
3806
3870
|
/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/
|
|
3807
3871
|
);
|
|
3808
3872
|
if (!t || !t.slice(1).some((m) => Number(m) > 0))
|
|
3809
3873
|
return;
|
|
3810
|
-
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(),
|
|
3811
|
-
Date.UTC(a, r, 1, o,
|
|
3874
|
+
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(
|
|
3875
|
+
Date.UTC(a, r, 1, o, l, d, c)
|
|
3812
3876
|
), f = new Date(
|
|
3813
|
-
Date.UTC(
|
|
3877
|
+
Date.UTC(u.getUTCFullYear(), u.getUTCMonth() + 1, 0)
|
|
3814
3878
|
).getUTCDate();
|
|
3815
|
-
return
|
|
3879
|
+
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();
|
|
3816
3880
|
}
|
|
3817
|
-
function
|
|
3881
|
+
function aa(s) {
|
|
3818
3882
|
const e = [];
|
|
3819
3883
|
for (const t of s.flatMap((i) => i.split(","))) {
|
|
3820
3884
|
const i = t.trim().split("/");
|
|
3821
3885
|
if (i.length === 3) {
|
|
3822
|
-
const r = Date.parse(i[0]), n = Date.parse(i[1]), o =
|
|
3886
|
+
const r = Date.parse(i[0]), n = Date.parse(i[1]), o = et(r, i[2]);
|
|
3823
3887
|
if (Number.isFinite(r) && Number.isFinite(n) && o && o > r)
|
|
3824
|
-
for (let
|
|
3825
|
-
e.push(
|
|
3888
|
+
for (let l = r, d = 0; l <= n && d < 1e5; d += 1)
|
|
3889
|
+
e.push(l), l = et(l, i[2]);
|
|
3826
3890
|
continue;
|
|
3827
3891
|
}
|
|
3828
3892
|
const a = Date.parse(t.trim());
|
|
@@ -3830,14 +3894,14 @@ function Ji(s) {
|
|
|
3830
3894
|
}
|
|
3831
3895
|
return [...new Set(e)].sort((t, i) => t - i);
|
|
3832
3896
|
}
|
|
3833
|
-
function
|
|
3834
|
-
for (const t of
|
|
3897
|
+
function tt(s, e) {
|
|
3898
|
+
for (const t of be(s, "Dimension"))
|
|
3835
3899
|
if (se(t, "Identifier")?.toLowerCase() === e.toLowerCase())
|
|
3836
|
-
return
|
|
3900
|
+
return be(t, "Value").map(At);
|
|
3837
3901
|
return [];
|
|
3838
3902
|
}
|
|
3839
|
-
function
|
|
3840
|
-
const t =
|
|
3903
|
+
function sa(s, e) {
|
|
3904
|
+
const t = be(s, "Layer").find(
|
|
3841
3905
|
(h) => se(h, "Identifier") === e.layer
|
|
3842
3906
|
);
|
|
3843
3907
|
if (!t)
|
|
@@ -3845,7 +3909,7 @@ function ea(s, e) {
|
|
|
3845
3909
|
const i = e.tileMatrixSet ?? se(t, "TileMatrixSet") ?? "";
|
|
3846
3910
|
if (!/3857|GoogleMapsCompatible/i.test(i))
|
|
3847
3911
|
throw new Error(`Unsupported WMTS tile matrix set: ${i || "missing"}`);
|
|
3848
|
-
const a =
|
|
3912
|
+
const a = aa(tt(t, "time")), r = a.length ? {
|
|
3849
3913
|
min: a[0],
|
|
3850
3914
|
max: a[a.length - 1],
|
|
3851
3915
|
size: a.length,
|
|
@@ -3854,22 +3918,22 @@ function ea(s, e) {
|
|
|
3854
3918
|
step: a.length > 1 && a.every(
|
|
3855
3919
|
(h, g) => g === 0 || h - a[g - 1] === a[1] - a[0]
|
|
3856
3920
|
) ? a[1] - a[0] : void 0
|
|
3857
|
-
} : { min: 0, max: 0, size: 1, values: [0], units: "static" }, n =
|
|
3921
|
+
} : { min: 0, max: 0, size: 1, values: [0], units: "static" }, n = tt(t, "elevation").flatMap((h) => h.split(",")).map(Number).filter(Number.isFinite), o = n.length ? { name: "elevation", label: "elevation", values: n } : null, l = s.match(
|
|
3858
3922
|
/GetTile[\s\S]*?(?:xlink:href|href)=["']([^"']+)/i
|
|
3859
|
-
)?.[1],
|
|
3923
|
+
)?.[1], c = [
|
|
3860
3924
|
...t.matchAll(/<(?:(?:\w+):)?ResourceURL\b([^>]*)\/?\s*>/gi)
|
|
3861
3925
|
].find(
|
|
3862
|
-
(h) =>
|
|
3863
|
-
),
|
|
3926
|
+
(h) => Pe(h[1], "resourceType")?.toLowerCase() === "tile"
|
|
3927
|
+
), u = c ? Pe(c[1], "template") : void 0, f = [
|
|
3864
3928
|
...t.matchAll(
|
|
3865
3929
|
/<(?:(?:\w+):)?Style\b([^>]*)>([\s\S]*?)<\/(?:(?:\w+):)?Style>/gi
|
|
3866
3930
|
)
|
|
3867
3931
|
], m = f.find(
|
|
3868
|
-
(h) =>
|
|
3932
|
+
(h) => Pe(h[1], "isDefault")?.toLowerCase() === "true"
|
|
3869
3933
|
), p = e.style ?? se(m?.[2] ?? f[0]?.[2] ?? "", "Identifier");
|
|
3870
3934
|
return {
|
|
3871
|
-
baseUrl: e.baseUrl ??
|
|
3872
|
-
tileUrlTemplate: e.tileUrlTemplate ?? (
|
|
3935
|
+
baseUrl: e.baseUrl ?? l ?? new URL(e.capabilitiesUrl).origin,
|
|
3936
|
+
tileUrlTemplate: e.tileUrlTemplate ?? (u ? ia(u, i, p) : void 0),
|
|
3873
3937
|
tileMatrixSet: i,
|
|
3874
3938
|
format: e.format ?? se(t, "Format") ?? "image/png",
|
|
3875
3939
|
style: p,
|
|
@@ -3877,15 +3941,15 @@ function ea(s, e) {
|
|
|
3877
3941
|
vertical: o
|
|
3878
3942
|
};
|
|
3879
3943
|
}
|
|
3880
|
-
async function
|
|
3944
|
+
async function ra(s, e) {
|
|
3881
3945
|
const t = await fetch(s.capabilitiesUrl, { signal: e });
|
|
3882
3946
|
if (!t.ok)
|
|
3883
3947
|
throw new Error(
|
|
3884
3948
|
`WMTS capabilities request failed (${t.status}): ${s.capabilitiesUrl}`
|
|
3885
3949
|
);
|
|
3886
|
-
return
|
|
3950
|
+
return sa(await t.text(), s);
|
|
3887
3951
|
}
|
|
3888
|
-
const
|
|
3952
|
+
const na = [
|
|
3889
3953
|
0.25,
|
|
3890
3954
|
0.5,
|
|
3891
3955
|
1,
|
|
@@ -3894,8 +3958,8 @@ const ia = [
|
|
|
3894
3958
|
8,
|
|
3895
3959
|
16,
|
|
3896
3960
|
32
|
|
3897
|
-
],
|
|
3898
|
-
function
|
|
3961
|
+
], it = [0.25, 0.5, 1, 2];
|
|
3962
|
+
function at(s, e) {
|
|
3899
3963
|
if (s.length === 0)
|
|
3900
3964
|
return e;
|
|
3901
3965
|
let t = s[0], i;
|
|
@@ -3903,8 +3967,8 @@ function it(s, e) {
|
|
|
3903
3967
|
a < t && (t = a), a <= e && (i === void 0 || a > i) && (i = a);
|
|
3904
3968
|
return i ?? t;
|
|
3905
3969
|
}
|
|
3906
|
-
function
|
|
3907
|
-
const e = s.map((n) => new Date(n)), t = (n) => n.every((o) => e.every((
|
|
3970
|
+
function oa(s) {
|
|
3971
|
+
const e = s.map((n) => new Date(n)), t = (n) => n.every((o) => e.every((l) => o(l) === o(e[0]))), i = [
|
|
3908
3972
|
(n) => n.getUTCHours(),
|
|
3909
3973
|
(n) => n.getUTCMinutes(),
|
|
3910
3974
|
(n) => n.getUTCSeconds(),
|
|
@@ -3915,7 +3979,7 @@ function aa(s) {
|
|
|
3915
3979
|
return "year";
|
|
3916
3980
|
if (t([(o) => o.getUTCDate(), ...i]))
|
|
3917
3981
|
return "month";
|
|
3918
|
-
const n = s.slice(1).map((o,
|
|
3982
|
+
const n = s.slice(1).map((o, l) => o - s[l]);
|
|
3919
3983
|
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";
|
|
3920
3984
|
}
|
|
3921
3985
|
const a = e[0];
|
|
@@ -3924,7 +3988,7 @@ function aa(s) {
|
|
|
3924
3988
|
const r = a.getUTCHours() === 0 && a.getUTCMinutes() === 0 && a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0;
|
|
3925
3989
|
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";
|
|
3926
3990
|
}
|
|
3927
|
-
function
|
|
3991
|
+
function Ct(s) {
|
|
3928
3992
|
if (s.length < 2)
|
|
3929
3993
|
return;
|
|
3930
3994
|
const e = s[1] - s[0];
|
|
@@ -3933,7 +3997,7 @@ function Lt(s) {
|
|
|
3933
3997
|
) ? e : void 0;
|
|
3934
3998
|
}
|
|
3935
3999
|
function re(s, e) {
|
|
3936
|
-
return e ?
|
|
4000
|
+
return e ? xt(e, [
|
|
3937
4001
|
s.values[0],
|
|
3938
4002
|
s.values[s.values.length - 1]
|
|
3939
4003
|
]) : null;
|
|
@@ -3952,11 +4016,11 @@ function ne(s, e) {
|
|
|
3952
4016
|
min: r[0],
|
|
3953
4017
|
max: r[r.length - 1],
|
|
3954
4018
|
size: r.length,
|
|
3955
|
-
step:
|
|
4019
|
+
step: Ct(r),
|
|
3956
4020
|
values: r
|
|
3957
4021
|
};
|
|
3958
4022
|
}
|
|
3959
|
-
function
|
|
4023
|
+
function st(s, e) {
|
|
3960
4024
|
const { start: t, end: i } = s.temporal ?? {};
|
|
3961
4025
|
return t || i ? ne(e, { start: t, end: i }) : e;
|
|
3962
4026
|
}
|
|
@@ -3966,20 +4030,20 @@ function fe(s) {
|
|
|
3966
4030
|
s.variables.derivation.magnitude_variable
|
|
3967
4031
|
] : [s.variables.u ?? "uo", s.variables.v ?? "vo"];
|
|
3968
4032
|
}
|
|
3969
|
-
function
|
|
3970
|
-
const t = s.sources.filter(
|
|
4033
|
+
function Ee(s, e) {
|
|
4034
|
+
const t = s.sources.filter(Fe);
|
|
3971
4035
|
return t.find((i) => i.id === e) ?? (e === "geovideo" || e === "auto" ? t[0] : void 0);
|
|
3972
4036
|
}
|
|
3973
|
-
function
|
|
4037
|
+
function kt(s) {
|
|
3974
4038
|
return [...s].sort((e, t) => {
|
|
3975
4039
|
const i = Math.abs(e), a = Math.abs(t);
|
|
3976
4040
|
return i !== a ? i - a : t - e;
|
|
3977
4041
|
});
|
|
3978
4042
|
}
|
|
3979
|
-
function
|
|
3980
|
-
return s?.values.length ? e == null ?
|
|
4043
|
+
function Le(s, e) {
|
|
4044
|
+
return s?.values.length ? e == null ? kt(s.values)[0] : U(s.values, e) : e ?? 0;
|
|
3981
4045
|
}
|
|
3982
|
-
function
|
|
4046
|
+
function U(s, e) {
|
|
3983
4047
|
if (s.length === 0)
|
|
3984
4048
|
return e;
|
|
3985
4049
|
let t = s[0], i = Math.abs(t - e);
|
|
@@ -3989,7 +4053,7 @@ function V(s, e) {
|
|
|
3989
4053
|
}
|
|
3990
4054
|
return t;
|
|
3991
4055
|
}
|
|
3992
|
-
function
|
|
4056
|
+
function rt(s) {
|
|
3993
4057
|
for (const [e, t] of [
|
|
3994
4058
|
[s?.playbackRate, "Playback rate"],
|
|
3995
4059
|
[s?.stepsPerSecond, "Steps per second"]
|
|
@@ -3997,14 +4061,14 @@ function st(s) {
|
|
|
3997
4061
|
if (e != null && (!Number.isFinite(e) || e <= 0))
|
|
3998
4062
|
throw new Error(`${t} must be positive`);
|
|
3999
4063
|
}
|
|
4000
|
-
function
|
|
4001
|
-
const t = s.surface?.value ?? 0, i =
|
|
4064
|
+
function nt(s, e) {
|
|
4065
|
+
const t = s.surface?.value ?? 0, i = U(
|
|
4002
4066
|
[t, ...s.depths.map((a) => a.value)],
|
|
4003
4067
|
e
|
|
4004
4068
|
);
|
|
4005
4069
|
return i === t ? null : i;
|
|
4006
4070
|
}
|
|
4007
|
-
function
|
|
4071
|
+
function la(s) {
|
|
4008
4072
|
const e = s.surface ?? s.depths[0];
|
|
4009
4073
|
return {
|
|
4010
4074
|
name: e.name,
|
|
@@ -4016,24 +4080,24 @@ function sa(s) {
|
|
|
4016
4080
|
]
|
|
4017
4081
|
};
|
|
4018
4082
|
}
|
|
4019
|
-
function
|
|
4083
|
+
function ot(s, e) {
|
|
4020
4084
|
return JSON.stringify([
|
|
4021
4085
|
s?.values ?? null,
|
|
4022
4086
|
e ? [e.name, e.units, e.values] : null
|
|
4023
4087
|
]);
|
|
4024
4088
|
}
|
|
4025
|
-
function
|
|
4089
|
+
function ca(s) {
|
|
4026
4090
|
const e = [...new Set(s)].sort((t, i) => t - i);
|
|
4027
4091
|
return {
|
|
4028
4092
|
min: e[0],
|
|
4029
4093
|
max: e[e.length - 1],
|
|
4030
|
-
step:
|
|
4094
|
+
step: Ct(e),
|
|
4031
4095
|
size: e.length,
|
|
4032
4096
|
units: "milliseconds since 1970-01-01T00:00:00Z",
|
|
4033
4097
|
values: e
|
|
4034
4098
|
};
|
|
4035
4099
|
}
|
|
4036
|
-
const
|
|
4100
|
+
const ha = 5 * 6e4, ua = 6e4, lt = 6;
|
|
4037
4101
|
function pe(s) {
|
|
4038
4102
|
const { particles: e = {}, raster: t = {} } = s, i = {
|
|
4039
4103
|
palette: s.palette,
|
|
@@ -4043,7 +4107,7 @@ function pe(s) {
|
|
|
4043
4107
|
speed: e.speed,
|
|
4044
4108
|
fade: e.fade,
|
|
4045
4109
|
glow: e.glow,
|
|
4046
|
-
colorGrade: e.grade === void 0 ? void 0 :
|
|
4110
|
+
colorGrade: e.grade === void 0 ? void 0 : pi(e.grade),
|
|
4047
4111
|
opacity: t.opacity,
|
|
4048
4112
|
logScale: t.logScale,
|
|
4049
4113
|
vibrance: t.vibrance,
|
|
@@ -4061,25 +4125,25 @@ function Ue(s) {
|
|
|
4061
4125
|
const e = s.alphaFadeLow ?? 0, t = s.alphaFadeHigh ?? 0;
|
|
4062
4126
|
return e > 0 || t > 0 ? { low: e, high: t, curve: s.alphaFadeCurve ?? "linear" } : void 0;
|
|
4063
4127
|
}
|
|
4064
|
-
const
|
|
4065
|
-
|
|
4066
|
-
),
|
|
4067
|
-
function
|
|
4068
|
-
return typeof s != "string" ||
|
|
4069
|
-
`[zartigl] palette "${s}" is not in this version: drawn with "${
|
|
4070
|
-
)),
|
|
4128
|
+
const ct = "rdylbu", da = new Set(
|
|
4129
|
+
_t({ includeDeprecated: !0 }).map((s) => s.id)
|
|
4130
|
+
), ht = /* @__PURE__ */ new Set();
|
|
4131
|
+
function Ne(s) {
|
|
4132
|
+
return typeof s != "string" || da.has(s) ? s : (ht.has(s) || (ht.add(s), console.warn(
|
|
4133
|
+
`[zartigl] palette "${s}" is not in this version: drawn with "${ct}"`
|
|
4134
|
+
)), ct);
|
|
4071
4135
|
}
|
|
4072
|
-
function
|
|
4073
|
-
const { reversePalette: e } = s, t =
|
|
4074
|
-
return t != null && (e || i) ?
|
|
4136
|
+
function De(s) {
|
|
4137
|
+
const { reversePalette: e } = s, t = Ne(s.palette), i = Ue(s);
|
|
4138
|
+
return t != null && (e || i) ? ke(t, { reverse: e, alphaFade: i }) : t;
|
|
4075
4139
|
}
|
|
4076
|
-
const
|
|
4140
|
+
const ma = [
|
|
4077
4141
|
"palette",
|
|
4078
4142
|
"reversePalette",
|
|
4079
4143
|
"alphaFadeLow",
|
|
4080
4144
|
"alphaFadeHigh",
|
|
4081
4145
|
"alphaFadeCurve"
|
|
4082
|
-
],
|
|
4146
|
+
], Ft = Object.freeze({
|
|
4083
4147
|
palette: "style.palette",
|
|
4084
4148
|
renderMode: "style.renderMode",
|
|
4085
4149
|
particleDensity: "style.particles.density",
|
|
@@ -4092,7 +4156,7 @@ const ca = [
|
|
|
4092
4156
|
colorDomain: "style.raster.colorDomain",
|
|
4093
4157
|
backdrop: "style.particles.backdrop"
|
|
4094
4158
|
});
|
|
4095
|
-
function
|
|
4159
|
+
function Ae(s) {
|
|
4096
4160
|
const {
|
|
4097
4161
|
palette: e,
|
|
4098
4162
|
renderMode: t,
|
|
@@ -4101,13 +4165,13 @@ function De(s) {
|
|
|
4101
4165
|
fade: r,
|
|
4102
4166
|
colorGrade: n,
|
|
4103
4167
|
opacity: o,
|
|
4104
|
-
logScale:
|
|
4105
|
-
vibrance:
|
|
4106
|
-
colorDomain:
|
|
4107
|
-
backdrop:
|
|
4168
|
+
logScale: l,
|
|
4169
|
+
vibrance: d,
|
|
4170
|
+
colorDomain: c,
|
|
4171
|
+
backdrop: u,
|
|
4108
4172
|
...f
|
|
4109
4173
|
} = s ?? {}, m = Object.keys(s ?? {}).filter(
|
|
4110
|
-
(h) => h in
|
|
4174
|
+
(h) => h in Ft && s[h] !== void 0
|
|
4111
4175
|
);
|
|
4112
4176
|
return {
|
|
4113
4177
|
style: ae({
|
|
@@ -4117,47 +4181,47 @@ function De(s) {
|
|
|
4117
4181
|
density: i,
|
|
4118
4182
|
speed: a,
|
|
4119
4183
|
fade: r,
|
|
4120
|
-
grade: n &&
|
|
4121
|
-
backdrop:
|
|
4184
|
+
grade: n && fi(n),
|
|
4185
|
+
backdrop: u
|
|
4122
4186
|
},
|
|
4123
|
-
raster: { opacity: o, logScale:
|
|
4187
|
+
raster: { opacity: o, logScale: l, vibrance: d, colorDomain: c }
|
|
4124
4188
|
}),
|
|
4125
4189
|
settings: e === void 0 || typeof e == "string" ? f : { ...f, palette: e },
|
|
4126
4190
|
legacyKeys: m
|
|
4127
4191
|
};
|
|
4128
4192
|
}
|
|
4129
|
-
const
|
|
4130
|
-
function
|
|
4193
|
+
const ut = /* @__PURE__ */ new Set();
|
|
4194
|
+
function dt(s) {
|
|
4131
4195
|
for (const e of s)
|
|
4132
|
-
|
|
4133
|
-
`[zartigl] settings.${e} is deprecated: use ${
|
|
4196
|
+
ut.has(e) || (ut.add(e), console.warn(
|
|
4197
|
+
`[zartigl] settings.${e} is deprecated: use ${Ft[e]}`
|
|
4134
4198
|
));
|
|
4135
4199
|
}
|
|
4136
|
-
function
|
|
4137
|
-
const t =
|
|
4200
|
+
function It(s, e) {
|
|
4201
|
+
const t = ze(s, e);
|
|
4138
4202
|
return {
|
|
4139
4203
|
...pe(t),
|
|
4140
4204
|
palette: t.palette ?? "rdylbu",
|
|
4141
4205
|
colorDomain: Q(t.raster.colorDomain)
|
|
4142
4206
|
};
|
|
4143
4207
|
}
|
|
4144
|
-
function
|
|
4208
|
+
function fa(s) {
|
|
4145
4209
|
return {
|
|
4146
|
-
...
|
|
4210
|
+
...It(s),
|
|
4147
4211
|
particleState: "auto",
|
|
4148
4212
|
rgba8MaxParticleZoom: 4
|
|
4149
4213
|
};
|
|
4150
4214
|
}
|
|
4151
|
-
function
|
|
4215
|
+
function pa(s) {
|
|
4152
4216
|
const { palette: e, ...t } = s;
|
|
4153
4217
|
return t;
|
|
4154
4218
|
}
|
|
4155
|
-
function
|
|
4156
|
-
s !== void 0 &&
|
|
4219
|
+
function mt(s, e, t) {
|
|
4220
|
+
s !== void 0 && ft(s, "style", {
|
|
4157
4221
|
kind: e.layers.find((i) => i.id === t)?.kind
|
|
4158
4222
|
});
|
|
4159
4223
|
}
|
|
4160
|
-
class
|
|
4224
|
+
class Aa {
|
|
4161
4225
|
constructor(e) {
|
|
4162
4226
|
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 = () => {
|
|
4163
4227
|
this.attachQueued && this.attachWhenReady();
|
|
@@ -4165,9 +4229,9 @@ class Pa {
|
|
|
4165
4229
|
throw new Error("Zartigl requires a layer UUID");
|
|
4166
4230
|
if (e.time != null && z(e.time, "time"), e.depth != null && !Number.isFinite(e.depth))
|
|
4167
4231
|
throw new Error("Depth must be finite");
|
|
4168
|
-
|
|
4169
|
-
const t =
|
|
4170
|
-
|
|
4232
|
+
rt(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;
|
|
4233
|
+
const t = Ae(e.settings);
|
|
4234
|
+
dt(t.legacyKeys), this.style = ae(t.style, e.style), mt(this.style, e.catalog, e.layer), this.settings = { ...t.settings, ...pe(this.style) }, this.settings.colorDomain !== void 0 && (this.settings.colorDomain = Q(
|
|
4171
4235
|
this.settings.colorDomain
|
|
4172
4236
|
)), 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);
|
|
4173
4237
|
}
|
|
@@ -4184,16 +4248,16 @@ class Pa {
|
|
|
4184
4248
|
}
|
|
4185
4249
|
async update(e) {
|
|
4186
4250
|
this.assertAlive();
|
|
4187
|
-
const t =
|
|
4188
|
-
|
|
4251
|
+
const t = Ae(e.settings);
|
|
4252
|
+
dt(t.legacyKeys);
|
|
4189
4253
|
const i = t.legacyKeys.length ? { ...e, settings: t.settings, stylePatch: t.style } : e;
|
|
4190
4254
|
if (!this.initialized)
|
|
4191
4255
|
throw new Error("Call init() before update()");
|
|
4192
4256
|
if (i.depth != null && !Number.isFinite(i.depth))
|
|
4193
4257
|
throw new Error("Depth must be finite");
|
|
4194
|
-
i.time != null && z(i.time, "time"),
|
|
4258
|
+
i.time != null && z(i.time, "time"), rt(i.geoVideo), i.settings?.colorDomain !== void 0 && Q(i.settings.colorDomain);
|
|
4195
4259
|
for (const a of [i.style, i.stylePatch])
|
|
4196
|
-
a !== void 0 &&
|
|
4260
|
+
a !== void 0 && ft(a, "style");
|
|
4197
4261
|
return i.time != null && this.pause(), this.enqueue(i, ++this.requestSeq);
|
|
4198
4262
|
}
|
|
4199
4263
|
/**
|
|
@@ -4215,11 +4279,11 @@ class Pa {
|
|
|
4215
4279
|
}
|
|
4216
4280
|
async applyUpdate(e, t, i) {
|
|
4217
4281
|
this.assertAlive(), i != null && e.time != null && this.playSeq !== 0 && this.playSeq < i && this.pause();
|
|
4218
|
-
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 },
|
|
4219
|
-
|
|
4220
|
-
const f =
|
|
4282
|
+
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 ? pa(d) : d;
|
|
4283
|
+
mt(u, this.catalog, l);
|
|
4284
|
+
const f = u ?? (a ? pt(
|
|
4221
4285
|
this.style,
|
|
4222
|
-
this.catalog.layers.find((m) => m.id ===
|
|
4286
|
+
this.catalog.layers.find((m) => m.id === l)?.kind
|
|
4223
4287
|
) : void 0);
|
|
4224
4288
|
if (a) {
|
|
4225
4289
|
const m = { ...e.settings, ...pe(f) };
|
|
@@ -4266,10 +4330,10 @@ class Pa {
|
|
|
4266
4330
|
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);
|
|
4267
4331
|
}
|
|
4268
4332
|
async loadLayer(e, t = this.sourcePreference, i, a) {
|
|
4269
|
-
const r = this.getSource(), n =
|
|
4333
|
+
const r = this.getSource(), n = ot(this.timeMeta, this.verticalMeta);
|
|
4270
4334
|
await this.loadSource(e, t, i, a);
|
|
4271
4335
|
const o = this.getSource();
|
|
4272
|
-
o && (o.id !== r?.id || o.type !== r?.type) ? this.emit("sourceChange", o) :
|
|
4336
|
+
o && (o.id !== r?.id || o.type !== r?.type) ? this.emit("sourceChange", o) : ot(this.timeMeta, this.verticalMeta) !== n && this.emit("axesChange");
|
|
4273
4337
|
}
|
|
4274
4338
|
async loadSource(e, t, i, a) {
|
|
4275
4339
|
this.assertAlive();
|
|
@@ -4278,104 +4342,104 @@ class Pa {
|
|
|
4278
4342
|
);
|
|
4279
4343
|
if (!r)
|
|
4280
4344
|
throw new Error(`Unknown zartigl catalog entry: ${e}`);
|
|
4281
|
-
const n =
|
|
4345
|
+
const n = fa(r), o = i ? i.timeRange : this.timeRange, l = a ?? ++this.switchGeneration, d = {
|
|
4282
4346
|
...i?.target,
|
|
4283
4347
|
depth: i?.target?.depth ?? this.depthRequest ?? void 0
|
|
4284
|
-
},
|
|
4348
|
+
}, c = await this.selectSource(
|
|
4285
4349
|
r,
|
|
4286
4350
|
t,
|
|
4287
4351
|
o,
|
|
4288
|
-
|
|
4289
|
-
),
|
|
4290
|
-
if (
|
|
4352
|
+
d
|
|
4353
|
+
), u = i?.settings ?? this.settings, f = i?.colorDomainOverridden ?? this.colorDomainOverridden, m = i?.paletteOverridden ?? this.paletteOverridden;
|
|
4354
|
+
if (c.type === "geovideo") {
|
|
4291
4355
|
this.emit("status", { phase: "metadata" });
|
|
4292
4356
|
try {
|
|
4293
|
-
if (!
|
|
4357
|
+
if (!c.manifestUrl)
|
|
4294
4358
|
throw new Error(
|
|
4295
|
-
`GeoVideo archive source was not resolved to a chunk: ${
|
|
4359
|
+
`GeoVideo archive source was not resolved to a chunk: ${c.id}`
|
|
4296
4360
|
);
|
|
4297
4361
|
const v = await this.loadChunkManifest(
|
|
4298
|
-
|
|
4362
|
+
c.manifestUrl
|
|
4299
4363
|
), _ = r.sources.find(
|
|
4300
4364
|
(ce) => ce.id === v.provenance.inputSourceId
|
|
4301
4365
|
);
|
|
4302
|
-
if (v.id !==
|
|
4366
|
+
if (v.id !== c.id || v.provenance.catalogEntryId !== r.id || _?.type !== "zarr")
|
|
4303
4367
|
throw new Error(
|
|
4304
|
-
`GeoVideo manifest identity does not match catalog entry/source: ${
|
|
4368
|
+
`GeoVideo manifest identity does not match catalog entry/source: ${c.id}`
|
|
4305
4369
|
);
|
|
4306
|
-
const S =
|
|
4307
|
-
if (S && (
|
|
4370
|
+
const S = Ee(r, c.id), E = S ? this.chunkLevels.get(c.manifestUrl) ?? null : null, R = v.vertical;
|
|
4371
|
+
if (S && (E ? !He(R, E) : R !== void 0))
|
|
4308
4372
|
throw new Error(
|
|
4309
|
-
`GeoVideo manifest level does not match its index: ${
|
|
4373
|
+
`GeoVideo manifest level does not match its index: ${c.manifestUrl}`
|
|
4310
4374
|
);
|
|
4311
|
-
const k =
|
|
4312
|
-
if (
|
|
4375
|
+
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 ? la(L) : null;
|
|
4376
|
+
if (l !== this.switchGeneration)
|
|
4313
4377
|
throw new DOMException(
|
|
4314
4378
|
"Layer selection was superseded",
|
|
4315
4379
|
"AbortError"
|
|
4316
4380
|
);
|
|
4317
|
-
const N =
|
|
4381
|
+
const N = we(v), C = ca(F ?? N), I = re(
|
|
4318
4382
|
C,
|
|
4319
4383
|
o
|
|
4320
4384
|
), w = ne(
|
|
4321
4385
|
C,
|
|
4322
4386
|
o
|
|
4323
|
-
),
|
|
4387
|
+
), V = N.filter(
|
|
4324
4388
|
(ce) => ce >= w.min && ce <= w.max
|
|
4325
|
-
), X =
|
|
4326
|
-
this.catalogLayer = r, this.catalogSource =
|
|
4327
|
-
const
|
|
4328
|
-
if (this.settings = { ...n, ...
|
|
4389
|
+
), X = V.length ? V : N, oe = this.catalogLayer?.id === r.id && this.catalogSource?.type === "geovideo", le = this.settings.palette;
|
|
4390
|
+
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] : U(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);
|
|
4391
|
+
const Gt = u.colorDomain;
|
|
4392
|
+
if (this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? Gt ?? 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))
|
|
4329
4393
|
return;
|
|
4330
4394
|
this.detach(), this.attachWhenReady();
|
|
4331
4395
|
return;
|
|
4332
4396
|
} catch (v) {
|
|
4333
|
-
const _ = v instanceof Error ? v : new Error(String(v)), S =
|
|
4334
|
-
if (_.name !== "AbortError" && !(_ instanceof RangeError) && t === "auto" && S && !this.failedGeoVideo.has(S) && this.catalogSource?.id !==
|
|
4335
|
-
return console.warn("[zartigl] GeoVideo unavailable, falling back:", _), this.failedGeoVideo.add(S), this.loadSource(e, t, i,
|
|
4397
|
+
const _ = v instanceof Error ? v : new Error(String(v)), S = c.manifestUrl;
|
|
4398
|
+
if (_.name !== "AbortError" && !(_ instanceof RangeError) && t === "auto" && S && !this.failedGeoVideo.has(S) && this.catalogSource?.id !== c.id)
|
|
4399
|
+
return console.warn("[zartigl] GeoVideo unavailable, falling back:", _), this.failedGeoVideo.add(S), this.loadSource(e, t, i, l);
|
|
4336
4400
|
throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
|
|
4337
4401
|
}
|
|
4338
4402
|
}
|
|
4339
|
-
if (
|
|
4403
|
+
if (c.type === "wmts") {
|
|
4340
4404
|
this.emit("status", { phase: "metadata" });
|
|
4341
4405
|
try {
|
|
4342
|
-
const v = await
|
|
4343
|
-
if (
|
|
4406
|
+
const v = await ra(c);
|
|
4407
|
+
if (l !== this.switchGeneration)
|
|
4344
4408
|
throw new DOMException(
|
|
4345
4409
|
"Layer selection was superseded",
|
|
4346
4410
|
"AbortError"
|
|
4347
4411
|
);
|
|
4348
4412
|
const _ = v.time, S = ne(_, o);
|
|
4349
4413
|
this.detach(), this.catalogLayer = r, this.catalogSource = {
|
|
4350
|
-
...
|
|
4414
|
+
...c,
|
|
4351
4415
|
baseUrl: v.baseUrl,
|
|
4352
|
-
tileUrlTemplate:
|
|
4416
|
+
tileUrlTemplate: c.tileUrlTemplate ?? v.tileUrlTemplate,
|
|
4353
4417
|
tileMatrixSet: v.tileMatrixSet,
|
|
4354
4418
|
format: v.format,
|
|
4355
|
-
style:
|
|
4419
|
+
style: c.style ?? v.style
|
|
4356
4420
|
}, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = null, this.wmtsMetadata = v, this.fullTimeMeta = _, this.resolvedTimeRange = re(
|
|
4357
4421
|
_,
|
|
4358
4422
|
o
|
|
4359
|
-
), this.timeMeta = S, this.verticalMeta = v.vertical, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = "", this.variableStandardName =
|
|
4423
|
+
), this.timeMeta = S, this.verticalMeta = v.vertical, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = "", this.variableStandardName = c.layer, this.time = this.pendingTime == null ? at(S.values, Date.now()) : U(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();
|
|
4360
4424
|
return;
|
|
4361
4425
|
} catch (v) {
|
|
4362
4426
|
const _ = v instanceof Error ? v : new Error(String(v));
|
|
4363
4427
|
throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
|
|
4364
4428
|
}
|
|
4365
4429
|
}
|
|
4366
|
-
const p = this.getFieldSource(
|
|
4430
|
+
const p = this.getFieldSource(c.endpoints.field);
|
|
4367
4431
|
let h, g, x, T, M;
|
|
4368
4432
|
this.emit("status", { phase: "metadata" });
|
|
4369
4433
|
try {
|
|
4370
4434
|
await p.init();
|
|
4371
|
-
const v = fe(
|
|
4435
|
+
const v = fe(c);
|
|
4372
4436
|
for (const _ of v)
|
|
4373
4437
|
if (!p.hasVariable(_))
|
|
4374
4438
|
throw new Error(
|
|
4375
4439
|
`Configured variable not found in Zarr store: ${_}`
|
|
4376
4440
|
);
|
|
4377
|
-
if (g =
|
|
4378
|
-
|
|
4441
|
+
if (g = st(
|
|
4442
|
+
c,
|
|
4379
4443
|
p.getTimeDimension()
|
|
4380
4444
|
), g.values.length === 0)
|
|
4381
4445
|
throw new Error("Zarr time coordinate is empty");
|
|
@@ -4386,11 +4450,11 @@ class Pa {
|
|
|
4386
4450
|
const _ = v instanceof Error ? v : new Error(String(v));
|
|
4387
4451
|
throw this.emit("status", { phase: "error", error: _ }), this.emit("error", _), _;
|
|
4388
4452
|
}
|
|
4389
|
-
if (
|
|
4453
|
+
if (l !== this.switchGeneration)
|
|
4390
4454
|
throw new DOMException("Layer selection was superseded", "AbortError");
|
|
4391
|
-
this.detach(), this.catalogLayer = r, this.catalogSource =
|
|
4392
|
-
const y =
|
|
4393
|
-
this.settings = { ...n, ...
|
|
4455
|
+
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 ? at(this.timeMeta.values, Date.now()) : U(this.timeMeta.values, this.pendingTime), this.pendingTime = null, this.depth = Le(T, d.depth);
|
|
4456
|
+
const y = u.colorDomain;
|
|
4457
|
+
this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? y ?? null : n.colorDomain ?? null, this.lastMeta = null, this.attachWhenReady();
|
|
4394
4458
|
}
|
|
4395
4459
|
async changeSource(e, t = this.timeRange, i = {}) {
|
|
4396
4460
|
if (this.assertAlive(), !this.catalogLayer) {
|
|
@@ -4414,16 +4478,16 @@ class Pa {
|
|
|
4414
4478
|
const a = this.catalogLayer, r = this.catalogSource;
|
|
4415
4479
|
if (!a || !r || !this.isArchiveChunk(r))
|
|
4416
4480
|
return !1;
|
|
4417
|
-
const n =
|
|
4418
|
-
if ((t.time == null && !i ||
|
|
4481
|
+
const n = Ee(a, this.sourcePreference), o = n ? await this.archiveLevels(a, n) : null, d = !!o?.depths.length && t.depth != null && nt(o, t.depth) !== this.archiveLevel;
|
|
4482
|
+
if ((t.time == null && !i || Ot(r, this.sourceTimeRequest(e, t.time))) && !d)
|
|
4419
4483
|
return !1;
|
|
4420
|
-
const
|
|
4484
|
+
const u = await this.selectSource(
|
|
4421
4485
|
a,
|
|
4422
4486
|
this.sourcePreference,
|
|
4423
4487
|
e,
|
|
4424
4488
|
t
|
|
4425
4489
|
);
|
|
4426
|
-
return !
|
|
4490
|
+
return !ti(u, r);
|
|
4427
4491
|
}
|
|
4428
4492
|
applyVisible(e) {
|
|
4429
4493
|
this.assertAlive(), this.visible !== e && (this.visible = e, e ? this.attachWhenReady() : this.detach());
|
|
@@ -4448,7 +4512,7 @@ class Pa {
|
|
|
4448
4512
|
applyTime(e) {
|
|
4449
4513
|
this.assertAlive();
|
|
4450
4514
|
const t = z(e, "time");
|
|
4451
|
-
this.layer || (this.pendingTime = t), this.time =
|
|
4515
|
+
this.layer || (this.pendingTime = t), this.time = U(this.timeMeta?.values ?? [], t), this.layer?.setTime(this.time);
|
|
4452
4516
|
}
|
|
4453
4517
|
/** Start GeoVideo playback; does nothing where playback is unavailable. */
|
|
4454
4518
|
async play() {
|
|
@@ -4475,7 +4539,7 @@ class Pa {
|
|
|
4475
4539
|
const t = this.timeMeta?.values ?? [];
|
|
4476
4540
|
if (!t.length)
|
|
4477
4541
|
return;
|
|
4478
|
-
const i =
|
|
4542
|
+
const i = U(t, this.requestedTime ?? this.time);
|
|
4479
4543
|
return t[t.indexOf(i) + e];
|
|
4480
4544
|
}
|
|
4481
4545
|
pause() {
|
|
@@ -4496,10 +4560,10 @@ class Pa {
|
|
|
4496
4560
|
}
|
|
4497
4561
|
/** Media rate for the loaded artifact: steps per second when set, else the raw multiplier. */
|
|
4498
4562
|
effectivePlaybackRate() {
|
|
4499
|
-
return this.stepsPerSecond != null && this.geoVideoManifest ?
|
|
4563
|
+
return this.stepsPerSecond != null && this.geoVideoManifest ? ii(this.geoVideoManifest, this.stepsPerSecond) : this.playbackRate;
|
|
4500
4564
|
}
|
|
4501
4565
|
playbackSpeeds() {
|
|
4502
|
-
return this.catalogLayer?.kind === "vector" ?
|
|
4566
|
+
return this.catalogLayer?.kind === "vector" ? it : na;
|
|
4503
4567
|
}
|
|
4504
4568
|
/**
|
|
4505
4569
|
* Steps per second the active source shows. Vector GeoVideo stays inside
|
|
@@ -4507,29 +4571,29 @@ class Pa {
|
|
|
4507
4571
|
*/
|
|
4508
4572
|
appliedStepsPerSecond() {
|
|
4509
4573
|
if (this.catalogLayer?.kind === "vector") {
|
|
4510
|
-
const e =
|
|
4574
|
+
const e = it;
|
|
4511
4575
|
return Math.min(
|
|
4512
4576
|
e[e.length - 1],
|
|
4513
4577
|
Math.max(e[0], this.stepsPerSecond ?? 1)
|
|
4514
4578
|
);
|
|
4515
4579
|
}
|
|
4516
|
-
return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate *
|
|
4580
|
+
return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate * ai(this.geoVideoManifest) : this.playbackRate;
|
|
4517
4581
|
}
|
|
4518
4582
|
/** Apply or clear a time window without rebuilding source metadata or the map layer. */
|
|
4519
4583
|
applyTimeRange(e) {
|
|
4520
4584
|
if (this.assertAlive(), !this.fullTimeMeta)
|
|
4521
4585
|
throw new Error("Set a layer before changing its time range");
|
|
4522
|
-
const t = e == null ? void 0 : { ...e }, i = re(this.fullTimeMeta, t), a = ne(this.fullTimeMeta, t), r =
|
|
4586
|
+
const t = e == null ? void 0 : { ...e }, i = re(this.fullTimeMeta, t), a = ne(this.fullTimeMeta, t), r = U(a.values, this.time);
|
|
4523
4587
|
return this.timeRange = t, this.resolvedTimeRange = i, this.timeMeta = a, this.time = r, this.layer?.setTimeRange([a.min, a.max]), this.layer?.setTime(r), this.getTimeMeta();
|
|
4524
4588
|
}
|
|
4525
4589
|
applyDepth(e) {
|
|
4526
|
-
this.assertAlive(), this.depth =
|
|
4590
|
+
this.assertAlive(), this.depth = U(this.verticalMeta?.values ?? [], e), this.layer?.setDepth(this.depth);
|
|
4527
4591
|
}
|
|
4528
4592
|
applyTimeAndDepth(e, t) {
|
|
4529
|
-
this.assertAlive(), this.time =
|
|
4593
|
+
this.assertAlive(), this.time = U(
|
|
4530
4594
|
this.timeMeta?.values ?? [],
|
|
4531
4595
|
z(e, "time")
|
|
4532
|
-
), this.depth =
|
|
4596
|
+
), this.depth = U(this.verticalMeta?.values ?? [], t), this.layer?.setTimeAndDepth(this.time, this.depth);
|
|
4533
4597
|
}
|
|
4534
4598
|
on(e, t) {
|
|
4535
4599
|
return this.assertAlive(), this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t), this;
|
|
@@ -4547,7 +4611,7 @@ class Pa {
|
|
|
4547
4611
|
values: t.values,
|
|
4548
4612
|
units: t.units,
|
|
4549
4613
|
current: this.time,
|
|
4550
|
-
granularity:
|
|
4614
|
+
granularity: oa(t.values),
|
|
4551
4615
|
timelineKind: this.geoVideoManifest?.timeline.kind
|
|
4552
4616
|
} : {
|
|
4553
4617
|
min: NaN,
|
|
@@ -4563,7 +4627,7 @@ class Pa {
|
|
|
4563
4627
|
return { values: [], label: "depth", current: void 0 };
|
|
4564
4628
|
const e = this.verticalMeta;
|
|
4565
4629
|
return {
|
|
4566
|
-
values:
|
|
4630
|
+
values: kt(e.values),
|
|
4567
4631
|
name: e.name,
|
|
4568
4632
|
label: e.label,
|
|
4569
4633
|
units: e.units,
|
|
@@ -4584,7 +4648,7 @@ class Pa {
|
|
|
4584
4648
|
const i = this.catalogSource;
|
|
4585
4649
|
return {
|
|
4586
4650
|
type: "image",
|
|
4587
|
-
url:
|
|
4651
|
+
url: Zi({
|
|
4588
4652
|
baseUrl: i.baseUrl ?? this.wmtsMetadata?.baseUrl ?? new URL(i.capabilitiesUrl).origin,
|
|
4589
4653
|
layer: i.layer,
|
|
4590
4654
|
style: i.style
|
|
@@ -4593,7 +4657,7 @@ class Pa {
|
|
|
4593
4657
|
};
|
|
4594
4658
|
}
|
|
4595
4659
|
if (this.catalogSource.type === "geovideo" && this.geoVideoManifest) {
|
|
4596
|
-
const i = typeof this.settings.palette == "string" ?
|
|
4660
|
+
const i = typeof this.settings.palette == "string" ? Ne(this.settings.palette) : "custom", a = this.settings.colorDomain ?? this.geoVideoManifest.style.colorDomain;
|
|
4597
4661
|
return {
|
|
4598
4662
|
type: "gradient",
|
|
4599
4663
|
palette: i,
|
|
@@ -4601,10 +4665,10 @@ class Pa {
|
|
|
4601
4665
|
alphaFade: Ue(this.settings),
|
|
4602
4666
|
min: a[0],
|
|
4603
4667
|
max: a[1],
|
|
4604
|
-
unit:
|
|
4668
|
+
unit: Ye(this.geoVideoManifest.style.unit)
|
|
4605
4669
|
};
|
|
4606
4670
|
}
|
|
4607
|
-
const e = typeof this.settings.palette == "string" ?
|
|
4671
|
+
const e = typeof this.settings.palette == "string" ? Ne(this.settings.palette) : "custom", t = this.catalogLayer.kind === "scalar" ? this.settings.colorDomain : null;
|
|
4608
4672
|
return {
|
|
4609
4673
|
type: "gradient",
|
|
4610
4674
|
palette: e,
|
|
@@ -4612,11 +4676,11 @@ class Pa {
|
|
|
4612
4676
|
alphaFade: this.catalogLayer.kind === "scalar" ? Ue(this.settings) : void 0,
|
|
4613
4677
|
min: t?.[0] ?? this.lastMeta?.min,
|
|
4614
4678
|
max: t?.[1] ?? this.lastMeta?.max,
|
|
4615
|
-
unit:
|
|
4679
|
+
unit: Ye(this.lastMeta?.unit ?? this.variableUnit)
|
|
4616
4680
|
};
|
|
4617
4681
|
}
|
|
4618
4682
|
getPalettes() {
|
|
4619
|
-
return
|
|
4683
|
+
return _t();
|
|
4620
4684
|
}
|
|
4621
4685
|
getSource() {
|
|
4622
4686
|
return this.catalogSource ? { id: this.catalogSource.id, type: this.catalogSource.type } : void 0;
|
|
@@ -4649,7 +4713,7 @@ class Pa {
|
|
|
4649
4713
|
if (e.timeline.kind === "snapshot-loop")
|
|
4650
4714
|
return this.catalogLayer?.kind !== "vector";
|
|
4651
4715
|
const t = this.timeMeta;
|
|
4652
|
-
return
|
|
4716
|
+
return we(e).filter(
|
|
4653
4717
|
(a) => !t || a >= t.min && a <= t.max
|
|
4654
4718
|
).length > 1;
|
|
4655
4719
|
}
|
|
@@ -4662,9 +4726,9 @@ class Pa {
|
|
|
4662
4726
|
* source chose, such as a GeoVideo archive's palette.
|
|
4663
4727
|
*/
|
|
4664
4728
|
getStyle() {
|
|
4665
|
-
return
|
|
4729
|
+
return ze(
|
|
4666
4730
|
this.catalogLayer ?? void 0,
|
|
4667
|
-
|
|
4731
|
+
Ae(this.settings).style
|
|
4668
4732
|
);
|
|
4669
4733
|
}
|
|
4670
4734
|
/** The style override over the layer's own. */
|
|
@@ -4688,7 +4752,7 @@ class Pa {
|
|
|
4688
4752
|
devicePixelRatio: typeof window < "u" ? window.devicePixelRatio : void 0,
|
|
4689
4753
|
catalogEntry: this.catalogLayer ? {
|
|
4690
4754
|
id: this.catalogLayer.id,
|
|
4691
|
-
title:
|
|
4755
|
+
title: Bt(
|
|
4692
4756
|
this.catalogLayer.title,
|
|
4693
4757
|
this.catalog.defaultLocale,
|
|
4694
4758
|
this.catalog.defaultLocale
|
|
@@ -4713,23 +4777,23 @@ class Pa {
|
|
|
4713
4777
|
* color domain of a GeoVideo archive included, as a load sets them.
|
|
4714
4778
|
*/
|
|
4715
4779
|
styledSettings() {
|
|
4716
|
-
const e =
|
|
4780
|
+
const e = It(
|
|
4717
4781
|
this.catalogLayer ?? void 0,
|
|
4718
4782
|
this.style
|
|
4719
4783
|
), t = this.catalogSource?.type === "geovideo" ? this.geoVideoManifest : null;
|
|
4720
|
-
return t && this.style.raster?.colorDomain === void 0 && (e.colorDomain = t.style.colorDomain), t && this.style.palette === void 0 && (e.palette =
|
|
4784
|
+
return t && this.style.raster?.colorDomain === void 0 && (e.colorDomain = t.style.colorDomain), t && this.style.palette === void 0 && (e.palette = qe(this.catalogLayer?.defaults)?.palette ?? t.style.palette), e;
|
|
4721
4785
|
}
|
|
4722
4786
|
applySettings(e) {
|
|
4723
4787
|
this.assertAlive();
|
|
4724
4788
|
const t = e.colorDomain === void 0 ? e : {
|
|
4725
4789
|
...e,
|
|
4726
4790
|
colorDomain: Q(e.colorDomain)
|
|
4727
|
-
}, i =
|
|
4791
|
+
}, i = ma.some(
|
|
4728
4792
|
(r) => t[r] != null && t[r] !== this.settings[r]
|
|
4729
4793
|
), a = t.particleState != null && t.particleState !== this.settings.particleState;
|
|
4730
4794
|
if (t.colorDomain !== void 0 && (this.colorDomainOverridden = !0), t.palette !== void 0 && (this.paletteOverridden = !0), this.settings = { ...this.settings, ...t }, !!this.layer) {
|
|
4731
4795
|
if (i && this.catalogSource?.type === "geovideo") {
|
|
4732
|
-
this.layer.setColorRamp(
|
|
4796
|
+
this.layer.setColorRamp(De(this.settings)), this.applyMutableSettings(this.layer, t);
|
|
4733
4797
|
return;
|
|
4734
4798
|
}
|
|
4735
4799
|
if (i || a) {
|
|
@@ -4748,7 +4812,7 @@ class Pa {
|
|
|
4748
4812
|
);
|
|
4749
4813
|
const a = Math.max(1, Math.floor(e.maxPoints ?? 512)), r = this.getQuerySource(i.endpoints.pointSeries);
|
|
4750
4814
|
await r.init();
|
|
4751
|
-
const n = r.getTimeDimension().values, o =
|
|
4815
|
+
const n = r.getTimeDimension().values, o = st(
|
|
4752
4816
|
i,
|
|
4753
4817
|
r.getTimeDimension()
|
|
4754
4818
|
);
|
|
@@ -4763,29 +4827,29 @@ class Pa {
|
|
|
4763
4827
|
stopAfterMissingSamples: 12
|
|
4764
4828
|
});
|
|
4765
4829
|
}
|
|
4766
|
-
const
|
|
4830
|
+
const l = this.timeRange ? Math.max(
|
|
4767
4831
|
o.min,
|
|
4768
4832
|
this.resolvedTimeRange?.[0] ?? this.timeMeta?.min ?? o.min
|
|
4769
|
-
) : o.min,
|
|
4833
|
+
) : o.min, d = this.timeRange ? Math.min(
|
|
4770
4834
|
o.max,
|
|
4771
4835
|
this.resolvedTimeRange?.[1] ?? this.timeMeta?.max ?? o.max
|
|
4772
|
-
) : o.max,
|
|
4773
|
-
let
|
|
4774
|
-
for (;
|
|
4775
|
-
|
|
4776
|
-
if (
|
|
4836
|
+
) : o.max, c = n.findIndex((m) => m >= l);
|
|
4837
|
+
let u = n.length - 1;
|
|
4838
|
+
for (; u >= 0 && n[u] > d; )
|
|
4839
|
+
u--;
|
|
4840
|
+
if (c < 0 || u < c)
|
|
4777
4841
|
throw new Error("Time range does not overlap the point-series store");
|
|
4778
4842
|
const f = Math.max(
|
|
4779
4843
|
1,
|
|
4780
|
-
Math.ceil((
|
|
4844
|
+
Math.ceil((u - c + 1) / a)
|
|
4781
4845
|
);
|
|
4782
4846
|
return r.sampleTimeSeries({
|
|
4783
4847
|
variables: fe(i),
|
|
4784
4848
|
longitude: e.longitude,
|
|
4785
4849
|
latitude: e.latitude,
|
|
4786
4850
|
depth: e.depth ?? this.depth,
|
|
4787
|
-
timeStartIndex:
|
|
4788
|
-
timeEndIndex:
|
|
4851
|
+
timeStartIndex: c,
|
|
4852
|
+
timeEndIndex: u,
|
|
4789
4853
|
stride: f,
|
|
4790
4854
|
stopAfterMissingSamples: 12
|
|
4791
4855
|
});
|
|
@@ -4822,7 +4886,7 @@ class Pa {
|
|
|
4822
4886
|
);
|
|
4823
4887
|
return;
|
|
4824
4888
|
}
|
|
4825
|
-
const e = new
|
|
4889
|
+
const e = new ta({
|
|
4826
4890
|
id: this.id,
|
|
4827
4891
|
entry: this.catalogLayer,
|
|
4828
4892
|
sourceConfig: this.catalogSource,
|
|
@@ -4848,14 +4912,14 @@ class Pa {
|
|
|
4848
4912
|
zarrSource: this.activeFieldSource ?? void 0,
|
|
4849
4913
|
unit: this.variableUnit,
|
|
4850
4914
|
verticalLabel: this.verticalMeta?.label,
|
|
4851
|
-
colorRamp:
|
|
4915
|
+
colorRamp: De(this.settings),
|
|
4852
4916
|
metadata: this.metadata ? { ...this.metadata } : void 0,
|
|
4853
4917
|
before: this.before
|
|
4854
4918
|
});
|
|
4855
4919
|
this.pendingTime = null, this.autoplayPending = !1, e.on("loading", () => this.emit("loading")), e.on("loaded", (t) => {
|
|
4856
4920
|
this.lastMeta = t, this.emit("loaded", t);
|
|
4857
4921
|
}), e.on("error", (t) => this.emit("error", t)), e.on("status", (t) => this.emit("status", t)), e.on("frameBuffered", (t) => this.emit("frameBuffered", t)), e.on("cacheInvalidated", () => this.emit("cacheInvalidated")), e.on("timeChange", (t) => {
|
|
4858
|
-
e === this.layer && (this.time =
|
|
4922
|
+
e === this.layer && (this.time = U(this.timeMeta?.values ?? [], t), this.playing && (this.requestedTime = null), this.emit("timeChange", this.time));
|
|
4859
4923
|
}), e.on("playbackChange", (t) => {
|
|
4860
4924
|
e === this.layer && (t && this.preloadNextArchiveChunk(e), t !== this.playing && (this.playing = t, this.emit("playbackChange", t)));
|
|
4861
4925
|
}), e.on("playbackEnd", () => {
|
|
@@ -4887,7 +4951,7 @@ class Pa {
|
|
|
4887
4951
|
loop: i.geoVideoLoop,
|
|
4888
4952
|
playbackRate: i.geoVideoPlaybackRate,
|
|
4889
4953
|
stepsPerSecond: this.catalogLayer?.kind === "vector" ? this.appliedStepsPerSecond() : void 0
|
|
4890
|
-
}) ? (t.setColorDomain(this.settings.colorDomain ?? null), this.settings.palette && this.settings.palette !== e && t.setColorRamp(
|
|
4954
|
+
}) ? (t.setColorDomain(this.settings.colorDomain ?? null), this.settings.palette && this.settings.palette !== e && t.setColorRamp(De(this.settings)), !0) : !1;
|
|
4891
4955
|
}
|
|
4892
4956
|
detach() {
|
|
4893
4957
|
const e = this.layer;
|
|
@@ -4902,11 +4966,11 @@ class Pa {
|
|
|
4902
4966
|
}
|
|
4903
4967
|
getQuerySource(e) {
|
|
4904
4968
|
let t = this.querySources.get(e);
|
|
4905
|
-
return t || (t = new
|
|
4969
|
+
return t || (t = new _e(e, 80), this.querySources.set(e, t)), t;
|
|
4906
4970
|
}
|
|
4907
4971
|
getFieldSource(e) {
|
|
4908
4972
|
let t = this.fieldSources.get(e);
|
|
4909
|
-
return t || (t = new
|
|
4973
|
+
return t || (t = new _e(e), this.fieldSources.set(e, t)), t;
|
|
4910
4974
|
}
|
|
4911
4975
|
/**
|
|
4912
4976
|
* Time the caller asked for, so selection skips fixed-period sources (such
|
|
@@ -4924,19 +4988,19 @@ class Pa {
|
|
|
4924
4988
|
* "auto", a level deeper than the surface GeoVideo renders shows Zarr.
|
|
4925
4989
|
*/
|
|
4926
4990
|
async selectSource(e, t, i, a = {}) {
|
|
4927
|
-
const r = this.sourceTimeRequest(i, a.time), n =
|
|
4991
|
+
const r = this.sourceTimeRequest(i, a.time), n = Ee(e, t);
|
|
4928
4992
|
if (n) {
|
|
4929
|
-
const o = await this.archiveLevels(e, n),
|
|
4993
|
+
const o = await this.archiveLevels(e, n), d = o.depths.length > 0 && a.depth != null ? nt(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(
|
|
4930
4994
|
(m) => m.id === n.id
|
|
4931
4995
|
);
|
|
4932
|
-
if (
|
|
4996
|
+
if (u.length) {
|
|
4933
4997
|
const m = await this.archiveSample(
|
|
4934
4998
|
e,
|
|
4935
4999
|
n.id,
|
|
4936
5000
|
i,
|
|
4937
5001
|
a.time,
|
|
4938
|
-
|
|
4939
|
-
), p =
|
|
5002
|
+
d
|
|
5003
|
+
), p = si(u, { time: m });
|
|
4940
5004
|
if (p && !this.isFailedGeoVideo(p))
|
|
4941
5005
|
return p;
|
|
4942
5006
|
if (t !== "auto" || this.catalogSource?.id === n.id)
|
|
@@ -4944,17 +5008,17 @@ class Pa {
|
|
|
4944
5008
|
`GeoVideo chunk unavailable: ${p?.type === "geovideo" ? p.manifestUrl : n.id}`
|
|
4945
5009
|
);
|
|
4946
5010
|
} else {
|
|
4947
|
-
if (
|
|
4948
|
-
throw new Error(`GeoVideo archive level unavailable: ${
|
|
5011
|
+
if (d != null)
|
|
5012
|
+
throw new Error(`GeoVideo archive level unavailable: ${d}`);
|
|
4949
5013
|
if (t !== "auto")
|
|
4950
5014
|
throw new Error(`GeoVideo archive unavailable: ${n.id}`);
|
|
4951
5015
|
}
|
|
4952
|
-
const f = he(
|
|
5016
|
+
const f = he(c, ["zarr"], r);
|
|
4953
5017
|
if (f)
|
|
4954
5018
|
return f;
|
|
4955
5019
|
e = {
|
|
4956
|
-
...
|
|
4957
|
-
sources:
|
|
5020
|
+
...c,
|
|
5021
|
+
sources: c.sources.filter(
|
|
4958
5022
|
(m) => m.type !== "geovideo"
|
|
4959
5023
|
)
|
|
4960
5024
|
};
|
|
@@ -4977,7 +5041,7 @@ class Pa {
|
|
|
4977
5041
|
}
|
|
4978
5042
|
isArchiveChunk(e) {
|
|
4979
5043
|
return e.type === "geovideo" && !!this.catalogLayer?.sources.some(
|
|
4980
|
-
(t) => t.id === e.id &&
|
|
5044
|
+
(t) => t.id === e.id && Fe(t)
|
|
4981
5045
|
);
|
|
4982
5046
|
}
|
|
4983
5047
|
/**
|
|
@@ -4989,7 +5053,7 @@ class Pa {
|
|
|
4989
5053
|
if (!e || !t || !this.isArchiveChunk(t))
|
|
4990
5054
|
return null;
|
|
4991
5055
|
const i = this.archiveLevel;
|
|
4992
|
-
return
|
|
5056
|
+
return ri(
|
|
4993
5057
|
(await this.resolveArchives(e, i)).sources,
|
|
4994
5058
|
t,
|
|
4995
5059
|
{
|
|
@@ -5000,7 +5064,7 @@ class Pa {
|
|
|
5000
5064
|
}
|
|
5001
5065
|
/** A chunk manifest, reusing the one requested ahead for the next chunk. */
|
|
5002
5066
|
loadChunkManifest(e) {
|
|
5003
|
-
return this.nextChunkManifest?.url === e ? this.nextChunkManifest.manifest :
|
|
5067
|
+
return this.nextChunkManifest?.url === e ? this.nextChunkManifest.manifest : Ce(e);
|
|
5004
5068
|
}
|
|
5005
5069
|
/**
|
|
5006
5070
|
* While a scalar archive chunk plays, load the next chunk into the layer so
|
|
@@ -5013,7 +5077,7 @@ class Pa {
|
|
|
5013
5077
|
const i = await this.nextArchiveChunk(), a = i?.source.type === "geovideo" && i.source.manifestUrl;
|
|
5014
5078
|
if (!i || !a)
|
|
5015
5079
|
return;
|
|
5016
|
-
this.nextChunkManifest?.url !== a && (this.nextChunkManifest = { url: a, manifest:
|
|
5080
|
+
this.nextChunkManifest?.url !== a && (this.nextChunkManifest = { url: a, manifest: Ce(a) });
|
|
5017
5081
|
const r = this.nextChunkManifest, n = await r.manifest.catch((o) => {
|
|
5018
5082
|
throw this.nextChunkManifest === r && (this.nextChunkManifest = null), o;
|
|
5019
5083
|
});
|
|
@@ -5066,14 +5130,14 @@ class Pa {
|
|
|
5066
5130
|
const a = (await this.resolveArchives(e, i)).sources.flatMap(
|
|
5067
5131
|
(n) => n.id === t && n.type === "geovideo" && n.manifestUrl ? [n.manifestUrl] : []
|
|
5068
5132
|
), r = a.filter((n) => !this.chunkTimes.has(n));
|
|
5069
|
-
for (let n = 0; n < r.length; n +=
|
|
5070
|
-
const o = r.slice(n, n +
|
|
5133
|
+
for (let n = 0; n < r.length; n += lt) {
|
|
5134
|
+
const o = r.slice(n, n + lt);
|
|
5071
5135
|
(await Promise.allSettled(
|
|
5072
|
-
o.map((
|
|
5073
|
-
)).forEach((
|
|
5074
|
-
|
|
5136
|
+
o.map((d) => this.loadChunkManifest(d))
|
|
5137
|
+
)).forEach((d, c) => {
|
|
5138
|
+
d.status === "fulfilled" ? this.chunkTimes.set(o[c], we(d.value)) : console.warn(
|
|
5075
5139
|
"[zartigl] GeoVideo chunk samples unavailable:",
|
|
5076
|
-
|
|
5140
|
+
d.reason
|
|
5077
5141
|
);
|
|
5078
5142
|
});
|
|
5079
5143
|
}
|
|
@@ -5088,13 +5152,13 @@ class Pa {
|
|
|
5088
5152
|
* and the time shown in agreement.
|
|
5089
5153
|
*/
|
|
5090
5154
|
async archiveSample(e, t, i, a, r = null) {
|
|
5091
|
-
const n = await this.archiveTimes(e, t, r), [o,
|
|
5092
|
-
if (
|
|
5155
|
+
const n = await this.archiveTimes(e, t, r), [o, l] = i && n.length ? xt(i, [n[0], n[n.length - 1]]) : [-1 / 0, 1 / 0], d = n.filter((u) => u >= o && u <= l);
|
|
5156
|
+
if (d.length === 0)
|
|
5093
5157
|
throw new RangeError(
|
|
5094
5158
|
"Time range does not contain any available timestamps"
|
|
5095
5159
|
);
|
|
5096
|
-
const
|
|
5097
|
-
return
|
|
5160
|
+
const c = this.sourceTimeRequest(void 0, a).time;
|
|
5161
|
+
return c == null ? d[d.length - 1] : U(d, c);
|
|
5098
5162
|
}
|
|
5099
5163
|
/**
|
|
5100
5164
|
* Entry whose archive sources are replaced by one fixed-period source per
|
|
@@ -5105,7 +5169,7 @@ class Pa {
|
|
|
5105
5169
|
async resolveArchives(e, t = null) {
|
|
5106
5170
|
const i = await Promise.all(
|
|
5107
5171
|
e.sources.map(async (a) => {
|
|
5108
|
-
if (!
|
|
5172
|
+
if (!Fe(a))
|
|
5109
5173
|
return [a];
|
|
5110
5174
|
const r = await this.archiveChunksAt(
|
|
5111
5175
|
e,
|
|
@@ -5119,7 +5183,7 @@ class Pa {
|
|
|
5119
5183
|
return n ? this.archiveChunksAt(
|
|
5120
5184
|
e,
|
|
5121
5185
|
a,
|
|
5122
|
-
|
|
5186
|
+
ni(n, a.indexUrl),
|
|
5123
5187
|
n
|
|
5124
5188
|
) : [];
|
|
5125
5189
|
})
|
|
@@ -5140,28 +5204,28 @@ class Pa {
|
|
|
5140
5204
|
if (r && r.expires > Date.now())
|
|
5141
5205
|
return r.chunks;
|
|
5142
5206
|
const n = {
|
|
5143
|
-
expires: Date.now() +
|
|
5144
|
-
chunks:
|
|
5145
|
-
if (a ? !
|
|
5207
|
+
expires: Date.now() + ha,
|
|
5208
|
+
chunks: oi(i).then((o) => {
|
|
5209
|
+
if (a ? !He(o.vertical, a) : o.vertical !== void 0)
|
|
5146
5210
|
throw new Error(`GeoVideo index level does not match: ${i}`);
|
|
5147
5211
|
!a && !this.archiveRoots.has(t.indexUrl) && this.archiveRoots.set(t.indexUrl, {
|
|
5148
5212
|
surface: o.surface,
|
|
5149
5213
|
depths: o.depths ?? []
|
|
5150
5214
|
});
|
|
5151
|
-
const
|
|
5215
|
+
const l = li(
|
|
5152
5216
|
{ ...t, indexUrl: i },
|
|
5153
5217
|
o,
|
|
5154
5218
|
e
|
|
5155
5219
|
);
|
|
5156
|
-
for (const
|
|
5157
|
-
this.chunkLevels.set(
|
|
5158
|
-
return
|
|
5159
|
-
}).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() +
|
|
5220
|
+
for (const d of ci(o, i))
|
|
5221
|
+
this.chunkLevels.set(d.manifestUrl, a), d.times && this.chunkTimes.set(d.manifestUrl, d.times);
|
|
5222
|
+
return l;
|
|
5223
|
+
}).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() + ua, []))
|
|
5160
5224
|
};
|
|
5161
5225
|
return this.archiveChunks.set(i, n), n.chunks;
|
|
5162
5226
|
}
|
|
5163
5227
|
resolveSource(e, t, i) {
|
|
5164
|
-
const a = t === "auto" ?
|
|
5228
|
+
const a = t === "auto" ? $t(e, i) : e.sources.find((r) => r.id === t) ?? he(
|
|
5165
5229
|
e,
|
|
5166
5230
|
[t],
|
|
5167
5231
|
i
|
|
@@ -5222,33 +5286,33 @@ class Pa {
|
|
|
5222
5286
|
a(...t);
|
|
5223
5287
|
}
|
|
5224
5288
|
}
|
|
5225
|
-
function
|
|
5289
|
+
function ga(s, e) {
|
|
5226
5290
|
const t = new Date(s).toISOString();
|
|
5227
5291
|
return e === "year" ? t.slice(0, 4) : e === "month" ? t.slice(0, 7) : e === "day" ? t.slice(0, 10) : "";
|
|
5228
5292
|
}
|
|
5229
|
-
function
|
|
5293
|
+
function va(s, e) {
|
|
5230
5294
|
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();
|
|
5231
5295
|
}
|
|
5232
|
-
function
|
|
5296
|
+
function Ca(s, e, t) {
|
|
5233
5297
|
if (!e || s.length === 0)
|
|
5234
5298
|
return;
|
|
5235
5299
|
if (["year", "month", "day"].includes(t)) {
|
|
5236
5300
|
const a = s.find(
|
|
5237
|
-
(r) =>
|
|
5301
|
+
(r) => ga(r, t) === e
|
|
5238
5302
|
);
|
|
5239
5303
|
if (a !== void 0)
|
|
5240
5304
|
return a;
|
|
5241
5305
|
}
|
|
5242
|
-
const i =
|
|
5306
|
+
const i = va(e, t);
|
|
5243
5307
|
if (Number.isFinite(i))
|
|
5244
5308
|
return s.reduce(
|
|
5245
5309
|
(a, r) => Math.abs(r - i) < Math.abs(a - i) ? r : a
|
|
5246
5310
|
);
|
|
5247
5311
|
}
|
|
5248
|
-
const
|
|
5312
|
+
const Vt = gt.devDependencies["maplibre-gl"].replace(
|
|
5249
5313
|
/^[^\d]*/,
|
|
5250
5314
|
""
|
|
5251
|
-
),
|
|
5315
|
+
), ya = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Vt}/+esm`, _a = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Vt}/dist/maplibre-gl.css`, xa = `{
|
|
5252
5316
|
version: 8,
|
|
5253
5317
|
sources: {
|
|
5254
5318
|
"eox-cloudless": {
|
|
@@ -5272,10 +5336,10 @@ const kt = pt.devDependencies["maplibre-gl"].replace(
|
|
|
5272
5336
|
function q(s) {
|
|
5273
5337
|
return JSON.stringify(s);
|
|
5274
5338
|
}
|
|
5275
|
-
function
|
|
5339
|
+
function ba(s) {
|
|
5276
5340
|
return JSON.stringify(s, null, 2);
|
|
5277
5341
|
}
|
|
5278
|
-
function
|
|
5342
|
+
function Ut(s) {
|
|
5279
5343
|
return s instanceof Date ? `new Date(${q(s.toISOString())})` : typeof s == "string" ? `new Date(${q(s)})` : String(s);
|
|
5280
5344
|
}
|
|
5281
5345
|
function ie(s, e = 6) {
|
|
@@ -5283,25 +5347,25 @@ function ie(s, e = 6) {
|
|
|
5283
5347
|
}
|
|
5284
5348
|
function $(s, e) {
|
|
5285
5349
|
const t = " ".repeat(e);
|
|
5286
|
-
return
|
|
5350
|
+
return ba(s).split(`
|
|
5287
5351
|
`).map((i) => `${t}${i}`).join(`
|
|
5288
5352
|
`).trimStart();
|
|
5289
5353
|
}
|
|
5290
|
-
function
|
|
5354
|
+
function Sa(s, e) {
|
|
5291
5355
|
const t = " ".repeat(e);
|
|
5292
5356
|
return s.split(`
|
|
5293
5357
|
`).map((i) => i.length > 0 ? `${t}${i}` : i).join(`
|
|
5294
5358
|
`);
|
|
5295
5359
|
}
|
|
5296
|
-
const
|
|
5360
|
+
const wa = (s) => {
|
|
5297
5361
|
const e = s.source ?? "auto";
|
|
5298
5362
|
return s.sourceType ?? (e === "wmts" || e === "geovideo" ? e : "zarr");
|
|
5299
5363
|
};
|
|
5300
|
-
function
|
|
5301
|
-
const { layerKind: e, layerDefaults: t } = s, i =
|
|
5364
|
+
function Nt(s) {
|
|
5365
|
+
const { layerKind: e, layerDefaults: t } = s, i = pt(s.style ?? {}, e), a = t === void 0 ? i : qt(i, ze({ kind: e, defaults: t })), r = a.raster?.opacity, n = wa(s) !== "wmts" ? a : r === void 0 ? {} : { raster: { opacity: r } };
|
|
5302
5366
|
return Object.keys(n).length ? n : void 0;
|
|
5303
5367
|
}
|
|
5304
|
-
function
|
|
5368
|
+
function zt(s) {
|
|
5305
5369
|
const { particleState: e, rgba8MaxParticleZoom: t } = s.settings ?? {}, i = Object.fromEntries(
|
|
5306
5370
|
Object.entries({ particleState: e, rgba8MaxParticleZoom: t }).filter(
|
|
5307
5371
|
([, a]) => a !== void 0
|
|
@@ -5309,8 +5373,8 @@ function Ut(s) {
|
|
|
5309
5373
|
);
|
|
5310
5374
|
return s.layerKind === "vector" && Object.keys(i).length ? i : void 0;
|
|
5311
5375
|
}
|
|
5312
|
-
function
|
|
5313
|
-
const e = s.source ?? "auto", t =
|
|
5376
|
+
function ka(s) {
|
|
5377
|
+
const e = s.source ?? "auto", t = Nt(s), i = zt(s), a = [
|
|
5314
5378
|
" idView: widget.opt.view.id,",
|
|
5315
5379
|
" map: widget.opt.map,",
|
|
5316
5380
|
` layer: ${q(s.layerId)},`,
|
|
@@ -5318,7 +5382,7 @@ function La(s) {
|
|
|
5318
5382
|
];
|
|
5319
5383
|
for (const r of ["title", "subtitle", "description"])
|
|
5320
5384
|
s[r] != null && a.push(` ${r}: ${$(s[r], 10)},`);
|
|
5321
|
-
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: ${
|
|
5385
|
+
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: ${Ut(s.time)},`), s.timeRange != null && a.push(
|
|
5322
5386
|
` timeRange: ${$(s.timeRange, 10)},`
|
|
5323
5387
|
), s.geoVideo != null && a.push(
|
|
5324
5388
|
` geoVideo: ${$(s.geoVideo, 10)},`
|
|
@@ -5357,16 +5421,16 @@ ${a.join(`
|
|
|
5357
5421
|
};
|
|
5358
5422
|
}`;
|
|
5359
5423
|
}
|
|
5360
|
-
function
|
|
5361
|
-
const e = s.moduleBaseUrl ?? `https://cdn.jsdelivr.net/npm/@fxi/zartigl@${
|
|
5424
|
+
function Ta(s) {
|
|
5425
|
+
const e = s.moduleBaseUrl ?? `https://cdn.jsdelivr.net/npm/@fxi/zartigl@${gt.version}/dist`, t = s.source ?? "auto", i = Nt(s), a = zt(s), r = s.timeRange == null ? "" : ` timeRange: ${$(s.timeRange, 2)},
|
|
5362
5426
|
`, n = s.geoVideo == null ? "" : ` geoVideo: ${$(s.geoVideo, 2)},
|
|
5363
5427
|
`, o = i == null ? "" : ` style: ${$(i, 2)},
|
|
5364
|
-
`,
|
|
5365
|
-
`,
|
|
5366
|
-
`,
|
|
5367
|
-
`,
|
|
5428
|
+
`, l = a == null ? "" : ` settings: ${$(a, 2)},
|
|
5429
|
+
`, d = s.time == null ? "" : ` time: ${Ut(s.time)},
|
|
5430
|
+
`, c = s.depth == null ? "" : ` depth: ${s.depth},
|
|
5431
|
+
`, u = s.center ?? [0, 20], f = s.projection ?? "mercator", m = s.mapStyle == null ? xa : q(s.mapStyle), p = `map.setProjection({ type: ${q(f)} });
|
|
5368
5432
|
map.jumpTo({
|
|
5369
|
-
center: [${ie(
|
|
5433
|
+
center: [${ie(u[0])}, ${ie(u[1])}],
|
|
5370
5434
|
zoom: ${ie(s.zoom ?? 2, 3)},
|
|
5371
5435
|
bearing: ${ie(s.bearing ?? 0, 3)},
|
|
5372
5436
|
pitch: ${ie(s.pitch ?? 0, 3)},
|
|
@@ -5393,10 +5457,10 @@ const z = new Zartigl({
|
|
|
5393
5457
|
catalog,
|
|
5394
5458
|
layer: ${q(s.layerId)},
|
|
5395
5459
|
source: ${q(t)},
|
|
5396
|
-
${r}${n}${o}${
|
|
5460
|
+
${r}${n}${o}${l}${d}${c}});
|
|
5397
5461
|
|
|
5398
5462
|
await z.init();`;
|
|
5399
|
-
return `import maplibregl from ${q(
|
|
5463
|
+
return `import maplibregl from ${q(ya)};
|
|
5400
5464
|
import { Zartigl } from "${e}/zartigl.js";
|
|
5401
5465
|
import { catalog } from "${e}/catalog.js";
|
|
5402
5466
|
|
|
@@ -5408,18 +5472,18 @@ const map = new maplibregl.Map({
|
|
|
5408
5472
|
});
|
|
5409
5473
|
|
|
5410
5474
|
map.once("style.load", async () => {
|
|
5411
|
-
${
|
|
5475
|
+
${Sa(p, 2)}
|
|
5412
5476
|
});`;
|
|
5413
5477
|
}
|
|
5414
|
-
function
|
|
5415
|
-
const e =
|
|
5478
|
+
function Fa(s) {
|
|
5479
|
+
const e = Ta(s);
|
|
5416
5480
|
return `<!doctype html>
|
|
5417
5481
|
<html lang="en">
|
|
5418
5482
|
<head>
|
|
5419
5483
|
<meta charset="UTF-8" />
|
|
5420
5484
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
5421
5485
|
<title>Zartigl demo</title>
|
|
5422
|
-
<link rel="stylesheet" href=${q(
|
|
5486
|
+
<link rel="stylesheet" href=${q(_a)} />
|
|
5423
5487
|
<style>
|
|
5424
5488
|
html, body, #map {
|
|
5425
5489
|
width: 100%;
|
|
@@ -5441,41 +5505,41 @@ ${e}
|
|
|
5441
5505
|
</html>`;
|
|
5442
5506
|
}
|
|
5443
5507
|
export {
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5508
|
+
hi as BACKDROP_OFF,
|
|
5509
|
+
ui as COLOR_GRADE_OFF,
|
|
5510
|
+
Ga as COLOR_GRADE_VIBRANT,
|
|
5511
|
+
na as GEOVIDEO_SPEEDS,
|
|
5448
5512
|
G as GeoVideoLayer,
|
|
5449
|
-
|
|
5450
|
-
|
|
5513
|
+
Ft as LEGACY_STYLE_SETTINGS,
|
|
5514
|
+
Rt as ParticleSimulation,
|
|
5451
5515
|
me as ScalarLayer,
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5516
|
+
it as VECTOR_GEOVIDEO_SPEEDS,
|
|
5517
|
+
P as VectorLayer,
|
|
5518
|
+
Pt as VelocityField,
|
|
5519
|
+
_e as ZarrSource,
|
|
5520
|
+
Aa as Zartigl,
|
|
5521
|
+
xe as ZartiglFrameUnavailableError,
|
|
5522
|
+
ka as buildMapxWidgetSnippet,
|
|
5523
|
+
Fa as buildStandaloneDemoHtml,
|
|
5524
|
+
Ta as buildStandaloneDemoSnippet,
|
|
5525
|
+
Zi as buildWmtsLegendUrl,
|
|
5526
|
+
Je as buildWmtsTileUrl,
|
|
5527
|
+
fi as colorGradeToGrade,
|
|
5528
|
+
Wi as deriveDirectionMagnitudeComponents,
|
|
5529
|
+
Ye as formatUnit,
|
|
5530
|
+
ei as geoVideoSecondsForTime,
|
|
5531
|
+
Ua as geoVideoTimeForSeconds,
|
|
5532
|
+
we as geoVideoTimelineValues,
|
|
5533
|
+
_t as getPalettes,
|
|
5534
|
+
Da as getVectorDerivationVariables,
|
|
5535
|
+
pi as gradeToColorGrade,
|
|
5536
|
+
Oa as isHexColor,
|
|
5537
|
+
Ce as loadGeoVideoManifest,
|
|
5538
|
+
St as resolveBackdrop,
|
|
5539
|
+
bt as resolveColorGrade,
|
|
5540
|
+
ke as resolveColorRamp,
|
|
5541
|
+
Ca as resolveTimeInputSelection,
|
|
5542
|
+
Ae as splitLegacySettings,
|
|
5543
|
+
Et as stitchVelocityChunks,
|
|
5544
|
+
Na as validateGeoVideoManifest
|
|
5481
5545
|
};
|