@idm-plugin/meteo2 0.8.3 → 0.8.5
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/index.js +289 -284
- package/dist/index.umd.cjs +2 -2
- package/dist/tropicals/src/index.d.ts +6 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var N0 = Object.defineProperty;
|
|
2
2
|
var S0 = (e, M, b) => M in e ? N0(e, M, { enumerable: !0, configurable: !0, writable: !0, value: b }) : e[M] = b;
|
|
3
|
-
var
|
|
3
|
+
var g = (e, M, b) => (S0(e, typeof M != "symbol" ? M + "" : M, b), b);
|
|
4
4
|
import x from "@log4js-node/log4js-api";
|
|
5
5
|
import L from "moment";
|
|
6
|
-
import
|
|
6
|
+
import w from "got";
|
|
7
7
|
import { fetchWeatherApi as v } from "openmeteo";
|
|
8
|
-
import { Meteo2Assist as
|
|
8
|
+
import { Meteo2Assist as D } from "@idm-plugin/meteo";
|
|
9
9
|
import U0 from "xml2js";
|
|
10
10
|
import { LaneHelper as q0 } from "@idm-plugin/geo2";
|
|
11
11
|
let u;
|
|
@@ -15,7 +15,7 @@ try {
|
|
|
15
15
|
} finally {
|
|
16
16
|
}
|
|
17
17
|
var B0 = /* @__PURE__ */ ((e) => (e.Arome = "arome", e.IconEU = "iconEu", e.GFS = "gfs", e.GFSWave = "gfsWave", e.NamConus = "namConus", e.NamHawaii = "namHawaii", e.NamAlaska = "namAlaska", e.Geos5 = "geos5", e))(B0 || {});
|
|
18
|
-
class
|
|
18
|
+
class y0 {
|
|
19
19
|
/**
|
|
20
20
|
* 点查海洋气象要素(全量)
|
|
21
21
|
* @param lng
|
|
@@ -27,18 +27,18 @@ class Q0 {
|
|
|
27
27
|
*/
|
|
28
28
|
static async queryPointMeteo(M, b, z, p = !1, c = "", W = {}) {
|
|
29
29
|
typeof z == "number" && (z = z < 1e12 ? z * 1e3 : z);
|
|
30
|
-
const
|
|
30
|
+
const O = L(z), o = {
|
|
31
31
|
searchParams: {
|
|
32
32
|
lng: M,
|
|
33
33
|
lat: b,
|
|
34
|
-
ts:
|
|
34
|
+
ts: O.valueOf(),
|
|
35
35
|
params: p ? "watertemp" : void 0,
|
|
36
36
|
source: c == null ? void 0 : c.toLowerCase()
|
|
37
37
|
},
|
|
38
38
|
timeout: 3e4
|
|
39
39
|
}, q = L(), R = q.valueOf();
|
|
40
|
-
|
|
41
|
-
const n = "https://aod4idm.idmwx.com/api/ocean/point", Y = await
|
|
40
|
+
O.isBefore(q.subtract(1, "month")) && (u == null || u.warn("[%s] get history meteo on %s: %j", W.requestId, O.format(), o));
|
|
41
|
+
const n = "https://aod4idm.idmwx.com/api/ocean/point", Y = await w.get(n, o).json(), f = L().valueOf();
|
|
42
42
|
if (u == null || u.info("[%s] get meteo(cost: %d ms) from %s with options: %j", W.requestId, f - R, n, o), (Y == null ? void 0 : Y.code) === 0)
|
|
43
43
|
return {
|
|
44
44
|
...Y.data,
|
|
@@ -62,18 +62,18 @@ class Q0 {
|
|
|
62
62
|
*/
|
|
63
63
|
static async queryPointFactor(M, b, z, p = "wind,wave,current,watertemp,visibility", c = "", W = {}) {
|
|
64
64
|
typeof z == "number" && (z = z < 1e12 ? z * 1e3 : z);
|
|
65
|
-
const
|
|
65
|
+
const O = L(z), o = {
|
|
66
66
|
searchParams: {
|
|
67
67
|
lng: M,
|
|
68
68
|
lat: b,
|
|
69
|
-
ts:
|
|
69
|
+
ts: O.valueOf(),
|
|
70
70
|
params: p,
|
|
71
71
|
source: c == null ? void 0 : c.toLowerCase()
|
|
72
72
|
},
|
|
73
73
|
timeout: 3e4
|
|
74
74
|
}, q = L(), R = q.valueOf();
|
|
75
|
-
|
|
76
|
-
const n = "https://aod4idm.idmwx.com/api/ocean/factor", Y = await
|
|
75
|
+
O.isBefore(q.subtract(1, "month")) && (u == null || u.warn("[%s] get history factors on %s: %j", W.requestId, O.format(), o));
|
|
76
|
+
const n = "https://aod4idm.idmwx.com/api/ocean/factor", Y = await w.get(n, o).json(), f = L().valueOf();
|
|
77
77
|
if (u == null || u.info("[%s] get factors(cost: %d ms) from %s with options: %j", W.requestId, f - R, n, o), (Y == null ? void 0 : Y.code) === 0)
|
|
78
78
|
return {
|
|
79
79
|
...Y.data,
|
|
@@ -88,8 +88,8 @@ class Q0 {
|
|
|
88
88
|
static async queryWindyPointForecast(M, b, z, p = {}) {
|
|
89
89
|
const c = "https://api.windy.com/api/point-forecast/v2", W = [];
|
|
90
90
|
try {
|
|
91
|
-
let
|
|
92
|
-
const o = await
|
|
91
|
+
let O = L().valueOf();
|
|
92
|
+
const o = await w.post(c, {
|
|
93
93
|
headers: {
|
|
94
94
|
"Content-Type": "application/json"
|
|
95
95
|
},
|
|
@@ -119,8 +119,8 @@ class Q0 {
|
|
|
119
119
|
}
|
|
120
120
|
}).json();
|
|
121
121
|
let q = L().valueOf();
|
|
122
|
-
u == null || u.info("[%s] get gfs-factors(cost: %d ms) from %s", p.requestId, q -
|
|
123
|
-
const R = await
|
|
122
|
+
u == null || u.info("[%s] get gfs-factors(cost: %d ms) from %s", p.requestId, q - O, c), O = q;
|
|
123
|
+
const R = await w.post(c, {
|
|
124
124
|
headers: {
|
|
125
125
|
"Content-Type": "application/json"
|
|
126
126
|
},
|
|
@@ -133,7 +133,7 @@ class Q0 {
|
|
|
133
133
|
levels: ["surface"]
|
|
134
134
|
}
|
|
135
135
|
}).json();
|
|
136
|
-
q = L().valueOf(), u == null || u.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", p.requestId, q -
|
|
136
|
+
q = L().valueOf(), u == null || u.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", p.requestId, q - O, c);
|
|
137
137
|
for (let Y = 0; Y < o.ts.length; Y++) {
|
|
138
138
|
const f = this.populateUVFactor(o["wind_u-surface"][Y], o["wind_v-surface"][Y], !1, p);
|
|
139
139
|
f.scale = this.calculateBeaufortWindForceScale(f.speed), W.push({
|
|
@@ -175,8 +175,8 @@ class Q0 {
|
|
|
175
175
|
const f = n.find((T) => T.utc === Y.utc);
|
|
176
176
|
Y.wave = f == null ? void 0 : f.wave;
|
|
177
177
|
}
|
|
178
|
-
} catch (
|
|
179
|
-
u.warn("[%s] get-gfs-factor failed: %s", p.requestId,
|
|
178
|
+
} catch (O) {
|
|
179
|
+
u.warn("[%s] get-gfs-factor failed: %s", p.requestId, O);
|
|
180
180
|
}
|
|
181
181
|
return W;
|
|
182
182
|
}
|
|
@@ -188,12 +188,12 @@ class Q0 {
|
|
|
188
188
|
* @param options
|
|
189
189
|
*/
|
|
190
190
|
static populateUVFactor(M, b, z = !1, p = {}) {
|
|
191
|
-
const c = Math.round(Math.sqrt(Math.pow(M, 2) + Math.pow(b, 2)) * 1e4) / 1e4, { degree: W, direction:
|
|
191
|
+
const c = Math.round(Math.sqrt(Math.pow(M, 2) + Math.pow(b, 2)) * 1e4) / 1e4, { degree: W, direction: O } = this.calculateUVDirection(M, b, z, p), o = this.convertMs2Kts(c);
|
|
192
192
|
return {
|
|
193
193
|
speed: c,
|
|
194
194
|
kts: o,
|
|
195
195
|
degree: W,
|
|
196
|
-
direction:
|
|
196
|
+
direction: O,
|
|
197
197
|
eastward: Math.round(M * 1e4) / 1e4,
|
|
198
198
|
northward: Math.round(b * 1e4) / 1e4
|
|
199
199
|
};
|
|
@@ -271,9 +271,9 @@ var Y0 = { exports: {} };
|
|
|
271
271
|
throw new RangeError("invalid coordinates");
|
|
272
272
|
if (90 <= b)
|
|
273
273
|
return "Etc/GMT";
|
|
274
|
-
var W = -1,
|
|
274
|
+
var W = -1, O = 48 * (180 + z) / 360.00000000000006, o = 24 * (90 - b) / 180.00000000000003, q = 0 | O, R = 0 | o, n = 96 * R + 2 * q;
|
|
275
275
|
for (n = 56 * p.charCodeAt(n) + p.charCodeAt(n + 1) - 1995; n + c.length < 3136; )
|
|
276
|
-
n = 56 * p.charCodeAt(n = 8 * (W = W + n + 1) + 4 * (R = 0 | (o = 2 * (o - R) % 2)) + 2 * (q = 0 | (
|
|
276
|
+
n = 56 * p.charCodeAt(n = 8 * (W = W + n + 1) + 4 * (R = 0 | (o = 2 * (o - R) % 2)) + 2 * (q = 0 | (O = 2 * (O - q) % 2)) + 2304) + p.charCodeAt(n + 1) - 1995;
|
|
277
277
|
return c[n + c.length - 3136];
|
|
278
278
|
}
|
|
279
279
|
e.exports = M;
|
|
@@ -291,38 +291,38 @@ var d0 = { exports: {} };
|
|
|
291
291
|
e.exports ? e.exports = b(L) : b(M.moment);
|
|
292
292
|
})(t0, function(M) {
|
|
293
293
|
M.version === void 0 && M.default && (M = M.default);
|
|
294
|
-
var b = "0.5.48", z = {}, p = {}, c = {}, W = {},
|
|
295
|
-
(!M || typeof M.version != "string") &&
|
|
294
|
+
var b = "0.5.48", z = {}, p = {}, c = {}, W = {}, O = {}, o;
|
|
295
|
+
(!M || typeof M.version != "string") && y("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
296
296
|
var q = M.version.split("."), R = +q[0], n = +q[1];
|
|
297
|
-
(R < 2 || R === 2 && n < 6) &&
|
|
298
|
-
function Y(
|
|
299
|
-
return
|
|
297
|
+
(R < 2 || R === 2 && n < 6) && y("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
|
|
298
|
+
function Y(A) {
|
|
299
|
+
return A > 96 ? A - 87 : A > 64 ? A - 29 : A - 48;
|
|
300
300
|
}
|
|
301
|
-
function f(
|
|
302
|
-
var d = 0, a =
|
|
303
|
-
for (
|
|
301
|
+
function f(A) {
|
|
302
|
+
var d = 0, a = A.split("."), X = a[0], i = a[1] || "", S = 1, P, B = 0, E = 1;
|
|
303
|
+
for (A.charCodeAt(0) === 45 && (d = 1, E = -1), d; d < X.length; d++)
|
|
304
304
|
P = Y(X.charCodeAt(d)), B = 60 * B + P;
|
|
305
305
|
for (d = 0; d < i.length; d++)
|
|
306
306
|
S = S / 60, P = Y(i.charCodeAt(d)), B += P * S;
|
|
307
307
|
return B * E;
|
|
308
308
|
}
|
|
309
|
-
function T(
|
|
310
|
-
for (var d = 0; d <
|
|
311
|
-
|
|
309
|
+
function T(A) {
|
|
310
|
+
for (var d = 0; d < A.length; d++)
|
|
311
|
+
A[d] = f(A[d]);
|
|
312
312
|
}
|
|
313
|
-
function t(
|
|
313
|
+
function t(A, d) {
|
|
314
314
|
for (var a = 0; a < d; a++)
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
A[a] = Math.round((A[a - 1] || 0) + A[a] * 6e4);
|
|
316
|
+
A[d - 1] = 1 / 0;
|
|
317
317
|
}
|
|
318
|
-
function V(
|
|
318
|
+
function V(A, d) {
|
|
319
319
|
var a = [], X;
|
|
320
320
|
for (X = 0; X < d.length; X++)
|
|
321
|
-
a[X] =
|
|
321
|
+
a[X] = A[d[X]];
|
|
322
322
|
return a;
|
|
323
323
|
}
|
|
324
|
-
function l(
|
|
325
|
-
var d =
|
|
324
|
+
function l(A) {
|
|
325
|
+
var d = A.split("|"), a = d[2].split(" "), X = d[3].split(""), i = d[4].split(" ");
|
|
326
326
|
return T(a), T(X), T(i), t(i, X.length), {
|
|
327
327
|
name: d[0],
|
|
328
328
|
abbrs: V(d[1].split(" "), X),
|
|
@@ -331,92 +331,92 @@ var d0 = { exports: {} };
|
|
|
331
331
|
population: d[5] | 0
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
|
-
function U(
|
|
335
|
-
|
|
334
|
+
function U(A) {
|
|
335
|
+
A && this._set(l(A));
|
|
336
336
|
}
|
|
337
|
-
function r(
|
|
337
|
+
function r(A, d) {
|
|
338
338
|
var a = d.length;
|
|
339
|
-
if (
|
|
339
|
+
if (A < d[0])
|
|
340
340
|
return 0;
|
|
341
|
-
if (a > 1 && d[a - 1] === 1 / 0 &&
|
|
341
|
+
if (a > 1 && d[a - 1] === 1 / 0 && A >= d[a - 2])
|
|
342
342
|
return a - 1;
|
|
343
|
-
if (
|
|
343
|
+
if (A >= d[a - 1])
|
|
344
344
|
return -1;
|
|
345
345
|
for (var X, i = 0, S = a - 1; S - i > 1; )
|
|
346
|
-
X = Math.floor((i + S) / 2), d[X] <=
|
|
346
|
+
X = Math.floor((i + S) / 2), d[X] <= A ? i = X : S = X;
|
|
347
347
|
return S;
|
|
348
348
|
}
|
|
349
349
|
U.prototype = {
|
|
350
|
-
_set: function(
|
|
351
|
-
this.name =
|
|
350
|
+
_set: function(A) {
|
|
351
|
+
this.name = A.name, this.abbrs = A.abbrs, this.untils = A.untils, this.offsets = A.offsets, this.population = A.population;
|
|
352
352
|
},
|
|
353
|
-
_index: function(
|
|
354
|
-
var d = +
|
|
353
|
+
_index: function(A) {
|
|
354
|
+
var d = +A, a = this.untils, X;
|
|
355
355
|
if (X = r(d, a), X >= 0)
|
|
356
356
|
return X;
|
|
357
357
|
},
|
|
358
358
|
countries: function() {
|
|
359
|
-
var
|
|
359
|
+
var A = this.name;
|
|
360
360
|
return Object.keys(c).filter(function(d) {
|
|
361
|
-
return c[d].zones.indexOf(
|
|
361
|
+
return c[d].zones.indexOf(A) !== -1;
|
|
362
362
|
});
|
|
363
363
|
},
|
|
364
|
-
parse: function(
|
|
365
|
-
var d = +
|
|
364
|
+
parse: function(A) {
|
|
365
|
+
var d = +A, a = this.offsets, X = this.untils, i = X.length - 1, S, P, B, E;
|
|
366
366
|
for (E = 0; E < i; E++)
|
|
367
367
|
if (S = a[E], P = a[E + 1], B = a[E && E - 1], S < P && s.moveAmbiguousForward ? S = P : S > B && s.moveInvalidForward && (S = B), d < X[E] - S * 6e4)
|
|
368
368
|
return a[E];
|
|
369
369
|
return a[i];
|
|
370
370
|
},
|
|
371
|
-
abbr: function(
|
|
372
|
-
return this.abbrs[this._index(
|
|
371
|
+
abbr: function(A) {
|
|
372
|
+
return this.abbrs[this._index(A)];
|
|
373
373
|
},
|
|
374
|
-
offset: function(
|
|
375
|
-
return
|
|
374
|
+
offset: function(A) {
|
|
375
|
+
return y("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(A)];
|
|
376
376
|
},
|
|
377
|
-
utcOffset: function(
|
|
378
|
-
return this.offsets[this._index(
|
|
377
|
+
utcOffset: function(A) {
|
|
378
|
+
return this.offsets[this._index(A)];
|
|
379
379
|
}
|
|
380
380
|
};
|
|
381
|
-
function Z(
|
|
382
|
-
this.name =
|
|
381
|
+
function Z(A, d) {
|
|
382
|
+
this.name = A, this.zones = d;
|
|
383
383
|
}
|
|
384
|
-
function m(
|
|
385
|
-
var d =
|
|
386
|
-
a && a[0] ? (a = a[0].match(/[A-Z]/g), a = a ? a.join("") : void 0) : (a = d.match(/[A-Z]{3,5}/g), a = a ? a[0] : void 0), a === "GMT" && (a = void 0), this.at = +
|
|
384
|
+
function m(A) {
|
|
385
|
+
var d = A.toTimeString(), a = d.match(/\([a-z ]+\)/i);
|
|
386
|
+
a && a[0] ? (a = a[0].match(/[A-Z]/g), a = a ? a.join("") : void 0) : (a = d.match(/[A-Z]{3,5}/g), a = a ? a[0] : void 0), a === "GMT" && (a = void 0), this.at = +A, this.abbr = a, this.offset = A.getTimezoneOffset();
|
|
387
387
|
}
|
|
388
|
-
function G(
|
|
389
|
-
this.zone =
|
|
388
|
+
function G(A) {
|
|
389
|
+
this.zone = A, this.offsetScore = 0, this.abbrScore = 0;
|
|
390
390
|
}
|
|
391
|
-
G.prototype.scoreOffsetAt = function(
|
|
392
|
-
this.offsetScore += Math.abs(this.zone.utcOffset(
|
|
391
|
+
G.prototype.scoreOffsetAt = function(A) {
|
|
392
|
+
this.offsetScore += Math.abs(this.zone.utcOffset(A.at) - A.offset), this.zone.abbr(A.at).replace(/[^A-Z]/g, "") !== A.abbr && this.abbrScore++;
|
|
393
393
|
};
|
|
394
|
-
function I(
|
|
395
|
-
for (var a, X; X = ((d.at -
|
|
396
|
-
a = new m(new Date(
|
|
397
|
-
return
|
|
394
|
+
function I(A, d) {
|
|
395
|
+
for (var a, X; X = ((d.at - A.at) / 12e4 | 0) * 6e4; )
|
|
396
|
+
a = new m(new Date(A.at + X)), a.offset === A.offset ? A = a : d = a;
|
|
397
|
+
return A;
|
|
398
398
|
}
|
|
399
399
|
function C() {
|
|
400
|
-
var
|
|
400
|
+
var A = (/* @__PURE__ */ new Date()).getFullYear() - 2, d = new m(new Date(A, 0, 1)), a = d.offset, X = [d], i, S, P, B;
|
|
401
401
|
for (B = 1; B < 48; B++)
|
|
402
|
-
P = new Date(
|
|
402
|
+
P = new Date(A, B, 1).getTimezoneOffset(), P !== a && (S = new m(new Date(A, B, 1)), i = I(d, S), X.push(i), X.push(new m(new Date(i.at + 6e4))), d = S, a = P);
|
|
403
403
|
for (B = 0; B < 4; B++)
|
|
404
|
-
X.push(new m(new Date(
|
|
404
|
+
X.push(new m(new Date(A + B, 0, 1))), X.push(new m(new Date(A + B, 6, 1)));
|
|
405
405
|
return X;
|
|
406
406
|
}
|
|
407
|
-
function
|
|
408
|
-
return
|
|
407
|
+
function F(A, d) {
|
|
408
|
+
return A.offsetScore !== d.offsetScore ? A.offsetScore - d.offsetScore : A.abbrScore !== d.abbrScore ? A.abbrScore - d.abbrScore : A.zone.population !== d.zone.population ? d.zone.population - A.zone.population : d.zone.name.localeCompare(A.zone.name);
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function Q(A, d) {
|
|
411
411
|
var a, X;
|
|
412
412
|
for (T(d), a = 0; a < d.length; a++)
|
|
413
|
-
X = d[a],
|
|
413
|
+
X = d[a], O[X] = O[X] || {}, O[X][A] = !0;
|
|
414
414
|
}
|
|
415
|
-
function M0(
|
|
416
|
-
var d =
|
|
415
|
+
function M0(A) {
|
|
416
|
+
var d = A.length, a = {}, X = [], i = {}, S, P, B, E;
|
|
417
417
|
for (S = 0; S < d; S++)
|
|
418
|
-
if (B =
|
|
419
|
-
E =
|
|
418
|
+
if (B = A[S].offset, !i.hasOwnProperty(B)) {
|
|
419
|
+
E = O[B] || {};
|
|
420
420
|
for (P in E)
|
|
421
421
|
E.hasOwnProperty(P) && (a[P] = !0);
|
|
422
422
|
i[B] = !0;
|
|
@@ -427,130 +427,130 @@ var d0 = { exports: {} };
|
|
|
427
427
|
}
|
|
428
428
|
function z0() {
|
|
429
429
|
try {
|
|
430
|
-
var
|
|
431
|
-
if (
|
|
432
|
-
var d = W[J(
|
|
430
|
+
var A = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
431
|
+
if (A && A.length > 3) {
|
|
432
|
+
var d = W[J(A)];
|
|
433
433
|
if (d)
|
|
434
434
|
return d;
|
|
435
|
-
|
|
435
|
+
y("Moment Timezone found " + A + " from the Intl api, but did not have that data loaded.");
|
|
436
436
|
}
|
|
437
437
|
} catch {
|
|
438
438
|
}
|
|
439
439
|
var a = C(), X = a.length, i = M0(a), S = [], P, B, E;
|
|
440
440
|
for (B = 0; B < i.length; B++) {
|
|
441
|
-
for (P = new G(
|
|
441
|
+
for (P = new G(_(i[B])), E = 0; E < X; E++)
|
|
442
442
|
P.scoreOffsetAt(a[E]);
|
|
443
443
|
S.push(P);
|
|
444
444
|
}
|
|
445
|
-
return S.sort(
|
|
445
|
+
return S.sort(F), S.length > 0 ? S[0].zone.name : void 0;
|
|
446
446
|
}
|
|
447
|
-
function X0(
|
|
448
|
-
return (!o ||
|
|
447
|
+
function X0(A) {
|
|
448
|
+
return (!o || A) && (o = z0()), o;
|
|
449
449
|
}
|
|
450
|
-
function J(
|
|
451
|
-
return (
|
|
450
|
+
function J(A) {
|
|
451
|
+
return (A || "").toLowerCase().replace(/\//g, "_");
|
|
452
452
|
}
|
|
453
|
-
function A0(
|
|
453
|
+
function A0(A) {
|
|
454
454
|
var d, a, X, i;
|
|
455
|
-
for (typeof
|
|
456
|
-
X =
|
|
455
|
+
for (typeof A == "string" && (A = [A]), d = 0; d < A.length; d++)
|
|
456
|
+
X = A[d].split("|"), a = X[0], i = J(a), z[i] = A[d], W[i] = a, Q(i, X[2].split(" "));
|
|
457
457
|
}
|
|
458
|
-
function
|
|
459
|
-
|
|
460
|
-
var a = z[
|
|
461
|
-
return a instanceof U ? a : typeof a == "string" ? (a = new U(a), z[
|
|
458
|
+
function _(A, d) {
|
|
459
|
+
A = J(A);
|
|
460
|
+
var a = z[A], X;
|
|
461
|
+
return a instanceof U ? a : typeof a == "string" ? (a = new U(a), z[A] = a, a) : p[A] && d !== _ && (X = _(p[A], _)) ? (a = z[A] = new U(), a._set(X), a.name = W[A], a) : null;
|
|
462
462
|
}
|
|
463
463
|
function n0() {
|
|
464
|
-
var
|
|
465
|
-
for (
|
|
466
|
-
W.hasOwnProperty(
|
|
464
|
+
var A, d = [];
|
|
465
|
+
for (A in W)
|
|
466
|
+
W.hasOwnProperty(A) && (z[A] || z[p[A]]) && W[A] && d.push(W[A]);
|
|
467
467
|
return d.sort();
|
|
468
468
|
}
|
|
469
469
|
function L0() {
|
|
470
470
|
return Object.keys(c);
|
|
471
471
|
}
|
|
472
|
-
function c0(
|
|
472
|
+
function c0(A) {
|
|
473
473
|
var d, a, X, i;
|
|
474
|
-
for (typeof
|
|
475
|
-
a =
|
|
474
|
+
for (typeof A == "string" && (A = [A]), d = 0; d < A.length; d++)
|
|
475
|
+
a = A[d].split("|"), X = J(a[0]), i = J(a[1]), p[X] = i, W[X] = a[0], p[i] = X, W[i] = a[1];
|
|
476
476
|
}
|
|
477
|
-
function e0(
|
|
477
|
+
function e0(A) {
|
|
478
478
|
var d, a, X, i;
|
|
479
|
-
if (!(!
|
|
480
|
-
for (d = 0; d <
|
|
481
|
-
i =
|
|
479
|
+
if (!(!A || !A.length))
|
|
480
|
+
for (d = 0; d < A.length; d++)
|
|
481
|
+
i = A[d].split("|"), a = i[0].toUpperCase(), X = i[1].split(" "), c[a] = new Z(
|
|
482
482
|
a,
|
|
483
483
|
X
|
|
484
484
|
);
|
|
485
485
|
}
|
|
486
|
-
function T0(
|
|
487
|
-
return
|
|
486
|
+
function T0(A) {
|
|
487
|
+
return A = A.toUpperCase(), c[A] || null;
|
|
488
488
|
}
|
|
489
|
-
function i0(
|
|
490
|
-
if (
|
|
489
|
+
function i0(A, d) {
|
|
490
|
+
if (A = T0(A), !A)
|
|
491
491
|
return null;
|
|
492
|
-
var a =
|
|
492
|
+
var a = A.zones.sort();
|
|
493
493
|
return d ? a.map(function(X) {
|
|
494
|
-
var i =
|
|
494
|
+
var i = _(X);
|
|
495
495
|
return {
|
|
496
496
|
name: X,
|
|
497
497
|
offset: i.utcOffset(/* @__PURE__ */ new Date())
|
|
498
498
|
};
|
|
499
499
|
}) : a;
|
|
500
500
|
}
|
|
501
|
-
function r0(
|
|
502
|
-
A0(
|
|
501
|
+
function r0(A) {
|
|
502
|
+
A0(A.zones), c0(A.links), e0(A.countries), s.dataVersion = A.version;
|
|
503
503
|
}
|
|
504
|
-
function b0(
|
|
505
|
-
return b0.didShowError || (b0.didShowError = !0,
|
|
504
|
+
function b0(A) {
|
|
505
|
+
return b0.didShowError || (b0.didShowError = !0, y("moment.tz.zoneExists('" + A + "') has been deprecated in favor of !moment.tz.zone('" + A + "')")), !!_(A);
|
|
506
506
|
}
|
|
507
|
-
function p0(
|
|
508
|
-
var d =
|
|
509
|
-
return !!(
|
|
507
|
+
function p0(A) {
|
|
508
|
+
var d = A._f === "X" || A._f === "x";
|
|
509
|
+
return !!(A._a && A._tzm === void 0 && !d);
|
|
510
510
|
}
|
|
511
|
-
function
|
|
512
|
-
typeof console < "u" && typeof console.error == "function" && console.error(
|
|
511
|
+
function y(A) {
|
|
512
|
+
typeof console < "u" && typeof console.error == "function" && console.error(A);
|
|
513
513
|
}
|
|
514
|
-
function s(
|
|
514
|
+
function s(A) {
|
|
515
515
|
var d = Array.prototype.slice.call(arguments, 0, -1), a = arguments[arguments.length - 1], X = M.utc.apply(null, d), i;
|
|
516
|
-
return !M.isMoment(
|
|
516
|
+
return !M.isMoment(A) && p0(X) && (i = _(a)) && X.add(i.parse(X), "minutes"), X.tz(a), X;
|
|
517
517
|
}
|
|
518
|
-
s.version = b, s.dataVersion = "", s._zones = z, s._links = p, s._names = W, s._countries = c, s.add = A0, s.link = c0, s.load = r0, s.zone =
|
|
519
|
-
var
|
|
520
|
-
M.tz = s, M.defaultZone = null, M.updateOffset = function(
|
|
518
|
+
s.version = b, s.dataVersion = "", s._zones = z, s._links = p, s._names = W, s._countries = c, s.add = A0, s.link = c0, s.load = r0, s.zone = _, s.zoneExists = b0, s.guess = X0, s.names = n0, s.Zone = U, s.unpack = l, s.unpackBase60 = f, s.needsOffset = p0, s.moveInvalidForward = !0, s.moveAmbiguousForward = !1, s.countries = L0, s.zonesForCountry = i0;
|
|
519
|
+
var K = M.fn;
|
|
520
|
+
M.tz = s, M.defaultZone = null, M.updateOffset = function(A, d) {
|
|
521
521
|
var a = M.defaultZone, X;
|
|
522
|
-
if (
|
|
523
|
-
if (X =
|
|
524
|
-
var i =
|
|
525
|
-
|
|
522
|
+
if (A._z === void 0 && (a && p0(A) && !A._isUTC && A.isValid() && (A._d = M.utc(A._a)._d, A.utc().add(a.parse(A), "minutes")), A._z = a), A._z)
|
|
523
|
+
if (X = A._z.utcOffset(A), Math.abs(X) < 16 && (X = X / 60), A.utcOffset !== void 0) {
|
|
524
|
+
var i = A._z;
|
|
525
|
+
A.utcOffset(-X, d), A._z = i;
|
|
526
526
|
} else
|
|
527
|
-
|
|
528
|
-
},
|
|
529
|
-
if (
|
|
530
|
-
if (typeof
|
|
531
|
-
throw new Error("Time zone name must be a string, got " +
|
|
532
|
-
return this._z =
|
|
527
|
+
A.zone(X, d);
|
|
528
|
+
}, K.tz = function(A, d) {
|
|
529
|
+
if (A) {
|
|
530
|
+
if (typeof A != "string")
|
|
531
|
+
throw new Error("Time zone name must be a string, got " + A + " [" + typeof A + "]");
|
|
532
|
+
return this._z = _(A), this._z ? M.updateOffset(this, d) : y("Moment Timezone has no data for " + A + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
|
|
533
533
|
}
|
|
534
534
|
if (this._z)
|
|
535
535
|
return this._z.name;
|
|
536
536
|
};
|
|
537
|
-
function W0(
|
|
537
|
+
function W0(A) {
|
|
538
538
|
return function() {
|
|
539
|
-
return this._z ? this._z.abbr(this) :
|
|
539
|
+
return this._z ? this._z.abbr(this) : A.call(this);
|
|
540
540
|
};
|
|
541
541
|
}
|
|
542
|
-
function o0(
|
|
542
|
+
function o0(A) {
|
|
543
543
|
return function() {
|
|
544
|
-
return this._z = null,
|
|
544
|
+
return this._z = null, A.apply(this, arguments);
|
|
545
545
|
};
|
|
546
546
|
}
|
|
547
|
-
function f0(
|
|
547
|
+
function f0(A) {
|
|
548
548
|
return function() {
|
|
549
|
-
return arguments.length > 0 && (this._z = null),
|
|
549
|
+
return arguments.length > 0 && (this._z = null), A.apply(this, arguments);
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
|
-
|
|
553
|
-
return (R < 2 || R === 2 && n < 9) &&
|
|
552
|
+
K.zoneName = W0(K.zoneName), K.zoneAbbr = W0(K.zoneAbbr), K.utc = o0(K.utc), K.local = o0(K.local), K.utcOffset = f0(K.utcOffset), M.tz.setDefault = function(A) {
|
|
553
|
+
return (R < 2 || R === 2 && n < 9) && y("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = A ? _(A) : null, M;
|
|
554
554
|
};
|
|
555
555
|
var $ = M.momentProperties;
|
|
556
556
|
return Object.prototype.toString.call($) === "[object Array]" ? ($.push("_z"), $.push("_a")) : $ && ($._z = null), M;
|
|
@@ -1418,11 +1418,11 @@ try {
|
|
|
1418
1418
|
} catch {
|
|
1419
1419
|
} finally {
|
|
1420
1420
|
}
|
|
1421
|
-
class
|
|
1421
|
+
class Q0 {
|
|
1422
1422
|
constructor(M, b) {
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1423
|
+
g(this, "apikey");
|
|
1424
|
+
g(this, "debug");
|
|
1425
|
+
g(this, "FORECAST", {
|
|
1426
1426
|
OM_URL: "https://customer-api.open-meteo.com/v1/forecast",
|
|
1427
1427
|
ORM_URL: "https://meteo3.idmwx.com/v1/forecast",
|
|
1428
1428
|
ORM_HISTORY_URL: "https://meteo1.idmwx.com/v1/forecast",
|
|
@@ -1441,40 +1441,40 @@ class y0 {
|
|
|
1441
1441
|
HOURLY: "wave_height,wave_direction,wave_period,wind_wave_height,wind_wave_direction,wind_wave_period,wind_wave_peak_period,swell_wave_height,swell_wave_direction,swell_wave_period,swell_wave_peak_period,ocean_current_velocity,ocean_current_direction,sea_level_height_msl,sea_surface_temperature"
|
|
1442
1442
|
}
|
|
1443
1443
|
});
|
|
1444
|
-
|
|
1444
|
+
g(this, "HISTORICAL", {
|
|
1445
1445
|
OM_URL: "https://customer-archive-api.open-meteo.com/v1/archive",
|
|
1446
1446
|
WEATHER_VARIABLES: {
|
|
1447
1447
|
HOURLY: "temperature_2m,apparent_temperature,precipitation,weather_code,pressure_msl,surface_pressure,wind_speed_10m,wind_direction_10m,wind_gusts_10m",
|
|
1448
1448
|
DAILY: "weather_code,temperature_2m_max,temperature_2m_min,temperature_2m_mean,precipitation_sum,precipitation_hours,wind_speed_10m_max,wind_gusts_10m_max,wind_direction_10m_dominant"
|
|
1449
1449
|
}
|
|
1450
1450
|
});
|
|
1451
|
-
|
|
1451
|
+
g(this, "CLIMATE", {
|
|
1452
1452
|
OM_URL: "https://customer-climate-api.open-meteo.com/v1/climate",
|
|
1453
1453
|
WEATHER_VARIABLES: {
|
|
1454
1454
|
DAILY: "temperature_2m_mean,temperature_2m_max,temperature_2m_min,wind_speed_10m_mean,wind_speed_10m_max,relative_humidity_2m_mean,relative_humidity_2m_max,relative_humidity_2m_min,precipitation_sum"
|
|
1455
1455
|
}
|
|
1456
1456
|
});
|
|
1457
|
-
|
|
1457
|
+
g(this, "SEASONAL", {
|
|
1458
1458
|
OM_URL: "https://seasonal-api.open-meteo.com/v1/seasonal",
|
|
1459
1459
|
WEATHER_VARIABLES: {
|
|
1460
1460
|
DAILY: "temperature_2m_max,temperature_2m_min,precipitation_sum,precipitation_hours,wind_direction_10m_dominant,wind_speed_10m_max",
|
|
1461
1461
|
SIX_HOURLY: "pressure_msl,temperature_2m,temperature_2m_max,temperature_2m_min,precipitation,wind_direction_10m,wind_speed_10m,relative_humidity_2m,showers,cloud_cover"
|
|
1462
1462
|
}
|
|
1463
1463
|
});
|
|
1464
|
-
|
|
1464
|
+
g(this, "METEO2_UPDATE", {
|
|
1465
1465
|
etime: L().unix(),
|
|
1466
1466
|
version: 0
|
|
1467
1467
|
});
|
|
1468
1468
|
this.apikey = M || "smE3JnDLHy3TizVv", this.debug = b;
|
|
1469
1469
|
}
|
|
1470
1470
|
async standardWeatherModels() {
|
|
1471
|
-
return
|
|
1471
|
+
return D.standardWeatherModels();
|
|
1472
1472
|
}
|
|
1473
1473
|
async standardMarineModels() {
|
|
1474
|
-
return
|
|
1474
|
+
return D.standardMarineModels();
|
|
1475
1475
|
}
|
|
1476
1476
|
async autoPickMeteoModel(M = "best_match") {
|
|
1477
|
-
return
|
|
1477
|
+
return D.autoPickMeteoModel(M);
|
|
1478
1478
|
}
|
|
1479
1479
|
range(M, b, z) {
|
|
1480
1480
|
return Array.from({ length: (b - M) / z }, (p, c) => M + c * z);
|
|
@@ -1491,14 +1491,14 @@ class y0 {
|
|
|
1491
1491
|
if (M.start_dates instanceof Array)
|
|
1492
1492
|
for (let W = 0; W < M.start_dates.length; W++) {
|
|
1493
1493
|
M.start_date = M.start_dates[W], M.end_date = M.end_dates[W], M.fake = M.fakes[W];
|
|
1494
|
-
const
|
|
1495
|
-
this.debug && h.debug("[%s] fetch weather via %s with %j", b.requestId,
|
|
1494
|
+
const O = M.url[W];
|
|
1495
|
+
this.debug && h.debug("[%s] fetch weather via %s with %j", b.requestId, O, {
|
|
1496
1496
|
start_date: M.start_date,
|
|
1497
1497
|
end_date: M.end_date,
|
|
1498
1498
|
fake: M.fake,
|
|
1499
1499
|
step: W
|
|
1500
1500
|
});
|
|
1501
|
-
const o = await v(
|
|
1501
|
+
const o = await v(O, M), q = await this.parseWeatherData(o, M, b);
|
|
1502
1502
|
p ? await this.mergeSegments(p, q) : p = q;
|
|
1503
1503
|
}
|
|
1504
1504
|
else {
|
|
@@ -1529,7 +1529,7 @@ class y0 {
|
|
|
1529
1529
|
* @param options
|
|
1530
1530
|
*/
|
|
1531
1531
|
async marineForecast(M, b = {}) {
|
|
1532
|
-
var z, p, c, W,
|
|
1532
|
+
var z, p, c, W, O, o, q, R;
|
|
1533
1533
|
try {
|
|
1534
1534
|
const n = L();
|
|
1535
1535
|
let Y;
|
|
@@ -1554,7 +1554,7 @@ class y0 {
|
|
|
1554
1554
|
const f = L();
|
|
1555
1555
|
this.debug && h.info("[%s] fetch marine api (%j) cost: %d ms", b.requestId, M.url, f.diff(n, "ms"));
|
|
1556
1556
|
const T = await this.mergeMarineData(Y), t = T.find((r) => r.model === "ncep_gfswave016"), V = T.find((r) => r.model === "ncep_gfswave025"), l = T.find((r) => r.model === "meteofrance_wave"), U = T.find((r) => r.model === "best_match");
|
|
1557
|
-
return (p = (z = U == null ? void 0 : U.hourly) == null ? void 0 : z.wave_height) != null && p.every((r) => r !== null) ? [U] : (W = (c = l == null ? void 0 : l.hourly) == null ? void 0 : c.wave_height) != null && W.every((r) => r !== null) ? [l] : (o = (
|
|
1557
|
+
return (p = (z = U == null ? void 0 : U.hourly) == null ? void 0 : z.wave_height) != null && p.every((r) => r !== null) ? [U] : (W = (c = l == null ? void 0 : l.hourly) == null ? void 0 : c.wave_height) != null && W.every((r) => r !== null) ? [l] : (o = (O = t == null ? void 0 : t.hourly) == null ? void 0 : O.wave_height) != null && o.every((r) => r !== null) ? [t] : (R = (q = V == null ? void 0 : V.hourly) == null ? void 0 : q.wave_height) != null && R.every((r) => r !== null) ? [V] : T != null && T.length ? [T[0]] : [];
|
|
1558
1558
|
} catch (n) {
|
|
1559
1559
|
return h.warn("[%s] marine forecast failed: %s, with %j", b.requestId, n, M), [];
|
|
1560
1560
|
}
|
|
@@ -1567,7 +1567,7 @@ class y0 {
|
|
|
1567
1567
|
* @private
|
|
1568
1568
|
*/
|
|
1569
1569
|
async parseWeatherData(M, b, z = {}) {
|
|
1570
|
-
var W,
|
|
1570
|
+
var W, O, o, q, R, n, Y;
|
|
1571
1571
|
const p = [], c = Math.pow(10, z.precision || 6);
|
|
1572
1572
|
for (let f = 0; f < M.length; f++) {
|
|
1573
1573
|
const T = M[f], t = T.utcOffsetSeconds(), V = T.timezone(), l = T.current(), U = T.hourly(), r = T.daily(), Z = {};
|
|
@@ -1592,8 +1592,8 @@ class y0 {
|
|
|
1592
1592
|
)
|
|
1593
1593
|
};
|
|
1594
1594
|
for (let C = 0; C < U.variablesLength(); C++) {
|
|
1595
|
-
const
|
|
1596
|
-
Z.hourly[b.hourly[C]] =
|
|
1595
|
+
const F = (q = (o = (O = U.variables(C).valuesArray()) == null ? void 0 : O.toString()) == null ? void 0 : o.split(",")) == null ? void 0 : q.map((Q) => isNaN(Q) ? null : Math.round(Number(Q) * c) / c);
|
|
1596
|
+
Z.hourly[b.hourly[C]] = F;
|
|
1597
1597
|
}
|
|
1598
1598
|
const I = L();
|
|
1599
1599
|
this.debug && h.debug("[%s] fetch hourly variables cost: %d ms", z.requestId, I.diff(m, "ms"));
|
|
@@ -1606,7 +1606,7 @@ class y0 {
|
|
|
1606
1606
|
)
|
|
1607
1607
|
};
|
|
1608
1608
|
for (let I = 0; I < r.variablesLength(); I += z.memberLength ?? 1) {
|
|
1609
|
-
const C = (Y = (n = (R = r.variables(I).valuesArray()) == null ? void 0 : R.toString()) == null ? void 0 : n.split(",")) == null ? void 0 : Y.map((
|
|
1609
|
+
const C = (Y = (n = (R = r.variables(I).valuesArray()) == null ? void 0 : R.toString()) == null ? void 0 : n.split(",")) == null ? void 0 : Y.map((F) => isNaN(F) ? null : Math.round(Number(F) * c) / c);
|
|
1610
1610
|
Z.daily[b.daily[I / (z.memberLength ?? 1)]] = C;
|
|
1611
1611
|
}
|
|
1612
1612
|
const G = L();
|
|
@@ -1628,9 +1628,9 @@ class y0 {
|
|
|
1628
1628
|
for (let W = M[z][p][c].length; W < b[z][p][c].length; W++)
|
|
1629
1629
|
M[z][p][c].push(b[z][p][c][W]);
|
|
1630
1630
|
} else {
|
|
1631
|
-
const W = L(b[z][p].date),
|
|
1631
|
+
const W = L(b[z][p].date), O = L(M[z][p].date);
|
|
1632
1632
|
for (let o = 0; o < b[z][p][c].length; o++) {
|
|
1633
|
-
const q = W.clone().add(o, "h").diff(
|
|
1633
|
+
const q = W.clone().add(o, "h").diff(O, "h");
|
|
1634
1634
|
q < M[z][p][c].length ? M[z][p][c][q] === null && (M[z][p][c][q] = b[z][p][c][o]) : c === "time" ? M[z][p][c].push(q) : M[z][p][c].push(b[z][p][c][o]);
|
|
1635
1635
|
}
|
|
1636
1636
|
}
|
|
@@ -1645,12 +1645,12 @@ class y0 {
|
|
|
1645
1645
|
return M;
|
|
1646
1646
|
}
|
|
1647
1647
|
async mergeMarineData(M) {
|
|
1648
|
-
var c, W,
|
|
1648
|
+
var c, W, O, o;
|
|
1649
1649
|
const b = [], z = M.find((q) => q.model === "best_match");
|
|
1650
1650
|
z && b.push(z);
|
|
1651
1651
|
const p = M.find((q) => q.model === "meteofrance_currents");
|
|
1652
1652
|
for (const q of M)
|
|
1653
|
-
["best_match", "meteofrance_currents"].includes(q.model) || (q.hourly.ocean_current_velocity = (c = p == null ? void 0 : p.hourly) == null ? void 0 : c.ocean_current_velocity, q.hourly.ocean_current_direction = (W = p == null ? void 0 : p.hourly) == null ? void 0 : W.ocean_current_direction, q.hourly.sea_level_height_msl = (
|
|
1653
|
+
["best_match", "meteofrance_currents"].includes(q.model) || (q.hourly.ocean_current_velocity = (c = p == null ? void 0 : p.hourly) == null ? void 0 : c.ocean_current_velocity, q.hourly.ocean_current_direction = (W = p == null ? void 0 : p.hourly) == null ? void 0 : W.ocean_current_direction, q.hourly.sea_level_height_msl = (O = p == null ? void 0 : p.hourly) == null ? void 0 : O.sea_level_height_msl, q.hourly.sea_surface_temperature = (o = p == null ? void 0 : p.hourly) == null ? void 0 : o.sea_surface_temperature, b.push(q));
|
|
1654
1654
|
return b;
|
|
1655
1655
|
}
|
|
1656
1656
|
pickForecastUrl(M, b, z, p = {}) {
|
|
@@ -1662,13 +1662,13 @@ class y0 {
|
|
|
1662
1662
|
if (!(b != null && b.length))
|
|
1663
1663
|
return ["best_match"];
|
|
1664
1664
|
const z = [];
|
|
1665
|
-
for (let
|
|
1666
|
-
const o = b[
|
|
1665
|
+
for (let O = 0; O < b.length; O++) {
|
|
1666
|
+
const o = b[O];
|
|
1667
1667
|
["ecmwf_wam025", "meteofrance_wave", "ewam", "gwam", "era5_ocean"].includes(o) ? z.push("meteofrance_currents", o) : ["gfswave", "ncep_gfswave025", "ncep_gfswave016"].includes(o) ? z.push("meteofrance_currents", "ncep_gfswave025", "ncep_gfswave016") : z.push("best_match");
|
|
1668
1668
|
}
|
|
1669
|
-
const p = z.reduce((
|
|
1670
|
-
return p.sort((
|
|
1671
|
-
const q = c.indexOf(
|
|
1669
|
+
const p = z.reduce((O, o) => (O.includes(o) || O.push(o), O), []), c = ["best_match", "meteofrance_currents", "meteofrance_wave", "ecmwf_wam025", "ncep_gfswave025", "gwam", "era5_ocean", "ewam", "ncep_gfswave016"];
|
|
1670
|
+
return p.sort((O, o) => {
|
|
1671
|
+
const q = c.indexOf(O), R = c.indexOf(o);
|
|
1672
1672
|
return q - R;
|
|
1673
1673
|
}), p;
|
|
1674
1674
|
}
|
|
@@ -1681,21 +1681,21 @@ class y0 {
|
|
|
1681
1681
|
* @private
|
|
1682
1682
|
*/
|
|
1683
1683
|
async prepare(M, b, z, p = {}) {
|
|
1684
|
-
var
|
|
1685
|
-
const c = L.utc(),
|
|
1684
|
+
var R, n;
|
|
1685
|
+
const c = p.maxDays || 14, W = L.utc(), O = M ? L.utc(M) : void 0, o = b ? await this.pickUpdateMeta(z.models) : [], q = (n = (R = o[0]) == null ? void 0 : R.meta) != null && n.endTime ? L(o[0].meta.endTime) : W.clone().add(c, "day");
|
|
1686
1686
|
if (M) {
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
], z.end_dates = [
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
], z.end_dates = [
|
|
1687
|
+
const Y = O.clone().utc().add(p.forecastDays ?? 1, "day");
|
|
1688
|
+
Y.isAfter(q) ? (Y.subtract(1, "year"), O.isAfter(q) ? (O.subtract(1, "year"), z.start_dates = [
|
|
1689
|
+
O.clone().subtract(p.pastDays || 0, "day").utc().format("YYYY-MM-DD")
|
|
1690
|
+
], z.end_dates = [Y.utc().format("YYYY-MM-DD")], z.fakes = [!0], z.url = [this.pickForecastUrl(b, p.selfHosted ?? !0, !0, p)]) : (z.start_dates = [
|
|
1691
|
+
O.clone().subtract(p.pastDays || 0, "day").utc().format("YYYY-MM-DD"),
|
|
1692
|
+
q.clone().subtract(1, "year").subtract(1, "day").utc().format("YYYY-MM-DD")
|
|
1693
|
+
], z.end_dates = [q.clone().subtract(1, "day").utc().format("YYYY-MM-DD"), Y.utc().format("YYYY-MM-DD")], z.fakes = [!1, !0], z.url = [
|
|
1694
1694
|
this.pickForecastUrl(b, p.selfHosted ?? !0, !1, p),
|
|
1695
1695
|
this.pickForecastUrl(b, p.selfHosted ?? !0, !0, p)
|
|
1696
1696
|
])) : (z.start_dates = [
|
|
1697
|
-
|
|
1698
|
-
], z.end_dates = [
|
|
1697
|
+
O.clone().subtract(p.pastDays || 0, "day").utc().format("YYYY-MM-DD")
|
|
1698
|
+
], z.end_dates = [Y.utc().format("YYYY-MM-DD")], z.fakes = [!1], z.url = [this.pickForecastUrl(b, p.selfHosted ?? !0, O.isBefore(W.clone().subtract(30, "day")), p)]);
|
|
1699
1699
|
} else
|
|
1700
1700
|
z.forecast_days = p.forecastDays, z.past_days = p.pastDays, z.fake = !1, z.url = this.pickForecastUrl(b, p.selfHosted ?? !0, !1, p);
|
|
1701
1701
|
return z;
|
|
@@ -1745,38 +1745,39 @@ class y0 {
|
|
|
1745
1745
|
* @param withHourly
|
|
1746
1746
|
* @param options
|
|
1747
1747
|
*/
|
|
1748
|
-
async spotForecast(M, b, z, p = !0, c = !0, W = !1,
|
|
1748
|
+
async spotForecast(M, b, z, p = !0, c = !0, W = !1, O = {
|
|
1749
1749
|
forecastDays: 1,
|
|
1750
1750
|
pastDays: 0,
|
|
1751
1751
|
precision: 6,
|
|
1752
|
-
selfHosted: !0
|
|
1752
|
+
selfHosted: !0,
|
|
1753
|
+
maxDays: 14
|
|
1753
1754
|
}) {
|
|
1754
1755
|
var T, t, V, l, U, r;
|
|
1755
|
-
b = this.toStdLng(b), this.debug && h.info("[%s] spot forecast params: %j",
|
|
1756
|
+
b = this.toStdLng(b), this.debug && h.info("[%s] spot forecast params: %j", O.requestId, { lat: M, lng: b, datetime: z, simplify: p, withDaily: c, withHourly: W, options: O });
|
|
1756
1757
|
const o = {
|
|
1757
1758
|
apikey: this.apikey,
|
|
1758
1759
|
latitude: M,
|
|
1759
1760
|
longitude: b,
|
|
1760
1761
|
cell_selection: "sea",
|
|
1761
1762
|
wind_speed_unit: "kn",
|
|
1762
|
-
models: ((T =
|
|
1763
|
+
models: ((T = O.weatherModels) == null ? void 0 : T.split(",")) || ["best_match"],
|
|
1763
1764
|
timezone: "auto"
|
|
1764
1765
|
};
|
|
1765
1766
|
let q;
|
|
1766
1767
|
const R = this.timezoneOffset(M, b);
|
|
1767
|
-
z && (q = L.utc(z).utcOffset(R), q.subtract(R > 0 ? R : -R, "h"),
|
|
1768
|
-
const n = await this.weatherForecast(o,
|
|
1768
|
+
z && (q = L.utc(z).utcOffset(R), q.subtract(R > 0 ? R : -R, "h"), O.selfHistory = !(q != null && q.isBefore(L.utc().subtract(120, "days")))), c && (o.daily = ((t = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : t.split(",")) || []), q || (O.forecastDays = O.forecastDays || 1, O.pastDays = 0, W = !0), W && (o.hourly = ((V = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : V.split(",")) || []), O.maxDays = O.maxDays || 14, O.pastDays = O.pastDays || 0, O.pastDays = O.pastDays > 7 ? 7 : O.pastDays < 0 ? 0 : O.pastDays, O.forecastDays = O.forecastDays ?? 1, O.forecastDays = O.forecastDays > O.maxDays ? O.maxDays : O.forecastDays < 0 ? 1 : O.forecastDays, await this.prepare(q == null ? void 0 : q.utc().format(), !1, o, O);
|
|
1769
|
+
const n = await this.weatherForecast(o, O), Y = {
|
|
1769
1770
|
apikey: this.apikey,
|
|
1770
1771
|
latitude: M,
|
|
1771
1772
|
longitude: b,
|
|
1772
1773
|
cell_selection: "sea",
|
|
1773
1774
|
timezone: "auto",
|
|
1774
1775
|
wind_speed_unit: "kn",
|
|
1775
|
-
models: this.pickMarineModels(
|
|
1776
|
+
models: this.pickMarineModels(O.marineModels)
|
|
1776
1777
|
};
|
|
1777
|
-
c && (Y.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), q || (
|
|
1778
|
-
let f = await this.marineForecast(Y,
|
|
1779
|
-
return (r = (U = (l = f[0]) == null ? void 0 : l.hourly) == null ? void 0 : U.wave_height) != null && r.every((Z) => Z === null || Z === 0) && (Y.models = this.pickMarineModels("best_match,ncep_gfswave025,meteofrance_wave"), f = await this.marineForecast(Y,
|
|
1778
|
+
c && (Y.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), q || (O.forecastDays = O.forecastDays || 1, W = !0), W && (Y.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), await this.prepare(q == null ? void 0 : q.utc().format(), !0, Y, O);
|
|
1779
|
+
let f = await this.marineForecast(Y, O);
|
|
1780
|
+
return (r = (U = (l = f[0]) == null ? void 0 : l.hourly) == null ? void 0 : U.wave_height) != null && r.every((Z) => Z === null || Z === 0) && (Y.models = this.pickMarineModels("best_match,ncep_gfswave025,meteofrance_wave"), f = await this.marineForecast(Y, O)), { weather: n, marine: f };
|
|
1780
1781
|
}
|
|
1781
1782
|
/**
|
|
1782
1783
|
* 历史再分析数据
|
|
@@ -1799,11 +1800,11 @@ class y0 {
|
|
|
1799
1800
|
* @param withMarine
|
|
1800
1801
|
* @param options
|
|
1801
1802
|
*/
|
|
1802
|
-
async spotHistorical(M, b, z, p, c = !0, W = !0,
|
|
1803
|
+
async spotHistorical(M, b, z, p, c = !0, W = !0, O = !1, o = {
|
|
1803
1804
|
precision: 6
|
|
1804
1805
|
}) {
|
|
1805
1806
|
var t, V;
|
|
1806
|
-
b = this.toStdLng(b), this.debug && h.info("[%s] spot historical params: %j", o.requestId, { lat: M, lng: b, startDate: z, endDate: p, withMarine:
|
|
1807
|
+
b = this.toStdLng(b), this.debug && h.info("[%s] spot historical params: %j", o.requestId, { lat: M, lng: b, startDate: z, endDate: p, withMarine: O, options: o });
|
|
1807
1808
|
const q = this.timezoneOffset(M, b), R = L.utc(z).utcOffset(q), n = L.utc(p).utcOffset(q);
|
|
1808
1809
|
R.subtract(q > 0 ? q : -q, "h"), n.subtract(q > 0 ? q : -q, "h");
|
|
1809
1810
|
const Y = {
|
|
@@ -1821,7 +1822,7 @@ class y0 {
|
|
|
1821
1822
|
c && (Y.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), W && (Y.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
|
|
1822
1823
|
const f = await this.weatherForecast(Y, o);
|
|
1823
1824
|
let T;
|
|
1824
|
-
if (
|
|
1825
|
+
if (O) {
|
|
1825
1826
|
const l = {
|
|
1826
1827
|
apikey: this.apikey,
|
|
1827
1828
|
latitude: M,
|
|
@@ -1855,8 +1856,8 @@ class y0 {
|
|
|
1855
1856
|
precision: 6
|
|
1856
1857
|
}) {
|
|
1857
1858
|
b = this.toStdLng(b), this.debug && h.info("[%s] spot seasonal params: %j", W.requestId, { lat: M, lng: b, startDate: z, endDate: p, options: W });
|
|
1858
|
-
const
|
|
1859
|
-
o.subtract(
|
|
1859
|
+
const O = this.timezoneOffset(M, b), o = L.utc(z).utcOffset(O), q = p ? L.utc(p).utcOffset(O) : o.clone().add(1, "month");
|
|
1860
|
+
o.subtract(O > 0 ? O : -O, "h"), q.subtract(O > 0 ? O : -O, "h");
|
|
1860
1861
|
const R = {
|
|
1861
1862
|
apikey: this.apikey,
|
|
1862
1863
|
latitude: M,
|
|
@@ -1896,8 +1897,8 @@ class y0 {
|
|
|
1896
1897
|
}) {
|
|
1897
1898
|
var n;
|
|
1898
1899
|
b = this.toStdLng(b), this.debug && h.info("[%s] spot climate params: %j", c.requestId, { lat: M, lng: b, startDate: z, endDate: p, options: c });
|
|
1899
|
-
const W = this.timezoneOffset(M, b),
|
|
1900
|
-
o.subtract(W > 0 ? W : -W, "h"),
|
|
1900
|
+
const W = this.timezoneOffset(M, b), O = L.utc(z).utcOffset(W), o = p ? L.utc(p).utcOffset(W) : O.clone().add(1, "day");
|
|
1901
|
+
o.subtract(W > 0 ? W : -W, "h"), O.subtract(W > 0 ? W : -W, "h");
|
|
1901
1902
|
const q = {
|
|
1902
1903
|
apikey: this.apikey,
|
|
1903
1904
|
latitude: M,
|
|
@@ -1907,7 +1908,7 @@ class y0 {
|
|
|
1907
1908
|
models: ((n = c.weatherModels) == null ? void 0 : n.split(",")) || "EC_Earth3P_HR",
|
|
1908
1909
|
timezone: "auto",
|
|
1909
1910
|
url: this.CLIMATE.OM_URL,
|
|
1910
|
-
start_date:
|
|
1911
|
+
start_date: O.format("YYYY-MM-DD"),
|
|
1911
1912
|
end_date: o.format("YYYY-MM-DD"),
|
|
1912
1913
|
daily: this.CLIMATE.WEATHER_VARIABLES.DAILY.split(",")
|
|
1913
1914
|
};
|
|
@@ -1923,11 +1924,11 @@ class y0 {
|
|
|
1923
1924
|
}
|
|
1924
1925
|
});
|
|
1925
1926
|
try {
|
|
1926
|
-
const
|
|
1927
|
-
if (
|
|
1928
|
-
const o =
|
|
1927
|
+
const O = await W.json();
|
|
1928
|
+
if (O.code === 0) {
|
|
1929
|
+
const o = O.data, q = D.standardWeatherModels();
|
|
1929
1930
|
for (const R of q) {
|
|
1930
|
-
const n =
|
|
1931
|
+
const n = D.autoPickSubCategories(R.alias), f = o.filter((T) => n.includes(T.category)).map((T) => {
|
|
1931
1932
|
var U, r, Z, m, G, I;
|
|
1932
1933
|
const t = L.unix((U = T.meta) == null ? void 0 : U.data_end_time).utc(), V = L.unix((r = T.meta) == null ? void 0 : r.last_run_availability_time).utc(), l = t.diff(V, "days");
|
|
1933
1934
|
return {
|
|
@@ -1947,8 +1948,8 @@ class y0 {
|
|
|
1947
1948
|
}
|
|
1948
1949
|
this.METEO2_UPDATE.version = z + 1, this.METEO2_UPDATE.etime = p.unix();
|
|
1949
1950
|
}
|
|
1950
|
-
} catch (
|
|
1951
|
-
h.error("[%s] update meteo2 error: %s", M.requestId,
|
|
1951
|
+
} catch (O) {
|
|
1952
|
+
h.error("[%s] update meteo2 error: %s", M.requestId, O);
|
|
1952
1953
|
}
|
|
1953
1954
|
}
|
|
1954
1955
|
return this.METEO2_UPDATE;
|
|
@@ -1972,8 +1973,8 @@ try {
|
|
|
1972
1973
|
}
|
|
1973
1974
|
class k0 {
|
|
1974
1975
|
constructor(M, b) {
|
|
1975
|
-
|
|
1976
|
-
|
|
1976
|
+
g(this, "apikey");
|
|
1977
|
+
g(this, "debug");
|
|
1977
1978
|
this.apikey = M || "aaf294e6-be27-40b8-82cb-0d7844d2dd74", this.debug = b;
|
|
1978
1979
|
}
|
|
1979
1980
|
toStdLng(M, b = 6) {
|
|
@@ -2009,10 +2010,10 @@ class k0 {
|
|
|
2009
2010
|
* @param datum
|
|
2010
2011
|
* @param options
|
|
2011
2012
|
*/
|
|
2012
|
-
async tidesForecast(M, b, z = 7, p = "today", c = !0, W = !1,
|
|
2013
|
-
p = p || "today", z = z || 7, b = this.toStdLng(b), this.debug && a0.info("[%s] spot tides forecast params: %j", q.requestId, { lat: M, lng: b, date: p, extremes: c, heights: W, datums:
|
|
2013
|
+
async tidesForecast(M, b, z = 7, p = "today", c = !0, W = !1, O = !1, o = "CD", q = {}) {
|
|
2014
|
+
p = p || "today", z = z || 7, b = this.toStdLng(b), this.debug && a0.info("[%s] spot tides forecast params: %j", q.requestId, { lat: M, lng: b, date: p, extremes: c, heights: W, datums: O, datum: o });
|
|
2014
2015
|
let R = `https://www.worldtides.info/api/v3?lat=${M}&lon=${b}&days=${z}&date=${p}&datum=${o}&key=${this.apikey}&localtime`;
|
|
2015
|
-
c && (R = `${R}&extremes`), W && (R = `${R}&heights`),
|
|
2016
|
+
c && (R = `${R}&extremes`), W && (R = `${R}&heights`), O && (R = `${R}&datums`);
|
|
2016
2017
|
const Y = await (await fetch(R)).json();
|
|
2017
2018
|
return Y.status === 200 ? {
|
|
2018
2019
|
rqt: {
|
|
@@ -2048,7 +2049,8 @@ class k {
|
|
|
2048
2049
|
lng: isNaN(c) ? null : c,
|
|
2049
2050
|
pressure: isNaN(z) ? null : Math.round(z) || null,
|
|
2050
2051
|
kts: isNaN(W) ? null : Math.round(W) || null,
|
|
2051
|
-
|
|
2052
|
+
bf: D.beaufort(D.kts2ms(W ?? 0)),
|
|
2053
|
+
...N.parseTropicalType(W),
|
|
2052
2054
|
wind: {
|
|
2053
2055
|
r7: null,
|
|
2054
2056
|
r7ne: null,
|
|
@@ -2074,16 +2076,17 @@ class k {
|
|
|
2074
2076
|
var c;
|
|
2075
2077
|
const z = L.utc(b.reftime).format(), p = {};
|
|
2076
2078
|
return (c = b.records) == null || c.forEach((W) => {
|
|
2077
|
-
const
|
|
2079
|
+
const O = L.utc(W.time), o = O.diff(z, "hour"), q = Number(W.pressure / 100), R = Number(W.lat), n = Number(W.lon), Y = Number(W.windSpeed * 3600 / 1852);
|
|
2078
2080
|
p[o] = {
|
|
2079
2081
|
lat: isNaN(R) ? null : R,
|
|
2080
2082
|
lng: isNaN(n) ? null : n,
|
|
2081
2083
|
pressure: isNaN(q) ? null : Math.round(q) || null,
|
|
2082
|
-
utc:
|
|
2084
|
+
utc: O.format(),
|
|
2083
2085
|
wind: {
|
|
2084
|
-
datetime:
|
|
2086
|
+
datetime: O.format(),
|
|
2085
2087
|
kts: isNaN(Y) ? null : Math.round(Y) || null,
|
|
2086
|
-
|
|
2088
|
+
bf: D.beaufort(D.kts2ms(Y ?? 0)),
|
|
2089
|
+
...N.parseTropicalType(Y),
|
|
2087
2090
|
r7: null,
|
|
2088
2091
|
r7ne: null,
|
|
2089
2092
|
r7nw: null,
|
|
@@ -2124,32 +2127,33 @@ class k {
|
|
|
2124
2127
|
return await N.tropicalMovement(c), c;
|
|
2125
2128
|
}
|
|
2126
2129
|
static async realtimeForecast() {
|
|
2127
|
-
const M = "https://node.windy.com/tc/v2/storms", b = await
|
|
2130
|
+
const M = "https://node.windy.com/tc/v2/storms", b = await w.get(M).json(), z = [];
|
|
2128
2131
|
for (const p of b.storms) {
|
|
2129
|
-
const c = `https://node.windy.com/tc/v2/storms/${p.id}`, W = await
|
|
2130
|
-
z.push(
|
|
2132
|
+
const c = `https://node.windy.com/tc/v2/storms/${p.id}`, W = await w.get(c).json(), O = await k.parseTropical(W);
|
|
2133
|
+
z.push(O);
|
|
2131
2134
|
}
|
|
2132
2135
|
return z;
|
|
2133
2136
|
}
|
|
2134
2137
|
}
|
|
2135
|
-
const
|
|
2138
|
+
const H = class H {
|
|
2136
2139
|
static async parseHistory(M) {
|
|
2137
|
-
const b = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${M}`, z = await
|
|
2138
|
-
for (const
|
|
2139
|
-
const o = L(
|
|
2140
|
+
const b = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${M}`, z = await w.post(b).text(), p = await H.parser.parseStringPromise(z), c = p.typhoon.position instanceof Array ? p.typhoon.position : [p.typhoon.position], W = [];
|
|
2141
|
+
for (const O of c) {
|
|
2142
|
+
const o = L(O.updatetime).utcOffset(8).utc().format(), q = Number(O.lat), R = Number(O.lon), n = Number(O.pressure), Y = Number(O.windspeed * 3600 / 1852), f = N.parseWindCircle(O.c7quad1 / 1.852), T = N.parseWindCircle(O.c7quad2 / 1.852), t = N.parseWindCircle(O.c7quad3 / 1.852), V = N.parseWindCircle(O.c7quad4 / 1.852), l = N.parseWindCircle(O.c10quad1 / 1.852), U = N.parseWindCircle(O.c10quad2 / 1.852), r = N.parseWindCircle(O.c10quad3 / 1.852), Z = N.parseWindCircle(O.c10quad4 / 1.852), m = N.parseWindCircle(O.c12quad1 / 1.852), G = N.parseWindCircle(O.c12quad2 / 1.852), I = N.parseWindCircle(O.c12quad3 / 1.852), C = N.parseWindCircle(O.c12quad4 / 1.852), { r7: F, r10: Q, r12: M0 } = N.estimateWindRadii(Y, q), z0 = {
|
|
2140
2143
|
updated: o,
|
|
2141
2144
|
lat: isNaN(q) ? null : q,
|
|
2142
2145
|
lng: isNaN(R) ? null : R,
|
|
2143
2146
|
pressure: isNaN(n) ? null : Math.round(n),
|
|
2144
2147
|
kts: isNaN(Y) ? null : Math.round(Y) || null,
|
|
2145
|
-
|
|
2148
|
+
bf: D.beaufort(D.kts2ms(Y ?? 0)),
|
|
2149
|
+
...N.parseTropicalType(Y),
|
|
2146
2150
|
wind: {
|
|
2147
|
-
r7:
|
|
2151
|
+
r7: F,
|
|
2148
2152
|
r7ne: f,
|
|
2149
2153
|
r7nw: T,
|
|
2150
2154
|
r7sw: t,
|
|
2151
2155
|
r7se: V,
|
|
2152
|
-
r10:
|
|
2156
|
+
r10: Q,
|
|
2153
2157
|
r10ne: l,
|
|
2154
2158
|
r10nw: U,
|
|
2155
2159
|
r10sw: r,
|
|
@@ -2163,10 +2167,10 @@ const _ = class _ {
|
|
|
2163
2167
|
};
|
|
2164
2168
|
W.push(z0);
|
|
2165
2169
|
}
|
|
2166
|
-
return W.sort((
|
|
2170
|
+
return W.sort((O, o) => L(o.updated).unix() - L(O.updated).unix()), W;
|
|
2167
2171
|
}
|
|
2168
2172
|
static async parseForecast(M, b) {
|
|
2169
|
-
const z = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${M}`, p = await
|
|
2173
|
+
const z = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${M}`, p = await w.post(z).text(), c = await H.parser.parseStringPromise(p), W = c.list.forecast instanceof Array ? c.list.forecast : [c.list.forecast], O = [];
|
|
2170
2174
|
for (const o of W)
|
|
2171
2175
|
if (o.xuhao === M) {
|
|
2172
2176
|
const q = o.positions.forecastposition instanceof Array ? o.positions.forecastposition : [o.positions.forecastposition];
|
|
@@ -2185,7 +2189,8 @@ const _ = class _ {
|
|
|
2185
2189
|
wind: {
|
|
2186
2190
|
datetime: f.format(),
|
|
2187
2191
|
kts: isNaN(U) ? null : Math.round(U),
|
|
2188
|
-
|
|
2192
|
+
bf: D.beaufort(D.kts2ms(U ?? 0)),
|
|
2193
|
+
...N.parseTropicalType(U),
|
|
2189
2194
|
r7: null,
|
|
2190
2195
|
r7ne: null,
|
|
2191
2196
|
r7nw: null,
|
|
@@ -2213,15 +2218,15 @@ const _ = class _ {
|
|
|
2213
2218
|
model: N.parseTropicalModel(o.country).toLowerCase(),
|
|
2214
2219
|
hours: R
|
|
2215
2220
|
};
|
|
2216
|
-
|
|
2221
|
+
O.push(n);
|
|
2217
2222
|
}
|
|
2218
2223
|
}
|
|
2219
|
-
return
|
|
2224
|
+
return O;
|
|
2220
2225
|
}
|
|
2221
2226
|
static async parseTropical(M) {
|
|
2222
|
-
var W,
|
|
2223
|
-
const b = await
|
|
2224
|
-
id: (
|
|
2227
|
+
var W, O, o;
|
|
2228
|
+
const b = await H.parseHistory(M.xuhao), z = (W = b.at(0)) == null ? void 0 : W.updated, p = await H.parseForecast(M.xuhao, z ? L(z) : void 0), c = {
|
|
2229
|
+
id: (O = M.enname) == null ? void 0 : O.toLowerCase(),
|
|
2225
2230
|
name: (o = M.enname) == null ? void 0 : o.toLowerCase(),
|
|
2226
2231
|
cnName: M.name,
|
|
2227
2232
|
history: b,
|
|
@@ -2230,17 +2235,17 @@ const _ = class _ {
|
|
|
2230
2235
|
return await N.tropicalMovement(c), c;
|
|
2231
2236
|
}
|
|
2232
2237
|
static async realtimeForecast() {
|
|
2233
|
-
const M = "https://hifleet.com/hifleetapi/getCurrentTyphoon2.do", b = await
|
|
2238
|
+
const M = "https://hifleet.com/hifleetapi/getCurrentTyphoon2.do", b = await w.post(M).text(), z = await H.parser.parseStringPromise(b), p = [], c = z.typhoon.position instanceof Array ? z.typhoon.position : [z.typhoon.position];
|
|
2234
2239
|
for (const W of c)
|
|
2235
2240
|
if (W) {
|
|
2236
|
-
const
|
|
2237
|
-
p.push(
|
|
2241
|
+
const O = await H.parseTropical(W);
|
|
2242
|
+
p.push(O);
|
|
2238
2243
|
}
|
|
2239
2244
|
return p;
|
|
2240
2245
|
}
|
|
2241
2246
|
};
|
|
2242
|
-
|
|
2243
|
-
let j =
|
|
2247
|
+
g(H, "parser", U0.Parser({ explicitArray: !1, mergeAttrs: !0, trim: !0 }));
|
|
2248
|
+
let j = H;
|
|
2244
2249
|
var O0 = /* @__PURE__ */ ((e) => (e.CMA = "CMA", e.CNTW = "CNTW", e.CNHK = "CNHK", e.JMA = "JMA", e.KMA = "KMA", e.ECMWF = "ECMWF", e.NOAA_AT = "NOAA-AT", e.NOAA_CP = "NOAA-CP", e.NOAA_EP = "NOAA-EP", e.UKM = "UKM", e.IMD = "IMD", e.GFS = "GFS", e.BOM_ACCESS = "BOM-ACCESS", e.BOM_BULLETIN_EAST = "BOM-BULLETIN-EAST", e.BOM_BULLETIN_NORTH = "BOM-BULLETIN-NORTH", e.BOM_BULLETIN_WEST = "BOM-BULLETIN-WEST", e.OTHER = "OTHER", e))(O0 || {});
|
|
2245
2250
|
class N {
|
|
2246
2251
|
/**
|
|
@@ -2256,26 +2261,26 @@ class N {
|
|
|
2256
2261
|
const b = Object.values(O0);
|
|
2257
2262
|
return (z = M.forecasts) == null || z.sort((p, c) => {
|
|
2258
2263
|
var o, q;
|
|
2259
|
-
const W = b.indexOf((o = p.model) == null ? void 0 : o.toUpperCase()),
|
|
2260
|
-
return (W === -1 ? 999 : W) - (
|
|
2264
|
+
const W = b.indexOf((o = p.model) == null ? void 0 : o.toUpperCase()), O = b.indexOf((q = c.model) == null ? void 0 : q.toUpperCase());
|
|
2265
|
+
return (W === -1 ? 999 : W) - (O === -1 ? 999 : O);
|
|
2261
2266
|
}), M;
|
|
2262
2267
|
}
|
|
2263
2268
|
static async mergeTropicals(M = !0, b = {}) {
|
|
2264
2269
|
var c, W;
|
|
2265
2270
|
const z = await k.realtimeForecast(), p = M ? await j.realtimeForecast() : [];
|
|
2266
|
-
for (const
|
|
2271
|
+
for (const O of z) {
|
|
2267
2272
|
const o = p.find((R) => {
|
|
2268
2273
|
var n, Y;
|
|
2269
|
-
return ((n = R.name) == null ? void 0 : n.toLowerCase()) === ((Y =
|
|
2274
|
+
return ((n = R.name) == null ? void 0 : n.toLowerCase()) === ((Y = O.name) == null ? void 0 : Y.toLowerCase());
|
|
2270
2275
|
});
|
|
2271
2276
|
if (o) {
|
|
2272
|
-
|
|
2277
|
+
O.cnName = o.cnName, (c = o.history) != null && c.length && (O.history = o.history), O.history.sort((R, n) => L(n.updated).valueOf() - L(R.updated).valueOf());
|
|
2273
2278
|
for (const R of o.forecasts)
|
|
2274
|
-
["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((W = R.model) == null ? void 0 : W.toUpperCase()) && !
|
|
2279
|
+
["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((W = R.model) == null ? void 0 : W.toUpperCase()) && !O.forecasts.find((n) => n.model.toLowerCase() === R.model.toLowerCase()) && O.forecasts.push(R);
|
|
2275
2280
|
}
|
|
2276
|
-
|
|
2277
|
-
const q =
|
|
2278
|
-
q &&
|
|
2281
|
+
O.history = O.history.reduce((R, n) => (R.find((Y) => Y.updated === n.updated) || R.push(n), R), []);
|
|
2282
|
+
const q = O.history[0];
|
|
2283
|
+
q && O.forecasts.forEach((R) => {
|
|
2279
2284
|
R.date = q.updated;
|
|
2280
2285
|
const n = L(q.updated), Y = {};
|
|
2281
2286
|
for (const f in R.hours) {
|
|
@@ -2283,13 +2288,13 @@ class N {
|
|
|
2283
2288
|
t > 0 && (Y[t] = T);
|
|
2284
2289
|
}
|
|
2285
2290
|
R.hours = Y;
|
|
2286
|
-
}), await N.tropicalMovement(
|
|
2291
|
+
}), await N.tropicalMovement(O);
|
|
2287
2292
|
}
|
|
2288
|
-
for (const
|
|
2293
|
+
for (const O of p)
|
|
2289
2294
|
z.every((o) => {
|
|
2290
2295
|
var q, R;
|
|
2291
|
-
return ((q = o.name) == null ? void 0 : q.toLowerCase()) !== ((R =
|
|
2292
|
-
}) && z.push(
|
|
2296
|
+
return ((q = o.name) == null ? void 0 : q.toLowerCase()) !== ((R = O.name) == null ? void 0 : R.toLowerCase());
|
|
2297
|
+
}) && z.push(O);
|
|
2293
2298
|
return z;
|
|
2294
2299
|
}
|
|
2295
2300
|
/**
|
|
@@ -2301,10 +2306,10 @@ class N {
|
|
|
2301
2306
|
let b = null;
|
|
2302
2307
|
M.forecasts.forEach((p) => {
|
|
2303
2308
|
const c = p.hours, W = Object.keys(c);
|
|
2304
|
-
for (let
|
|
2305
|
-
const o = c[W[
|
|
2309
|
+
for (let O = 0; O < W.length - 1; O++) {
|
|
2310
|
+
const o = c[W[O]];
|
|
2306
2311
|
b = b || o;
|
|
2307
|
-
const q = c[W[
|
|
2312
|
+
const q = c[W[O + 1]];
|
|
2308
2313
|
o.movement = N.calculateMovement(o, q);
|
|
2309
2314
|
const R = N.supplementWindRadii(o);
|
|
2310
2315
|
o.wind = { ...o.wind || {}, ...R };
|
|
@@ -2314,8 +2319,8 @@ class N {
|
|
|
2314
2319
|
for (let p = 0; p < M.history.length - 1; p++) {
|
|
2315
2320
|
const c = M.history[p + 1], W = M.history[p];
|
|
2316
2321
|
z = z || W, c.movement = N.calculateMovement(c, W);
|
|
2317
|
-
const
|
|
2318
|
-
c.wind = { ...c.wind || {}, ...
|
|
2322
|
+
const O = N.supplementWindRadii(c);
|
|
2323
|
+
c.wind = { ...c.wind || {}, ...O };
|
|
2319
2324
|
}
|
|
2320
2325
|
if (z && b) {
|
|
2321
2326
|
z.movement = N.calculateMovement(z, b);
|
|
@@ -2361,10 +2366,10 @@ class N {
|
|
|
2361
2366
|
return 0;
|
|
2362
2367
|
let c = z, W = z * 10;
|
|
2363
2368
|
for (; W - c > 0.1; ) {
|
|
2364
|
-
const
|
|
2365
|
-
b * Math.sqrt(q) > M ? c =
|
|
2369
|
+
const O = (c + W) / 2, o = z / O, q = Math.pow(o, p) * Math.exp(1 - Math.pow(o, p));
|
|
2370
|
+
b * Math.sqrt(q) > M ? c = O : W = O;
|
|
2366
2371
|
}
|
|
2367
|
-
return
|
|
2372
|
+
return D.kmh2kts(c + W);
|
|
2368
2373
|
}
|
|
2369
2374
|
/**
|
|
2370
2375
|
* 基于台风强度推算风圈基础半径的经验公式
|
|
@@ -2373,10 +2378,10 @@ class N {
|
|
|
2373
2378
|
* @returns 风圈半径对象
|
|
2374
2379
|
*/
|
|
2375
2380
|
static estimateWindRadii(M, b) {
|
|
2376
|
-
const z =
|
|
2381
|
+
const z = D.kts2ms(M), p = N.estimateRMW(z, b), c = N.estimateHollandB(z, p, b), W = N.findWindRadius(17.2, z, p, c), O = N.findWindRadius(28.5, z, p, c), o = N.findWindRadius(37, z, p, c);
|
|
2377
2382
|
return {
|
|
2378
2383
|
r7: W ? Math.round(W) : null,
|
|
2379
|
-
r10:
|
|
2384
|
+
r10: O ? Math.round(O) : null,
|
|
2380
2385
|
r12: o ? Math.round(o) : null
|
|
2381
2386
|
};
|
|
2382
2387
|
}
|
|
@@ -2393,7 +2398,7 @@ class N {
|
|
|
2393
2398
|
return { ne: null, nw: null, se: null, sw: null };
|
|
2394
2399
|
if (b < 9)
|
|
2395
2400
|
return { ne: M, nw: M, se: M, sw: M };
|
|
2396
|
-
const W = 0.15 * Math.min(b / (20 / 1.852), 1),
|
|
2401
|
+
const W = 0.15 * Math.min(b / (20 / 1.852), 1), O = {
|
|
2397
2402
|
ne: (45 - z + 360) % 360,
|
|
2398
2403
|
nw: (315 - z + 360) % 360,
|
|
2399
2404
|
se: (135 - z + 360) % 360,
|
|
@@ -2403,10 +2408,10 @@ class N {
|
|
|
2403
2408
|
return 1 - W * n;
|
|
2404
2409
|
};
|
|
2405
2410
|
return {
|
|
2406
|
-
ne: Math.round(M * o(
|
|
2407
|
-
nw: Math.round(M * o(
|
|
2408
|
-
se: Math.round(M * o(
|
|
2409
|
-
sw: Math.round(M * o(
|
|
2411
|
+
ne: Math.round(M * o(O.ne)),
|
|
2412
|
+
nw: Math.round(M * o(O.nw)),
|
|
2413
|
+
se: Math.round(M * o(O.se)),
|
|
2414
|
+
sw: Math.round(M * o(O.sw))
|
|
2410
2415
|
};
|
|
2411
2416
|
}
|
|
2412
2417
|
/**
|
|
@@ -2439,16 +2444,16 @@ class N {
|
|
|
2439
2444
|
r12se: null,
|
|
2440
2445
|
r12sw: null
|
|
2441
2446
|
};
|
|
2442
|
-
const W = N.estimateWindRadii(c, z),
|
|
2447
|
+
const W = N.estimateWindRadii(c, z), O = {};
|
|
2443
2448
|
return ["r7", "r10", "r12"].forEach((q) => {
|
|
2444
2449
|
const R = W[q];
|
|
2445
2450
|
if (R) {
|
|
2446
|
-
|
|
2451
|
+
O[q] = R;
|
|
2447
2452
|
const n = N.estimateAsymmetricRadii(R, (p == null ? void 0 : p.kts) || 0, (p == null ? void 0 : p.deg) || 0, z > 0 ? "N" : "S");
|
|
2448
|
-
|
|
2453
|
+
O[`${q}ne`] = n.ne, O[`${q}nw`] = n.nw, O[`${q}se`] = n.se, O[`${q}sw`] = n.sw;
|
|
2449
2454
|
} else
|
|
2450
|
-
|
|
2451
|
-
}),
|
|
2455
|
+
O[q] = null, O[`${q}ne`] = null, O[`${q}nw`] = null, O[`${q}se`] = null, O[`${q}sw`] = null;
|
|
2456
|
+
}), O;
|
|
2452
2457
|
}
|
|
2453
2458
|
/**
|
|
2454
2459
|
* 台风类型
|
|
@@ -2458,7 +2463,7 @@ class N {
|
|
|
2458
2463
|
* 2 强热带风暴 Severe Tropical Storm
|
|
2459
2464
|
*/
|
|
2460
2465
|
static parseTropicalType(M) {
|
|
2461
|
-
return !M || M < 32 ? "Tropical Depression" : M < 47 ? "Tropical Storm" : M < 63 ? "Severe Tropical Storm" : M < 80 ? "Typhoon" : M < 94 ? "Strong Typhoon" : "Super Typhoon";
|
|
2466
|
+
return !M || M < 32 ? { type: "Tropical Depression", en: "TD", cn: "热带低压", i18n: "tropical.td" } : M < 47 ? { type: "Tropical Storm", en: "TS", cn: "热带风暴", i18n: "tropical.ts" } : M < 63 ? { type: "Severe Tropical Storm", en: "STS", cn: "强热带风暴", i18n: "tropical.sts" } : M < 80 ? { type: "Typhoon", en: "TY", cn: "台风", i18n: "tropical.ty" } : M < 94 ? { type: "Strong Typhoon", en: "STY", cn: "强台风", i18n: "tropical.sty" } : { type: "Super Typhoon", en: "Super TY", cn: "超强台风", i18n: "tropical.superTy" };
|
|
2462
2467
|
}
|
|
2463
2468
|
/**
|
|
2464
2469
|
* @param name
|
|
@@ -2471,8 +2476,8 @@ class N {
|
|
|
2471
2476
|
}
|
|
2472
2477
|
}
|
|
2473
2478
|
export {
|
|
2474
|
-
|
|
2475
|
-
|
|
2479
|
+
y0 as MeteoHelper,
|
|
2480
|
+
Q0 as MeteoHelper2,
|
|
2476
2481
|
k0 as TidesHelper,
|
|
2477
2482
|
N as TropicalHelper,
|
|
2478
2483
|
O0 as TropicalModel,
|