@idm-plugin/meteo2 0.2.3 → 0.2.4
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 +85 -67
- 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,11 +155,11 @@ 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
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]), E = 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
|
-
|
|
162
|
-
utc:
|
|
161
|
+
L.push({
|
|
162
|
+
utc: e(n.ts[a]).utc().format(),
|
|
163
163
|
wave: {
|
|
164
164
|
sig: N,
|
|
165
165
|
wd: t,
|
|
@@ -169,7 +169,7 @@ class m0 {
|
|
|
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
|
}
|
|
@@ -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,13 @@ 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
|
+
},
|
|
1418
1424
|
{
|
|
1419
1425
|
rank: 1,
|
|
1420
1426
|
name: "GFS",
|
|
@@ -1550,7 +1556,13 @@ const I0 = [
|
|
|
1550
1556
|
categories: "bom_access_global",
|
|
1551
1557
|
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
1558
|
}
|
|
1553
|
-
],
|
|
1559
|
+
], t0 = [
|
|
1560
|
+
{
|
|
1561
|
+
rank: 0,
|
|
1562
|
+
name: "Best Match",
|
|
1563
|
+
alias: "BEST MATCH",
|
|
1564
|
+
model: "best_match"
|
|
1565
|
+
},
|
|
1554
1566
|
{
|
|
1555
1567
|
rank: 1,
|
|
1556
1568
|
name: "MFWAM",
|
|
@@ -1701,6 +1713,12 @@ class G0 {
|
|
|
1701
1713
|
});
|
|
1702
1714
|
this.apikey = M || "smE3JnDLHy3TizVv", this.debug = b;
|
|
1703
1715
|
}
|
|
1716
|
+
async standardWeatherModels() {
|
|
1717
|
+
return V0.filter((M) => !M.disabled && M.alias);
|
|
1718
|
+
}
|
|
1719
|
+
async standardMarineModels() {
|
|
1720
|
+
return t0.filter((M) => !M.disabled && M.alias);
|
|
1721
|
+
}
|
|
1704
1722
|
range(M, b, p) {
|
|
1705
1723
|
return Array.from({ length: (b - M) / p }, (O, Y) => M + Y * p);
|
|
1706
1724
|
}
|
|
@@ -1711,7 +1729,7 @@ class G0 {
|
|
|
1711
1729
|
*/
|
|
1712
1730
|
async weatherForecast(M, b = {}) {
|
|
1713
1731
|
try {
|
|
1714
|
-
const p =
|
|
1732
|
+
const p = e();
|
|
1715
1733
|
let O;
|
|
1716
1734
|
if (M.start_dates instanceof Array)
|
|
1717
1735
|
for (let o = 0; o < M.start_dates.length; o++) {
|
|
@@ -1731,7 +1749,7 @@ class G0 {
|
|
|
1731
1749
|
O = await this.parseWeatherData(o, M, b);
|
|
1732
1750
|
}
|
|
1733
1751
|
delete M.apikey;
|
|
1734
|
-
const Y =
|
|
1752
|
+
const Y = e();
|
|
1735
1753
|
return this.debug && Z.info("[%s] fetch weather api (%s) cost: %d ms", b.requestId, M.url, Y.diff(p, "ms")), O;
|
|
1736
1754
|
} catch (p) {
|
|
1737
1755
|
return Z.warn("[%s] weather forecast failed: %s, with %j", b.requestId, p, M), [];
|
|
@@ -1755,7 +1773,7 @@ class G0 {
|
|
|
1755
1773
|
*/
|
|
1756
1774
|
async marineForecast(M, b = {}) {
|
|
1757
1775
|
try {
|
|
1758
|
-
const p =
|
|
1776
|
+
const p = e();
|
|
1759
1777
|
let O;
|
|
1760
1778
|
if (M.start_dates instanceof Array)
|
|
1761
1779
|
for (let o = 0; o < M.start_dates.length; o++) {
|
|
@@ -1775,7 +1793,7 @@ class G0 {
|
|
|
1775
1793
|
O = await this.parseWeatherData(o, M, b);
|
|
1776
1794
|
}
|
|
1777
1795
|
delete M.apikey;
|
|
1778
|
-
const Y =
|
|
1796
|
+
const Y = e();
|
|
1779
1797
|
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
1798
|
} catch (p) {
|
|
1781
1799
|
return Z.warn("[%s] marine forecast failed: %s, with %j", b.requestId, p, M), [];
|
|
@@ -1789,64 +1807,64 @@ class G0 {
|
|
|
1789
1807
|
* @private
|
|
1790
1808
|
*/
|
|
1791
1809
|
async parseWeatherData(M, b, p = {}) {
|
|
1792
|
-
var o, W, q, X, n,
|
|
1810
|
+
var o, W, q, X, n, L, a, N, t;
|
|
1793
1811
|
const O = [], Y = Math.pow(10, p.precision || 6);
|
|
1794
1812
|
for (let E = 0; E < M.length; E++) {
|
|
1795
1813
|
const V = M[E], v = V.utcOffsetSeconds(), g = V.timezone(), F = V.current(), _ = V.hourly(), l = V.sixHourly(), C = V.daily(), m = {};
|
|
1796
1814
|
if (m.timezone = g || void 0, m.offset = this.prettyTimezoneOffset(v), m.model = b.models[E], F) {
|
|
1797
|
-
const D =
|
|
1815
|
+
const D = e();
|
|
1798
1816
|
m.current = {
|
|
1799
|
-
time:
|
|
1817
|
+
time: e.unix(Number(F.time())).utc().format()
|
|
1800
1818
|
};
|
|
1801
1819
|
for (let s = 0; s < F.variablesLength(); s++) {
|
|
1802
1820
|
const B = F.variables(s).value();
|
|
1803
1821
|
m.current[b.current[s]] = isNaN(B) ? null : Math.round(B * Y) / Y;
|
|
1804
1822
|
}
|
|
1805
|
-
const I =
|
|
1823
|
+
const I = e();
|
|
1806
1824
|
this.debug && Z.debug("[%s] fetch current variables cost: %d ms", p.requestId, I.diff(D, "ms"));
|
|
1807
1825
|
}
|
|
1808
1826
|
if (_) {
|
|
1809
|
-
const D =
|
|
1827
|
+
const D = e(), I = e.unix(Number(_.time())).add(b.fake ? 1 : 0, "year");
|
|
1810
1828
|
m.hourly = {
|
|
1811
1829
|
date: I.utc().format(),
|
|
1812
1830
|
time: this.range(Number(_.time()), Number(_.timeEnd()), _.interval()).map(
|
|
1813
|
-
(B) =>
|
|
1831
|
+
(B) => e.unix(B).add(b.fake ? 1 : 0, "year").diff(I, "h")
|
|
1814
1832
|
)
|
|
1815
1833
|
};
|
|
1816
1834
|
for (let B = 0; B < _.variablesLength(); B++) {
|
|
1817
1835
|
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
1836
|
m.hourly[b.hourly[B]] = h;
|
|
1819
1837
|
}
|
|
1820
|
-
const s =
|
|
1838
|
+
const s = e();
|
|
1821
1839
|
this.debug && Z.debug("[%s] fetch hourly variables cost: %d ms", p.requestId, s.diff(D, "ms"));
|
|
1822
1840
|
}
|
|
1823
1841
|
if (l) {
|
|
1824
|
-
const D =
|
|
1842
|
+
const D = e(), I = e.unix(Number(l.time())).add(b.fake ? 1 : 0, "year");
|
|
1825
1843
|
m.sixHourly = {
|
|
1826
1844
|
date: I.utc().format(),
|
|
1827
1845
|
time: this.range(Number(l.time()), Number(l.timeEnd()), l.interval()).map(
|
|
1828
|
-
(B) =>
|
|
1846
|
+
(B) => e.unix(B).add(b.fake ? 1 : 0, "year").diff(I, "h")
|
|
1829
1847
|
)
|
|
1830
1848
|
};
|
|
1831
1849
|
for (let B = 0; B < l.variablesLength(); B += p.memberLength ?? 1) {
|
|
1832
|
-
const h = (
|
|
1850
|
+
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);
|
|
1833
1851
|
l.variables(B), m.sixHourly[b.six_hourly[B / (p.memberLength ?? 1)]] = h;
|
|
1834
1852
|
}
|
|
1835
|
-
const s =
|
|
1853
|
+
const s = e();
|
|
1836
1854
|
this.debug && Z.debug("[%s] fetch 6-hourly variables cost: %d ms", p.requestId, s.diff(D, "ms"));
|
|
1837
1855
|
}
|
|
1838
1856
|
if (C) {
|
|
1839
|
-
const D =
|
|
1857
|
+
const D = e();
|
|
1840
1858
|
m.daily = {
|
|
1841
1859
|
time: this.range(Number(C.time()), Number(C.timeEnd()), C.interval()).map(
|
|
1842
|
-
(s) =>
|
|
1860
|
+
(s) => e.unix(s).add(b.fake ? 1 : 0, "year").utc().format()
|
|
1843
1861
|
)
|
|
1844
1862
|
};
|
|
1845
1863
|
for (let s = 0; s < C.variablesLength(); s += p.memberLength ?? 1) {
|
|
1846
1864
|
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
1865
|
m.daily[b.daily[s / (p.memberLength ?? 1)]] = B;
|
|
1848
1866
|
}
|
|
1849
|
-
const I =
|
|
1867
|
+
const I = e();
|
|
1850
1868
|
this.debug && Z.debug("[%s] fetch daily variables cost: %d ms", p.requestId, I.diff(D, "ms"));
|
|
1851
1869
|
}
|
|
1852
1870
|
O.push(m);
|
|
@@ -1903,7 +1921,7 @@ class G0 {
|
|
|
1903
1921
|
* @private
|
|
1904
1922
|
*/
|
|
1905
1923
|
prepare(M, b, p, O = {}) {
|
|
1906
|
-
const Y =
|
|
1924
|
+
const Y = e().utc(), o = M ? e.utc(M) : void 0, W = Y.clone().utc().add(b ? 9 : 14, "day");
|
|
1907
1925
|
if (M) {
|
|
1908
1926
|
const q = o.clone().utc().add(O.forecastDays ?? 1, "day");
|
|
1909
1927
|
q.isAfter(W) ? (q.subtract(1, "year"), o.isAfter(W) ? (o.subtract(1, "year"), p.start_dates = [
|
|
@@ -1924,7 +1942,7 @@ class G0 {
|
|
|
1924
1942
|
return Math.round(M * p) / p;
|
|
1925
1943
|
}
|
|
1926
1944
|
timezoneOffset(M, b) {
|
|
1927
|
-
const p = i0(M, b), O =
|
|
1945
|
+
const p = i0(M, b), O = e().tz(p).utcOffset();
|
|
1928
1946
|
return Math.round(O / 60 * 10) / 10;
|
|
1929
1947
|
}
|
|
1930
1948
|
/**
|
|
@@ -1983,10 +2001,10 @@ class G0 {
|
|
|
1983
2001
|
let X;
|
|
1984
2002
|
if (p) {
|
|
1985
2003
|
const V = this.timezoneOffset(M, b);
|
|
1986
|
-
X =
|
|
2004
|
+
X = e.utc(p).utcOffset(V), X.subtract(V > 0 ? V : -V, "h");
|
|
1987
2005
|
}
|
|
1988
2006
|
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 = ((E = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : E.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);
|
|
1989
|
-
const n = await this.weatherForecast(q, W),
|
|
2007
|
+
const n = await this.weatherForecast(q, W), L = {
|
|
1990
2008
|
apikey: this.apikey,
|
|
1991
2009
|
latitude: M,
|
|
1992
2010
|
longitude: b,
|
|
@@ -1995,8 +2013,8 @@ class G0 {
|
|
|
1995
2013
|
wind_speed_unit: "kn",
|
|
1996
2014
|
models: this.pickMarineModels(W.marineModels)
|
|
1997
2015
|
};
|
|
1998
|
-
Y && (
|
|
1999
|
-
const a = await this.marineForecast(
|
|
2016
|
+
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);
|
|
2017
|
+
const a = await this.marineForecast(L, W);
|
|
2000
2018
|
return { weather: n, marine: a };
|
|
2001
2019
|
}
|
|
2002
2020
|
/**
|
|
@@ -2025,8 +2043,8 @@ class G0 {
|
|
|
2025
2043
|
}) {
|
|
2026
2044
|
var E, V;
|
|
2027
2045
|
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"),
|
|
2046
|
+
const X = this.timezoneOffset(M, b), n = e.utc(p).utcOffset(X), L = e.utc(O).utcOffset(X);
|
|
2047
|
+
n.subtract(X > 0 ? X : -X, "h"), L.subtract(X > 0 ? X : -X, "h");
|
|
2030
2048
|
const a = {
|
|
2031
2049
|
apikey: this.apikey,
|
|
2032
2050
|
latitude: M,
|
|
@@ -2037,7 +2055,7 @@ class G0 {
|
|
|
2037
2055
|
timezone: "auto",
|
|
2038
2056
|
url: this.HISTORICAL.OM_URL,
|
|
2039
2057
|
start_date: n.format("YYYY-MM-DD"),
|
|
2040
|
-
end_date:
|
|
2058
|
+
end_date: L.format("YYYY-MM-DD")
|
|
2041
2059
|
};
|
|
2042
2060
|
Y && (a.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), o && (a.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
|
|
2043
2061
|
const N = await this.weatherForecast(a, q);
|
|
@@ -2055,7 +2073,7 @@ class G0 {
|
|
|
2055
2073
|
hourly: this.FORECAST.MARINE_VARIABLES.HOURLY.split(","),
|
|
2056
2074
|
url: this.FORECAST.OM_MARINE_URL,
|
|
2057
2075
|
start_date: n.format("YYYY-MM-DD"),
|
|
2058
|
-
end_date:
|
|
2076
|
+
end_date: L.format("YYYY-MM-DD")
|
|
2059
2077
|
};
|
|
2060
2078
|
t = await this.marineForecast(v, q);
|
|
2061
2079
|
}
|
|
@@ -2076,7 +2094,7 @@ class G0 {
|
|
|
2076
2094
|
precision: 6
|
|
2077
2095
|
}) {
|
|
2078
2096
|
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 =
|
|
2097
|
+
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
2098
|
q.subtract(W > 0 ? W : -W, "h"), X.subtract(W > 0 ? W : -W, "h");
|
|
2081
2099
|
const n = {
|
|
2082
2100
|
apikey: this.apikey,
|
|
@@ -2115,9 +2133,9 @@ class G0 {
|
|
|
2115
2133
|
async spotClimate(M, b, p, O, Y = {
|
|
2116
2134
|
precision: 6
|
|
2117
2135
|
}) {
|
|
2118
|
-
var
|
|
2136
|
+
var L;
|
|
2119
2137
|
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 =
|
|
2138
|
+
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
2139
|
q.subtract(o > 0 ? o : -o, "h"), W.subtract(o > 0 ? o : -o, "h");
|
|
2122
2140
|
const X = {
|
|
2123
2141
|
apikey: this.apikey,
|
|
@@ -2125,7 +2143,7 @@ class G0 {
|
|
|
2125
2143
|
longitude: b,
|
|
2126
2144
|
cell_selection: "sea",
|
|
2127
2145
|
wind_speed_unit: "kn",
|
|
2128
|
-
models: ((
|
|
2146
|
+
models: ((L = Y.weatherModels) == null ? void 0 : L.split(",")) || "EC_Earth3P_HR",
|
|
2129
2147
|
timezone: "auto",
|
|
2130
2148
|
url: this.CLIMATE.OM_URL,
|
|
2131
2149
|
start_date: W.format("YYYY-MM-DD"),
|
|
@@ -2136,9 +2154,9 @@ class G0 {
|
|
|
2136
2154
|
}
|
|
2137
2155
|
}
|
|
2138
2156
|
export {
|
|
2139
|
-
|
|
2140
|
-
|
|
2157
|
+
t0 as MARINE_MODELS,
|
|
2158
|
+
P0 as MeteoHelper,
|
|
2141
2159
|
G0 as MeteoHelper2,
|
|
2142
|
-
|
|
2160
|
+
V0 as WEATHER_MODELS,
|
|
2143
2161
|
n0 as WindyModel
|
|
2144
2162
|
};
|