@idm-plugin/meteo2 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +109 -89
- package/dist/index.umd.cjs +2 -2
- package/dist/openmeteo/src/index.d.ts +10 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var X0 = Object.defineProperty;
|
|
|
2
2
|
var R0 = (i, M, b) => M in i ? X0(i, M, { enumerable: !0, configurable: !0, writable: !0, value: b }) : i[M] = b;
|
|
3
3
|
var H = (i, M, b) => (R0(i, typeof M != "symbol" ? M + "" : M, b), b);
|
|
4
4
|
import p0 from "@log4js-node/log4js-api";
|
|
5
|
-
import
|
|
5
|
+
import e from "moment";
|
|
6
6
|
import k from "got";
|
|
7
7
|
import { fetchWeatherApi as J } from "openmeteo";
|
|
8
8
|
let f;
|
|
@@ -12,7 +12,7 @@ try {
|
|
|
12
12
|
} finally {
|
|
13
13
|
}
|
|
14
14
|
var n0 = /* @__PURE__ */ ((i) => (i.Arome = "arome", i.IconEU = "iconEu", i.GFS = "gfs", i.GFSWave = "gfsWave", i.NamConus = "namConus", i.NamHawaii = "namHawaii", i.NamAlaska = "namAlaska", i.Geos5 = "geos5", i))(n0 || {});
|
|
15
|
-
class
|
|
15
|
+
class P0 {
|
|
16
16
|
/**
|
|
17
17
|
* 点查海洋气象要素(全量)
|
|
18
18
|
* @param lng
|
|
@@ -24,7 +24,7 @@ class m0 {
|
|
|
24
24
|
*/
|
|
25
25
|
static async queryPointMeteo(M, b, p, O = !1, Y = "", o = {}) {
|
|
26
26
|
typeof p == "number" && (p = p < 1e12 ? p * 1e3 : p);
|
|
27
|
-
const W =
|
|
27
|
+
const W = e(p), q = {
|
|
28
28
|
searchParams: {
|
|
29
29
|
lng: M,
|
|
30
30
|
lat: b,
|
|
@@ -33,10 +33,10 @@ class m0 {
|
|
|
33
33
|
source: Y == null ? void 0 : Y.toLowerCase()
|
|
34
34
|
},
|
|
35
35
|
timeout: 3e4
|
|
36
|
-
}, X =
|
|
36
|
+
}, X = e(), n = X.valueOf();
|
|
37
37
|
W.isBefore(X.subtract(1, "month")) && (f == null || f.warn("[%s] get history meteo on %s: %j", o.requestId, W.format(), q));
|
|
38
|
-
const
|
|
39
|
-
if (f == null || f.info("[%s] get meteo(cost: %d ms) from %s with options: %j", o.requestId, N - n,
|
|
38
|
+
const L = "https://aod4idm.idmwx.com/api/ocean/point", a = await k.get(L, q).json(), N = e().valueOf();
|
|
39
|
+
if (f == null || f.info("[%s] get meteo(cost: %d ms) from %s with options: %j", o.requestId, N - n, L, q), (a == null ? void 0 : a.code) === 0)
|
|
40
40
|
return {
|
|
41
41
|
...a.data,
|
|
42
42
|
source: Y
|
|
@@ -59,7 +59,7 @@ class m0 {
|
|
|
59
59
|
*/
|
|
60
60
|
static async queryPointFactor(M, b, p, O = "wind,wave,current,watertemp,visibility", Y = "", o = {}) {
|
|
61
61
|
typeof p == "number" && (p = p < 1e12 ? p * 1e3 : p);
|
|
62
|
-
const W =
|
|
62
|
+
const W = e(p), q = {
|
|
63
63
|
searchParams: {
|
|
64
64
|
lng: M,
|
|
65
65
|
lat: b,
|
|
@@ -68,10 +68,10 @@ class m0 {
|
|
|
68
68
|
source: Y == null ? void 0 : Y.toLowerCase()
|
|
69
69
|
},
|
|
70
70
|
timeout: 3e4
|
|
71
|
-
}, X =
|
|
71
|
+
}, X = e(), n = X.valueOf();
|
|
72
72
|
W.isBefore(X.subtract(1, "month")) && (f == null || f.warn("[%s] get history factors on %s: %j", o.requestId, W.format(), q));
|
|
73
|
-
const
|
|
74
|
-
if (f == null || f.info("[%s] get factors(cost: %d ms) from %s with options: %j", o.requestId, N - n,
|
|
73
|
+
const L = "https://aod4idm.idmwx.com/api/ocean/factor", a = await k.get(L, q).json(), N = e().valueOf();
|
|
74
|
+
if (f == null || f.info("[%s] get factors(cost: %d ms) from %s with options: %j", o.requestId, N - n, L, q), (a == null ? void 0 : a.code) === 0)
|
|
75
75
|
return {
|
|
76
76
|
...a.data,
|
|
77
77
|
source: Y
|
|
@@ -85,7 +85,7 @@ class m0 {
|
|
|
85
85
|
static async queryWindyPointForecast(M, b, p, O = {}) {
|
|
86
86
|
const Y = "https://api.windy.com/api/point-forecast/v2", o = [];
|
|
87
87
|
try {
|
|
88
|
-
let W =
|
|
88
|
+
let W = e().valueOf();
|
|
89
89
|
const q = await k.post(Y, {
|
|
90
90
|
headers: {
|
|
91
91
|
"Content-Type": "application/json"
|
|
@@ -115,7 +115,7 @@ class m0 {
|
|
|
115
115
|
levels: ["surface"]
|
|
116
116
|
}
|
|
117
117
|
}).json();
|
|
118
|
-
let X =
|
|
118
|
+
let X = e().valueOf();
|
|
119
119
|
f == null || f.info("[%s] get gfs-factors(cost: %d ms) from %s", O.requestId, X - W, Y), W = X;
|
|
120
120
|
const n = await k.post(Y, {
|
|
121
121
|
headers: {
|
|
@@ -130,11 +130,11 @@ class m0 {
|
|
|
130
130
|
levels: ["surface"]
|
|
131
131
|
}
|
|
132
132
|
}).json();
|
|
133
|
-
X =
|
|
133
|
+
X = e().valueOf(), f == null || f.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", O.requestId, X - W, Y);
|
|
134
134
|
for (let a = 0; a < q.ts.length; a++) {
|
|
135
135
|
const N = this.populateUVFactor(q["wind_u-surface"][a], q["wind_v-surface"][a], !1, O);
|
|
136
136
|
N.scale = this.calculateBeaufortWindForceScale(N.speed), o.push({
|
|
137
|
-
utc:
|
|
137
|
+
utc: e(q.ts[a]).utc().format(),
|
|
138
138
|
temp: q["temp-surface"][a] ? Math.round((q["temp-surface"][a] - 273.15) * 100) / 100 : void 0,
|
|
139
139
|
dp_temp: q["dewpoint-surface"][a] ? Math.round((q["dewpoint-surface"][a] - 273.15) * 100) / 100 : void 0,
|
|
140
140
|
precip: {
|
|
@@ -155,21 +155,21 @@ class m0 {
|
|
|
155
155
|
pressure: Math.round(q["pressure-surface"][a] / 100 * 100) / 100
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
-
const
|
|
158
|
+
const L = [];
|
|
159
159
|
for (let a = 0; a < n.ts.length; a++) {
|
|
160
|
-
const N = this.calculateDouglasScale(n["waves_height-surface"][a], n["waves_direction-surface"][a], n["waves_period-surface"][a]), t = this.calculateDouglasScale(n["wwaves_height-surface"][a], n["wwaves_direction-surface"][a], n["wwaves_period-surface"][a]),
|
|
161
|
-
|
|
162
|
-
utc:
|
|
160
|
+
const N = this.calculateDouglasScale(n["waves_height-surface"][a], n["waves_direction-surface"][a], n["waves_period-surface"][a]), t = this.calculateDouglasScale(n["wwaves_height-surface"][a], n["wwaves_direction-surface"][a], n["wwaves_period-surface"][a]), m = this.calculateDouglasScale(n["swell1_height-surface"][a], n["swell1_direction-surface"][a], n["swell1_period-surface"][a]), V = this.calculateDouglasScale(n["swell2_height-surface"][a], n["swell2_direction-surface"][a], n["swell2_period-surface"][a]);
|
|
161
|
+
L.push({
|
|
162
|
+
utc: e(n.ts[a]).utc().format(),
|
|
163
163
|
wave: {
|
|
164
164
|
sig: N,
|
|
165
165
|
wd: t,
|
|
166
|
-
swell:
|
|
166
|
+
swell: m,
|
|
167
167
|
swell2: V
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
for (const a of o) {
|
|
172
|
-
const N =
|
|
172
|
+
const N = L.find((t) => t.utc === a.utc);
|
|
173
173
|
a.wave = N == null ? void 0 : N.wave;
|
|
174
174
|
}
|
|
175
175
|
} catch (W) {
|
|
@@ -256,8 +256,8 @@ class m0 {
|
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
var
|
|
260
|
-
function
|
|
259
|
+
var e0 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
260
|
+
function L0(i) {
|
|
261
261
|
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
262
262
|
}
|
|
263
263
|
var O0 = { exports: {} };
|
|
@@ -268,15 +268,15 @@ var O0 = { exports: {} };
|
|
|
268
268
|
throw new RangeError("invalid coordinates");
|
|
269
269
|
if (90 <= b)
|
|
270
270
|
return "Etc/GMT";
|
|
271
|
-
var o = -1, W = 48 * (180 + p) / 360.00000000000006, q = 24 * (90 - b) / 180.00000000000003, X = 0 | W, n = 0 | q,
|
|
272
|
-
for (
|
|
273
|
-
|
|
274
|
-
return Y[
|
|
271
|
+
var o = -1, W = 48 * (180 + p) / 360.00000000000006, q = 24 * (90 - b) / 180.00000000000003, X = 0 | W, n = 0 | q, L = 96 * n + 2 * X;
|
|
272
|
+
for (L = 56 * O.charCodeAt(L) + O.charCodeAt(L + 1) - 1995; L + Y.length < 3136; )
|
|
273
|
+
L = 56 * O.charCodeAt(L = 8 * (o = o + L + 1) + 4 * (n = 0 | (q = 2 * (q - n) % 2)) + 2 * (X = 0 | (W = 2 * (W - X) % 2)) + 2304) + O.charCodeAt(L + 1) - 1995;
|
|
274
|
+
return Y[L + Y.length - 3136];
|
|
275
275
|
}
|
|
276
276
|
i.exports = M;
|
|
277
277
|
})(O0);
|
|
278
278
|
var T0 = O0.exports;
|
|
279
|
-
const i0 = /* @__PURE__ */
|
|
279
|
+
const i0 = /* @__PURE__ */ L0(T0);
|
|
280
280
|
var A0 = { exports: {} };
|
|
281
281
|
(function(i) {
|
|
282
282
|
//! moment-timezone.js
|
|
@@ -285,13 +285,13 @@ var A0 = { exports: {} };
|
|
|
285
285
|
//! license : MIT
|
|
286
286
|
//! github.com/moment/moment-timezone
|
|
287
287
|
(function(M, b) {
|
|
288
|
-
i.exports ? i.exports = b(
|
|
289
|
-
})(
|
|
288
|
+
i.exports ? i.exports = b(e) : b(M.moment);
|
|
289
|
+
})(e0, function(M) {
|
|
290
290
|
M.version === void 0 && M.default && (M = M.default);
|
|
291
291
|
var b = "0.5.47", p = {}, O = {}, Y = {}, o = {}, W = {}, q;
|
|
292
292
|
(!M || typeof M.version != "string") && w("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
293
|
-
var X = M.version.split("."), n = +X[0],
|
|
294
|
-
(n < 2 || n === 2 &&
|
|
293
|
+
var X = M.version.split("."), n = +X[0], L = +X[1];
|
|
294
|
+
(n < 2 || n === 2 && L < 6) && w("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
|
|
295
295
|
function a(z) {
|
|
296
296
|
return z > 96 ? z - 87 : z > 64 ? z - 29 : z - 48;
|
|
297
297
|
}
|
|
@@ -307,7 +307,7 @@ var A0 = { exports: {} };
|
|
|
307
307
|
for (var A = 0; A < z.length; A++)
|
|
308
308
|
z[A] = N(z[A]);
|
|
309
309
|
}
|
|
310
|
-
function
|
|
310
|
+
function m(z, A) {
|
|
311
311
|
for (var c = 0; c < A; c++)
|
|
312
312
|
z[c] = Math.round((z[c - 1] || 0) + z[c] * 6e4);
|
|
313
313
|
z[A - 1] = 1 / 0;
|
|
@@ -320,7 +320,7 @@ var A0 = { exports: {} };
|
|
|
320
320
|
}
|
|
321
321
|
function v(z) {
|
|
322
322
|
var A = z.split("|"), c = A[2].split(" "), d = A[3].split(""), R = A[4].split(" ");
|
|
323
|
-
return t(c), t(d), t(R),
|
|
323
|
+
return t(c), t(d), t(R), m(R, d.length), {
|
|
324
324
|
name: A[0],
|
|
325
325
|
abbrs: V(A[1].split(" "), d),
|
|
326
326
|
offsets: V(c, d),
|
|
@@ -388,7 +388,7 @@ var A0 = { exports: {} };
|
|
|
388
388
|
C.prototype.scoreOffsetAt = function(z) {
|
|
389
389
|
this.offsetScore += Math.abs(this.zone.utcOffset(z.at) - z.offset), this.zone.abbr(z.at).replace(/[^A-Z]/g, "") !== z.abbr && this.abbrScore++;
|
|
390
390
|
};
|
|
391
|
-
function
|
|
391
|
+
function E(z, A) {
|
|
392
392
|
for (var c, d; d = ((A.at - z.at) / 12e4 | 0) * 6e4; )
|
|
393
393
|
c = new l(new Date(z.at + d)), c.offset === z.offset ? z = c : A = c;
|
|
394
394
|
return z;
|
|
@@ -396,7 +396,7 @@ var A0 = { exports: {} };
|
|
|
396
396
|
function D() {
|
|
397
397
|
var z = (/* @__PURE__ */ new Date()).getFullYear() - 2, A = new l(new Date(z, 0, 1)), c = A.offset, d = [A], R, T, u, r;
|
|
398
398
|
for (r = 1; r < 48; r++)
|
|
399
|
-
u = new Date(z, r, 1).getTimezoneOffset(), u !== c && (T = new l(new Date(z, r, 1)), R =
|
|
399
|
+
u = new Date(z, r, 1).getTimezoneOffset(), u !== c && (T = new l(new Date(z, r, 1)), R = E(A, T), d.push(R), d.push(new l(new Date(R.at + 6e4))), A = T, c = u);
|
|
400
400
|
for (r = 0; r < 4; r++)
|
|
401
401
|
d.push(new l(new Date(z + r, 0, 1))), d.push(new l(new Date(z + r, 6, 1)));
|
|
402
402
|
return d;
|
|
@@ -547,7 +547,7 @@ var A0 = { exports: {} };
|
|
|
547
547
|
};
|
|
548
548
|
}
|
|
549
549
|
P.zoneName = z0(P.zoneName), P.zoneAbbr = z0(P.zoneAbbr), P.utc = b0(P.utc), P.local = b0(P.local), P.utcOffset = a0(P.utcOffset), M.tz.setDefault = function(z) {
|
|
550
|
-
return (n < 2 || n === 2 &&
|
|
550
|
+
return (n < 2 || n === 2 && L < 9) && w("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = z ? G(z) : null, M;
|
|
551
551
|
};
|
|
552
552
|
var y = M.momentProperties;
|
|
553
553
|
return Object.prototype.toString.call(y) === "[object Array]" ? (y.push("_z"), y.push("_a")) : y && (y._z = null), M;
|
|
@@ -1414,7 +1414,14 @@ try {
|
|
|
1414
1414
|
} catch {
|
|
1415
1415
|
} finally {
|
|
1416
1416
|
}
|
|
1417
|
-
const
|
|
1417
|
+
const V0 = [
|
|
1418
|
+
{
|
|
1419
|
+
rank: 0,
|
|
1420
|
+
name: "Best Match",
|
|
1421
|
+
alias: "BEST MATCH",
|
|
1422
|
+
model: "best_match",
|
|
1423
|
+
models: ["best_match"]
|
|
1424
|
+
},
|
|
1418
1425
|
{
|
|
1419
1426
|
rank: 1,
|
|
1420
1427
|
name: "GFS",
|
|
@@ -1550,7 +1557,14 @@ const I0 = [
|
|
|
1550
1557
|
categories: "bom_access_global",
|
|
1551
1558
|
variables: "temperature_2m,relative_humidity_2m,dew_point_2m,apparent_temperature,precipitation_probability,precipitation,rain,showers,snowfall_water_equivalent,snowfall,frozen_precipitation_percent,pressure_msl,cloud_cover,visibility,wind_speed_10m,wind_u_component_10m,wind_v_component_10m,wind_direction_10m,wind_gusts_10m,cape,lifted_index,weather_code"
|
|
1552
1559
|
}
|
|
1553
|
-
],
|
|
1560
|
+
], t0 = [
|
|
1561
|
+
{
|
|
1562
|
+
rank: 0,
|
|
1563
|
+
name: "Best Match",
|
|
1564
|
+
alias: "BEST MATCH",
|
|
1565
|
+
model: "best_match",
|
|
1566
|
+
models: ["best_match"]
|
|
1567
|
+
},
|
|
1554
1568
|
{
|
|
1555
1569
|
rank: 1,
|
|
1556
1570
|
name: "MFWAM",
|
|
@@ -1701,6 +1715,12 @@ class G0 {
|
|
|
1701
1715
|
});
|
|
1702
1716
|
this.apikey = M || "smE3JnDLHy3TizVv", this.debug = b;
|
|
1703
1717
|
}
|
|
1718
|
+
async standardWeatherModels() {
|
|
1719
|
+
return V0.filter((M) => !M.disabled && M.alias);
|
|
1720
|
+
}
|
|
1721
|
+
async standardMarineModels() {
|
|
1722
|
+
return t0.filter((M) => !M.disabled && M.alias);
|
|
1723
|
+
}
|
|
1704
1724
|
range(M, b, p) {
|
|
1705
1725
|
return Array.from({ length: (b - M) / p }, (O, Y) => M + Y * p);
|
|
1706
1726
|
}
|
|
@@ -1711,7 +1731,7 @@ class G0 {
|
|
|
1711
1731
|
*/
|
|
1712
1732
|
async weatherForecast(M, b = {}) {
|
|
1713
1733
|
try {
|
|
1714
|
-
const p =
|
|
1734
|
+
const p = e();
|
|
1715
1735
|
let O;
|
|
1716
1736
|
if (M.start_dates instanceof Array)
|
|
1717
1737
|
for (let o = 0; o < M.start_dates.length; o++) {
|
|
@@ -1731,7 +1751,7 @@ class G0 {
|
|
|
1731
1751
|
O = await this.parseWeatherData(o, M, b);
|
|
1732
1752
|
}
|
|
1733
1753
|
delete M.apikey;
|
|
1734
|
-
const Y =
|
|
1754
|
+
const Y = e();
|
|
1735
1755
|
return this.debug && Z.info("[%s] fetch weather api (%s) cost: %d ms", b.requestId, M.url, Y.diff(p, "ms")), O;
|
|
1736
1756
|
} catch (p) {
|
|
1737
1757
|
return Z.warn("[%s] weather forecast failed: %s, with %j", b.requestId, p, M), [];
|
|
@@ -1755,7 +1775,7 @@ class G0 {
|
|
|
1755
1775
|
*/
|
|
1756
1776
|
async marineForecast(M, b = {}) {
|
|
1757
1777
|
try {
|
|
1758
|
-
const p =
|
|
1778
|
+
const p = e();
|
|
1759
1779
|
let O;
|
|
1760
1780
|
if (M.start_dates instanceof Array)
|
|
1761
1781
|
for (let o = 0; o < M.start_dates.length; o++) {
|
|
@@ -1775,7 +1795,7 @@ class G0 {
|
|
|
1775
1795
|
O = await this.parseWeatherData(o, M, b);
|
|
1776
1796
|
}
|
|
1777
1797
|
delete M.apikey;
|
|
1778
|
-
const Y =
|
|
1798
|
+
const Y = e();
|
|
1779
1799
|
return this.debug && Z.info("[%s] fetch marine api (%s) cost: %d ms", b.requestId, M.url, Y.diff(p, "ms")), this.mergeMarineData(O);
|
|
1780
1800
|
} catch (p) {
|
|
1781
1801
|
return Z.warn("[%s] marine forecast failed: %s, with %j", b.requestId, p, M), [];
|
|
@@ -1789,67 +1809,67 @@ class G0 {
|
|
|
1789
1809
|
* @private
|
|
1790
1810
|
*/
|
|
1791
1811
|
async parseWeatherData(M, b, p = {}) {
|
|
1792
|
-
var o, W, q, X, n,
|
|
1812
|
+
var o, W, q, X, n, L, a, N, t;
|
|
1793
1813
|
const O = [], Y = Math.pow(10, p.precision || 6);
|
|
1794
|
-
for (let
|
|
1795
|
-
const V = M[
|
|
1796
|
-
if (
|
|
1797
|
-
const D =
|
|
1798
|
-
|
|
1799
|
-
time:
|
|
1814
|
+
for (let m = 0; m < M.length; m++) {
|
|
1815
|
+
const V = M[m], v = V.utcOffsetSeconds(), g = V.timezone(), F = V.current(), _ = V.hourly(), l = V.sixHourly(), C = V.daily(), E = {};
|
|
1816
|
+
if (E.timezone = g || void 0, E.offset = this.prettyTimezoneOffset(v), E.model = b.models[m], F) {
|
|
1817
|
+
const D = e();
|
|
1818
|
+
E.current = {
|
|
1819
|
+
time: e.unix(Number(F.time())).utc().format()
|
|
1800
1820
|
};
|
|
1801
1821
|
for (let s = 0; s < F.variablesLength(); s++) {
|
|
1802
1822
|
const B = F.variables(s).value();
|
|
1803
|
-
|
|
1823
|
+
E.current[b.current[s]] = isNaN(B) ? null : Math.round(B * Y) / Y;
|
|
1804
1824
|
}
|
|
1805
|
-
const I =
|
|
1825
|
+
const I = e();
|
|
1806
1826
|
this.debug && Z.debug("[%s] fetch current variables cost: %d ms", p.requestId, I.diff(D, "ms"));
|
|
1807
1827
|
}
|
|
1808
1828
|
if (_) {
|
|
1809
|
-
const D =
|
|
1810
|
-
|
|
1829
|
+
const D = e(), I = e.unix(Number(_.time())).add(b.fake ? 1 : 0, "year");
|
|
1830
|
+
E.hourly = {
|
|
1811
1831
|
date: I.utc().format(),
|
|
1812
1832
|
time: this.range(Number(_.time()), Number(_.timeEnd()), _.interval()).map(
|
|
1813
|
-
(B) =>
|
|
1833
|
+
(B) => e.unix(B).add(b.fake ? 1 : 0, "year").diff(I, "h")
|
|
1814
1834
|
)
|
|
1815
1835
|
};
|
|
1816
1836
|
for (let B = 0; B < _.variablesLength(); B++) {
|
|
1817
1837
|
const h = (q = (W = (o = _.variables(B).valuesArray()) == null ? void 0 : o.toString()) == null ? void 0 : W.split(",")) == null ? void 0 : q.map((K) => isNaN(K) ? null : Math.round(Number(K) * Y) / Y);
|
|
1818
|
-
|
|
1838
|
+
E.hourly[b.hourly[B]] = h;
|
|
1819
1839
|
}
|
|
1820
|
-
const s =
|
|
1840
|
+
const s = e();
|
|
1821
1841
|
this.debug && Z.debug("[%s] fetch hourly variables cost: %d ms", p.requestId, s.diff(D, "ms"));
|
|
1822
1842
|
}
|
|
1823
1843
|
if (l) {
|
|
1824
|
-
const D =
|
|
1825
|
-
|
|
1844
|
+
const D = e(), I = e.unix(Number(l.time())).add(b.fake ? 1 : 0, "year");
|
|
1845
|
+
E.sixHourly = {
|
|
1826
1846
|
date: I.utc().format(),
|
|
1827
1847
|
time: this.range(Number(l.time()), Number(l.timeEnd()), l.interval()).map(
|
|
1828
|
-
(B) =>
|
|
1848
|
+
(B) => e.unix(B).add(b.fake ? 1 : 0, "year").diff(I, "h")
|
|
1829
1849
|
)
|
|
1830
1850
|
};
|
|
1831
1851
|
for (let B = 0; B < l.variablesLength(); B += p.memberLength ?? 1) {
|
|
1832
|
-
const h = (
|
|
1833
|
-
l.variables(B),
|
|
1852
|
+
const h = (L = (n = (X = l.variables(B).valuesArray()) == null ? void 0 : X.toString()) == null ? void 0 : n.split(",")) == null ? void 0 : L.map((K) => isNaN(K) ? null : Math.round(Number(K) * Y) / Y);
|
|
1853
|
+
l.variables(B), E.sixHourly[b.six_hourly[B / (p.memberLength ?? 1)]] = h;
|
|
1834
1854
|
}
|
|
1835
|
-
const s =
|
|
1855
|
+
const s = e();
|
|
1836
1856
|
this.debug && Z.debug("[%s] fetch 6-hourly variables cost: %d ms", p.requestId, s.diff(D, "ms"));
|
|
1837
1857
|
}
|
|
1838
1858
|
if (C) {
|
|
1839
|
-
const D =
|
|
1840
|
-
|
|
1859
|
+
const D = e();
|
|
1860
|
+
E.daily = {
|
|
1841
1861
|
time: this.range(Number(C.time()), Number(C.timeEnd()), C.interval()).map(
|
|
1842
|
-
(s) =>
|
|
1862
|
+
(s) => e.unix(s).add(b.fake ? 1 : 0, "year").utc().format()
|
|
1843
1863
|
)
|
|
1844
1864
|
};
|
|
1845
1865
|
for (let s = 0; s < C.variablesLength(); s += p.memberLength ?? 1) {
|
|
1846
1866
|
const B = (t = (N = (a = C.variables(s).valuesArray()) == null ? void 0 : a.toString()) == null ? void 0 : N.split(",")) == null ? void 0 : t.map((h) => isNaN(h) ? null : Math.round(Number(h) * Y) / Y);
|
|
1847
|
-
|
|
1867
|
+
E.daily[b.daily[s / (p.memberLength ?? 1)]] = B;
|
|
1848
1868
|
}
|
|
1849
|
-
const I =
|
|
1869
|
+
const I = e();
|
|
1850
1870
|
this.debug && Z.debug("[%s] fetch daily variables cost: %d ms", p.requestId, I.diff(D, "ms"));
|
|
1851
1871
|
}
|
|
1852
|
-
O.push(
|
|
1872
|
+
O.push(E);
|
|
1853
1873
|
}
|
|
1854
1874
|
return O;
|
|
1855
1875
|
}
|
|
@@ -1903,7 +1923,7 @@ class G0 {
|
|
|
1903
1923
|
* @private
|
|
1904
1924
|
*/
|
|
1905
1925
|
prepare(M, b, p, O = {}) {
|
|
1906
|
-
const Y =
|
|
1926
|
+
const Y = e().utc(), o = M ? e.utc(M) : void 0, W = Y.clone().utc().add(b ? 9 : 14, "day");
|
|
1907
1927
|
if (M) {
|
|
1908
1928
|
const q = o.clone().utc().add(O.forecastDays ?? 1, "day");
|
|
1909
1929
|
q.isAfter(W) ? (q.subtract(1, "year"), o.isAfter(W) ? (o.subtract(1, "year"), p.start_dates = [
|
|
@@ -1924,7 +1944,7 @@ class G0 {
|
|
|
1924
1944
|
return Math.round(M * p) / p;
|
|
1925
1945
|
}
|
|
1926
1946
|
timezoneOffset(M, b) {
|
|
1927
|
-
const p = i0(M, b), O =
|
|
1947
|
+
const p = i0(M, b), O = e().tz(p).utcOffset();
|
|
1928
1948
|
return Math.round(O / 60 * 10) / 10;
|
|
1929
1949
|
}
|
|
1930
1950
|
/**
|
|
@@ -1969,7 +1989,7 @@ class G0 {
|
|
|
1969
1989
|
precision: 6,
|
|
1970
1990
|
selfHosted: !0
|
|
1971
1991
|
}) {
|
|
1972
|
-
var N, t,
|
|
1992
|
+
var N, t, m;
|
|
1973
1993
|
b = this.toStdLng(b), this.debug && Z.info("[%s] spot forecast params: %j", W.requestId, { lat: M, lng: b, datetime: p, simplify: O, withDaily: Y, withHourly: o, options: W });
|
|
1974
1994
|
const q = {
|
|
1975
1995
|
apikey: this.apikey,
|
|
@@ -1983,10 +2003,10 @@ class G0 {
|
|
|
1983
2003
|
let X;
|
|
1984
2004
|
if (p) {
|
|
1985
2005
|
const V = this.timezoneOffset(M, b);
|
|
1986
|
-
X =
|
|
2006
|
+
X = e.utc(p).utcOffset(V), X.subtract(V > 0 ? V : -V, "h");
|
|
1987
2007
|
}
|
|
1988
|
-
Y && (q.daily = ((t = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : t.split(",")) || []), X || (W.forecastDays = W.forecastDays || 1, W.pastDays = 0, o = !0), o && (q.hourly = ((
|
|
1989
|
-
const n = await this.weatherForecast(q, W),
|
|
2008
|
+
Y && (q.daily = ((t = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : t.split(",")) || []), X || (W.forecastDays = W.forecastDays || 1, W.pastDays = 0, o = !0), o && (q.hourly = ((m = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : m.split(",")) || []), W.pastDays = W.pastDays || 0, W.pastDays = W.pastDays > 7 ? 7 : W.pastDays < 0 ? 0 : W.pastDays, W.forecastDays = W.forecastDays ?? 1, W.forecastDays = W.forecastDays > 14 ? 14 : W.forecastDays < 0 ? 1 : W.forecastDays, this.prepare(X == null ? void 0 : X.utc().format(), !1, q, W);
|
|
2009
|
+
const n = await this.weatherForecast(q, W), L = {
|
|
1990
2010
|
apikey: this.apikey,
|
|
1991
2011
|
latitude: M,
|
|
1992
2012
|
longitude: b,
|
|
@@ -1995,8 +2015,8 @@ class G0 {
|
|
|
1995
2015
|
wind_speed_unit: "kn",
|
|
1996
2016
|
models: this.pickMarineModels(W.marineModels)
|
|
1997
2017
|
};
|
|
1998
|
-
Y && (
|
|
1999
|
-
const a = await this.marineForecast(
|
|
2018
|
+
Y && (L.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), X || (W.forecastDays = W.forecastDays || 1, o = !0), o && (L.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), this.prepare(X == null ? void 0 : X.utc().format(), !0, L, W);
|
|
2019
|
+
const a = await this.marineForecast(L, W);
|
|
2000
2020
|
return { weather: n, marine: a };
|
|
2001
2021
|
}
|
|
2002
2022
|
/**
|
|
@@ -2023,21 +2043,21 @@ class G0 {
|
|
|
2023
2043
|
async spotHistorical(M, b, p, O, Y = !0, o = !0, W = !1, q = {
|
|
2024
2044
|
precision: 6
|
|
2025
2045
|
}) {
|
|
2026
|
-
var
|
|
2046
|
+
var m, V;
|
|
2027
2047
|
b = this.toStdLng(b), this.debug && Z.info("[%s] spot historical params: %j", q.requestId, { lat: M, lng: b, startDate: p, endDate: O, withMarine: W, options: q });
|
|
2028
|
-
const X = this.timezoneOffset(M, b), n =
|
|
2029
|
-
n.subtract(X > 0 ? X : -X, "h"),
|
|
2048
|
+
const X = this.timezoneOffset(M, b), n = e.utc(p).utcOffset(X), L = e.utc(O).utcOffset(X);
|
|
2049
|
+
n.subtract(X > 0 ? X : -X, "h"), L.subtract(X > 0 ? X : -X, "h");
|
|
2030
2050
|
const a = {
|
|
2031
2051
|
apikey: this.apikey,
|
|
2032
2052
|
latitude: M,
|
|
2033
2053
|
longitude: b,
|
|
2034
2054
|
cell_selection: "sea",
|
|
2035
2055
|
wind_speed_unit: "kn",
|
|
2036
|
-
models: ((
|
|
2056
|
+
models: ((m = q.weatherModels) == null ? void 0 : m.split(",")) || ["best_match"],
|
|
2037
2057
|
timezone: "auto",
|
|
2038
2058
|
url: this.HISTORICAL.OM_URL,
|
|
2039
2059
|
start_date: n.format("YYYY-MM-DD"),
|
|
2040
|
-
end_date:
|
|
2060
|
+
end_date: L.format("YYYY-MM-DD")
|
|
2041
2061
|
};
|
|
2042
2062
|
Y && (a.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), o && (a.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
|
|
2043
2063
|
const N = await this.weatherForecast(a, q);
|
|
@@ -2055,7 +2075,7 @@ class G0 {
|
|
|
2055
2075
|
hourly: this.FORECAST.MARINE_VARIABLES.HOURLY.split(","),
|
|
2056
2076
|
url: this.FORECAST.OM_MARINE_URL,
|
|
2057
2077
|
start_date: n.format("YYYY-MM-DD"),
|
|
2058
|
-
end_date:
|
|
2078
|
+
end_date: L.format("YYYY-MM-DD")
|
|
2059
2079
|
};
|
|
2060
2080
|
t = await this.marineForecast(v, q);
|
|
2061
2081
|
}
|
|
@@ -2076,7 +2096,7 @@ class G0 {
|
|
|
2076
2096
|
precision: 6
|
|
2077
2097
|
}) {
|
|
2078
2098
|
b = this.toStdLng(b), this.debug && Z.info("[%s] spot seasonal params: %j", o.requestId, { lat: M, lng: b, startDate: p, endDate: O, options: o });
|
|
2079
|
-
const W = this.timezoneOffset(M, b), q =
|
|
2099
|
+
const W = this.timezoneOffset(M, b), q = e.utc(p).utcOffset(W), X = O ? e.utc(O).utcOffset(W) : q.clone().add(1, "month");
|
|
2080
2100
|
q.subtract(W > 0 ? W : -W, "h"), X.subtract(W > 0 ? W : -W, "h");
|
|
2081
2101
|
const n = {
|
|
2082
2102
|
apikey: this.apikey,
|
|
@@ -2115,9 +2135,9 @@ class G0 {
|
|
|
2115
2135
|
async spotClimate(M, b, p, O, Y = {
|
|
2116
2136
|
precision: 6
|
|
2117
2137
|
}) {
|
|
2118
|
-
var
|
|
2138
|
+
var L;
|
|
2119
2139
|
b = this.toStdLng(b), this.debug && Z.info("[%s] spot climate params: %j", Y.requestId, { lat: M, lng: b, startDate: p, endDate: O, options: Y });
|
|
2120
|
-
const o = this.timezoneOffset(M, b), W =
|
|
2140
|
+
const o = this.timezoneOffset(M, b), W = e.utc(p).utcOffset(o), q = O ? e.utc(O).utcOffset(o) : W.clone().add(1, "day");
|
|
2121
2141
|
q.subtract(o > 0 ? o : -o, "h"), W.subtract(o > 0 ? o : -o, "h");
|
|
2122
2142
|
const X = {
|
|
2123
2143
|
apikey: this.apikey,
|
|
@@ -2125,7 +2145,7 @@ class G0 {
|
|
|
2125
2145
|
longitude: b,
|
|
2126
2146
|
cell_selection: "sea",
|
|
2127
2147
|
wind_speed_unit: "kn",
|
|
2128
|
-
models: ((
|
|
2148
|
+
models: ((L = Y.weatherModels) == null ? void 0 : L.split(",")) || "EC_Earth3P_HR",
|
|
2129
2149
|
timezone: "auto",
|
|
2130
2150
|
url: this.CLIMATE.OM_URL,
|
|
2131
2151
|
start_date: W.format("YYYY-MM-DD"),
|
|
@@ -2136,9 +2156,9 @@ class G0 {
|
|
|
2136
2156
|
}
|
|
2137
2157
|
}
|
|
2138
2158
|
export {
|
|
2139
|
-
|
|
2140
|
-
|
|
2159
|
+
t0 as MARINE_MODELS,
|
|
2160
|
+
P0 as MeteoHelper,
|
|
2141
2161
|
G0 as MeteoHelper2,
|
|
2142
|
-
|
|
2162
|
+
V0 as WEATHER_MODELS,
|
|
2143
2163
|
n0 as WindyModel
|
|
2144
2164
|
};
|