@idm-plugin/meteo2 0.2.4 → 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 +26 -24
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -157,13 +157,13 @@ class P0 {
|
|
|
157
157
|
}
|
|
158
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]),
|
|
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
161
|
L.push({
|
|
162
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
|
});
|
|
@@ -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;
|
|
@@ -1419,7 +1419,8 @@ const V0 = [
|
|
|
1419
1419
|
rank: 0,
|
|
1420
1420
|
name: "Best Match",
|
|
1421
1421
|
alias: "BEST MATCH",
|
|
1422
|
-
model: "best_match"
|
|
1422
|
+
model: "best_match",
|
|
1423
|
+
models: ["best_match"]
|
|
1423
1424
|
},
|
|
1424
1425
|
{
|
|
1425
1426
|
rank: 1,
|
|
@@ -1561,7 +1562,8 @@ const V0 = [
|
|
|
1561
1562
|
rank: 0,
|
|
1562
1563
|
name: "Best Match",
|
|
1563
1564
|
alias: "BEST MATCH",
|
|
1564
|
-
model: "best_match"
|
|
1565
|
+
model: "best_match",
|
|
1566
|
+
models: ["best_match"]
|
|
1565
1567
|
},
|
|
1566
1568
|
{
|
|
1567
1569
|
rank: 1,
|
|
@@ -1809,23 +1811,23 @@ class G0 {
|
|
|
1809
1811
|
async parseWeatherData(M, b, p = {}) {
|
|
1810
1812
|
var o, W, q, X, n, L, a, N, t;
|
|
1811
1813
|
const O = [], Y = Math.pow(10, p.precision || 6);
|
|
1812
|
-
for (let
|
|
1813
|
-
const V = M[
|
|
1814
|
-
if (
|
|
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) {
|
|
1815
1817
|
const D = e();
|
|
1816
|
-
|
|
1818
|
+
E.current = {
|
|
1817
1819
|
time: e.unix(Number(F.time())).utc().format()
|
|
1818
1820
|
};
|
|
1819
1821
|
for (let s = 0; s < F.variablesLength(); s++) {
|
|
1820
1822
|
const B = F.variables(s).value();
|
|
1821
|
-
|
|
1823
|
+
E.current[b.current[s]] = isNaN(B) ? null : Math.round(B * Y) / Y;
|
|
1822
1824
|
}
|
|
1823
1825
|
const I = e();
|
|
1824
1826
|
this.debug && Z.debug("[%s] fetch current variables cost: %d ms", p.requestId, I.diff(D, "ms"));
|
|
1825
1827
|
}
|
|
1826
1828
|
if (_) {
|
|
1827
1829
|
const D = e(), I = e.unix(Number(_.time())).add(b.fake ? 1 : 0, "year");
|
|
1828
|
-
|
|
1830
|
+
E.hourly = {
|
|
1829
1831
|
date: I.utc().format(),
|
|
1830
1832
|
time: this.range(Number(_.time()), Number(_.timeEnd()), _.interval()).map(
|
|
1831
1833
|
(B) => e.unix(B).add(b.fake ? 1 : 0, "year").diff(I, "h")
|
|
@@ -1833,14 +1835,14 @@ class G0 {
|
|
|
1833
1835
|
};
|
|
1834
1836
|
for (let B = 0; B < _.variablesLength(); B++) {
|
|
1835
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);
|
|
1836
|
-
|
|
1838
|
+
E.hourly[b.hourly[B]] = h;
|
|
1837
1839
|
}
|
|
1838
1840
|
const s = e();
|
|
1839
1841
|
this.debug && Z.debug("[%s] fetch hourly variables cost: %d ms", p.requestId, s.diff(D, "ms"));
|
|
1840
1842
|
}
|
|
1841
1843
|
if (l) {
|
|
1842
1844
|
const D = e(), I = e.unix(Number(l.time())).add(b.fake ? 1 : 0, "year");
|
|
1843
|
-
|
|
1845
|
+
E.sixHourly = {
|
|
1844
1846
|
date: I.utc().format(),
|
|
1845
1847
|
time: this.range(Number(l.time()), Number(l.timeEnd()), l.interval()).map(
|
|
1846
1848
|
(B) => e.unix(B).add(b.fake ? 1 : 0, "year").diff(I, "h")
|
|
@@ -1848,26 +1850,26 @@ class G0 {
|
|
|
1848
1850
|
};
|
|
1849
1851
|
for (let B = 0; B < l.variablesLength(); B += p.memberLength ?? 1) {
|
|
1850
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);
|
|
1851
|
-
l.variables(B),
|
|
1853
|
+
l.variables(B), E.sixHourly[b.six_hourly[B / (p.memberLength ?? 1)]] = h;
|
|
1852
1854
|
}
|
|
1853
1855
|
const s = e();
|
|
1854
1856
|
this.debug && Z.debug("[%s] fetch 6-hourly variables cost: %d ms", p.requestId, s.diff(D, "ms"));
|
|
1855
1857
|
}
|
|
1856
1858
|
if (C) {
|
|
1857
1859
|
const D = e();
|
|
1858
|
-
|
|
1860
|
+
E.daily = {
|
|
1859
1861
|
time: this.range(Number(C.time()), Number(C.timeEnd()), C.interval()).map(
|
|
1860
1862
|
(s) => e.unix(s).add(b.fake ? 1 : 0, "year").utc().format()
|
|
1861
1863
|
)
|
|
1862
1864
|
};
|
|
1863
1865
|
for (let s = 0; s < C.variablesLength(); s += p.memberLength ?? 1) {
|
|
1864
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);
|
|
1865
|
-
|
|
1867
|
+
E.daily[b.daily[s / (p.memberLength ?? 1)]] = B;
|
|
1866
1868
|
}
|
|
1867
1869
|
const I = e();
|
|
1868
1870
|
this.debug && Z.debug("[%s] fetch daily variables cost: %d ms", p.requestId, I.diff(D, "ms"));
|
|
1869
1871
|
}
|
|
1870
|
-
O.push(
|
|
1872
|
+
O.push(E);
|
|
1871
1873
|
}
|
|
1872
1874
|
return O;
|
|
1873
1875
|
}
|
|
@@ -1987,7 +1989,7 @@ class G0 {
|
|
|
1987
1989
|
precision: 6,
|
|
1988
1990
|
selfHosted: !0
|
|
1989
1991
|
}) {
|
|
1990
|
-
var N, t,
|
|
1992
|
+
var N, t, m;
|
|
1991
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 });
|
|
1992
1994
|
const q = {
|
|
1993
1995
|
apikey: this.apikey,
|
|
@@ -2003,7 +2005,7 @@ class G0 {
|
|
|
2003
2005
|
const V = this.timezoneOffset(M, b);
|
|
2004
2006
|
X = e.utc(p).utcOffset(V), X.subtract(V > 0 ? V : -V, "h");
|
|
2005
2007
|
}
|
|
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 = ((
|
|
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);
|
|
2007
2009
|
const n = await this.weatherForecast(q, W), L = {
|
|
2008
2010
|
apikey: this.apikey,
|
|
2009
2011
|
latitude: M,
|
|
@@ -2041,7 +2043,7 @@ class G0 {
|
|
|
2041
2043
|
async spotHistorical(M, b, p, O, Y = !0, o = !0, W = !1, q = {
|
|
2042
2044
|
precision: 6
|
|
2043
2045
|
}) {
|
|
2044
|
-
var
|
|
2046
|
+
var m, V;
|
|
2045
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 });
|
|
2046
2048
|
const X = this.timezoneOffset(M, b), n = e.utc(p).utcOffset(X), L = e.utc(O).utcOffset(X);
|
|
2047
2049
|
n.subtract(X > 0 ? X : -X, "h"), L.subtract(X > 0 ? X : -X, "h");
|
|
@@ -2051,7 +2053,7 @@ class G0 {
|
|
|
2051
2053
|
longitude: b,
|
|
2052
2054
|
cell_selection: "sea",
|
|
2053
2055
|
wind_speed_unit: "kn",
|
|
2054
|
-
models: ((
|
|
2056
|
+
models: ((m = q.weatherModels) == null ? void 0 : m.split(",")) || ["best_match"],
|
|
2055
2057
|
timezone: "auto",
|
|
2056
2058
|
url: this.HISTORICAL.OM_URL,
|
|
2057
2059
|
start_date: n.format("YYYY-MM-DD"),
|