@idm-plugin/meteo2 0.7.9 → 0.8.0
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 +471 -455
- package/dist/index.umd.cjs +2 -2
- package/dist/tropicals/src/index.d.ts +19 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import p0 from "@log4js-node/log4js-api";
|
|
|
5
5
|
import L from "moment";
|
|
6
6
|
import Q from "got";
|
|
7
7
|
import { fetchWeatherApi as z0 } from "openmeteo";
|
|
8
|
-
import { Meteo2Assist as
|
|
8
|
+
import { Meteo2Assist as $ } from "@idm-plugin/meteo";
|
|
9
9
|
import u0 from "xml2js";
|
|
10
10
|
import { LaneHelper as d0 } from "@idm-plugin/geo2";
|
|
11
11
|
let s;
|
|
@@ -27,24 +27,24 @@ class Q0 {
|
|
|
27
27
|
*/
|
|
28
28
|
static async queryPointMeteo(M, z, b, p = !1, c = "", W = {}) {
|
|
29
29
|
typeof b == "number" && (b = b < 1e12 ? b * 1e3 : b);
|
|
30
|
-
const
|
|
30
|
+
const O = L(b), o = {
|
|
31
31
|
searchParams: {
|
|
32
32
|
lng: M,
|
|
33
33
|
lat: z,
|
|
34
|
-
ts:
|
|
34
|
+
ts: O.valueOf(),
|
|
35
35
|
params: p ? "watertemp" : void 0,
|
|
36
36
|
source: c == null ? void 0 : c.toLowerCase()
|
|
37
37
|
},
|
|
38
38
|
timeout: 3e4
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
const X = "https://aod4idm.idmwx.com/api/ocean/point",
|
|
42
|
-
if (s == null || s.info("[%s] get meteo(cost: %d ms) from %s with options: %j", W.requestId, f -
|
|
39
|
+
}, q = L(), d = q.valueOf();
|
|
40
|
+
O.isBefore(q.subtract(1, "month")) && (s == null || s.warn("[%s] get history meteo on %s: %j", W.requestId, O.format(), o));
|
|
41
|
+
const X = "https://aod4idm.idmwx.com/api/ocean/point", Y = await Q.get(X, o).json(), f = L().valueOf();
|
|
42
|
+
if (s == null || s.info("[%s] get meteo(cost: %d ms) from %s with options: %j", W.requestId, f - d, X, o), (Y == null ? void 0 : Y.code) === 0)
|
|
43
43
|
return {
|
|
44
|
-
...
|
|
44
|
+
...Y.data,
|
|
45
45
|
source: c
|
|
46
46
|
};
|
|
47
|
-
s == null || s.warn("[%s] get meteo failed: %j", W.requestId,
|
|
47
|
+
s == null || s.warn("[%s] get meteo failed: %j", W.requestId, Y);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* 点查海洋气象要素(指定要素组合)
|
|
@@ -62,24 +62,24 @@ class Q0 {
|
|
|
62
62
|
*/
|
|
63
63
|
static async queryPointFactor(M, z, b, p = "wind,wave,current,watertemp,visibility", c = "", W = {}) {
|
|
64
64
|
typeof b == "number" && (b = b < 1e12 ? b * 1e3 : b);
|
|
65
|
-
const
|
|
65
|
+
const O = L(b), o = {
|
|
66
66
|
searchParams: {
|
|
67
67
|
lng: M,
|
|
68
68
|
lat: z,
|
|
69
|
-
ts:
|
|
69
|
+
ts: O.valueOf(),
|
|
70
70
|
params: p,
|
|
71
71
|
source: c == null ? void 0 : c.toLowerCase()
|
|
72
72
|
},
|
|
73
73
|
timeout: 3e4
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
const X = "https://aod4idm.idmwx.com/api/ocean/factor",
|
|
77
|
-
if (s == null || s.info("[%s] get factors(cost: %d ms) from %s with options: %j", W.requestId, f -
|
|
74
|
+
}, q = L(), d = q.valueOf();
|
|
75
|
+
O.isBefore(q.subtract(1, "month")) && (s == null || s.warn("[%s] get history factors on %s: %j", W.requestId, O.format(), o));
|
|
76
|
+
const X = "https://aod4idm.idmwx.com/api/ocean/factor", Y = await Q.get(X, o).json(), f = L().valueOf();
|
|
77
|
+
if (s == null || s.info("[%s] get factors(cost: %d ms) from %s with options: %j", W.requestId, f - d, X, o), (Y == null ? void 0 : Y.code) === 0)
|
|
78
78
|
return {
|
|
79
|
-
...
|
|
79
|
+
...Y.data,
|
|
80
80
|
source: c
|
|
81
81
|
};
|
|
82
|
-
s == null || s.warn("[%s] get factors failed: %j", W.requestId,
|
|
82
|
+
s == null || s.warn("[%s] get factors failed: %j", W.requestId, Y);
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* @see https://api.windy.com/point-forecast/docs
|
|
@@ -88,7 +88,7 @@ class Q0 {
|
|
|
88
88
|
static async queryWindyPointForecast(M, z, b, p = {}) {
|
|
89
89
|
const c = "https://api.windy.com/api/point-forecast/v2", W = [];
|
|
90
90
|
try {
|
|
91
|
-
let
|
|
91
|
+
let O = L().valueOf();
|
|
92
92
|
const o = await Q.post(c, {
|
|
93
93
|
headers: {
|
|
94
94
|
"Content-Type": "application/json"
|
|
@@ -118,9 +118,9 @@ class Q0 {
|
|
|
118
118
|
levels: ["surface"]
|
|
119
119
|
}
|
|
120
120
|
}).json();
|
|
121
|
-
let
|
|
122
|
-
s == null || s.info("[%s] get gfs-factors(cost: %d ms) from %s", p.requestId,
|
|
123
|
-
const
|
|
121
|
+
let q = L().valueOf();
|
|
122
|
+
s == null || s.info("[%s] get gfs-factors(cost: %d ms) from %s", p.requestId, q - O, c), O = q;
|
|
123
|
+
const d = await Q.post(c, {
|
|
124
124
|
headers: {
|
|
125
125
|
"Content-Type": "application/json"
|
|
126
126
|
},
|
|
@@ -133,36 +133,36 @@ class Q0 {
|
|
|
133
133
|
levels: ["surface"]
|
|
134
134
|
}
|
|
135
135
|
}).json();
|
|
136
|
-
|
|
137
|
-
for (let
|
|
138
|
-
const f = this.populateUVFactor(o["wind_u-surface"][
|
|
136
|
+
q = L().valueOf(), s == null || s.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", p.requestId, q - O, c);
|
|
137
|
+
for (let Y = 0; Y < o.ts.length; Y++) {
|
|
138
|
+
const f = this.populateUVFactor(o["wind_u-surface"][Y], o["wind_v-surface"][Y], !1, p);
|
|
139
139
|
f.scale = this.calculateBeaufortWindForceScale(f.speed), W.push({
|
|
140
|
-
utc: L(o.ts[
|
|
141
|
-
temp: o["temp-surface"][
|
|
142
|
-
dp_temp: o["dewpoint-surface"][
|
|
140
|
+
utc: L(o.ts[Y]).utc().format(),
|
|
141
|
+
temp: o["temp-surface"][Y] ? Math.round((o["temp-surface"][Y] - 273.15) * 100) / 100 : void 0,
|
|
142
|
+
dp_temp: o["dewpoint-surface"][Y] ? Math.round((o["dewpoint-surface"][Y] - 273.15) * 100) / 100 : void 0,
|
|
143
143
|
precip: {
|
|
144
|
-
inter3h: o["past3hprecip-surface"][
|
|
145
|
-
inter3hSnow: o["past3hsnowprecip-surface"][
|
|
146
|
-
inter3hConv: o["past3hconvprecip-surface"][
|
|
144
|
+
inter3h: o["past3hprecip-surface"][Y] ? Math.round(o["past3hprecip-surface"][Y] * 1e3 * 1e3) / 1e3 : 0,
|
|
145
|
+
inter3hSnow: o["past3hsnowprecip-surface"][Y] ? Math.round(o["past3hsnowprecip-surface"][Y] * 1e3 * 1e3) / 1e3 : 0,
|
|
146
|
+
inter3hConv: o["past3hconvprecip-surface"][Y] ? Math.round(o["past3hconvprecip-surface"][Y] * 1e3 * 1e3) / 1e3 : 0
|
|
147
147
|
},
|
|
148
148
|
wind: f,
|
|
149
149
|
gusts: {
|
|
150
|
-
speed: Math.round((o["gust-surface"][
|
|
151
|
-
kts: this.convertMs2Kts(o["gust-surface"][
|
|
150
|
+
speed: Math.round((o["gust-surface"][Y] || 0) * 100) / 100,
|
|
151
|
+
kts: this.convertMs2Kts(o["gust-surface"][Y])
|
|
152
152
|
},
|
|
153
|
-
lclouds: o["lclouds-surface"][
|
|
154
|
-
mclouds: o["mclouds-surface"][
|
|
155
|
-
hclouds: o["hclouds-surface"][
|
|
156
|
-
rh: o["rh-surface"][
|
|
157
|
-
gh: o["gh-surface"][
|
|
158
|
-
pressure: Math.round(o["pressure-surface"][
|
|
153
|
+
lclouds: o["lclouds-surface"][Y] ? Math.round(o["lclouds-surface"][Y] * 100) / 100 : 0,
|
|
154
|
+
mclouds: o["mclouds-surface"][Y] ? Math.round(o["mclouds-surface"][Y] * 100) / 100 : 0,
|
|
155
|
+
hclouds: o["hclouds-surface"][Y] ? Math.round(o["hclouds-surface"][Y] * 100) / 100 : 0,
|
|
156
|
+
rh: o["rh-surface"][Y] ? Math.round(o["rh-surface"][Y] * 100) / 100 : 0,
|
|
157
|
+
gh: o["gh-surface"][Y] ? Math.round(o["gh-surface"][Y] * 100) / 100 : 0,
|
|
158
|
+
pressure: Math.round(o["pressure-surface"][Y] / 100 * 100) / 100
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
const X = [];
|
|
162
|
-
for (let
|
|
163
|
-
const f = this.calculateDouglasScale(
|
|
162
|
+
for (let Y = 0; Y < d.ts.length; Y++) {
|
|
163
|
+
const f = this.calculateDouglasScale(d["waves_height-surface"][Y], d["waves_direction-surface"][Y], d["waves_period-surface"][Y]), e = this.calculateDouglasScale(d["wwaves_height-surface"][Y], d["wwaves_direction-surface"][Y], d["wwaves_period-surface"][Y]), r = this.calculateDouglasScale(d["swell1_height-surface"][Y], d["swell1_direction-surface"][Y], d["swell1_period-surface"][Y]), N = this.calculateDouglasScale(d["swell2_height-surface"][Y], d["swell2_direction-surface"][Y], d["swell2_period-surface"][Y]);
|
|
164
164
|
X.push({
|
|
165
|
-
utc: L(
|
|
165
|
+
utc: L(d.ts[Y]).utc().format(),
|
|
166
166
|
wave: {
|
|
167
167
|
sig: f,
|
|
168
168
|
wd: e,
|
|
@@ -171,12 +171,12 @@ class Q0 {
|
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
-
for (const
|
|
175
|
-
const f = X.find((e) => e.utc ===
|
|
176
|
-
|
|
174
|
+
for (const Y of W) {
|
|
175
|
+
const f = X.find((e) => e.utc === Y.utc);
|
|
176
|
+
Y.wave = f == null ? void 0 : f.wave;
|
|
177
177
|
}
|
|
178
|
-
} catch (
|
|
179
|
-
s.warn("[%s] get-gfs-factor failed: %s", p.requestId,
|
|
178
|
+
} catch (O) {
|
|
179
|
+
s.warn("[%s] get-gfs-factor failed: %s", p.requestId, O);
|
|
180
180
|
}
|
|
181
181
|
return W;
|
|
182
182
|
}
|
|
@@ -188,12 +188,12 @@ class Q0 {
|
|
|
188
188
|
* @param options
|
|
189
189
|
*/
|
|
190
190
|
static populateUVFactor(M, z, b = !1, p = {}) {
|
|
191
|
-
const c = Math.round(Math.sqrt(Math.pow(M, 2) + Math.pow(z, 2)) * 1e4) / 1e4, { degree: W, direction:
|
|
191
|
+
const c = Math.round(Math.sqrt(Math.pow(M, 2) + Math.pow(z, 2)) * 1e4) / 1e4, { degree: W, direction: O } = this.calculateUVDirection(M, z, b, p), o = this.convertMs2Kts(c);
|
|
192
192
|
return {
|
|
193
193
|
speed: c,
|
|
194
194
|
kts: o,
|
|
195
195
|
degree: W,
|
|
196
|
-
direction:
|
|
196
|
+
direction: O,
|
|
197
197
|
eastward: Math.round(M * 1e4) / 1e4,
|
|
198
198
|
northward: Math.round(z * 1e4) / 1e4
|
|
199
199
|
};
|
|
@@ -271,9 +271,9 @@ var a0 = { exports: {} };
|
|
|
271
271
|
throw new RangeError("invalid coordinates");
|
|
272
272
|
if (90 <= z)
|
|
273
273
|
return "Etc/GMT";
|
|
274
|
-
var W = -1,
|
|
274
|
+
var W = -1, O = 48 * (180 + b) / 360.00000000000006, o = 24 * (90 - z) / 180.00000000000003, q = 0 | O, d = 0 | o, X = 96 * d + 2 * q;
|
|
275
275
|
for (X = 56 * p.charCodeAt(X) + p.charCodeAt(X + 1) - 1995; X + c.length < 3136; )
|
|
276
|
-
X = 56 * p.charCodeAt(X = 8 * (W = W + X + 1) + 4 * (
|
|
276
|
+
X = 56 * p.charCodeAt(X = 8 * (W = W + X + 1) + 4 * (d = 0 | (o = 2 * (o - d) % 2)) + 2 * (q = 0 | (O = 2 * (O - q) % 2)) + 2304) + p.charCodeAt(X + 1) - 1995;
|
|
277
277
|
return c[X + c.length - 3136];
|
|
278
278
|
}
|
|
279
279
|
i.exports = M;
|
|
@@ -291,38 +291,38 @@ var n0 = { exports: {} };
|
|
|
291
291
|
i.exports ? i.exports = z(L) : z(M.moment);
|
|
292
292
|
})(B0, function(M) {
|
|
293
293
|
M.version === void 0 && M.default && (M = M.default);
|
|
294
|
-
var z = "0.5.48", b = {}, p = {}, c = {}, W = {},
|
|
294
|
+
var z = "0.5.48", b = {}, p = {}, c = {}, W = {}, O = {}, o;
|
|
295
295
|
(!M || typeof M.version != "string") && v("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
296
|
-
var
|
|
297
|
-
(
|
|
298
|
-
function
|
|
299
|
-
return
|
|
296
|
+
var q = M.version.split("."), d = +q[0], X = +q[1];
|
|
297
|
+
(d < 2 || d === 2 && X < 6) && v("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
|
|
298
|
+
function Y(A) {
|
|
299
|
+
return A > 96 ? A - 87 : A > 64 ? A - 29 : A - 48;
|
|
300
300
|
}
|
|
301
|
-
function f(
|
|
302
|
-
var a = 0, n =
|
|
303
|
-
for (
|
|
304
|
-
|
|
301
|
+
function f(A) {
|
|
302
|
+
var a = 0, n = A.split("."), R = n[0], t = n[1] || "", U = 1, G, V = 0, I = 1;
|
|
303
|
+
for (A.charCodeAt(0) === 45 && (a = 1, I = -1), a; a < R.length; a++)
|
|
304
|
+
G = Y(R.charCodeAt(a)), V = 60 * V + G;
|
|
305
305
|
for (a = 0; a < t.length; a++)
|
|
306
|
-
U = U / 60,
|
|
306
|
+
U = U / 60, G = Y(t.charCodeAt(a)), V += G * U;
|
|
307
307
|
return V * I;
|
|
308
308
|
}
|
|
309
|
-
function e(
|
|
310
|
-
for (var a = 0; a <
|
|
311
|
-
|
|
309
|
+
function e(A) {
|
|
310
|
+
for (var a = 0; a < A.length; a++)
|
|
311
|
+
A[a] = f(A[a]);
|
|
312
312
|
}
|
|
313
|
-
function r(
|
|
313
|
+
function r(A, a) {
|
|
314
314
|
for (var n = 0; n < a; n++)
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
A[n] = Math.round((A[n - 1] || 0) + A[n] * 6e4);
|
|
316
|
+
A[a - 1] = 1 / 0;
|
|
317
317
|
}
|
|
318
|
-
function N(
|
|
318
|
+
function N(A, a) {
|
|
319
319
|
var n = [], R;
|
|
320
320
|
for (R = 0; R < a.length; R++)
|
|
321
|
-
n[R] =
|
|
321
|
+
n[R] = A[a[R]];
|
|
322
322
|
return n;
|
|
323
323
|
}
|
|
324
|
-
function u(
|
|
325
|
-
var a =
|
|
324
|
+
function u(A) {
|
|
325
|
+
var a = A.split("|"), n = a[2].split(" "), R = a[3].split(""), t = a[4].split(" ");
|
|
326
326
|
return e(n), e(R), e(t), r(t, R.length), {
|
|
327
327
|
name: a[0],
|
|
328
328
|
abbrs: N(a[1].split(" "), R),
|
|
@@ -331,94 +331,94 @@ var n0 = { exports: {} };
|
|
|
331
331
|
population: a[5] | 0
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
|
-
function B(
|
|
335
|
-
|
|
334
|
+
function B(A) {
|
|
335
|
+
A && this._set(u(A));
|
|
336
336
|
}
|
|
337
|
-
function S(
|
|
337
|
+
function S(A, a) {
|
|
338
338
|
var n = a.length;
|
|
339
|
-
if (
|
|
339
|
+
if (A < a[0])
|
|
340
340
|
return 0;
|
|
341
|
-
if (n > 1 && a[n - 1] === 1 / 0 &&
|
|
341
|
+
if (n > 1 && a[n - 1] === 1 / 0 && A >= a[n - 2])
|
|
342
342
|
return n - 1;
|
|
343
|
-
if (
|
|
343
|
+
if (A >= a[n - 1])
|
|
344
344
|
return -1;
|
|
345
345
|
for (var R, t = 0, U = n - 1; U - t > 1; )
|
|
346
|
-
R = Math.floor((t + U) / 2), a[R] <=
|
|
346
|
+
R = Math.floor((t + U) / 2), a[R] <= A ? t = R : U = R;
|
|
347
347
|
return U;
|
|
348
348
|
}
|
|
349
349
|
B.prototype = {
|
|
350
|
-
_set: function(
|
|
351
|
-
this.name =
|
|
350
|
+
_set: function(A) {
|
|
351
|
+
this.name = A.name, this.abbrs = A.abbrs, this.untils = A.untils, this.offsets = A.offsets, this.population = A.population;
|
|
352
352
|
},
|
|
353
|
-
_index: function(
|
|
354
|
-
var a = +
|
|
353
|
+
_index: function(A) {
|
|
354
|
+
var a = +A, n = this.untils, R;
|
|
355
355
|
if (R = S(a, n), R >= 0)
|
|
356
356
|
return R;
|
|
357
357
|
},
|
|
358
358
|
countries: function() {
|
|
359
|
-
var
|
|
359
|
+
var A = this.name;
|
|
360
360
|
return Object.keys(c).filter(function(a) {
|
|
361
|
-
return c[a].zones.indexOf(
|
|
361
|
+
return c[a].zones.indexOf(A) !== -1;
|
|
362
362
|
});
|
|
363
363
|
},
|
|
364
|
-
parse: function(
|
|
365
|
-
var a = +
|
|
364
|
+
parse: function(A) {
|
|
365
|
+
var a = +A, n = this.offsets, R = this.untils, t = R.length - 1, U, G, V, I;
|
|
366
366
|
for (I = 0; I < t; I++)
|
|
367
|
-
if (U = n[I],
|
|
367
|
+
if (U = n[I], G = n[I + 1], V = n[I && I - 1], U < G && l.moveAmbiguousForward ? U = G : U > V && l.moveInvalidForward && (U = V), a < R[I] - U * 6e4)
|
|
368
368
|
return n[I];
|
|
369
369
|
return n[t];
|
|
370
370
|
},
|
|
371
|
-
abbr: function(
|
|
372
|
-
return this.abbrs[this._index(
|
|
371
|
+
abbr: function(A) {
|
|
372
|
+
return this.abbrs[this._index(A)];
|
|
373
373
|
},
|
|
374
|
-
offset: function(
|
|
375
|
-
return v("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(
|
|
374
|
+
offset: function(A) {
|
|
375
|
+
return v("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(A)];
|
|
376
376
|
},
|
|
377
|
-
utcOffset: function(
|
|
378
|
-
return this.offsets[this._index(
|
|
377
|
+
utcOffset: function(A) {
|
|
378
|
+
return this.offsets[this._index(A)];
|
|
379
379
|
}
|
|
380
380
|
};
|
|
381
|
-
function m(
|
|
382
|
-
this.name =
|
|
381
|
+
function m(A, a) {
|
|
382
|
+
this.name = A, this.zones = a;
|
|
383
383
|
}
|
|
384
|
-
function
|
|
385
|
-
var a =
|
|
386
|
-
n && n[0] ? (n = n[0].match(/[A-Z]/g), n = n ? n.join("") : void 0) : (n = a.match(/[A-Z]{3,5}/g), n = n ? n[0] : void 0), n === "GMT" && (n = void 0), this.at = +
|
|
384
|
+
function Z(A) {
|
|
385
|
+
var a = A.toTimeString(), n = a.match(/\([a-z ]+\)/i);
|
|
386
|
+
n && n[0] ? (n = n[0].match(/[A-Z]/g), n = n ? n.join("") : void 0) : (n = a.match(/[A-Z]{3,5}/g), n = n ? n[0] : void 0), n === "GMT" && (n = void 0), this.at = +A, this.abbr = n, this.offset = A.getTimezoneOffset();
|
|
387
387
|
}
|
|
388
|
-
function P(
|
|
389
|
-
this.zone =
|
|
388
|
+
function P(A) {
|
|
389
|
+
this.zone = A, this.offsetScore = 0, this.abbrScore = 0;
|
|
390
390
|
}
|
|
391
|
-
P.prototype.scoreOffsetAt = function(
|
|
392
|
-
this.offsetScore += Math.abs(this.zone.utcOffset(
|
|
391
|
+
P.prototype.scoreOffsetAt = function(A) {
|
|
392
|
+
this.offsetScore += Math.abs(this.zone.utcOffset(A.at) - A.offset), this.zone.abbr(A.at).replace(/[^A-Z]/g, "") !== A.abbr && this.abbrScore++;
|
|
393
393
|
};
|
|
394
|
-
function K(
|
|
395
|
-
for (var n, R; R = ((a.at -
|
|
396
|
-
n = new
|
|
397
|
-
return
|
|
394
|
+
function K(A, a) {
|
|
395
|
+
for (var n, R; R = ((a.at - A.at) / 12e4 | 0) * 6e4; )
|
|
396
|
+
n = new Z(new Date(A.at + R)), n.offset === A.offset ? A = n : a = n;
|
|
397
|
+
return A;
|
|
398
398
|
}
|
|
399
399
|
function h() {
|
|
400
|
-
var
|
|
400
|
+
var A = (/* @__PURE__ */ new Date()).getFullYear() - 2, a = new Z(new Date(A, 0, 1)), n = a.offset, R = [a], t, U, G, V;
|
|
401
401
|
for (V = 1; V < 48; V++)
|
|
402
|
-
|
|
402
|
+
G = new Date(A, V, 1).getTimezoneOffset(), G !== n && (U = new Z(new Date(A, V, 1)), t = K(a, U), R.push(t), R.push(new Z(new Date(t.at + 6e4))), a = U, n = G);
|
|
403
403
|
for (V = 0; V < 4; V++)
|
|
404
|
-
R.push(new
|
|
404
|
+
R.push(new Z(new Date(A + V, 0, 1))), R.push(new Z(new Date(A + V, 6, 1)));
|
|
405
405
|
return R;
|
|
406
406
|
}
|
|
407
|
-
function H(
|
|
408
|
-
return
|
|
407
|
+
function H(A, a) {
|
|
408
|
+
return A.offsetScore !== a.offsetScore ? A.offsetScore - a.offsetScore : A.abbrScore !== a.abbrScore ? A.abbrScore - a.abbrScore : A.zone.population !== a.zone.population ? a.zone.population - A.zone.population : a.zone.name.localeCompare(A.zone.name);
|
|
409
409
|
}
|
|
410
|
-
function g(
|
|
410
|
+
function g(A, a) {
|
|
411
411
|
var n, R;
|
|
412
412
|
for (e(a), n = 0; n < a.length; n++)
|
|
413
|
-
R = a[n],
|
|
413
|
+
R = a[n], O[R] = O[R] || {}, O[R][A] = !0;
|
|
414
414
|
}
|
|
415
|
-
function
|
|
416
|
-
var a =
|
|
415
|
+
function C(A) {
|
|
416
|
+
var a = A.length, n = {}, R = [], t = {}, U, G, V, I;
|
|
417
417
|
for (U = 0; U < a; U++)
|
|
418
|
-
if (V =
|
|
419
|
-
I =
|
|
420
|
-
for (
|
|
421
|
-
I.hasOwnProperty(
|
|
418
|
+
if (V = A[U].offset, !t.hasOwnProperty(V)) {
|
|
419
|
+
I = O[V] || {};
|
|
420
|
+
for (G in I)
|
|
421
|
+
I.hasOwnProperty(G) && (n[G] = !0);
|
|
422
422
|
t[V] = !0;
|
|
423
423
|
}
|
|
424
424
|
for (U in n)
|
|
@@ -427,69 +427,69 @@ var n0 = { exports: {} };
|
|
|
427
427
|
}
|
|
428
428
|
function E() {
|
|
429
429
|
try {
|
|
430
|
-
var
|
|
431
|
-
if (
|
|
432
|
-
var a = W[_(
|
|
430
|
+
var A = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
431
|
+
if (A && A.length > 3) {
|
|
432
|
+
var a = W[_(A)];
|
|
433
433
|
if (a)
|
|
434
434
|
return a;
|
|
435
|
-
v("Moment Timezone found " +
|
|
435
|
+
v("Moment Timezone found " + A + " from the Intl api, but did not have that data loaded.");
|
|
436
436
|
}
|
|
437
437
|
} catch {
|
|
438
438
|
}
|
|
439
|
-
var n = h(), R = n.length, t =
|
|
439
|
+
var n = h(), R = n.length, t = C(n), U = [], G, V, I;
|
|
440
440
|
for (V = 0; V < t.length; V++) {
|
|
441
|
-
for (
|
|
442
|
-
|
|
443
|
-
U.push(
|
|
441
|
+
for (G = new P(y(t[V])), I = 0; I < R; I++)
|
|
442
|
+
G.scoreOffsetAt(n[I]);
|
|
443
|
+
U.push(G);
|
|
444
444
|
}
|
|
445
445
|
return U.sort(H), U.length > 0 ? U[0].zone.name : void 0;
|
|
446
446
|
}
|
|
447
|
-
function
|
|
448
|
-
return (!o ||
|
|
447
|
+
function J(A) {
|
|
448
|
+
return (!o || A) && (o = E()), o;
|
|
449
449
|
}
|
|
450
|
-
function _(
|
|
451
|
-
return (
|
|
450
|
+
function _(A) {
|
|
451
|
+
return (A || "").toLowerCase().replace(/\//g, "_");
|
|
452
452
|
}
|
|
453
|
-
function W0(
|
|
453
|
+
function W0(A) {
|
|
454
454
|
var a, n, R, t;
|
|
455
|
-
for (typeof
|
|
456
|
-
R =
|
|
455
|
+
for (typeof A == "string" && (A = [A]), a = 0; a < A.length; a++)
|
|
456
|
+
R = A[a].split("|"), n = R[0], t = _(n), b[t] = A[a], W[t] = n, g(t, R[2].split(" "));
|
|
457
457
|
}
|
|
458
|
-
function y(
|
|
459
|
-
|
|
460
|
-
var n = b[
|
|
461
|
-
return n instanceof B ? n : typeof n == "string" ? (n = new B(n), b[
|
|
458
|
+
function y(A, a) {
|
|
459
|
+
A = _(A);
|
|
460
|
+
var n = b[A], R;
|
|
461
|
+
return n instanceof B ? n : typeof n == "string" ? (n = new B(n), b[A] = n, n) : p[A] && a !== y && (R = y(p[A], y)) ? (n = b[A] = new B(), n._set(R), n.name = W[A], n) : null;
|
|
462
462
|
}
|
|
463
463
|
function L0() {
|
|
464
|
-
var
|
|
465
|
-
for (
|
|
466
|
-
W.hasOwnProperty(
|
|
464
|
+
var A, a = [];
|
|
465
|
+
for (A in W)
|
|
466
|
+
W.hasOwnProperty(A) && (b[A] || b[p[A]]) && W[A] && a.push(W[A]);
|
|
467
467
|
return a.sort();
|
|
468
468
|
}
|
|
469
469
|
function e0() {
|
|
470
470
|
return Object.keys(c);
|
|
471
471
|
}
|
|
472
|
-
function o0(
|
|
472
|
+
function o0(A) {
|
|
473
473
|
var a, n, R, t;
|
|
474
|
-
for (typeof
|
|
475
|
-
n =
|
|
474
|
+
for (typeof A == "string" && (A = [A]), a = 0; a < A.length; a++)
|
|
475
|
+
n = A[a].split("|"), R = _(n[0]), t = _(n[1]), p[R] = t, W[R] = n[0], p[t] = R, W[t] = n[1];
|
|
476
476
|
}
|
|
477
|
-
function T0(
|
|
477
|
+
function T0(A) {
|
|
478
478
|
var a, n, R, t;
|
|
479
|
-
if (!(!
|
|
480
|
-
for (a = 0; a <
|
|
481
|
-
t =
|
|
479
|
+
if (!(!A || !A.length))
|
|
480
|
+
for (a = 0; a < A.length; a++)
|
|
481
|
+
t = A[a].split("|"), n = t[0].toUpperCase(), R = t[1].split(" "), c[n] = new m(
|
|
482
482
|
n,
|
|
483
483
|
R
|
|
484
484
|
);
|
|
485
485
|
}
|
|
486
|
-
function i0(
|
|
487
|
-
return
|
|
486
|
+
function i0(A) {
|
|
487
|
+
return A = A.toUpperCase(), c[A] || null;
|
|
488
488
|
}
|
|
489
|
-
function r0(
|
|
490
|
-
if (
|
|
489
|
+
function r0(A, a) {
|
|
490
|
+
if (A = i0(A), !A)
|
|
491
491
|
return null;
|
|
492
|
-
var n =
|
|
492
|
+
var n = A.zones.sort();
|
|
493
493
|
return a ? n.map(function(R) {
|
|
494
494
|
var t = y(R);
|
|
495
495
|
return {
|
|
@@ -498,62 +498,62 @@ var n0 = { exports: {} };
|
|
|
498
498
|
};
|
|
499
499
|
}) : n;
|
|
500
500
|
}
|
|
501
|
-
function f0(
|
|
502
|
-
W0(
|
|
501
|
+
function f0(A) {
|
|
502
|
+
W0(A.zones), o0(A.links), T0(A.countries), l.dataVersion = A.version;
|
|
503
503
|
}
|
|
504
|
-
function O0(
|
|
505
|
-
return O0.didShowError || (O0.didShowError = !0, v("moment.tz.zoneExists('" +
|
|
504
|
+
function O0(A) {
|
|
505
|
+
return O0.didShowError || (O0.didShowError = !0, v("moment.tz.zoneExists('" + A + "') has been deprecated in favor of !moment.tz.zone('" + A + "')")), !!y(A);
|
|
506
506
|
}
|
|
507
|
-
function A0(
|
|
508
|
-
var a =
|
|
509
|
-
return !!(
|
|
507
|
+
function A0(A) {
|
|
508
|
+
var a = A._f === "X" || A._f === "x";
|
|
509
|
+
return !!(A._a && A._tzm === void 0 && !a);
|
|
510
510
|
}
|
|
511
|
-
function v(
|
|
512
|
-
typeof console < "u" && typeof console.error == "function" && console.error(
|
|
511
|
+
function v(A) {
|
|
512
|
+
typeof console < "u" && typeof console.error == "function" && console.error(A);
|
|
513
513
|
}
|
|
514
|
-
function
|
|
514
|
+
function l(A) {
|
|
515
515
|
var a = Array.prototype.slice.call(arguments, 0, -1), n = arguments[arguments.length - 1], R = M.utc.apply(null, a), t;
|
|
516
|
-
return !M.isMoment(
|
|
516
|
+
return !M.isMoment(A) && A0(R) && (t = y(n)) && R.add(t.parse(R), "minutes"), R.tz(n), R;
|
|
517
517
|
}
|
|
518
|
-
|
|
518
|
+
l.version = z, l.dataVersion = "", l._zones = b, l._links = p, l._names = W, l._countries = c, l.add = W0, l.link = o0, l.load = f0, l.zone = y, l.zoneExists = O0, l.guess = J, l.names = L0, l.Zone = B, l.unpack = u, l.unpackBase60 = f, l.needsOffset = A0, l.moveInvalidForward = !0, l.moveAmbiguousForward = !1, l.countries = e0, l.zonesForCountry = r0;
|
|
519
519
|
var w = M.fn;
|
|
520
|
-
M.tz =
|
|
520
|
+
M.tz = l, M.defaultZone = null, M.updateOffset = function(A, a) {
|
|
521
521
|
var n = M.defaultZone, R;
|
|
522
|
-
if (
|
|
523
|
-
if (R =
|
|
524
|
-
var t =
|
|
525
|
-
|
|
522
|
+
if (A._z === void 0 && (n && A0(A) && !A._isUTC && A.isValid() && (A._d = M.utc(A._a)._d, A.utc().add(n.parse(A), "minutes")), A._z = n), A._z)
|
|
523
|
+
if (R = A._z.utcOffset(A), Math.abs(R) < 16 && (R = R / 60), A.utcOffset !== void 0) {
|
|
524
|
+
var t = A._z;
|
|
525
|
+
A.utcOffset(-R, a), A._z = t;
|
|
526
526
|
} else
|
|
527
|
-
|
|
528
|
-
}, w.tz = function(
|
|
529
|
-
if (
|
|
530
|
-
if (typeof
|
|
531
|
-
throw new Error("Time zone name must be a string, got " +
|
|
532
|
-
return this._z = y(
|
|
527
|
+
A.zone(R, a);
|
|
528
|
+
}, w.tz = function(A, a) {
|
|
529
|
+
if (A) {
|
|
530
|
+
if (typeof A != "string")
|
|
531
|
+
throw new Error("Time zone name must be a string, got " + A + " [" + typeof A + "]");
|
|
532
|
+
return this._z = y(A), this._z ? M.updateOffset(this, a) : v("Moment Timezone has no data for " + A + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
|
|
533
533
|
}
|
|
534
534
|
if (this._z)
|
|
535
535
|
return this._z.name;
|
|
536
536
|
};
|
|
537
|
-
function q0(
|
|
537
|
+
function q0(A) {
|
|
538
538
|
return function() {
|
|
539
|
-
return this._z ? this._z.abbr(this) :
|
|
539
|
+
return this._z ? this._z.abbr(this) : A.call(this);
|
|
540
540
|
};
|
|
541
541
|
}
|
|
542
|
-
function Y0(
|
|
542
|
+
function Y0(A) {
|
|
543
543
|
return function() {
|
|
544
|
-
return this._z = null,
|
|
544
|
+
return this._z = null, A.apply(this, arguments);
|
|
545
545
|
};
|
|
546
546
|
}
|
|
547
|
-
function N0(
|
|
547
|
+
function N0(A) {
|
|
548
548
|
return function() {
|
|
549
|
-
return arguments.length > 0 && (this._z = null),
|
|
549
|
+
return arguments.length > 0 && (this._z = null), A.apply(this, arguments);
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
|
-
w.zoneName = q0(w.zoneName), w.zoneAbbr = q0(w.zoneAbbr), w.utc = Y0(w.utc), w.local = Y0(w.local), w.utcOffset = N0(w.utcOffset), M.tz.setDefault = function(
|
|
553
|
-
return (
|
|
552
|
+
w.zoneName = q0(w.zoneName), w.zoneAbbr = q0(w.zoneAbbr), w.utc = Y0(w.utc), w.local = Y0(w.local), w.utcOffset = N0(w.utcOffset), M.tz.setDefault = function(A) {
|
|
553
|
+
return (d < 2 || d === 2 && X < 9) && v("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = A ? y(A) : null, M;
|
|
554
554
|
};
|
|
555
|
-
var
|
|
556
|
-
return Object.prototype.toString.call(
|
|
555
|
+
var M0 = M.momentProperties;
|
|
556
|
+
return Object.prototype.toString.call(M0) === "[object Array]" ? (M0.push("_z"), M0.push("_a")) : M0 && (M0._z = null), M;
|
|
557
557
|
});
|
|
558
558
|
})(n0);
|
|
559
559
|
var Z0 = n0.exports;
|
|
@@ -1418,7 +1418,7 @@ try {
|
|
|
1418
1418
|
} catch {
|
|
1419
1419
|
} finally {
|
|
1420
1420
|
}
|
|
1421
|
-
class
|
|
1421
|
+
class k0 {
|
|
1422
1422
|
constructor(M, z) {
|
|
1423
1423
|
F(this, "apikey");
|
|
1424
1424
|
F(this, "debug");
|
|
@@ -1468,13 +1468,13 @@ class J0 {
|
|
|
1468
1468
|
this.apikey = M || "smE3JnDLHy3TizVv", this.debug = z;
|
|
1469
1469
|
}
|
|
1470
1470
|
async standardWeatherModels() {
|
|
1471
|
-
return
|
|
1471
|
+
return $.standardWeatherModels();
|
|
1472
1472
|
}
|
|
1473
1473
|
async standardMarineModels() {
|
|
1474
|
-
return
|
|
1474
|
+
return $.standardMarineModels();
|
|
1475
1475
|
}
|
|
1476
1476
|
async autoPickMeteoModel(M = "best_match") {
|
|
1477
|
-
return
|
|
1477
|
+
return $.autoPickMeteoModel(M);
|
|
1478
1478
|
}
|
|
1479
1479
|
range(M, z, b) {
|
|
1480
1480
|
return Array.from({ length: (z - M) / b }, (p, c) => M + c * b);
|
|
@@ -1491,15 +1491,15 @@ class J0 {
|
|
|
1491
1491
|
if (M.start_dates instanceof Array)
|
|
1492
1492
|
for (let W = 0; W < M.start_dates.length; W++) {
|
|
1493
1493
|
M.start_date = M.start_dates[W], M.end_date = M.end_dates[W], M.fake = M.fakes[W];
|
|
1494
|
-
const
|
|
1495
|
-
this.debug && D.debug("[%s] fetch weather via %s with %j", z.requestId,
|
|
1494
|
+
const O = M.url[W];
|
|
1495
|
+
this.debug && D.debug("[%s] fetch weather via %s with %j", z.requestId, O, {
|
|
1496
1496
|
start_date: M.start_date,
|
|
1497
1497
|
end_date: M.end_date,
|
|
1498
1498
|
fake: M.fake,
|
|
1499
1499
|
step: W
|
|
1500
1500
|
});
|
|
1501
|
-
const o = await z0(
|
|
1502
|
-
p ? await this.mergeSegments(p,
|
|
1501
|
+
const o = await z0(O, M), q = await this.parseWeatherData(o, M, z);
|
|
1502
|
+
p ? await this.mergeSegments(p, q) : p = q;
|
|
1503
1503
|
}
|
|
1504
1504
|
else {
|
|
1505
1505
|
const W = await z0(M.url, M);
|
|
@@ -1529,10 +1529,10 @@ class J0 {
|
|
|
1529
1529
|
* @param options
|
|
1530
1530
|
*/
|
|
1531
1531
|
async marineForecast(M, z = {}) {
|
|
1532
|
-
var b, p, c, W,
|
|
1532
|
+
var b, p, c, W, O, o, q, d;
|
|
1533
1533
|
try {
|
|
1534
1534
|
const X = L();
|
|
1535
|
-
let
|
|
1535
|
+
let Y;
|
|
1536
1536
|
if (M.start_dates instanceof Array)
|
|
1537
1537
|
for (let S = 0; S < M.start_dates.length; S++) {
|
|
1538
1538
|
M.start_date = M.start_dates[S], M.end_date = M.end_dates[S], M.fake = M.fakes[S];
|
|
@@ -1543,18 +1543,18 @@ class J0 {
|
|
|
1543
1543
|
fake: M.fake,
|
|
1544
1544
|
step: S
|
|
1545
1545
|
});
|
|
1546
|
-
const
|
|
1547
|
-
|
|
1546
|
+
const Z = await z0(m, M), P = await this.parseWeatherData(Z, M, z);
|
|
1547
|
+
Y ? await this.mergeSegments(Y, P) : Y = P;
|
|
1548
1548
|
}
|
|
1549
1549
|
else {
|
|
1550
1550
|
const S = await z0(M.url, M);
|
|
1551
|
-
|
|
1551
|
+
Y = await this.parseWeatherData(S, M, z);
|
|
1552
1552
|
}
|
|
1553
1553
|
delete M.apikey;
|
|
1554
1554
|
const f = L();
|
|
1555
1555
|
this.debug && D.info("[%s] fetch marine api (%j) cost: %d ms", z.requestId, M.url, f.diff(X, "ms"));
|
|
1556
|
-
const e = await this.mergeMarineData(
|
|
1557
|
-
return (p = (b = B == null ? void 0 : B.hourly) == null ? void 0 : b.wave_height) != null && p.every((S) => S !== null) ? [B] : (W = (c = u == null ? void 0 : u.hourly) == null ? void 0 : c.wave_height) != null && W.every((S) => S !== null) ? [u] : (o = (
|
|
1556
|
+
const e = await this.mergeMarineData(Y), r = e.find((S) => S.model === "ncep_gfswave016"), N = e.find((S) => S.model === "ncep_gfswave025"), u = e.find((S) => S.model === "meteofrance_wave"), B = e.find((S) => S.model === "best_match");
|
|
1557
|
+
return (p = (b = B == null ? void 0 : B.hourly) == null ? void 0 : b.wave_height) != null && p.every((S) => S !== null) ? [B] : (W = (c = u == null ? void 0 : u.hourly) == null ? void 0 : c.wave_height) != null && W.every((S) => S !== null) ? [u] : (o = (O = r == null ? void 0 : r.hourly) == null ? void 0 : O.wave_height) != null && o.every((S) => S !== null) ? [r] : (d = (q = N == null ? void 0 : N.hourly) == null ? void 0 : q.wave_height) != null && d.every((S) => S !== null) ? [N] : e != null && e.length ? [e[0]] : [];
|
|
1558
1558
|
} catch (X) {
|
|
1559
1559
|
return D.warn("[%s] marine forecast failed: %s, with %j", z.requestId, X, M), [];
|
|
1560
1560
|
}
|
|
@@ -1567,36 +1567,36 @@ class J0 {
|
|
|
1567
1567
|
* @private
|
|
1568
1568
|
*/
|
|
1569
1569
|
async parseWeatherData(M, z, b = {}) {
|
|
1570
|
-
var W,
|
|
1570
|
+
var W, O, o, q, d, X, Y, f, e, r;
|
|
1571
1571
|
const p = [], c = Math.pow(10, b.precision || 6);
|
|
1572
1572
|
for (let N = 0; N < M.length; N++) {
|
|
1573
|
-
const u = M[N], B = u.utcOffsetSeconds(), S = u.timezone(), m = u.current(),
|
|
1573
|
+
const u = M[N], B = u.utcOffsetSeconds(), S = u.timezone(), m = u.current(), Z = u.hourly(), P = u.sixHourly(), K = u.daily(), h = {};
|
|
1574
1574
|
if (h.timezone = S || void 0, h.offset = this.prettyTimezoneOffset(B), h.model = z.models instanceof Array ? (W = z.models) == null ? void 0 : W[N] : z.models || "best_match", m) {
|
|
1575
1575
|
const H = L();
|
|
1576
1576
|
h.current = {
|
|
1577
1577
|
time: L.unix(Number(m.time())).utc().format()
|
|
1578
1578
|
};
|
|
1579
|
-
for (let
|
|
1580
|
-
const E = m.variables(
|
|
1581
|
-
h.current[z.current[
|
|
1579
|
+
for (let C = 0; C < m.variablesLength(); C++) {
|
|
1580
|
+
const E = m.variables(C).value();
|
|
1581
|
+
h.current[z.current[C]] = isNaN(E) ? null : Math.round(E * c) / c;
|
|
1582
1582
|
}
|
|
1583
1583
|
const g = L();
|
|
1584
1584
|
this.debug && D.debug("[%s] fetch current variables cost: %d ms", b.requestId, g.diff(H, "ms"));
|
|
1585
1585
|
}
|
|
1586
|
-
if (
|
|
1587
|
-
const H = L(), g = L.unix(Number(
|
|
1586
|
+
if (Z) {
|
|
1587
|
+
const H = L(), g = L.unix(Number(Z.time())).add(z.fake ? 1 : 0, "year");
|
|
1588
1588
|
h.hourly = {
|
|
1589
1589
|
date: g.utc().format(),
|
|
1590
|
-
time: this.range(Number(
|
|
1590
|
+
time: this.range(Number(Z.time()), Number(Z.timeEnd()), Z.interval()).map(
|
|
1591
1591
|
(E) => L.unix(E).add(z.fake ? 1 : 0, "year").diff(g, "h")
|
|
1592
1592
|
)
|
|
1593
1593
|
};
|
|
1594
|
-
for (let E = 0; E <
|
|
1595
|
-
const
|
|
1596
|
-
h.hourly[z.hourly[E]] =
|
|
1594
|
+
for (let E = 0; E < Z.variablesLength(); E++) {
|
|
1595
|
+
const J = (q = (o = (O = Z.variables(E).valuesArray()) == null ? void 0 : O.toString()) == null ? void 0 : o.split(",")) == null ? void 0 : q.map((_) => isNaN(_) ? null : Math.round(Number(_) * c) / c);
|
|
1596
|
+
h.hourly[z.hourly[E]] = J;
|
|
1597
1597
|
}
|
|
1598
|
-
const
|
|
1599
|
-
this.debug && D.debug("[%s] fetch hourly variables cost: %d ms", b.requestId,
|
|
1598
|
+
const C = L();
|
|
1599
|
+
this.debug && D.debug("[%s] fetch hourly variables cost: %d ms", b.requestId, C.diff(H, "ms"));
|
|
1600
1600
|
}
|
|
1601
1601
|
if (P) {
|
|
1602
1602
|
const H = L(), g = L.unix(Number(P.time())).add(z.fake ? 1 : 0, "year");
|
|
@@ -1607,22 +1607,22 @@ class J0 {
|
|
|
1607
1607
|
)
|
|
1608
1608
|
};
|
|
1609
1609
|
for (let E = 0; E < P.variablesLength(); E += b.memberLength ?? 1) {
|
|
1610
|
-
const
|
|
1611
|
-
P.variables(E), h.sixHourly[z.six_hourly[E / (b.memberLength ?? 1)]] =
|
|
1610
|
+
const J = (Y = (X = (d = P.variables(E).valuesArray()) == null ? void 0 : d.toString()) == null ? void 0 : X.split(",")) == null ? void 0 : Y.map((_) => isNaN(_) ? null : Math.round(Number(_) * c) / c);
|
|
1611
|
+
P.variables(E), h.sixHourly[z.six_hourly[E / (b.memberLength ?? 1)]] = J;
|
|
1612
1612
|
}
|
|
1613
|
-
const
|
|
1614
|
-
this.debug && D.debug("[%s] fetch 6-hourly variables cost: %d ms", b.requestId,
|
|
1613
|
+
const C = L();
|
|
1614
|
+
this.debug && D.debug("[%s] fetch 6-hourly variables cost: %d ms", b.requestId, C.diff(H, "ms"));
|
|
1615
1615
|
}
|
|
1616
1616
|
if (K) {
|
|
1617
1617
|
const H = L();
|
|
1618
1618
|
h.daily = {
|
|
1619
1619
|
time: this.range(Number(K.time()), Number(K.timeEnd()), K.interval()).map(
|
|
1620
|
-
(
|
|
1620
|
+
(C) => L.unix(C).add(z.fake ? 1 : 0, "year").utc().format()
|
|
1621
1621
|
)
|
|
1622
1622
|
};
|
|
1623
|
-
for (let
|
|
1624
|
-
const E = (r = (e = (f = K.variables(
|
|
1625
|
-
h.daily[z.daily[
|
|
1623
|
+
for (let C = 0; C < K.variablesLength(); C += b.memberLength ?? 1) {
|
|
1624
|
+
const E = (r = (e = (f = K.variables(C).valuesArray()) == null ? void 0 : f.toString()) == null ? void 0 : e.split(",")) == null ? void 0 : r.map((J) => isNaN(J) ? null : Math.round(Number(J) * c) / c);
|
|
1625
|
+
h.daily[z.daily[C / (b.memberLength ?? 1)]] = E;
|
|
1626
1626
|
}
|
|
1627
1627
|
const g = L();
|
|
1628
1628
|
this.debug && D.debug("[%s] fetch daily variables cost: %d ms", b.requestId, g.diff(H, "ms"));
|
|
@@ -1643,10 +1643,10 @@ class J0 {
|
|
|
1643
1643
|
for (let W = M[b][p][c].length; W < z[b][p][c].length; W++)
|
|
1644
1644
|
M[b][p][c].push(z[b][p][c][W]);
|
|
1645
1645
|
} else {
|
|
1646
|
-
const W = L(z[b][p].date),
|
|
1646
|
+
const W = L(z[b][p].date), O = L(M[b][p].date);
|
|
1647
1647
|
for (let o = 0; o < z[b][p][c].length; o++) {
|
|
1648
|
-
const
|
|
1649
|
-
|
|
1648
|
+
const q = W.clone().add(o, "h").diff(O, "h");
|
|
1649
|
+
q < M[b][p][c].length ? M[b][p][c][q] === null && (M[b][p][c][q] = z[b][p][c][o]) : c === "time" ? M[b][p][c].push(q) : M[b][p][c].push(z[b][p][c][o]);
|
|
1650
1650
|
}
|
|
1651
1651
|
}
|
|
1652
1652
|
} else if (p === "daily") {
|
|
@@ -1660,12 +1660,12 @@ class J0 {
|
|
|
1660
1660
|
return M;
|
|
1661
1661
|
}
|
|
1662
1662
|
async mergeMarineData(M) {
|
|
1663
|
-
var c, W,
|
|
1664
|
-
const z = [], b = M.find((
|
|
1663
|
+
var c, W, O, o;
|
|
1664
|
+
const z = [], b = M.find((q) => q.model === "best_match");
|
|
1665
1665
|
b && z.push(b);
|
|
1666
|
-
const p = M.find((
|
|
1667
|
-
for (const
|
|
1668
|
-
["best_match", "meteofrance_currents"].includes(
|
|
1666
|
+
const p = M.find((q) => q.model === "meteofrance_currents");
|
|
1667
|
+
for (const q of M)
|
|
1668
|
+
["best_match", "meteofrance_currents"].includes(q.model) || (q.hourly.ocean_current_velocity = (c = p == null ? void 0 : p.hourly) == null ? void 0 : c.ocean_current_velocity, q.hourly.ocean_current_direction = (W = p == null ? void 0 : p.hourly) == null ? void 0 : W.ocean_current_direction, q.hourly.sea_level_height_msl = (O = p == null ? void 0 : p.hourly) == null ? void 0 : O.sea_level_height_msl, q.hourly.sea_surface_temperature = (o = p == null ? void 0 : p.hourly) == null ? void 0 : o.sea_surface_temperature, z.push(q));
|
|
1669
1669
|
return z;
|
|
1670
1670
|
}
|
|
1671
1671
|
pickForecastUrl(M, z, b, p = {}) {
|
|
@@ -1677,14 +1677,14 @@ class J0 {
|
|
|
1677
1677
|
if (!(z != null && z.length))
|
|
1678
1678
|
return ["best_match"];
|
|
1679
1679
|
const b = [];
|
|
1680
|
-
for (let
|
|
1681
|
-
const o = z[
|
|
1680
|
+
for (let O = 0; O < z.length; O++) {
|
|
1681
|
+
const o = z[O];
|
|
1682
1682
|
["ecmwf_wam025", "meteofrance_wave", "ewam", "gwam", "era5_ocean"].includes(o) ? b.push("meteofrance_currents", o) : ["gfswave", "ncep_gfswave025", "ncep_gfswave016"].includes(o) ? b.push("meteofrance_currents", "ncep_gfswave025", "ncep_gfswave016") : b.push("best_match");
|
|
1683
1683
|
}
|
|
1684
|
-
const p = b.reduce((
|
|
1685
|
-
return p.sort((
|
|
1686
|
-
const
|
|
1687
|
-
return
|
|
1684
|
+
const p = b.reduce((O, o) => (O.includes(o) || O.push(o), O), []), c = ["best_match", "meteofrance_currents", "meteofrance_wave", "ecmwf_wam025", "ncep_gfswave025", "gwam", "era5_ocean", "ewam", "ncep_gfswave016"];
|
|
1685
|
+
return p.sort((O, o) => {
|
|
1686
|
+
const q = c.indexOf(O), d = c.indexOf(o);
|
|
1687
|
+
return q - d;
|
|
1688
1688
|
}), p;
|
|
1689
1689
|
}
|
|
1690
1690
|
/**
|
|
@@ -1696,8 +1696,8 @@ class J0 {
|
|
|
1696
1696
|
* @private
|
|
1697
1697
|
*/
|
|
1698
1698
|
async prepare(M, z, b, p = {}) {
|
|
1699
|
-
var
|
|
1700
|
-
const c = L.utc(), W = M ? L.utc(M) : void 0,
|
|
1699
|
+
var q, d;
|
|
1700
|
+
const c = L.utc(), W = M ? L.utc(M) : void 0, O = z ? await this.pickUpdateMeta(b.models) : [], o = (d = (q = O[0]) == null ? void 0 : q.meta) != null && d.endTime ? L(O[0].meta.endTime) : c.clone().add(14, "day");
|
|
1701
1701
|
if (M) {
|
|
1702
1702
|
const X = W.clone().utc().add(p.forecastDays ?? 1, "day");
|
|
1703
1703
|
X.isAfter(o) ? (X.subtract(1, "year"), W.isAfter(o) ? (W.subtract(1, "year"), b.start_dates = [
|
|
@@ -1760,38 +1760,38 @@ class J0 {
|
|
|
1760
1760
|
* @param withHourly
|
|
1761
1761
|
* @param options
|
|
1762
1762
|
*/
|
|
1763
|
-
async spotForecast(M, z, b, p = !0, c = !0, W = !1,
|
|
1763
|
+
async spotForecast(M, z, b, p = !0, c = !0, W = !1, O = {
|
|
1764
1764
|
forecastDays: 1,
|
|
1765
1765
|
pastDays: 0,
|
|
1766
1766
|
precision: 6,
|
|
1767
1767
|
selfHosted: !0
|
|
1768
1768
|
}) {
|
|
1769
1769
|
var e, r, N, u, B, S;
|
|
1770
|
-
z = this.toStdLng(z), this.debug && D.info("[%s] spot forecast params: %j",
|
|
1770
|
+
z = this.toStdLng(z), this.debug && D.info("[%s] spot forecast params: %j", O.requestId, { lat: M, lng: z, datetime: b, simplify: p, withDaily: c, withHourly: W, options: O });
|
|
1771
1771
|
const o = {
|
|
1772
1772
|
apikey: this.apikey,
|
|
1773
1773
|
latitude: M,
|
|
1774
1774
|
longitude: z,
|
|
1775
1775
|
cell_selection: "sea",
|
|
1776
1776
|
wind_speed_unit: "kn",
|
|
1777
|
-
models: ((e =
|
|
1777
|
+
models: ((e = O.weatherModels) == null ? void 0 : e.split(",")) || ["best_match"],
|
|
1778
1778
|
timezone: "auto"
|
|
1779
1779
|
};
|
|
1780
|
-
let
|
|
1781
|
-
const
|
|
1782
|
-
b && (
|
|
1783
|
-
const X = await this.weatherForecast(o,
|
|
1780
|
+
let q;
|
|
1781
|
+
const d = this.timezoneOffset(M, z);
|
|
1782
|
+
b && (q = L.utc(b).utcOffset(d), q.subtract(d > 0 ? d : -d, "h"), O.selfHistory = !(q != null && q.isBefore(L.utc().subtract(120, "days")))), c && (o.daily = ((r = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : r.split(",")) || []), q || (O.forecastDays = O.forecastDays || 1, O.pastDays = 0, W = !0), W && (o.hourly = ((N = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : N.split(",")) || []), 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 > 14 ? 14 : O.forecastDays < 0 ? 1 : O.forecastDays, await this.prepare(q == null ? void 0 : q.utc().format(), !1, o, O);
|
|
1783
|
+
const X = await this.weatherForecast(o, O), Y = {
|
|
1784
1784
|
apikey: this.apikey,
|
|
1785
1785
|
latitude: M,
|
|
1786
1786
|
longitude: z,
|
|
1787
1787
|
cell_selection: "sea",
|
|
1788
1788
|
timezone: "auto",
|
|
1789
1789
|
wind_speed_unit: "kn",
|
|
1790
|
-
models: this.pickMarineModels(
|
|
1790
|
+
models: this.pickMarineModels(O.marineModels)
|
|
1791
1791
|
};
|
|
1792
|
-
c && (
|
|
1793
|
-
let f = await this.marineForecast(
|
|
1794
|
-
return (S = (B = (u = f[0]) == null ? void 0 : u.hourly) == null ? void 0 : B.wave_height) != null && S.every((m) => m === null || m === 0) && (
|
|
1792
|
+
c && (Y.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), q || (O.forecastDays = O.forecastDays || 1, W = !0), W && (Y.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), await this.prepare(q == null ? void 0 : q.utc().format(), !0, Y, O);
|
|
1793
|
+
let f = await this.marineForecast(Y, O);
|
|
1794
|
+
return (S = (B = (u = f[0]) == null ? void 0 : u.hourly) == null ? void 0 : B.wave_height) != null && S.every((m) => m === null || m === 0) && (Y.models = this.pickMarineModels("best_match,ncep_gfswave025,meteofrance_wave"), f = await this.marineForecast(Y, O)), { weather: X, marine: f };
|
|
1795
1795
|
}
|
|
1796
1796
|
/**
|
|
1797
1797
|
* 历史再分析数据
|
|
@@ -1814,14 +1814,14 @@ class J0 {
|
|
|
1814
1814
|
* @param withMarine
|
|
1815
1815
|
* @param options
|
|
1816
1816
|
*/
|
|
1817
|
-
async spotHistorical(M, z, b, p, c = !0, W = !0,
|
|
1817
|
+
async spotHistorical(M, z, b, p, c = !0, W = !0, O = !1, o = {
|
|
1818
1818
|
precision: 6
|
|
1819
1819
|
}) {
|
|
1820
1820
|
var r, N;
|
|
1821
|
-
z = this.toStdLng(z), this.debug && D.info("[%s] spot historical params: %j", o.requestId, { lat: M, lng: z, startDate: b, endDate: p, withMarine:
|
|
1822
|
-
const
|
|
1823
|
-
|
|
1824
|
-
const
|
|
1821
|
+
z = this.toStdLng(z), this.debug && D.info("[%s] spot historical params: %j", o.requestId, { lat: M, lng: z, startDate: b, endDate: p, withMarine: O, options: o });
|
|
1822
|
+
const q = this.timezoneOffset(M, z), d = L.utc(b).utcOffset(q), X = L.utc(p).utcOffset(q);
|
|
1823
|
+
d.subtract(q > 0 ? q : -q, "h"), X.subtract(q > 0 ? q : -q, "h");
|
|
1824
|
+
const Y = {
|
|
1825
1825
|
apikey: this.apikey,
|
|
1826
1826
|
latitude: M,
|
|
1827
1827
|
longitude: z,
|
|
@@ -1830,13 +1830,13 @@ class J0 {
|
|
|
1830
1830
|
models: ((r = o.weatherModels) == null ? void 0 : r.split(",")) || ["best_match"],
|
|
1831
1831
|
timezone: "auto",
|
|
1832
1832
|
url: this.HISTORICAL.OM_URL,
|
|
1833
|
-
start_date:
|
|
1833
|
+
start_date: d.format("YYYY-MM-DD"),
|
|
1834
1834
|
end_date: X.format("YYYY-MM-DD")
|
|
1835
1835
|
};
|
|
1836
|
-
c && (
|
|
1837
|
-
const f = await this.weatherForecast(
|
|
1836
|
+
c && (Y.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), W && (Y.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
|
|
1837
|
+
const f = await this.weatherForecast(Y, o);
|
|
1838
1838
|
let e;
|
|
1839
|
-
if (
|
|
1839
|
+
if (O) {
|
|
1840
1840
|
const u = {
|
|
1841
1841
|
apikey: this.apikey,
|
|
1842
1842
|
latitude: M,
|
|
@@ -1848,7 +1848,7 @@ class J0 {
|
|
|
1848
1848
|
daily: this.FORECAST.MARINE_VARIABLES.DAILY.split(","),
|
|
1849
1849
|
hourly: this.FORECAST.MARINE_VARIABLES.HOURLY.split(","),
|
|
1850
1850
|
url: this.FORECAST.OM_MARINE_URL,
|
|
1851
|
-
start_date:
|
|
1851
|
+
start_date: d.format("YYYY-MM-DD"),
|
|
1852
1852
|
end_date: X.format("YYYY-MM-DD")
|
|
1853
1853
|
};
|
|
1854
1854
|
e = await this.marineForecast(u, o);
|
|
@@ -1870,9 +1870,9 @@ class J0 {
|
|
|
1870
1870
|
precision: 6
|
|
1871
1871
|
}) {
|
|
1872
1872
|
z = this.toStdLng(z), this.debug && D.info("[%s] spot seasonal params: %j", W.requestId, { lat: M, lng: z, startDate: b, endDate: p, options: W });
|
|
1873
|
-
const
|
|
1874
|
-
o.subtract(
|
|
1875
|
-
const
|
|
1873
|
+
const O = this.timezoneOffset(M, z), o = L.utc(b).utcOffset(O), q = p ? L.utc(p).utcOffset(O) : o.clone().add(1, "month");
|
|
1874
|
+
o.subtract(O > 0 ? O : -O, "h"), q.subtract(O > 0 ? O : -O, "h");
|
|
1875
|
+
const d = {
|
|
1876
1876
|
apikey: this.apikey,
|
|
1877
1877
|
latitude: M,
|
|
1878
1878
|
longitude: z,
|
|
@@ -1881,10 +1881,10 @@ class J0 {
|
|
|
1881
1881
|
timezone: "auto",
|
|
1882
1882
|
url: this.SEASONAL.OM_URL,
|
|
1883
1883
|
start_date: o.format("YYYY-MM-DD"),
|
|
1884
|
-
end_date:
|
|
1884
|
+
end_date: q.format("YYYY-MM-DD"),
|
|
1885
1885
|
daily: this.SEASONAL.WEATHER_VARIABLES.DAILY.split(",")
|
|
1886
1886
|
};
|
|
1887
|
-
return c && (
|
|
1887
|
+
return c && (d.six_hourly = this.SEASONAL.WEATHER_VARIABLES.SIX_HOURLY.split(",")), W.memberLength = 4, { weather: await this.weatherForecast(d, W) };
|
|
1888
1888
|
}
|
|
1889
1889
|
/**
|
|
1890
1890
|
* 气候态数据
|
|
@@ -1911,9 +1911,9 @@ class J0 {
|
|
|
1911
1911
|
}) {
|
|
1912
1912
|
var X;
|
|
1913
1913
|
z = this.toStdLng(z), this.debug && D.info("[%s] spot climate params: %j", c.requestId, { lat: M, lng: z, startDate: b, endDate: p, options: c });
|
|
1914
|
-
const W = this.timezoneOffset(M, z),
|
|
1915
|
-
o.subtract(W > 0 ? W : -W, "h"),
|
|
1916
|
-
const
|
|
1914
|
+
const W = this.timezoneOffset(M, z), O = L.utc(b).utcOffset(W), o = p ? L.utc(p).utcOffset(W) : O.clone().add(1, "day");
|
|
1915
|
+
o.subtract(W > 0 ? W : -W, "h"), O.subtract(W > 0 ? W : -W, "h");
|
|
1916
|
+
const q = {
|
|
1917
1917
|
apikey: this.apikey,
|
|
1918
1918
|
latitude: M,
|
|
1919
1919
|
longitude: z,
|
|
@@ -1922,11 +1922,11 @@ class J0 {
|
|
|
1922
1922
|
models: ((X = c.weatherModels) == null ? void 0 : X.split(",")) || "EC_Earth3P_HR",
|
|
1923
1923
|
timezone: "auto",
|
|
1924
1924
|
url: this.CLIMATE.OM_URL,
|
|
1925
|
-
start_date:
|
|
1925
|
+
start_date: O.format("YYYY-MM-DD"),
|
|
1926
1926
|
end_date: o.format("YYYY-MM-DD"),
|
|
1927
1927
|
daily: this.CLIMATE.WEATHER_VARIABLES.DAILY.split(",")
|
|
1928
1928
|
};
|
|
1929
|
-
return { weather: await this.weatherForecast(
|
|
1929
|
+
return { weather: await this.weatherForecast(q, c) };
|
|
1930
1930
|
}
|
|
1931
1931
|
async update(M = {}) {
|
|
1932
1932
|
const z = L.unix(this.METEO2_UPDATE.etime), b = this.METEO2_UPDATE.version, p = L();
|
|
@@ -1938,12 +1938,12 @@ class J0 {
|
|
|
1938
1938
|
}
|
|
1939
1939
|
});
|
|
1940
1940
|
try {
|
|
1941
|
-
const
|
|
1942
|
-
if (
|
|
1943
|
-
const o =
|
|
1944
|
-
for (const
|
|
1945
|
-
const X =
|
|
1946
|
-
var B, S, m,
|
|
1941
|
+
const O = await W.json();
|
|
1942
|
+
if (O.code === 0) {
|
|
1943
|
+
const o = O.data, q = $.standardWeatherModels();
|
|
1944
|
+
for (const d of q) {
|
|
1945
|
+
const X = $.autoPickSubCategories(d.alias), f = o.filter((e) => X.includes(e.category)).map((e) => {
|
|
1946
|
+
var B, S, m, Z, P, K;
|
|
1947
1947
|
const r = L.unix((B = e.meta) == null ? void 0 : B.data_end_time).utc(), N = L.unix((S = e.meta) == null ? void 0 : S.last_run_availability_time).utc(), u = r.diff(N, "days");
|
|
1948
1948
|
return {
|
|
1949
1949
|
category: e.category,
|
|
@@ -1952,18 +1952,18 @@ class J0 {
|
|
|
1952
1952
|
availabilityTime: N.format(),
|
|
1953
1953
|
days: u,
|
|
1954
1954
|
initialisationTime: L.unix((m = e.meta) == null ? void 0 : m.last_run_initialisation_time).utc().format(),
|
|
1955
|
-
modificationTime: L.unix((
|
|
1955
|
+
modificationTime: L.unix((Z = e.meta) == null ? void 0 : Z.last_run_modification_time).utc().format(),
|
|
1956
1956
|
temporalResolution: Math.round(((P = e.meta) == null ? void 0 : P.temporal_resolution_seconds) / 3600),
|
|
1957
1957
|
frequency: Math.round(((K = e.meta) == null ? void 0 : K.update_interval_seconds) / 3600)
|
|
1958
1958
|
}
|
|
1959
1959
|
};
|
|
1960
1960
|
});
|
|
1961
|
-
f.length && (this.METEO2_UPDATE[
|
|
1961
|
+
f.length && (this.METEO2_UPDATE[d.alias] = f);
|
|
1962
1962
|
}
|
|
1963
1963
|
this.METEO2_UPDATE.version = b + 1, this.METEO2_UPDATE.etime = p.unix();
|
|
1964
1964
|
}
|
|
1965
|
-
} catch (
|
|
1966
|
-
D.error("[%s] update meteo2 error: %s", M.requestId,
|
|
1965
|
+
} catch (O) {
|
|
1966
|
+
D.error("[%s] update meteo2 error: %s", M.requestId, O);
|
|
1967
1967
|
}
|
|
1968
1968
|
}
|
|
1969
1969
|
return this.METEO2_UPDATE;
|
|
@@ -1985,7 +1985,7 @@ try {
|
|
|
1985
1985
|
} catch {
|
|
1986
1986
|
} finally {
|
|
1987
1987
|
}
|
|
1988
|
-
class
|
|
1988
|
+
class J0 {
|
|
1989
1989
|
constructor(M, z) {
|
|
1990
1990
|
F(this, "apikey");
|
|
1991
1991
|
F(this, "debug");
|
|
@@ -2024,27 +2024,27 @@ class k0 {
|
|
|
2024
2024
|
* @param datum
|
|
2025
2025
|
* @param options
|
|
2026
2026
|
*/
|
|
2027
|
-
async tidesForecast(M, z, b = 7, p = "today", c = !0, W = !1,
|
|
2028
|
-
p = p || "today", b = b || 7, z = this.toStdLng(z), this.debug && R0.info("[%s] spot tides forecast params: %j",
|
|
2029
|
-
let
|
|
2030
|
-
c && (
|
|
2031
|
-
const
|
|
2032
|
-
return
|
|
2027
|
+
async tidesForecast(M, z, b = 7, p = "today", c = !0, W = !1, O = !1, o = "CD", q = {}) {
|
|
2028
|
+
p = p || "today", b = b || 7, z = this.toStdLng(z), this.debug && R0.info("[%s] spot tides forecast params: %j", q.requestId, { lat: M, lng: z, date: p, extremes: c, heights: W, datums: O, datum: o });
|
|
2029
|
+
let d = `https://www.worldtides.info/api/v3?lat=${M}&lon=${z}&days=${b}&date=${p}&datum=${o}&key=${this.apikey}&localtime`;
|
|
2030
|
+
c && (d = `${d}&extremes`), W && (d = `${d}&heights`), O && (d = `${d}&datums`);
|
|
2031
|
+
const Y = await (await fetch(d)).json();
|
|
2032
|
+
return Y.status === 200 ? {
|
|
2033
2033
|
rqt: {
|
|
2034
2034
|
lat: M,
|
|
2035
2035
|
lng: z
|
|
2036
2036
|
},
|
|
2037
2037
|
rsp: {
|
|
2038
|
-
lat:
|
|
2039
|
-
lng:
|
|
2038
|
+
lat: Y.responseLat,
|
|
2039
|
+
lng: Y.responseLon
|
|
2040
2040
|
},
|
|
2041
|
-
atlas:
|
|
2042
|
-
datum:
|
|
2043
|
-
extremes:
|
|
2044
|
-
heights:
|
|
2045
|
-
stations:
|
|
2046
|
-
datums:
|
|
2047
|
-
} :
|
|
2041
|
+
atlas: Y.atlas,
|
|
2042
|
+
datum: Y.responseDatum,
|
|
2043
|
+
extremes: Y.extremes || [],
|
|
2044
|
+
heights: Y.heights || [],
|
|
2045
|
+
stations: Y.stations || [],
|
|
2046
|
+
datums: Y.datums || []
|
|
2047
|
+
} : Y;
|
|
2048
2048
|
}
|
|
2049
2049
|
}
|
|
2050
2050
|
let X0;
|
|
@@ -2053,7 +2053,7 @@ try {
|
|
|
2053
2053
|
} catch {
|
|
2054
2054
|
} finally {
|
|
2055
2055
|
}
|
|
2056
|
-
class
|
|
2056
|
+
class j {
|
|
2057
2057
|
static async parseHistory(M) {
|
|
2058
2058
|
return M == null ? void 0 : M.map((z) => {
|
|
2059
2059
|
const b = Number(z.pressure / 100), p = Number(z.lat), c = Number(z.lon), W = Number(z.windSpeed * 3600 / 1852);
|
|
@@ -2089,16 +2089,16 @@ class $ {
|
|
|
2089
2089
|
var c;
|
|
2090
2090
|
const b = L.utc(z.reftime).format(), p = {};
|
|
2091
2091
|
return (c = z.records) == null || c.forEach((W) => {
|
|
2092
|
-
const
|
|
2092
|
+
const O = L.utc(W.time), o = O.diff(b, "hour"), q = Number(W.pressure / 100), d = Number(W.lat), X = Number(W.lon), Y = Number(W.windSpeed * 3600 / 1852);
|
|
2093
2093
|
p[o] = {
|
|
2094
|
-
lat: isNaN(
|
|
2094
|
+
lat: isNaN(d) ? null : d,
|
|
2095
2095
|
lng: isNaN(X) ? null : X,
|
|
2096
|
-
pressure: isNaN(
|
|
2097
|
-
utc:
|
|
2096
|
+
pressure: isNaN(q) ? null : Math.round(q) || null,
|
|
2097
|
+
utc: O.format(),
|
|
2098
2098
|
wind: {
|
|
2099
|
-
datetime:
|
|
2100
|
-
kts: isNaN(
|
|
2101
|
-
type: T.parseTropicalType(
|
|
2099
|
+
datetime: O.format(),
|
|
2100
|
+
kts: isNaN(Y) ? null : Math.round(Y) || null,
|
|
2101
|
+
type: T.parseTropicalType(Y),
|
|
2102
2102
|
r7: null,
|
|
2103
2103
|
r7ne: null,
|
|
2104
2104
|
r7nw: null,
|
|
@@ -2133,31 +2133,31 @@ class $ {
|
|
|
2133
2133
|
id: z == null ? void 0 : z.toLowerCase(),
|
|
2134
2134
|
name: (W = b == null ? void 0 : b.toLowerCase()) == null ? void 0 : W.replaceAll(/\s/g, "-"),
|
|
2135
2135
|
strength: p,
|
|
2136
|
-
history: await
|
|
2137
|
-
forecasts: await
|
|
2136
|
+
history: await j.parseHistory(M.history),
|
|
2137
|
+
forecasts: await j.parseForecast(M.forecast)
|
|
2138
2138
|
};
|
|
2139
2139
|
return await T.tropicalMovement(c), c;
|
|
2140
2140
|
}
|
|
2141
2141
|
static async realtimeForecast() {
|
|
2142
2142
|
const M = "https://node.windy.com/tc/v2/storms", z = await Q.get(M).json(), b = [];
|
|
2143
2143
|
for (const p of z.storms) {
|
|
2144
|
-
const c = `https://node.windy.com/tc/v2/storms/${p.id}`, W = await Q.get(c).json(),
|
|
2145
|
-
b.push(
|
|
2144
|
+
const c = `https://node.windy.com/tc/v2/storms/${p.id}`, W = await Q.get(c).json(), O = await j.parseTropical(W);
|
|
2145
|
+
b.push(O);
|
|
2146
2146
|
}
|
|
2147
2147
|
return b;
|
|
2148
2148
|
}
|
|
2149
2149
|
}
|
|
2150
|
-
const
|
|
2150
|
+
const k = class k {
|
|
2151
2151
|
static async parseHistory(M) {
|
|
2152
|
-
const z = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${M}`, b = await Q.post(z).text(), p = await
|
|
2153
|
-
for (const
|
|
2154
|
-
const o = L(
|
|
2152
|
+
const z = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${M}`, b = await Q.post(z).text(), p = await k.parser.parseStringPromise(b), c = p.typhoon.position instanceof Array ? p.typhoon.position : [p.typhoon.position], W = [];
|
|
2153
|
+
for (const O of c) {
|
|
2154
|
+
const o = L(O.updatetime).utcOffset(8).utc().format(), q = Number(O.lat), d = Number(O.lon), X = Number(O.pressure), Y = Number(O.windspeed * 3600 / 1852), f = T.parseWindCircle(O.c7quad1 / 1.852), e = T.parseWindCircle(O.c7quad2 / 1.852), r = T.parseWindCircle(O.c7quad3 / 1.852), N = T.parseWindCircle(O.c7quad4 / 1.852), u = T.parseWindCircle(O.c10quad1 / 1.852), B = T.parseWindCircle(O.c10quad2 / 1.852), S = T.parseWindCircle(O.c10quad3 / 1.852), m = T.parseWindCircle(O.c10quad4 / 1.852), Z = T.parseWindCircle(O.c12quad1 / 1.852), P = T.parseWindCircle(O.c12quad2 / 1.852), K = T.parseWindCircle(O.c12quad3 / 1.852), h = T.parseWindCircle(O.c12quad4 / 1.852), { r7: H, r10: g, r12: C } = T.estimateWindRadii(Y, q), E = {
|
|
2155
2155
|
updated: o,
|
|
2156
|
-
lat: isNaN(
|
|
2157
|
-
lng: isNaN(
|
|
2156
|
+
lat: isNaN(q) ? null : q,
|
|
2157
|
+
lng: isNaN(d) ? null : d,
|
|
2158
2158
|
pressure: isNaN(X) ? null : Math.round(X),
|
|
2159
|
-
kts: isNaN(
|
|
2160
|
-
type: T.parseTropicalType(
|
|
2159
|
+
kts: isNaN(Y) ? null : Math.round(Y) || null,
|
|
2160
|
+
type: T.parseTropicalType(Y),
|
|
2161
2161
|
wind: {
|
|
2162
2162
|
r7: H,
|
|
2163
2163
|
r7ne: f,
|
|
@@ -2169,8 +2169,8 @@ const J = class J {
|
|
|
2169
2169
|
r10nw: B,
|
|
2170
2170
|
r10sw: S,
|
|
2171
2171
|
r10se: m,
|
|
2172
|
-
r12:
|
|
2173
|
-
r12ne:
|
|
2172
|
+
r12: C,
|
|
2173
|
+
r12ne: Z,
|
|
2174
2174
|
r12nw: P,
|
|
2175
2175
|
r12sw: K,
|
|
2176
2176
|
r12se: h
|
|
@@ -2178,21 +2178,21 @@ const J = class J {
|
|
|
2178
2178
|
};
|
|
2179
2179
|
W.push(E);
|
|
2180
2180
|
}
|
|
2181
|
-
return W.sort((
|
|
2181
|
+
return W.sort((O, o) => L(o.updated).unix() - L(O.updated).unix()), W;
|
|
2182
2182
|
}
|
|
2183
2183
|
static async parseForecast(M, z) {
|
|
2184
|
-
const b = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${M}`, p = await Q.post(b).text(), c = await
|
|
2184
|
+
const b = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${M}`, p = await Q.post(b).text(), c = await k.parser.parseStringPromise(p), W = c.list.forecast instanceof Array ? c.list.forecast : [c.list.forecast], O = [];
|
|
2185
2185
|
for (const o of W)
|
|
2186
2186
|
if (o.xuhao === M) {
|
|
2187
|
-
const
|
|
2188
|
-
if (
|
|
2189
|
-
z = z || L(
|
|
2190
|
-
const
|
|
2191
|
-
for (const
|
|
2192
|
-
const f = L(
|
|
2187
|
+
const q = o.positions.forecastposition instanceof Array ? o.positions.forecastposition : [o.positions.forecastposition];
|
|
2188
|
+
if (q.length) {
|
|
2189
|
+
z = z || L(q.at(0).forecasttime).utcOffset(8).utc();
|
|
2190
|
+
const d = {};
|
|
2191
|
+
for (const Y of q) {
|
|
2192
|
+
const f = L(Y.forecasttime).utcOffset(8).utc(), e = f.diff(z, "hours");
|
|
2193
2193
|
if (e) {
|
|
2194
|
-
const r = Number(
|
|
2195
|
-
|
|
2194
|
+
const r = Number(Y.forelat), N = Number(Y.forelon), u = Number(Y.forepressure), B = Number(Y.forespeed * 3600 / 1852);
|
|
2195
|
+
d[e] = {
|
|
2196
2196
|
lat: isNaN(r) ? null : r,
|
|
2197
2197
|
lng: isNaN(N) ? null : N,
|
|
2198
2198
|
pressure: u ? Math.round(u) : null,
|
|
@@ -2226,17 +2226,17 @@ const J = class J {
|
|
|
2226
2226
|
const X = {
|
|
2227
2227
|
date: z.utc().format(),
|
|
2228
2228
|
model: T.parseTropicalModel(o.country).toLowerCase(),
|
|
2229
|
-
hours:
|
|
2229
|
+
hours: d
|
|
2230
2230
|
};
|
|
2231
|
-
|
|
2231
|
+
O.push(X);
|
|
2232
2232
|
}
|
|
2233
2233
|
}
|
|
2234
|
-
return
|
|
2234
|
+
return O;
|
|
2235
2235
|
}
|
|
2236
2236
|
static async parseTropical(M) {
|
|
2237
|
-
var W,
|
|
2238
|
-
const z = await
|
|
2239
|
-
id: (
|
|
2237
|
+
var W, O, o;
|
|
2238
|
+
const z = await k.parseHistory(M.xuhao), b = (W = z.at(0)) == null ? void 0 : W.updated, p = await k.parseForecast(M.xuhao, b ? L(b) : void 0), c = {
|
|
2239
|
+
id: (O = M.enname) == null ? void 0 : O.toLowerCase(),
|
|
2240
2240
|
name: (o = M.enname) == null ? void 0 : o.toLowerCase(),
|
|
2241
2241
|
cnName: M.name,
|
|
2242
2242
|
history: z,
|
|
@@ -2245,21 +2245,21 @@ const J = class J {
|
|
|
2245
2245
|
return await T.tropicalMovement(c), c;
|
|
2246
2246
|
}
|
|
2247
2247
|
static async realtimeForecast() {
|
|
2248
|
-
const M = "https://hifleet.com/hifleetapi/getCurrentTyphoon2.do", z = await Q.post(M).text(), b = await
|
|
2248
|
+
const M = "https://hifleet.com/hifleetapi/getCurrentTyphoon2.do", z = await Q.post(M).text(), b = await k.parser.parseStringPromise(z), p = [], c = b.typhoon.position instanceof Array ? b.typhoon.position : [b.typhoon.position];
|
|
2249
2249
|
for (const W of c)
|
|
2250
2250
|
if (W) {
|
|
2251
|
-
const
|
|
2252
|
-
p.push(
|
|
2251
|
+
const O = await k.parseTropical(W);
|
|
2252
|
+
p.push(O);
|
|
2253
2253
|
}
|
|
2254
2254
|
return p;
|
|
2255
2255
|
}
|
|
2256
2256
|
};
|
|
2257
|
-
F(
|
|
2258
|
-
let b0 =
|
|
2259
|
-
class
|
|
2257
|
+
F(k, "parser", u0.Parser({ explicitArray: !1, mergeAttrs: !0, trim: !0 }));
|
|
2258
|
+
let b0 = k;
|
|
2259
|
+
class x {
|
|
2260
2260
|
static async parseHistory(M) {
|
|
2261
2261
|
return M.map((z) => {
|
|
2262
|
-
const b = Number(z.lat), p = Number(z.lon), c = Number(z.maxSP * 3600 / 1852), W =
|
|
2262
|
+
const b = Number(z.lat), p = Number(z.lon), c = Number(z.maxSP * 3600 / 1852), W = T.parseWindCircle(z.r7Ne / 1.852), O = T.parseWindCircle(z.r7Nw / 1.852), o = T.parseWindCircle(z.r7Se / 1.852), q = T.parseWindCircle(z.r7Sw / 1.852), d = T.parseWindCircle(z.r10Ne / 1.852), X = T.parseWindCircle(z.r10Nw / 1.852), Y = T.parseWindCircle(z.r10Se / 1.852), f = T.parseWindCircle(z.r10Sw / 1.852), e = T.parseWindCircle(z.r12Ne / 1.852), r = T.parseWindCircle(z.r12Nw / 1.852), N = T.parseWindCircle(z.r12Se / 1.852), u = T.parseWindCircle(z.r12Sw / 1.852), { r7: B, r10: S, r12: m } = T.estimateWindRadii(c, b);
|
|
2263
2263
|
return {
|
|
2264
2264
|
updated: L.utc(z.realTime).format(),
|
|
2265
2265
|
lat: isNaN(b) ? null : b || null,
|
|
@@ -2267,21 +2267,21 @@ class j {
|
|
|
2267
2267
|
kts: isNaN(c) ? null : Math.round(c) || null,
|
|
2268
2268
|
type: T.parseTropicalType(c),
|
|
2269
2269
|
wind: {
|
|
2270
|
-
r7:
|
|
2271
|
-
r7ne:
|
|
2272
|
-
r7nw:
|
|
2273
|
-
r7se:
|
|
2274
|
-
r7sw:
|
|
2275
|
-
r10:
|
|
2276
|
-
r10ne:
|
|
2277
|
-
r10nw:
|
|
2278
|
-
r10se:
|
|
2279
|
-
r10sw:
|
|
2280
|
-
r12:
|
|
2281
|
-
r12ne:
|
|
2282
|
-
r12nw:
|
|
2283
|
-
r12se:
|
|
2284
|
-
r12sw:
|
|
2270
|
+
r7: B,
|
|
2271
|
+
r7ne: W,
|
|
2272
|
+
r7nw: O,
|
|
2273
|
+
r7se: o,
|
|
2274
|
+
r7sw: q,
|
|
2275
|
+
r10: S,
|
|
2276
|
+
r10ne: d,
|
|
2277
|
+
r10nw: X,
|
|
2278
|
+
r10se: Y,
|
|
2279
|
+
r10sw: f,
|
|
2280
|
+
r12: m,
|
|
2281
|
+
r12ne: e,
|
|
2282
|
+
r12nw: r,
|
|
2283
|
+
r12se: N,
|
|
2284
|
+
r12sw: u
|
|
2285
2285
|
}
|
|
2286
2286
|
};
|
|
2287
2287
|
});
|
|
@@ -2289,32 +2289,32 @@ class j {
|
|
|
2289
2289
|
static async parseForecast(M) {
|
|
2290
2290
|
return M.map((z) => {
|
|
2291
2291
|
const b = z.currentPosition, p = z.forecastPoints, c = L.utc(b.realTime).format(), W = {};
|
|
2292
|
-
return p.forEach((
|
|
2293
|
-
const o = L.utc(
|
|
2294
|
-
W[
|
|
2295
|
-
lat:
|
|
2296
|
-
lng:
|
|
2297
|
-
pressure:
|
|
2292
|
+
return p.forEach((O) => {
|
|
2293
|
+
const o = L.utc(O.forecastTime), q = o.diff(c, "hour"), d = Math.round(O.maxSP * 3600 / 1852), X = Math.round(O.maxSP * 3600 / 1852), Y = T.parseWindCircle(O.r7Ne / 1.852), f = T.parseWindCircle(O.r7Nw / 1.852), e = T.parseWindCircle(O.r7Sw / 1.852), r = T.parseWindCircle(O.r7Se / 1.852), N = T.parseWindCircle(O.r10Ne / 1.852), u = T.parseWindCircle(O.r10Nw / 1.852), B = T.parseWindCircle(O.r10Sw / 1.852), S = T.parseWindCircle(O.r10Se / 1.852), m = T.parseWindCircle(O.r12Ne / 1.852), Z = T.parseWindCircle(O.r12Nw / 1.852), P = T.parseWindCircle(O.r12Sw / 1.852), K = T.parseWindCircle(O.r12Se / 1.852), { r7: h, r10: H, r12: g } = T.estimateWindRadii(d, O.lat);
|
|
2294
|
+
W[q] = {
|
|
2295
|
+
lat: O.lat,
|
|
2296
|
+
lng: O.lon,
|
|
2297
|
+
pressure: O.pressure,
|
|
2298
2298
|
utc: o.format(),
|
|
2299
2299
|
wind: {
|
|
2300
|
-
kts: isNaN(
|
|
2301
|
-
type: T.parseTropicalType(
|
|
2300
|
+
kts: isNaN(d) ? null : d || null,
|
|
2301
|
+
type: T.parseTropicalType(d),
|
|
2302
2302
|
datetime: o.format(),
|
|
2303
|
-
r7:
|
|
2304
|
-
r7ne:
|
|
2305
|
-
r7nw:
|
|
2306
|
-
r7sw:
|
|
2307
|
-
r7se:
|
|
2308
|
-
r10:
|
|
2309
|
-
r10ne:
|
|
2310
|
-
r10nw:
|
|
2311
|
-
r10sw:
|
|
2312
|
-
r10se:
|
|
2313
|
-
r12:
|
|
2314
|
-
r12ne:
|
|
2315
|
-
r12nw:
|
|
2316
|
-
r12sw:
|
|
2317
|
-
r12se:
|
|
2303
|
+
r7: h,
|
|
2304
|
+
r7ne: Y,
|
|
2305
|
+
r7nw: f,
|
|
2306
|
+
r7sw: e,
|
|
2307
|
+
r7se: r,
|
|
2308
|
+
r10: H,
|
|
2309
|
+
r10ne: N,
|
|
2310
|
+
r10nw: u,
|
|
2311
|
+
r10sw: B,
|
|
2312
|
+
r10se: S,
|
|
2313
|
+
r12: g,
|
|
2314
|
+
r12ne: m,
|
|
2315
|
+
r12nw: Z,
|
|
2316
|
+
r12sw: P,
|
|
2317
|
+
r12se: K
|
|
2318
2318
|
},
|
|
2319
2319
|
gusts: {
|
|
2320
2320
|
kts: isNaN(X) ? null : X || null
|
|
@@ -2335,15 +2335,15 @@ class j {
|
|
|
2335
2335
|
cName: z == null ? void 0 : z.cName,
|
|
2336
2336
|
lat: b == null ? void 0 : b.lat,
|
|
2337
2337
|
lng: b == null ? void 0 : b.lon,
|
|
2338
|
-
history: await
|
|
2339
|
-
forecasts: await
|
|
2338
|
+
history: await x.parseHistory(M.historyPoint),
|
|
2339
|
+
forecasts: await x.parseForecast(M.forecastSets)
|
|
2340
2340
|
};
|
|
2341
2341
|
return await T.tropicalMovement(c), c;
|
|
2342
2342
|
}
|
|
2343
2343
|
static async realtimeForecast() {
|
|
2344
2344
|
const M = "http://weather.ninecosmos.cn/jiufang/meteo/typhoon", z = await Q.get(M).json(), b = [];
|
|
2345
2345
|
for (const p in z.data)
|
|
2346
|
-
b.push(await
|
|
2346
|
+
b.push(await x.parseTropical(z.data[p]));
|
|
2347
2347
|
return b;
|
|
2348
2348
|
}
|
|
2349
2349
|
}
|
|
@@ -2355,44 +2355,44 @@ class T {
|
|
|
2355
2355
|
* @param options
|
|
2356
2356
|
*/
|
|
2357
2357
|
static async realtimeForecast(M = "", z = {}) {
|
|
2358
|
-
return X0.info("[%s] try to fetch realtime tropicals forecast from %s", z.requestId, M), M === "windy" ?
|
|
2358
|
+
return X0.info("[%s] try to fetch realtime tropicals forecast from %s", z.requestId, M), M === "windy" ? j.realtimeForecast() : M === "hifleet" ? b0.realtimeForecast() : M === "nio" ? x.realtimeForecast() : T.mergeTropicals(!0, !1, z);
|
|
2359
2359
|
}
|
|
2360
2360
|
static async sortTropical(M) {
|
|
2361
2361
|
var b;
|
|
2362
2362
|
const z = Object.values(c0);
|
|
2363
2363
|
return (b = M.forecasts) == null || b.sort((p, c) => {
|
|
2364
|
-
var o,
|
|
2365
|
-
const W = z.indexOf((o = p.model) == null ? void 0 : o.toUpperCase()),
|
|
2366
|
-
return (W === -1 ? 999 : W) - (
|
|
2364
|
+
var o, q;
|
|
2365
|
+
const W = z.indexOf((o = p.model) == null ? void 0 : o.toUpperCase()), O = z.indexOf((q = c.model) == null ? void 0 : q.toUpperCase());
|
|
2366
|
+
return (W === -1 ? 999 : W) - (O === -1 ? 999 : O);
|
|
2367
2367
|
}), M;
|
|
2368
2368
|
}
|
|
2369
2369
|
static async mergeTropicals(M = !0, z = !1, b = {}) {
|
|
2370
|
-
var
|
|
2371
|
-
const p = await
|
|
2372
|
-
for (const
|
|
2370
|
+
var O, o, q;
|
|
2371
|
+
const p = await j.realtimeForecast(), c = M ? await b0.realtimeForecast() : [], W = z ? await x.realtimeForecast() : [];
|
|
2372
|
+
for (const d of p) {
|
|
2373
2373
|
const X = c.find((e) => {
|
|
2374
2374
|
var r, N;
|
|
2375
|
-
return ((r = e.name) == null ? void 0 : r.toLowerCase()) === ((N =
|
|
2376
|
-
}),
|
|
2375
|
+
return ((r = e.name) == null ? void 0 : r.toLowerCase()) === ((N = d.name) == null ? void 0 : N.toLowerCase());
|
|
2376
|
+
}), Y = W.find((e) => {
|
|
2377
2377
|
var r, N;
|
|
2378
|
-
return ((r = e.name) == null ? void 0 : r.toLowerCase()) === ((N =
|
|
2378
|
+
return ((r = e.name) == null ? void 0 : r.toLowerCase()) === ((N = d.name) == null ? void 0 : N.toLowerCase());
|
|
2379
2379
|
});
|
|
2380
|
-
if (
|
|
2381
|
-
|
|
2382
|
-
for (const e of
|
|
2383
|
-
["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((
|
|
2380
|
+
if (Y) {
|
|
2381
|
+
d.history.sort((e, r) => L(r.updated).valueOf() - L(e.updated).valueOf());
|
|
2382
|
+
for (const e of Y.forecasts)
|
|
2383
|
+
["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((O = e.model) == null ? void 0 : O.toUpperCase()) && !d.forecasts.find((r) => {
|
|
2384
2384
|
var N, u;
|
|
2385
2385
|
return ((N = r.model) == null ? void 0 : N.toLowerCase()) === ((u = e.model) == null ? void 0 : u.toLowerCase());
|
|
2386
|
-
}) &&
|
|
2386
|
+
}) && d.forecasts.push(e);
|
|
2387
2387
|
}
|
|
2388
2388
|
if (X) {
|
|
2389
|
-
(o = X.history) != null && o.length && (
|
|
2389
|
+
(o = X.history) != null && o.length && (d.history = X.history), d.history.sort((e, r) => L(r.updated).valueOf() - L(e.updated).valueOf());
|
|
2390
2390
|
for (const e of X.forecasts)
|
|
2391
|
-
["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((
|
|
2391
|
+
["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((q = e.model) == null ? void 0 : q.toUpperCase()) && !d.forecasts.find((r) => r.model.toLowerCase() === e.model.toLowerCase()) && d.forecasts.push(e);
|
|
2392
2392
|
}
|
|
2393
|
-
|
|
2394
|
-
const f =
|
|
2395
|
-
f &&
|
|
2393
|
+
d.history = d.history.reduce((e, r) => (e.find((N) => N.updated === r.updated) || e.push(r), e), []);
|
|
2394
|
+
const f = d.history[0];
|
|
2395
|
+
f && d.forecasts.forEach((e) => {
|
|
2396
2396
|
e.date = f.updated;
|
|
2397
2397
|
const r = L(f.updated), N = {};
|
|
2398
2398
|
for (const u in e.hours) {
|
|
@@ -2400,13 +2400,13 @@ class T {
|
|
|
2400
2400
|
S > 0 && (N[S] = B);
|
|
2401
2401
|
}
|
|
2402
2402
|
e.hours = N;
|
|
2403
|
-
}), await T.tropicalMovement(
|
|
2403
|
+
}), await T.tropicalMovement(d);
|
|
2404
2404
|
}
|
|
2405
|
-
for (const
|
|
2405
|
+
for (const d of c)
|
|
2406
2406
|
p.every((X) => {
|
|
2407
|
-
var
|
|
2408
|
-
return ((
|
|
2409
|
-
}) && p.push(
|
|
2407
|
+
var Y, f;
|
|
2408
|
+
return ((Y = X.name) == null ? void 0 : Y.toLowerCase()) !== ((f = d.name) == null ? void 0 : f.toLowerCase());
|
|
2409
|
+
}) && p.push(d);
|
|
2410
2410
|
return p;
|
|
2411
2411
|
}
|
|
2412
2412
|
/**
|
|
@@ -2418,21 +2418,21 @@ class T {
|
|
|
2418
2418
|
let z = null;
|
|
2419
2419
|
M.forecasts.forEach((p) => {
|
|
2420
2420
|
const c = p.hours, W = Object.keys(c);
|
|
2421
|
-
for (let
|
|
2422
|
-
const o = c[W[
|
|
2421
|
+
for (let O = 0; O < W.length - 1; O++) {
|
|
2422
|
+
const o = c[W[O]];
|
|
2423
2423
|
z = z || o;
|
|
2424
|
-
const
|
|
2425
|
-
o.movement = T.calculateMovement(o,
|
|
2426
|
-
const
|
|
2427
|
-
o.wind = { ...o.wind || {}, ...
|
|
2424
|
+
const q = c[W[O + 1]];
|
|
2425
|
+
o.movement = T.calculateMovement(o, q);
|
|
2426
|
+
const d = T.supplementWindRadii(o);
|
|
2427
|
+
o.wind = { ...o.wind || {}, ...d };
|
|
2428
2428
|
}
|
|
2429
2429
|
});
|
|
2430
2430
|
let b = null;
|
|
2431
2431
|
for (let p = 0; p < M.history.length - 1; p++) {
|
|
2432
2432
|
const c = M.history[p + 1], W = M.history[p];
|
|
2433
2433
|
b = b || W, c.movement = T.calculateMovement(c, W);
|
|
2434
|
-
const
|
|
2435
|
-
c.wind = { ...c.wind || {}, ...
|
|
2434
|
+
const O = T.supplementWindRadii(c);
|
|
2435
|
+
c.wind = { ...c.wind || {}, ...O };
|
|
2436
2436
|
}
|
|
2437
2437
|
if (b && z) {
|
|
2438
2438
|
b.movement = T.calculateMovement(b, z);
|
|
@@ -2450,35 +2450,51 @@ class T {
|
|
|
2450
2450
|
}
|
|
2451
2451
|
/**
|
|
2452
2452
|
* 估算最大风速半径 (RMW - Radius of Maximum Wind)
|
|
2453
|
-
* @param
|
|
2454
|
-
* @param pressure 中心气压(hPa)
|
|
2453
|
+
* @param ms 最大风速(m/s)
|
|
2455
2454
|
* @param lat 纬度
|
|
2456
2455
|
*/
|
|
2457
|
-
static estimateRMW(M, z
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2456
|
+
static estimateRMW(M, z) {
|
|
2457
|
+
const b = Math.abs(z || 25), p = 51.6 * Math.exp(-0.0223 * M + 0.0281 * b);
|
|
2458
|
+
return Math.max(10, Math.min(150, p));
|
|
2459
|
+
}
|
|
2460
|
+
/**
|
|
2461
|
+
* 反映风速衰减快慢,由台风特性决定
|
|
2462
|
+
* @param vMax 最大风速(m/s)
|
|
2463
|
+
* @param rmw 最大风速半径(km)
|
|
2464
|
+
* @param lat 中心纬度
|
|
2465
|
+
*/
|
|
2466
|
+
static estimateHollandB(M, z, b) {
|
|
2467
|
+
return 1.0036 + 0.0173 * M - 0.0312 * Math.log(z) + 87e-4 * b;
|
|
2468
|
+
}
|
|
2469
|
+
/**
|
|
2470
|
+
* 推算风圈半径
|
|
2471
|
+
* @param vTarget 目标风速 m/s
|
|
2472
|
+
* @param vMax 最大风速 m/s
|
|
2473
|
+
* @param rmw 最大风速半径(km)
|
|
2474
|
+
* @param b Holland形状参数B
|
|
2475
|
+
*/
|
|
2476
|
+
static findWindRadius(M, z, b, p) {
|
|
2477
|
+
if (M >= z)
|
|
2478
|
+
return 0;
|
|
2479
|
+
let c = b, W = b * 10;
|
|
2480
|
+
for (; W - c > 0.1; ) {
|
|
2481
|
+
const O = (c + W) / 2, o = b / O, q = Math.pow(o, p) * Math.exp(1 - Math.pow(o, p));
|
|
2482
|
+
z * Math.sqrt(q) > M ? c = O : W = O;
|
|
2483
|
+
}
|
|
2484
|
+
return $.kmh2kts(c + W);
|
|
2466
2485
|
}
|
|
2467
2486
|
/**
|
|
2468
2487
|
* 基于台风强度推算风圈基础半径的经验公式
|
|
2469
2488
|
* @param kts 最大风速(节)
|
|
2470
|
-
* @param pressure 中心气压(hPa)
|
|
2471
2489
|
* @param lat 纬度
|
|
2472
2490
|
* @returns 风圈半径对象
|
|
2473
2491
|
*/
|
|
2474
|
-
static estimateWindRadii(M, z
|
|
2475
|
-
|
|
2476
|
-
return { r7: null, r10: null, r12: null };
|
|
2477
|
-
const p = T.estimateRMW(M, z, b), c = p * 2.5, W = M >= 50 ? p * 1.8 : null, A = M >= 64 ? p * 1.3 : null;
|
|
2492
|
+
static estimateWindRadii(M, z) {
|
|
2493
|
+
const b = $.kts2ms(M), p = T.estimateRMW(b, z), c = T.estimateHollandB(b, p, z), W = T.findWindRadius(17.2, b, p, c), O = T.findWindRadius(28.5, b, p, c), o = T.findWindRadius(37, b, p, c);
|
|
2478
2494
|
return {
|
|
2479
|
-
r7: Math.round(
|
|
2480
|
-
r10:
|
|
2481
|
-
r12:
|
|
2495
|
+
r7: W ? Math.round(W) : null,
|
|
2496
|
+
r10: O ? Math.round(O) : null,
|
|
2497
|
+
r12: o ? Math.round(o) : null
|
|
2482
2498
|
};
|
|
2483
2499
|
}
|
|
2484
2500
|
/**
|
|
@@ -2494,20 +2510,20 @@ class T {
|
|
|
2494
2510
|
return { ne: null, nw: null, se: null, sw: null };
|
|
2495
2511
|
if (z < 9)
|
|
2496
2512
|
return { ne: M, nw: M, se: M, sw: M };
|
|
2497
|
-
const W = 0.15 * Math.min(z / (20 / 1.852), 1),
|
|
2513
|
+
const W = 0.15 * Math.min(z / (20 / 1.852), 1), O = {
|
|
2498
2514
|
ne: (45 - b + 360) % 360,
|
|
2499
2515
|
nw: (315 - b + 360) % 360,
|
|
2500
2516
|
se: (135 - b + 360) % 360,
|
|
2501
2517
|
sw: (225 - b + 360) % 360
|
|
2502
|
-
}, o = (
|
|
2503
|
-
const
|
|
2518
|
+
}, o = (q) => {
|
|
2519
|
+
const d = q > 180 ? q - 360 : q, X = Math.cos(d * Math.PI / 180);
|
|
2504
2520
|
return 1 - W * X;
|
|
2505
2521
|
};
|
|
2506
2522
|
return {
|
|
2507
|
-
ne: Math.round(M * o(
|
|
2508
|
-
nw: Math.round(M * o(
|
|
2509
|
-
se: Math.round(M * o(
|
|
2510
|
-
sw: Math.round(M * o(
|
|
2523
|
+
ne: Math.round(M * o(O.ne)),
|
|
2524
|
+
nw: Math.round(M * o(O.nw)),
|
|
2525
|
+
se: Math.round(M * o(O.se)),
|
|
2526
|
+
sw: Math.round(M * o(O.sw))
|
|
2511
2527
|
};
|
|
2512
2528
|
}
|
|
2513
2529
|
/**
|
|
@@ -2515,14 +2531,14 @@ class T {
|
|
|
2515
2531
|
* @param position 预报点数据
|
|
2516
2532
|
*/
|
|
2517
2533
|
static supplementWindRadii(M) {
|
|
2518
|
-
const { wind: z,
|
|
2534
|
+
const { wind: z, lat: b, movement: p } = M;
|
|
2519
2535
|
if (z.r7) {
|
|
2520
|
-
for (const
|
|
2521
|
-
/^r[7,10,12]/.test(
|
|
2536
|
+
for (const q of Object.keys(z))
|
|
2537
|
+
/^r[7,10,12]/.test(q) && (isNaN(Number(z[q])) || z[q] < 0) && (z[q] = null);
|
|
2522
2538
|
return z;
|
|
2523
2539
|
}
|
|
2524
|
-
const
|
|
2525
|
-
if (!
|
|
2540
|
+
const c = z.kts;
|
|
2541
|
+
if (!c || c < 17)
|
|
2526
2542
|
return {
|
|
2527
2543
|
r7: null,
|
|
2528
2544
|
r7ne: null,
|
|
@@ -2540,16 +2556,16 @@ class T {
|
|
|
2540
2556
|
r12se: null,
|
|
2541
2557
|
r12sw: null
|
|
2542
2558
|
};
|
|
2543
|
-
const
|
|
2544
|
-
return ["r7", "r10", "r12"].forEach((
|
|
2545
|
-
const
|
|
2546
|
-
if (
|
|
2547
|
-
|
|
2548
|
-
const
|
|
2549
|
-
|
|
2559
|
+
const W = T.estimateWindRadii(c, b), O = {};
|
|
2560
|
+
return ["r7", "r10", "r12"].forEach((q) => {
|
|
2561
|
+
const d = W[q];
|
|
2562
|
+
if (d) {
|
|
2563
|
+
O[q] = d;
|
|
2564
|
+
const X = T.estimateAsymmetricRadii(d, (p == null ? void 0 : p.kts) || 0, (p == null ? void 0 : p.deg) || 0, b > 0 ? "N" : "S");
|
|
2565
|
+
O[`${q}ne`] = X.ne, O[`${q}nw`] = X.nw, O[`${q}se`] = X.se, O[`${q}sw`] = X.sw;
|
|
2550
2566
|
} else
|
|
2551
|
-
|
|
2552
|
-
}),
|
|
2567
|
+
O[q] = null, O[`${q}ne`] = null, O[`${q}nw`] = null, O[`${q}se`] = null, O[`${q}sw`] = null;
|
|
2568
|
+
}), O;
|
|
2553
2569
|
}
|
|
2554
2570
|
/**
|
|
2555
2571
|
* 台风类型
|
|
@@ -2573,8 +2589,8 @@ class T {
|
|
|
2573
2589
|
}
|
|
2574
2590
|
export {
|
|
2575
2591
|
Q0 as MeteoHelper,
|
|
2576
|
-
|
|
2577
|
-
|
|
2592
|
+
k0 as MeteoHelper2,
|
|
2593
|
+
J0 as TidesHelper,
|
|
2578
2594
|
T as TropicalHelper,
|
|
2579
2595
|
c0 as TropicalModel,
|
|
2580
2596
|
U0 as WindyModel
|