@idm-plugin/meteo2 0.9.1 → 0.9.3
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 +182 -182
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,9 +5,9 @@ import Y0 from "@log4js-node/log4js-api";
|
|
|
5
5
|
import L from "moment";
|
|
6
6
|
import $ from "got";
|
|
7
7
|
import { fetchWeatherApi as o0 } from "openmeteo";
|
|
8
|
-
import { Meteo2Assist as
|
|
8
|
+
import { Meteo2Assist as w } from "@idm-plugin/meteo";
|
|
9
9
|
import Z0 from "xml2js";
|
|
10
|
-
import { LaneHelper as
|
|
10
|
+
import { LaneHelper as T0 } from "@idm-plugin/geo2";
|
|
11
11
|
let Z;
|
|
12
12
|
try {
|
|
13
13
|
Z = Y0.getLogger("meteo");
|
|
@@ -36,10 +36,10 @@ class j0 {
|
|
|
36
36
|
source: W == null ? void 0 : W.toLowerCase()
|
|
37
37
|
},
|
|
38
38
|
timeout: 3e4
|
|
39
|
-
},
|
|
40
|
-
A.isBefore(
|
|
39
|
+
}, a = L(), Y = a.valueOf();
|
|
40
|
+
A.isBefore(a.subtract(1, "month")) && (Z == null || Z.warn("[%s] get history meteo on %s: %j", o.requestId, A.format(), q));
|
|
41
41
|
const e = "https://aod4idm.idmwx.com/api/ocean/point", d = await $.get(e, q).json(), t = L().valueOf();
|
|
42
|
-
if (Z == null || Z.info("[%s] get meteo(cost: %d ms) from %s with options: %j", o.requestId, t -
|
|
42
|
+
if (Z == null || Z.info("[%s] get meteo(cost: %d ms) from %s with options: %j", o.requestId, t - Y, e, q), (d == null ? void 0 : d.code) === 0)
|
|
43
43
|
return {
|
|
44
44
|
...d.data,
|
|
45
45
|
source: W
|
|
@@ -71,10 +71,10 @@ class j0 {
|
|
|
71
71
|
source: W == null ? void 0 : W.toLowerCase()
|
|
72
72
|
},
|
|
73
73
|
timeout: 3e4
|
|
74
|
-
},
|
|
75
|
-
A.isBefore(
|
|
74
|
+
}, a = L(), Y = a.valueOf();
|
|
75
|
+
A.isBefore(a.subtract(1, "month")) && (Z == null || Z.warn("[%s] get history factors on %s: %j", o.requestId, A.format(), q));
|
|
76
76
|
const e = "https://aod4idm.idmwx.com/api/ocean/factor", d = await $.get(e, q).json(), t = L().valueOf();
|
|
77
|
-
if (Z == null || Z.info("[%s] get factors(cost: %d ms) from %s with options: %j", o.requestId, t -
|
|
77
|
+
if (Z == null || Z.info("[%s] get factors(cost: %d ms) from %s with options: %j", o.requestId, t - Y, e, q), (d == null ? void 0 : d.code) === 0)
|
|
78
78
|
return {
|
|
79
79
|
...d.data,
|
|
80
80
|
source: W
|
|
@@ -118,9 +118,9 @@ class j0 {
|
|
|
118
118
|
levels: ["surface"]
|
|
119
119
|
}
|
|
120
120
|
}).json();
|
|
121
|
-
let
|
|
122
|
-
Z == null || Z.info("[%s] get gfs-factors(cost: %d ms) from %s", O.requestId,
|
|
123
|
-
const
|
|
121
|
+
let a = L().valueOf();
|
|
122
|
+
Z == null || Z.info("[%s] get gfs-factors(cost: %d ms) from %s", O.requestId, a - A, W), A = a;
|
|
123
|
+
const Y = await $.post(W, {
|
|
124
124
|
headers: {
|
|
125
125
|
"Content-Type": "application/json"
|
|
126
126
|
},
|
|
@@ -133,7 +133,7 @@ class j0 {
|
|
|
133
133
|
levels: ["surface"]
|
|
134
134
|
}
|
|
135
135
|
}).json();
|
|
136
|
-
|
|
136
|
+
a = L().valueOf(), Z == null || Z.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", O.requestId, a - A, W);
|
|
137
137
|
for (let d = 0; d < q.ts.length; d++) {
|
|
138
138
|
const t = this.populateUVFactor(q["wind_u-surface"][d], q["wind_v-surface"][d], !1, O);
|
|
139
139
|
t.scale = this.calculateBeaufortWindForceScale(t.speed), o.push({
|
|
@@ -159,20 +159,20 @@ class j0 {
|
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
const e = [];
|
|
162
|
-
for (let d = 0; d <
|
|
163
|
-
const t = this.calculateDouglasScale(
|
|
162
|
+
for (let d = 0; d < Y.ts.length; d++) {
|
|
163
|
+
const t = this.calculateDouglasScale(Y["waves_height-surface"][d], Y["waves_direction-surface"][d], Y["waves_period-surface"][d]), i = this.calculateDouglasScale(Y["wwaves_height-surface"][d], Y["wwaves_direction-surface"][d], Y["wwaves_period-surface"][d]), U = this.calculateDouglasScale(Y["swell1_height-surface"][d], Y["swell1_direction-surface"][d], Y["swell1_period-surface"][d]), s = this.calculateDouglasScale(Y["swell2_height-surface"][d], Y["swell2_direction-surface"][d], Y["swell2_period-surface"][d]);
|
|
164
164
|
e.push({
|
|
165
|
-
utc: L(
|
|
165
|
+
utc: L(Y.ts[d]).utc().format(),
|
|
166
166
|
wave: {
|
|
167
167
|
sig: t,
|
|
168
|
-
wd:
|
|
168
|
+
wd: i,
|
|
169
169
|
swell: U,
|
|
170
170
|
swell2: s
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
for (const d of o) {
|
|
175
|
-
const t = e.find((
|
|
175
|
+
const t = e.find((i) => i.utc === d.utc);
|
|
176
176
|
d.wave = t == null ? void 0 : t.wave;
|
|
177
177
|
}
|
|
178
178
|
} catch (A) {
|
|
@@ -271,9 +271,9 @@ var t0 = { exports: {} };
|
|
|
271
271
|
throw new RangeError("invalid coordinates");
|
|
272
272
|
if (90 <= p)
|
|
273
273
|
return "Etc/GMT";
|
|
274
|
-
var o = -1, A = 48 * (180 + b) / 360.00000000000006, q = 24 * (90 - p) / 180.00000000000003,
|
|
274
|
+
var o = -1, A = 48 * (180 + b) / 360.00000000000006, q = 24 * (90 - p) / 180.00000000000003, a = 0 | A, Y = 0 | q, e = 96 * Y + 2 * a;
|
|
275
275
|
for (e = 56 * O.charCodeAt(e) + O.charCodeAt(e + 1) - 1995; e + W.length < 3136; )
|
|
276
|
-
e = 56 * O.charCodeAt(e = 8 * (o = o + e + 1) + 4 * (
|
|
276
|
+
e = 56 * O.charCodeAt(e = 8 * (o = o + e + 1) + 4 * (Y = 0 | (q = 2 * (q - Y) % 2)) + 2 * (a = 0 | (A = 2 * (A - a) % 2)) + 2304) + O.charCodeAt(e + 1) - 1995;
|
|
277
277
|
return W[e + W.length - 3136];
|
|
278
278
|
}
|
|
279
279
|
M.exports = z;
|
|
@@ -293,8 +293,8 @@ var N0 = { exports: {} };
|
|
|
293
293
|
z.version === void 0 && z.default && (z = z.default);
|
|
294
294
|
var p = "0.5.48", b = {}, O = {}, W = {}, o = {}, A = {}, q;
|
|
295
295
|
(!z || typeof z.version != "string") && j("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
296
|
-
var
|
|
297
|
-
(
|
|
296
|
+
var a = z.version.split("."), Y = +a[0], e = +a[1];
|
|
297
|
+
(Y < 2 || Y === 2 && e < 6) && j("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + z.version + ". See momentjs.com");
|
|
298
298
|
function d(c) {
|
|
299
299
|
return c > 96 ? c - 87 : c > 64 ? c - 29 : c - 48;
|
|
300
300
|
}
|
|
@@ -306,7 +306,7 @@ var N0 = { exports: {} };
|
|
|
306
306
|
u = u / 60, C = d(f.charCodeAt(n)), B += C * u;
|
|
307
307
|
return B * G;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function i(c) {
|
|
310
310
|
for (var n = 0; n < c.length; n++)
|
|
311
311
|
c[n] = t(c[n]);
|
|
312
312
|
}
|
|
@@ -323,7 +323,7 @@ var N0 = { exports: {} };
|
|
|
323
323
|
}
|
|
324
324
|
function V(c) {
|
|
325
325
|
var n = c.split("|"), R = n[2].split(" "), X = n[3].split(""), f = n[4].split(" ");
|
|
326
|
-
return
|
|
326
|
+
return i(R), i(X), i(f), U(f, X.length), {
|
|
327
327
|
name: n[0],
|
|
328
328
|
abbrs: s(n[1].split(" "), X),
|
|
329
329
|
offsets: s(R, X),
|
|
@@ -407,9 +407,9 @@ var N0 = { exports: {} };
|
|
|
407
407
|
function v(c, n) {
|
|
408
408
|
return c.offsetScore !== n.offsetScore ? c.offsetScore - n.offsetScore : c.abbrScore !== n.abbrScore ? c.abbrScore - n.abbrScore : c.zone.population !== n.zone.population ? n.zone.population - c.zone.population : n.zone.name.localeCompare(c.zone.name);
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function K(c, n) {
|
|
411
411
|
var R, X;
|
|
412
|
-
for (
|
|
412
|
+
for (i(n), R = 0; R < n.length; R++)
|
|
413
413
|
X = n[R], A[X] = A[X] || {}, A[X][c] = !0;
|
|
414
414
|
}
|
|
415
415
|
function k(c) {
|
|
@@ -453,7 +453,7 @@ var N0 = { exports: {} };
|
|
|
453
453
|
function W0(c) {
|
|
454
454
|
var n, R, X, f;
|
|
455
455
|
for (typeof c == "string" && (c = [c]), n = 0; n < c.length; n++)
|
|
456
|
-
X = c[n].split("|"), R = X[0], f = x(R), b[f] = c[n], o[f] = R,
|
|
456
|
+
X = c[n].split("|"), R = X[0], f = x(R), b[f] = c[n], o[f] = R, K(f, X[2].split(" "));
|
|
457
457
|
}
|
|
458
458
|
function y(c, n) {
|
|
459
459
|
c = x(c);
|
|
@@ -466,7 +466,7 @@ var N0 = { exports: {} };
|
|
|
466
466
|
o.hasOwnProperty(c) && (b[c] || b[O[c]]) && o[c] && n.push(o[c]);
|
|
467
467
|
return n.sort();
|
|
468
468
|
}
|
|
469
|
-
function
|
|
469
|
+
function T() {
|
|
470
470
|
return Object.keys(W);
|
|
471
471
|
}
|
|
472
472
|
function M0(c) {
|
|
@@ -474,7 +474,7 @@ var N0 = { exports: {} };
|
|
|
474
474
|
for (typeof c == "string" && (c = [c]), n = 0; n < c.length; n++)
|
|
475
475
|
R = c[n].split("|"), X = x(R[0]), f = x(R[1]), O[X] = f, o[X] = R[0], O[f] = X, o[f] = R[1];
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function g(c) {
|
|
478
478
|
var n, R, X, f;
|
|
479
479
|
if (!(!c || !c.length))
|
|
480
480
|
for (n = 0; n < c.length; n++)
|
|
@@ -499,7 +499,7 @@ var N0 = { exports: {} };
|
|
|
499
499
|
}) : R;
|
|
500
500
|
}
|
|
501
501
|
function B0(c) {
|
|
502
|
-
W0(c.zones), M0(c.links),
|
|
502
|
+
W0(c.zones), M0(c.links), g(c.countries), m.dataVersion = c.version;
|
|
503
503
|
}
|
|
504
504
|
function a0(c) {
|
|
505
505
|
return a0.didShowError || (a0.didShowError = !0, j("moment.tz.zoneExists('" + c + "') has been deprecated in favor of !moment.tz.zone('" + c + "')")), !!y(c);
|
|
@@ -515,7 +515,7 @@ var N0 = { exports: {} };
|
|
|
515
515
|
var n = Array.prototype.slice.call(arguments, 0, -1), R = arguments[arguments.length - 1], X = z.utc.apply(null, n), f;
|
|
516
516
|
return !z.isMoment(c) && n0(X) && (f = y(R)) && X.add(f.parse(X), "minutes"), X.tz(R), X;
|
|
517
517
|
}
|
|
518
|
-
m.version = p, m.dataVersion = "", m._zones = b, m._links = O, m._names = o, m._countries = W, m.add = W0, m.link = M0, m.load = B0, m.zone = y, m.zoneExists = a0, m.guess = d0, m.names = H, m.Zone = S, m.unpack = V, m.unpackBase60 = t, m.needsOffset = n0, m.moveInvalidForward = !0, m.moveAmbiguousForward = !1, m.countries =
|
|
518
|
+
m.version = p, m.dataVersion = "", m._zones = b, m._links = O, m._names = o, m._countries = W, m.add = W0, m.link = M0, m.load = B0, m.zone = y, m.zoneExists = a0, m.guess = d0, m.names = H, m.Zone = S, m.unpack = V, m.unpackBase60 = t, m.needsOffset = n0, m.moveInvalidForward = !0, m.moveAmbiguousForward = !1, m.countries = T, m.zonesForCountry = U0;
|
|
519
519
|
var F = z.fn;
|
|
520
520
|
z.tz = m, z.defaultZone = null, z.updateOffset = function(c, n) {
|
|
521
521
|
var R = z.defaultZone, X;
|
|
@@ -539,7 +539,7 @@ var N0 = { exports: {} };
|
|
|
539
539
|
return this._z ? this._z.abbr(this) : c.call(this);
|
|
540
540
|
};
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function i0(c) {
|
|
543
543
|
return function() {
|
|
544
544
|
return this._z = null, c.apply(this, arguments);
|
|
545
545
|
};
|
|
@@ -549,8 +549,8 @@ var N0 = { exports: {} };
|
|
|
549
549
|
return arguments.length > 0 && (this._z = null), c.apply(this, arguments);
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
|
-
F.zoneName = L0(F.zoneName), F.zoneAbbr = L0(F.zoneAbbr), F.utc =
|
|
553
|
-
return (
|
|
552
|
+
F.zoneName = L0(F.zoneName), F.zoneAbbr = L0(F.zoneAbbr), F.utc = i0(F.utc), F.local = i0(F.local), F.utcOffset = s0(F.utcOffset), z.tz.setDefault = function(c) {
|
|
553
|
+
return (Y < 2 || Y === 2 && e < 9) && j("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + z.version + "."), z.defaultZone = c ? y(c) : null, z;
|
|
554
554
|
};
|
|
555
555
|
var A0 = z.momentProperties;
|
|
556
556
|
return Object.prototype.toString.call(A0) === "[object Array]" ? (A0.push("_z"), A0.push("_a")) : A0 && (A0._z = null), z;
|
|
@@ -1156,7 +1156,7 @@ const _0 = "2025b", h0 = [
|
|
|
1156
1156
|
"Pacific/Tarawa|Pacific/Majuro",
|
|
1157
1157
|
"Pacific/Tarawa|Pacific/Wake",
|
|
1158
1158
|
"Pacific/Tarawa|Pacific/Wallis"
|
|
1159
|
-
],
|
|
1159
|
+
], w0 = [
|
|
1160
1160
|
"AD|Europe/Andorra",
|
|
1161
1161
|
"AE|Asia/Dubai",
|
|
1162
1162
|
"AF|Asia/Kabul",
|
|
@@ -1404,14 +1404,14 @@ const _0 = "2025b", h0 = [
|
|
|
1404
1404
|
"ZA|Africa/Johannesburg",
|
|
1405
1405
|
"ZM|Africa/Maputo Africa/Lusaka",
|
|
1406
1406
|
"ZW|Africa/Maputo Africa/Harare"
|
|
1407
|
-
],
|
|
1407
|
+
], K0 = {
|
|
1408
1408
|
version: _0,
|
|
1409
1409
|
zones: h0,
|
|
1410
1410
|
links: D0,
|
|
1411
|
-
countries:
|
|
1411
|
+
countries: w0
|
|
1412
1412
|
};
|
|
1413
|
-
var
|
|
1414
|
-
|
|
1413
|
+
var g0 = C0;
|
|
1414
|
+
g0.tz.load(K0);
|
|
1415
1415
|
var R0 = {};
|
|
1416
1416
|
Object.defineProperty(R0, "__esModule", { value: !0 });
|
|
1417
1417
|
var z0 = R0.Variable = void 0, r0;
|
|
@@ -1483,13 +1483,13 @@ class b0 {
|
|
|
1483
1483
|
this.apikey = z || "smE3JnDLHy3TizVv", this.debug = p;
|
|
1484
1484
|
}
|
|
1485
1485
|
async standardWeatherModels() {
|
|
1486
|
-
return
|
|
1486
|
+
return w.standardWeatherModels();
|
|
1487
1487
|
}
|
|
1488
1488
|
async standardMarineModels() {
|
|
1489
|
-
return
|
|
1489
|
+
return w.standardMarineModels();
|
|
1490
1490
|
}
|
|
1491
1491
|
async autoPickMeteoModel(z = "best_match") {
|
|
1492
|
-
return
|
|
1492
|
+
return w.autoPickMeteoModel(z);
|
|
1493
1493
|
}
|
|
1494
1494
|
static range(z, p, b) {
|
|
1495
1495
|
return Array.from({ length: (p - z) / b }, (O, W) => z + W * b);
|
|
@@ -1514,8 +1514,8 @@ class b0 {
|
|
|
1514
1514
|
fake: z.fake,
|
|
1515
1515
|
step: A
|
|
1516
1516
|
});
|
|
1517
|
-
const
|
|
1518
|
-
W ? await this.mergeSegments(W,
|
|
1517
|
+
const a = await o0(q, z), Y = p ? await p(a, z, b) : await this.parseWeatherData(a, z, b);
|
|
1518
|
+
W ? await this.mergeSegments(W, Y) : W = Y;
|
|
1519
1519
|
}
|
|
1520
1520
|
else {
|
|
1521
1521
|
const A = await o0(z.url, z);
|
|
@@ -1545,7 +1545,7 @@ class b0 {
|
|
|
1545
1545
|
* @param options
|
|
1546
1546
|
*/
|
|
1547
1547
|
async marineForecast(z, p = {}) {
|
|
1548
|
-
var b, O, W, o, A, q,
|
|
1548
|
+
var b, O, W, o, A, q, a, Y;
|
|
1549
1549
|
try {
|
|
1550
1550
|
const e = L();
|
|
1551
1551
|
let d;
|
|
@@ -1569,8 +1569,8 @@ class b0 {
|
|
|
1569
1569
|
delete z.apikey;
|
|
1570
1570
|
const t = L();
|
|
1571
1571
|
this.debug && D.info("[%s] fetch marine api (%j) cost: %d ms", p.requestId, z.url, t.diff(e, "ms"));
|
|
1572
|
-
const
|
|
1573
|
-
return (O = (b = S == null ? void 0 : S.hourly) == null ? void 0 : b.wave_height) != null && O.every((r) => r !== null) ? [S] : (o = (W = V == null ? void 0 : V.hourly) == null ? void 0 : W.wave_height) != null && o.every((r) => r !== null) ? [V] : (q = (A = U == null ? void 0 : U.hourly) == null ? void 0 : A.wave_height) != null && q.every((r) => r !== null) ? [U] : (
|
|
1572
|
+
const i = await this.mergeMarineData(d), U = i.find((r) => r.model === "ncep_gfswave016"), s = i.find((r) => r.model === "ncep_gfswave025"), V = i.find((r) => r.model === "meteofrance_wave"), S = i.find((r) => r.model === "best_match");
|
|
1573
|
+
return (O = (b = S == null ? void 0 : S.hourly) == null ? void 0 : b.wave_height) != null && O.every((r) => r !== null) ? [S] : (o = (W = V == null ? void 0 : V.hourly) == null ? void 0 : W.wave_height) != null && o.every((r) => r !== null) ? [V] : (q = (A = U == null ? void 0 : U.hourly) == null ? void 0 : A.wave_height) != null && q.every((r) => r !== null) ? [U] : (Y = (a = s == null ? void 0 : s.hourly) == null ? void 0 : a.wave_height) != null && Y.every((r) => r !== null) ? [s] : i != null && i.length ? [i[0]] : [];
|
|
1574
1574
|
} catch (e) {
|
|
1575
1575
|
return D.warn("[%s] marine forecast failed: %s, with %j", p.requestId, e, z), [];
|
|
1576
1576
|
}
|
|
@@ -1583,10 +1583,10 @@ class b0 {
|
|
|
1583
1583
|
* @private
|
|
1584
1584
|
*/
|
|
1585
1585
|
async parseWeatherData(z, p, b = {}) {
|
|
1586
|
-
var o, A, q,
|
|
1586
|
+
var o, A, q, a, Y, e, d;
|
|
1587
1587
|
const O = [], W = Math.pow(10, b.precision || 6);
|
|
1588
1588
|
for (let t = 0; t < z.length; t++) {
|
|
1589
|
-
const
|
|
1589
|
+
const i = z[t], U = i.utcOffsetSeconds(), s = i.timezone(), V = i.current(), S = i.hourly(), r = i.daily(), l = {};
|
|
1590
1590
|
if (l.timezone = s || void 0, l.offset = b0.prettyTimezoneOffset(U), l.model = p.models instanceof Array ? (o = p.models) == null ? void 0 : o[t] : p.models || "best_match", V) {
|
|
1591
1591
|
const I = L();
|
|
1592
1592
|
l.current = {
|
|
@@ -1608,7 +1608,7 @@ class b0 {
|
|
|
1608
1608
|
)
|
|
1609
1609
|
};
|
|
1610
1610
|
for (let _ = 0; _ < S.variablesLength(); _++) {
|
|
1611
|
-
const v = (
|
|
1611
|
+
const v = (a = (q = (A = S.variables(_).valuesArray()) == null ? void 0 : A.toString()) == null ? void 0 : q.split(",")) == null ? void 0 : a.map((K) => isNaN(K) ? null : Math.round(Number(K) * W) / W);
|
|
1612
1612
|
l.hourly[p.hourly[_]] = v;
|
|
1613
1613
|
}
|
|
1614
1614
|
const E = L();
|
|
@@ -1622,7 +1622,7 @@ class b0 {
|
|
|
1622
1622
|
)
|
|
1623
1623
|
};
|
|
1624
1624
|
for (let E = 0; E < r.variablesLength(); E += b.memberLength ?? 1) {
|
|
1625
|
-
const _ = (d = (e = (
|
|
1625
|
+
const _ = (d = (e = (Y = r.variables(E).valuesArray()) == null ? void 0 : Y.toString()) == null ? void 0 : e.split(",")) == null ? void 0 : d.map((v) => isNaN(v) ? null : Math.round(Number(v) * W) / W);
|
|
1626
1626
|
l.daily[p.daily[E / (b.memberLength ?? 1)]] = _;
|
|
1627
1627
|
}
|
|
1628
1628
|
const P = L();
|
|
@@ -1639,37 +1639,37 @@ class b0 {
|
|
|
1639
1639
|
* @private
|
|
1640
1640
|
*/
|
|
1641
1641
|
async parseSeasonalDailyVariable(z, p, b = {}) {
|
|
1642
|
-
var o, A, q,
|
|
1642
|
+
var o, A, q, a, Y, e, d, t, i, U, s, V, S, r, l, I;
|
|
1643
1643
|
const O = [], W = Math.pow(10, b.precision || 6);
|
|
1644
1644
|
for (let P = 0; P < z.length; P++) {
|
|
1645
|
-
const E = z[P], _ = E.utcOffsetSeconds(), v = E.timezone(),
|
|
1646
|
-
(
|
|
1645
|
+
const E = z[P], _ = E.utcOffsetSeconds(), v = E.timezone(), K = E.daily(), k = [...Array(K.variablesLength())].map((T, M0) => K.variables(M0)), O0 = k.filter(
|
|
1646
|
+
(T) => (T == null ? void 0 : T.variable()) === z0.temperature && (T == null ? void 0 : T.altitude()) === 2 && (T == null ? void 0 : T.aggregation()) === c0.maximum
|
|
1647
1647
|
), d0 = k.filter(
|
|
1648
|
-
(
|
|
1649
|
-
), x = k.filter((
|
|
1650
|
-
(
|
|
1648
|
+
(T) => (T == null ? void 0 : T.variable()) === z0.temperature && (T == null ? void 0 : T.altitude()) === 2 && (T == null ? void 0 : T.aggregation()) === c0.minimum
|
|
1649
|
+
), x = k.filter((T) => (T == null ? void 0 : T.variable()) === z0.precipitation), W0 = k.filter(
|
|
1650
|
+
(T) => (T == null ? void 0 : T.variable()) === z0.wind_speed && (T == null ? void 0 : T.altitude()) === 10 && (T == null ? void 0 : T.aggregation()) === c0.maximum
|
|
1651
1651
|
), y = k.filter(
|
|
1652
|
-
(
|
|
1652
|
+
(T) => (T == null ? void 0 : T.variable()) === z0.wind_direction && (T == null ? void 0 : T.altitude()) === 10 && (T == null ? void 0 : T.aggregation()) === c0.dominant
|
|
1653
1653
|
), H = {};
|
|
1654
|
-
if (H.timezone = v || void 0, H.offset = b0.prettyTimezoneOffset(_), H.model = p.models instanceof Array ? (o = p.models) == null ? void 0 : o[P] : p.models || "best_match",
|
|
1655
|
-
const
|
|
1654
|
+
if (H.timezone = v || void 0, H.offset = b0.prettyTimezoneOffset(_), H.model = p.models instanceof Array ? (o = p.models) == null ? void 0 : o[P] : p.models || "best_match", K) {
|
|
1655
|
+
const T = L();
|
|
1656
1656
|
H.daily = {
|
|
1657
|
-
time: b0.range(Number(
|
|
1658
|
-
(
|
|
1657
|
+
time: b0.range(Number(K.time()), Number(K.timeEnd()), K.interval()).map(
|
|
1658
|
+
(g) => L.unix(g).add(p.fake ? 1 : 0, "year").utc().format()
|
|
1659
1659
|
)
|
|
1660
1660
|
};
|
|
1661
|
-
for (const
|
|
1662
|
-
H.daily.temperature_2m_max = (
|
|
1663
|
-
for (const
|
|
1664
|
-
H.daily.temperature_2m_min = (d = (e = (
|
|
1665
|
-
for (const
|
|
1666
|
-
H.daily.precipitation_sum = (U = (
|
|
1667
|
-
for (const
|
|
1668
|
-
H.daily.wind_direction_10m_dominant = (S = (V = (s =
|
|
1669
|
-
for (const
|
|
1670
|
-
H.daily.wind_speed_10m_max = (I = (l = (r =
|
|
1661
|
+
for (const g of O0)
|
|
1662
|
+
H.daily.temperature_2m_max = (a = (q = (A = g.valuesArray()) == null ? void 0 : A.toString()) == null ? void 0 : q.split(",")) == null ? void 0 : a.map((h) => isNaN(h) ? null : Math.round(Number(h) * W) / W);
|
|
1663
|
+
for (const g of d0)
|
|
1664
|
+
H.daily.temperature_2m_min = (d = (e = (Y = g.valuesArray()) == null ? void 0 : Y.toString()) == null ? void 0 : e.split(",")) == null ? void 0 : d.map((h) => isNaN(h) ? null : Math.round(Number(h) * W) / W);
|
|
1665
|
+
for (const g of x)
|
|
1666
|
+
H.daily.precipitation_sum = (U = (i = (t = g.valuesArray()) == null ? void 0 : t.toString()) == null ? void 0 : i.split(",")) == null ? void 0 : U.map((h) => isNaN(h) ? null : Math.round(Number(h) * W) / W);
|
|
1667
|
+
for (const g of y)
|
|
1668
|
+
H.daily.wind_direction_10m_dominant = (S = (V = (s = g.valuesArray()) == null ? void 0 : s.toString()) == null ? void 0 : V.split(",")) == null ? void 0 : S.map((h) => isNaN(h) ? null : Math.round(Number(h) * W) / W);
|
|
1669
|
+
for (const g of W0)
|
|
1670
|
+
H.daily.wind_speed_10m_max = (I = (l = (r = g.valuesArray()) == null ? void 0 : r.toString()) == null ? void 0 : l.split(",")) == null ? void 0 : I.map((h) => isNaN(h) ? null : Math.round(Number(h) * W) / W);
|
|
1671
1671
|
const M0 = L();
|
|
1672
|
-
D.debug("[%s] fetch daily variables cost: %d ms", b.requestId, M0.diff(
|
|
1672
|
+
D.debug("[%s] fetch daily variables cost: %d ms", b.requestId, M0.diff(T, "ms"));
|
|
1673
1673
|
}
|
|
1674
1674
|
O.push(H);
|
|
1675
1675
|
}
|
|
@@ -1689,8 +1689,8 @@ class b0 {
|
|
|
1689
1689
|
} else {
|
|
1690
1690
|
const o = L(p[b][O].date), A = L(z[b][O].date);
|
|
1691
1691
|
for (let q = 0; q < p[b][O][W].length; q++) {
|
|
1692
|
-
const
|
|
1693
|
-
|
|
1692
|
+
const a = o.clone().add(q, "h").diff(A, "h");
|
|
1693
|
+
a < z[b][O][W].length ? z[b][O][W][a] === null && (z[b][O][W][a] = p[b][O][W][q]) : W === "time" ? z[b][O][W].push(a) : z[b][O][W].push(p[b][O][W][q]);
|
|
1694
1694
|
}
|
|
1695
1695
|
}
|
|
1696
1696
|
} else if (O === "daily") {
|
|
@@ -1704,12 +1704,12 @@ class b0 {
|
|
|
1704
1704
|
return z;
|
|
1705
1705
|
}
|
|
1706
1706
|
async mergeMarineData(z) {
|
|
1707
|
-
var
|
|
1707
|
+
var o, A, q, a;
|
|
1708
1708
|
const p = [], b = z.find((Y) => Y.model === "best_match");
|
|
1709
1709
|
b && p.push(b);
|
|
1710
|
-
const O = z.find((Y) => Y.model === "meteofrance_currents");
|
|
1710
|
+
const O = z.find((Y) => Y.model === "meteofrance_currents"), W = z.find((Y) => Y.model === "ecmwf_wam025");
|
|
1711
1711
|
for (const Y of z)
|
|
1712
|
-
["best_match", "meteofrance_currents"].includes(Y.model) || (Y.hourly.ocean_current_velocity = (
|
|
1712
|
+
["best_match", "meteofrance_currents"].includes(Y.model) || (Y.hourly.ocean_current_velocity = (o = O == null ? void 0 : O.hourly) == null ? void 0 : o.ocean_current_velocity, Y.hourly.ocean_current_direction = (A = O == null ? void 0 : O.hourly) == null ? void 0 : A.ocean_current_direction, Y.hourly.sea_level_height_msl = (q = O == null ? void 0 : O.hourly) == null ? void 0 : q.sea_level_height_msl, Y.hourly.sea_surface_temperature = (a = O == null ? void 0 : O.hourly) == null ? void 0 : a.sea_surface_temperature, p.push(Y)), Y.model === "meteofrance_wave" && W && (Y.hourly.time = W.hourly.time, Y.hourly.wave_height = W.hourly.wave_height, Y.hourly.wave_direction = W.hourly.wave_direction, Y.hourly.wave_period = W.hourly.wave_period, Y.daily.time = W.daily.time, Y.daily.wave_height_max = W.daily.wave_height_max, Y.daily.wave_direction_dominant = W.daily.wave_direction_dominant, Y.daily.wave_period_max = W.daily.wave_period_max);
|
|
1713
1713
|
return p;
|
|
1714
1714
|
}
|
|
1715
1715
|
pickForecastUrl(z, p, b, O = {}) {
|
|
@@ -1723,12 +1723,12 @@ class b0 {
|
|
|
1723
1723
|
const b = [];
|
|
1724
1724
|
for (let A = 0; A < p.length; A++) {
|
|
1725
1725
|
const q = p[A];
|
|
1726
|
-
["ecmwf_wam025", "meteofrance_wave", "ewam", "gwam", "era5_ocean"].includes(q) ? b.push("meteofrance_currents", q) : ["gfswave", "ncep_gfswave025", "ncep_gfswave016"].includes(q) ? b.push("meteofrance_currents", "ncep_gfswave025", "ncep_gfswave016") : b.push("best_match");
|
|
1726
|
+
["ecmwf_wam025", "meteofrance_wave", "ewam", "gwam", "era5_ocean"].includes(q) ? b.push("meteofrance_currents", "ecmwf_wam025", q) : ["gfswave", "ncep_gfswave025", "ncep_gfswave016"].includes(q) ? b.push("meteofrance_currents", "ncep_gfswave025", "ncep_gfswave016") : b.push("best_match");
|
|
1727
1727
|
}
|
|
1728
|
-
const O = b.reduce((A, q) => (A.includes(q) || A.push(q), A), []), W = ["best_match", "meteofrance_currents", "
|
|
1728
|
+
const O = b.reduce((A, q) => (A.includes(q) || A.push(q), A), []), W = ["best_match", "meteofrance_currents", "ecmwf_wam025", "meteofrance_wave", "ncep_gfswave025", "gwam", "era5_ocean", "ewam", "ncep_gfswave016"];
|
|
1729
1729
|
return O.sort((A, q) => {
|
|
1730
|
-
const
|
|
1731
|
-
return
|
|
1730
|
+
const a = W.indexOf(A), Y = W.indexOf(q);
|
|
1731
|
+
return a - Y;
|
|
1732
1732
|
}), O;
|
|
1733
1733
|
}
|
|
1734
1734
|
/**
|
|
@@ -1740,16 +1740,16 @@ class b0 {
|
|
|
1740
1740
|
* @private
|
|
1741
1741
|
*/
|
|
1742
1742
|
async prepare(z, p, b, O = {}) {
|
|
1743
|
-
var
|
|
1744
|
-
const W = O.maxDays || 14, o = L.utc(), A = z ? L.utc(z) : void 0, q = p ? await this.pickUpdateMeta(b.models) : [],
|
|
1743
|
+
var Y, e;
|
|
1744
|
+
const W = O.maxDays || 14, o = L.utc(), A = z ? L.utc(z) : void 0, q = p ? await this.pickUpdateMeta(b.models) : [], a = (e = (Y = q[0]) == null ? void 0 : Y.meta) != null && e.endTime ? L(q[0].meta.endTime) : o.clone().add(W, "day");
|
|
1745
1745
|
if (z) {
|
|
1746
1746
|
const d = A.clone().utc().add(O.forecastDays ?? 1, "day");
|
|
1747
|
-
d.isAfter(
|
|
1747
|
+
d.isAfter(a) ? (d.subtract(1, "year"), A.isAfter(a) ? (A.subtract(1, "year"), b.start_dates = [
|
|
1748
1748
|
A.clone().subtract(O.pastDays || 0, "day").utc().format("YYYY-MM-DD")
|
|
1749
1749
|
], b.end_dates = [d.utc().format("YYYY-MM-DD")], b.fakes = [!0], b.url = [this.pickForecastUrl(p, O.selfHosted ?? !0, !0, O)]) : (b.start_dates = [
|
|
1750
1750
|
A.clone().subtract(O.pastDays || 0, "day").utc().format("YYYY-MM-DD"),
|
|
1751
|
-
|
|
1752
|
-
], b.end_dates = [
|
|
1751
|
+
a.clone().subtract(1, "year").subtract(1, "day").utc().format("YYYY-MM-DD")
|
|
1752
|
+
], b.end_dates = [a.clone().subtract(1, "day").utc().format("YYYY-MM-DD"), d.utc().format("YYYY-MM-DD")], b.fakes = [!1, !0], b.url = [
|
|
1753
1753
|
this.pickForecastUrl(p, O.selfHosted ?? !0, !1, O),
|
|
1754
1754
|
this.pickForecastUrl(p, O.selfHosted ?? !0, !0, O)
|
|
1755
1755
|
])) : (b.start_dates = [
|
|
@@ -1811,7 +1811,7 @@ class b0 {
|
|
|
1811
1811
|
selfHosted: !0,
|
|
1812
1812
|
maxDays: 14
|
|
1813
1813
|
}) {
|
|
1814
|
-
var
|
|
1814
|
+
var i, U, s, V, S, r;
|
|
1815
1815
|
p = this.toStdLng(p), this.debug && D.info("[%s] spot forecast params: %j", A.requestId, { lat: z, lng: p, datetime: b, simplify: O, withDaily: W, withHourly: o, options: A });
|
|
1816
1816
|
const q = {
|
|
1817
1817
|
apikey: this.apikey,
|
|
@@ -1819,12 +1819,12 @@ class b0 {
|
|
|
1819
1819
|
longitude: p,
|
|
1820
1820
|
cell_selection: "sea",
|
|
1821
1821
|
wind_speed_unit: "kn",
|
|
1822
|
-
models: ((
|
|
1822
|
+
models: ((i = A.weatherModels) == null ? void 0 : i.split(",")) || ["best_match"],
|
|
1823
1823
|
timezone: "auto"
|
|
1824
1824
|
};
|
|
1825
|
-
let
|
|
1826
|
-
const
|
|
1827
|
-
b && (
|
|
1825
|
+
let a;
|
|
1826
|
+
const Y = this.timezoneOffset(z, p);
|
|
1827
|
+
b && (a = L.utc(b).utcOffset(Y), a.subtract(Y > 0 ? Y : -Y, "h"), A.selfHistory = !(a != null && a.isBefore(L.utc().subtract(240, "days")))), W && (q.daily = ((U = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : U.split(",")) || []), a || (A.forecastDays = A.forecastDays || 1, A.pastDays = 0, o = !0), o && (q.hourly = ((s = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : s.split(",")) || []), A.maxDays = A.maxDays || 14, A.pastDays = A.pastDays || 0, A.pastDays = A.pastDays > 7 ? 7 : A.pastDays < 0 ? 0 : A.pastDays, A.forecastDays = A.forecastDays ?? 1, A.forecastDays = A.forecastDays > A.maxDays ? A.maxDays : A.forecastDays < 0 ? 1 : A.forecastDays, await this.prepare(a == null ? void 0 : a.utc().format(), !1, q, A);
|
|
1828
1828
|
const e = await this.weatherForecast(q, void 0, A), d = {
|
|
1829
1829
|
apikey: this.apikey,
|
|
1830
1830
|
latitude: z,
|
|
@@ -1834,9 +1834,9 @@ class b0 {
|
|
|
1834
1834
|
wind_speed_unit: "kn",
|
|
1835
1835
|
models: this.pickMarineModels(A.marineModels)
|
|
1836
1836
|
};
|
|
1837
|
-
W && (d.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")),
|
|
1837
|
+
W && (d.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), a || (A.forecastDays = A.forecastDays || 1, o = !0), o && (d.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), await this.prepare(a == null ? void 0 : a.utc().format(), !0, d, A);
|
|
1838
1838
|
let t = await this.marineForecast(d, A);
|
|
1839
|
-
return (r = (S = (V = t[0]) == null ? void 0 : V.hourly) == null ? void 0 : S.wave_height) != null && r.every((l) => l === null || l === 0) && (d.models = this.pickMarineModels("best_match,ncep_gfswave025,meteofrance_wave"), t = await this.marineForecast(d, A)), { weather: e, marine: t };
|
|
1839
|
+
return (r = (S = (V = t[0]) == null ? void 0 : V.hourly) == null ? void 0 : S.wave_height) != null && r.every((l) => l === null || l === 0) && (d.models = this.pickMarineModels("best_match,ncep_gfswave025,ecmwf_wam025,meteofrance_wave"), t = await this.marineForecast(d, A)), { weather: e, marine: t };
|
|
1840
1840
|
}
|
|
1841
1841
|
/**
|
|
1842
1842
|
* 历史再分析数据
|
|
@@ -1864,8 +1864,8 @@ class b0 {
|
|
|
1864
1864
|
}) {
|
|
1865
1865
|
var U, s;
|
|
1866
1866
|
p = this.toStdLng(p), this.debug && D.info("[%s] spot historical params: %j", q.requestId, { lat: z, lng: p, startDate: b, endDate: O, withMarine: A, options: q });
|
|
1867
|
-
const
|
|
1868
|
-
|
|
1867
|
+
const a = this.timezoneOffset(z, p), Y = L.utc(b).utcOffset(a), e = L.utc(O).utcOffset(a);
|
|
1868
|
+
Y.subtract(a > 0 ? a : -a, "h"), e.subtract(a > 0 ? a : -a, "h");
|
|
1869
1869
|
const d = {
|
|
1870
1870
|
apikey: this.apikey,
|
|
1871
1871
|
latitude: z,
|
|
@@ -1875,12 +1875,12 @@ class b0 {
|
|
|
1875
1875
|
models: ((U = q.weatherModels) == null ? void 0 : U.split(",")) || ["best_match"],
|
|
1876
1876
|
timezone: "auto",
|
|
1877
1877
|
url: this.HISTORICAL.OM_URL,
|
|
1878
|
-
start_date:
|
|
1878
|
+
start_date: Y.format("YYYY-MM-DD"),
|
|
1879
1879
|
end_date: e.format("YYYY-MM-DD")
|
|
1880
1880
|
};
|
|
1881
1881
|
W && (d.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), o && (d.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
|
|
1882
1882
|
const t = await this.weatherForecast(d, void 0, q);
|
|
1883
|
-
let
|
|
1883
|
+
let i;
|
|
1884
1884
|
if (A) {
|
|
1885
1885
|
const V = {
|
|
1886
1886
|
apikey: this.apikey,
|
|
@@ -1893,12 +1893,12 @@ class b0 {
|
|
|
1893
1893
|
daily: this.FORECAST.MARINE_VARIABLES.DAILY.split(","),
|
|
1894
1894
|
hourly: this.FORECAST.MARINE_VARIABLES.HOURLY.split(","),
|
|
1895
1895
|
url: this.FORECAST.OM_MARINE_URL,
|
|
1896
|
-
start_date:
|
|
1896
|
+
start_date: Y.format("YYYY-MM-DD"),
|
|
1897
1897
|
end_date: e.format("YYYY-MM-DD")
|
|
1898
1898
|
};
|
|
1899
|
-
|
|
1899
|
+
i = await this.marineForecast(V, q);
|
|
1900
1900
|
}
|
|
1901
|
-
return { weather: t, marine:
|
|
1901
|
+
return { weather: t, marine: i };
|
|
1902
1902
|
}
|
|
1903
1903
|
/**
|
|
1904
1904
|
* 季节预报数据
|
|
@@ -1916,9 +1916,9 @@ class b0 {
|
|
|
1916
1916
|
precision: 6
|
|
1917
1917
|
}) {
|
|
1918
1918
|
p = this.toStdLng(p), this.debug && D.info("[%s] spot seasonal params: %j", o.requestId, { lat: z, lng: p, startDate: b, endDate: O, options: o });
|
|
1919
|
-
const A = this.timezoneOffset(z, p), q = L.utc(b).utcOffset(A),
|
|
1920
|
-
q.subtract(A > 0 ? A : -A, "h"),
|
|
1921
|
-
const
|
|
1919
|
+
const A = this.timezoneOffset(z, p), q = L.utc(b).utcOffset(A), a = O ? L.utc(O).utcOffset(A) : q.clone().add(1, "month");
|
|
1920
|
+
q.subtract(A > 0 ? A : -A, "h"), a.subtract(A > 0 ? A : -A, "h");
|
|
1921
|
+
const Y = {
|
|
1922
1922
|
apikey: this.apikey,
|
|
1923
1923
|
latitude: z,
|
|
1924
1924
|
longitude: p,
|
|
@@ -1927,10 +1927,10 @@ class b0 {
|
|
|
1927
1927
|
timezone: "auto",
|
|
1928
1928
|
url: this.SEASONAL.OM_URL,
|
|
1929
1929
|
start_date: q.format("YYYY-MM-DD"),
|
|
1930
|
-
end_date:
|
|
1930
|
+
end_date: a.format("YYYY-MM-DD"),
|
|
1931
1931
|
daily: this.SEASONAL.WEATHER_VARIABLES.DAILY.split(",")
|
|
1932
1932
|
};
|
|
1933
|
-
return W && (
|
|
1933
|
+
return W && (Y.six_hourly = this.SEASONAL.WEATHER_VARIABLES.SIX_HOURLY.split(",")), o.memberLength = 4, { weather: await this.weatherForecast(Y, this.parseSeasonalDailyVariable, o) };
|
|
1934
1934
|
}
|
|
1935
1935
|
/**
|
|
1936
1936
|
* 气候态数据
|
|
@@ -1959,7 +1959,7 @@ class b0 {
|
|
|
1959
1959
|
p = this.toStdLng(p), this.debug && D.info("[%s] spot climate params: %j", W.requestId, { lat: z, lng: p, startDate: b, endDate: O, options: W });
|
|
1960
1960
|
const o = this.timezoneOffset(z, p), A = L.utc(b).utcOffset(o), q = O ? L.utc(O).utcOffset(o) : A.clone().add(1, "day");
|
|
1961
1961
|
q.subtract(o > 0 ? o : -o, "h"), A.subtract(o > 0 ? o : -o, "h");
|
|
1962
|
-
const
|
|
1962
|
+
const a = {
|
|
1963
1963
|
apikey: this.apikey,
|
|
1964
1964
|
latitude: z,
|
|
1965
1965
|
longitude: p,
|
|
@@ -1972,7 +1972,7 @@ class b0 {
|
|
|
1972
1972
|
end_date: q.format("YYYY-MM-DD"),
|
|
1973
1973
|
daily: this.CLIMATE.WEATHER_VARIABLES.DAILY.split(",")
|
|
1974
1974
|
};
|
|
1975
|
-
return { weather: await this.weatherForecast(
|
|
1975
|
+
return { weather: await this.weatherForecast(a, void 0, W) };
|
|
1976
1976
|
}
|
|
1977
1977
|
async update(z = {}) {
|
|
1978
1978
|
const p = L.unix(this.METEO2_UPDATE.etime), b = this.METEO2_UPDATE.version, O = L();
|
|
@@ -1986,25 +1986,25 @@ class b0 {
|
|
|
1986
1986
|
try {
|
|
1987
1987
|
const A = await o.json();
|
|
1988
1988
|
if (A.code === 0) {
|
|
1989
|
-
const q = A.data,
|
|
1990
|
-
for (const
|
|
1991
|
-
const e =
|
|
1989
|
+
const q = A.data, a = w.standardWeatherModels();
|
|
1990
|
+
for (const Y of a) {
|
|
1991
|
+
const e = w.autoPickSubCategories(Y.alias), t = q.filter((i) => e.includes(i.category)).map((i) => {
|
|
1992
1992
|
var S, r, l, I, P, E;
|
|
1993
|
-
const U = L.unix((S =
|
|
1993
|
+
const U = L.unix((S = i.meta) == null ? void 0 : S.data_end_time).utc(), s = L.unix((r = i.meta) == null ? void 0 : r.last_run_availability_time).utc(), V = U.diff(s, "days");
|
|
1994
1994
|
return {
|
|
1995
|
-
category:
|
|
1995
|
+
category: i.category,
|
|
1996
1996
|
meta: {
|
|
1997
1997
|
endTime: U.format(),
|
|
1998
1998
|
availabilityTime: s.format(),
|
|
1999
1999
|
days: V,
|
|
2000
|
-
initialisationTime: L.unix((l =
|
|
2001
|
-
modificationTime: L.unix((I =
|
|
2002
|
-
temporalResolution: Math.round(((P =
|
|
2003
|
-
frequency: Math.round(((E =
|
|
2000
|
+
initialisationTime: L.unix((l = i.meta) == null ? void 0 : l.last_run_initialisation_time).utc().format(),
|
|
2001
|
+
modificationTime: L.unix((I = i.meta) == null ? void 0 : I.last_run_modification_time).utc().format(),
|
|
2002
|
+
temporalResolution: Math.round(((P = i.meta) == null ? void 0 : P.temporal_resolution_seconds) / 3600),
|
|
2003
|
+
frequency: Math.round(((E = i.meta) == null ? void 0 : E.update_interval_seconds) / 3600)
|
|
2004
2004
|
}
|
|
2005
2005
|
};
|
|
2006
2006
|
});
|
|
2007
|
-
t.length && (this.METEO2_UPDATE[
|
|
2007
|
+
t.length && (this.METEO2_UPDATE[Y.alias] = t);
|
|
2008
2008
|
}
|
|
2009
2009
|
this.METEO2_UPDATE.version = b + 1, this.METEO2_UPDATE.etime = O.unix();
|
|
2010
2010
|
}
|
|
@@ -2070,11 +2070,11 @@ class M1 {
|
|
|
2070
2070
|
* @param datum
|
|
2071
2071
|
* @param options
|
|
2072
2072
|
*/
|
|
2073
|
-
async tidesForecast(z, p, b = 7, O = "today", W = !0, o = !1, A = !1, q = "CD",
|
|
2074
|
-
O = O || "today", b = b || 7, p = this.toStdLng(p), this.debug && S0.info("[%s] spot tides forecast params: %j",
|
|
2075
|
-
let
|
|
2076
|
-
W && (
|
|
2077
|
-
const d = await (await fetch(
|
|
2073
|
+
async tidesForecast(z, p, b = 7, O = "today", W = !0, o = !1, A = !1, q = "CD", a = {}) {
|
|
2074
|
+
O = O || "today", b = b || 7, p = this.toStdLng(p), this.debug && S0.info("[%s] spot tides forecast params: %j", a.requestId, { lat: z, lng: p, date: O, extremes: W, heights: o, datums: A, datum: q });
|
|
2075
|
+
let Y = `https://www.worldtides.info/api/v3?lat=${z}&lon=${p}&days=${b}&date=${O}&datum=${q}&key=${this.apikey}&localtime`;
|
|
2076
|
+
W && (Y = `${Y}&extremes`), o && (Y = `${Y}&heights`), A && (Y = `${Y}&datums`);
|
|
2077
|
+
const d = await (await fetch(Y)).json();
|
|
2078
2078
|
return d.status === 200 ? {
|
|
2079
2079
|
rqt: {
|
|
2080
2080
|
lat: z,
|
|
@@ -2109,7 +2109,7 @@ class p0 {
|
|
|
2109
2109
|
lng: isNaN(W) ? null : W,
|
|
2110
2110
|
pressure: isNaN(b) ? null : Math.round(b) || null,
|
|
2111
2111
|
kts: isNaN(o) ? null : Math.round(o) || null,
|
|
2112
|
-
bf:
|
|
2112
|
+
bf: w.beaufort(w.kts2ms(o ?? 0)),
|
|
2113
2113
|
...N.parseTropicalType(o),
|
|
2114
2114
|
wind: {
|
|
2115
2115
|
r7: null,
|
|
@@ -2136,16 +2136,16 @@ class p0 {
|
|
|
2136
2136
|
var W;
|
|
2137
2137
|
const b = L.utc(p.reftime).format(), O = {};
|
|
2138
2138
|
return (W = p.records) == null || W.forEach((o) => {
|
|
2139
|
-
const A = L.utc(o.time), q = A.diff(b, "hour"),
|
|
2139
|
+
const A = L.utc(o.time), q = A.diff(b, "hour"), a = Number(o.pressure / 100), Y = Number(o.lat), e = Number(o.lon), d = Number(o.windSpeed * 3600 / 1852);
|
|
2140
2140
|
O[q] = {
|
|
2141
|
-
lat: isNaN(
|
|
2141
|
+
lat: isNaN(Y) ? null : Y,
|
|
2142
2142
|
lng: isNaN(e) ? null : e,
|
|
2143
|
-
pressure: isNaN(
|
|
2143
|
+
pressure: isNaN(a) ? null : Math.round(a) || null,
|
|
2144
2144
|
utc: A.format(),
|
|
2145
2145
|
wind: {
|
|
2146
2146
|
datetime: A.format(),
|
|
2147
2147
|
kts: isNaN(d) ? null : Math.round(d) || null,
|
|
2148
|
-
bf:
|
|
2148
|
+
bf: w.beaufort(w.kts2ms(d ?? 0)),
|
|
2149
2149
|
...N.parseTropicalType(d),
|
|
2150
2150
|
r7: null,
|
|
2151
2151
|
r7ne: null,
|
|
@@ -2199,21 +2199,21 @@ const J = class J {
|
|
|
2199
2199
|
static async parseHistory(z) {
|
|
2200
2200
|
const p = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${z}`, b = await $.post(p).text(), O = await J.parser.parseStringPromise(b), W = O.typhoon.position instanceof Array ? O.typhoon.position : [O.typhoon.position], o = [];
|
|
2201
2201
|
for (const A of W) {
|
|
2202
|
-
const q = L(A.updatetime).utcOffset(8).utc().format(),
|
|
2202
|
+
const q = L(A.updatetime).utcOffset(8).utc().format(), a = Number(A.lat), Y = Number(A.lon), e = Number(A.pressure), d = Number(A.windspeed * 3600 / 1852), t = N.parseWindCircle(A.c7quad1 / 1.852), i = N.parseWindCircle(A.c7quad2 / 1.852), U = N.parseWindCircle(A.c7quad3 / 1.852), s = N.parseWindCircle(A.c7quad4 / 1.852), V = N.parseWindCircle(A.c10quad1 / 1.852), S = N.parseWindCircle(A.c10quad2 / 1.852), r = N.parseWindCircle(A.c10quad3 / 1.852), l = N.parseWindCircle(A.c10quad4 / 1.852), I = N.parseWindCircle(A.c12quad1 / 1.852), P = N.parseWindCircle(A.c12quad2 / 1.852), E = N.parseWindCircle(A.c12quad3 / 1.852), _ = N.parseWindCircle(A.c12quad4 / 1.852), { r7: v, r10: K, r12: k } = N.estimateWindRadii(d, a), O0 = {
|
|
2203
2203
|
updated: q,
|
|
2204
|
-
lat: isNaN(
|
|
2205
|
-
lng: isNaN(
|
|
2204
|
+
lat: isNaN(a) ? null : a,
|
|
2205
|
+
lng: isNaN(Y) ? null : Y,
|
|
2206
2206
|
pressure: isNaN(e) ? null : Math.round(e),
|
|
2207
2207
|
kts: isNaN(d) ? null : Math.round(d) || null,
|
|
2208
|
-
bf:
|
|
2208
|
+
bf: w.beaufort(w.kts2ms(d ?? 0)),
|
|
2209
2209
|
...N.parseTropicalType(d),
|
|
2210
2210
|
wind: {
|
|
2211
2211
|
r7: v,
|
|
2212
2212
|
r7ne: t,
|
|
2213
|
-
r7nw:
|
|
2213
|
+
r7nw: i,
|
|
2214
2214
|
r7sw: U,
|
|
2215
2215
|
r7se: s,
|
|
2216
|
-
r10:
|
|
2216
|
+
r10: K,
|
|
2217
2217
|
r10ne: V,
|
|
2218
2218
|
r10nw: S,
|
|
2219
2219
|
r10sw: r,
|
|
@@ -2233,15 +2233,15 @@ const J = class J {
|
|
|
2233
2233
|
const b = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${z}`, O = await $.post(b).text(), W = await J.parser.parseStringPromise(O), o = W.list.forecast instanceof Array ? W.list.forecast : [W.list.forecast], A = [];
|
|
2234
2234
|
for (const q of o)
|
|
2235
2235
|
if (q.xuhao === z) {
|
|
2236
|
-
const
|
|
2237
|
-
if (
|
|
2238
|
-
p = p || L(
|
|
2239
|
-
const
|
|
2240
|
-
for (const d of
|
|
2241
|
-
const t = L(d.forecasttime).utcOffset(8).utc(),
|
|
2242
|
-
if (
|
|
2236
|
+
const a = q.positions.forecastposition instanceof Array ? q.positions.forecastposition : [q.positions.forecastposition];
|
|
2237
|
+
if (a.length) {
|
|
2238
|
+
p = p || L(a.at(0).forecasttime).utcOffset(8).utc();
|
|
2239
|
+
const Y = {};
|
|
2240
|
+
for (const d of a) {
|
|
2241
|
+
const t = L(d.forecasttime).utcOffset(8).utc(), i = t.diff(p, "hours");
|
|
2242
|
+
if (i) {
|
|
2243
2243
|
const U = Number(d.forelat), s = Number(d.forelon), V = Number(d.forepressure), S = Number(d.forespeed * 3600 / 1852);
|
|
2244
|
-
|
|
2244
|
+
Y[i] = {
|
|
2245
2245
|
lat: isNaN(U) ? null : U,
|
|
2246
2246
|
lng: isNaN(s) ? null : s,
|
|
2247
2247
|
pressure: V ? Math.round(V) : null,
|
|
@@ -2249,7 +2249,7 @@ const J = class J {
|
|
|
2249
2249
|
wind: {
|
|
2250
2250
|
datetime: t.format(),
|
|
2251
2251
|
kts: isNaN(S) ? null : Math.round(S),
|
|
2252
|
-
bf:
|
|
2252
|
+
bf: w.beaufort(w.kts2ms(S ?? 0)),
|
|
2253
2253
|
...N.parseTropicalType(S),
|
|
2254
2254
|
r7: null,
|
|
2255
2255
|
r7ne: null,
|
|
@@ -2276,7 +2276,7 @@ const J = class J {
|
|
|
2276
2276
|
const e = {
|
|
2277
2277
|
date: p.utc().format(),
|
|
2278
2278
|
model: N.parseTropicalModel(q.country).toLowerCase(),
|
|
2279
|
-
hours:
|
|
2279
|
+
hours: Y
|
|
2280
2280
|
};
|
|
2281
2281
|
A.push(e);
|
|
2282
2282
|
}
|
|
@@ -2320,8 +2320,8 @@ class N {
|
|
|
2320
2320
|
var b;
|
|
2321
2321
|
const p = Object.values(e0);
|
|
2322
2322
|
return (b = z.forecasts) == null || b.sort((O, W) => {
|
|
2323
|
-
var q,
|
|
2324
|
-
const o = p.indexOf((q = O.model) == null ? void 0 : q.toUpperCase()), A = p.indexOf((
|
|
2323
|
+
var q, a;
|
|
2324
|
+
const o = p.indexOf((q = O.model) == null ? void 0 : q.toUpperCase()), A = p.indexOf((a = W.model) == null ? void 0 : a.toUpperCase());
|
|
2325
2325
|
return (o === -1 ? 999 : o) - (A === -1 ? 999 : A);
|
|
2326
2326
|
}), z;
|
|
2327
2327
|
}
|
|
@@ -2329,31 +2329,31 @@ class N {
|
|
|
2329
2329
|
var W, o;
|
|
2330
2330
|
const b = await p0.realtimeForecast(), O = z ? await q0.realtimeForecast() : [];
|
|
2331
2331
|
for (const A of b) {
|
|
2332
|
-
const q = O.find((
|
|
2332
|
+
const q = O.find((Y) => {
|
|
2333
2333
|
var e, d;
|
|
2334
|
-
return ((e =
|
|
2334
|
+
return ((e = Y.name) == null ? void 0 : e.toLowerCase()) === ((d = A.name) == null ? void 0 : d.toLowerCase());
|
|
2335
2335
|
});
|
|
2336
2336
|
if (q) {
|
|
2337
|
-
A.cnName = q.cnName, (W = q.history) != null && W.length && (A.history = q.history), A.history.sort((
|
|
2338
|
-
for (const
|
|
2339
|
-
["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((o =
|
|
2337
|
+
A.cnName = q.cnName, (W = q.history) != null && W.length && (A.history = q.history), A.history.sort((Y, e) => L(e.updated).valueOf() - L(Y.updated).valueOf());
|
|
2338
|
+
for (const Y of q.forecasts)
|
|
2339
|
+
["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((o = Y.model) == null ? void 0 : o.toUpperCase()) && !A.forecasts.find((e) => e.model.toLowerCase() === Y.model.toLowerCase()) && A.forecasts.push(Y);
|
|
2340
2340
|
}
|
|
2341
|
-
A.history = A.history.reduce((
|
|
2342
|
-
const
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
const e = L(
|
|
2346
|
-
for (const t in
|
|
2347
|
-
const
|
|
2348
|
-
U > 0 && (d[U] =
|
|
2341
|
+
A.history = A.history.reduce((Y, e) => (Y.find((d) => d.updated === e.updated) || Y.push(e), Y), []);
|
|
2342
|
+
const a = A.history[0];
|
|
2343
|
+
a && A.forecasts.forEach((Y) => {
|
|
2344
|
+
Y.date = a.updated;
|
|
2345
|
+
const e = L(a.updated), d = {};
|
|
2346
|
+
for (const t in Y.hours) {
|
|
2347
|
+
const i = Y.hours[t], U = L(i.utc).diff(e, "h");
|
|
2348
|
+
U > 0 && (d[U] = i);
|
|
2349
2349
|
}
|
|
2350
|
-
|
|
2350
|
+
Y.hours = d;
|
|
2351
2351
|
}), await N.tropicalMovement(A);
|
|
2352
2352
|
}
|
|
2353
2353
|
for (const A of O)
|
|
2354
2354
|
b.every((q) => {
|
|
2355
|
-
var
|
|
2356
|
-
return ((
|
|
2355
|
+
var a, Y;
|
|
2356
|
+
return ((a = q.name) == null ? void 0 : a.toLowerCase()) !== ((Y = A.name) == null ? void 0 : Y.toLowerCase());
|
|
2357
2357
|
}) && b.push(A);
|
|
2358
2358
|
return b;
|
|
2359
2359
|
}
|
|
@@ -2369,10 +2369,10 @@ class N {
|
|
|
2369
2369
|
for (let A = 0; A < o.length - 1; A++) {
|
|
2370
2370
|
const q = W[o[A]];
|
|
2371
2371
|
p = p || q;
|
|
2372
|
-
const
|
|
2373
|
-
q.movement = N.calculateMovement(q,
|
|
2374
|
-
const
|
|
2375
|
-
q.wind = { ...q.wind || {}, ...
|
|
2372
|
+
const a = W[o[A + 1]];
|
|
2373
|
+
q.movement = N.calculateMovement(q, a);
|
|
2374
|
+
const Y = N.supplementWindRadii(q);
|
|
2375
|
+
q.wind = { ...q.wind || {}, ...Y };
|
|
2376
2376
|
}
|
|
2377
2377
|
});
|
|
2378
2378
|
let b = null;
|
|
@@ -2390,10 +2390,10 @@ class N {
|
|
|
2390
2390
|
return z;
|
|
2391
2391
|
}
|
|
2392
2392
|
static calculateMovement(z, p) {
|
|
2393
|
-
const b =
|
|
2393
|
+
const b = T0.calculateDistance(z, p), O = L(p.utc || p.updated).diff(z.utc || z.updated, "h", !0);
|
|
2394
2394
|
return {
|
|
2395
2395
|
kts: Math.round(b / O * 100) / 100,
|
|
2396
|
-
deg:
|
|
2396
|
+
deg: T0.calculateBearing(z, p, !0, 0)
|
|
2397
2397
|
};
|
|
2398
2398
|
}
|
|
2399
2399
|
/**
|
|
@@ -2426,10 +2426,10 @@ class N {
|
|
|
2426
2426
|
return 0;
|
|
2427
2427
|
let W = b, o = b * 10;
|
|
2428
2428
|
for (; o - W > 0.1; ) {
|
|
2429
|
-
const A = (W + o) / 2, q = b / A,
|
|
2430
|
-
p * Math.sqrt(
|
|
2429
|
+
const A = (W + o) / 2, q = b / A, a = Math.pow(q, O) * Math.exp(1 - Math.pow(q, O));
|
|
2430
|
+
p * Math.sqrt(a) > z ? W = A : o = A;
|
|
2431
2431
|
}
|
|
2432
|
-
return
|
|
2432
|
+
return w.kmh2kts(W + o);
|
|
2433
2433
|
}
|
|
2434
2434
|
/**
|
|
2435
2435
|
* 基于台风强度推算风圈基础半径的经验公式
|
|
@@ -2438,7 +2438,7 @@ class N {
|
|
|
2438
2438
|
* @returns 风圈半径对象
|
|
2439
2439
|
*/
|
|
2440
2440
|
static estimateWindRadii(z, p) {
|
|
2441
|
-
const b =
|
|
2441
|
+
const b = w.kts2ms(z), O = N.estimateRMW(b, p), W = N.estimateHollandB(b, O, p), o = N.findWindRadius(17.2, b, O, W), A = N.findWindRadius(28.5, b, O, W), q = N.findWindRadius(37, b, O, W);
|
|
2442
2442
|
return {
|
|
2443
2443
|
r7: o ? Math.round(o) : null,
|
|
2444
2444
|
r10: A ? Math.round(A) : null,
|
|
@@ -2463,8 +2463,8 @@ class N {
|
|
|
2463
2463
|
nw: (315 - b + 360) % 360,
|
|
2464
2464
|
se: (135 - b + 360) % 360,
|
|
2465
2465
|
sw: (225 - b + 360) % 360
|
|
2466
|
-
}, q = (
|
|
2467
|
-
const
|
|
2466
|
+
}, q = (a) => {
|
|
2467
|
+
const Y = a > 180 ? a - 360 : a, e = Math.cos(Y * Math.PI / 180);
|
|
2468
2468
|
return 1 - o * e;
|
|
2469
2469
|
};
|
|
2470
2470
|
return {
|
|
@@ -2481,8 +2481,8 @@ class N {
|
|
|
2481
2481
|
static supplementWindRadii(z) {
|
|
2482
2482
|
const { wind: p, lat: b, movement: O } = z;
|
|
2483
2483
|
if (p.r7) {
|
|
2484
|
-
for (const
|
|
2485
|
-
/^r[7,10,12]/.test(
|
|
2484
|
+
for (const a of Object.keys(p))
|
|
2485
|
+
/^r[7,10,12]/.test(a) && (isNaN(Number(p[a])) || p[a] < 0) && (p[a] = null);
|
|
2486
2486
|
return p;
|
|
2487
2487
|
}
|
|
2488
2488
|
const W = p.kts;
|
|
@@ -2505,14 +2505,14 @@ class N {
|
|
|
2505
2505
|
r12sw: null
|
|
2506
2506
|
};
|
|
2507
2507
|
const o = N.estimateWindRadii(W, b), A = {};
|
|
2508
|
-
return ["r7", "r10", "r12"].forEach((
|
|
2509
|
-
const
|
|
2510
|
-
if (
|
|
2511
|
-
A[
|
|
2512
|
-
const e = N.estimateAsymmetricRadii(
|
|
2513
|
-
A[`${
|
|
2508
|
+
return ["r7", "r10", "r12"].forEach((a) => {
|
|
2509
|
+
const Y = o[a];
|
|
2510
|
+
if (Y) {
|
|
2511
|
+
A[a] = Y;
|
|
2512
|
+
const e = N.estimateAsymmetricRadii(Y, (O == null ? void 0 : O.kts) || 0, (O == null ? void 0 : O.deg) || 0, b > 0 ? "N" : "S");
|
|
2513
|
+
A[`${a}ne`] = e.ne, A[`${a}nw`] = e.nw, A[`${a}se`] = e.se, A[`${a}sw`] = e.sw;
|
|
2514
2514
|
} else
|
|
2515
|
-
A[
|
|
2515
|
+
A[a] = null, A[`${a}ne`] = null, A[`${a}nw`] = null, A[`${a}se`] = null, A[`${a}sw`] = null;
|
|
2516
2516
|
}), A;
|
|
2517
2517
|
}
|
|
2518
2518
|
/**
|