@idm-plugin/meteo2 0.5.4 → 0.5.6
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 +103 -101
- package/dist/index.umd.cjs +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,9 +3,9 @@ var n0 = (f, M, b) => M in f ? L0(f, M, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var H = (f, M, b) => (n0(f, typeof M != "symbol" ? M + "" : M, b), b);
|
|
4
4
|
import M0 from "@log4js-node/log4js-api";
|
|
5
5
|
import L from "moment";
|
|
6
|
-
import
|
|
6
|
+
import k from "got";
|
|
7
7
|
import { fetchWeatherApi as $ } from "openmeteo";
|
|
8
|
-
import { Meteo2Assist as
|
|
8
|
+
import { Meteo2Assist as v } from "@idm-plugin/meteo";
|
|
9
9
|
let U;
|
|
10
10
|
try {
|
|
11
11
|
U = M0.getLogger("meteo");
|
|
@@ -34,9 +34,9 @@ class m0 {
|
|
|
34
34
|
source: Y == null ? void 0 : Y.toLowerCase()
|
|
35
35
|
},
|
|
36
36
|
timeout: 3e4
|
|
37
|
-
},
|
|
38
|
-
A.isBefore(
|
|
39
|
-
const n = "https://aod4idm.idmwx.com/api/ocean/point", o = await
|
|
37
|
+
}, a = L(), R = a.valueOf();
|
|
38
|
+
A.isBefore(a.subtract(1, "month")) && (U == null || U.warn("[%s] get history meteo on %s: %j", d.requestId, A.format(), q));
|
|
39
|
+
const n = "https://aod4idm.idmwx.com/api/ocean/point", o = await k.get(n, q).json(), S = L().valueOf();
|
|
40
40
|
if (U == null || U.info("[%s] get meteo(cost: %d ms) from %s with options: %j", d.requestId, S - R, n, q), (o == null ? void 0 : o.code) === 0)
|
|
41
41
|
return {
|
|
42
42
|
...o.data,
|
|
@@ -69,9 +69,9 @@ class m0 {
|
|
|
69
69
|
source: Y == null ? void 0 : Y.toLowerCase()
|
|
70
70
|
},
|
|
71
71
|
timeout: 3e4
|
|
72
|
-
},
|
|
73
|
-
A.isBefore(
|
|
74
|
-
const n = "https://aod4idm.idmwx.com/api/ocean/factor", o = await
|
|
72
|
+
}, a = L(), R = a.valueOf();
|
|
73
|
+
A.isBefore(a.subtract(1, "month")) && (U == null || U.warn("[%s] get history factors on %s: %j", d.requestId, A.format(), q));
|
|
74
|
+
const n = "https://aod4idm.idmwx.com/api/ocean/factor", o = await k.get(n, q).json(), S = L().valueOf();
|
|
75
75
|
if (U == null || U.info("[%s] get factors(cost: %d ms) from %s with options: %j", d.requestId, S - R, n, q), (o == null ? void 0 : o.code) === 0)
|
|
76
76
|
return {
|
|
77
77
|
...o.data,
|
|
@@ -87,7 +87,7 @@ class m0 {
|
|
|
87
87
|
const Y = "https://api.windy.com/api/point-forecast/v2", d = [];
|
|
88
88
|
try {
|
|
89
89
|
let A = L().valueOf();
|
|
90
|
-
const q = await
|
|
90
|
+
const q = await k.post(Y, {
|
|
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
|
|
120
|
-
U == null || U.info("[%s] get gfs-factors(cost: %d ms) from %s", O.requestId,
|
|
121
|
-
const R = await
|
|
119
|
+
let a = L().valueOf();
|
|
120
|
+
U == null || U.info("[%s] get gfs-factors(cost: %d ms) from %s", O.requestId, a - A, Y), A = a;
|
|
121
|
+
const R = await k.post(Y, {
|
|
122
122
|
headers: {
|
|
123
123
|
"Content-Type": "application/json"
|
|
124
124
|
},
|
|
@@ -131,7 +131,7 @@ class m0 {
|
|
|
131
131
|
levels: ["surface"]
|
|
132
132
|
}
|
|
133
133
|
}).json();
|
|
134
|
-
|
|
134
|
+
a = L().valueOf(), U == null || U.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", O.requestId, a - A, Y);
|
|
135
135
|
for (let o = 0; o < q.ts.length; o++) {
|
|
136
136
|
const S = this.populateUVFactor(q["wind_u-surface"][o], q["wind_v-surface"][o], !1, O);
|
|
137
137
|
S.scale = this.calculateBeaufortWindForceScale(S.speed), d.push({
|
|
@@ -269,9 +269,9 @@ var A0 = { exports: {} };
|
|
|
269
269
|
throw new RangeError("invalid coordinates");
|
|
270
270
|
if (90 <= b)
|
|
271
271
|
return "Etc/GMT";
|
|
272
|
-
var d = -1, A = 48 * (180 + p) / 360.00000000000006, q = 24 * (90 - b) / 180.00000000000003,
|
|
272
|
+
var d = -1, A = 48 * (180 + p) / 360.00000000000006, q = 24 * (90 - b) / 180.00000000000003, a = 0 | A, R = 0 | q, n = 96 * R + 2 * a;
|
|
273
273
|
for (n = 56 * O.charCodeAt(n) + O.charCodeAt(n + 1) - 1995; n + Y.length < 3136; )
|
|
274
|
-
n = 56 * O.charCodeAt(n = 8 * (d = d + n + 1) + 4 * (R = 0 | (q = 2 * (q - R) % 2)) + 2 * (
|
|
274
|
+
n = 56 * O.charCodeAt(n = 8 * (d = d + n + 1) + 4 * (R = 0 | (q = 2 * (q - R) % 2)) + 2 * (a = 0 | (A = 2 * (A - a) % 2)) + 2304) + O.charCodeAt(n + 1) - 1995;
|
|
275
275
|
return Y[n + Y.length - 3136];
|
|
276
276
|
}
|
|
277
277
|
f.exports = M;
|
|
@@ -291,15 +291,15 @@ var c0 = { exports: {} };
|
|
|
291
291
|
M.version === void 0 && M.default && (M = M.default);
|
|
292
292
|
var b = "0.5.48", p = {}, O = {}, Y = {}, d = {}, A = {}, q;
|
|
293
293
|
(!M || typeof M.version != "string") && y("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
294
|
-
var
|
|
294
|
+
var a = M.version.split("."), R = +a[0], n = +a[1];
|
|
295
295
|
(R < 2 || R === 2 && n < 6) && y("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
|
|
296
296
|
function o(z) {
|
|
297
297
|
return z > 96 ? z - 87 : z > 64 ? z - 29 : z - 48;
|
|
298
298
|
}
|
|
299
299
|
function S(z) {
|
|
300
|
-
var c = 0, W = z.split("."),
|
|
301
|
-
for (z.charCodeAt(0) === 45 && (c = 1, t = -1), c; c <
|
|
302
|
-
Z = o(
|
|
300
|
+
var c = 0, W = z.split("."), X = W[0], T = W[1] || "", N = 1, Z, r = 0, t = 1;
|
|
301
|
+
for (z.charCodeAt(0) === 45 && (c = 1, t = -1), c; c < X.length; c++)
|
|
302
|
+
Z = o(X.charCodeAt(c)), r = 60 * r + Z;
|
|
303
303
|
for (c = 0; c < T.length; c++)
|
|
304
304
|
N = N / 60, Z = o(T.charCodeAt(c)), r += Z * N;
|
|
305
305
|
return r * t;
|
|
@@ -314,17 +314,17 @@ var c0 = { exports: {} };
|
|
|
314
314
|
z[c - 1] = 1 / 0;
|
|
315
315
|
}
|
|
316
316
|
function u(z, c) {
|
|
317
|
-
var W = [],
|
|
318
|
-
for (
|
|
319
|
-
W[
|
|
317
|
+
var W = [], X;
|
|
318
|
+
for (X = 0; X < c.length; X++)
|
|
319
|
+
W[X] = z[c[X]];
|
|
320
320
|
return W;
|
|
321
321
|
}
|
|
322
322
|
function V(z) {
|
|
323
|
-
var c = z.split("|"), W = c[2].split(" "),
|
|
324
|
-
return i(W), i(
|
|
323
|
+
var c = z.split("|"), W = c[2].split(" "), X = c[3].split(""), T = c[4].split(" ");
|
|
324
|
+
return i(W), i(X), i(T), l(T, X.length), {
|
|
325
325
|
name: c[0],
|
|
326
|
-
abbrs: u(c[1].split(" "),
|
|
327
|
-
offsets: u(W,
|
|
326
|
+
abbrs: u(c[1].split(" "), X),
|
|
327
|
+
offsets: u(W, X),
|
|
328
328
|
untils: T,
|
|
329
329
|
population: c[5] | 0
|
|
330
330
|
};
|
|
@@ -340,8 +340,8 @@ var c0 = { exports: {} };
|
|
|
340
340
|
return W - 1;
|
|
341
341
|
if (z >= c[W - 1])
|
|
342
342
|
return -1;
|
|
343
|
-
for (var
|
|
344
|
-
|
|
343
|
+
for (var X, T = 0, N = W - 1; N - T > 1; )
|
|
344
|
+
X = Math.floor((T + N) / 2), c[X] <= z ? T = X : N = X;
|
|
345
345
|
return N;
|
|
346
346
|
}
|
|
347
347
|
E.prototype = {
|
|
@@ -349,9 +349,9 @@ var c0 = { exports: {} };
|
|
|
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
|
-
var c = +z, W = this.untils,
|
|
353
|
-
if (
|
|
354
|
-
return
|
|
352
|
+
var c = +z, W = this.untils, X;
|
|
353
|
+
if (X = e(c, W), X >= 0)
|
|
354
|
+
return X;
|
|
355
355
|
},
|
|
356
356
|
countries: function() {
|
|
357
357
|
var z = this.name;
|
|
@@ -360,9 +360,9 @@ var c0 = { exports: {} };
|
|
|
360
360
|
});
|
|
361
361
|
},
|
|
362
362
|
parse: function(z) {
|
|
363
|
-
var c = +z, W = this.offsets,
|
|
363
|
+
var c = +z, W = this.offsets, X = this.untils, T = X.length - 1, N, Z, r, t;
|
|
364
364
|
for (t = 0; t < T; t++)
|
|
365
|
-
if (N = W[t], Z = W[t + 1], r = W[t && t - 1], N < Z && B.moveAmbiguousForward ? N = Z : N > r && B.moveInvalidForward && (N = r), c <
|
|
365
|
+
if (N = W[t], Z = W[t + 1], r = W[t && t - 1], N < Z && B.moveAmbiguousForward ? N = Z : N > r && B.moveInvalidForward && (N = r), c < X[t] - N * 6e4)
|
|
366
366
|
return W[t];
|
|
367
367
|
return W[T];
|
|
368
368
|
},
|
|
@@ -390,28 +390,28 @@ var c0 = { exports: {} };
|
|
|
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
392
|
function F(z, c) {
|
|
393
|
-
for (var W,
|
|
394
|
-
W = new P(new Date(z.at +
|
|
393
|
+
for (var W, X; X = ((c.at - z.at) / 12e4 | 0) * 6e4; )
|
|
394
|
+
W = new P(new Date(z.at + X)), W.offset === z.offset ? z = W : c = W;
|
|
395
395
|
return z;
|
|
396
396
|
}
|
|
397
397
|
function C() {
|
|
398
|
-
var z = (/* @__PURE__ */ new Date()).getFullYear() - 2, c = new P(new Date(z, 0, 1)), W = c.offset,
|
|
398
|
+
var z = (/* @__PURE__ */ new Date()).getFullYear() - 2, c = new P(new Date(z, 0, 1)), W = c.offset, X = [c], T, N, Z, r;
|
|
399
399
|
for (r = 1; r < 48; r++)
|
|
400
|
-
Z = new Date(z, r, 1).getTimezoneOffset(), Z !== W && (N = new P(new Date(z, r, 1)), T = F(c, N),
|
|
400
|
+
Z = new Date(z, r, 1).getTimezoneOffset(), Z !== W && (N = new P(new Date(z, r, 1)), T = F(c, N), X.push(T), X.push(new P(new Date(T.at + 6e4))), c = N, W = Z);
|
|
401
401
|
for (r = 0; r < 4; r++)
|
|
402
|
-
|
|
403
|
-
return
|
|
402
|
+
X.push(new P(new Date(z + r, 0, 1))), X.push(new P(new Date(z + r, 6, 1)));
|
|
403
|
+
return X;
|
|
404
404
|
}
|
|
405
405
|
function Q(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 h(z, c) {
|
|
409
|
-
var W,
|
|
409
|
+
var W, X;
|
|
410
410
|
for (i(c), W = 0; W < c.length; W++)
|
|
411
|
-
|
|
411
|
+
X = c[W], A[X] = A[X] || {}, A[X][z] = !0;
|
|
412
412
|
}
|
|
413
413
|
function I(z) {
|
|
414
|
-
var c = z.length, W = {},
|
|
414
|
+
var c = z.length, W = {}, X = [], T = {}, N, Z, r, t;
|
|
415
415
|
for (N = 0; N < c; N++)
|
|
416
416
|
if (r = z[N].offset, !T.hasOwnProperty(r)) {
|
|
417
417
|
t = A[r] || {};
|
|
@@ -420,8 +420,8 @@ var c0 = { exports: {} };
|
|
|
420
420
|
T[r] = !0;
|
|
421
421
|
}
|
|
422
422
|
for (N in W)
|
|
423
|
-
W.hasOwnProperty(N) &&
|
|
424
|
-
return
|
|
423
|
+
W.hasOwnProperty(N) && X.push(d[N]);
|
|
424
|
+
return X;
|
|
425
425
|
}
|
|
426
426
|
function s() {
|
|
427
427
|
try {
|
|
@@ -434,9 +434,9 @@ var c0 = { exports: {} };
|
|
|
434
434
|
}
|
|
435
435
|
} catch {
|
|
436
436
|
}
|
|
437
|
-
var W = C(),
|
|
437
|
+
var W = C(), X = W.length, T = I(W), N = [], Z, r, t;
|
|
438
438
|
for (r = 0; r < T.length; r++) {
|
|
439
|
-
for (Z = new m(_(T[r])), t = 0; t <
|
|
439
|
+
for (Z = new m(_(T[r])), t = 0; t < X; t++)
|
|
440
440
|
Z.scoreOffsetAt(W[t]);
|
|
441
441
|
N.push(Z);
|
|
442
442
|
}
|
|
@@ -449,14 +449,14 @@ var c0 = { exports: {} };
|
|
|
449
449
|
return (z || "").toLowerCase().replace(/\//g, "_");
|
|
450
450
|
}
|
|
451
451
|
function z0(z) {
|
|
452
|
-
var c, W,
|
|
452
|
+
var c, W, X, T;
|
|
453
453
|
for (typeof z == "string" && (z = [z]), c = 0; c < z.length; c++)
|
|
454
|
-
|
|
454
|
+
X = z[c].split("|"), W = X[0], T = K(W), p[T] = z[c], d[T] = W, h(T, X[2].split(" "));
|
|
455
455
|
}
|
|
456
456
|
function _(z, c) {
|
|
457
457
|
z = K(z);
|
|
458
|
-
var W = p[z],
|
|
459
|
-
return W instanceof E ? W : typeof W == "string" ? (W = new E(W), p[z] = W, W) : O[z] && c !== _ && (
|
|
458
|
+
var W = p[z], X;
|
|
459
|
+
return W instanceof E ? W : typeof W == "string" ? (W = new E(W), p[z] = W, W) : O[z] && c !== _ && (X = _(O[z], _)) ? (W = p[z] = new E(), W._set(X), W.name = d[z], W) : null;
|
|
460
460
|
}
|
|
461
461
|
function q0() {
|
|
462
462
|
var z, c = [];
|
|
@@ -468,17 +468,17 @@ var c0 = { exports: {} };
|
|
|
468
468
|
return Object.keys(Y);
|
|
469
469
|
}
|
|
470
470
|
function b0(z) {
|
|
471
|
-
var c, W,
|
|
471
|
+
var c, W, X, T;
|
|
472
472
|
for (typeof z == "string" && (z = [z]), c = 0; c < z.length; c++)
|
|
473
|
-
W = z[c].split("|"),
|
|
473
|
+
W = z[c].split("|"), X = K(W[0]), T = K(W[1]), O[X] = T, d[X] = W[0], O[T] = X, d[T] = W[1];
|
|
474
474
|
}
|
|
475
475
|
function Y0(z) {
|
|
476
|
-
var c, W,
|
|
476
|
+
var c, W, X, T;
|
|
477
477
|
if (!(!z || !z.length))
|
|
478
478
|
for (c = 0; c < z.length; c++)
|
|
479
|
-
T = z[c].split("|"), W = T[0].toUpperCase(),
|
|
479
|
+
T = z[c].split("|"), W = T[0].toUpperCase(), X = T[1].split(" "), Y[W] = new D(
|
|
480
480
|
W,
|
|
481
|
-
|
|
481
|
+
X
|
|
482
482
|
);
|
|
483
483
|
}
|
|
484
484
|
function d0(z) {
|
|
@@ -488,10 +488,10 @@ var c0 = { exports: {} };
|
|
|
488
488
|
if (z = d0(z), !z)
|
|
489
489
|
return null;
|
|
490
490
|
var W = z.zones.sort();
|
|
491
|
-
return c ? W.map(function(
|
|
492
|
-
var T = _(
|
|
491
|
+
return c ? W.map(function(X) {
|
|
492
|
+
var T = _(X);
|
|
493
493
|
return {
|
|
494
|
-
name:
|
|
494
|
+
name: X,
|
|
495
495
|
offset: T.utcOffset(/* @__PURE__ */ new Date())
|
|
496
496
|
};
|
|
497
497
|
}) : W;
|
|
@@ -510,19 +510,19 @@ var c0 = { exports: {} };
|
|
|
510
510
|
typeof console < "u" && typeof console.error == "function" && console.error(z);
|
|
511
511
|
}
|
|
512
512
|
function B(z) {
|
|
513
|
-
var c = Array.prototype.slice.call(arguments, 0, -1), W = arguments[arguments.length - 1],
|
|
514
|
-
return !M.isMoment(z) && x(
|
|
513
|
+
var c = Array.prototype.slice.call(arguments, 0, -1), W = arguments[arguments.length - 1], X = M.utc.apply(null, c), T;
|
|
514
|
+
return !M.isMoment(z) && x(X) && (T = _(W)) && X.add(T.parse(X), "minutes"), X.tz(W), X;
|
|
515
515
|
}
|
|
516
516
|
B.version = b, B.dataVersion = "", B._zones = p, B._links = O, B._names = d, B._countries = Y, B.add = z0, B.link = b0, B.load = X0, B.zone = _, B.zoneExists = j, B.guess = w, B.names = q0, B.Zone = E, B.unpack = V, B.unpackBase60 = S, B.needsOffset = x, B.moveInvalidForward = !0, B.moveAmbiguousForward = !1, B.countries = o0, B.zonesForCountry = a0;
|
|
517
517
|
var g = M.fn;
|
|
518
518
|
M.tz = B, M.defaultZone = null, M.updateOffset = function(z, c) {
|
|
519
|
-
var W = M.defaultZone,
|
|
519
|
+
var W = M.defaultZone, X;
|
|
520
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
|
-
if (
|
|
521
|
+
if (X = z._z.utcOffset(z), Math.abs(X) < 16 && (X = X / 60), z.utcOffset !== void 0) {
|
|
522
522
|
var T = z._z;
|
|
523
|
-
z.utcOffset(-
|
|
523
|
+
z.utcOffset(-X, c), z._z = T;
|
|
524
524
|
} else
|
|
525
|
-
z.zone(
|
|
525
|
+
z.zone(X, c);
|
|
526
526
|
}, g.tz = function(z, c) {
|
|
527
527
|
if (z) {
|
|
528
528
|
if (typeof z != "string")
|
|
@@ -1423,9 +1423,11 @@ class C0 {
|
|
|
1423
1423
|
H(this, "FORECAST", {
|
|
1424
1424
|
OM_URL: "https://customer-api.open-meteo.com/v1/forecast",
|
|
1425
1425
|
ORM_URL: "https://meteo3.idmwx.com/v1/forecast",
|
|
1426
|
+
ORM_HISTORY_URL: "https://meteo1.idmwx.com/v1/forecast",
|
|
1426
1427
|
OM_HISTORY_URL: "https://customer-historical-forecast-api.open-meteo.com/v1/forecast",
|
|
1427
1428
|
OM_MARINE_URL: "https://customer-marine-api.open-meteo.com/v1/marine",
|
|
1428
1429
|
ORM_MARINE_URL: "https://meteo3.idmwx.com/v1/marine",
|
|
1430
|
+
ORM_HISTORY_MARINE_URL: "https://meteo1.idmwx.com/v1/marine",
|
|
1429
1431
|
WEATHER_VARIABLES: {
|
|
1430
1432
|
NORMAL: {
|
|
1431
1433
|
DAILY: "weather_code,temperature_2m_max,temperature_2m_min,apparent_temperature_max,apparent_temperature_min,sunrise,sunset,precipitation_sum,precipitation_hours,precipitation_probability_max,rain_sum,showers_sum,snowfall_sum,wind_speed_10m_max,wind_gusts_10m_max,wind_direction_10m_dominant",
|
|
@@ -1464,13 +1466,13 @@ class C0 {
|
|
|
1464
1466
|
this.apikey = M || "smE3JnDLHy3TizVv", this.debug = b;
|
|
1465
1467
|
}
|
|
1466
1468
|
async standardWeatherModels() {
|
|
1467
|
-
return
|
|
1469
|
+
return v.standardWeatherModels();
|
|
1468
1470
|
}
|
|
1469
1471
|
async standardMarineModels() {
|
|
1470
|
-
return
|
|
1472
|
+
return v.standardMarineModels();
|
|
1471
1473
|
}
|
|
1472
1474
|
async autoPickMeteoModel(M = "best_match") {
|
|
1473
|
-
return
|
|
1475
|
+
return v.autoPickMeteoModel(M);
|
|
1474
1476
|
}
|
|
1475
1477
|
range(M, b, p) {
|
|
1476
1478
|
return Array.from({ length: (b - M) / p }, (O, Y) => M + Y * p);
|
|
@@ -1494,8 +1496,8 @@ class C0 {
|
|
|
1494
1496
|
fake: M.fake,
|
|
1495
1497
|
step: d
|
|
1496
1498
|
});
|
|
1497
|
-
const q = await $(A, M),
|
|
1498
|
-
O ? await this.mergeSegments(O,
|
|
1499
|
+
const q = await $(A, M), a = await this.parseWeatherData(q, M, b);
|
|
1500
|
+
O ? await this.mergeSegments(O, a) : O = a;
|
|
1499
1501
|
}
|
|
1500
1502
|
else {
|
|
1501
1503
|
const d = await $(M.url, M);
|
|
@@ -1525,7 +1527,7 @@ class C0 {
|
|
|
1525
1527
|
* @param options
|
|
1526
1528
|
*/
|
|
1527
1529
|
async marineForecast(M, b = {}) {
|
|
1528
|
-
var p, O, Y, d, A, q,
|
|
1530
|
+
var p, O, Y, d, A, q, a, R;
|
|
1529
1531
|
try {
|
|
1530
1532
|
const n = L();
|
|
1531
1533
|
let o;
|
|
@@ -1550,7 +1552,7 @@ class C0 {
|
|
|
1550
1552
|
const S = L();
|
|
1551
1553
|
this.debug && G.info("[%s] fetch marine api (%j) cost: %d ms", b.requestId, M.url, S.diff(n, "ms"));
|
|
1552
1554
|
const i = await this.mergeMarineData(o), l = i.find((e) => e.model === "ncep_gfswave016"), u = i.find((e) => e.model === "ncep_gfswave025"), V = i.find((e) => e.model === "meteofrance_wave"), E = i.find((e) => e.model === "best_match");
|
|
1553
|
-
return (O = (p = E == null ? void 0 : E.hourly) == null ? void 0 : p.wave_height) != null && O.every((e) => e !== null) ? [E] : (d = (Y = V == null ? void 0 : V.hourly) == null ? void 0 : Y.wave_height) != null && d.every((e) => e !== null) ? [V] : (q = (A = l == null ? void 0 : l.hourly) == null ? void 0 : A.wave_height) != null && q.every((e) => e !== null) ? [l] : (R = (
|
|
1555
|
+
return (O = (p = E == null ? void 0 : E.hourly) == null ? void 0 : p.wave_height) != null && O.every((e) => e !== null) ? [E] : (d = (Y = V == null ? void 0 : V.hourly) == null ? void 0 : Y.wave_height) != null && d.every((e) => e !== null) ? [V] : (q = (A = l == null ? void 0 : l.hourly) == null ? void 0 : A.wave_height) != null && q.every((e) => e !== null) ? [l] : (R = (a = u == null ? void 0 : u.hourly) == null ? void 0 : a.wave_height) != null && R.every((e) => e !== null) ? [u] : i != null && i.length ? [i[0]] : [];
|
|
1554
1556
|
} catch (n) {
|
|
1555
1557
|
return G.warn("[%s] marine forecast failed: %s, with %j", b.requestId, n, M), [];
|
|
1556
1558
|
}
|
|
@@ -1563,7 +1565,7 @@ class C0 {
|
|
|
1563
1565
|
* @private
|
|
1564
1566
|
*/
|
|
1565
1567
|
async parseWeatherData(M, b, p = {}) {
|
|
1566
|
-
var d, A, q,
|
|
1568
|
+
var d, A, q, a, R, n, o, S, i, l;
|
|
1567
1569
|
const O = [], Y = Math.pow(10, p.precision || 6);
|
|
1568
1570
|
for (let u = 0; u < M.length; u++) {
|
|
1569
1571
|
const V = M[u], E = V.utcOffsetSeconds(), e = V.timezone(), D = V.current(), P = V.hourly(), m = V.sixHourly(), F = V.daily(), C = {};
|
|
@@ -1588,7 +1590,7 @@ class C0 {
|
|
|
1588
1590
|
)
|
|
1589
1591
|
};
|
|
1590
1592
|
for (let s = 0; s < P.variablesLength(); s++) {
|
|
1591
|
-
const w = (
|
|
1593
|
+
const w = (a = (q = (A = P.variables(s).valuesArray()) == null ? void 0 : A.toString()) == null ? void 0 : q.split(",")) == null ? void 0 : a.map((K) => isNaN(K) ? null : Math.round(Number(K) * Y) / Y);
|
|
1592
1594
|
C.hourly[b.hourly[s]] = w;
|
|
1593
1595
|
}
|
|
1594
1596
|
const I = L();
|
|
@@ -1643,15 +1645,15 @@ class C0 {
|
|
|
1643
1645
|
}
|
|
1644
1646
|
async mergeMarineData(M) {
|
|
1645
1647
|
var Y, d, A, q;
|
|
1646
|
-
const b = [], p = M.find((
|
|
1648
|
+
const b = [], p = M.find((a) => a.model === "best_match");
|
|
1647
1649
|
p && b.push(p);
|
|
1648
|
-
const O = M.find((
|
|
1649
|
-
for (const
|
|
1650
|
-
["best_match", "meteofrance_currents"].includes(
|
|
1650
|
+
const O = M.find((a) => a.model === "meteofrance_currents");
|
|
1651
|
+
for (const a of M)
|
|
1652
|
+
["best_match", "meteofrance_currents"].includes(a.model) || (a.hourly.ocean_current_velocity = (Y = O == null ? void 0 : O.hourly) == null ? void 0 : Y.ocean_current_velocity, a.hourly.ocean_current_direction = (d = O == null ? void 0 : O.hourly) == null ? void 0 : d.ocean_current_direction, a.hourly.sea_level_height_msl = (A = O == null ? void 0 : O.hourly) == null ? void 0 : A.sea_level_height_msl, a.hourly.sea_surface_temperature = (q = O == null ? void 0 : O.hourly) == null ? void 0 : q.sea_surface_temperature, b.push(a));
|
|
1651
1653
|
return b;
|
|
1652
1654
|
}
|
|
1653
1655
|
pickForecastUrl(M, b, p, O = {}) {
|
|
1654
|
-
return M ? p && !O.noFake ? this.FORECAST.OM_MARINE_URL : b ? O.marineUrl || this.FORECAST.ORM_MARINE_URL : this.FORECAST.OM_MARINE_URL : p && !O.noFake ? this.FORECAST.OM_HISTORY_URL : b ? O.weatherUrl || this.FORECAST.ORM_URL : this.FORECAST.OM_URL;
|
|
1656
|
+
return M ? p && !O.noFake ? O.selfHistory ? this.FORECAST.ORM_HISTORY_MARINE_URL : this.FORECAST.OM_MARINE_URL : b ? O.marineUrl || this.FORECAST.ORM_MARINE_URL : this.FORECAST.OM_MARINE_URL : p && !O.noFake ? O.selfHistory ? this.FORECAST.ORM_HISTORY_URL : this.FORECAST.OM_HISTORY_URL : b ? O.weatherUrl || this.FORECAST.ORM_URL : this.FORECAST.OM_URL;
|
|
1655
1657
|
}
|
|
1656
1658
|
pickMarineModels(M) {
|
|
1657
1659
|
var d;
|
|
@@ -1665,8 +1667,8 @@ class C0 {
|
|
|
1665
1667
|
}
|
|
1666
1668
|
const O = p.reduce((A, q) => (A.includes(q) || A.push(q), A), []), Y = ["best_match", "meteofrance_currents", "meteofrance_wave", "ecmwf_wam025", "ncep_gfswave025", "gwam", "era5_ocean", "ewam", "ncep_gfswave016"];
|
|
1667
1669
|
return O.sort((A, q) => {
|
|
1668
|
-
const
|
|
1669
|
-
return
|
|
1670
|
+
const a = Y.indexOf(A), R = Y.indexOf(q);
|
|
1671
|
+
return a - R;
|
|
1670
1672
|
}), O;
|
|
1671
1673
|
}
|
|
1672
1674
|
/**
|
|
@@ -1681,18 +1683,18 @@ class C0 {
|
|
|
1681
1683
|
var q;
|
|
1682
1684
|
const Y = L().utc(), d = M ? L.utc(M) : void 0, A = Y.clone().utc().add(b && ((q = p.models) != null && q.includes("meteofrance_wave")) ? 10 : 15, "day");
|
|
1683
1685
|
if (M) {
|
|
1684
|
-
const
|
|
1685
|
-
|
|
1686
|
+
const a = d.clone().utc().add(O.forecastDays ?? 1, "day");
|
|
1687
|
+
a.isAfter(A) ? (a.subtract(1, "year"), d.isAfter(A) ? (d.subtract(1, "year"), p.start_dates = [
|
|
1686
1688
|
d.clone().subtract(O.pastDays || 0, "day").utc().format("YYYY-MM-DD")
|
|
1687
|
-
], p.end_dates = [
|
|
1689
|
+
], p.end_dates = [a.utc().format("YYYY-MM-DD")], p.fakes = [!0], p.url = [this.pickForecastUrl(b, O.selfHosted ?? !0, !0, O)]) : (p.start_dates = [
|
|
1688
1690
|
d.clone().subtract(O.pastDays || 0, "day").utc().format("YYYY-MM-DD"),
|
|
1689
1691
|
A.clone().subtract(1, "year").utc().format("YYYY-MM-DD")
|
|
1690
|
-
], p.end_dates = [A.clone().subtract(1, "day").utc().format("YYYY-MM-DD"),
|
|
1692
|
+
], p.end_dates = [A.clone().subtract(1, "day").utc().format("YYYY-MM-DD"), a.utc().format("YYYY-MM-DD")], p.fakes = [!1, !0], p.url = [
|
|
1691
1693
|
this.pickForecastUrl(b, O.selfHosted ?? !0, !1, O),
|
|
1692
1694
|
this.pickForecastUrl(b, O.selfHosted ?? !0, !0, O)
|
|
1693
1695
|
])) : (p.start_dates = [
|
|
1694
1696
|
d.clone().subtract(O.pastDays || 0, "day").utc().format("YYYY-MM-DD")
|
|
1695
|
-
], p.end_dates = [
|
|
1697
|
+
], p.end_dates = [a.utc().format("YYYY-MM-DD")], p.fakes = [!1], p.url = [this.pickForecastUrl(b, O.selfHosted ?? !0, d.isBefore(Y.clone().subtract(30, "day")), O)]);
|
|
1696
1698
|
} else
|
|
1697
1699
|
p.forecast_days = O.forecastDays, p.past_days = O.pastDays, p.fake = !1, p.url = this.pickForecastUrl(b, O.selfHosted ?? !0, !1, O);
|
|
1698
1700
|
return p;
|
|
@@ -1759,12 +1761,12 @@ class C0 {
|
|
|
1759
1761
|
models: ((S = A.weatherModels) == null ? void 0 : S.split(",")) || ["best_match"],
|
|
1760
1762
|
timezone: "auto"
|
|
1761
1763
|
};
|
|
1762
|
-
let
|
|
1764
|
+
let a;
|
|
1763
1765
|
if (p) {
|
|
1764
1766
|
const e = this.timezoneOffset(M, b);
|
|
1765
|
-
|
|
1767
|
+
a = L.utc(p).utcOffset(e), a.subtract(e > 0 ? e : -e, "h"), A.selfHistory = !(a != null && a.isBefore(L.utc().subtract(120, "days")));
|
|
1766
1768
|
}
|
|
1767
|
-
Y && (q.daily = ((i = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : i.split(",")) || []),
|
|
1769
|
+
Y && (q.daily = ((i = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : i.split(",")) || []), a || (A.forecastDays = A.forecastDays || 1, A.pastDays = 0, d = !0), d && (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(a == null ? void 0 : a.utc().format(), !1, q, A);
|
|
1768
1770
|
const R = await this.weatherForecast(q, A), n = {
|
|
1769
1771
|
apikey: this.apikey,
|
|
1770
1772
|
latitude: M,
|
|
@@ -1774,7 +1776,7 @@ class C0 {
|
|
|
1774
1776
|
wind_speed_unit: "kn",
|
|
1775
1777
|
models: this.pickMarineModels(A.marineModels)
|
|
1776
1778
|
};
|
|
1777
|
-
Y && (n.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")),
|
|
1779
|
+
Y && (n.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), a || (A.forecastDays = A.forecastDays || 1, d = !0), d && (n.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), this.prepare(a == null ? void 0 : a.utc().format(), !0, n, A);
|
|
1778
1780
|
let o = await this.marineForecast(n, A);
|
|
1779
1781
|
return (E = (V = (u = o[0]) == null ? void 0 : u.hourly) == null ? void 0 : V.wave_height) != null && E.every((e) => e === null) && (n.models = this.pickMarineModels("best_match,ncep_gfswave025,meteofrance_wave"), o = await this.marineForecast(n, A)), { weather: R, marine: o };
|
|
1780
1782
|
}
|
|
@@ -1804,8 +1806,8 @@ class C0 {
|
|
|
1804
1806
|
}) {
|
|
1805
1807
|
var l, u;
|
|
1806
1808
|
b = this.toStdLng(b), this.debug && G.info("[%s] spot historical params: %j", q.requestId, { lat: M, lng: b, startDate: p, endDate: O, withMarine: A, options: q });
|
|
1807
|
-
const
|
|
1808
|
-
R.subtract(
|
|
1809
|
+
const a = this.timezoneOffset(M, b), R = L.utc(p).utcOffset(a), n = L.utc(O).utcOffset(a);
|
|
1810
|
+
R.subtract(a > 0 ? a : -a, "h"), n.subtract(a > 0 ? a : -a, "h");
|
|
1809
1811
|
const o = {
|
|
1810
1812
|
apikey: this.apikey,
|
|
1811
1813
|
latitude: M,
|
|
@@ -1855,8 +1857,8 @@ class C0 {
|
|
|
1855
1857
|
precision: 6
|
|
1856
1858
|
}) {
|
|
1857
1859
|
b = this.toStdLng(b), this.debug && G.info("[%s] spot seasonal params: %j", d.requestId, { lat: M, lng: b, startDate: p, endDate: O, options: d });
|
|
1858
|
-
const A = this.timezoneOffset(M, b), q = L.utc(p).utcOffset(A),
|
|
1859
|
-
q.subtract(A > 0 ? A : -A, "h"),
|
|
1860
|
+
const A = this.timezoneOffset(M, b), q = L.utc(p).utcOffset(A), a = O ? L.utc(O).utcOffset(A) : q.clone().add(1, "month");
|
|
1861
|
+
q.subtract(A > 0 ? A : -A, "h"), a.subtract(A > 0 ? A : -A, "h");
|
|
1860
1862
|
const R = {
|
|
1861
1863
|
apikey: this.apikey,
|
|
1862
1864
|
latitude: M,
|
|
@@ -1866,7 +1868,7 @@ class C0 {
|
|
|
1866
1868
|
timezone: "auto",
|
|
1867
1869
|
url: this.SEASONAL.OM_URL,
|
|
1868
1870
|
start_date: q.format("YYYY-MM-DD"),
|
|
1869
|
-
end_date:
|
|
1871
|
+
end_date: a.format("YYYY-MM-DD"),
|
|
1870
1872
|
daily: this.SEASONAL.WEATHER_VARIABLES.DAILY.split(",")
|
|
1871
1873
|
};
|
|
1872
1874
|
return Y && (R.six_hourly = this.SEASONAL.WEATHER_VARIABLES.SIX_HOURLY.split(",")), d.memberLength = 4, { weather: await this.weatherForecast(R, d) };
|
|
@@ -1898,7 +1900,7 @@ class C0 {
|
|
|
1898
1900
|
b = this.toStdLng(b), this.debug && G.info("[%s] spot climate params: %j", Y.requestId, { lat: M, lng: b, startDate: p, endDate: O, options: Y });
|
|
1899
1901
|
const d = this.timezoneOffset(M, b), A = L.utc(p).utcOffset(d), q = O ? L.utc(O).utcOffset(d) : A.clone().add(1, "day");
|
|
1900
1902
|
q.subtract(d > 0 ? d : -d, "h"), A.subtract(d > 0 ? d : -d, "h");
|
|
1901
|
-
const
|
|
1903
|
+
const a = {
|
|
1902
1904
|
apikey: this.apikey,
|
|
1903
1905
|
latitude: M,
|
|
1904
1906
|
longitude: b,
|
|
@@ -1911,7 +1913,7 @@ class C0 {
|
|
|
1911
1913
|
end_date: q.format("YYYY-MM-DD"),
|
|
1912
1914
|
daily: this.CLIMATE.WEATHER_VARIABLES.DAILY.split(",")
|
|
1913
1915
|
};
|
|
1914
|
-
return { weather: await this.weatherForecast(
|
|
1916
|
+
return { weather: await this.weatherForecast(a, Y) };
|
|
1915
1917
|
}
|
|
1916
1918
|
async update(M = {}) {
|
|
1917
1919
|
const b = L.unix(this.METEO2_UPDATE.etime), p = this.METEO2_UPDATE.version, O = L();
|
|
@@ -1923,9 +1925,9 @@ class C0 {
|
|
|
1923
1925
|
}
|
|
1924
1926
|
})).json();
|
|
1925
1927
|
if (A.code === 0) {
|
|
1926
|
-
const q = A.data,
|
|
1927
|
-
for (const R of
|
|
1928
|
-
const n =
|
|
1928
|
+
const q = A.data, a = v.standardWeatherModels();
|
|
1929
|
+
for (const R of a) {
|
|
1930
|
+
const n = v.autoPickSubCategories(R.alias), S = q.filter((i) => n.includes(i.category)).map((i) => {
|
|
1929
1931
|
var l, u, V, E, e, D;
|
|
1930
1932
|
return {
|
|
1931
1933
|
category: i.category,
|
|
@@ -1991,8 +1993,8 @@ class D0 {
|
|
|
1991
1993
|
* @param datum
|
|
1992
1994
|
* @param options
|
|
1993
1995
|
*/
|
|
1994
|
-
async tidesForecast(M, b, p = 7, O = "today", Y = !0, d = !1, A = !1, q = "CD",
|
|
1995
|
-
O = O || "today", p = p || 7, b = this.toStdLng(b), this.debug && W0.info("[%s] spot tides forecast params: %j",
|
|
1996
|
+
async tidesForecast(M, b, p = 7, O = "today", Y = !0, d = !1, A = !1, q = "CD", a = {}) {
|
|
1997
|
+
O = O || "today", p = p || 7, b = this.toStdLng(b), this.debug && W0.info("[%s] spot tides forecast params: %j", a.requestId, { lat: M, lng: b, date: O, extremes: Y, heights: d, datums: A, datum: q });
|
|
1996
1998
|
let R = `https://www.worldtides.info/api/v3?lat=${M}&lon=${b}&days=${p}&date=${O}&datum=${q}&key=${this.apikey}&localtime`;
|
|
1997
1999
|
Y && (R = `${R}&extremes`), d && (R = `${R}&heights`), A && (R = `${R}&datums`);
|
|
1998
2000
|
const o = await (await fetch(R)).json();
|