@idm-plugin/meteo2 1.0.4 → 1.0.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 +311 -301
- package/dist/index.umd.cjs +2 -2
- package/dist/openmeteo/src/index.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,19 +2,19 @@ var V0 = Object.defineProperty;
|
|
|
2
2
|
var l0 = (M, z, b) => z in M ? V0(M, z, { enumerable: !0, configurable: !0, writable: !0, value: b }) : M[z] = b;
|
|
3
3
|
var F = (M, z, b) => (l0(M, typeof z != "symbol" ? z + "" : z, b), b);
|
|
4
4
|
import e0 from "@log4js-node/log4js-api";
|
|
5
|
-
import
|
|
5
|
+
import i from "moment";
|
|
6
6
|
import x from "got";
|
|
7
7
|
import { fetchWeatherApi as t0 } from "openmeteo";
|
|
8
|
-
import { Meteo2Assist as
|
|
9
|
-
import
|
|
8
|
+
import { Meteo2Assist as g } from "@idm-plugin/meteo";
|
|
9
|
+
import m0 from "xml2js";
|
|
10
10
|
import { LaneHelper as f0 } from "@idm-plugin/geo2";
|
|
11
|
-
let
|
|
11
|
+
let P;
|
|
12
12
|
try {
|
|
13
|
-
|
|
13
|
+
P = e0.getLogger("meteo");
|
|
14
14
|
} catch {
|
|
15
15
|
} finally {
|
|
16
16
|
}
|
|
17
|
-
var
|
|
17
|
+
var Z0 = /* @__PURE__ */ ((M) => (M.Arome = "arome", M.IconEU = "iconEu", M.GFS = "gfs", M.GFSWave = "gfsWave", M.NamConus = "namConus", M.NamHawaii = "namHawaii", M.NamAlaska = "namAlaska", M.Geos5 = "geos5", M))(Z0 || {});
|
|
18
18
|
class j0 {
|
|
19
19
|
/**
|
|
20
20
|
* 点查海洋气象要素(全量)
|
|
@@ -27,7 +27,7 @@ class j0 {
|
|
|
27
27
|
*/
|
|
28
28
|
static async queryPointMeteo(z, b, p, W = !1, A = "", c = {}) {
|
|
29
29
|
typeof p == "number" && (p = p < 1e12 ? p * 1e3 : p);
|
|
30
|
-
const O =
|
|
30
|
+
const O = i(p), Y = {
|
|
31
31
|
searchParams: {
|
|
32
32
|
lng: z,
|
|
33
33
|
lat: b,
|
|
@@ -36,15 +36,15 @@ class j0 {
|
|
|
36
36
|
source: A == null ? void 0 : A.toLowerCase()
|
|
37
37
|
},
|
|
38
38
|
timeout: 3e4
|
|
39
|
-
}, a =
|
|
40
|
-
O.isBefore(a.subtract(1, "month")) && (
|
|
41
|
-
const X = "https://aod4idm.idmwx.com/api/ocean/point", d = await x.get(X, Y).json(), t =
|
|
42
|
-
if (
|
|
39
|
+
}, a = i(), n = a.valueOf();
|
|
40
|
+
O.isBefore(a.subtract(1, "month")) && (P == null || P.warn("[%s] get history meteo on %s: %j", c.requestId, O.format(), Y));
|
|
41
|
+
const X = "https://aod4idm.idmwx.com/api/ocean/point", d = await x.get(X, Y).json(), t = i().valueOf();
|
|
42
|
+
if (P == null || P.info("[%s] get meteo(cost: %d ms) from %s with options: %j", c.requestId, t - n, X, Y), (d == null ? void 0 : d.code) === 0)
|
|
43
43
|
return {
|
|
44
44
|
...d.data,
|
|
45
45
|
source: A
|
|
46
46
|
};
|
|
47
|
-
|
|
47
|
+
P == null || P.warn("[%s] get meteo failed: %j", c.requestId, d);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* 点查海洋气象要素(指定要素组合)
|
|
@@ -62,7 +62,7 @@ class j0 {
|
|
|
62
62
|
*/
|
|
63
63
|
static async queryPointFactor(z, b, p, W = "wind,wave,current,watertemp,visibility", A = "", c = {}) {
|
|
64
64
|
typeof p == "number" && (p = p < 1e12 ? p * 1e3 : p);
|
|
65
|
-
const O =
|
|
65
|
+
const O = i(p), Y = {
|
|
66
66
|
searchParams: {
|
|
67
67
|
lng: z,
|
|
68
68
|
lat: b,
|
|
@@ -71,15 +71,15 @@ class j0 {
|
|
|
71
71
|
source: A == null ? void 0 : A.toLowerCase()
|
|
72
72
|
},
|
|
73
73
|
timeout: 3e4
|
|
74
|
-
}, a =
|
|
75
|
-
O.isBefore(a.subtract(1, "month")) && (
|
|
76
|
-
const X = "https://aod4idm.idmwx.com/api/ocean/factor", d = await x.get(X, Y).json(), t =
|
|
77
|
-
if (
|
|
74
|
+
}, a = i(), n = a.valueOf();
|
|
75
|
+
O.isBefore(a.subtract(1, "month")) && (P == null || P.warn("[%s] get history factors on %s: %j", c.requestId, O.format(), Y));
|
|
76
|
+
const X = "https://aod4idm.idmwx.com/api/ocean/factor", d = await x.get(X, Y).json(), t = i().valueOf();
|
|
77
|
+
if (P == null || P.info("[%s] get factors(cost: %d ms) from %s with options: %j", c.requestId, t - n, X, Y), (d == null ? void 0 : d.code) === 0)
|
|
78
78
|
return {
|
|
79
79
|
...d.data,
|
|
80
80
|
source: A
|
|
81
81
|
};
|
|
82
|
-
|
|
82
|
+
P == null || P.warn("[%s] get factors failed: %j", c.requestId, d);
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* @see https://api.windy.com/point-forecast/docs
|
|
@@ -88,7 +88,7 @@ class j0 {
|
|
|
88
88
|
static async queryWindyPointForecast(z, b, p, W = {}) {
|
|
89
89
|
const A = "https://api.windy.com/api/point-forecast/v2", c = [];
|
|
90
90
|
try {
|
|
91
|
-
let O =
|
|
91
|
+
let O = i().valueOf();
|
|
92
92
|
const Y = await x.post(A, {
|
|
93
93
|
headers: {
|
|
94
94
|
"Content-Type": "application/json"
|
|
@@ -118,8 +118,8 @@ class j0 {
|
|
|
118
118
|
levels: ["surface"]
|
|
119
119
|
}
|
|
120
120
|
}).json();
|
|
121
|
-
let a =
|
|
122
|
-
|
|
121
|
+
let a = i().valueOf();
|
|
122
|
+
P == null || P.info("[%s] get gfs-factors(cost: %d ms) from %s", W.requestId, a - O, A), O = a;
|
|
123
123
|
const n = await x.post(A, {
|
|
124
124
|
headers: {
|
|
125
125
|
"Content-Type": "application/json"
|
|
@@ -133,11 +133,11 @@ class j0 {
|
|
|
133
133
|
levels: ["surface"]
|
|
134
134
|
}
|
|
135
135
|
}).json();
|
|
136
|
-
a =
|
|
136
|
+
a = i().valueOf(), P == null || P.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", W.requestId, a - O, A);
|
|
137
137
|
for (let d = 0; d < Y.ts.length; d++) {
|
|
138
138
|
const t = this.populateUVFactor(Y["wind_u-surface"][d], Y["wind_v-surface"][d], !1, W);
|
|
139
139
|
t.scale = this.calculateBeaufortWindForceScale(t.speed), c.push({
|
|
140
|
-
utc:
|
|
140
|
+
utc: i(Y.ts[d]).utc().format(),
|
|
141
141
|
temp: Y["temp-surface"][d] ? Math.round((Y["temp-surface"][d] - 273.15) * 100) / 100 : void 0,
|
|
142
142
|
dp_temp: Y["dewpoint-surface"][d] ? Math.round((Y["dewpoint-surface"][d] - 273.15) * 100) / 100 : void 0,
|
|
143
143
|
precip: {
|
|
@@ -160,14 +160,14 @@ class j0 {
|
|
|
160
160
|
}
|
|
161
161
|
const X = [];
|
|
162
162
|
for (let d = 0; d < n.ts.length; d++) {
|
|
163
|
-
const t = this.calculateDouglasScale(n["waves_height-surface"][d], n["waves_direction-surface"][d], n["waves_period-surface"][d]), r = this.calculateDouglasScale(n["wwaves_height-surface"][d], n["wwaves_direction-surface"][d], n["wwaves_period-surface"][d]), u = this.calculateDouglasScale(n["swell1_height-surface"][d], n["swell1_direction-surface"][d], n["swell1_period-surface"][d]),
|
|
163
|
+
const t = this.calculateDouglasScale(n["waves_height-surface"][d], n["waves_direction-surface"][d], n["waves_period-surface"][d]), r = this.calculateDouglasScale(n["wwaves_height-surface"][d], n["wwaves_direction-surface"][d], n["wwaves_period-surface"][d]), u = this.calculateDouglasScale(n["swell1_height-surface"][d], n["swell1_direction-surface"][d], n["swell1_period-surface"][d]), s = this.calculateDouglasScale(n["swell2_height-surface"][d], n["swell2_direction-surface"][d], n["swell2_period-surface"][d]);
|
|
164
164
|
X.push({
|
|
165
|
-
utc:
|
|
165
|
+
utc: i(n.ts[d]).utc().format(),
|
|
166
166
|
wave: {
|
|
167
167
|
sig: t,
|
|
168
168
|
wd: r,
|
|
169
169
|
swell: u,
|
|
170
|
-
swell2:
|
|
170
|
+
swell2: s
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
}
|
|
@@ -176,7 +176,7 @@ class j0 {
|
|
|
176
176
|
d.wave = t == null ? void 0 : t.wave;
|
|
177
177
|
}
|
|
178
178
|
} catch (O) {
|
|
179
|
-
|
|
179
|
+
P.warn("[%s] get-gfs-factor failed: %s", W.requestId, O);
|
|
180
180
|
}
|
|
181
181
|
return c;
|
|
182
182
|
}
|
|
@@ -288,7 +288,7 @@ var U0 = { exports: {} };
|
|
|
288
288
|
//! license : MIT
|
|
289
289
|
//! github.com/moment/moment-timezone
|
|
290
290
|
(function(z, b) {
|
|
291
|
-
M.exports ? M.exports = b(
|
|
291
|
+
M.exports ? M.exports = b(i) : b(z.moment);
|
|
292
292
|
})(E0, function(z) {
|
|
293
293
|
z.version === void 0 && z.default && (z = z.default);
|
|
294
294
|
var b = "0.5.48", p = {}, W = {}, A = {}, c = {}, O = {}, Y;
|
|
@@ -299,12 +299,12 @@ var U0 = { exports: {} };
|
|
|
299
299
|
return o > 96 ? o - 87 : o > 64 ? o - 29 : o - 48;
|
|
300
300
|
}
|
|
301
301
|
function t(o) {
|
|
302
|
-
var q = 0, e = o.split("."), R = e[0], T = e[1] || "",
|
|
302
|
+
var q = 0, e = o.split("."), R = e[0], T = e[1] || "", B = 1, C, V = 0, h = 1;
|
|
303
303
|
for (o.charCodeAt(0) === 45 && (q = 1, h = -1), q; q < R.length; q++)
|
|
304
|
-
C = d(R.charCodeAt(q)),
|
|
304
|
+
C = d(R.charCodeAt(q)), V = 60 * V + C;
|
|
305
305
|
for (q = 0; q < T.length; q++)
|
|
306
|
-
|
|
307
|
-
return
|
|
306
|
+
B = B / 60, C = d(T.charCodeAt(q)), V += C * B;
|
|
307
|
+
return V * h;
|
|
308
308
|
}
|
|
309
309
|
function r(o) {
|
|
310
310
|
for (var q = 0; q < o.length; q++)
|
|
@@ -315,7 +315,7 @@ var U0 = { exports: {} };
|
|
|
315
315
|
o[e] = Math.round((o[e - 1] || 0) + o[e] * 6e4);
|
|
316
316
|
o[q - 1] = 1 / 0;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function s(o, q) {
|
|
319
319
|
var e = [], R;
|
|
320
320
|
for (R = 0; R < q.length; R++)
|
|
321
321
|
e[R] = o[q[R]];
|
|
@@ -325,16 +325,16 @@ var U0 = { exports: {} };
|
|
|
325
325
|
var q = o.split("|"), e = q[2].split(" "), R = q[3].split(""), T = q[4].split(" ");
|
|
326
326
|
return r(e), r(R), r(T), u(T, R.length), {
|
|
327
327
|
name: q[0],
|
|
328
|
-
abbrs:
|
|
329
|
-
offsets:
|
|
328
|
+
abbrs: s(q[1].split(" "), R),
|
|
329
|
+
offsets: s(e, R),
|
|
330
330
|
untils: T,
|
|
331
331
|
population: q[5] | 0
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function L(o) {
|
|
335
335
|
o && this._set(m(o));
|
|
336
336
|
}
|
|
337
|
-
function
|
|
337
|
+
function U(o, q) {
|
|
338
338
|
var e = q.length;
|
|
339
339
|
if (o < q[0])
|
|
340
340
|
return 0;
|
|
@@ -342,17 +342,17 @@ var U0 = { exports: {} };
|
|
|
342
342
|
return e - 1;
|
|
343
343
|
if (o >= q[e - 1])
|
|
344
344
|
return -1;
|
|
345
|
-
for (var R, T = 0,
|
|
346
|
-
R = Math.floor((T +
|
|
347
|
-
return
|
|
345
|
+
for (var R, T = 0, B = e - 1; B - T > 1; )
|
|
346
|
+
R = Math.floor((T + B) / 2), q[R] <= o ? T = R : B = R;
|
|
347
|
+
return B;
|
|
348
348
|
}
|
|
349
|
-
|
|
349
|
+
L.prototype = {
|
|
350
350
|
_set: function(o) {
|
|
351
351
|
this.name = o.name, this.abbrs = o.abbrs, this.untils = o.untils, this.offsets = o.offsets, this.population = o.population;
|
|
352
352
|
},
|
|
353
353
|
_index: function(o) {
|
|
354
354
|
var q = +o, e = this.untils, R;
|
|
355
|
-
if (R =
|
|
355
|
+
if (R = U(q, e), R >= 0)
|
|
356
356
|
return R;
|
|
357
357
|
},
|
|
358
358
|
countries: function() {
|
|
@@ -362,9 +362,9 @@ var U0 = { exports: {} };
|
|
|
362
362
|
});
|
|
363
363
|
},
|
|
364
364
|
parse: function(o) {
|
|
365
|
-
var q = +o, e = this.offsets, R = this.untils, T = R.length - 1,
|
|
365
|
+
var q = +o, e = this.offsets, R = this.untils, T = R.length - 1, B, C, V, h;
|
|
366
366
|
for (h = 0; h < T; h++)
|
|
367
|
-
if (
|
|
367
|
+
if (B = e[h], C = e[h + 1], V = e[h && h - 1], B < C && I.moveAmbiguousForward ? B = C : B > V && I.moveInvalidForward && (B = V), q < R[h] - B * 6e4)
|
|
368
368
|
return e[h];
|
|
369
369
|
return e[T];
|
|
370
370
|
},
|
|
@@ -378,33 +378,33 @@ var U0 = { exports: {} };
|
|
|
378
378
|
return this.offsets[this._index(o)];
|
|
379
379
|
}
|
|
380
380
|
};
|
|
381
|
-
function
|
|
381
|
+
function Z(o, q) {
|
|
382
382
|
this.name = o, this.zones = q;
|
|
383
383
|
}
|
|
384
384
|
function N(o) {
|
|
385
385
|
var q = o.toTimeString(), e = q.match(/\([a-z ]+\)/i);
|
|
386
386
|
e && e[0] ? (e = e[0].match(/[A-Z]/g), e = e ? e.join("") : void 0) : (e = q.match(/[A-Z]{3,5}/g), e = e ? e[0] : void 0), e === "GMT" && (e = void 0), this.at = +o, this.abbr = e, this.offset = o.getTimezoneOffset();
|
|
387
387
|
}
|
|
388
|
-
function
|
|
388
|
+
function l(o) {
|
|
389
389
|
this.zone = o, this.offsetScore = 0, this.abbrScore = 0;
|
|
390
390
|
}
|
|
391
|
-
|
|
391
|
+
l.prototype.scoreOffsetAt = function(o) {
|
|
392
392
|
this.offsetScore += Math.abs(this.zone.utcOffset(o.at) - o.offset), this.zone.abbr(o.at).replace(/[^A-Z]/g, "") !== o.abbr && this.abbrScore++;
|
|
393
393
|
};
|
|
394
|
-
function
|
|
394
|
+
function _(o, q) {
|
|
395
395
|
for (var e, R; R = ((q.at - o.at) / 12e4 | 0) * 6e4; )
|
|
396
396
|
e = new N(new Date(o.at + R)), e.offset === o.offset ? o = e : q = e;
|
|
397
397
|
return o;
|
|
398
398
|
}
|
|
399
|
-
function
|
|
400
|
-
var o = (/* @__PURE__ */ new Date()).getFullYear() - 2, q = new N(new Date(o, 0, 1)), e = q.offset, R = [q], T,
|
|
401
|
-
for (
|
|
402
|
-
C = new Date(o,
|
|
403
|
-
for (
|
|
404
|
-
R.push(new N(new Date(o +
|
|
399
|
+
function f() {
|
|
400
|
+
var o = (/* @__PURE__ */ new Date()).getFullYear() - 2, q = new N(new Date(o, 0, 1)), e = q.offset, R = [q], T, B, C, V;
|
|
401
|
+
for (V = 1; V < 48; V++)
|
|
402
|
+
C = new Date(o, V, 1).getTimezoneOffset(), C !== e && (B = new N(new Date(o, V, 1)), T = _(q, B), R.push(T), R.push(new N(new Date(T.at + 6e4))), q = B, e = C);
|
|
403
|
+
for (V = 0; V < 4; V++)
|
|
404
|
+
R.push(new N(new Date(o + V, 0, 1))), R.push(new N(new Date(o + V, 6, 1)));
|
|
405
405
|
return R;
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function E(o, q) {
|
|
408
408
|
return o.offsetScore !== q.offsetScore ? o.offsetScore - q.offsetScore : o.abbrScore !== q.abbrScore ? o.abbrScore - q.abbrScore : o.zone.population !== q.zone.population ? q.zone.population - o.zone.population : q.zone.name.localeCompare(o.zone.name);
|
|
409
409
|
}
|
|
410
410
|
function w(o, q) {
|
|
@@ -412,17 +412,17 @@ var U0 = { exports: {} };
|
|
|
412
412
|
for (r(q), e = 0; e < q.length; e++)
|
|
413
413
|
R = q[e], O[R] = O[R] || {}, O[R][o] = !0;
|
|
414
414
|
}
|
|
415
|
-
function
|
|
416
|
-
var q = o.length, e = {}, R = [], T = {},
|
|
417
|
-
for (
|
|
418
|
-
if (
|
|
419
|
-
h = O[
|
|
415
|
+
function D(o) {
|
|
416
|
+
var q = o.length, e = {}, R = [], T = {}, B, C, V, h;
|
|
417
|
+
for (B = 0; B < q; B++)
|
|
418
|
+
if (V = o[B].offset, !T.hasOwnProperty(V)) {
|
|
419
|
+
h = O[V] || {};
|
|
420
420
|
for (C in h)
|
|
421
421
|
h.hasOwnProperty(C) && (e[C] = !0);
|
|
422
|
-
T[
|
|
422
|
+
T[V] = !0;
|
|
423
423
|
}
|
|
424
|
-
for (
|
|
425
|
-
e.hasOwnProperty(
|
|
424
|
+
for (B in e)
|
|
425
|
+
e.hasOwnProperty(B) && R.push(c[B]);
|
|
426
426
|
return R;
|
|
427
427
|
}
|
|
428
428
|
function v() {
|
|
@@ -436,13 +436,13 @@ var U0 = { exports: {} };
|
|
|
436
436
|
}
|
|
437
437
|
} catch {
|
|
438
438
|
}
|
|
439
|
-
var e =
|
|
440
|
-
for (
|
|
441
|
-
for (C = new
|
|
439
|
+
var e = f(), R = e.length, T = D(e), B = [], C, V, h;
|
|
440
|
+
for (V = 0; V < T.length; V++) {
|
|
441
|
+
for (C = new l(y(T[V])), h = 0; h < R; h++)
|
|
442
442
|
C.scoreOffsetAt(e[h]);
|
|
443
|
-
|
|
443
|
+
B.push(C);
|
|
444
444
|
}
|
|
445
|
-
return
|
|
445
|
+
return B.sort(E), B.length > 0 ? B[0].zone.name : void 0;
|
|
446
446
|
}
|
|
447
447
|
function q0(o) {
|
|
448
448
|
return (!Y || o) && (Y = v()), Y;
|
|
@@ -455,10 +455,10 @@ var U0 = { exports: {} };
|
|
|
455
455
|
for (typeof o == "string" && (o = [o]), q = 0; q < o.length; q++)
|
|
456
456
|
R = o[q].split("|"), e = R[0], T = j(e), p[T] = o[q], c[T] = e, w(T, R[2].split(" "));
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function y(o, q) {
|
|
459
459
|
o = j(o);
|
|
460
460
|
var e = p[o], R;
|
|
461
|
-
return e instanceof
|
|
461
|
+
return e instanceof L ? e : typeof e == "string" ? (e = new L(e), p[o] = e, e) : W[o] && q !== y && (R = y(W[o], y)) ? (e = p[o] = new L(), e._set(R), e.name = c[o], e) : null;
|
|
462
462
|
}
|
|
463
463
|
function Y0() {
|
|
464
464
|
var o, q = [];
|
|
@@ -474,24 +474,24 @@ var U0 = { exports: {} };
|
|
|
474
474
|
for (typeof o == "string" && (o = [o]), q = 0; q < o.length; q++)
|
|
475
475
|
e = o[q].split("|"), R = j(e[0]), T = j(e[1]), W[R] = T, c[R] = e[0], W[T] = R, c[T] = e[1];
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function R0(o) {
|
|
478
478
|
var q, e, R, T;
|
|
479
479
|
if (!(!o || !o.length))
|
|
480
480
|
for (q = 0; q < o.length; q++)
|
|
481
|
-
T = o[q].split("|"), e = T[0].toUpperCase(), R = T[1].split(" "), A[e] = new
|
|
481
|
+
T = o[q].split("|"), e = T[0].toUpperCase(), R = T[1].split(" "), A[e] = new Z(
|
|
482
482
|
e,
|
|
483
483
|
R
|
|
484
484
|
);
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function X0(o) {
|
|
487
487
|
return o = o.toUpperCase(), A[o] || null;
|
|
488
488
|
}
|
|
489
489
|
function M0(o, q) {
|
|
490
|
-
if (o =
|
|
490
|
+
if (o = X0(o), !o)
|
|
491
491
|
return null;
|
|
492
492
|
var e = o.zones.sort();
|
|
493
493
|
return q ? e.map(function(R) {
|
|
494
|
-
var T =
|
|
494
|
+
var T = y(R);
|
|
495
495
|
return {
|
|
496
496
|
name: R,
|
|
497
497
|
offset: T.utcOffset(/* @__PURE__ */ new Date())
|
|
@@ -499,10 +499,10 @@ var U0 = { exports: {} };
|
|
|
499
499
|
}) : e;
|
|
500
500
|
}
|
|
501
501
|
function H(o) {
|
|
502
|
-
c0(o.zones), O0(o.links),
|
|
502
|
+
c0(o.zones), O0(o.links), R0(o.countries), I.dataVersion = o.version;
|
|
503
503
|
}
|
|
504
504
|
function W0(o) {
|
|
505
|
-
return W0.didShowError || (W0.didShowError = !0, J("moment.tz.zoneExists('" + o + "') has been deprecated in favor of !moment.tz.zone('" + o + "')")), !!
|
|
505
|
+
return W0.didShowError || (W0.didShowError = !0, J("moment.tz.zoneExists('" + o + "') has been deprecated in favor of !moment.tz.zone('" + o + "')")), !!y(o);
|
|
506
506
|
}
|
|
507
507
|
function o0(o) {
|
|
508
508
|
var q = o._f === "X" || o._f === "x";
|
|
@@ -513,10 +513,10 @@ var U0 = { exports: {} };
|
|
|
513
513
|
}
|
|
514
514
|
function I(o) {
|
|
515
515
|
var q = Array.prototype.slice.call(arguments, 0, -1), e = arguments[arguments.length - 1], R = z.utc.apply(null, q), T;
|
|
516
|
-
return !z.isMoment(o) && o0(R) && (T =
|
|
516
|
+
return !z.isMoment(o) && o0(R) && (T = y(e)) && R.add(T.parse(R), "minutes"), R.tz(e), R;
|
|
517
517
|
}
|
|
518
|
-
I.version = b, I.dataVersion = "", I._zones = p, I._links = W, I._names = c, I._countries = A, I.add = c0, I.link = O0, I.load = H, I.zone =
|
|
519
|
-
var
|
|
518
|
+
I.version = b, I.dataVersion = "", I._zones = p, I._links = W, I._names = c, I._countries = A, I.add = c0, I.link = O0, I.load = H, I.zone = y, I.zoneExists = W0, I.guess = q0, I.names = Y0, I.Zone = L, I.unpack = m, I.unpackBase60 = t, I.needsOffset = o0, I.moveInvalidForward = !0, I.moveAmbiguousForward = !1, I.countries = p0, I.zonesForCountry = M0;
|
|
519
|
+
var K = z.fn;
|
|
520
520
|
z.tz = I, z.defaultZone = null, z.updateOffset = function(o, q) {
|
|
521
521
|
var e = z.defaultZone, R;
|
|
522
522
|
if (o._z === void 0 && (e && o0(o) && !o._isUTC && o.isValid() && (o._d = z.utc(o._a)._d, o.utc().add(e.parse(o), "minutes")), o._z = e), o._z)
|
|
@@ -525,11 +525,11 @@ var U0 = { exports: {} };
|
|
|
525
525
|
o.utcOffset(-R, q), o._z = T;
|
|
526
526
|
} else
|
|
527
527
|
o.zone(R, q);
|
|
528
|
-
},
|
|
528
|
+
}, K.tz = function(o, q) {
|
|
529
529
|
if (o) {
|
|
530
530
|
if (typeof o != "string")
|
|
531
531
|
throw new Error("Time zone name must be a string, got " + o + " [" + typeof o + "]");
|
|
532
|
-
return this._z =
|
|
532
|
+
return this._z = y(o), this._z ? z.updateOffset(this, q) : J("Moment Timezone has no data for " + o + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
|
|
533
533
|
}
|
|
534
534
|
if (this._z)
|
|
535
535
|
return this._z.name;
|
|
@@ -544,13 +544,13 @@ var U0 = { exports: {} };
|
|
|
544
544
|
return this._z = null, o.apply(this, arguments);
|
|
545
545
|
};
|
|
546
546
|
}
|
|
547
|
-
function
|
|
547
|
+
function L0(o) {
|
|
548
548
|
return function() {
|
|
549
549
|
return arguments.length > 0 && (this._z = null), o.apply(this, arguments);
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
|
-
|
|
553
|
-
return (n < 2 || n === 2 && X < 9) && J("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + z.version + "."), z.defaultZone = o ?
|
|
552
|
+
K.zoneName = d0(K.zoneName), K.zoneAbbr = d0(K.zoneAbbr), K.utc = a0(K.utc), K.local = a0(K.local), K.utcOffset = L0(K.utcOffset), z.tz.setDefault = function(o) {
|
|
553
|
+
return (n < 2 || n === 2 && X < 9) && J("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + z.version + "."), z.defaultZone = o ? y(o) : null, z;
|
|
554
554
|
};
|
|
555
555
|
var b0 = z.momentProperties;
|
|
556
556
|
return Object.prototype.toString.call(b0) === "[object Array]" ? (b0.push("_z"), b0.push("_a")) : b0 && (b0._z = null), z;
|
|
@@ -1412,21 +1412,21 @@ const h0 = "2025b", C0 = [
|
|
|
1412
1412
|
};
|
|
1413
1413
|
var y0 = _0;
|
|
1414
1414
|
y0.tz.load(g0);
|
|
1415
|
-
var
|
|
1416
|
-
Object.defineProperty(
|
|
1417
|
-
var k =
|
|
1415
|
+
var i0 = {};
|
|
1416
|
+
Object.defineProperty(i0, "__esModule", { value: !0 });
|
|
1417
|
+
var k = i0.Variable = void 0, u0;
|
|
1418
1418
|
(function(M) {
|
|
1419
1419
|
M[M.undefined = 0] = "undefined", M[M.apparent_temperature = 1] = "apparent_temperature", M[M.cape = 2] = "cape", M[M.cloud_cover = 3] = "cloud_cover", M[M.cloud_cover_high = 4] = "cloud_cover_high", M[M.cloud_cover_low = 5] = "cloud_cover_low", M[M.cloud_cover_mid = 6] = "cloud_cover_mid", M[M.daylight_duration = 7] = "daylight_duration", M[M.dew_point = 8] = "dew_point", M[M.diffuse_radiation = 9] = "diffuse_radiation", M[M.diffuse_radiation_instant = 10] = "diffuse_radiation_instant", M[M.direct_normal_irradiance = 11] = "direct_normal_irradiance", M[M.direct_normal_irradiance_instant = 12] = "direct_normal_irradiance_instant", M[M.direct_radiation = 13] = "direct_radiation", M[M.direct_radiation_instant = 14] = "direct_radiation_instant", M[M.et0_fao_evapotranspiration = 15] = "et0_fao_evapotranspiration", M[M.evapotranspiration = 16] = "evapotranspiration", M[M.freezing_level_height = 17] = "freezing_level_height", M[M.growing_degree_days = 18] = "growing_degree_days", M[M.is_day = 19] = "is_day", M[M.latent_heat_flux = 20] = "latent_heat_flux", M[M.leaf_wetness_probability = 21] = "leaf_wetness_probability", M[M.lifted_index = 22] = "lifted_index", M[M.lightning_potential = 23] = "lightning_potential", M[M.precipitation = 24] = "precipitation", M[M.precipitation_hours = 25] = "precipitation_hours", M[M.precipitation_probability = 26] = "precipitation_probability", M[M.pressure_msl = 27] = "pressure_msl", M[M.rain = 28] = "rain", M[M.relative_humidity = 29] = "relative_humidity", M[M.runoff = 30] = "runoff", M[M.sensible_heat_flux = 31] = "sensible_heat_flux", M[M.shortwave_radiation = 32] = "shortwave_radiation", M[M.shortwave_radiation_instant = 33] = "shortwave_radiation_instant", M[M.showers = 34] = "showers", M[M.snow_depth = 35] = "snow_depth", M[M.snow_height = 36] = "snow_height", M[M.snowfall = 37] = "snowfall", M[M.snowfall_height = 38] = "snowfall_height", M[M.snowfall_water_equivalent = 39] = "snowfall_water_equivalent", M[M.sunrise = 40] = "sunrise", M[M.sunset = 41] = "sunset", M[M.soil_moisture = 42] = "soil_moisture", M[M.soil_moisture_index = 43] = "soil_moisture_index", M[M.soil_temperature = 44] = "soil_temperature", M[M.surface_pressure = 45] = "surface_pressure", M[M.surface_temperature = 46] = "surface_temperature", M[M.temperature = 47] = "temperature", M[M.terrestrial_radiation = 48] = "terrestrial_radiation", M[M.terrestrial_radiation_instant = 49] = "terrestrial_radiation_instant", M[M.total_column_integrated_water_vapour = 50] = "total_column_integrated_water_vapour", M[M.updraft = 51] = "updraft", M[M.uv_index = 52] = "uv_index", M[M.uv_index_clear_sky = 53] = "uv_index_clear_sky", M[M.vapour_pressure_deficit = 54] = "vapour_pressure_deficit", M[M.visibility = 55] = "visibility", M[M.weather_code = 56] = "weather_code", M[M.wind_direction = 57] = "wind_direction", M[M.wind_gusts = 58] = "wind_gusts", M[M.wind_speed = 59] = "wind_speed", M[M.vertical_velocity = 60] = "vertical_velocity", M[M.geopotential_height = 61] = "geopotential_height", M[M.wet_bulb_temperature = 62] = "wet_bulb_temperature", M[M.river_discharge = 63] = "river_discharge", M[M.wave_height = 64] = "wave_height", M[M.wave_period = 65] = "wave_period", M[M.wave_direction = 66] = "wave_direction", M[M.wind_wave_height = 67] = "wind_wave_height", M[M.wind_wave_period = 68] = "wind_wave_period", M[M.wind_wave_peak_period = 69] = "wind_wave_peak_period", M[M.wind_wave_direction = 70] = "wind_wave_direction", M[M.swell_wave_height = 71] = "swell_wave_height", M[M.swell_wave_period = 72] = "swell_wave_period", M[M.swell_wave_peak_period = 73] = "swell_wave_peak_period", M[M.swell_wave_direction = 74] = "swell_wave_direction", M[M.pm10 = 75] = "pm10", M[M.pm2p5 = 76] = "pm2p5", M[M.dust = 77] = "dust", M[M.aerosol_optical_depth = 78] = "aerosol_optical_depth", M[M.carbon_monoxide = 79] = "carbon_monoxide", M[M.nitrogen_dioxide = 80] = "nitrogen_dioxide", M[M.ammonia = 81] = "ammonia", M[M.ozone = 82] = "ozone", M[M.sulphur_dioxide = 83] = "sulphur_dioxide", M[M.alder_pollen = 84] = "alder_pollen", M[M.birch_pollen = 85] = "birch_pollen", M[M.grass_pollen = 86] = "grass_pollen", M[M.mugwort_pollen = 87] = "mugwort_pollen", M[M.olive_pollen = 88] = "olive_pollen", M[M.ragweed_pollen = 89] = "ragweed_pollen", M[M.european_aqi = 90] = "european_aqi", M[M.european_aqi_pm2p5 = 91] = "european_aqi_pm2p5", M[M.european_aqi_pm10 = 92] = "european_aqi_pm10", M[M.european_aqi_nitrogen_dioxide = 93] = "european_aqi_nitrogen_dioxide", M[M.european_aqi_ozone = 94] = "european_aqi_ozone", M[M.european_aqi_sulphur_dioxide = 95] = "european_aqi_sulphur_dioxide", M[M.us_aqi = 96] = "us_aqi", M[M.us_aqi_pm2p5 = 97] = "us_aqi_pm2p5", M[M.us_aqi_pm10 = 98] = "us_aqi_pm10", M[M.us_aqi_nitrogen_dioxide = 99] = "us_aqi_nitrogen_dioxide", M[M.us_aqi_ozone = 100] = "us_aqi_ozone", M[M.us_aqi_sulphur_dioxide = 101] = "us_aqi_sulphur_dioxide", M[M.us_aqi_carbon_monoxide = 102] = "us_aqi_carbon_monoxide", M[M.sunshine_duration = 103] = "sunshine_duration", M[M.convective_inhibition = 104] = "convective_inhibition", M[M.shortwave_radiation_clear_sky = 105] = "shortwave_radiation_clear_sky", M[M.global_tilted_irradiance = 106] = "global_tilted_irradiance", M[M.global_tilted_irradiance_instant = 107] = "global_tilted_irradiance_instant", M[M.ocean_current_velocity = 108] = "ocean_current_velocity", M[M.ocean_current_direction = 109] = "ocean_current_direction", M[M.cloud_base = 110] = "cloud_base", M[M.cloud_top = 111] = "cloud_top", M[M.mass_density = 112] = "mass_density", M[M.boundary_layer_height = 113] = "boundary_layer_height", M[M.formaldehyde = 114] = "formaldehyde", M[M.glyoxal = 115] = "glyoxal", M[M.non_methane_volatile_organic_compounds = 116] = "non_methane_volatile_organic_compounds", M[M.pm10_wildfires = 117] = "pm10_wildfires", M[M.peroxyacyl_nitrates = 118] = "peroxyacyl_nitrates", M[M.secondary_inorganic_aerosol = 119] = "secondary_inorganic_aerosol", M[M.residential_elementary_carbon = 120] = "residential_elementary_carbon", M[M.total_elementary_carbon = 121] = "total_elementary_carbon", M[M.pm2_5_total_organic_matter = 122] = "pm2_5_total_organic_matter", M[M.sea_salt_aerosol = 123] = "sea_salt_aerosol", M[M.nitrogen_monoxide = 124] = "nitrogen_monoxide", M[M.thunderstorm_probability = 125] = "thunderstorm_probability", M[M.rain_probability = 126] = "rain_probability", M[M.freezing_rain_probability = 127] = "freezing_rain_probability", M[M.ice_pellets_probability = 128] = "ice_pellets_probability", M[M.snowfall_probability = 129] = "snowfall_probability", M[M.carbon_dioxide = 130] = "carbon_dioxide", M[M.methane = 131] = "methane", M[M.sea_level_height_msl = 132] = "sea_level_height_msl", M[M.sea_surface_temperature = 133] = "sea_surface_temperature", M[M.invert_barometer_height = 134] = "invert_barometer_height", M[M.hail = 135] = "hail", M[M.albedo = 136] = "albedo", M[M.precipitation_type = 137] = "precipitation_type", M[M.convective_cloud_base = 138] = "convective_cloud_base", M[M.convective_cloud_top = 139] = "convective_cloud_top", M[M.snow_depth_water_equivalent = 140] = "snow_depth_water_equivalent", M[M.secondary_swell_wave_height = 141] = "secondary_swell_wave_height", M[M.secondary_swell_wave_period = 142] = "secondary_swell_wave_period", M[M.secondary_swell_wave_peak_period = 143] = "secondary_swell_wave_peak_period", M[M.secondary_swell_wave_direction = 144] = "secondary_swell_wave_direction", M[M.tertiary_swell_wave_height = 145] = "tertiary_swell_wave_height", M[M.tertiary_swell_wave_period = 146] = "tertiary_swell_wave_period", M[M.tertiary_swell_wave_peak_period = 147] = "tertiary_swell_wave_peak_period", M[M.tertiary_swell_wave_direction = 148] = "tertiary_swell_wave_direction", M[M.wind_u_component = 149] = "wind_u_component", M[M.wind_v_component = 150] = "wind_v_component", M[M.temperature_max24h = 151] = "temperature_max24h", M[M.temperature_min24h = 152] = "temperature_min24h", M[M.temperature_mean24h = 153] = "temperature_mean24h", M[M.snow_density = 154] = "snow_density", M[M.longwave_radiation = 155] = "longwave_radiation", M[M.sea_ice_cover = 156] = "sea_ice_cover", M[M.k_index = 157] = "k_index", M[M.roughness_length = 158] = "roughness_length", M[M.potential_evapotranspiration = 159] = "potential_evapotranspiration", M[M.wave_peak_period = 160] = "wave_peak_period", M[M.temperature_max6h = 161] = "temperature_max6h", M[M.temperature_min6h = 162] = "temperature_min6h", M[M.lightning_density = 163] = "lightning_density", M[M.sea_ice_thickness = 164] = "sea_ice_thickness", M[M.shortwave_radiation_clear_sky_instant = 165] = "shortwave_radiation_clear_sky_instant", M[M.sea_water_salinity = 166] = "sea_water_salinity";
|
|
1420
|
-
})(u0 || (k =
|
|
1420
|
+
})(u0 || (k = i0.Variable = u0 = {}));
|
|
1421
1421
|
var T0 = {};
|
|
1422
1422
|
Object.defineProperty(T0, "__esModule", { value: !0 });
|
|
1423
1423
|
var z0 = T0.Aggregation = void 0, N0;
|
|
1424
1424
|
(function(M) {
|
|
1425
1425
|
M[M.none = 0] = "none", M[M.minimum = 1] = "minimum", M[M.maximum = 2] = "maximum", M[M.mean = 3] = "mean", M[M.p10 = 4] = "p10", M[M.p25 = 5] = "p25", M[M.median = 6] = "median", M[M.p75 = 7] = "p75", M[M.p90 = 8] = "p90", M[M.dominant = 9] = "dominant", M[M.sum = 10] = "sum", M[M.spread = 11] = "spread", M[M.anomaly = 12] = "anomaly", M[M.sot10 = 13] = "sot10", M[M.sot90 = 14] = "sot90", M[M.efi = 15] = "efi";
|
|
1426
1426
|
})(N0 || (z0 = T0.Aggregation = N0 = {}));
|
|
1427
|
-
let
|
|
1427
|
+
let G;
|
|
1428
1428
|
try {
|
|
1429
|
-
|
|
1429
|
+
G = e0.getLogger("meteo2");
|
|
1430
1430
|
} catch {
|
|
1431
1431
|
} finally {
|
|
1432
1432
|
}
|
|
@@ -1477,7 +1477,7 @@ class Q {
|
|
|
1477
1477
|
}
|
|
1478
1478
|
});
|
|
1479
1479
|
F(this, "METEO2_UPDATE", {
|
|
1480
|
-
etime:
|
|
1480
|
+
etime: i().unix(),
|
|
1481
1481
|
version: 0
|
|
1482
1482
|
});
|
|
1483
1483
|
this.apikey = z || "smE3JnDLHy3TizVv", this.debug = b;
|
|
@@ -1486,20 +1486,20 @@ class Q {
|
|
|
1486
1486
|
* 标准大气模式
|
|
1487
1487
|
*/
|
|
1488
1488
|
async standardWeatherModels() {
|
|
1489
|
-
return
|
|
1489
|
+
return g.standardWeatherModels();
|
|
1490
1490
|
}
|
|
1491
1491
|
/**
|
|
1492
1492
|
* 标准海洋模式
|
|
1493
1493
|
*/
|
|
1494
1494
|
async standardMarineModels() {
|
|
1495
|
-
return
|
|
1495
|
+
return g.standardMarineModels();
|
|
1496
1496
|
}
|
|
1497
1497
|
/**
|
|
1498
1498
|
* 自动匹配大气模式和海洋模式
|
|
1499
1499
|
* @param model0
|
|
1500
1500
|
*/
|
|
1501
1501
|
async autoPickMeteoModel(z = "best_match") {
|
|
1502
|
-
return
|
|
1502
|
+
return g.autoPickMeteoModel(z);
|
|
1503
1503
|
}
|
|
1504
1504
|
/**
|
|
1505
1505
|
* 生成指定范围内的数字序列
|
|
@@ -1520,37 +1520,32 @@ class Q {
|
|
|
1520
1520
|
* @param options
|
|
1521
1521
|
*/
|
|
1522
1522
|
async weatherForecast(z, b, p, W, A, c = {}) {
|
|
1523
|
-
const { st: O, et: Y, interval: a } = await this.checkTimeInterval(z.start_date, z.end_date, !p && !W && !A, c)
|
|
1523
|
+
const { st: O, et: Y, interval: a } = await this.checkTimeInterval(z.start_date, z.end_date, !p && !W && !A, c);
|
|
1524
|
+
let n = "";
|
|
1525
|
+
const X = i();
|
|
1524
1526
|
try {
|
|
1525
|
-
if (p)
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
return await this.tryToFetchWeatherApi(
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
z.start_date = O == null ? void 0 : O.clone().subtract(X, "year").format("YYYY-MM-DD"), z.end_date = Y == null ? void 0 : Y.clone().subtract(X, "year").format("YYYY-MM-DD");
|
|
1543
|
-
const d = this.pickForecastUrl(!1, !0, !1, c);
|
|
1544
|
-
return await this.tryToFetchWeatherApi(d, z, b, X, c);
|
|
1545
|
-
} else {
|
|
1546
|
-
const X = this.pickForecastUrl(!1, !0, !1, c);
|
|
1547
|
-
return await this.tryToFetchWeatherApi(X, z, b, 0, c);
|
|
1527
|
+
if (p)
|
|
1528
|
+
return n = this.SEASONAL.OM_URL, await this.tryToFetchWeatherApi(n, z, b, 0, c);
|
|
1529
|
+
if (W)
|
|
1530
|
+
return n = this.CLIMATE.OM_URL, await this.tryToFetchWeatherApi(n, z, b, 0, c);
|
|
1531
|
+
if (A)
|
|
1532
|
+
return n = this.HISTORICAL.OM_URL, await this.tryToFetchWeatherApi(n, z, b, 0, c);
|
|
1533
|
+
if (!z.start_date && !z.end_date)
|
|
1534
|
+
return n = this.pickForecastUrl(!1, c.selfHosted, !1, c), await this.tryToFetchWeatherApi(n, z, b, 0, c);
|
|
1535
|
+
{
|
|
1536
|
+
const d = c.selfHostedMaxDays || 240, t = c.fakeForecastMaxDays || 30;
|
|
1537
|
+
if (Y != null && Y.isBefore(X.clone().subtract(d, "day")))
|
|
1538
|
+
return n = this.pickForecastUrl(!1, !1, !0, c), await this.tryToFetchWeatherApi(n, z, b, 0, c);
|
|
1539
|
+
if (O != null && O.isAfter(X.clone().add(t, "day"))) {
|
|
1540
|
+
const r = O.get("year") - X.get("year") + 1;
|
|
1541
|
+
return z.start_date = O == null ? void 0 : O.clone().subtract(r, "year").format("YYYY-MM-DD"), z.end_date = Y == null ? void 0 : Y.clone().subtract(r, "year").format("YYYY-MM-DD"), n = this.pickForecastUrl(!1, !0, !1, c), await this.tryToFetchWeatherApi(n, z, b, r, c);
|
|
1542
|
+
} else
|
|
1543
|
+
return n = this.pickForecastUrl(!1, !0, !1, c), await this.tryToFetchWeatherApi(n, z, b, 0, c);
|
|
1548
1544
|
}
|
|
1549
|
-
} catch (
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
return await this.tryToFetchWeatherApi(r, z, b, 0, c);
|
|
1545
|
+
} catch (d) {
|
|
1546
|
+
G.warn("[%s] fetch weather api (%s) failed: %s", c.requestId, n, { message: d == null ? void 0 : d.message, params: z });
|
|
1547
|
+
const { start_date: t, end_date: r } = await this.matchDateRange(d == null ? void 0 : d.message, a, "", c);
|
|
1548
|
+
return z.start_date = t, z.end_date = r, G.info("[%s] retry with extracted date range: %s to %s", c.requestId, t, r), n = p ? this.SEASONAL.OM_URL : W ? this.CLIMATE.OM_URL : A ? this.HISTORICAL.OM_URL : this.pickForecastUrl(!1, !0, !1, c), await this.tryToFetchWeatherApi(n, z, b, 0, c);
|
|
1554
1549
|
}
|
|
1555
1550
|
}
|
|
1556
1551
|
/**
|
|
@@ -1563,16 +1558,12 @@ class Q {
|
|
|
1563
1558
|
* @private
|
|
1564
1559
|
*/
|
|
1565
1560
|
async tryToFetchWeatherApi(z, b, p, W = 0, A = {}) {
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
return this.debug && _.info("[%s] fetch weather api (%s) cost: %d ms", A.requestId, b.url, a.diff(c, "ms")), this.mergeWeatherData(Y);
|
|
1573
|
-
} catch (c) {
|
|
1574
|
-
throw _.warn("[%s] weather forecast failed: %s, with %j", A.requestId, c, b), c;
|
|
1575
|
-
}
|
|
1561
|
+
const c = i();
|
|
1562
|
+
G.debug("[%s] fetch weather via %s with %j", A.requestId, z, b);
|
|
1563
|
+
const O = await t0(z, b), Y = p ? await p(O, b, A) : await this.parseWeatherData(O, b, W, A);
|
|
1564
|
+
delete b.apikey;
|
|
1565
|
+
const a = i();
|
|
1566
|
+
return G.debug("[%s] fetch weather api (%s) cost: %d ms", A.requestId, b.url, a.diff(c, "ms")), this.mergeWeatherData(Y);
|
|
1576
1567
|
}
|
|
1577
1568
|
/**
|
|
1578
1569
|
* 海洋数据
|
|
@@ -1590,48 +1581,56 @@ class Q {
|
|
|
1590
1581
|
* @param options
|
|
1591
1582
|
*/
|
|
1592
1583
|
async marineForecast(z, b = {}) {
|
|
1593
|
-
var
|
|
1594
|
-
const { st: p, et: W, interval: A } = await this.checkTimeInterval(z.start_date, z.end_date, !0, b)
|
|
1595
|
-
let
|
|
1584
|
+
var s, m, L, U, Z, N, l, _;
|
|
1585
|
+
const { st: p, et: W, interval: A } = await this.checkTimeInterval(z.start_date, z.end_date, !0, b);
|
|
1586
|
+
let c = "";
|
|
1587
|
+
const O = i(), Y = [];
|
|
1588
|
+
let a = 0;
|
|
1596
1589
|
if (!z.start_date && !z.end_date) {
|
|
1597
|
-
|
|
1598
|
-
|
|
1590
|
+
c = this.pickForecastUrl(!0, b.selfHosted, !1, b);
|
|
1591
|
+
const f = await this.tryToFetchMarineApi(c, z, b);
|
|
1592
|
+
Y.push(...f);
|
|
1599
1593
|
} else
|
|
1600
1594
|
for (const f of z.models)
|
|
1601
1595
|
try {
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
Y
|
|
1607
|
-
|
|
1608
|
-
O.
|
|
1596
|
+
const E = b.selfHostedMaxDays || 240, w = b.fakeForecastMaxDays || 30;
|
|
1597
|
+
if (W != null && W.isBefore(O.clone().subtract(E, "day"))) {
|
|
1598
|
+
c = this.pickForecastUrl(!0, !1, !0, b);
|
|
1599
|
+
const D = await this.tryToFetchMarineApi(c, { ...z, models: [f] }, b);
|
|
1600
|
+
Y.push(...D);
|
|
1601
|
+
} else if (p != null && p.isAfter(O.clone().add(w, "day"))) {
|
|
1602
|
+
a = p.get("year") - O.get("year") + 1, z.start_date = p == null ? void 0 : p.clone().subtract(a, "year").format("YYYY-MM-DD"), z.end_date = W == null ? void 0 : W.clone().subtract(a, "year").format("YYYY-MM-DD"), c = this.pickForecastUrl(!0, !0, !0, b);
|
|
1603
|
+
const D = await this.tryToFetchMarineApi(c, { ...z, models: [f] }, b);
|
|
1604
|
+
Y.push(...D);
|
|
1609
1605
|
} else {
|
|
1610
|
-
|
|
1611
|
-
|
|
1606
|
+
c = this.pickForecastUrl(!0, !0, !1, b);
|
|
1607
|
+
const D = await this.tryToFetchMarineApi(c, { ...z, models: [f] }, b);
|
|
1608
|
+
Y.push(...D);
|
|
1612
1609
|
}
|
|
1613
|
-
} catch (
|
|
1614
|
-
|
|
1610
|
+
} catch (E) {
|
|
1611
|
+
G.warn("[%s] fetch marine api (%s) failed: %j", b.requestId, { message: E == null ? void 0 : E.message, model: f, params: z });
|
|
1612
|
+
const { start_date: w, end_date: D } = await this.matchDateRange(E == null ? void 0 : E.message, A, f, b);
|
|
1613
|
+
G.info("[%s] retry with extracted date range: %s to %s", b.requestId, w, D), c = this.pickForecastUrl(!0, !0, !1, b);
|
|
1615
1614
|
try {
|
|
1616
1615
|
const v = await this.tryToFetchMarineApi(
|
|
1617
|
-
|
|
1616
|
+
c,
|
|
1618
1617
|
{
|
|
1619
1618
|
...z,
|
|
1620
|
-
start_date:
|
|
1621
|
-
end_date:
|
|
1619
|
+
start_date: w,
|
|
1620
|
+
end_date: D,
|
|
1622
1621
|
models: [f]
|
|
1623
1622
|
},
|
|
1624
1623
|
b
|
|
1625
1624
|
);
|
|
1626
|
-
|
|
1625
|
+
Y.push(...v);
|
|
1627
1626
|
} catch (v) {
|
|
1628
|
-
|
|
1627
|
+
G.warn("[%s] marine forecast for model %s failed: %s, just ignore", b.requestId, f, v);
|
|
1629
1628
|
}
|
|
1630
1629
|
}
|
|
1631
|
-
const
|
|
1630
|
+
const n = await this.parseWeatherData(Y, z, a, b);
|
|
1632
1631
|
delete z.apikey;
|
|
1633
|
-
const
|
|
1634
|
-
return (
|
|
1632
|
+
const X = await this.mergeMarineData(n, p), d = X.find((f) => f.model === "ncep_gfswave016"), t = X.find((f) => f.model === "ncep_gfswave025"), r = X.find((f) => f.model === "meteofrance_wave"), u = X.find((f) => f.model === "best_match");
|
|
1633
|
+
return (m = (s = u == null ? void 0 : u.hourly) == null ? void 0 : s.wave_height) != null && m.every((f) => f !== null) ? [u] : (U = (L = r == null ? void 0 : r.hourly) == null ? void 0 : L.wave_height) != null && U.every((f) => f !== null) ? [r] : (N = (Z = d == null ? void 0 : d.hourly) == null ? void 0 : Z.wave_height) != null && N.every((f) => f !== null) ? [d] : (_ = (l = t == null ? void 0 : t.hourly) == null ? void 0 : l.wave_height) != null && _.every((f) => f !== null) ? [t] : X != null && X.length ? [X[0]] : [];
|
|
1635
1634
|
}
|
|
1636
1635
|
/**
|
|
1637
1636
|
* 尝试调用海洋接口
|
|
@@ -1641,14 +1640,10 @@ class Q {
|
|
|
1641
1640
|
* @private
|
|
1642
1641
|
*/
|
|
1643
1642
|
async tryToFetchMarineApi(z, b, p = {}) {
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
return this.debug && _.info("[%s] fetch weather api (%s) cost: %d ms", p.requestId, b.url, c.diff(W, "ms")), A;
|
|
1649
|
-
} catch (W) {
|
|
1650
|
-
throw _.warn("[%s] marine forecast failed: %s, with %j", p.requestId, W, b), W;
|
|
1651
|
-
}
|
|
1643
|
+
const W = i();
|
|
1644
|
+
G.debug("[%s] fetch marine via %s with %j", p.requestId, z, b);
|
|
1645
|
+
const A = await t0(z, b), c = i();
|
|
1646
|
+
return G.debug("[%s] fetch weather api (%s) cost: %d ms", p.requestId, b.url, c.diff(W, "ms")), A;
|
|
1652
1647
|
}
|
|
1653
1648
|
/**
|
|
1654
1649
|
* 检查时间区间, 并调整为合理范围(不超时90天)
|
|
@@ -1660,23 +1655,38 @@ class Q {
|
|
|
1660
1655
|
*/
|
|
1661
1656
|
async checkTimeInterval(z, b, p, W = {}) {
|
|
1662
1657
|
let A, c, O = 1;
|
|
1663
|
-
|
|
1658
|
+
if (p) {
|
|
1659
|
+
if (z && b) {
|
|
1660
|
+
A = i.utc(z), c = i.utc(b);
|
|
1661
|
+
const Y = W.maxIntervalDays || 90;
|
|
1662
|
+
c.diff(A, "days") > Y && (c = A.clone().add(Y, "d")), O = c.diff(A, "day");
|
|
1663
|
+
}
|
|
1664
|
+
this.debug && G.info("[%s] check time interval: %s to %s, with interval: %d days", W.requestId, A == null ? void 0 : A.format(), c == null ? void 0 : c.format(), O);
|
|
1665
|
+
} else
|
|
1666
|
+
A = i.utc(z), c = i.utc(b), O = c.diff(A, "day");
|
|
1667
|
+
return { st: A, et: c, interval: O };
|
|
1664
1668
|
}
|
|
1665
1669
|
/**
|
|
1666
1670
|
* 从消息中提取时间区间, 并调整为合理范围
|
|
1667
1671
|
* @param message
|
|
1668
1672
|
* @param interval
|
|
1673
|
+
* @param model
|
|
1669
1674
|
* @param options
|
|
1670
1675
|
* @private
|
|
1671
1676
|
*/
|
|
1672
|
-
async matchDateRange(z, b = 1, p = {}) {
|
|
1673
|
-
const
|
|
1674
|
-
if (
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
+
async matchDateRange(z, b = 1, p = "", W = {}) {
|
|
1678
|
+
const A = z == null ? void 0 : z.match(/from (\d{4}-\d{2}-\d{2}) to (\d{4}-\d{2}-\d{2})/);
|
|
1679
|
+
if (A) {
|
|
1680
|
+
let c = i.utc(A[2]);
|
|
1681
|
+
if (p === "meteofrance_currents") {
|
|
1682
|
+
const a = i.utc().add(W.fakeCurrentMaxDays || 9, "day");
|
|
1683
|
+
c.isAfter(a) && (c = a);
|
|
1684
|
+
}
|
|
1685
|
+
const O = c.format("YYYY-MM-DD"), Y = c.subtract(b || 1, "day").format("YYYY-MM-DD");
|
|
1686
|
+
return G.info("[%s] extract date range from message: %s to %s", W.requestId, Y, O), { start_date: Y, end_date: O };
|
|
1677
1687
|
} else {
|
|
1678
|
-
const
|
|
1679
|
-
return
|
|
1688
|
+
const c = i.utc().add(7, "day"), O = c.format("YYYY-MM-DD"), Y = c.clone().subtract(b, "day").format("YYYY-MM-DD");
|
|
1689
|
+
return G.info("[%s] extract date range with interval (%d): %s to %s", W.requestId, b, Y, O), { start_date: Y, end_date: O };
|
|
1680
1690
|
}
|
|
1681
1691
|
}
|
|
1682
1692
|
/**
|
|
@@ -1691,47 +1701,47 @@ class Q {
|
|
|
1691
1701
|
var O, Y, a, n, X, d, t;
|
|
1692
1702
|
const A = [], c = Math.pow(10, W.precision || 6);
|
|
1693
1703
|
for (let r = 0; r < z.length; r++) {
|
|
1694
|
-
const u = z[r],
|
|
1695
|
-
if (N.timezone = m || void 0, N.offset = Q.prettyTimezoneOffset(
|
|
1696
|
-
const
|
|
1704
|
+
const u = z[r], s = u.utcOffsetSeconds(), m = u.timezone(), L = u.current(), U = u.hourly(), Z = u.daily(), N = {};
|
|
1705
|
+
if (N.timezone = m || void 0, N.offset = Q.prettyTimezoneOffset(s), N.model = b.models instanceof Array ? (O = b.models) == null ? void 0 : O[r] : b.models || "best_match", L) {
|
|
1706
|
+
const l = i();
|
|
1697
1707
|
N.current = {
|
|
1698
|
-
time:
|
|
1708
|
+
time: i.unix(Number(L.time())).utc().add(p, "year").format()
|
|
1699
1709
|
};
|
|
1700
|
-
for (let
|
|
1701
|
-
const
|
|
1702
|
-
N.current[b.current[
|
|
1710
|
+
for (let f = 0; f < L.variablesLength(); f++) {
|
|
1711
|
+
const E = L.variables(f).value();
|
|
1712
|
+
N.current[b.current[f]] = isNaN(E) ? null : Math.round(E * c) / c;
|
|
1703
1713
|
}
|
|
1704
|
-
const
|
|
1705
|
-
this.debug &&
|
|
1714
|
+
const _ = i();
|
|
1715
|
+
this.debug && G.debug("[%s] fetch current variables cost: %d ms", W.requestId, _.diff(l, "ms"));
|
|
1706
1716
|
}
|
|
1707
|
-
if (
|
|
1708
|
-
const
|
|
1717
|
+
if (U) {
|
|
1718
|
+
const l = i(), _ = i.unix(Number(U.time())).add(p, "year");
|
|
1709
1719
|
N.hourly = {
|
|
1710
|
-
date:
|
|
1711
|
-
time: Q.range(Number(
|
|
1712
|
-
(
|
|
1720
|
+
date: _.utc().format(),
|
|
1721
|
+
time: Q.range(Number(U.time()), Number(U.timeEnd()), U.interval()).map(
|
|
1722
|
+
(E) => i.unix(E).add(p, "year").diff(_, "h")
|
|
1713
1723
|
)
|
|
1714
1724
|
};
|
|
1715
|
-
for (let
|
|
1716
|
-
const w = (n = (a = (Y =
|
|
1717
|
-
N.hourly[b.hourly[
|
|
1725
|
+
for (let E = 0; E < U.variablesLength(); E++) {
|
|
1726
|
+
const w = (n = (a = (Y = U.variables(E).valuesArray()) == null ? void 0 : Y.toString()) == null ? void 0 : a.split(",")) == null ? void 0 : n.map((D) => isNaN(D) ? null : Math.round(Number(D) * c) / c);
|
|
1727
|
+
N.hourly[b.hourly[E]] = w;
|
|
1718
1728
|
}
|
|
1719
|
-
const
|
|
1720
|
-
this.debug &&
|
|
1729
|
+
const f = i();
|
|
1730
|
+
this.debug && G.debug("[%s] fetch hourly variables cost: %d ms", W.requestId, f.diff(l, "ms"));
|
|
1721
1731
|
}
|
|
1722
|
-
if (
|
|
1723
|
-
const
|
|
1732
|
+
if (Z) {
|
|
1733
|
+
const l = i();
|
|
1724
1734
|
N.daily = {
|
|
1725
|
-
time: Q.range(Number(
|
|
1726
|
-
(
|
|
1735
|
+
time: Q.range(Number(Z.time()), Number(Z.timeEnd()), Z.interval()).map(
|
|
1736
|
+
(f) => i.unix(f).add(p, "year").utc().format()
|
|
1727
1737
|
)
|
|
1728
1738
|
};
|
|
1729
|
-
for (let
|
|
1730
|
-
const
|
|
1731
|
-
N.daily[b.daily[
|
|
1739
|
+
for (let f = 0; f < Z.variablesLength(); f += W.memberLength ?? 1) {
|
|
1740
|
+
const E = (t = (d = (X = Z.variables(f).valuesArray()) == null ? void 0 : X.toString()) == null ? void 0 : d.split(",")) == null ? void 0 : t.map((w) => isNaN(w) ? null : Math.round(Number(w) * c) / c);
|
|
1741
|
+
N.daily[b.daily[f / (W.memberLength ?? 1)]] = E;
|
|
1732
1742
|
}
|
|
1733
|
-
const
|
|
1734
|
-
this.debug &&
|
|
1743
|
+
const _ = i();
|
|
1744
|
+
this.debug && G.debug("[%s] fetch daily variables cost: %d ms", W.requestId, _.diff(l, "ms"));
|
|
1735
1745
|
}
|
|
1736
1746
|
A.push(N);
|
|
1737
1747
|
}
|
|
@@ -1744,28 +1754,28 @@ class Q {
|
|
|
1744
1754
|
* @private
|
|
1745
1755
|
*/
|
|
1746
1756
|
async parseSeasonalDailyVariable(z, b, p = {}) {
|
|
1747
|
-
var c, O, Y, a, n, X, d, t, r, u,
|
|
1757
|
+
var c, O, Y, a, n, X, d, t, r, u, s, m, L, U, Z, N, l, _, f, E, w, D, v, q0, j, c0, y, Y0;
|
|
1748
1758
|
const W = [], A = Math.pow(10, p.precision || 6);
|
|
1749
1759
|
for (let p0 = 0; p0 < z.length; p0++) {
|
|
1750
|
-
const O0 = z[p0],
|
|
1760
|
+
const O0 = z[p0], R0 = O0.utcOffsetSeconds(), X0 = O0.timezone(), M0 = O0.daily(), H = Array.from({ length: M0.variablesLength() }, (q, e) => M0.variables(e)), W0 = H.filter(
|
|
1751
1761
|
(q) => (q == null ? void 0 : q.variable()) === k.temperature && (q == null ? void 0 : q.altitude()) === 2 && (q == null ? void 0 : q.aggregation()) === z0.maximum
|
|
1752
1762
|
), o0 = H.filter(
|
|
1753
1763
|
(q) => (q == null ? void 0 : q.variable()) === k.temperature && (q == null ? void 0 : q.altitude()) === 2 && (q == null ? void 0 : q.aggregation()) === z0.minimum
|
|
1754
1764
|
), J = H.filter(
|
|
1755
1765
|
(q) => (q == null ? void 0 : q.variable()) === k.temperature && (q == null ? void 0 : q.altitude()) === 2 && (q == null ? void 0 : q.aggregation()) === z0.mean
|
|
1756
|
-
), I = H.filter((q) => (q == null ? void 0 : q.variable()) === k.precipitation),
|
|
1766
|
+
), I = H.filter((q) => (q == null ? void 0 : q.variable()) === k.precipitation), K = H.filter((q) => (q == null ? void 0 : q.variable()) === k.weather_code), d0 = H.filter(
|
|
1757
1767
|
(q) => (q == null ? void 0 : q.variable()) === k.wind_speed && (q == null ? void 0 : q.altitude()) === 10 && (q == null ? void 0 : q.aggregation()) === z0.mean
|
|
1758
1768
|
), a0 = H.filter(
|
|
1759
1769
|
(q) => (q == null ? void 0 : q.variable()) === k.wind_speed && (q == null ? void 0 : q.altitude()) === 10 && (q == null ? void 0 : q.aggregation()) === z0.maximum
|
|
1760
|
-
),
|
|
1770
|
+
), L0 = H.filter(
|
|
1761
1771
|
(q) => (q == null ? void 0 : q.variable()) === k.wind_gusts && (q == null ? void 0 : q.altitude()) === 10 && (q == null ? void 0 : q.aggregation()) === z0.maximum
|
|
1762
1772
|
), b0 = H.filter(
|
|
1763
1773
|
(q) => (q == null ? void 0 : q.variable()) === k.wind_direction && (q == null ? void 0 : q.altitude()) === 10 && (q == null ? void 0 : q.aggregation()) === z0.dominant
|
|
1764
1774
|
), o = {};
|
|
1765
|
-
if (o.timezone =
|
|
1766
|
-
const q =
|
|
1775
|
+
if (o.timezone = X0 || void 0, o.offset = Q.prettyTimezoneOffset(R0), o.model = b.models instanceof Array ? (c = b.models) == null ? void 0 : c[p0] : b.models || "best_match", M0) {
|
|
1776
|
+
const q = i();
|
|
1767
1777
|
o.daily = {
|
|
1768
|
-
time: Q.range(Number(M0.time()), Number(M0.timeEnd()), M0.interval()).map((R) =>
|
|
1778
|
+
time: Q.range(Number(M0.time()), Number(M0.timeEnd()), M0.interval()).map((R) => i.unix(R).utc().format())
|
|
1769
1779
|
};
|
|
1770
1780
|
for (const R of W0)
|
|
1771
1781
|
o.daily.temperature_2m_max = (a = (Y = (O = R.valuesArray()) == null ? void 0 : O.toString()) == null ? void 0 : Y.split(",")) == null ? void 0 : a.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
@@ -1774,19 +1784,19 @@ class Q {
|
|
|
1774
1784
|
for (const R of J)
|
|
1775
1785
|
o.daily.temperature_2m_mean = (u = (r = (t = R.valuesArray()) == null ? void 0 : t.toString()) == null ? void 0 : r.split(",")) == null ? void 0 : u.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1776
1786
|
for (const R of I)
|
|
1777
|
-
o.daily.precipitation_sum = (
|
|
1778
|
-
for (const R of
|
|
1779
|
-
o.daily.weather_code = (N = (
|
|
1787
|
+
o.daily.precipitation_sum = (L = (m = (s = R.valuesArray()) == null ? void 0 : s.toString()) == null ? void 0 : m.split(",")) == null ? void 0 : L.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1788
|
+
for (const R of K)
|
|
1789
|
+
o.daily.weather_code = (N = (Z = (U = R.valuesArray()) == null ? void 0 : U.toString()) == null ? void 0 : Z.split(",")) == null ? void 0 : N.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1780
1790
|
for (const R of b0)
|
|
1781
|
-
o.daily.wind_direction_10m_dominant = (
|
|
1791
|
+
o.daily.wind_direction_10m_dominant = (f = (_ = (l = R.valuesArray()) == null ? void 0 : l.toString()) == null ? void 0 : _.split(",")) == null ? void 0 : f.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1782
1792
|
for (const R of d0)
|
|
1783
|
-
o.daily.wind_speed_10m_mean = (
|
|
1793
|
+
o.daily.wind_speed_10m_mean = (D = (w = (E = R.valuesArray()) == null ? void 0 : E.toString()) == null ? void 0 : w.split(",")) == null ? void 0 : D.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1784
1794
|
for (const R of a0)
|
|
1785
1795
|
o.daily.wind_speed_10m_max = (j = (q0 = (v = R.valuesArray()) == null ? void 0 : v.toString()) == null ? void 0 : q0.split(",")) == null ? void 0 : j.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1786
|
-
for (const R of
|
|
1787
|
-
o.daily.wind_gusts_10m_max = (Y0 = (
|
|
1788
|
-
const e =
|
|
1789
|
-
|
|
1796
|
+
for (const R of L0)
|
|
1797
|
+
o.daily.wind_gusts_10m_max = (Y0 = (y = (c0 = R.valuesArray()) == null ? void 0 : c0.toString()) == null ? void 0 : y.split(",")) == null ? void 0 : Y0.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1798
|
+
const e = i();
|
|
1799
|
+
G.debug("[%s] fetch daily variables cost: %d ms", p.requestId, e.diff(q, "ms"));
|
|
1790
1800
|
}
|
|
1791
1801
|
W.push(o);
|
|
1792
1802
|
}
|
|
@@ -1804,7 +1814,7 @@ class Q {
|
|
|
1804
1814
|
for (let c = z[p][W][A].length; c < b[p][W][A].length; c++)
|
|
1805
1815
|
z[p][W][A].push(b[p][W][A][c]);
|
|
1806
1816
|
} else {
|
|
1807
|
-
const c =
|
|
1817
|
+
const c = i(b[p][W].date), O = i(z[p][W].date);
|
|
1808
1818
|
for (let Y = 0; Y < b[p][W][A].length; Y++) {
|
|
1809
1819
|
const a = c.clone().add(Y, "h").diff(O, "h");
|
|
1810
1820
|
a < z[p][W][A].length ? z[p][W][A][a] === null && (z[p][W][A][a] = b[p][W][A][Y]) : A === "time" ? z[p][W][A].push(a) : z[p][W][A].push(b[p][W][A][Y]);
|
|
@@ -1837,32 +1847,32 @@ class Q {
|
|
|
1837
1847
|
* @private
|
|
1838
1848
|
*/
|
|
1839
1849
|
async mergeMarineData(z, b) {
|
|
1840
|
-
var Y, a, n, X, d, t, r, u,
|
|
1850
|
+
var Y, a, n, X, d, t, r, u, s, m;
|
|
1841
1851
|
if (b && (z == null ? void 0 : z.length) > 0) {
|
|
1842
|
-
let
|
|
1852
|
+
let L = z[0], U = Math.abs((a = i((Y = z[0].hourly) == null ? void 0 : Y.date)) == null ? void 0 : a.diff(b));
|
|
1843
1853
|
for (const N of z) {
|
|
1844
|
-
const
|
|
1845
|
-
|
|
1854
|
+
const l = Math.abs((X = i((n = N.hourly) == null ? void 0 : n.date)) == null ? void 0 : X.diff(b));
|
|
1855
|
+
l < U && (U = l, L = N);
|
|
1846
1856
|
}
|
|
1847
|
-
const
|
|
1848
|
-
|
|
1849
|
-
N.hourly.date =
|
|
1857
|
+
const Z = (d = L == null ? void 0 : L.hourly) == null ? void 0 : d.date;
|
|
1858
|
+
Z && z.forEach((N) => {
|
|
1859
|
+
N.hourly.date = Z;
|
|
1850
1860
|
});
|
|
1851
1861
|
} else {
|
|
1852
|
-
z.sort((
|
|
1853
|
-
var N,
|
|
1854
|
-
return ((
|
|
1862
|
+
z.sort((U, Z) => {
|
|
1863
|
+
var N, l, _, f;
|
|
1864
|
+
return ((l = i((N = Z.hourly) == null ? void 0 : N.date)) == null ? void 0 : l.valueOf()) - ((f = i((_ = U.hourly) == null ? void 0 : _.date)) == null ? void 0 : f.valueOf());
|
|
1855
1865
|
});
|
|
1856
|
-
const
|
|
1857
|
-
|
|
1858
|
-
|
|
1866
|
+
const L = (t = z == null ? void 0 : z.at(0).hourly) == null ? void 0 : t.date;
|
|
1867
|
+
L && z.forEach((U) => {
|
|
1868
|
+
U.hourly.date = L;
|
|
1859
1869
|
});
|
|
1860
1870
|
}
|
|
1861
|
-
const p = [], W = z.find((
|
|
1871
|
+
const p = [], W = z.find((L) => L.model === "best_match");
|
|
1862
1872
|
W && p.push(W);
|
|
1863
|
-
const A = z.find((
|
|
1864
|
-
for (const
|
|
1865
|
-
["best_match", "meteofrance_currents"].includes(
|
|
1873
|
+
const A = z.find((L) => L.model === "meteofrance_currents"), c = z.find((L) => L.model === "ecmwf_wam025"), O = z.find((L) => L.model === "meteofrance_wave");
|
|
1874
|
+
for (const L of z)
|
|
1875
|
+
["best_match", "meteofrance_currents"].includes(L.model) || (L.hourly.ocean_current_velocity = (r = A == null ? void 0 : A.hourly) == null ? void 0 : r.ocean_current_velocity, L.hourly.ocean_current_direction = (u = A == null ? void 0 : A.hourly) == null ? void 0 : u.ocean_current_direction, L.hourly.sea_level_height_msl = (s = A == null ? void 0 : A.hourly) == null ? void 0 : s.sea_level_height_msl, L.hourly.sea_surface_temperature = (m = A == null ? void 0 : A.hourly) == null ? void 0 : m.sea_surface_temperature, p.push(L)), L.model === "meteofrance_wave" && c && (L.hourly.time = c.hourly.time, L.hourly.wave_height = c.hourly.wave_height, L.hourly.wave_direction = c.hourly.wave_direction, L.hourly.wave_period = c.hourly.wave_period, L.daily && c.daily && (L.daily.time = c.daily.time, L.daily.wave_height_max = c.daily.wave_height_max, L.daily.wave_direction_dominant = c.daily.wave_direction_dominant, L.daily.wave_period_max = c.daily.wave_period_max)), L.model === "ecmwf_wam025" && O && (L.hourly.swell_wave_height = O.hourly.swell_wave_height, L.hourly.swell_wave_direction = O.hourly.swell_wave_direction, L.hourly.swell_wave_period = O.hourly.swell_wave_period, L.hourly.wind_wave_height = O.hourly.wind_wave_height, L.hourly.wind_wave_direction = O.hourly.wind_wave_direction, L.hourly.wind_wave_period = O.hourly.wind_wave_period, L.daily && O.daily && (L.daily.swell_wave_height_max = O.daily.swell_wave_height_max, L.daily.swell_wave_period_max = O.daily.swell_wave_period_max, L.daily.swell_wave_direction_dominant = O.daily.swell_wave_direction_dominant, L.daily.wind_wave_height_max = O.daily.wind_wave_height_max, L.daily.wind_wave_direction_dominant = O.daily.wind_wave_direction_dominant, L.daily.wind_wave_period_max = O.daily.wind_wave_period_max));
|
|
1866
1876
|
return p;
|
|
1867
1877
|
}
|
|
1868
1878
|
/**
|
|
@@ -1923,7 +1933,7 @@ class Q {
|
|
|
1923
1933
|
*/
|
|
1924
1934
|
async prepare(z, b, p = {}) {
|
|
1925
1935
|
if (z) {
|
|
1926
|
-
const W =
|
|
1936
|
+
const W = i.utc(z);
|
|
1927
1937
|
b.start_date = W.clone().subtract(p.pastDays || 0, "day").utc().format("YYYY-MM-DD"), b.end_date = W.clone().add(p.forecastDays ?? 1, "day").utc().format("YYYY-MM-DD"), b.fake = !1;
|
|
1928
1938
|
} else
|
|
1929
1939
|
b.forecast_days = p.forecastDays, b.past_days = p.pastDays, b.fake = !1;
|
|
@@ -1935,7 +1945,7 @@ class Q {
|
|
|
1935
1945
|
return Math.round(z * p) / p;
|
|
1936
1946
|
}
|
|
1937
1947
|
timezoneOffset(z, b) {
|
|
1938
|
-
const p = G0(z, b), W =
|
|
1948
|
+
const p = G0(z, b), W = i().tz(p).utcOffset();
|
|
1939
1949
|
return Math.round(W / 60 * 10) / 10;
|
|
1940
1950
|
}
|
|
1941
1951
|
/**
|
|
@@ -1981,8 +1991,8 @@ class Q {
|
|
|
1981
1991
|
selfHosted: !0,
|
|
1982
1992
|
maxDays: 14
|
|
1983
1993
|
}) {
|
|
1984
|
-
var r, u,
|
|
1985
|
-
b = Q.toStdLng(b), this.debug &&
|
|
1994
|
+
var r, u, s, m, L, U, Z, N;
|
|
1995
|
+
b = Q.toStdLng(b), this.debug && G.info("[%s] spot forecast params: %j", O.requestId, { lat: z, lng: b, datetime: p, simplify: W, withDaily: A, withHourly: c, options: O });
|
|
1986
1996
|
const Y = {
|
|
1987
1997
|
apikey: this.apikey,
|
|
1988
1998
|
latitude: z,
|
|
@@ -1994,7 +2004,7 @@ class Q {
|
|
|
1994
2004
|
};
|
|
1995
2005
|
let a;
|
|
1996
2006
|
const n = this.timezoneOffset(z, b);
|
|
1997
|
-
p && (a =
|
|
2007
|
+
p && (a = i.utc(p).utcOffset(n), a.subtract(n > 0 ? n : -n, "h")), A && (Y.daily = ((r = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : r.split(",")) || []), a || (O.forecastDays = O.forecastDays || 1, O.pastDays = 0, c = !0), c && (Y.hourly = ((u = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : u.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((s = a == null ? void 0 : a.utc()) == null ? void 0 : s.format(), Y, O);
|
|
1998
2008
|
const X = await this.weatherForecast(Y, void 0, !1, !1, !1, O), d = {
|
|
1999
2009
|
apikey: this.apikey,
|
|
2000
2010
|
latitude: z,
|
|
@@ -2006,7 +2016,7 @@ class Q {
|
|
|
2006
2016
|
};
|
|
2007
2017
|
A && (d.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), a || (O.forecastDays = O.forecastDays || 1, c = !0), c && (d.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), await this.prepare((m = a == null ? void 0 : a.utc()) == null ? void 0 : m.format(), d, O);
|
|
2008
2018
|
let t = await this.marineForecast(d, O);
|
|
2009
|
-
return (
|
|
2019
|
+
return (Z = (U = (L = t[0]) == null ? void 0 : L.hourly) == null ? void 0 : U.wave_height) != null && Z.every((l) => l === null || l === 0) && (d.models = this.pickMarineModels("best_match,ncep_gfswave025,ecmwf_wam025,meteofrance_wave"), t = await this.marineForecast(d, O)), { weather: X, marine: t, wparams: Y, mparams: d, datetime: (N = a == null ? void 0 : a.utc()) == null ? void 0 : N.format() };
|
|
2010
2020
|
}
|
|
2011
2021
|
/**
|
|
2012
2022
|
* 历史再分析数据
|
|
@@ -2034,8 +2044,8 @@ class Q {
|
|
|
2034
2044
|
async spotHistorical(z, b, p, W, A = !0, c = !0, O = !1, Y = {
|
|
2035
2045
|
precision: 6
|
|
2036
2046
|
}) {
|
|
2037
|
-
b = Q.toStdLng(b), this.debug &&
|
|
2038
|
-
const a = this.timezoneOffset(z, b), n =
|
|
2047
|
+
b = Q.toStdLng(b), this.debug && G.info("[%s] spot historical params: %j", Y.requestId, { lat: z, lng: b, startDate: p, endDate: W, withMarine: O, options: Y });
|
|
2048
|
+
const a = this.timezoneOffset(z, b), n = i.utc(p).utcOffset(a), X = i.utc(W).utcOffset(a);
|
|
2039
2049
|
n.subtract(a > 0 ? a : -a, "h"), X.subtract(a > 0 ? a : -a, "h");
|
|
2040
2050
|
const d = 730;
|
|
2041
2051
|
if (X.diff(n, "days") <= d)
|
|
@@ -2050,13 +2060,13 @@ class Q {
|
|
|
2050
2060
|
Y
|
|
2051
2061
|
);
|
|
2052
2062
|
{
|
|
2053
|
-
this.debug &&
|
|
2063
|
+
this.debug && G.info("[%s] splitting historical request into chunks of %d days", Y.requestId, d);
|
|
2054
2064
|
const r = [];
|
|
2055
2065
|
let u = n.clone();
|
|
2056
2066
|
for (; u.isBefore(X); ) {
|
|
2057
|
-
const
|
|
2058
|
-
this.debug &&
|
|
2059
|
-
const
|
|
2067
|
+
const s = u.clone().add(d, "days"), m = s.isAfter(X) ? X : s;
|
|
2068
|
+
this.debug && G.debug("[%s] fetching chunk from %s to %s", Y.requestId, u.format("YYYY-MM-DD"), m.format("YYYY-MM-DD"));
|
|
2069
|
+
const L = await this._fetchHistoricalData(
|
|
2060
2070
|
z,
|
|
2061
2071
|
b,
|
|
2062
2072
|
u.format("YYYY-MM-DD"),
|
|
@@ -2066,7 +2076,7 @@ class Q {
|
|
|
2066
2076
|
O,
|
|
2067
2077
|
Y
|
|
2068
2078
|
);
|
|
2069
|
-
r.push(
|
|
2079
|
+
r.push(L), u = m.clone().add(1, "second"), await new Promise((U) => setTimeout(U, 100));
|
|
2070
2080
|
}
|
|
2071
2081
|
return this._mergeHistoricalResults(r);
|
|
2072
2082
|
}
|
|
@@ -2147,8 +2157,8 @@ class Q {
|
|
|
2147
2157
|
async spotSeasonal(z, b, p, W, A = !1, c = {
|
|
2148
2158
|
precision: 6
|
|
2149
2159
|
}) {
|
|
2150
|
-
b = Q.toStdLng(b), this.debug &&
|
|
2151
|
-
const O = this.timezoneOffset(z, b), Y =
|
|
2160
|
+
b = Q.toStdLng(b), this.debug && G.info("[%s] spot seasonal params: %j", c.requestId, { lat: z, lng: b, startDate: p, endDate: W, options: c });
|
|
2161
|
+
const O = this.timezoneOffset(z, b), Y = i.utc(p).utcOffset(O), a = W ? i.utc(W).utcOffset(O) : Y.clone().add(1, "month");
|
|
2152
2162
|
Y.subtract(O > 0 ? O : -O, "h"), a.subtract(O > 0 ? O : -O, "h");
|
|
2153
2163
|
const n = {
|
|
2154
2164
|
apikey: this.apikey,
|
|
@@ -2187,21 +2197,21 @@ class Q {
|
|
|
2187
2197
|
async spotClimate(z, b, p, W, A = {
|
|
2188
2198
|
precision: 6
|
|
2189
2199
|
}) {
|
|
2190
|
-
b = Q.toStdLng(b), this.debug &&
|
|
2191
|
-
const c = this.timezoneOffset(z, b), O =
|
|
2200
|
+
b = Q.toStdLng(b), this.debug && G.info("[%s] spot climate params: %j", A.requestId, { lat: z, lng: b, startDate: p, endDate: W, options: A });
|
|
2201
|
+
const c = this.timezoneOffset(z, b), O = i.utc(p).utcOffset(c), Y = W ? i.utc(W).utcOffset(c) : O.clone().add(1, "day");
|
|
2192
2202
|
Y.subtract(c > 0 ? c : -c, "h"), O.subtract(c > 0 ? c : -c, "h");
|
|
2193
2203
|
const a = 730;
|
|
2194
2204
|
if (Y.diff(O, "days") <= a)
|
|
2195
2205
|
return await this._fetchClimateData(z, b, O.format("YYYY-MM-DD"), Y.format("YYYY-MM-DD"), A);
|
|
2196
2206
|
{
|
|
2197
|
-
this.debug &&
|
|
2207
|
+
this.debug && G.info("[%s] splitting climate request into chunks of %d days", A.requestId, a);
|
|
2198
2208
|
const X = [];
|
|
2199
2209
|
let d = O.clone();
|
|
2200
2210
|
for (; d.isBefore(Y); ) {
|
|
2201
2211
|
const t = d.clone().add(a, "days"), r = t.isAfter(Y) ? Y : t;
|
|
2202
|
-
this.debug &&
|
|
2212
|
+
this.debug && G.debug("[%s] fetching climate chunk from %s to %s", A.requestId, d.format("YYYY-MM-DD"), r.format("YYYY-MM-DD"));
|
|
2203
2213
|
const u = await this._fetchClimateData(z, b, d.format("YYYY-MM-DD"), r.format("YYYY-MM-DD"), A);
|
|
2204
|
-
X.push(u), d = r.clone().add(1, "second"), await new Promise((
|
|
2214
|
+
X.push(u), d = r.clone().add(1, "second"), await new Promise((s) => setTimeout(s, 100));
|
|
2205
2215
|
}
|
|
2206
2216
|
return this._mergeClimateResults(X);
|
|
2207
2217
|
}
|
|
@@ -2248,7 +2258,7 @@ class Q {
|
|
|
2248
2258
|
* @param options
|
|
2249
2259
|
*/
|
|
2250
2260
|
async update(z = {}) {
|
|
2251
|
-
const b =
|
|
2261
|
+
const b = i.unix(this.METEO2_UPDATE.etime), p = this.METEO2_UPDATE.version, W = i();
|
|
2252
2262
|
if (!p || b.clone().add(10, "minute").isBefore(W)) {
|
|
2253
2263
|
const A = z.url || "https://meteo3agent.idmwx.com/api/agents/update", c = await fetch(A, {
|
|
2254
2264
|
headers: {
|
|
@@ -2259,21 +2269,21 @@ class Q {
|
|
|
2259
2269
|
try {
|
|
2260
2270
|
const O = await c.json();
|
|
2261
2271
|
if (O.code === 0) {
|
|
2262
|
-
const Y = O.data, a =
|
|
2272
|
+
const Y = O.data, a = g.standardWeatherModels();
|
|
2263
2273
|
for (const n of a) {
|
|
2264
|
-
const X =
|
|
2265
|
-
var
|
|
2266
|
-
const u =
|
|
2274
|
+
const X = g.autoPickSubCategories(n.alias), t = Y.filter((r) => X.includes(r.category)).map((r) => {
|
|
2275
|
+
var L, U, Z, N, l, _;
|
|
2276
|
+
const u = i.unix((L = r.meta) == null ? void 0 : L.data_end_time).utc(), s = i.unix((U = r.meta) == null ? void 0 : U.last_run_availability_time).utc(), m = u.diff(s, "days");
|
|
2267
2277
|
return {
|
|
2268
2278
|
category: r.category,
|
|
2269
2279
|
meta: {
|
|
2270
2280
|
endTime: u.format(),
|
|
2271
|
-
availabilityTime:
|
|
2281
|
+
availabilityTime: s.format(),
|
|
2272
2282
|
days: m,
|
|
2273
|
-
initialisationTime:
|
|
2274
|
-
modificationTime:
|
|
2275
|
-
temporalResolution: Math.round(((
|
|
2276
|
-
frequency: Math.round(((
|
|
2283
|
+
initialisationTime: i.unix((Z = r.meta) == null ? void 0 : Z.last_run_initialisation_time).utc().format(),
|
|
2284
|
+
modificationTime: i.unix((N = r.meta) == null ? void 0 : N.last_run_modification_time).utc().format(),
|
|
2285
|
+
temporalResolution: Math.round(((l = r.meta) == null ? void 0 : l.temporal_resolution_seconds) / 3600),
|
|
2286
|
+
frequency: Math.round(((_ = r.meta) == null ? void 0 : _.update_interval_seconds) / 3600)
|
|
2277
2287
|
}
|
|
2278
2288
|
};
|
|
2279
2289
|
});
|
|
@@ -2282,7 +2292,7 @@ class Q {
|
|
|
2282
2292
|
this.METEO2_UPDATE.version = p + 1, this.METEO2_UPDATE.etime = W.unix();
|
|
2283
2293
|
}
|
|
2284
2294
|
} catch (O) {
|
|
2285
|
-
|
|
2295
|
+
G.error("[%s] update meteo2 error: %s", z.requestId, O);
|
|
2286
2296
|
}
|
|
2287
2297
|
}
|
|
2288
2298
|
return this.METEO2_UPDATE;
|
|
@@ -2300,7 +2310,7 @@ class Q {
|
|
|
2300
2310
|
if (p[A] instanceof Array)
|
|
2301
2311
|
for (const c of p[A])
|
|
2302
2312
|
z != null && z.includes(c.category) && W.push(c);
|
|
2303
|
-
return W.sort((A, c) =>
|
|
2313
|
+
return W.sort((A, c) => i(c.meta.endTime).unix() - i(A.meta.endTime).unix()), W;
|
|
2304
2314
|
}
|
|
2305
2315
|
}
|
|
2306
2316
|
let B0;
|
|
@@ -2377,12 +2387,12 @@ class A0 {
|
|
|
2377
2387
|
return z == null ? void 0 : z.map((b) => {
|
|
2378
2388
|
const p = Number(b.pressure / 100), W = Number(b.lat), A = Number(b.lon), c = Number(b.windSpeed * 3600 / 1852);
|
|
2379
2389
|
return {
|
|
2380
|
-
updated:
|
|
2390
|
+
updated: i.utc(b.time).format(),
|
|
2381
2391
|
lat: isNaN(W) ? null : W,
|
|
2382
2392
|
lng: isNaN(A) ? null : A,
|
|
2383
2393
|
pressure: isNaN(p) ? null : Math.round(p) || null,
|
|
2384
2394
|
kts: isNaN(c) ? null : Math.round(c) || null,
|
|
2385
|
-
bf:
|
|
2395
|
+
bf: g.beaufort(g.kts2ms(c ?? 0)),
|
|
2386
2396
|
...S.parseTropicalType(c),
|
|
2387
2397
|
wind: {
|
|
2388
2398
|
r7: null,
|
|
@@ -2407,9 +2417,9 @@ class A0 {
|
|
|
2407
2417
|
static async parseForecast(z) {
|
|
2408
2418
|
return z.map((b) => {
|
|
2409
2419
|
var A;
|
|
2410
|
-
const p =
|
|
2420
|
+
const p = i.utc(b.reftime).format(), W = {};
|
|
2411
2421
|
return (A = b.records) == null || A.forEach((c) => {
|
|
2412
|
-
const O =
|
|
2422
|
+
const O = i.utc(c.time), Y = O.diff(p, "hour"), a = Number(c.pressure / 100), n = Number(c.lat), X = Number(c.lon), d = Number(c.windSpeed * 3600 / 1852);
|
|
2413
2423
|
W[Y] = {
|
|
2414
2424
|
lat: isNaN(n) ? null : n,
|
|
2415
2425
|
lng: isNaN(X) ? null : X,
|
|
@@ -2418,7 +2428,7 @@ class A0 {
|
|
|
2418
2428
|
wind: {
|
|
2419
2429
|
datetime: O.format(),
|
|
2420
2430
|
kts: isNaN(d) ? null : Math.round(d) || null,
|
|
2421
|
-
bf:
|
|
2431
|
+
bf: g.beaufort(g.kts2ms(d ?? 0)),
|
|
2422
2432
|
...S.parseTropicalType(d),
|
|
2423
2433
|
r7: null,
|
|
2424
2434
|
r7ne: null,
|
|
@@ -2472,35 +2482,35 @@ const $ = class $ {
|
|
|
2472
2482
|
static async parseHistory(z) {
|
|
2473
2483
|
const b = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${z}`, p = await x.post(b).text(), W = await $.parser.parseStringPromise(p), A = W.typhoon.position instanceof Array ? W.typhoon.position : [W.typhoon.position], c = [];
|
|
2474
2484
|
for (const O of A) {
|
|
2475
|
-
const Y =
|
|
2485
|
+
const Y = i(O.updatetime).utcOffset(8).utc().format(), a = Number(O.lat), n = Number(O.lon), X = Number(O.pressure), d = Number(O.windspeed * 3600 / 1852), t = S.parseWindCircle(O.c7quad1 / 1.852), r = S.parseWindCircle(O.c7quad2 / 1.852), u = S.parseWindCircle(O.c7quad3 / 1.852), s = S.parseWindCircle(O.c7quad4 / 1.852), m = S.parseWindCircle(O.c10quad1 / 1.852), L = S.parseWindCircle(O.c10quad2 / 1.852), U = S.parseWindCircle(O.c10quad3 / 1.852), Z = S.parseWindCircle(O.c10quad4 / 1.852), N = S.parseWindCircle(O.c12quad1 / 1.852), l = S.parseWindCircle(O.c12quad2 / 1.852), _ = S.parseWindCircle(O.c12quad3 / 1.852), f = S.parseWindCircle(O.c12quad4 / 1.852), { r7: E, r10: w, r12: D } = S.estimateWindRadii(d, a), v = {
|
|
2476
2486
|
updated: Y,
|
|
2477
2487
|
lat: isNaN(a) ? null : a,
|
|
2478
2488
|
lng: isNaN(n) ? null : n,
|
|
2479
2489
|
pressure: isNaN(X) ? null : Math.round(X),
|
|
2480
2490
|
kts: isNaN(d) ? null : Math.round(d) || null,
|
|
2481
|
-
bf:
|
|
2491
|
+
bf: g.beaufort(g.kts2ms(d ?? 0)),
|
|
2482
2492
|
...S.parseTropicalType(d),
|
|
2483
2493
|
wind: {
|
|
2484
|
-
r7:
|
|
2494
|
+
r7: E,
|
|
2485
2495
|
r7ne: t,
|
|
2486
2496
|
r7nw: r,
|
|
2487
2497
|
r7sw: u,
|
|
2488
|
-
r7se:
|
|
2498
|
+
r7se: s,
|
|
2489
2499
|
r10: w,
|
|
2490
2500
|
r10ne: m,
|
|
2491
|
-
r10nw:
|
|
2492
|
-
r10sw:
|
|
2493
|
-
r10se:
|
|
2494
|
-
r12:
|
|
2501
|
+
r10nw: L,
|
|
2502
|
+
r10sw: U,
|
|
2503
|
+
r10se: Z,
|
|
2504
|
+
r12: D,
|
|
2495
2505
|
r12ne: N,
|
|
2496
|
-
r12nw:
|
|
2497
|
-
r12sw:
|
|
2498
|
-
r12se:
|
|
2506
|
+
r12nw: l,
|
|
2507
|
+
r12sw: _,
|
|
2508
|
+
r12se: f
|
|
2499
2509
|
}
|
|
2500
2510
|
};
|
|
2501
2511
|
c.push(v);
|
|
2502
2512
|
}
|
|
2503
|
-
return c.sort((O, Y) =>
|
|
2513
|
+
return c.sort((O, Y) => i(Y.updated).unix() - i(O.updated).unix()), c;
|
|
2504
2514
|
}
|
|
2505
2515
|
static async parseForecast(z, b) {
|
|
2506
2516
|
const p = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${z}`, W = await x.post(p).text(), A = await $.parser.parseStringPromise(W), c = A.list.forecast instanceof Array ? A.list.forecast : [A.list.forecast], O = [];
|
|
@@ -2508,22 +2518,22 @@ const $ = class $ {
|
|
|
2508
2518
|
if (Y.xuhao === z) {
|
|
2509
2519
|
const a = Y.positions.forecastposition instanceof Array ? Y.positions.forecastposition : [Y.positions.forecastposition];
|
|
2510
2520
|
if (a.length) {
|
|
2511
|
-
b = b ||
|
|
2521
|
+
b = b || i(a.at(0).forecasttime).utcOffset(8).utc();
|
|
2512
2522
|
const n = {};
|
|
2513
2523
|
for (const d of a) {
|
|
2514
|
-
const t =
|
|
2524
|
+
const t = i(d.forecasttime).utcOffset(8).utc(), r = t.diff(b, "hours");
|
|
2515
2525
|
if (r) {
|
|
2516
|
-
const u = Number(d.forelat),
|
|
2526
|
+
const u = Number(d.forelat), s = Number(d.forelon), m = Number(d.forepressure), L = Number(d.forespeed * 3600 / 1852);
|
|
2517
2527
|
n[r] = {
|
|
2518
2528
|
lat: isNaN(u) ? null : u,
|
|
2519
|
-
lng: isNaN(
|
|
2529
|
+
lng: isNaN(s) ? null : s,
|
|
2520
2530
|
pressure: m ? Math.round(m) : null,
|
|
2521
2531
|
utc: t.format(),
|
|
2522
2532
|
wind: {
|
|
2523
2533
|
datetime: t.format(),
|
|
2524
|
-
kts: isNaN(
|
|
2525
|
-
bf:
|
|
2526
|
-
...S.parseTropicalType(
|
|
2534
|
+
kts: isNaN(L) ? null : Math.round(L),
|
|
2535
|
+
bf: g.beaufort(g.kts2ms(L ?? 0)),
|
|
2536
|
+
...S.parseTropicalType(L),
|
|
2527
2537
|
r7: null,
|
|
2528
2538
|
r7ne: null,
|
|
2529
2539
|
r7nw: null,
|
|
@@ -2558,7 +2568,7 @@ const $ = class $ {
|
|
|
2558
2568
|
}
|
|
2559
2569
|
static async parseTropical(z) {
|
|
2560
2570
|
var c, O, Y;
|
|
2561
|
-
const b = await $.parseHistory(z.xuhao), p = (c = b.at(0)) == null ? void 0 : c.updated, W = await $.parseForecast(z.xuhao, p ?
|
|
2571
|
+
const b = await $.parseHistory(z.xuhao), p = (c = b.at(0)) == null ? void 0 : c.updated, W = await $.parseForecast(z.xuhao, p ? i(p) : void 0), A = {
|
|
2562
2572
|
id: (O = z.enname) == null ? void 0 : O.toLowerCase(),
|
|
2563
2573
|
name: (Y = z.enname) == null ? void 0 : Y.toLowerCase(),
|
|
2564
2574
|
cnName: z.name,
|
|
@@ -2577,7 +2587,7 @@ const $ = class $ {
|
|
|
2577
2587
|
return W;
|
|
2578
2588
|
}
|
|
2579
2589
|
};
|
|
2580
|
-
F($, "parser",
|
|
2590
|
+
F($, "parser", m0.Parser({ explicitArray: !1, mergeAttrs: !0, trim: !0 }));
|
|
2581
2591
|
let n0 = $;
|
|
2582
2592
|
var r0 = /* @__PURE__ */ ((M) => (M.CMA = "CMA", M.CNTW = "CNTW", M.CNHK = "CNHK", M.JMA = "JMA", M.KMA = "KMA", M.ECMWF = "ECMWF", M.NOAA_AT = "NOAA-AT", M.NOAA_CP = "NOAA-CP", M.NOAA_EP = "NOAA-EP", M.UKM = "UKM", M.IMD = "IMD", M.GFS = "GFS", M.BOM_ACCESS = "BOM-ACCESS", M.BOM_BULLETIN_EAST = "BOM-BULLETIN-EAST", M.BOM_BULLETIN_NORTH = "BOM-BULLETIN-NORTH", M.BOM_BULLETIN_WEST = "BOM-BULLETIN-WEST", M.OTHER = "OTHER", M))(r0 || {});
|
|
2583
2593
|
class S {
|
|
@@ -2607,7 +2617,7 @@ class S {
|
|
|
2607
2617
|
return ((X = n.name) == null ? void 0 : X.toLowerCase()) === ((d = O.name) == null ? void 0 : d.toLowerCase());
|
|
2608
2618
|
});
|
|
2609
2619
|
if (Y) {
|
|
2610
|
-
O.cnName = Y.cnName, (A = Y.history) != null && A.length && (O.history = Y.history), O.history.sort((n, X) =>
|
|
2620
|
+
O.cnName = Y.cnName, (A = Y.history) != null && A.length && (O.history = Y.history), O.history.sort((n, X) => i(X.updated).valueOf() - i(n.updated).valueOf());
|
|
2611
2621
|
for (const n of Y.forecasts)
|
|
2612
2622
|
["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((c = n.model) == null ? void 0 : c.toUpperCase()) && !O.forecasts.find((X) => X.model.toLowerCase() === n.model.toLowerCase()) && O.forecasts.push(n);
|
|
2613
2623
|
}
|
|
@@ -2615,9 +2625,9 @@ class S {
|
|
|
2615
2625
|
const a = O.history[0];
|
|
2616
2626
|
a && O.forecasts.forEach((n) => {
|
|
2617
2627
|
n.date = a.updated;
|
|
2618
|
-
const X =
|
|
2628
|
+
const X = i(a.updated), d = {};
|
|
2619
2629
|
for (const t in n.hours) {
|
|
2620
|
-
const r = n.hours[t], u =
|
|
2630
|
+
const r = n.hours[t], u = i(r.utc).diff(X, "h");
|
|
2621
2631
|
u > 0 && (d[u] = r);
|
|
2622
2632
|
}
|
|
2623
2633
|
n.hours = d;
|
|
@@ -2663,7 +2673,7 @@ class S {
|
|
|
2663
2673
|
return z;
|
|
2664
2674
|
}
|
|
2665
2675
|
static calculateMovement(z, b) {
|
|
2666
|
-
const p = f0.calculateDistance(z, b), W =
|
|
2676
|
+
const p = f0.calculateDistance(z, b), W = i(b.utc || b.updated).diff(z.utc || z.updated, "h", !0);
|
|
2667
2677
|
return {
|
|
2668
2678
|
kts: Math.round(p / W * 100) / 100,
|
|
2669
2679
|
deg: f0.calculateBearing(z, b, !0, 0)
|
|
@@ -2702,7 +2712,7 @@ class S {
|
|
|
2702
2712
|
const O = (A + c) / 2, Y = p / O, a = Math.pow(Y, W) * Math.exp(1 - Math.pow(Y, W));
|
|
2703
2713
|
b * Math.sqrt(a) > z ? A = O : c = O;
|
|
2704
2714
|
}
|
|
2705
|
-
return
|
|
2715
|
+
return g.kmh2kts(A + c);
|
|
2706
2716
|
}
|
|
2707
2717
|
/**
|
|
2708
2718
|
* 基于台风强度推算风圈基础半径的经验公式
|
|
@@ -2711,7 +2721,7 @@ class S {
|
|
|
2711
2721
|
* @returns 风圈半径对象
|
|
2712
2722
|
*/
|
|
2713
2723
|
static estimateWindRadii(z, b) {
|
|
2714
|
-
const p =
|
|
2724
|
+
const p = g.kts2ms(z), W = S.estimateRMW(p, b), A = S.estimateHollandB(p, W, b), c = S.findWindRadius(17.2, p, W, A), O = S.findWindRadius(28.5, p, W, A), Y = S.findWindRadius(37, p, W, A);
|
|
2715
2725
|
return {
|
|
2716
2726
|
r7: c ? Math.round(c) : null,
|
|
2717
2727
|
r10: O ? Math.round(O) : null,
|
|
@@ -2814,5 +2824,5 @@ export {
|
|
|
2814
2824
|
M1 as TidesHelper,
|
|
2815
2825
|
S as TropicalHelper,
|
|
2816
2826
|
r0 as TropicalModel,
|
|
2817
|
-
|
|
2827
|
+
Z0 as WindyModel
|
|
2818
2828
|
};
|