@idm-plugin/meteo2 0.4.6 → 0.4.7
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 +296 -290
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@ 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
|
|
5
|
+
import n from "moment";
|
|
6
|
+
import v from "got";
|
|
7
|
+
import { fetchWeatherApi as $ } from "openmeteo";
|
|
8
8
|
import { Meteo2Assist as k } from "@idm-plugin/meteo";
|
|
9
9
|
let r;
|
|
10
10
|
try {
|
|
@@ -25,24 +25,24 @@ 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
|
|
28
|
+
const W = n(p), q = {
|
|
29
29
|
searchParams: {
|
|
30
30
|
lng: M,
|
|
31
31
|
lat: b,
|
|
32
|
-
ts:
|
|
32
|
+
ts: W.valueOf(),
|
|
33
33
|
params: O ? "watertemp" : void 0,
|
|
34
34
|
source: o == null ? void 0 : o.toLowerCase()
|
|
35
35
|
},
|
|
36
36
|
timeout: 3e4
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
if (r == null || r.info("[%s] get meteo(cost: %d ms) from %s with options: %j", Y.requestId, N - R,
|
|
37
|
+
}, d = n(), R = d.valueOf();
|
|
38
|
+
W.isBefore(d.subtract(1, "month")) && (r == null || r.warn("[%s] get history meteo on %s: %j", Y.requestId, W.format(), q));
|
|
39
|
+
const L = "https://aod4idm.idmwx.com/api/ocean/point", a = await v.get(L, q).json(), N = n().valueOf();
|
|
40
|
+
if (r == null || r.info("[%s] get meteo(cost: %d ms) from %s with options: %j", Y.requestId, N - R, L, q), (a == null ? void 0 : a.code) === 0)
|
|
41
41
|
return {
|
|
42
|
-
...
|
|
42
|
+
...a.data,
|
|
43
43
|
source: o
|
|
44
44
|
};
|
|
45
|
-
r == null || r.warn("[%s] get meteo failed: %j", Y.requestId,
|
|
45
|
+
r == null || r.warn("[%s] get meteo failed: %j", Y.requestId, a);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* 点查海洋气象要素(指定要素组合)
|
|
@@ -60,24 +60,24 @@ 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
|
|
63
|
+
const W = n(p), q = {
|
|
64
64
|
searchParams: {
|
|
65
65
|
lng: M,
|
|
66
66
|
lat: b,
|
|
67
|
-
ts:
|
|
67
|
+
ts: W.valueOf(),
|
|
68
68
|
params: O,
|
|
69
69
|
source: o == null ? void 0 : o.toLowerCase()
|
|
70
70
|
},
|
|
71
71
|
timeout: 3e4
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
if (r == null || r.info("[%s] get factors(cost: %d ms) from %s with options: %j", Y.requestId, N - R,
|
|
72
|
+
}, d = n(), R = d.valueOf();
|
|
73
|
+
W.isBefore(d.subtract(1, "month")) && (r == null || r.warn("[%s] get history factors on %s: %j", Y.requestId, W.format(), q));
|
|
74
|
+
const L = "https://aod4idm.idmwx.com/api/ocean/factor", a = await v.get(L, q).json(), N = n().valueOf();
|
|
75
|
+
if (r == null || r.info("[%s] get factors(cost: %d ms) from %s with options: %j", Y.requestId, N - R, L, q), (a == null ? void 0 : a.code) === 0)
|
|
76
76
|
return {
|
|
77
|
-
...
|
|
77
|
+
...a.data,
|
|
78
78
|
source: o
|
|
79
79
|
};
|
|
80
|
-
r == null || r.warn("[%s] get factors failed: %j", Y.requestId,
|
|
80
|
+
r == null || r.warn("[%s] get factors failed: %j", Y.requestId, a);
|
|
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
|
|
90
|
-
const q = await
|
|
89
|
+
let W = n().valueOf();
|
|
90
|
+
const q = await v.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
|
|
120
|
-
r == null || r.info("[%s] get gfs-factors(cost: %d ms) from %s", O.requestId,
|
|
121
|
-
const R = await
|
|
119
|
+
let d = n().valueOf();
|
|
120
|
+
r == null || r.info("[%s] get gfs-factors(cost: %d ms) from %s", O.requestId, d - W, o), W = d;
|
|
121
|
+
const R = await v.post(o, {
|
|
122
122
|
headers: {
|
|
123
123
|
"Content-Type": "application/json"
|
|
124
124
|
},
|
|
@@ -131,36 +131,36 @@ class m0 {
|
|
|
131
131
|
levels: ["surface"]
|
|
132
132
|
}
|
|
133
133
|
}).json();
|
|
134
|
-
|
|
135
|
-
for (let
|
|
136
|
-
const N = this.populateUVFactor(q["wind_u-surface"][
|
|
134
|
+
d = n().valueOf(), r == null || r.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", O.requestId, d - W, o);
|
|
135
|
+
for (let a = 0; a < q.ts.length; a++) {
|
|
136
|
+
const N = this.populateUVFactor(q["wind_u-surface"][a], q["wind_v-surface"][a], !1, O);
|
|
137
137
|
N.scale = this.calculateBeaufortWindForceScale(N.speed), Y.push({
|
|
138
|
-
utc:
|
|
139
|
-
temp: q["temp-surface"][
|
|
140
|
-
dp_temp: q["dewpoint-surface"][
|
|
138
|
+
utc: n(q.ts[a]).utc().format(),
|
|
139
|
+
temp: q["temp-surface"][a] ? Math.round((q["temp-surface"][a] - 273.15) * 100) / 100 : void 0,
|
|
140
|
+
dp_temp: q["dewpoint-surface"][a] ? Math.round((q["dewpoint-surface"][a] - 273.15) * 100) / 100 : void 0,
|
|
141
141
|
precip: {
|
|
142
|
-
inter3h: q["past3hprecip-surface"][
|
|
143
|
-
inter3hSnow: q["past3hsnowprecip-surface"][
|
|
144
|
-
inter3hConv: q["past3hconvprecip-surface"][
|
|
142
|
+
inter3h: q["past3hprecip-surface"][a] ? Math.round(q["past3hprecip-surface"][a] * 1e3 * 1e3) / 1e3 : 0,
|
|
143
|
+
inter3hSnow: q["past3hsnowprecip-surface"][a] ? Math.round(q["past3hsnowprecip-surface"][a] * 1e3 * 1e3) / 1e3 : 0,
|
|
144
|
+
inter3hConv: q["past3hconvprecip-surface"][a] ? Math.round(q["past3hconvprecip-surface"][a] * 1e3 * 1e3) / 1e3 : 0
|
|
145
145
|
},
|
|
146
146
|
wind: N,
|
|
147
147
|
gusts: {
|
|
148
|
-
speed: Math.round((q["gust-surface"][
|
|
149
|
-
kts: this.convertMs2Kts(q["gust-surface"][
|
|
148
|
+
speed: Math.round((q["gust-surface"][a] || 0) * 100) / 100,
|
|
149
|
+
kts: this.convertMs2Kts(q["gust-surface"][a])
|
|
150
150
|
},
|
|
151
|
-
lclouds: q["lclouds-surface"][
|
|
152
|
-
mclouds: q["mclouds-surface"][
|
|
153
|
-
hclouds: q["hclouds-surface"][
|
|
154
|
-
rh: q["rh-surface"][
|
|
155
|
-
gh: q["gh-surface"][
|
|
156
|
-
pressure: Math.round(q["pressure-surface"][
|
|
151
|
+
lclouds: q["lclouds-surface"][a] ? Math.round(q["lclouds-surface"][a] * 100) / 100 : 0,
|
|
152
|
+
mclouds: q["mclouds-surface"][a] ? Math.round(q["mclouds-surface"][a] * 100) / 100 : 0,
|
|
153
|
+
hclouds: q["hclouds-surface"][a] ? Math.round(q["hclouds-surface"][a] * 100) / 100 : 0,
|
|
154
|
+
rh: q["rh-surface"][a] ? Math.round(q["rh-surface"][a] * 100) / 100 : 0,
|
|
155
|
+
gh: q["gh-surface"][a] ? Math.round(q["gh-surface"][a] * 100) / 100 : 0,
|
|
156
|
+
pressure: Math.round(q["pressure-surface"][a] / 100 * 100) / 100
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
-
const
|
|
160
|
-
for (let
|
|
161
|
-
const N = this.calculateDouglasScale(R["waves_height-surface"][
|
|
162
|
-
|
|
163
|
-
utc:
|
|
159
|
+
const L = [];
|
|
160
|
+
for (let a = 0; a < R.ts.length; a++) {
|
|
161
|
+
const N = this.calculateDouglasScale(R["waves_height-surface"][a], R["waves_direction-surface"][a], R["waves_period-surface"][a]), S = this.calculateDouglasScale(R["wwaves_height-surface"][a], R["wwaves_direction-surface"][a], R["wwaves_period-surface"][a]), l = this.calculateDouglasScale(R["swell1_height-surface"][a], R["swell1_direction-surface"][a], R["swell1_period-surface"][a]), V = this.calculateDouglasScale(R["swell2_height-surface"][a], R["swell2_direction-surface"][a], R["swell2_period-surface"][a]);
|
|
162
|
+
L.push({
|
|
163
|
+
utc: n(R.ts[a]).utc().format(),
|
|
164
164
|
wave: {
|
|
165
165
|
sig: N,
|
|
166
166
|
wd: S,
|
|
@@ -169,12 +169,12 @@ class m0 {
|
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
for (const
|
|
173
|
-
const N =
|
|
174
|
-
|
|
172
|
+
for (const a of Y) {
|
|
173
|
+
const N = L.find((S) => S.utc === a.utc);
|
|
174
|
+
a.wave = N == null ? void 0 : N.wave;
|
|
175
175
|
}
|
|
176
|
-
} catch (
|
|
177
|
-
r.warn("[%s] get-gfs-factor failed: %s", O.requestId,
|
|
176
|
+
} catch (W) {
|
|
177
|
+
r.warn("[%s] get-gfs-factor failed: %s", O.requestId, W);
|
|
178
178
|
}
|
|
179
179
|
return Y;
|
|
180
180
|
}
|
|
@@ -186,12 +186,12 @@ class m0 {
|
|
|
186
186
|
* @param options
|
|
187
187
|
*/
|
|
188
188
|
static populateUVFactor(M, b, p = !1, O = {}) {
|
|
189
|
-
const o = Math.round(Math.sqrt(Math.pow(M, 2) + Math.pow(b, 2)) * 1e4) / 1e4, { degree: Y, direction:
|
|
189
|
+
const o = Math.round(Math.sqrt(Math.pow(M, 2) + Math.pow(b, 2)) * 1e4) / 1e4, { degree: Y, direction: W } = this.calculateUVDirection(M, b, p, O), q = this.convertMs2Kts(o);
|
|
190
190
|
return {
|
|
191
191
|
speed: o,
|
|
192
192
|
kts: q,
|
|
193
193
|
degree: Y,
|
|
194
|
-
direction:
|
|
194
|
+
direction: W,
|
|
195
195
|
eastward: Math.round(M * 1e4) / 1e4,
|
|
196
196
|
northward: Math.round(b * 1e4) / 1e4
|
|
197
197
|
};
|
|
@@ -269,10 +269,10 @@ var A0 = { exports: {} };
|
|
|
269
269
|
throw new RangeError("invalid coordinates");
|
|
270
270
|
if (90 <= b)
|
|
271
271
|
return "Etc/GMT";
|
|
272
|
-
var Y = -1,
|
|
273
|
-
for (
|
|
274
|
-
|
|
275
|
-
return o[
|
|
272
|
+
var Y = -1, W = 48 * (180 + p) / 360.00000000000006, q = 24 * (90 - b) / 180.00000000000003, d = 0 | W, R = 0 | q, L = 96 * R + 2 * d;
|
|
273
|
+
for (L = 56 * O.charCodeAt(L) + O.charCodeAt(L + 1) - 1995; L + o.length < 3136; )
|
|
274
|
+
L = 56 * O.charCodeAt(L = 8 * (Y = Y + L + 1) + 4 * (R = 0 | (q = 2 * (q - R) % 2)) + 2 * (d = 0 | (W = 2 * (W - d) % 2)) + 2304) + O.charCodeAt(L + 1) - 1995;
|
|
275
|
+
return o[L + o.length - 3136];
|
|
276
276
|
}
|
|
277
277
|
e.exports = M;
|
|
278
278
|
})(A0);
|
|
@@ -286,62 +286,62 @@ 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(n) : b(M.moment);
|
|
290
290
|
})(e0, function(M) {
|
|
291
291
|
M.version === void 0 && M.default && (M = M.default);
|
|
292
|
-
var b = "0.5.48", p = {}, O = {}, o = {}, Y = {},
|
|
292
|
+
var b = "0.5.48", p = {}, O = {}, o = {}, Y = {}, W = {}, q;
|
|
293
293
|
(!M || typeof M.version != "string") && w("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
294
|
-
var
|
|
295
|
-
(R < 2 || R === 2 &&
|
|
296
|
-
function
|
|
294
|
+
var d = M.version.split("."), R = +d[0], L = +d[1];
|
|
295
|
+
(R < 2 || R === 2 && L < 6) && w("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
|
|
296
|
+
function a(z) {
|
|
297
297
|
return z > 96 ? z - 87 : z > 64 ? z - 29 : z - 48;
|
|
298
298
|
}
|
|
299
299
|
function N(z) {
|
|
300
|
-
var
|
|
301
|
-
for (z.charCodeAt(0) === 45 && (
|
|
302
|
-
t =
|
|
303
|
-
for (
|
|
304
|
-
i = i / 60, t =
|
|
300
|
+
var A = 0, c = z.split("."), X = c[0], T = c[1] || "", i = 1, t, f = 0, B = 1;
|
|
301
|
+
for (z.charCodeAt(0) === 45 && (A = 1, B = -1), A; A < X.length; A++)
|
|
302
|
+
t = a(X.charCodeAt(A)), f = 60 * f + t;
|
|
303
|
+
for (A = 0; A < T.length; A++)
|
|
304
|
+
i = i / 60, t = a(T.charCodeAt(A)), f += t * i;
|
|
305
305
|
return f * B;
|
|
306
306
|
}
|
|
307
307
|
function S(z) {
|
|
308
|
-
for (var
|
|
309
|
-
z[
|
|
308
|
+
for (var A = 0; A < z.length; A++)
|
|
309
|
+
z[A] = N(z[A]);
|
|
310
310
|
}
|
|
311
|
-
function l(z,
|
|
312
|
-
for (var
|
|
313
|
-
z[
|
|
314
|
-
z[
|
|
311
|
+
function l(z, A) {
|
|
312
|
+
for (var c = 0; c < A; c++)
|
|
313
|
+
z[c] = Math.round((z[c - 1] || 0) + z[c] * 6e4);
|
|
314
|
+
z[A - 1] = 1 / 0;
|
|
315
315
|
}
|
|
316
|
-
function V(z,
|
|
317
|
-
var
|
|
318
|
-
for (
|
|
319
|
-
|
|
320
|
-
return
|
|
316
|
+
function V(z, A) {
|
|
317
|
+
var c = [], X;
|
|
318
|
+
for (X = 0; X < A.length; X++)
|
|
319
|
+
c[X] = z[A[X]];
|
|
320
|
+
return c;
|
|
321
321
|
}
|
|
322
322
|
function E(z) {
|
|
323
|
-
var
|
|
324
|
-
return S(
|
|
325
|
-
name:
|
|
326
|
-
abbrs: V(
|
|
327
|
-
offsets: V(
|
|
328
|
-
untils:
|
|
329
|
-
population:
|
|
323
|
+
var A = z.split("|"), c = A[2].split(" "), X = A[3].split(""), T = A[4].split(" ");
|
|
324
|
+
return S(c), S(X), S(T), l(T, X.length), {
|
|
325
|
+
name: A[0],
|
|
326
|
+
abbrs: V(A[1].split(" "), X),
|
|
327
|
+
offsets: V(c, X),
|
|
328
|
+
untils: T,
|
|
329
|
+
population: A[5] | 0
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
332
|
function h(z) {
|
|
333
333
|
z && this._set(E(z));
|
|
334
334
|
}
|
|
335
|
-
function y(z,
|
|
336
|
-
var
|
|
337
|
-
if (z <
|
|
335
|
+
function y(z, A) {
|
|
336
|
+
var c = A.length;
|
|
337
|
+
if (z < A[0])
|
|
338
338
|
return 0;
|
|
339
|
-
if (
|
|
340
|
-
return
|
|
341
|
-
if (z >= c
|
|
339
|
+
if (c > 1 && A[c - 1] === 1 / 0 && z >= A[c - 2])
|
|
340
|
+
return c - 1;
|
|
341
|
+
if (z >= A[c - 1])
|
|
342
342
|
return -1;
|
|
343
|
-
for (var
|
|
344
|
-
|
|
343
|
+
for (var X, T = 0, i = c - 1; i - T > 1; )
|
|
344
|
+
X = Math.floor((T + i) / 2), A[X] <= z ? T = X : i = X;
|
|
345
345
|
return i;
|
|
346
346
|
}
|
|
347
347
|
h.prototype = {
|
|
@@ -349,22 +349,22 @@ 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
|
|
353
|
-
if (
|
|
354
|
-
return
|
|
352
|
+
var A = +z, c = this.untils, X;
|
|
353
|
+
if (X = y(A, c), X >= 0)
|
|
354
|
+
return X;
|
|
355
355
|
},
|
|
356
356
|
countries: function() {
|
|
357
357
|
var z = this.name;
|
|
358
|
-
return Object.keys(o).filter(function(
|
|
359
|
-
return o[
|
|
358
|
+
return Object.keys(o).filter(function(A) {
|
|
359
|
+
return o[A].zones.indexOf(z) !== -1;
|
|
360
360
|
});
|
|
361
361
|
},
|
|
362
362
|
parse: function(z) {
|
|
363
|
-
var
|
|
364
|
-
for (B = 0; B <
|
|
365
|
-
if (i =
|
|
366
|
-
return
|
|
367
|
-
return
|
|
363
|
+
var A = +z, c = this.offsets, X = this.untils, T = X.length - 1, i, t, f, B;
|
|
364
|
+
for (B = 0; B < T; B++)
|
|
365
|
+
if (i = c[B], t = c[B + 1], f = c[B && B - 1], i < t && U.moveAmbiguousForward ? i = t : i > f && U.moveInvalidForward && (i = f), A < X[B] - i * 6e4)
|
|
366
|
+
return c[B];
|
|
367
|
+
return c[T];
|
|
368
368
|
},
|
|
369
369
|
abbr: function(z) {
|
|
370
370
|
return this.abbrs[this._index(z)];
|
|
@@ -376,12 +376,12 @@ var c0 = { exports: {} };
|
|
|
376
376
|
return this.offsets[this._index(z)];
|
|
377
377
|
}
|
|
378
378
|
};
|
|
379
|
-
function _(z,
|
|
380
|
-
this.name = z, this.zones =
|
|
379
|
+
function _(z, A) {
|
|
380
|
+
this.name = z, this.zones = A;
|
|
381
381
|
}
|
|
382
382
|
function I(z) {
|
|
383
|
-
var
|
|
384
|
-
|
|
383
|
+
var A = z.toTimeString(), c = A.match(/\([a-z ]+\)/i);
|
|
384
|
+
c && c[0] ? (c = c[0].match(/[A-Z]/g), c = c ? c.join("") : void 0) : (c = A.match(/[A-Z]{3,5}/g), c = c ? c[0] : void 0), c === "GMT" && (c = void 0), this.at = +z, this.abbr = c, this.offset = z.getTimezoneOffset();
|
|
385
385
|
}
|
|
386
386
|
function G(z) {
|
|
387
387
|
this.zone = z, this.offsetScore = 0, this.abbrScore = 0;
|
|
@@ -389,55 +389,55 @@ 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 Q(z,
|
|
393
|
-
for (var
|
|
394
|
-
|
|
392
|
+
function Q(z, A) {
|
|
393
|
+
for (var c, X; X = ((A.at - z.at) / 12e4 | 0) * 6e4; )
|
|
394
|
+
c = new I(new Date(z.at + X)), c.offset === z.offset ? z = c : A = c;
|
|
395
395
|
return z;
|
|
396
396
|
}
|
|
397
397
|
function P() {
|
|
398
|
-
var z = (/* @__PURE__ */ new Date()).getFullYear() - 2,
|
|
398
|
+
var z = (/* @__PURE__ */ new Date()).getFullYear() - 2, A = new I(new Date(z, 0, 1)), c = A.offset, X = [A], T, i, t, f;
|
|
399
399
|
for (f = 1; f < 48; f++)
|
|
400
|
-
t = new Date(z, f, 1).getTimezoneOffset(), t !==
|
|
400
|
+
t = new Date(z, f, 1).getTimezoneOffset(), t !== c && (i = new I(new Date(z, f, 1)), T = Q(A, i), X.push(T), X.push(new I(new Date(T.at + 6e4))), A = i, c = t);
|
|
401
401
|
for (f = 0; f < 4; f++)
|
|
402
|
-
|
|
403
|
-
return
|
|
402
|
+
X.push(new I(new Date(z + f, 0, 1))), X.push(new I(new Date(z + f, 6, 1)));
|
|
403
|
+
return X;
|
|
404
404
|
}
|
|
405
|
-
function H(z,
|
|
406
|
-
return z.offsetScore !==
|
|
405
|
+
function H(z, A) {
|
|
406
|
+
return z.offsetScore !== A.offsetScore ? z.offsetScore - A.offsetScore : z.abbrScore !== A.abbrScore ? z.abbrScore - A.abbrScore : z.zone.population !== A.zone.population ? A.zone.population - z.zone.population : A.zone.name.localeCompare(z.zone.name);
|
|
407
407
|
}
|
|
408
|
-
function m(z,
|
|
409
|
-
var
|
|
410
|
-
for (S(
|
|
411
|
-
|
|
408
|
+
function m(z, A) {
|
|
409
|
+
var c, X;
|
|
410
|
+
for (S(A), c = 0; c < A.length; c++)
|
|
411
|
+
X = A[c], W[X] = W[X] || {}, W[X][z] = !0;
|
|
412
412
|
}
|
|
413
413
|
function s(z) {
|
|
414
|
-
var
|
|
415
|
-
for (i = 0; i <
|
|
416
|
-
if (f = z[i].offset, !
|
|
417
|
-
B =
|
|
414
|
+
var A = z.length, c = {}, X = [], T = {}, i, t, f, B;
|
|
415
|
+
for (i = 0; i < A; i++)
|
|
416
|
+
if (f = z[i].offset, !T.hasOwnProperty(f)) {
|
|
417
|
+
B = W[f] || {};
|
|
418
418
|
for (t in B)
|
|
419
|
-
B.hasOwnProperty(t) && (
|
|
420
|
-
|
|
419
|
+
B.hasOwnProperty(t) && (c[t] = !0);
|
|
420
|
+
T[f] = !0;
|
|
421
421
|
}
|
|
422
|
-
for (i in
|
|
423
|
-
|
|
424
|
-
return
|
|
422
|
+
for (i in c)
|
|
423
|
+
c.hasOwnProperty(i) && X.push(Y[i]);
|
|
424
|
+
return X;
|
|
425
425
|
}
|
|
426
426
|
function u() {
|
|
427
427
|
try {
|
|
428
428
|
var z = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
429
429
|
if (z && z.length > 3) {
|
|
430
|
-
var
|
|
431
|
-
if (
|
|
432
|
-
return
|
|
430
|
+
var A = Y[C(z)];
|
|
431
|
+
if (A)
|
|
432
|
+
return A;
|
|
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
|
|
438
|
-
for (f = 0; f <
|
|
439
|
-
for (t = new G(K(
|
|
440
|
-
t.scoreOffsetAt(
|
|
437
|
+
var c = P(), X = c.length, T = s(c), i = [], t, f, B;
|
|
438
|
+
for (f = 0; f < T.length; f++) {
|
|
439
|
+
for (t = new G(K(T[f])), B = 0; B < X; B++)
|
|
440
|
+
t.scoreOffsetAt(c[B]);
|
|
441
441
|
i.push(t);
|
|
442
442
|
}
|
|
443
443
|
return i.sort(H), i.length > 0 ? i[0].zone.name : void 0;
|
|
@@ -449,52 +449,52 @@ var c0 = { exports: {} };
|
|
|
449
449
|
return (z || "").toLowerCase().replace(/\//g, "_");
|
|
450
450
|
}
|
|
451
451
|
function z0(z) {
|
|
452
|
-
var
|
|
453
|
-
for (typeof z == "string" && (z = [z]),
|
|
454
|
-
|
|
452
|
+
var A, c, X, T;
|
|
453
|
+
for (typeof z == "string" && (z = [z]), A = 0; A < z.length; A++)
|
|
454
|
+
X = z[A].split("|"), c = X[0], T = C(c), p[T] = z[A], Y[T] = c, m(T, X[2].split(" "));
|
|
455
455
|
}
|
|
456
|
-
function K(z,
|
|
456
|
+
function K(z, A) {
|
|
457
457
|
z = C(z);
|
|
458
|
-
var
|
|
459
|
-
return
|
|
458
|
+
var c = p[z], X;
|
|
459
|
+
return c instanceof h ? c : typeof c == "string" ? (c = new h(c), p[z] = c, c) : O[z] && A !== K && (X = K(O[z], K)) ? (c = p[z] = new h(), c._set(X), c.name = Y[z], c) : null;
|
|
460
460
|
}
|
|
461
461
|
function q0() {
|
|
462
|
-
var z,
|
|
462
|
+
var z, A = [];
|
|
463
463
|
for (z in Y)
|
|
464
|
-
Y.hasOwnProperty(z) && (p[z] || p[O[z]]) && Y[z] &&
|
|
465
|
-
return
|
|
464
|
+
Y.hasOwnProperty(z) && (p[z] || p[O[z]]) && Y[z] && A.push(Y[z]);
|
|
465
|
+
return A.sort();
|
|
466
466
|
}
|
|
467
467
|
function o0() {
|
|
468
468
|
return Object.keys(o);
|
|
469
469
|
}
|
|
470
470
|
function b0(z) {
|
|
471
|
-
var
|
|
472
|
-
for (typeof z == "string" && (z = [z]),
|
|
473
|
-
|
|
471
|
+
var A, c, X, T;
|
|
472
|
+
for (typeof z == "string" && (z = [z]), A = 0; A < z.length; A++)
|
|
473
|
+
c = z[A].split("|"), X = C(c[0]), T = C(c[1]), O[X] = T, Y[X] = c[0], O[T] = X, Y[T] = c[1];
|
|
474
474
|
}
|
|
475
475
|
function Y0(z) {
|
|
476
|
-
var
|
|
476
|
+
var A, c, X, T;
|
|
477
477
|
if (!(!z || !z.length))
|
|
478
|
-
for (
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
478
|
+
for (A = 0; A < z.length; A++)
|
|
479
|
+
T = z[A].split("|"), c = T[0].toUpperCase(), X = T[1].split(" "), o[c] = new _(
|
|
480
|
+
c,
|
|
481
|
+
X
|
|
482
482
|
);
|
|
483
483
|
}
|
|
484
484
|
function d0(z) {
|
|
485
485
|
return z = z.toUpperCase(), o[z] || null;
|
|
486
486
|
}
|
|
487
|
-
function a0(z,
|
|
487
|
+
function a0(z, A) {
|
|
488
488
|
if (z = d0(z), !z)
|
|
489
489
|
return null;
|
|
490
|
-
var
|
|
491
|
-
return
|
|
492
|
-
var
|
|
490
|
+
var c = z.zones.sort();
|
|
491
|
+
return A ? c.map(function(X) {
|
|
492
|
+
var T = K(X);
|
|
493
493
|
return {
|
|
494
|
-
name:
|
|
495
|
-
offset:
|
|
494
|
+
name: X,
|
|
495
|
+
offset: T.utcOffset(/* @__PURE__ */ new Date())
|
|
496
496
|
};
|
|
497
|
-
}) :
|
|
497
|
+
}) : c;
|
|
498
498
|
}
|
|
499
499
|
function X0(z) {
|
|
500
500
|
z0(z.zones), b0(z.links), Y0(z.countries), U.dataVersion = z.version;
|
|
@@ -503,31 +503,31 @@ var c0 = { exports: {} };
|
|
|
503
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
504
|
}
|
|
505
505
|
function x(z) {
|
|
506
|
-
var
|
|
507
|
-
return !!(z._a && z._tzm === void 0 && !
|
|
506
|
+
var A = z._f === "X" || z._f === "x";
|
|
507
|
+
return !!(z._a && z._tzm === void 0 && !A);
|
|
508
508
|
}
|
|
509
509
|
function w(z) {
|
|
510
510
|
typeof console < "u" && typeof console.error == "function" && console.error(z);
|
|
511
511
|
}
|
|
512
512
|
function U(z) {
|
|
513
|
-
var
|
|
514
|
-
return !M.isMoment(z) && x(
|
|
513
|
+
var A = Array.prototype.slice.call(arguments, 0, -1), c = arguments[arguments.length - 1], X = M.utc.apply(null, A), T;
|
|
514
|
+
return !M.isMoment(z) && x(X) && (T = K(c)) && X.add(T.parse(X), "minutes"), X.tz(c), X;
|
|
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 = N, U.needsOffset = x, U.moveInvalidForward = !0, U.moveAmbiguousForward = !1, U.countries = o0, U.zonesForCountry = a0;
|
|
517
517
|
var D = M.fn;
|
|
518
|
-
M.tz = U, M.defaultZone = null, M.updateOffset = function(z,
|
|
519
|
-
var
|
|
520
|
-
if (z._z === void 0 && (
|
|
521
|
-
if (
|
|
522
|
-
var
|
|
523
|
-
z.utcOffset(-
|
|
518
|
+
M.tz = U, M.defaultZone = null, M.updateOffset = function(z, A) {
|
|
519
|
+
var c = M.defaultZone, X;
|
|
520
|
+
if (z._z === void 0 && (c && x(z) && !z._isUTC && z.isValid() && (z._d = M.utc(z._a)._d, z.utc().add(c.parse(z), "minutes")), z._z = c), z._z)
|
|
521
|
+
if (X = z._z.utcOffset(z), Math.abs(X) < 16 && (X = X / 60), z.utcOffset !== void 0) {
|
|
522
|
+
var T = z._z;
|
|
523
|
+
z.utcOffset(-X, A), z._z = T;
|
|
524
524
|
} else
|
|
525
|
-
z.zone(
|
|
526
|
-
}, D.tz = function(z,
|
|
525
|
+
z.zone(X, A);
|
|
526
|
+
}, D.tz = function(z, A) {
|
|
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 = K(z), this._z ? M.updateOffset(this,
|
|
530
|
+
return this._z = K(z), this._z ? M.updateOffset(this, A) : 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,7 +548,7 @@ 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 &&
|
|
551
|
+
return (R < 2 || R === 2 && L < 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;
|
|
@@ -1458,7 +1458,7 @@ class C0 {
|
|
|
1458
1458
|
}
|
|
1459
1459
|
});
|
|
1460
1460
|
g(this, "METEO2_UPDATE", {
|
|
1461
|
-
etime:
|
|
1461
|
+
etime: n().unix(),
|
|
1462
1462
|
version: 0
|
|
1463
1463
|
});
|
|
1464
1464
|
this.apikey = M || "smE3JnDLHy3TizVv", this.debug = b;
|
|
@@ -1482,27 +1482,27 @@ class C0 {
|
|
|
1482
1482
|
*/
|
|
1483
1483
|
async weatherForecast(M, b = {}) {
|
|
1484
1484
|
try {
|
|
1485
|
-
const p =
|
|
1485
|
+
const p = n();
|
|
1486
1486
|
let O;
|
|
1487
1487
|
if (M.start_dates instanceof Array)
|
|
1488
1488
|
for (let Y = 0; Y < M.start_dates.length; Y++) {
|
|
1489
1489
|
M.start_date = M.start_dates[Y], M.end_date = M.end_dates[Y], M.fake = M.fakes[Y];
|
|
1490
|
-
const
|
|
1491
|
-
this.debug && Z.debug("[%s] fetch weather via %s with %j", b.requestId,
|
|
1490
|
+
const W = M.url[Y];
|
|
1491
|
+
this.debug && Z.debug("[%s] fetch weather via %s with %j", b.requestId, W, {
|
|
1492
1492
|
start_date: M.start_date,
|
|
1493
1493
|
end_date: M.end_date,
|
|
1494
1494
|
fake: M.fake,
|
|
1495
1495
|
step: Y
|
|
1496
1496
|
});
|
|
1497
|
-
const q = await
|
|
1498
|
-
O ? await this.mergeSegments(O,
|
|
1497
|
+
const q = await $(W, M), d = await this.parseWeatherData(q, M, b);
|
|
1498
|
+
O ? await this.mergeSegments(O, d) : O = d;
|
|
1499
1499
|
}
|
|
1500
1500
|
else {
|
|
1501
|
-
const Y = await
|
|
1501
|
+
const Y = await $(M.url, M);
|
|
1502
1502
|
O = await this.parseWeatherData(Y, M, b);
|
|
1503
1503
|
}
|
|
1504
1504
|
delete M.apikey;
|
|
1505
|
-
const o =
|
|
1505
|
+
const o = n();
|
|
1506
1506
|
return this.debug && Z.info("[%s] fetch weather api (%j) cost: %d ms", b.requestId, M.url, o.diff(p, "ms")), O;
|
|
1507
1507
|
} catch (p) {
|
|
1508
1508
|
return Z.warn("[%s] weather forecast failed: %s, with %j", b.requestId, p, M), [];
|
|
@@ -1525,33 +1525,38 @@ class C0 {
|
|
|
1525
1525
|
* @param options
|
|
1526
1526
|
*/
|
|
1527
1527
|
async marineForecast(M, b = {}) {
|
|
1528
|
+
var p, O;
|
|
1528
1529
|
try {
|
|
1529
|
-
const
|
|
1530
|
-
let
|
|
1530
|
+
const o = n();
|
|
1531
|
+
let Y;
|
|
1531
1532
|
if (M.start_dates instanceof Array)
|
|
1532
|
-
for (let
|
|
1533
|
-
M.start_date = M.start_dates[
|
|
1534
|
-
const
|
|
1535
|
-
this.debug && Z.debug("[%s] fetch marine via %s with %j", b.requestId,
|
|
1533
|
+
for (let d = 0; d < M.start_dates.length; d++) {
|
|
1534
|
+
M.start_date = M.start_dates[d], M.end_date = M.end_dates[d], M.fake = M.fakes[d];
|
|
1535
|
+
const R = M.url[d];
|
|
1536
|
+
this.debug && Z.debug("[%s] fetch marine via %s with %j", b.requestId, R, {
|
|
1536
1537
|
start_date: M.start_date,
|
|
1537
1538
|
end_date: M.end_date,
|
|
1538
1539
|
fake: M.fake,
|
|
1539
|
-
step:
|
|
1540
|
+
step: d
|
|
1540
1541
|
});
|
|
1541
|
-
const
|
|
1542
|
-
|
|
1542
|
+
const L = await $(R, M), a = await this.parseWeatherData(L, M, b);
|
|
1543
|
+
Y ? await this.mergeSegments(Y, a) : Y = a;
|
|
1543
1544
|
}
|
|
1544
1545
|
else {
|
|
1545
|
-
const
|
|
1546
|
-
|
|
1546
|
+
const d = await $(M.url, M);
|
|
1547
|
+
Y = await this.parseWeatherData(d, M, b);
|
|
1547
1548
|
}
|
|
1548
1549
|
delete M.apikey;
|
|
1549
|
-
const
|
|
1550
|
-
this.debug && Z.info("[%s] fetch marine api (%j) cost: %d ms", b.requestId, M.url,
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1550
|
+
const W = n();
|
|
1551
|
+
this.debug && Z.info("[%s] fetch marine api (%j) cost: %d ms", b.requestId, M.url, W.diff(o, "ms"));
|
|
1552
|
+
const q = await this.mergeMarineData(Y);
|
|
1553
|
+
if (["gfswave", "ncep_gfswave025"].includes(b.marineModels)) {
|
|
1554
|
+
const d = q.find((L) => L.model === "ncep_gfswave016"), R = q.find((L) => L.model === "ncep_gfswave025");
|
|
1555
|
+
return (O = (p = d == null ? void 0 : d.hourly) == null ? void 0 : p.wave_height) != null && O.every((L) => L !== null) ? [d] : [R];
|
|
1556
|
+
} else
|
|
1557
|
+
return q;
|
|
1558
|
+
} catch (o) {
|
|
1559
|
+
return Z.warn("[%s] marine forecast failed: %s, with %j", b.requestId, o, M), [];
|
|
1555
1560
|
}
|
|
1556
1561
|
}
|
|
1557
1562
|
/**
|
|
@@ -1562,64 +1567,64 @@ class C0 {
|
|
|
1562
1567
|
* @private
|
|
1563
1568
|
*/
|
|
1564
1569
|
async parseWeatherData(M, b, p = {}) {
|
|
1565
|
-
var Y,
|
|
1570
|
+
var Y, W, q, d, R, L, a, N, S, l;
|
|
1566
1571
|
const O = [], o = Math.pow(10, p.precision || 6);
|
|
1567
1572
|
for (let V = 0; V < M.length; V++) {
|
|
1568
1573
|
const E = M[V], h = E.utcOffsetSeconds(), y = E.timezone(), _ = E.current(), I = E.hourly(), G = E.sixHourly(), Q = E.daily(), P = {};
|
|
1569
1574
|
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", _) {
|
|
1570
|
-
const H =
|
|
1575
|
+
const H = n();
|
|
1571
1576
|
P.current = {
|
|
1572
|
-
time:
|
|
1577
|
+
time: n.unix(Number(_.time())).utc().format()
|
|
1573
1578
|
};
|
|
1574
1579
|
for (let s = 0; s < _.variablesLength(); s++) {
|
|
1575
1580
|
const u = _.variables(s).value();
|
|
1576
1581
|
P.current[b.current[s]] = isNaN(u) ? null : Math.round(u * o) / o;
|
|
1577
1582
|
}
|
|
1578
|
-
const m =
|
|
1583
|
+
const m = n();
|
|
1579
1584
|
this.debug && Z.debug("[%s] fetch current variables cost: %d ms", p.requestId, m.diff(H, "ms"));
|
|
1580
1585
|
}
|
|
1581
1586
|
if (I) {
|
|
1582
|
-
const H =
|
|
1587
|
+
const H = n(), m = n.unix(Number(I.time())).add(b.fake ? 1 : 0, "year");
|
|
1583
1588
|
P.hourly = {
|
|
1584
1589
|
date: m.utc().format(),
|
|
1585
1590
|
time: this.range(Number(I.time()), Number(I.timeEnd()), I.interval()).map(
|
|
1586
|
-
(u) =>
|
|
1591
|
+
(u) => n.unix(u).add(b.fake ? 1 : 0, "year").diff(m, "h")
|
|
1587
1592
|
)
|
|
1588
1593
|
};
|
|
1589
1594
|
for (let u = 0; u < I.variablesLength(); u++) {
|
|
1590
|
-
const F = (
|
|
1595
|
+
const F = (d = (q = (W = I.variables(u).valuesArray()) == null ? void 0 : W.toString()) == null ? void 0 : q.split(",")) == null ? void 0 : d.map((C) => isNaN(C) ? null : Math.round(Number(C) * o) / o);
|
|
1591
1596
|
P.hourly[b.hourly[u]] = F;
|
|
1592
1597
|
}
|
|
1593
|
-
const s =
|
|
1598
|
+
const s = n();
|
|
1594
1599
|
this.debug && Z.debug("[%s] fetch hourly variables cost: %d ms", p.requestId, s.diff(H, "ms"));
|
|
1595
1600
|
}
|
|
1596
1601
|
if (G) {
|
|
1597
|
-
const H =
|
|
1602
|
+
const H = n(), m = n.unix(Number(G.time())).add(b.fake ? 1 : 0, "year");
|
|
1598
1603
|
P.sixHourly = {
|
|
1599
1604
|
date: m.utc().format(),
|
|
1600
1605
|
time: this.range(Number(G.time()), Number(G.timeEnd()), G.interval()).map(
|
|
1601
|
-
(u) =>
|
|
1606
|
+
(u) => n.unix(u).add(b.fake ? 1 : 0, "year").diff(m, "h")
|
|
1602
1607
|
)
|
|
1603
1608
|
};
|
|
1604
1609
|
for (let u = 0; u < G.variablesLength(); u += p.memberLength ?? 1) {
|
|
1605
|
-
const F = (
|
|
1610
|
+
const F = (a = (L = (R = G.variables(u).valuesArray()) == null ? void 0 : R.toString()) == null ? void 0 : L.split(",")) == null ? void 0 : a.map((C) => isNaN(C) ? null : Math.round(Number(C) * o) / o);
|
|
1606
1611
|
G.variables(u), P.sixHourly[b.six_hourly[u / (p.memberLength ?? 1)]] = F;
|
|
1607
1612
|
}
|
|
1608
|
-
const s =
|
|
1613
|
+
const s = n();
|
|
1609
1614
|
this.debug && Z.debug("[%s] fetch 6-hourly variables cost: %d ms", p.requestId, s.diff(H, "ms"));
|
|
1610
1615
|
}
|
|
1611
1616
|
if (Q) {
|
|
1612
|
-
const H =
|
|
1617
|
+
const H = n();
|
|
1613
1618
|
P.daily = {
|
|
1614
1619
|
time: this.range(Number(Q.time()), Number(Q.timeEnd()), Q.interval()).map(
|
|
1615
|
-
(s) =>
|
|
1620
|
+
(s) => n.unix(s).add(b.fake ? 1 : 0, "year").utc().format()
|
|
1616
1621
|
)
|
|
1617
1622
|
};
|
|
1618
1623
|
for (let s = 0; s < Q.variablesLength(); s += p.memberLength ?? 1) {
|
|
1619
1624
|
const u = (l = (S = (N = Q.variables(s).valuesArray()) == null ? void 0 : N.toString()) == null ? void 0 : S.split(",")) == null ? void 0 : l.map((F) => isNaN(F) ? null : Math.round(Number(F) * o) / o);
|
|
1620
1625
|
P.daily[b.daily[s / (p.memberLength ?? 1)]] = u;
|
|
1621
1626
|
}
|
|
1622
|
-
const m =
|
|
1627
|
+
const m = n();
|
|
1623
1628
|
this.debug && Z.debug("[%s] fetch daily variables cost: %d ms", p.requestId, m.diff(H, "ms"));
|
|
1624
1629
|
}
|
|
1625
1630
|
O.push(P);
|
|
@@ -1634,19 +1639,19 @@ class C0 {
|
|
|
1634
1639
|
if (M[p][O][o] instanceof Array)
|
|
1635
1640
|
if (o === "time" && O === "hourly") {
|
|
1636
1641
|
const Y = M[p][O][o].at(-1);
|
|
1637
|
-
b[p][O][o] = b[p][O][o].map((
|
|
1642
|
+
b[p][O][o] = b[p][O][o].map((W) => W + Y + 1), M[p][O][o].push(...b[p][O][o]);
|
|
1638
1643
|
} else
|
|
1639
1644
|
M[p][O][o].push(...b[p][O][o]);
|
|
1640
1645
|
}
|
|
1641
1646
|
return M;
|
|
1642
1647
|
}
|
|
1643
1648
|
async mergeMarineData(M) {
|
|
1644
|
-
var o, Y,
|
|
1645
|
-
const b = [], p = M.find((
|
|
1649
|
+
var o, Y, W, q;
|
|
1650
|
+
const b = [], p = M.find((d) => d.model === "best_match");
|
|
1646
1651
|
p && b.push(p);
|
|
1647
|
-
const O = M.find((
|
|
1648
|
-
for (const
|
|
1649
|
-
["best_match", "meteofrance_currents"].includes(
|
|
1652
|
+
const O = M.find((d) => d.model === "meteofrance_currents");
|
|
1653
|
+
for (const d of M)
|
|
1654
|
+
["best_match", "meteofrance_currents"].includes(d.model) || (d.hourly.ocean_current_velocity = (o = O == null ? void 0 : O.hourly) == null ? void 0 : o.ocean_current_velocity, d.hourly.ocean_current_direction = (Y = O == null ? void 0 : O.hourly) == null ? void 0 : Y.ocean_current_direction, d.hourly.sea_level_height_msl = (W = O == null ? void 0 : O.hourly) == null ? void 0 : W.sea_level_height_msl, d.hourly.sea_surface_temperature = (q = O == null ? void 0 : O.hourly) == null ? void 0 : q.sea_surface_temperature, b.push(d));
|
|
1650
1655
|
return b;
|
|
1651
1656
|
}
|
|
1652
1657
|
pickForecastUrl(M, b, p, O = {}) {
|
|
@@ -1658,14 +1663,14 @@ class C0 {
|
|
|
1658
1663
|
if (!(b != null && b.length))
|
|
1659
1664
|
return ["best_match"];
|
|
1660
1665
|
const p = [];
|
|
1661
|
-
for (let
|
|
1662
|
-
const q = b[
|
|
1663
|
-
["ecmwf_wam025", "meteofrance_wave", "ewam", "gwam", "era5_ocean"].includes(q) ? p.push("meteofrance_currents", q) : ["gfswave", "ncep_gfswave025", "ncep_gfswave016"].includes(q) ? p.push("meteofrance_currents", "ncep_gfswave025") : p.push("best_match");
|
|
1666
|
+
for (let W = 0; W < b.length; W++) {
|
|
1667
|
+
const q = b[W];
|
|
1668
|
+
["ecmwf_wam025", "meteofrance_wave", "ewam", "gwam", "era5_ocean"].includes(q) ? p.push("meteofrance_currents", q) : ["gfswave", "ncep_gfswave025", "ncep_gfswave016"].includes(q) ? p.push("meteofrance_currents", "ncep_gfswave025", "ncep_gfswave016") : p.push("best_match");
|
|
1664
1669
|
}
|
|
1665
|
-
const O = p.reduce((
|
|
1666
|
-
return O.sort((
|
|
1667
|
-
const
|
|
1668
|
-
return
|
|
1670
|
+
const O = p.reduce((W, q) => (W.includes(q) || W.push(q), W), []), o = ["best_match", "meteofrance_currents", "meteofrance_wave", "ecmwf_wam025", "ncep_gfswave025", "gwam", "era5_ocean", "ewam"];
|
|
1671
|
+
return O.sort((W, q) => {
|
|
1672
|
+
const d = o.indexOf(W), R = o.indexOf(q);
|
|
1673
|
+
return d - R;
|
|
1669
1674
|
}), O;
|
|
1670
1675
|
}
|
|
1671
1676
|
/**
|
|
@@ -1677,17 +1682,18 @@ class C0 {
|
|
|
1677
1682
|
* @private
|
|
1678
1683
|
*/
|
|
1679
1684
|
prepare(M, b, p, O = {}) {
|
|
1680
|
-
|
|
1685
|
+
var q;
|
|
1686
|
+
const o = n().utc(), Y = M ? n.utc(M) : void 0, W = o.clone().utc().add(b && ((q = p.models) != null && q.includes("meteofrance_wave")) ? 10 : 15, "day");
|
|
1681
1687
|
if (M) {
|
|
1682
|
-
const
|
|
1683
|
-
|
|
1688
|
+
const d = Y.clone().utc().add(O.forecastDays ?? 1, "day");
|
|
1689
|
+
d.isAfter(W) ? (d.subtract(1, "year"), Y.isAfter(W) ? (Y.subtract(1, "year"), p.start_dates = [
|
|
1684
1690
|
Y.clone().subtract(O.pastDays || 0, "day").utc().format("YYYY-MM-DD")
|
|
1685
|
-
], p.end_dates = [
|
|
1691
|
+
], p.end_dates = [d.utc().format("YYYY-MM-DD")], p.fakes = [!0], p.url = [this.pickForecastUrl(b, !1, !0, O)]) : (p.start_dates = [
|
|
1686
1692
|
Y.clone().subtract(O.pastDays || 0, "day").utc().format("YYYY-MM-DD"),
|
|
1687
|
-
|
|
1688
|
-
], p.end_dates = [
|
|
1693
|
+
W.clone().subtract(1, "year").utc().format("YYYY-MM-DD")
|
|
1694
|
+
], p.end_dates = [W.clone().subtract(1, "day").utc().format("YYYY-MM-DD"), d.utc().format("YYYY-MM-DD")], p.fakes = [!1, !0], p.url = [this.pickForecastUrl(b, O.selfHosted ?? !0, !1, O), this.pickForecastUrl(b, !1, !0, O)])) : (p.start_dates = [
|
|
1689
1695
|
Y.clone().subtract(O.pastDays || 0, "day").utc().format("YYYY-MM-DD")
|
|
1690
|
-
], p.end_dates = [
|
|
1696
|
+
], p.end_dates = [d.utc().format("YYYY-MM-DD")], p.fakes = [!1], p.url = [this.pickForecastUrl(b, O.selfHosted ?? !0, Y.isBefore(o.clone().subtract(30, "day")), O)]);
|
|
1691
1697
|
} else
|
|
1692
1698
|
p.forecast_days = O.forecastDays, p.past_days = O.pastDays, p.fake = !1, p.url = this.pickForecastUrl(b, O.selfHosted ?? !0, !1, O);
|
|
1693
1699
|
return p;
|
|
@@ -1698,7 +1704,7 @@ class C0 {
|
|
|
1698
1704
|
return Math.round(M * p) / p;
|
|
1699
1705
|
}
|
|
1700
1706
|
timezoneOffset(M, b) {
|
|
1701
|
-
const p = N0(M, b), O =
|
|
1707
|
+
const p = N0(M, b), O = n().tz(p).utcOffset();
|
|
1702
1708
|
return Math.round(O / 60 * 10) / 10;
|
|
1703
1709
|
}
|
|
1704
1710
|
/**
|
|
@@ -1737,41 +1743,41 @@ class C0 {
|
|
|
1737
1743
|
* @param withHourly
|
|
1738
1744
|
* @param options
|
|
1739
1745
|
*/
|
|
1740
|
-
async spotForecast(M, b, p, O = !0, o = !0, Y = !1,
|
|
1746
|
+
async spotForecast(M, b, p, O = !0, o = !0, Y = !1, W = {
|
|
1741
1747
|
forecastDays: 1,
|
|
1742
1748
|
pastDays: 0,
|
|
1743
1749
|
precision: 6,
|
|
1744
1750
|
selfHosted: !0
|
|
1745
1751
|
}) {
|
|
1746
1752
|
var N, S, l;
|
|
1747
|
-
b = this.toStdLng(b), this.debug && Z.info("[%s] spot forecast params: %j",
|
|
1753
|
+
b = this.toStdLng(b), this.debug && Z.info("[%s] spot forecast params: %j", W.requestId, { lat: M, lng: b, datetime: p, simplify: O, withDaily: o, withHourly: Y, options: W });
|
|
1748
1754
|
const q = {
|
|
1749
1755
|
apikey: this.apikey,
|
|
1750
1756
|
latitude: M,
|
|
1751
1757
|
longitude: b,
|
|
1752
1758
|
cell_selection: "sea",
|
|
1753
1759
|
wind_speed_unit: "kn",
|
|
1754
|
-
models: ((N =
|
|
1760
|
+
models: ((N = W.weatherModels) == null ? void 0 : N.split(",")) || ["best_match"],
|
|
1755
1761
|
timezone: "auto"
|
|
1756
1762
|
};
|
|
1757
|
-
let
|
|
1763
|
+
let d;
|
|
1758
1764
|
if (p) {
|
|
1759
1765
|
const V = this.timezoneOffset(M, b);
|
|
1760
|
-
|
|
1766
|
+
d = n.utc(p).utcOffset(V), d.subtract(V > 0 ? V : -V, "h");
|
|
1761
1767
|
}
|
|
1762
|
-
o && (q.daily = ((S = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : S.split(",")) || []),
|
|
1763
|
-
const R = await this.weatherForecast(q,
|
|
1768
|
+
o && (q.daily = ((S = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : S.split(",")) || []), d || (W.forecastDays = W.forecastDays || 1, W.pastDays = 0, Y = !0), Y && (q.hourly = ((l = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : l.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(d == null ? void 0 : d.utc().format(), !1, q, W);
|
|
1769
|
+
const R = await this.weatherForecast(q, W), L = {
|
|
1764
1770
|
apikey: this.apikey,
|
|
1765
1771
|
latitude: M,
|
|
1766
1772
|
longitude: b,
|
|
1767
1773
|
cell_selection: "sea",
|
|
1768
1774
|
timezone: "auto",
|
|
1769
1775
|
wind_speed_unit: "kn",
|
|
1770
|
-
models: this.pickMarineModels(
|
|
1776
|
+
models: this.pickMarineModels(W.marineModels)
|
|
1771
1777
|
};
|
|
1772
|
-
o && (
|
|
1773
|
-
const
|
|
1774
|
-
return { weather: R, marine:
|
|
1778
|
+
o && (L.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), d || (W.forecastDays = W.forecastDays || 1, Y = !0), Y && (L.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), this.prepare(d == null ? void 0 : d.utc().format(), !0, L, W);
|
|
1779
|
+
const a = await this.marineForecast(L, W);
|
|
1780
|
+
return { weather: R, marine: a };
|
|
1775
1781
|
}
|
|
1776
1782
|
/**
|
|
1777
1783
|
* 历史再分析数据
|
|
@@ -1794,14 +1800,14 @@ class C0 {
|
|
|
1794
1800
|
* @param withMarine
|
|
1795
1801
|
* @param options
|
|
1796
1802
|
*/
|
|
1797
|
-
async spotHistorical(M, b, p, O, o = !0, Y = !0,
|
|
1803
|
+
async spotHistorical(M, b, p, O, o = !0, Y = !0, W = !1, q = {
|
|
1798
1804
|
precision: 6
|
|
1799
1805
|
}) {
|
|
1800
1806
|
var l, V;
|
|
1801
|
-
b = this.toStdLng(b), this.debug && Z.info("[%s] spot historical params: %j", q.requestId, { lat: M, lng: b, startDate: p, endDate: O, withMarine:
|
|
1802
|
-
const
|
|
1803
|
-
R.subtract(
|
|
1804
|
-
const
|
|
1807
|
+
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 });
|
|
1808
|
+
const d = this.timezoneOffset(M, b), R = n.utc(p).utcOffset(d), L = n.utc(O).utcOffset(d);
|
|
1809
|
+
R.subtract(d > 0 ? d : -d, "h"), L.subtract(d > 0 ? d : -d, "h");
|
|
1810
|
+
const a = {
|
|
1805
1811
|
apikey: this.apikey,
|
|
1806
1812
|
latitude: M,
|
|
1807
1813
|
longitude: b,
|
|
@@ -1811,12 +1817,12 @@ class C0 {
|
|
|
1811
1817
|
timezone: "auto",
|
|
1812
1818
|
url: this.HISTORICAL.OM_URL,
|
|
1813
1819
|
start_date: R.format("YYYY-MM-DD"),
|
|
1814
|
-
end_date:
|
|
1820
|
+
end_date: L.format("YYYY-MM-DD")
|
|
1815
1821
|
};
|
|
1816
|
-
o && (
|
|
1817
|
-
const N = await this.weatherForecast(
|
|
1822
|
+
o && (a.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), Y && (a.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
|
|
1823
|
+
const N = await this.weatherForecast(a, q);
|
|
1818
1824
|
let S;
|
|
1819
|
-
if (
|
|
1825
|
+
if (W) {
|
|
1820
1826
|
const E = {
|
|
1821
1827
|
apikey: this.apikey,
|
|
1822
1828
|
latitude: M,
|
|
@@ -1829,7 +1835,7 @@ class C0 {
|
|
|
1829
1835
|
hourly: this.FORECAST.MARINE_VARIABLES.HOURLY.split(","),
|
|
1830
1836
|
url: this.FORECAST.OM_MARINE_URL,
|
|
1831
1837
|
start_date: R.format("YYYY-MM-DD"),
|
|
1832
|
-
end_date:
|
|
1838
|
+
end_date: L.format("YYYY-MM-DD")
|
|
1833
1839
|
};
|
|
1834
1840
|
S = await this.marineForecast(E, q);
|
|
1835
1841
|
}
|
|
@@ -1850,8 +1856,8 @@ class C0 {
|
|
|
1850
1856
|
precision: 6
|
|
1851
1857
|
}) {
|
|
1852
1858
|
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 });
|
|
1853
|
-
const
|
|
1854
|
-
q.subtract(
|
|
1859
|
+
const W = this.timezoneOffset(M, b), q = n.utc(p).utcOffset(W), d = O ? n.utc(O).utcOffset(W) : q.clone().add(1, "month");
|
|
1860
|
+
q.subtract(W > 0 ? W : -W, "h"), d.subtract(W > 0 ? W : -W, "h");
|
|
1855
1861
|
const R = {
|
|
1856
1862
|
apikey: this.apikey,
|
|
1857
1863
|
latitude: M,
|
|
@@ -1861,7 +1867,7 @@ class C0 {
|
|
|
1861
1867
|
timezone: "auto",
|
|
1862
1868
|
url: this.SEASONAL.OM_URL,
|
|
1863
1869
|
start_date: q.format("YYYY-MM-DD"),
|
|
1864
|
-
end_date:
|
|
1870
|
+
end_date: d.format("YYYY-MM-DD"),
|
|
1865
1871
|
daily: this.SEASONAL.WEATHER_VARIABLES.DAILY.split(",")
|
|
1866
1872
|
};
|
|
1867
1873
|
return o && (R.six_hourly = this.SEASONAL.WEATHER_VARIABLES.SIX_HOURLY.split(",")), Y.memberLength = 4, { weather: await this.weatherForecast(R, Y) };
|
|
@@ -1889,46 +1895,46 @@ class C0 {
|
|
|
1889
1895
|
async spotClimate(M, b, p, O, o = {
|
|
1890
1896
|
precision: 6
|
|
1891
1897
|
}) {
|
|
1892
|
-
var
|
|
1898
|
+
var L;
|
|
1893
1899
|
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 });
|
|
1894
|
-
const Y = this.timezoneOffset(M, b),
|
|
1895
|
-
q.subtract(Y > 0 ? Y : -Y, "h"),
|
|
1896
|
-
const
|
|
1900
|
+
const Y = this.timezoneOffset(M, b), W = n.utc(p).utcOffset(Y), q = O ? n.utc(O).utcOffset(Y) : W.clone().add(1, "day");
|
|
1901
|
+
q.subtract(Y > 0 ? Y : -Y, "h"), W.subtract(Y > 0 ? Y : -Y, "h");
|
|
1902
|
+
const d = {
|
|
1897
1903
|
apikey: this.apikey,
|
|
1898
1904
|
latitude: M,
|
|
1899
1905
|
longitude: b,
|
|
1900
1906
|
cell_selection: "sea",
|
|
1901
1907
|
wind_speed_unit: "kn",
|
|
1902
|
-
models: ((
|
|
1908
|
+
models: ((L = o.weatherModels) == null ? void 0 : L.split(",")) || "EC_Earth3P_HR",
|
|
1903
1909
|
timezone: "auto",
|
|
1904
1910
|
url: this.CLIMATE.OM_URL,
|
|
1905
|
-
start_date:
|
|
1911
|
+
start_date: W.format("YYYY-MM-DD"),
|
|
1906
1912
|
end_date: q.format("YYYY-MM-DD"),
|
|
1907
1913
|
daily: this.CLIMATE.WEATHER_VARIABLES.DAILY.split(",")
|
|
1908
1914
|
};
|
|
1909
|
-
return { weather: await this.weatherForecast(
|
|
1915
|
+
return { weather: await this.weatherForecast(d, o) };
|
|
1910
1916
|
}
|
|
1911
1917
|
async update(M = {}) {
|
|
1912
|
-
const b =
|
|
1918
|
+
const b = n.unix(this.METEO2_UPDATE.etime), p = this.METEO2_UPDATE.version, O = n();
|
|
1913
1919
|
if (!p || b.clone().add(10, "minute").isBefore(O)) {
|
|
1914
|
-
const o = M.url || "https://meteo3agent.idmwx.com/api/agents/update",
|
|
1920
|
+
const o = M.url || "https://meteo3agent.idmwx.com/api/agents/update", W = await (await fetch(o, {
|
|
1915
1921
|
headers: {
|
|
1916
1922
|
"Content-Type": "application/json",
|
|
1917
1923
|
Authorization: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsYmY5M3I0YTAwMDE4Ymx0NWJ4emFwNWMiLCJyb2xlIjoyMDQ3LCJpYXQiOjE2NzA1NTM0NzAsImV4cCI6Mzg3ODA3MzQ3MH0.MxTv0yLGarZCtOSCZfJHMqrXNMNN0-OL4gBGKGcYcc8"
|
|
1918
1924
|
}
|
|
1919
1925
|
})).json();
|
|
1920
|
-
if (
|
|
1921
|
-
const q =
|
|
1922
|
-
for (const R of
|
|
1923
|
-
const
|
|
1926
|
+
if (W.code === 0) {
|
|
1927
|
+
const q = W.data, d = k.standardWeatherModels();
|
|
1928
|
+
for (const R of d) {
|
|
1929
|
+
const L = k.autoPickSubCategories(R.alias), N = q.filter((S) => L.includes(S.category)).map((S) => {
|
|
1924
1930
|
var l, V, E, h, y, _;
|
|
1925
1931
|
return {
|
|
1926
1932
|
category: S.category,
|
|
1927
1933
|
meta: {
|
|
1928
|
-
endTime:
|
|
1929
|
-
availabilityTime:
|
|
1930
|
-
initialisationTime:
|
|
1931
|
-
modificationTime:
|
|
1934
|
+
endTime: n.unix((l = S.meta) == null ? void 0 : l.data_end_time).utc().format(),
|
|
1935
|
+
availabilityTime: n.unix((V = S.meta) == null ? void 0 : V.last_run_availability_time).utc().format(),
|
|
1936
|
+
initialisationTime: n.unix((E = S.meta) == null ? void 0 : E.last_run_initialisation_time).utc().format(),
|
|
1937
|
+
modificationTime: n.unix((h = S.meta) == null ? void 0 : h.last_run_modification_time).utc().format(),
|
|
1932
1938
|
temporalResolution: Math.round(((y = S.meta) == null ? void 0 : y.temporal_resolution_seconds) / 3600),
|
|
1933
1939
|
frequency: Math.round(((_ = S.meta) == null ? void 0 : _.update_interval_seconds) / 3600)
|
|
1934
1940
|
}
|
|
@@ -1986,27 +1992,27 @@ class D0 {
|
|
|
1986
1992
|
* @param datum
|
|
1987
1993
|
* @param options
|
|
1988
1994
|
*/
|
|
1989
|
-
async tidesForecast(M, b, p = 7, O = "today", o = !0, Y = !1,
|
|
1990
|
-
O = O || "today", p = p || 7, b = this.toStdLng(b), this.debug && W0.info("[%s] spot tides forecast params: %j",
|
|
1995
|
+
async tidesForecast(M, b, p = 7, O = "today", o = !0, Y = !1, W = !1, q = "CD", d = {}) {
|
|
1996
|
+
O = O || "today", p = p || 7, b = this.toStdLng(b), this.debug && W0.info("[%s] spot tides forecast params: %j", d.requestId, { lat: M, lng: b, date: O, extremes: o, heights: Y, datums: W, datum: q });
|
|
1991
1997
|
let R = `https://www.worldtides.info/api/v3?lat=${M}&lon=${b}&days=${p}&date=${O}&datum=${q}&key=${this.apikey}&localtime`;
|
|
1992
|
-
o && (R = `${R}&extremes`), Y && (R = `${R}&heights`),
|
|
1993
|
-
const
|
|
1994
|
-
return
|
|
1998
|
+
o && (R = `${R}&extremes`), Y && (R = `${R}&heights`), W && (R = `${R}&datums`);
|
|
1999
|
+
const a = await (await fetch(R)).json();
|
|
2000
|
+
return a.status === 200 ? {
|
|
1995
2001
|
rqt: {
|
|
1996
2002
|
lat: M,
|
|
1997
2003
|
lng: b
|
|
1998
2004
|
},
|
|
1999
2005
|
rsp: {
|
|
2000
|
-
lat:
|
|
2001
|
-
lng:
|
|
2006
|
+
lat: a.responseLat,
|
|
2007
|
+
lng: a.responseLon
|
|
2002
2008
|
},
|
|
2003
|
-
atlas:
|
|
2004
|
-
datum:
|
|
2005
|
-
extremes:
|
|
2006
|
-
heights:
|
|
2007
|
-
stations:
|
|
2008
|
-
datums:
|
|
2009
|
-
} :
|
|
2009
|
+
atlas: a.atlas,
|
|
2010
|
+
datum: a.responseDatum,
|
|
2011
|
+
extremes: a.extremes || [],
|
|
2012
|
+
heights: a.heights || [],
|
|
2013
|
+
stations: a.stations || [],
|
|
2014
|
+
datums: a.datums || []
|
|
2015
|
+
} : a;
|
|
2010
2016
|
}
|
|
2011
2017
|
}
|
|
2012
2018
|
export {
|