@idm-plugin/meteo2 0.4.0 → 0.4.2
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 +234 -197
- package/dist/index.umd.cjs +2 -2
- package/dist/openmeteo/src/index.d.ts +2 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,13 +2,13 @@ var L0 = Object.defineProperty;
|
|
|
2
2
|
var n0 = (e, M, b) => M in e ? L0(e, M, { enumerable: !0, configurable: !0, writable: !0, value: b }) : e[M] = b;
|
|
3
3
|
var g = (e, M, b) => (n0(e, typeof M != "symbol" ? M + "" : M, b), b);
|
|
4
4
|
import M0 from "@log4js-node/log4js-api";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { fetchWeatherApi as
|
|
8
|
-
import { Meteo2Assist as
|
|
9
|
-
let
|
|
5
|
+
import L from "moment";
|
|
6
|
+
import $ from "got";
|
|
7
|
+
import { fetchWeatherApi as v } from "openmeteo";
|
|
8
|
+
import { Meteo2Assist as k } from "@idm-plugin/meteo";
|
|
9
|
+
let r;
|
|
10
10
|
try {
|
|
11
|
-
|
|
11
|
+
r = M0.getLogger("meteo");
|
|
12
12
|
} catch {
|
|
13
13
|
} finally {
|
|
14
14
|
}
|
|
@@ -25,7 +25,7 @@ class m0 {
|
|
|
25
25
|
*/
|
|
26
26
|
static async queryPointMeteo(M, b, p, O = !1, o = "", Y = {}) {
|
|
27
27
|
typeof p == "number" && (p = p < 1e12 ? p * 1e3 : p);
|
|
28
|
-
const A =
|
|
28
|
+
const A = L(p), q = {
|
|
29
29
|
searchParams: {
|
|
30
30
|
lng: M,
|
|
31
31
|
lat: b,
|
|
@@ -34,15 +34,15 @@ class m0 {
|
|
|
34
34
|
source: o == null ? void 0 : o.toLowerCase()
|
|
35
35
|
},
|
|
36
36
|
timeout: 3e4
|
|
37
|
-
}, X =
|
|
38
|
-
A.isBefore(X.subtract(1, "month")) && (
|
|
39
|
-
const T = "https://aod4idm.idmwx.com/api/ocean/point", d = await
|
|
40
|
-
if (
|
|
37
|
+
}, X = L(), R = X.valueOf();
|
|
38
|
+
A.isBefore(X.subtract(1, "month")) && (r == null || r.warn("[%s] get history meteo on %s: %j", Y.requestId, A.format(), q));
|
|
39
|
+
const T = "https://aod4idm.idmwx.com/api/ocean/point", d = await $.get(T, q).json(), S = L().valueOf();
|
|
40
|
+
if (r == null || r.info("[%s] get meteo(cost: %d ms) from %s with options: %j", Y.requestId, S - R, T, q), (d == null ? void 0 : d.code) === 0)
|
|
41
41
|
return {
|
|
42
42
|
...d.data,
|
|
43
43
|
source: o
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
r == null || r.warn("[%s] get meteo failed: %j", Y.requestId, d);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* 点查海洋气象要素(指定要素组合)
|
|
@@ -60,7 +60,7 @@ class m0 {
|
|
|
60
60
|
*/
|
|
61
61
|
static async queryPointFactor(M, b, p, O = "wind,wave,current,watertemp,visibility", o = "", Y = {}) {
|
|
62
62
|
typeof p == "number" && (p = p < 1e12 ? p * 1e3 : p);
|
|
63
|
-
const A =
|
|
63
|
+
const A = L(p), q = {
|
|
64
64
|
searchParams: {
|
|
65
65
|
lng: M,
|
|
66
66
|
lat: b,
|
|
@@ -69,15 +69,15 @@ class m0 {
|
|
|
69
69
|
source: o == null ? void 0 : o.toLowerCase()
|
|
70
70
|
},
|
|
71
71
|
timeout: 3e4
|
|
72
|
-
}, X =
|
|
73
|
-
A.isBefore(X.subtract(1, "month")) && (
|
|
74
|
-
const T = "https://aod4idm.idmwx.com/api/ocean/factor", d = await
|
|
75
|
-
if (
|
|
72
|
+
}, X = L(), R = X.valueOf();
|
|
73
|
+
A.isBefore(X.subtract(1, "month")) && (r == null || r.warn("[%s] get history factors on %s: %j", Y.requestId, A.format(), q));
|
|
74
|
+
const T = "https://aod4idm.idmwx.com/api/ocean/factor", d = await $.get(T, q).json(), S = L().valueOf();
|
|
75
|
+
if (r == null || r.info("[%s] get factors(cost: %d ms) from %s with options: %j", Y.requestId, S - R, T, q), (d == null ? void 0 : d.code) === 0)
|
|
76
76
|
return {
|
|
77
77
|
...d.data,
|
|
78
78
|
source: o
|
|
79
79
|
};
|
|
80
|
-
|
|
80
|
+
r == null || r.warn("[%s] get factors failed: %j", Y.requestId, d);
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* @see https://api.windy.com/point-forecast/docs
|
|
@@ -86,8 +86,8 @@ class m0 {
|
|
|
86
86
|
static async queryWindyPointForecast(M, b, p, O = {}) {
|
|
87
87
|
const o = "https://api.windy.com/api/point-forecast/v2", Y = [];
|
|
88
88
|
try {
|
|
89
|
-
let A =
|
|
90
|
-
const q = await
|
|
89
|
+
let A = L().valueOf();
|
|
90
|
+
const q = await $.post(o, {
|
|
91
91
|
headers: {
|
|
92
92
|
"Content-Type": "application/json"
|
|
93
93
|
},
|
|
@@ -116,9 +116,9 @@ class m0 {
|
|
|
116
116
|
levels: ["surface"]
|
|
117
117
|
}
|
|
118
118
|
}).json();
|
|
119
|
-
let X =
|
|
120
|
-
|
|
121
|
-
const R = await
|
|
119
|
+
let X = L().valueOf();
|
|
120
|
+
r == null || r.info("[%s] get gfs-factors(cost: %d ms) from %s", O.requestId, X - A, o), A = X;
|
|
121
|
+
const R = await $.post(o, {
|
|
122
122
|
headers: {
|
|
123
123
|
"Content-Type": "application/json"
|
|
124
124
|
},
|
|
@@ -131,11 +131,11 @@ class m0 {
|
|
|
131
131
|
levels: ["surface"]
|
|
132
132
|
}
|
|
133
133
|
}).json();
|
|
134
|
-
X =
|
|
134
|
+
X = L().valueOf(), r == null || r.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", O.requestId, X - A, o);
|
|
135
135
|
for (let d = 0; d < q.ts.length; d++) {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
utc:
|
|
136
|
+
const S = this.populateUVFactor(q["wind_u-surface"][d], q["wind_v-surface"][d], !1, O);
|
|
137
|
+
S.scale = this.calculateBeaufortWindForceScale(S.speed), Y.push({
|
|
138
|
+
utc: L(q.ts[d]).utc().format(),
|
|
139
139
|
temp: q["temp-surface"][d] ? Math.round((q["temp-surface"][d] - 273.15) * 100) / 100 : void 0,
|
|
140
140
|
dp_temp: q["dewpoint-surface"][d] ? Math.round((q["dewpoint-surface"][d] - 273.15) * 100) / 100 : void 0,
|
|
141
141
|
precip: {
|
|
@@ -143,7 +143,7 @@ class m0 {
|
|
|
143
143
|
inter3hSnow: q["past3hsnowprecip-surface"][d] ? Math.round(q["past3hsnowprecip-surface"][d] * 1e3 * 1e3) / 1e3 : 0,
|
|
144
144
|
inter3hConv: q["past3hconvprecip-surface"][d] ? Math.round(q["past3hconvprecip-surface"][d] * 1e3 * 1e3) / 1e3 : 0
|
|
145
145
|
},
|
|
146
|
-
wind:
|
|
146
|
+
wind: S,
|
|
147
147
|
gusts: {
|
|
148
148
|
speed: Math.round((q["gust-surface"][d] || 0) * 100) / 100,
|
|
149
149
|
kts: this.convertMs2Kts(q["gust-surface"][d])
|
|
@@ -158,23 +158,23 @@ class m0 {
|
|
|
158
158
|
}
|
|
159
159
|
const T = [];
|
|
160
160
|
for (let d = 0; d < R.ts.length; d++) {
|
|
161
|
-
const
|
|
161
|
+
const S = this.calculateDouglasScale(R["waves_height-surface"][d], R["waves_direction-surface"][d], R["waves_period-surface"][d]), N = this.calculateDouglasScale(R["wwaves_height-surface"][d], R["wwaves_direction-surface"][d], R["wwaves_period-surface"][d]), l = this.calculateDouglasScale(R["swell1_height-surface"][d], R["swell1_direction-surface"][d], R["swell1_period-surface"][d]), V = this.calculateDouglasScale(R["swell2_height-surface"][d], R["swell2_direction-surface"][d], R["swell2_period-surface"][d]);
|
|
162
162
|
T.push({
|
|
163
|
-
utc:
|
|
163
|
+
utc: L(R.ts[d]).utc().format(),
|
|
164
164
|
wave: {
|
|
165
|
-
sig:
|
|
166
|
-
wd:
|
|
167
|
-
swell:
|
|
168
|
-
swell2:
|
|
165
|
+
sig: S,
|
|
166
|
+
wd: N,
|
|
167
|
+
swell: l,
|
|
168
|
+
swell2: V
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
for (const d of Y) {
|
|
173
|
-
const
|
|
174
|
-
d.wave =
|
|
173
|
+
const S = T.find((N) => N.utc === d.utc);
|
|
174
|
+
d.wave = S == null ? void 0 : S.wave;
|
|
175
175
|
}
|
|
176
176
|
} catch (A) {
|
|
177
|
-
|
|
177
|
+
r.warn("[%s] get-gfs-factor failed: %s", O.requestId, A);
|
|
178
178
|
}
|
|
179
179
|
return Y;
|
|
180
180
|
}
|
|
@@ -277,7 +277,7 @@ var A0 = { exports: {} };
|
|
|
277
277
|
e.exports = M;
|
|
278
278
|
})(A0);
|
|
279
279
|
var f0 = A0.exports;
|
|
280
|
-
const
|
|
280
|
+
const N0 = /* @__PURE__ */ i0(f0);
|
|
281
281
|
var c0 = { exports: {} };
|
|
282
282
|
(function(e) {
|
|
283
283
|
//! moment-timezone.js
|
|
@@ -286,53 +286,53 @@ var c0 = { exports: {} };
|
|
|
286
286
|
//! license : MIT
|
|
287
287
|
//! github.com/moment/moment-timezone
|
|
288
288
|
(function(M, b) {
|
|
289
|
-
e.exports ? e.exports = b(
|
|
289
|
+
e.exports ? e.exports = b(L) : b(M.moment);
|
|
290
290
|
})(e0, function(M) {
|
|
291
291
|
M.version === void 0 && M.default && (M = M.default);
|
|
292
292
|
var b = "0.5.47", p = {}, O = {}, o = {}, Y = {}, A = {}, q;
|
|
293
|
-
(!M || typeof M.version != "string") &&
|
|
293
|
+
(!M || typeof M.version != "string") && w("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
294
294
|
var X = M.version.split("."), R = +X[0], T = +X[1];
|
|
295
|
-
(R < 2 || R === 2 && T < 6) &&
|
|
295
|
+
(R < 2 || R === 2 && T < 6) && w("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
|
|
296
296
|
function d(z) {
|
|
297
297
|
return z > 96 ? z - 87 : z > 64 ? z - 29 : z - 48;
|
|
298
298
|
}
|
|
299
|
-
function
|
|
300
|
-
var c = 0, W = z.split("."), a = W[0],
|
|
301
|
-
for (z.charCodeAt(0) === 45 && (c = 1,
|
|
302
|
-
|
|
303
|
-
for (c = 0; c <
|
|
304
|
-
i = i / 60,
|
|
305
|
-
return f *
|
|
299
|
+
function S(z) {
|
|
300
|
+
var c = 0, W = z.split("."), a = W[0], n = W[1] || "", i = 1, t, f = 0, B = 1;
|
|
301
|
+
for (z.charCodeAt(0) === 45 && (c = 1, B = -1), c; c < a.length; c++)
|
|
302
|
+
t = d(a.charCodeAt(c)), f = 60 * f + t;
|
|
303
|
+
for (c = 0; c < n.length; c++)
|
|
304
|
+
i = i / 60, t = d(n.charCodeAt(c)), f += t * i;
|
|
305
|
+
return f * B;
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function N(z) {
|
|
308
308
|
for (var c = 0; c < z.length; c++)
|
|
309
|
-
z[c] =
|
|
309
|
+
z[c] = S(z[c]);
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function l(z, c) {
|
|
312
312
|
for (var W = 0; W < c; W++)
|
|
313
313
|
z[W] = Math.round((z[W - 1] || 0) + z[W] * 6e4);
|
|
314
314
|
z[c - 1] = 1 / 0;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function V(z, c) {
|
|
317
317
|
var W = [], a;
|
|
318
318
|
for (a = 0; a < c.length; a++)
|
|
319
319
|
W[a] = z[c[a]];
|
|
320
320
|
return W;
|
|
321
321
|
}
|
|
322
|
-
function
|
|
323
|
-
var c = z.split("|"), W = c[2].split(" "), a = c[3].split(""),
|
|
324
|
-
return
|
|
322
|
+
function E(z) {
|
|
323
|
+
var c = z.split("|"), W = c[2].split(" "), a = c[3].split(""), n = c[4].split(" ");
|
|
324
|
+
return N(W), N(a), N(n), l(n, a.length), {
|
|
325
325
|
name: c[0],
|
|
326
|
-
abbrs:
|
|
327
|
-
offsets:
|
|
328
|
-
untils:
|
|
326
|
+
abbrs: V(c[1].split(" "), a),
|
|
327
|
+
offsets: V(W, a),
|
|
328
|
+
untils: n,
|
|
329
329
|
population: c[5] | 0
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
|
-
function
|
|
333
|
-
z && this._set(
|
|
332
|
+
function h(z) {
|
|
333
|
+
z && this._set(E(z));
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function y(z, c) {
|
|
336
336
|
var W = c.length;
|
|
337
337
|
if (z < c[0])
|
|
338
338
|
return 0;
|
|
@@ -340,17 +340,17 @@ var c0 = { exports: {} };
|
|
|
340
340
|
return W - 1;
|
|
341
341
|
if (z >= c[W - 1])
|
|
342
342
|
return -1;
|
|
343
|
-
for (var a,
|
|
344
|
-
a = Math.floor((
|
|
343
|
+
for (var a, n = 0, i = W - 1; i - n > 1; )
|
|
344
|
+
a = Math.floor((n + i) / 2), c[a] <= z ? n = a : i = a;
|
|
345
345
|
return i;
|
|
346
346
|
}
|
|
347
|
-
|
|
347
|
+
h.prototype = {
|
|
348
348
|
_set: function(z) {
|
|
349
349
|
this.name = z.name, this.abbrs = z.abbrs, this.untils = z.untils, this.offsets = z.offsets, this.population = z.population;
|
|
350
350
|
},
|
|
351
351
|
_index: function(z) {
|
|
352
352
|
var c = +z, W = this.untils, a;
|
|
353
|
-
if (a =
|
|
353
|
+
if (a = y(c, W), a >= 0)
|
|
354
354
|
return a;
|
|
355
355
|
},
|
|
356
356
|
countries: function() {
|
|
@@ -360,26 +360,26 @@ var c0 = { exports: {} };
|
|
|
360
360
|
});
|
|
361
361
|
},
|
|
362
362
|
parse: function(z) {
|
|
363
|
-
var c = +z, W = this.offsets, a = this.untils,
|
|
364
|
-
for (
|
|
365
|
-
if (i = W[
|
|
366
|
-
return W[
|
|
367
|
-
return W[
|
|
363
|
+
var c = +z, W = this.offsets, a = this.untils, n = a.length - 1, i, t, f, B;
|
|
364
|
+
for (B = 0; B < n; B++)
|
|
365
|
+
if (i = W[B], t = W[B + 1], f = W[B && B - 1], i < t && U.moveAmbiguousForward ? i = t : i > f && U.moveInvalidForward && (i = f), c < a[B] - i * 6e4)
|
|
366
|
+
return W[B];
|
|
367
|
+
return W[n];
|
|
368
368
|
},
|
|
369
369
|
abbr: function(z) {
|
|
370
370
|
return this.abbrs[this._index(z)];
|
|
371
371
|
},
|
|
372
372
|
offset: function(z) {
|
|
373
|
-
return
|
|
373
|
+
return w("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(z)];
|
|
374
374
|
},
|
|
375
375
|
utcOffset: function(z) {
|
|
376
376
|
return this.offsets[this._index(z)];
|
|
377
377
|
}
|
|
378
378
|
};
|
|
379
|
-
function
|
|
379
|
+
function _(z, c) {
|
|
380
380
|
this.name = z, this.zones = c;
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function I(z) {
|
|
383
383
|
var c = z.toTimeString(), W = c.match(/\([a-z ]+\)/i);
|
|
384
384
|
W && W[0] ? (W = W[0].match(/[A-Z]/g), W = W ? W.join("") : void 0) : (W = c.match(/[A-Z]{3,5}/g), W = W ? W[0] : void 0), W === "GMT" && (W = void 0), this.at = +z, this.abbr = W, this.offset = z.getTimezoneOffset();
|
|
385
385
|
}
|
|
@@ -389,74 +389,74 @@ var c0 = { exports: {} };
|
|
|
389
389
|
G.prototype.scoreOffsetAt = function(z) {
|
|
390
390
|
this.offsetScore += Math.abs(this.zone.utcOffset(z.at) - z.offset), this.zone.abbr(z.at).replace(/[^A-Z]/g, "") !== z.abbr && this.abbrScore++;
|
|
391
391
|
};
|
|
392
|
-
function
|
|
392
|
+
function Q(z, c) {
|
|
393
393
|
for (var W, a; a = ((c.at - z.at) / 12e4 | 0) * 6e4; )
|
|
394
|
-
W = new
|
|
394
|
+
W = new I(new Date(z.at + a)), W.offset === z.offset ? z = W : c = W;
|
|
395
395
|
return z;
|
|
396
396
|
}
|
|
397
|
-
function
|
|
398
|
-
var z = (/* @__PURE__ */ new Date()).getFullYear() - 2, c = new
|
|
397
|
+
function P() {
|
|
398
|
+
var z = (/* @__PURE__ */ new Date()).getFullYear() - 2, c = new I(new Date(z, 0, 1)), W = c.offset, a = [c], n, i, t, f;
|
|
399
399
|
for (f = 1; f < 48; f++)
|
|
400
|
-
|
|
400
|
+
t = new Date(z, f, 1).getTimezoneOffset(), t !== W && (i = new I(new Date(z, f, 1)), n = Q(c, i), a.push(n), a.push(new I(new Date(n.at + 6e4))), c = i, W = t);
|
|
401
401
|
for (f = 0; f < 4; f++)
|
|
402
|
-
a.push(new
|
|
402
|
+
a.push(new I(new Date(z + f, 0, 1))), a.push(new I(new Date(z + f, 6, 1)));
|
|
403
403
|
return a;
|
|
404
404
|
}
|
|
405
|
-
function
|
|
405
|
+
function H(z, c) {
|
|
406
406
|
return z.offsetScore !== c.offsetScore ? z.offsetScore - c.offsetScore : z.abbrScore !== c.abbrScore ? z.abbrScore - c.abbrScore : z.zone.population !== c.zone.population ? c.zone.population - z.zone.population : c.zone.name.localeCompare(z.zone.name);
|
|
407
407
|
}
|
|
408
408
|
function m(z, c) {
|
|
409
409
|
var W, a;
|
|
410
|
-
for (
|
|
410
|
+
for (N(c), W = 0; W < c.length; W++)
|
|
411
411
|
a = c[W], A[a] = A[a] || {}, A[a][z] = !0;
|
|
412
412
|
}
|
|
413
413
|
function s(z) {
|
|
414
|
-
var c = z.length, W = {}, a = [],
|
|
414
|
+
var c = z.length, W = {}, a = [], n = {}, i, t, f, B;
|
|
415
415
|
for (i = 0; i < c; i++)
|
|
416
|
-
if (f = z[i].offset, !
|
|
417
|
-
|
|
418
|
-
for (
|
|
419
|
-
|
|
420
|
-
|
|
416
|
+
if (f = z[i].offset, !n.hasOwnProperty(f)) {
|
|
417
|
+
B = A[f] || {};
|
|
418
|
+
for (t in B)
|
|
419
|
+
B.hasOwnProperty(t) && (W[t] = !0);
|
|
420
|
+
n[f] = !0;
|
|
421
421
|
}
|
|
422
422
|
for (i in W)
|
|
423
423
|
W.hasOwnProperty(i) && a.push(Y[i]);
|
|
424
424
|
return a;
|
|
425
425
|
}
|
|
426
|
-
function
|
|
426
|
+
function u() {
|
|
427
427
|
try {
|
|
428
428
|
var z = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
429
429
|
if (z && z.length > 3) {
|
|
430
430
|
var c = Y[C(z)];
|
|
431
431
|
if (c)
|
|
432
432
|
return c;
|
|
433
|
-
|
|
433
|
+
w("Moment Timezone found " + z + " from the Intl api, but did not have that data loaded.");
|
|
434
434
|
}
|
|
435
435
|
} catch {
|
|
436
436
|
}
|
|
437
|
-
var W =
|
|
438
|
-
for (f = 0; f <
|
|
439
|
-
for (
|
|
440
|
-
|
|
441
|
-
i.push(
|
|
437
|
+
var W = P(), a = W.length, n = s(W), i = [], t, f, B;
|
|
438
|
+
for (f = 0; f < n.length; f++) {
|
|
439
|
+
for (t = new G(K(n[f])), B = 0; B < a; B++)
|
|
440
|
+
t.scoreOffsetAt(W[B]);
|
|
441
|
+
i.push(t);
|
|
442
442
|
}
|
|
443
|
-
return i.sort(
|
|
443
|
+
return i.sort(H), i.length > 0 ? i[0].zone.name : void 0;
|
|
444
444
|
}
|
|
445
|
-
function
|
|
446
|
-
return (!q || z) && (q =
|
|
445
|
+
function F(z) {
|
|
446
|
+
return (!q || z) && (q = u()), q;
|
|
447
447
|
}
|
|
448
448
|
function C(z) {
|
|
449
449
|
return (z || "").toLowerCase().replace(/\//g, "_");
|
|
450
450
|
}
|
|
451
451
|
function z0(z) {
|
|
452
|
-
var c, W, a,
|
|
452
|
+
var c, W, a, n;
|
|
453
453
|
for (typeof z == "string" && (z = [z]), c = 0; c < z.length; c++)
|
|
454
|
-
a = z[c].split("|"), W = a[0],
|
|
454
|
+
a = z[c].split("|"), W = a[0], n = C(W), p[n] = z[c], Y[n] = W, m(n, a[2].split(" "));
|
|
455
455
|
}
|
|
456
|
-
function
|
|
456
|
+
function K(z, c) {
|
|
457
457
|
z = C(z);
|
|
458
458
|
var W = p[z], a;
|
|
459
|
-
return W instanceof
|
|
459
|
+
return W instanceof h ? W : typeof W == "string" ? (W = new h(W), p[z] = W, W) : O[z] && c !== K && (a = K(O[z], K)) ? (W = p[z] = new h(), W._set(a), W.name = Y[z], W) : null;
|
|
460
460
|
}
|
|
461
461
|
function q0() {
|
|
462
462
|
var z, c = [];
|
|
@@ -468,15 +468,15 @@ var c0 = { exports: {} };
|
|
|
468
468
|
return Object.keys(o);
|
|
469
469
|
}
|
|
470
470
|
function b0(z) {
|
|
471
|
-
var c, W, a,
|
|
471
|
+
var c, W, a, n;
|
|
472
472
|
for (typeof z == "string" && (z = [z]), c = 0; c < z.length; c++)
|
|
473
|
-
W = z[c].split("|"), a = C(W[0]),
|
|
473
|
+
W = z[c].split("|"), a = C(W[0]), n = C(W[1]), O[a] = n, Y[a] = W[0], O[n] = a, Y[n] = W[1];
|
|
474
474
|
}
|
|
475
475
|
function Y0(z) {
|
|
476
|
-
var c, W, a,
|
|
476
|
+
var c, W, a, n;
|
|
477
477
|
if (!(!z || !z.length))
|
|
478
478
|
for (c = 0; c < z.length; c++)
|
|
479
|
-
|
|
479
|
+
n = z[c].split("|"), W = n[0].toUpperCase(), a = n[1].split(" "), o[W] = new _(
|
|
480
480
|
W,
|
|
481
481
|
a
|
|
482
482
|
);
|
|
@@ -489,45 +489,45 @@ var c0 = { exports: {} };
|
|
|
489
489
|
return null;
|
|
490
490
|
var W = z.zones.sort();
|
|
491
491
|
return c ? W.map(function(a) {
|
|
492
|
-
var
|
|
492
|
+
var n = K(a);
|
|
493
493
|
return {
|
|
494
494
|
name: a,
|
|
495
|
-
offset:
|
|
495
|
+
offset: n.utcOffset(/* @__PURE__ */ new Date())
|
|
496
496
|
};
|
|
497
497
|
}) : W;
|
|
498
498
|
}
|
|
499
499
|
function X0(z) {
|
|
500
|
-
z0(z.zones), b0(z.links), Y0(z.countries),
|
|
501
|
-
}
|
|
502
|
-
function v(z) {
|
|
503
|
-
return v.didShowError || (v.didShowError = !0, F("moment.tz.zoneExists('" + z + "') has been deprecated in favor of !moment.tz.zone('" + z + "')")), !!h(z);
|
|
500
|
+
z0(z.zones), b0(z.links), Y0(z.countries), U.dataVersion = z.version;
|
|
504
501
|
}
|
|
505
502
|
function j(z) {
|
|
503
|
+
return j.didShowError || (j.didShowError = !0, w("moment.tz.zoneExists('" + z + "') has been deprecated in favor of !moment.tz.zone('" + z + "')")), !!K(z);
|
|
504
|
+
}
|
|
505
|
+
function x(z) {
|
|
506
506
|
var c = z._f === "X" || z._f === "x";
|
|
507
507
|
return !!(z._a && z._tzm === void 0 && !c);
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function w(z) {
|
|
510
510
|
typeof console < "u" && typeof console.error == "function" && console.error(z);
|
|
511
511
|
}
|
|
512
|
-
function
|
|
513
|
-
var c = Array.prototype.slice.call(arguments, 0, -1), W = arguments[arguments.length - 1], a = M.utc.apply(null, c),
|
|
514
|
-
return !M.isMoment(z) &&
|
|
512
|
+
function U(z) {
|
|
513
|
+
var c = Array.prototype.slice.call(arguments, 0, -1), W = arguments[arguments.length - 1], a = M.utc.apply(null, c), n;
|
|
514
|
+
return !M.isMoment(z) && x(a) && (n = K(W)) && a.add(n.parse(a), "minutes"), a.tz(W), a;
|
|
515
515
|
}
|
|
516
|
-
|
|
516
|
+
U.version = b, U.dataVersion = "", U._zones = p, U._links = O, U._names = Y, U._countries = o, U.add = z0, U.link = b0, U.load = X0, U.zone = K, U.zoneExists = j, U.guess = F, U.names = q0, U.Zone = h, U.unpack = E, U.unpackBase60 = S, U.needsOffset = x, U.moveInvalidForward = !0, U.moveAmbiguousForward = !1, U.countries = o0, U.zonesForCountry = a0;
|
|
517
517
|
var D = M.fn;
|
|
518
|
-
M.tz =
|
|
518
|
+
M.tz = U, M.defaultZone = null, M.updateOffset = function(z, c) {
|
|
519
519
|
var W = M.defaultZone, a;
|
|
520
|
-
if (z._z === void 0 && (W &&
|
|
520
|
+
if (z._z === void 0 && (W && x(z) && !z._isUTC && z.isValid() && (z._d = M.utc(z._a)._d, z.utc().add(W.parse(z), "minutes")), z._z = W), z._z)
|
|
521
521
|
if (a = z._z.utcOffset(z), Math.abs(a) < 16 && (a = a / 60), z.utcOffset !== void 0) {
|
|
522
|
-
var
|
|
523
|
-
z.utcOffset(-a, c), z._z =
|
|
522
|
+
var n = z._z;
|
|
523
|
+
z.utcOffset(-a, c), z._z = n;
|
|
524
524
|
} else
|
|
525
525
|
z.zone(a, c);
|
|
526
526
|
}, D.tz = function(z, c) {
|
|
527
527
|
if (z) {
|
|
528
528
|
if (typeof z != "string")
|
|
529
529
|
throw new Error("Time zone name must be a string, got " + z + " [" + typeof z + "]");
|
|
530
|
-
return this._z =
|
|
530
|
+
return this._z = K(z), this._z ? M.updateOffset(this, c) : w("Moment Timezone has no data for " + z + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
|
|
531
531
|
}
|
|
532
532
|
if (this._z)
|
|
533
533
|
return this._z.name;
|
|
@@ -548,14 +548,14 @@ var c0 = { exports: {} };
|
|
|
548
548
|
};
|
|
549
549
|
}
|
|
550
550
|
D.zoneName = p0(D.zoneName), D.zoneAbbr = p0(D.zoneAbbr), D.utc = O0(D.utc), D.local = O0(D.local), D.utcOffset = R0(D.utcOffset), M.tz.setDefault = function(z) {
|
|
551
|
-
return (R < 2 || R === 2 && T < 9) &&
|
|
551
|
+
return (R < 2 || R === 2 && T < 9) && w("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = z ? K(z) : null, M;
|
|
552
552
|
};
|
|
553
553
|
var J = M.momentProperties;
|
|
554
554
|
return Object.prototype.toString.call(J) === "[object Array]" ? (J.push("_z"), J.push("_a")) : J && (J._z = null), M;
|
|
555
555
|
});
|
|
556
556
|
})(c0);
|
|
557
|
-
var
|
|
558
|
-
const
|
|
557
|
+
var S0 = c0.exports;
|
|
558
|
+
const r0 = "2025a", U0 = [
|
|
559
559
|
"Africa/Abidjan|LMT GMT|g.8 0|01|-2ldXH.Q|48e5",
|
|
560
560
|
"Africa/Nairobi|LMT +0230 EAT +0245|-2r.g -2u -30 -2J|012132|-2ua2r.g N6nV.g 3Fbu h1cu dzbJ|47e5",
|
|
561
561
|
"Africa/Algiers|LMT PMT WET WEST CET CEST|-c.c -9.l 0 -10 -10 -20|01232323232323232454542423234542324|-3bQ0c.c MDA2.P cNb9.l HA0 19A0 1iM0 11c0 1oo0 Wo0 1rc0 QM0 1EM0 UM0 DA0 Imo0 rd0 De0 9Xz0 1fb0 1ap0 16K0 2yo0 mEp0 hwL0 jxA0 11A0 dDd0 17b0 11B0 1cN0 2Dy0 1cN0 1fB0 1cL0|26e5",
|
|
@@ -1402,12 +1402,12 @@ const U0 = "2025a", r0 = [
|
|
|
1402
1402
|
"ZM|Africa/Maputo Africa/Lusaka",
|
|
1403
1403
|
"ZW|Africa/Maputo Africa/Harare"
|
|
1404
1404
|
], V0 = {
|
|
1405
|
-
version:
|
|
1406
|
-
zones:
|
|
1405
|
+
version: r0,
|
|
1406
|
+
zones: U0,
|
|
1407
1407
|
links: B0,
|
|
1408
1408
|
countries: u0
|
|
1409
1409
|
};
|
|
1410
|
-
var t0 =
|
|
1410
|
+
var t0 = S0;
|
|
1411
1411
|
t0.tz.load(V0);
|
|
1412
1412
|
let Z;
|
|
1413
1413
|
try {
|
|
@@ -1456,16 +1456,20 @@ class C0 {
|
|
|
1456
1456
|
SIX_HOURLY: "pressure_msl,temperature_2m,temperature_2m_max,temperature_2m_min,precipitation,wind_direction_10m,wind_speed_10m,relative_humidity_2m,showers,cloud_cover"
|
|
1457
1457
|
}
|
|
1458
1458
|
});
|
|
1459
|
+
g(this, "METEO2_UPDATE", {
|
|
1460
|
+
etime: L().unix(),
|
|
1461
|
+
version: 0
|
|
1462
|
+
});
|
|
1459
1463
|
this.apikey = M || "smE3JnDLHy3TizVv", this.debug = b;
|
|
1460
1464
|
}
|
|
1461
1465
|
async standardWeatherModels() {
|
|
1462
|
-
return
|
|
1466
|
+
return k.standardWeatherModels();
|
|
1463
1467
|
}
|
|
1464
1468
|
async standardMarineModels() {
|
|
1465
|
-
return
|
|
1469
|
+
return k.standardMarineModels();
|
|
1466
1470
|
}
|
|
1467
1471
|
async autoPickMeteoModel(M = "best_match") {
|
|
1468
|
-
return
|
|
1472
|
+
return k.autoPickMeteoModel(M);
|
|
1469
1473
|
}
|
|
1470
1474
|
range(M, b, p) {
|
|
1471
1475
|
return Array.from({ length: (b - M) / p }, (O, o) => M + o * p);
|
|
@@ -1477,7 +1481,7 @@ class C0 {
|
|
|
1477
1481
|
*/
|
|
1478
1482
|
async weatherForecast(M, b = {}) {
|
|
1479
1483
|
try {
|
|
1480
|
-
const p =
|
|
1484
|
+
const p = L();
|
|
1481
1485
|
let O;
|
|
1482
1486
|
if (M.start_dates instanceof Array)
|
|
1483
1487
|
for (let Y = 0; Y < M.start_dates.length; Y++) {
|
|
@@ -1489,15 +1493,15 @@ class C0 {
|
|
|
1489
1493
|
fake: M.fake,
|
|
1490
1494
|
step: Y
|
|
1491
1495
|
});
|
|
1492
|
-
const q = await
|
|
1496
|
+
const q = await v(A, M), X = await this.parseWeatherData(q, M, b);
|
|
1493
1497
|
O ? await this.mergeSegments(O, X) : O = X;
|
|
1494
1498
|
}
|
|
1495
1499
|
else {
|
|
1496
|
-
const Y = await
|
|
1500
|
+
const Y = await v(M.url, M);
|
|
1497
1501
|
O = await this.parseWeatherData(Y, M, b);
|
|
1498
1502
|
}
|
|
1499
1503
|
delete M.apikey;
|
|
1500
|
-
const o =
|
|
1504
|
+
const o = L();
|
|
1501
1505
|
return this.debug && Z.info("[%s] fetch weather api (%j) cost: %d ms", b.requestId, M.url, o.diff(p, "ms")), O;
|
|
1502
1506
|
} catch (p) {
|
|
1503
1507
|
return Z.warn("[%s] weather forecast failed: %s, with %j", b.requestId, p, M), [];
|
|
@@ -1521,7 +1525,7 @@ class C0 {
|
|
|
1521
1525
|
*/
|
|
1522
1526
|
async marineForecast(M, b = {}) {
|
|
1523
1527
|
try {
|
|
1524
|
-
const p =
|
|
1528
|
+
const p = L();
|
|
1525
1529
|
let O;
|
|
1526
1530
|
if (M.start_dates instanceof Array)
|
|
1527
1531
|
for (let A = 0; A < M.start_dates.length; A++) {
|
|
@@ -1533,15 +1537,15 @@ class C0 {
|
|
|
1533
1537
|
fake: M.fake,
|
|
1534
1538
|
step: A
|
|
1535
1539
|
});
|
|
1536
|
-
const X = await
|
|
1540
|
+
const X = await v(q, M), R = await this.parseWeatherData(X, M, b);
|
|
1537
1541
|
O ? await this.mergeSegments(O, R) : O = R;
|
|
1538
1542
|
}
|
|
1539
1543
|
else {
|
|
1540
|
-
const A = await
|
|
1544
|
+
const A = await v(M.url, M);
|
|
1541
1545
|
O = await this.parseWeatherData(A, M, b);
|
|
1542
1546
|
}
|
|
1543
1547
|
delete M.apikey;
|
|
1544
|
-
const o =
|
|
1548
|
+
const o = L();
|
|
1545
1549
|
this.debug && Z.info("[%s] fetch marine api (%j) cost: %d ms", b.requestId, M.url, o.diff(p, "ms"));
|
|
1546
1550
|
const Y = await this.mergeMarineData(O);
|
|
1547
1551
|
return ["gfswave", "ncep_gfswave025"].includes(b.marineModels) ? [Y.at(-1)] : Y;
|
|
@@ -1557,67 +1561,67 @@ class C0 {
|
|
|
1557
1561
|
* @private
|
|
1558
1562
|
*/
|
|
1559
1563
|
async parseWeatherData(M, b, p = {}) {
|
|
1560
|
-
var Y, A, q, X, R, T, d,
|
|
1564
|
+
var Y, A, q, X, R, T, d, S, N, l;
|
|
1561
1565
|
const O = [], o = Math.pow(10, p.precision || 6);
|
|
1562
|
-
for (let
|
|
1563
|
-
const
|
|
1564
|
-
if (
|
|
1565
|
-
const
|
|
1566
|
-
|
|
1567
|
-
time:
|
|
1566
|
+
for (let V = 0; V < M.length; V++) {
|
|
1567
|
+
const E = M[V], h = E.utcOffsetSeconds(), y = E.timezone(), _ = E.current(), I = E.hourly(), G = E.sixHourly(), Q = E.daily(), P = {};
|
|
1568
|
+
if (P.timezone = y || void 0, P.offset = this.prettyTimezoneOffset(h), P.model = b.models instanceof Array ? (Y = b.models) == null ? void 0 : Y[V] : b.models || "best_match", _) {
|
|
1569
|
+
const H = L();
|
|
1570
|
+
P.current = {
|
|
1571
|
+
time: L.unix(Number(_.time())).utc().format()
|
|
1568
1572
|
};
|
|
1569
|
-
for (let s = 0; s <
|
|
1570
|
-
const
|
|
1571
|
-
|
|
1573
|
+
for (let s = 0; s < _.variablesLength(); s++) {
|
|
1574
|
+
const u = _.variables(s).value();
|
|
1575
|
+
P.current[b.current[s]] = isNaN(u) ? null : Math.round(u * o) / o;
|
|
1572
1576
|
}
|
|
1573
|
-
const m =
|
|
1574
|
-
this.debug && Z.debug("[%s] fetch current variables cost: %d ms", p.requestId, m.diff(
|
|
1577
|
+
const m = L();
|
|
1578
|
+
this.debug && Z.debug("[%s] fetch current variables cost: %d ms", p.requestId, m.diff(H, "ms"));
|
|
1575
1579
|
}
|
|
1576
|
-
if (
|
|
1577
|
-
const
|
|
1578
|
-
|
|
1580
|
+
if (I) {
|
|
1581
|
+
const H = L(), m = L.unix(Number(I.time())).add(b.fake ? 1 : 0, "year");
|
|
1582
|
+
P.hourly = {
|
|
1579
1583
|
date: m.utc().format(),
|
|
1580
|
-
time: this.range(Number(
|
|
1581
|
-
(
|
|
1584
|
+
time: this.range(Number(I.time()), Number(I.timeEnd()), I.interval()).map(
|
|
1585
|
+
(u) => L.unix(u).add(b.fake ? 1 : 0, "year").diff(m, "h")
|
|
1582
1586
|
)
|
|
1583
1587
|
};
|
|
1584
|
-
for (let
|
|
1585
|
-
const
|
|
1586
|
-
|
|
1588
|
+
for (let u = 0; u < I.variablesLength(); u++) {
|
|
1589
|
+
const F = (X = (q = (A = I.variables(u).valuesArray()) == null ? void 0 : A.toString()) == null ? void 0 : q.split(",")) == null ? void 0 : X.map((C) => isNaN(C) ? null : Math.round(Number(C) * o) / o);
|
|
1590
|
+
P.hourly[b.hourly[u]] = F;
|
|
1587
1591
|
}
|
|
1588
|
-
const s =
|
|
1589
|
-
this.debug && Z.debug("[%s] fetch hourly variables cost: %d ms", p.requestId, s.diff(
|
|
1592
|
+
const s = L();
|
|
1593
|
+
this.debug && Z.debug("[%s] fetch hourly variables cost: %d ms", p.requestId, s.diff(H, "ms"));
|
|
1590
1594
|
}
|
|
1591
1595
|
if (G) {
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1596
|
+
const H = L(), m = L.unix(Number(G.time())).add(b.fake ? 1 : 0, "year");
|
|
1597
|
+
P.sixHourly = {
|
|
1594
1598
|
date: m.utc().format(),
|
|
1595
1599
|
time: this.range(Number(G.time()), Number(G.timeEnd()), G.interval()).map(
|
|
1596
|
-
(
|
|
1600
|
+
(u) => L.unix(u).add(b.fake ? 1 : 0, "year").diff(m, "h")
|
|
1597
1601
|
)
|
|
1598
1602
|
};
|
|
1599
|
-
for (let
|
|
1600
|
-
const
|
|
1601
|
-
G.variables(
|
|
1603
|
+
for (let u = 0; u < G.variablesLength(); u += p.memberLength ?? 1) {
|
|
1604
|
+
const F = (d = (T = (R = G.variables(u).valuesArray()) == null ? void 0 : R.toString()) == null ? void 0 : T.split(",")) == null ? void 0 : d.map((C) => isNaN(C) ? null : Math.round(Number(C) * o) / o);
|
|
1605
|
+
G.variables(u), P.sixHourly[b.six_hourly[u / (p.memberLength ?? 1)]] = F;
|
|
1602
1606
|
}
|
|
1603
|
-
const s =
|
|
1604
|
-
this.debug && Z.debug("[%s] fetch 6-hourly variables cost: %d ms", p.requestId, s.diff(
|
|
1607
|
+
const s = L();
|
|
1608
|
+
this.debug && Z.debug("[%s] fetch 6-hourly variables cost: %d ms", p.requestId, s.diff(H, "ms"));
|
|
1605
1609
|
}
|
|
1606
|
-
if (
|
|
1607
|
-
const
|
|
1608
|
-
|
|
1609
|
-
time: this.range(Number(
|
|
1610
|
-
(s) =>
|
|
1610
|
+
if (Q) {
|
|
1611
|
+
const H = L();
|
|
1612
|
+
P.daily = {
|
|
1613
|
+
time: this.range(Number(Q.time()), Number(Q.timeEnd()), Q.interval()).map(
|
|
1614
|
+
(s) => L.unix(s).add(b.fake ? 1 : 0, "year").utc().format()
|
|
1611
1615
|
)
|
|
1612
1616
|
};
|
|
1613
|
-
for (let s = 0; s <
|
|
1614
|
-
const
|
|
1615
|
-
|
|
1617
|
+
for (let s = 0; s < Q.variablesLength(); s += p.memberLength ?? 1) {
|
|
1618
|
+
const u = (l = (N = (S = Q.variables(s).valuesArray()) == null ? void 0 : S.toString()) == null ? void 0 : N.split(",")) == null ? void 0 : l.map((F) => isNaN(F) ? null : Math.round(Number(F) * o) / o);
|
|
1619
|
+
P.daily[b.daily[s / (p.memberLength ?? 1)]] = u;
|
|
1616
1620
|
}
|
|
1617
|
-
const m =
|
|
1618
|
-
this.debug && Z.debug("[%s] fetch daily variables cost: %d ms", p.requestId, m.diff(
|
|
1621
|
+
const m = L();
|
|
1622
|
+
this.debug && Z.debug("[%s] fetch daily variables cost: %d ms", p.requestId, m.diff(H, "ms"));
|
|
1619
1623
|
}
|
|
1620
|
-
O.push(
|
|
1624
|
+
O.push(P);
|
|
1621
1625
|
}
|
|
1622
1626
|
return O;
|
|
1623
1627
|
}
|
|
@@ -1671,7 +1675,7 @@ class C0 {
|
|
|
1671
1675
|
* @private
|
|
1672
1676
|
*/
|
|
1673
1677
|
prepare(M, b, p, O = {}) {
|
|
1674
|
-
const o =
|
|
1678
|
+
const o = L().utc(), Y = M ? L.utc(M) : void 0, A = o.clone().utc().add(b ? 9 : 14, "day");
|
|
1675
1679
|
if (M) {
|
|
1676
1680
|
const q = Y.clone().utc().add(O.forecastDays ?? 1, "day");
|
|
1677
1681
|
q.isAfter(A) ? (q.subtract(1, "year"), Y.isAfter(A) ? (Y.subtract(1, "year"), p.start_dates = [
|
|
@@ -1692,7 +1696,7 @@ class C0 {
|
|
|
1692
1696
|
return Math.round(M * p) / p;
|
|
1693
1697
|
}
|
|
1694
1698
|
timezoneOffset(M, b) {
|
|
1695
|
-
const p =
|
|
1699
|
+
const p = N0(M, b), O = L().tz(p).utcOffset();
|
|
1696
1700
|
return Math.round(O / 60 * 10) / 10;
|
|
1697
1701
|
}
|
|
1698
1702
|
/**
|
|
@@ -1737,7 +1741,7 @@ class C0 {
|
|
|
1737
1741
|
precision: 6,
|
|
1738
1742
|
selfHosted: !0
|
|
1739
1743
|
}) {
|
|
1740
|
-
var
|
|
1744
|
+
var S, N, l;
|
|
1741
1745
|
b = this.toStdLng(b), this.debug && Z.info("[%s] spot forecast params: %j", A.requestId, { lat: M, lng: b, datetime: p, simplify: O, withDaily: o, withHourly: Y, options: A });
|
|
1742
1746
|
const q = {
|
|
1743
1747
|
apikey: this.apikey,
|
|
@@ -1745,15 +1749,15 @@ class C0 {
|
|
|
1745
1749
|
longitude: b,
|
|
1746
1750
|
cell_selection: "sea",
|
|
1747
1751
|
wind_speed_unit: "kn",
|
|
1748
|
-
models: ((
|
|
1752
|
+
models: ((S = A.weatherModels) == null ? void 0 : S.split(",")) || ["best_match"],
|
|
1749
1753
|
timezone: "auto"
|
|
1750
1754
|
};
|
|
1751
1755
|
let X;
|
|
1752
1756
|
if (p) {
|
|
1753
|
-
const
|
|
1754
|
-
X =
|
|
1757
|
+
const V = this.timezoneOffset(M, b);
|
|
1758
|
+
X = L.utc(p).utcOffset(V), X.subtract(V > 0 ? V : -V, "h");
|
|
1755
1759
|
}
|
|
1756
|
-
o && (q.daily = ((
|
|
1760
|
+
o && (q.daily = ((N = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : N.split(",")) || []), X || (A.forecastDays = A.forecastDays || 1, A.pastDays = 0, Y = !0), Y && (q.hourly = ((l = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : l.split(",")) || []), 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 > 14 ? 14 : A.forecastDays < 0 ? 1 : A.forecastDays, this.prepare(X == null ? void 0 : X.utc().format(), !1, q, A);
|
|
1757
1761
|
const R = await this.weatherForecast(q, A), T = {
|
|
1758
1762
|
apikey: this.apikey,
|
|
1759
1763
|
latitude: M,
|
|
@@ -1791,9 +1795,9 @@ class C0 {
|
|
|
1791
1795
|
async spotHistorical(M, b, p, O, o = !0, Y = !0, A = !1, q = {
|
|
1792
1796
|
precision: 6
|
|
1793
1797
|
}) {
|
|
1794
|
-
var
|
|
1798
|
+
var l, V;
|
|
1795
1799
|
b = this.toStdLng(b), this.debug && Z.info("[%s] spot historical params: %j", q.requestId, { lat: M, lng: b, startDate: p, endDate: O, withMarine: A, options: q });
|
|
1796
|
-
const X = this.timezoneOffset(M, b), R =
|
|
1800
|
+
const X = this.timezoneOffset(M, b), R = L.utc(p).utcOffset(X), T = L.utc(O).utcOffset(X);
|
|
1797
1801
|
R.subtract(X > 0 ? X : -X, "h"), T.subtract(X > 0 ? X : -X, "h");
|
|
1798
1802
|
const d = {
|
|
1799
1803
|
apikey: this.apikey,
|
|
@@ -1801,33 +1805,33 @@ class C0 {
|
|
|
1801
1805
|
longitude: b,
|
|
1802
1806
|
cell_selection: "sea",
|
|
1803
1807
|
wind_speed_unit: "kn",
|
|
1804
|
-
models: ((
|
|
1808
|
+
models: ((l = q.weatherModels) == null ? void 0 : l.split(",")) || ["best_match"],
|
|
1805
1809
|
timezone: "auto",
|
|
1806
1810
|
url: this.HISTORICAL.OM_URL,
|
|
1807
1811
|
start_date: R.format("YYYY-MM-DD"),
|
|
1808
1812
|
end_date: T.format("YYYY-MM-DD")
|
|
1809
1813
|
};
|
|
1810
1814
|
o && (d.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), Y && (d.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
|
|
1811
|
-
const
|
|
1812
|
-
let
|
|
1815
|
+
const S = await this.weatherForecast(d, q);
|
|
1816
|
+
let N;
|
|
1813
1817
|
if (A) {
|
|
1814
|
-
const
|
|
1818
|
+
const E = {
|
|
1815
1819
|
apikey: this.apikey,
|
|
1816
1820
|
latitude: M,
|
|
1817
1821
|
longitude: b,
|
|
1818
1822
|
cell_selection: "sea",
|
|
1819
1823
|
timezone: "auto",
|
|
1820
1824
|
wind_speed_unit: "kn",
|
|
1821
|
-
models: ((
|
|
1825
|
+
models: ((V = q.marineModels) == null ? void 0 : V.split(",")) || ["best_match"],
|
|
1822
1826
|
daily: this.FORECAST.MARINE_VARIABLES.DAILY.split(","),
|
|
1823
1827
|
hourly: this.FORECAST.MARINE_VARIABLES.HOURLY.split(","),
|
|
1824
1828
|
url: this.FORECAST.OM_MARINE_URL,
|
|
1825
1829
|
start_date: R.format("YYYY-MM-DD"),
|
|
1826
1830
|
end_date: T.format("YYYY-MM-DD")
|
|
1827
1831
|
};
|
|
1828
|
-
|
|
1832
|
+
N = await this.marineForecast(E, q);
|
|
1829
1833
|
}
|
|
1830
|
-
return { weather:
|
|
1834
|
+
return { weather: S, marine: N };
|
|
1831
1835
|
}
|
|
1832
1836
|
/**
|
|
1833
1837
|
* 季节预报数据
|
|
@@ -1844,7 +1848,7 @@ class C0 {
|
|
|
1844
1848
|
precision: 6
|
|
1845
1849
|
}) {
|
|
1846
1850
|
b = this.toStdLng(b), this.debug && Z.info("[%s] spot seasonal params: %j", Y.requestId, { lat: M, lng: b, startDate: p, endDate: O, options: Y });
|
|
1847
|
-
const A = this.timezoneOffset(M, b), q =
|
|
1851
|
+
const A = this.timezoneOffset(M, b), q = L.utc(p).utcOffset(A), X = O ? L.utc(O).utcOffset(A) : q.clone().add(1, "month");
|
|
1848
1852
|
q.subtract(A > 0 ? A : -A, "h"), X.subtract(A > 0 ? A : -A, "h");
|
|
1849
1853
|
const R = {
|
|
1850
1854
|
apikey: this.apikey,
|
|
@@ -1885,7 +1889,7 @@ class C0 {
|
|
|
1885
1889
|
}) {
|
|
1886
1890
|
var T;
|
|
1887
1891
|
b = this.toStdLng(b), this.debug && Z.info("[%s] spot climate params: %j", o.requestId, { lat: M, lng: b, startDate: p, endDate: O, options: o });
|
|
1888
|
-
const Y = this.timezoneOffset(M, b), A =
|
|
1892
|
+
const Y = this.timezoneOffset(M, b), A = L.utc(p).utcOffset(Y), q = O ? L.utc(O).utcOffset(Y) : A.clone().add(1, "day");
|
|
1889
1893
|
q.subtract(Y > 0 ? Y : -Y, "h"), A.subtract(Y > 0 ? Y : -Y, "h");
|
|
1890
1894
|
const X = {
|
|
1891
1895
|
apikey: this.apikey,
|
|
@@ -1902,6 +1906,39 @@ class C0 {
|
|
|
1902
1906
|
};
|
|
1903
1907
|
return { weather: await this.weatherForecast(X, o) };
|
|
1904
1908
|
}
|
|
1909
|
+
async update(M = {}) {
|
|
1910
|
+
const b = L.unix(this.METEO2_UPDATE.etime), p = this.METEO2_UPDATE.version, O = L();
|
|
1911
|
+
if (!p || b.clone().add(10, "minute").isBefore(O)) {
|
|
1912
|
+
const A = await (await fetch("https://meteo2agent.idmwx.com/api/agents/update", {
|
|
1913
|
+
headers: {
|
|
1914
|
+
"Content-Type": "application/json",
|
|
1915
|
+
Authorization: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsYmY5M3I0YTAwMDE4Ymx0NWJ4emFwNWMiLCJyb2xlIjoyMDQ3LCJpYXQiOjE2NzA1NTM0NzAsImV4cCI6Mzg3ODA3MzQ3MH0.MxTv0yLGarZCtOSCZfJHMqrXNMNN0-OL4gBGKGcYcc8"
|
|
1916
|
+
}
|
|
1917
|
+
})).json();
|
|
1918
|
+
if (A.code === 0) {
|
|
1919
|
+
const q = A.data, X = k.standardWeatherModels();
|
|
1920
|
+
for (const R of X) {
|
|
1921
|
+
const T = k.autoPickSubCategories(R.alias), S = q.filter((N) => T.includes(N.category)).map((N) => {
|
|
1922
|
+
var l, V, E, h, y, _;
|
|
1923
|
+
return {
|
|
1924
|
+
category: N.category,
|
|
1925
|
+
meta: {
|
|
1926
|
+
endTime: L.unix((l = N.meta) == null ? void 0 : l.data_end_time).utc().format(),
|
|
1927
|
+
availabilityTime: L.unix((V = N.meta) == null ? void 0 : V.last_run_availability_time).utc().format(),
|
|
1928
|
+
initialisationTime: L.unix((E = N.meta) == null ? void 0 : E.last_run_initialisation_time).utc().format(),
|
|
1929
|
+
modificationTime: L.unix((h = N.meta) == null ? void 0 : h.last_run_modification_time).utc().format(),
|
|
1930
|
+
temporalResolution: Math.round(((y = N.meta) == null ? void 0 : y.temporal_resolution_seconds) / 3600),
|
|
1931
|
+
frequency: Math.round(((_ = N.meta) == null ? void 0 : _.update_interval_seconds) / 3600)
|
|
1932
|
+
}
|
|
1933
|
+
};
|
|
1934
|
+
});
|
|
1935
|
+
R.update.length && (this.METEO2_UPDATE[R.alias] = S);
|
|
1936
|
+
}
|
|
1937
|
+
this.METEO2_UPDATE.version = p + 1, this.METEO2_UPDATE.etime = O.unix();
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
return this.METEO2_UPDATE;
|
|
1941
|
+
}
|
|
1905
1942
|
}
|
|
1906
1943
|
let W0;
|
|
1907
1944
|
try {
|