@3clear/basegis 0.1.6 → 0.1.8

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.
@@ -0,0 +1,508 @@
1
+ const C = {
2
+ OK: "OK",
3
+ CANCELLED: "CANCELLED",
4
+ FAILED: "FAILED",
5
+ NOT_INITIALIZED: "NOT_INITIALIZED",
6
+ INVALID_CONTAINER: "INVALID_CONTAINER",
7
+ ENGINE_NOT_REGISTERED: "ENGINE_NOT_REGISTERED",
8
+ ENGINE_RESOURCE_MISSING: "ENGINE_RESOURCE_MISSING",
9
+ METHOD_NOT_FOUND: "METHOD_NOT_FOUND",
10
+ UNSUPPORTED_CAPABILITY: "UNSUPPORTED_CAPABILITY",
11
+ INVALID_DEM: "INVALID_DEM"
12
+ };
13
+ function v({
14
+ success: t = !0,
15
+ message: n = "",
16
+ data: e = null,
17
+ code: i = C.OK
18
+ } = {}) {
19
+ return { success: t, message: n, data: e, code: i };
20
+ }
21
+ function k(t = null, n = "OK", e = C.OK) {
22
+ return v({ success: !0, message: n, data: t, code: e });
23
+ }
24
+ function U(t = "Operation failed.", n = C.FAILED, e = null) {
25
+ return v({ success: !1, message: t, data: e, code: n });
26
+ }
27
+ function tt(t, n, e = "") {
28
+ const i = `${n} adapter does not support "${t}". ${e}`.trim();
29
+ return console.warn(`[3clear-dt-base] ${i}`), U(i, C.UNSUPPORTED_CAPABILITY, {
30
+ methodName: t,
31
+ engineType: n,
32
+ detail: e
33
+ });
34
+ }
35
+ function nt(t, n = {}) {
36
+ var i, s, o, r, l;
37
+ if (n.currentTime !== void 0 && n.currentTime !== null && !Number.isFinite(n.currentTime))
38
+ return "currentTime must be a finite timestamp in milliseconds or null.";
39
+ if (t.times !== void 0) {
40
+ if (!t.colors || !Array.isArray(t.times) || t.times.length !== ((i = t.positions) == null ? void 0 : i.length))
41
+ return "line.times requires vertex colors and one timestamp for each position.";
42
+ for (let a = 0; a < t.times.length; a += 1)
43
+ if (!Number.isFinite(t.times[a]) || a > 0 && t.times[a] <= t.times[a - 1])
44
+ return "line.times must contain strictly increasing finite timestamps in milliseconds.";
45
+ }
46
+ if (t.colors === void 0) return "";
47
+ if (!Array.isArray(t.colors) || t.colors.length !== ((s = t.positions) == null ? void 0 : s.length))
48
+ return "line.colors must have one color for each position.";
49
+ if (t.colors.some((a) => typeof a != "string" || !/^#[0-9a-f]{6}$/i.test(a)))
50
+ return "line.colors requires six-digit HEX colors.";
51
+ const e = { ...n.style, ...t.style };
52
+ return e.pattern === "dashed" || (r = (o = e.color) == null ? void 0 : o.flow) != null && r.enabled ? "Vertex colors support solid lines only." : (e.clampToGround ?? n.clampToGround) === !0 ? "Vertex colors do not support clampToGround; use false for the thematic overlay." : (l = n.animation) != null && l.enabled && (!n.animation.lineId || String(n.animation.lineId) === String(t.id)) ? "Vertex-colored lines do not support reveal animation." : "";
53
+ }
54
+ const V = {
55
+ TD: "#e6d64f",
56
+ TS: "#2f8df4",
57
+ STS: "#28a46a",
58
+ TY: "#f59e0b",
59
+ STY: "#d946ef",
60
+ SuperTY: "#ef4444"
61
+ }, L = {
62
+ trackLine: {
63
+ color: "#ffffff",
64
+ width: 3,
65
+ opacity: 0.96,
66
+ outlineColor: "#08131f",
67
+ outlineWidth: 1
68
+ },
69
+ forecastLine: {
70
+ color: "#f8fafc",
71
+ width: 2,
72
+ opacity: 0.92,
73
+ dashLength: 12,
74
+ gapLength: 8
75
+ },
76
+ point: {
77
+ radius: 5,
78
+ outlineColor: "#07111f",
79
+ outlineWidth: 1
80
+ },
81
+ label: {
82
+ visible: !0,
83
+ color: "#ffffff",
84
+ fontSize: 12,
85
+ backgroundColor: "rgba(2, 20, 42, 0.82)",
86
+ offset: [0, -22]
87
+ },
88
+ center: {
89
+ iconUrl: "",
90
+ iconSize: [36, 36],
91
+ rotate: !0,
92
+ rotationDurationMs: 1400,
93
+ showLabel: !0,
94
+ labelColor: "#07111f",
95
+ labelBackgroundColor: "rgba(255, 255, 255, 0.88)",
96
+ labelOffset: [30, -30]
97
+ },
98
+ windCircle: {
99
+ visible: !0,
100
+ r7: { color: "#c8c537", fillOpacity: 0.26, outlineOpacity: 0.9 },
101
+ r10: { color: "#ffaa00", fillOpacity: 0.22, outlineOpacity: 0.9 },
102
+ r12: { color: "#cc4400", fillOpacity: 0.18, outlineOpacity: 0.95 }
103
+ },
104
+ intensityColors: V
105
+ }, R = {
106
+ enabled: !0,
107
+ durationMs: 15e3,
108
+ autoplay: !1,
109
+ loop: !1,
110
+ currentIndex: 0
111
+ };
112
+ function c(t) {
113
+ return !!(t && typeof t == "object" && !Array.isArray(t));
114
+ }
115
+ function y(t, n) {
116
+ return Object.prototype.hasOwnProperty.call(t || {}, n);
117
+ }
118
+ function f(t, n, e) {
119
+ return Math.min(Math.max(t, n), e);
120
+ }
121
+ function u(t, n = 0) {
122
+ const e = Number(t);
123
+ return Number.isFinite(e) ? e : n;
124
+ }
125
+ function p(t, n) {
126
+ return {
127
+ ...c(t) ? t : {},
128
+ ...c(n) ? n : {}
129
+ };
130
+ }
131
+ function _(t = {}, n = {}) {
132
+ const e = c(t) ? t : {}, i = c(n) ? n : {}, s = {
133
+ ...e,
134
+ ...i
135
+ };
136
+ ["trackLine", "forecastLine", "point", "label", "center", "intensityColors"].forEach((l) => {
137
+ s[l] = p(e[l], i[l]);
138
+ });
139
+ const o = c(e.windCircle) ? e.windCircle : {}, r = c(i.windCircle) ? i.windCircle : {};
140
+ return s.windCircle = {
141
+ ...o,
142
+ ...r,
143
+ r7: p(o.r7, r.r7),
144
+ r10: p(o.r10, r.r10),
145
+ r12: p(o.r12, r.r12)
146
+ }, s;
147
+ }
148
+ function et(t = {}, n = {}) {
149
+ const e = c(t) ? t : {}, i = c(n) ? n : {}, s = {
150
+ ...e,
151
+ ...i,
152
+ typhoon: p(e.typhoon, i.typhoon),
153
+ style: _(e.style, i.style),
154
+ playback: p(e.playback, i.playback)
155
+ };
156
+ return !y(i, "tracks") && y(e, "tracks") && (s.tracks = e.tracks), !y(i, "forecastPaths") && y(e, "forecastPaths") && (s.forecastPaths = e.forecastPaths), s;
157
+ }
158
+ function G(t, n) {
159
+ if (!Array.isArray(t) || t.length < 2)
160
+ throw new Error(`${n} must be [longitude, latitude, height?].`);
161
+ const e = Number(t[0]), i = Number(t[1]), s = t.length > 2 ? Number(t[2]) : 0;
162
+ if (!Number.isFinite(e) || !Number.isFinite(i) || !Number.isFinite(s) || i < -90 || i > 90)
163
+ throw new Error(`${n} must contain finite coordinates and latitude must be between -90 and 90.`);
164
+ return [e, i, s];
165
+ }
166
+ function Y(t, n) {
167
+ if (t == null) return null;
168
+ if (!c(t))
169
+ throw new Error(`${n} must be { ne, se, sw, nw } in kilometres.`);
170
+ const e = {};
171
+ for (const i of ["ne", "se", "sw", "nw"]) {
172
+ const s = Number(t[i]);
173
+ if (!Number.isFinite(s) || s < 0)
174
+ throw new Error(`${n}.${i} must be a non-negative number.`);
175
+ e[i] = s;
176
+ }
177
+ return e;
178
+ }
179
+ function W(t, n) {
180
+ if (t == null) return {};
181
+ if (!c(t)) throw new Error(`${n} must be an object.`);
182
+ return ["r7", "r10", "r12"].reduce((e, i) => {
183
+ const s = Y(t[i], `${n}.${i}`);
184
+ return s && (e[i] = s), e;
185
+ }, {});
186
+ }
187
+ function $(t, n, e = "tracks") {
188
+ if (!c(t)) throw new Error(`${e}[${n}] must be an object.`);
189
+ const i = t.time ?? "", s = Date.parse(i), o = i == null || String(i) === "" ? `${e}-${n}` : i;
190
+ return {
191
+ ...t,
192
+ id: String(t.id === void 0 || t.id === null || String(t.id) === "" ? o : t.id),
193
+ time: i,
194
+ timestamp: Number.isFinite(s) ? s : null,
195
+ position: G(t.position, `${e}[${n}].position`),
196
+ level: String(t.level || "TD"),
197
+ windSpeed: t.windSpeed === void 0 ? null : u(t.windSpeed, null),
198
+ pressure: t.pressure === void 0 ? null : u(t.pressure, null),
199
+ windCircles: W(t.windCircles, `${e}[${n}].windCircles`)
200
+ };
201
+ }
202
+ function j(t, n, e) {
203
+ if (!c(t)) throw new Error(`forecastPaths[${n}] must be an object.`);
204
+ if (!Array.isArray(t.points) || t.points.length === 0)
205
+ throw new Error(`forecastPaths[${n}].points requires at least one point.`);
206
+ const i = String(t.id ?? `forecast-${n}`), s = t.points.map((o, r) => {
207
+ const l = $(o, r, `forecastPaths[${n}].points`), a = o == null ? void 0 : o.uncertaintyRadiusKm;
208
+ return {
209
+ ...l,
210
+ uncertaintyRadiusKm: a == null ? 0 : Math.max(u(a, 0), 0)
211
+ };
212
+ });
213
+ return {
214
+ ...t,
215
+ id: i,
216
+ points: s,
217
+ style: p(e, t.style)
218
+ };
219
+ }
220
+ function q(t = {}) {
221
+ const n = _(L, t);
222
+ return n.trackLine.width = Math.max(u(n.trackLine.width, 3), 0.5), n.trackLine.opacity = f(u(n.trackLine.opacity, 0.96), 0, 1), n.trackLine.outlineWidth = Math.max(u(n.trackLine.outlineWidth, 1), 0), n.forecastLine.width = Math.max(u(n.forecastLine.width, 2), 0.5), n.forecastLine.opacity = f(u(n.forecastLine.opacity, 0.92), 0, 1), n.forecastLine.dashLength = Math.max(u(n.forecastLine.dashLength, 12), 1), n.forecastLine.gapLength = Math.max(u(n.forecastLine.gapLength, 8), 1), n.point.radius = Math.max(u(n.point.radius, 5), 1), n.point.outlineWidth = Math.max(u(n.point.outlineWidth, 1), 0), n.label.fontSize = Math.max(u(n.label.fontSize, 12), 8), n.label.offset = Array.isArray(n.label.offset) ? n.label.offset.slice(0, 2) : [0, -22], n.center.iconSize = Array.isArray(n.center.iconSize) ? n.center.iconSize.slice(0, 2).map((e) => Math.max(u(e, 36), 1)) : [36, 36], n.center.rotationDurationMs = Math.max(u(n.center.rotationDurationMs, 1400), 1), n.center.labelOffset = Array.isArray(n.center.labelOffset) ? n.center.labelOffset.slice(0, 2) : [30, -30], ["r7", "r10", "r12"].forEach((e) => {
223
+ n.windCircle[e].fillOpacity = f(
224
+ u(n.windCircle[e].fillOpacity, L.windCircle[e].fillOpacity),
225
+ 0,
226
+ 1
227
+ ), n.windCircle[e].outlineOpacity = f(
228
+ u(n.windCircle[e].outlineOpacity, L.windCircle[e].outlineOpacity),
229
+ 0,
230
+ 1
231
+ );
232
+ }), n;
233
+ }
234
+ function it(t = {}, n = {}) {
235
+ const e = c(t) ? t : {}, i = Array.isArray(e.tracks) ? e.tracks.map((l, a) => $(l, a)) : [];
236
+ if (!n.allowEmpty && i.length === 0)
237
+ throw new Error("Typhoon path requires a non-empty tracks array.");
238
+ const s = q(e.style), o = Array.isArray(e.forecastPaths) ? e.forecastPaths.map((l, a) => j(l, a, s.forecastLine)) : [], r = p(R, e.playback);
239
+ return r.enabled = r.enabled !== !1, r.durationMs = Math.max(u(r.durationMs, R.durationMs), 1), r.autoplay = r.autoplay === !0, r.loop = r.loop === !0, r.currentIndex = i.length ? f(Math.floor(u(r.currentIndex, 0)), 0, i.length - 1) : 0, {
240
+ ...e,
241
+ layerId: String(e.typhoonPathLayerId || e.layerId || e.id || "typhoon-path-default"),
242
+ typhoon: p({}, e.typhoon),
243
+ tracks: i,
244
+ forecastPaths: o,
245
+ style: s,
246
+ playback: r,
247
+ visible: e.visible !== !1,
248
+ onCurrentChange: typeof e.onCurrentChange == "function" ? e.onCurrentChange : null,
249
+ onPointClick: typeof e.onPointClick == "function" ? e.onPointClick : null
250
+ };
251
+ }
252
+ function m(t) {
253
+ return t * Math.PI / 180;
254
+ }
255
+ function N(t) {
256
+ return t * 180 / Math.PI;
257
+ }
258
+ function K(t, n) {
259
+ const e = m(t[1]), i = m(n[1]), s = i - e, o = m(n[0] - t[0]), r = Math.sin(s / 2) ** 2 + Math.cos(e) * Math.cos(i) * Math.sin(o / 2) ** 2;
260
+ return 6371e3 * 2 * Math.atan2(Math.sqrt(r), Math.sqrt(Math.max(1 - r, 0)));
261
+ }
262
+ function F(t) {
263
+ if (t.length <= 1) return [0];
264
+ if (t.every(
265
+ (s, o) => s.timestamp !== null && (o === 0 || s.timestamp > t[o - 1].timestamp)
266
+ )) {
267
+ const s = t[0].timestamp, o = t[t.length - 1].timestamp - s;
268
+ if (o > 0) return t.map((r) => (r.timestamp - s) / o);
269
+ }
270
+ const e = [0];
271
+ for (let s = 1; s < t.length; s += 1) {
272
+ const o = K(t[s - 1].position, t[s].position), r = t[s].position[2] - t[s - 1].position[2];
273
+ e.push(e[s - 1] + Math.hypot(o, r));
274
+ }
275
+ const i = e[e.length - 1];
276
+ return i > 0 ? e.map((s) => s / i) : e.map((s, o) => o / (t.length - 1));
277
+ }
278
+ function H(t, n, e) {
279
+ const i = m(t[1]), s = m(t[0]), o = m(n[1]), r = m(n[0]), l = 2 * Math.asin(Math.sqrt(
280
+ Math.sin((o - i) / 2) ** 2 + Math.cos(i) * Math.cos(o) * Math.sin((r - s) / 2) ** 2
281
+ ));
282
+ if (!Number.isFinite(l) || l < 1e-9)
283
+ return [t[0], t[1], t[2] + (n[2] - t[2]) * e];
284
+ const a = Math.sin(l), h = Math.sin((1 - e) * l) / a, d = Math.sin(e * l) / a, M = h * Math.cos(i) * Math.cos(s) + d * Math.cos(o) * Math.cos(r), g = h * Math.cos(i) * Math.sin(s) + d * Math.cos(o) * Math.sin(r), b = h * Math.sin(i) + d * Math.sin(o);
285
+ return [
286
+ N(Math.atan2(g, M)),
287
+ N(Math.atan2(b, Math.hypot(M, g))),
288
+ t[2] + (n[2] - t[2]) * e
289
+ ];
290
+ }
291
+ function st(t = [], n = 0) {
292
+ if (!t.length) return null;
293
+ const e = f(u(n, 0), 0, 1);
294
+ if (t.length === 1)
295
+ return { progress: e, index: 0, nextIndex: 0, segmentProgress: 0, position: [...t[0].position], track: t[0] };
296
+ const i = F(t);
297
+ let s = i.length - 2;
298
+ for (let h = 1; h < i.length; h += 1)
299
+ if (e < i[h]) {
300
+ s = h - 1;
301
+ break;
302
+ }
303
+ e >= 1 && (s = t.length - 1);
304
+ const o = Math.min(s + 1, t.length - 1), r = i[s], l = i[o], a = o === s ? 0 : f((e - r) / Math.max(l - r, Number.EPSILON), 0, 1);
305
+ return {
306
+ progress: e,
307
+ index: s,
308
+ nextIndex: o,
309
+ segmentProgress: a,
310
+ position: H(t[s].position, t[o].position, a),
311
+ track: t[s]
312
+ };
313
+ }
314
+ function ot(t = [], n = 0) {
315
+ if (!t.length) return 0;
316
+ const e = f(Math.floor(u(n, 0)), 0, t.length - 1);
317
+ return F(t)[e] || 0;
318
+ }
319
+ function rt(t = [], n) {
320
+ if (!t.length) return -1;
321
+ const e = Date.parse(n);
322
+ return Number.isFinite(e) ? t.reduce((i, s, o) => {
323
+ if (s.timestamp === null) return i;
324
+ const r = Math.abs(s.timestamp - e), l = t[i].timestamp === null ? Number.POSITIVE_INFINITY : Math.abs(t[i].timestamp - e);
325
+ return r < l ? o : i;
326
+ }, 0) : -1;
327
+ }
328
+ function z(t, n, e, i) {
329
+ const s = i / 6371, o = m(e), r = m(n), l = m(t), a = Math.asin(
330
+ Math.sin(r) * Math.cos(s) + Math.cos(r) * Math.sin(s) * Math.cos(o)
331
+ ), h = l + Math.atan2(
332
+ Math.sin(o) * Math.sin(s) * Math.cos(r),
333
+ Math.cos(s) - Math.sin(r) * Math.sin(a)
334
+ );
335
+ return [(N(h) + 540) % 360 - 180, N(a)];
336
+ }
337
+ function at(t, n, e, i = 4) {
338
+ if (!c(e)) return [];
339
+ const s = [], o = f(Math.floor(u(i, 4)), 1, 30);
340
+ for (let r = 0; r < 360; r += o) {
341
+ const l = r < 90 ? e.ne : r < 180 ? e.se : r < 270 ? e.sw : e.nw;
342
+ s.push(z(t, n, r, u(l, 0)));
343
+ }
344
+ return s;
345
+ }
346
+ function lt(t, n, e, i = 6) {
347
+ const s = [], o = f(Math.floor(u(i, 6)), 1, 30);
348
+ for (let r = 0; r < 360; r += o)
349
+ s.push(z(t, n, r, Math.max(u(e, 0), 0)));
350
+ return s;
351
+ }
352
+ function ut(t = [], n = []) {
353
+ const e = t.map((i) => i.position);
354
+ return n.forEach((i) => i.points.forEach((s) => e.push(s.position))), e.length ? e.reduce((i, s) => ({
355
+ west: Math.min(i.west, s[0]),
356
+ south: Math.min(i.south, s[1]),
357
+ east: Math.max(i.east, s[0]),
358
+ north: Math.max(i.north, s[1])
359
+ }), { west: 1 / 0, south: 1 / 0, east: -1 / 0, north: -1 / 0 }) : null;
360
+ }
361
+ function ht(t = {}, n = {}) {
362
+ const e = [t.code, t.name].filter(Boolean).join(" "), i = [n.stage || n.level, n.windSpeed === null ? "" : `${n.windSpeed}m/s`].filter(Boolean).join(" ");
363
+ return [e, i].filter(Boolean).join(`
364
+ `);
365
+ }
366
+ function Z(t = [-180, 180]) {
367
+ if (!Array.isArray(t) || t.length !== 2 || !(Number(t[0]) === -180 && Number(t[1]) === 180 || Number(t[0]) === 0 && Number(t[1]) === 360))
368
+ throw new Error("longitudeRange must be [-180, 180] or [0, 360].");
369
+ return t.map(Number);
370
+ }
371
+ function B(t, n = -180) {
372
+ return n + ((t - n) % 360 + 360) % 360;
373
+ }
374
+ function Q(t, n, e) {
375
+ return t + 360 * Math.round(((n + e) / 2 - t) / 360);
376
+ }
377
+ function X(t, n, e) {
378
+ const i = n - t, s = i / (e - 1), o = Math.max(1e-5, s * 1e-4);
379
+ return Math.abs(i - 360) <= o || Math.abs(i + s - 360) <= o ? 360 : 0;
380
+ }
381
+ function J(t, n, e, i = [-180, 180]) {
382
+ if (e) return { min: i[0], max: i[1] };
383
+ const s = B(t, i[0]);
384
+ return { min: s, max: s + n - t };
385
+ }
386
+ function ct(t, n, e, i = 0) {
387
+ if (i) return { ...t };
388
+ const s = 360 * Math.round((t.min + t.max - (n + e)) / 720), o = [];
389
+ for (const a of [s - 360, s, s + 360]) {
390
+ const h = Math.max(t.min, n + a), d = Math.min(t.max, e + a);
391
+ h < d && o.push({ min: h, max: d });
392
+ }
393
+ if (!o.length) return null;
394
+ const r = Math.min(...o.map((a) => a.min)), l = Math.max(...o.map((a) => a.max));
395
+ return e - n < l - r ? { min: n + s, max: e + s } : { min: r, max: l };
396
+ }
397
+ class dt {
398
+ constructor(n = {}, e = {}) {
399
+ this.rawData = n, this.bound = Array.isArray(n.Bound) ? n.Bound : [], this.data = Array.isArray(n.DataAry) ? n.DataAry : [], this.valid = !1, this.errorMessage = "", this.lonMin = 0, this.latMin = 0, this.lonMax = 0, this.latMax = 0, this.lonCount = 0, this.latCount = 0, this.lonSpan = 0, this.latSpan = 0, this.lonStep = 0, this.latStep = 0, this.valueScale = 1, this.longitudePeriod = 0, this.longitudeRange = [-180, 180], this.flipY = !1;
400
+ try {
401
+ this.longitudeRange = Z(e.longitudeRange);
402
+ } catch (i) {
403
+ this.errorMessage = i.message;
404
+ return;
405
+ }
406
+ this.bound.length ? this.parse() : this.parseComponents(e), this.valid && (this.longitudePeriod = X(this.lonMin, this.lonMax, this.lonCount));
407
+ }
408
+ parse() {
409
+ if (this.bound.length < 6) {
410
+ this.errorMessage = "Wind field Bound must contain at least 6 values.";
411
+ return;
412
+ }
413
+ const [n, e, i, s, o, r, l = 1] = this.bound, a = Number(i) * Number(s) * 2;
414
+ if (!Number.isFinite(Number(n)) || !Number.isFinite(Number(e)) || Number(i) < 2 || Number(s) < 2 || Number(o) <= 0 || Number(r) <= 0 || this.data.length !== a) {
415
+ this.errorMessage = `Invalid wind field data. Expected DataAry length ${a}, got ${this.data.length}.`;
416
+ return;
417
+ }
418
+ this.lonMin = Number(n), this.latMin = Number(e), this.lonCount = Number(i), this.latCount = Number(s), this.lonSpan = Number(o), this.latSpan = Number(r), this.valueScale = Number(l) || 1, this.lonMax = this.lonMin + this.lonSpan, this.latMax = this.latMin + this.latSpan, this.lonStep = this.lonSpan / (this.lonCount - 1), this.latStep = this.latSpan / (this.latCount - 1), this.valid = !0;
419
+ }
420
+ parseComponents(n) {
421
+ const { width: e, height: i, bounds: s = {} } = this.rawData, o = this.rawData.u || this.rawData.U, r = this.rawData.v || this.rawData.V;
422
+ this.u = (o == null ? void 0 : o.array) || o, this.v = (r == null ? void 0 : r.array) || r, this.lonMin = Number(s.west), this.lonMax = Number(s.east), this.latMin = Number(s.south), this.latMax = Number(s.north), this.lonMax < this.lonMin && (this.lonMax += 360), this.lonCount = Number(e), this.latCount = Number(i), this.lonSpan = this.lonMax - this.lonMin, this.latSpan = this.latMax - this.latMin;
423
+ const l = (a) => Array.isArray(a) || ArrayBuffer.isView(a);
424
+ if (!Number.isInteger(this.lonCount) || this.lonCount < 2 || !Number.isInteger(this.latCount) || this.latCount < 2 || ![this.lonMin, this.lonMax, this.latMin, this.latMax].every(Number.isFinite) || this.lonSpan <= 0 || this.latSpan <= 0 || !l(this.u) || !l(this.v) || this.u.length !== this.lonCount * this.latCount || this.v.length !== this.u.length) {
425
+ this.errorMessage = "U/V wind data requires width, height, bounds, u and v.";
426
+ return;
427
+ }
428
+ this.lonStep = this.lonSpan / (this.lonCount - 1), this.latStep = this.latSpan / (this.latCount - 1), this.flipY = n.flipY === !0 || this.rawData.rowOrder === "north-to-south", this.valid = !0;
429
+ }
430
+ normalizeLongitude(n) {
431
+ return this.longitudePeriod ? B(n, this.lonMin) : Q(n, this.lonMin, this.lonMax);
432
+ }
433
+ contains(n, e) {
434
+ const i = this.normalizeLongitude(n);
435
+ return Number.isFinite(n) && Number.isFinite(e) && (this.longitudePeriod > 0 || i >= this.lonMin && i <= this.lonMax) && e >= this.latMin && e <= this.latMax;
436
+ }
437
+ getBounds() {
438
+ const n = J(
439
+ this.lonMin,
440
+ this.lonMax,
441
+ this.longitudePeriod,
442
+ this.longitudeRange
443
+ );
444
+ return {
445
+ west: n.min,
446
+ south: this.latMin,
447
+ east: n.max,
448
+ north: this.latMax
449
+ };
450
+ }
451
+ getCenter() {
452
+ const n = this.getBounds();
453
+ return {
454
+ lon: (n.west + n.east) / 2,
455
+ lat: this.latMin + this.latSpan / 2
456
+ };
457
+ }
458
+ getVector(n, e) {
459
+ if (this.u) {
460
+ const o = (this.flipY ? this.latCount - n - 1 : n) * this.lonCount + e;
461
+ return { u: Number(this.u[o]), v: Number(this.v[o]) };
462
+ }
463
+ const i = (n * this.lonCount + e) * 2;
464
+ return {
465
+ u: Number(this.data[i]) / this.valueScale,
466
+ v: Number(this.data[i + 1]) / this.valueScale
467
+ };
468
+ }
469
+ /**
470
+ * 双线性插值。
471
+ *
472
+ * row 始终按从南到北计算;U/V 的北到南行序在 getVector 中换算。
473
+ * 全球网格跨末列与首列插值,不把 0…359 的最后一度当成无数据区域。
474
+ */
475
+ sample(n, e) {
476
+ if (!this.valid || !this.contains(n, e))
477
+ return null;
478
+ const i = (this.normalizeLongitude(n) - this.lonMin) / this.lonStep, s = (e - this.latMin) / this.latStep, o = this.longitudePeriod ? Math.round(this.longitudePeriod / this.lonStep) : this.lonCount, r = Math.max(0, Math.min(Math.floor(i), o - (this.longitudePeriod ? 1 : 2))), l = Math.max(0, Math.min(Math.floor(s), this.latCount - 2)), a = this.longitudePeriod ? (r + 1) % o : r + 1, h = l + 1, d = Math.max(0, Math.min(i - r, 1)), M = Math.max(0, Math.min(s - l, 1)), g = this.getVector(l, r), b = this.getVector(l, a), x = this.getVector(h, r), I = this.getVector(h, a), E = 1 - d, A = 1 - M, T = E * A, O = d * A, P = E * M, D = d * M, S = g.u * T + b.u * O + x.u * P + I.u * D, w = g.v * T + b.v * O + x.v * P + I.v * D;
479
+ return !Number.isFinite(S) || !Number.isFinite(w) ? null : {
480
+ u: S,
481
+ v: w,
482
+ speed: Math.hypot(S, w)
483
+ };
484
+ }
485
+ }
486
+ export {
487
+ C as R,
488
+ dt as W,
489
+ at as a,
490
+ lt as b,
491
+ st as c,
492
+ ut as d,
493
+ Q as e,
494
+ ht as f,
495
+ ot as g,
496
+ X as h,
497
+ J as i,
498
+ ct as j,
499
+ Z as k,
500
+ U as l,
501
+ et as m,
502
+ it as n,
503
+ rt as r,
504
+ k as s,
505
+ tt as u,
506
+ nt as v,
507
+ B as w
508
+ };
package/dist/assets.js CHANGED
@@ -1,8 +1,8 @@
1
- import { t as r } from "./typhoon-path-BAiUgsJf.js";
2
- const f = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3ccircle%20cx='12'%20cy='12'%20r='11'%20fill='%232f80ed'/%3e%3cpath%20fill='%23ffffff'%20d='M7%203h5l-.7%208.2%203.7-2V12l4-2.2V21H5v-8h1.2L7%203Zm1.9%202-.7%208H7v6h10v-5.8l-4%202.2v-2.8l-4%202.2L9.8%205h-.9Z'/%3e%3cpath%20fill='%23ffffff'%20d='M7%2017h2v2H7zm4%200h2v2h-2zm4%200h2v2h-2z'/%3e%3c/svg%3e", e = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='84'%20height='100'%20viewBox='0%200%2084%20100'%3e%3cdefs%3e%3clinearGradient%20id='pin-gradient'%20x1='0%25'%20y1='0%25'%20x2='100%25'%20y2='100%25'%3e%3cstop%20offset='0%25'%20stop-color='%234fd3ff'%20/%3e%3cstop%20offset='100%25'%20stop-color='%231d79ff'%20/%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20d='M42%204C22.12%204%206%2020.12%206%2040c0%2026%2030.5%2053.2%2034.02%2056.28a3%203%200%200%200%203.96%200C47.5%2093.2%2078%2066%2078%2040%2078%2020.12%2061.88%204%2042%204Z'%20fill='url(%23pin-gradient)'%20stroke='%23d8f0ff'%20stroke-width='3'/%3e%3ccircle%20cx='42'%20cy='39'%20r='15'%20fill='%23ffffff'%20fill-opacity='0.92'/%3e%3ccircle%20cx='42'%20cy='39'%20r='7'%20fill='%231d79ff'/%3e%3c/svg%3e", c = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3ccircle%20cx='12'%20cy='12'%20r='10'%20fill='%232f80ed'/%3e%3ccircle%20cx='12'%20cy='7.5'%20r='1.4'%20fill='%23ffffff'/%3e%3crect%20x='10.8'%20y='10'%20width='2.4'%20height='7'%20rx='1.2'%20fill='%23ffffff'/%3e%3c/svg%3e";
1
+ import { t } from "./typhoon-path-BAiUgsJf.js";
2
+ const e = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cpath%20fill='%23ffffff'%20stroke='%231d4ed8'%20stroke-width='1.4'%20stroke-linejoin='round'%20d='M12%202.6a7.2%207.2%200%200%200-7.2%207.2c0%205.1%205.8%2010.8%206.5%2011.5a1%201%200%200%200%201.4%200c.7-.7%206.5-6.4%206.5-11.5A7.2%207.2%200%200%200%2012%202.6Z'%20/%3e%3ccircle%20cx='12'%20cy='9.8'%20r='3'%20fill='%233b82f6'/%3e%3ccircle%20cx='12'%20cy='9.8'%20r='1.15'%20fill='%23ffffff'/%3e%3c/svg%3e", f = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='84'%20height='100'%20viewBox='0%200%2084%20100'%3e%3cdefs%3e%3clinearGradient%20id='pin-gradient'%20x1='0%25'%20y1='0%25'%20x2='100%25'%20y2='100%25'%3e%3cstop%20offset='0%25'%20stop-color='%234fd3ff'%20/%3e%3cstop%20offset='100%25'%20stop-color='%231d79ff'%20/%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20d='M42%204C22.12%204%206%2020.12%206%2040c0%2026%2030.5%2053.2%2034.02%2056.28a3%203%200%200%200%203.96%200C47.5%2093.2%2078%2066%2078%2040%2078%2020.12%2061.88%204%2042%204Z'%20fill='url(%23pin-gradient)'%20stroke='%23d8f0ff'%20stroke-width='3'/%3e%3ccircle%20cx='42'%20cy='39'%20r='15'%20fill='%23ffffff'%20fill-opacity='0.92'/%3e%3ccircle%20cx='42'%20cy='39'%20r='7'%20fill='%231d79ff'/%3e%3c/svg%3e", c = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3ccircle%20cx='12'%20cy='12'%20r='10'%20fill='%232f80ed'/%3e%3ccircle%20cx='12'%20cy='7.5'%20r='1.4'%20fill='%23ffffff'/%3e%3crect%20x='10.8'%20y='10'%20width='2.4'%20height='7'%20rx='1.2'%20fill='%23ffffff'/%3e%3c/svg%3e";
3
3
  export {
4
- f as gisFactoryMarker,
4
+ e as gisFactoryMarker,
5
5
  c as gisInfoMarker,
6
- e as gisMarkerSample,
7
- r as typhoonPathIcon
6
+ f as gisMarkerSample,
7
+ t as typhoonPathIcon
8
8
  };