@idm-plugin/meteo2 0.5.1 → 0.5.2
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 +322 -322
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
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
|
-
var
|
|
3
|
+
var _ = (e, M, b) => (n0(e, typeof M != "symbol" ? M + "" : M, b), b);
|
|
4
4
|
import M0 from "@log4js-node/log4js-api";
|
|
5
5
|
import n from "moment";
|
|
6
6
|
import v from "got";
|
|
@@ -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 A = n(p), q = {
|
|
29
29
|
searchParams: {
|
|
30
30
|
lng: M,
|
|
31
31
|
lat: b,
|
|
32
|
-
ts:
|
|
32
|
+
ts: A.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 L = "https://aod4idm.idmwx.com/api/ocean/point",
|
|
40
|
-
if (r == null || r.info("[%s] get meteo(cost: %d ms) from %s with options: %j", Y.requestId, N - R, L, q), (
|
|
37
|
+
}, a = n(), R = a.valueOf();
|
|
38
|
+
A.isBefore(a.subtract(1, "month")) && (r == null || r.warn("[%s] get history meteo on %s: %j", Y.requestId, A.format(), q));
|
|
39
|
+
const L = "https://aod4idm.idmwx.com/api/ocean/point", d = 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), (d == null ? void 0 : d.code) === 0)
|
|
41
41
|
return {
|
|
42
|
-
...
|
|
42
|
+
...d.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, d);
|
|
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 A = n(p), q = {
|
|
64
64
|
searchParams: {
|
|
65
65
|
lng: M,
|
|
66
66
|
lat: b,
|
|
67
|
-
ts:
|
|
67
|
+
ts: A.valueOf(),
|
|
68
68
|
params: O,
|
|
69
69
|
source: o == null ? void 0 : o.toLowerCase()
|
|
70
70
|
},
|
|
71
71
|
timeout: 3e4
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
const L = "https://aod4idm.idmwx.com/api/ocean/factor",
|
|
75
|
-
if (r == null || r.info("[%s] get factors(cost: %d ms) from %s with options: %j", Y.requestId, N - R, L, q), (
|
|
72
|
+
}, a = n(), R = a.valueOf();
|
|
73
|
+
A.isBefore(a.subtract(1, "month")) && (r == null || r.warn("[%s] get history factors on %s: %j", Y.requestId, A.format(), q));
|
|
74
|
+
const L = "https://aod4idm.idmwx.com/api/ocean/factor", d = 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), (d == null ? void 0 : d.code) === 0)
|
|
76
76
|
return {
|
|
77
|
-
...
|
|
77
|
+
...d.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, d);
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* @see https://api.windy.com/point-forecast/docs
|
|
@@ -86,7 +86,7 @@ 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
|
|
89
|
+
let A = n().valueOf();
|
|
90
90
|
const q = await v.post(o, {
|
|
91
91
|
headers: {
|
|
92
92
|
"Content-Type": "application/json"
|
|
@@ -116,8 +116,8 @@ 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,
|
|
119
|
+
let a = n().valueOf();
|
|
120
|
+
r == null || r.info("[%s] get gfs-factors(cost: %d ms) from %s", O.requestId, a - A, o), A = a;
|
|
121
121
|
const R = await v.post(o, {
|
|
122
122
|
headers: {
|
|
123
123
|
"Content-Type": "application/json"
|
|
@@ -131,50 +131,50 @@ 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
|
+
a = n().valueOf(), r == null || r.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", O.requestId, a - A, o);
|
|
135
|
+
for (let d = 0; d < q.ts.length; d++) {
|
|
136
|
+
const N = this.populateUVFactor(q["wind_u-surface"][d], q["wind_v-surface"][d], !1, O);
|
|
137
137
|
N.scale = this.calculateBeaufortWindForceScale(N.speed), Y.push({
|
|
138
|
-
utc: n(q.ts[
|
|
139
|
-
temp: q["temp-surface"][
|
|
140
|
-
dp_temp: q["dewpoint-surface"][
|
|
138
|
+
utc: n(q.ts[d]).utc().format(),
|
|
139
|
+
temp: q["temp-surface"][d] ? Math.round((q["temp-surface"][d] - 273.15) * 100) / 100 : void 0,
|
|
140
|
+
dp_temp: q["dewpoint-surface"][d] ? Math.round((q["dewpoint-surface"][d] - 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"][d] ? Math.round(q["past3hprecip-surface"][d] * 1e3 * 1e3) / 1e3 : 0,
|
|
143
|
+
inter3hSnow: q["past3hsnowprecip-surface"][d] ? Math.round(q["past3hsnowprecip-surface"][d] * 1e3 * 1e3) / 1e3 : 0,
|
|
144
|
+
inter3hConv: q["past3hconvprecip-surface"][d] ? Math.round(q["past3hconvprecip-surface"][d] * 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"][d] || 0) * 100) / 100,
|
|
149
|
+
kts: this.convertMs2Kts(q["gust-surface"][d])
|
|
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"][d] ? Math.round(q["lclouds-surface"][d] * 100) / 100 : 0,
|
|
152
|
+
mclouds: q["mclouds-surface"][d] ? Math.round(q["mclouds-surface"][d] * 100) / 100 : 0,
|
|
153
|
+
hclouds: q["hclouds-surface"][d] ? Math.round(q["hclouds-surface"][d] * 100) / 100 : 0,
|
|
154
|
+
rh: q["rh-surface"][d] ? Math.round(q["rh-surface"][d] * 100) / 100 : 0,
|
|
155
|
+
gh: q["gh-surface"][d] ? Math.round(q["gh-surface"][d] * 100) / 100 : 0,
|
|
156
|
+
pressure: Math.round(q["pressure-surface"][d] / 100 * 100) / 100
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
const L = [];
|
|
160
|
-
for (let
|
|
161
|
-
const N = this.calculateDouglasScale(R["waves_height-surface"][
|
|
160
|
+
for (let d = 0; d < R.ts.length; d++) {
|
|
161
|
+
const N = this.calculateDouglasScale(R["waves_height-surface"][d], R["waves_direction-surface"][d], R["waves_period-surface"][d]), S = this.calculateDouglasScale(R["wwaves_height-surface"][d], R["wwaves_direction-surface"][d], R["wwaves_period-surface"][d]), Z = this.calculateDouglasScale(R["swell1_height-surface"][d], R["swell1_direction-surface"][d], R["swell1_period-surface"][d]), t = this.calculateDouglasScale(R["swell2_height-surface"][d], R["swell2_direction-surface"][d], R["swell2_period-surface"][d]);
|
|
162
162
|
L.push({
|
|
163
|
-
utc: n(R.ts[
|
|
163
|
+
utc: n(R.ts[d]).utc().format(),
|
|
164
164
|
wave: {
|
|
165
165
|
sig: N,
|
|
166
166
|
wd: S,
|
|
167
|
-
swell:
|
|
168
|
-
swell2:
|
|
167
|
+
swell: Z,
|
|
168
|
+
swell2: t
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
for (const
|
|
173
|
-
const N = L.find((S) => S.utc ===
|
|
174
|
-
|
|
172
|
+
for (const d of Y) {
|
|
173
|
+
const N = L.find((S) => S.utc === d.utc);
|
|
174
|
+
d.wave = N == null ? void 0 : N.wave;
|
|
175
175
|
}
|
|
176
|
-
} catch (
|
|
177
|
-
r.warn("[%s] get-gfs-factor failed: %s", O.requestId,
|
|
176
|
+
} catch (A) {
|
|
177
|
+
r.warn("[%s] get-gfs-factor failed: %s", O.requestId, A);
|
|
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: A } = 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: A,
|
|
195
195
|
eastward: Math.round(M * 1e4) / 1e4,
|
|
196
196
|
northward: Math.round(b * 1e4) / 1e4
|
|
197
197
|
};
|
|
@@ -269,9 +269,9 @@ var A0 = { exports: {} };
|
|
|
269
269
|
throw new RangeError("invalid coordinates");
|
|
270
270
|
if (90 <= b)
|
|
271
271
|
return "Etc/GMT";
|
|
272
|
-
var Y = -1,
|
|
272
|
+
var Y = -1, A = 48 * (180 + p) / 360.00000000000006, q = 24 * (90 - b) / 180.00000000000003, a = 0 | A, R = 0 | q, L = 96 * R + 2 * a;
|
|
273
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 * (
|
|
274
|
+
L = 56 * O.charCodeAt(L = 8 * (Y = Y + L + 1) + 4 * (R = 0 | (q = 2 * (q - R) % 2)) + 2 * (a = 0 | (A = 2 * (A - a) % 2)) + 2304) + O.charCodeAt(L + 1) - 1995;
|
|
275
275
|
return o[L + o.length - 3136];
|
|
276
276
|
}
|
|
277
277
|
e.exports = M;
|
|
@@ -289,245 +289,245 @@ var c0 = { exports: {} };
|
|
|
289
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 = {},
|
|
293
|
-
(!M || typeof M.version != "string") &&
|
|
294
|
-
var
|
|
295
|
-
(R < 2 || R === 2 && L < 6) &&
|
|
296
|
-
function
|
|
292
|
+
var b = "0.5.48", p = {}, O = {}, o = {}, Y = {}, A = {}, q;
|
|
293
|
+
(!M || typeof M.version != "string") && y("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
294
|
+
var a = M.version.split("."), R = +a[0], L = +a[1];
|
|
295
|
+
(R < 2 || R === 2 && L < 6) && y("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
|
|
296
|
+
function d(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
|
-
|
|
303
|
-
for (
|
|
304
|
-
i = i / 60,
|
|
300
|
+
var c = 0, W = z.split("."), X = W[0], T = W[1] || "", i = 1, V, f = 0, B = 1;
|
|
301
|
+
for (z.charCodeAt(0) === 45 && (c = 1, B = -1), c; c < X.length; c++)
|
|
302
|
+
V = d(X.charCodeAt(c)), f = 60 * f + V;
|
|
303
|
+
for (c = 0; c < T.length; c++)
|
|
304
|
+
i = i / 60, V = d(T.charCodeAt(c)), f += V * i;
|
|
305
305
|
return f * B;
|
|
306
306
|
}
|
|
307
307
|
function S(z) {
|
|
308
|
-
for (var
|
|
309
|
-
z[
|
|
308
|
+
for (var c = 0; c < z.length; c++)
|
|
309
|
+
z[c] = N(z[c]);
|
|
310
310
|
}
|
|
311
|
-
function
|
|
312
|
-
for (var
|
|
313
|
-
z[
|
|
314
|
-
z[
|
|
311
|
+
function Z(z, c) {
|
|
312
|
+
for (var W = 0; W < c; W++)
|
|
313
|
+
z[W] = Math.round((z[W - 1] || 0) + z[W] * 6e4);
|
|
314
|
+
z[c - 1] = 1 / 0;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
var
|
|
318
|
-
for (X = 0; X <
|
|
319
|
-
|
|
320
|
-
return
|
|
316
|
+
function t(z, c) {
|
|
317
|
+
var W = [], X;
|
|
318
|
+
for (X = 0; X < c.length; X++)
|
|
319
|
+
W[X] = z[c[X]];
|
|
320
|
+
return W;
|
|
321
321
|
}
|
|
322
|
-
function
|
|
323
|
-
var
|
|
324
|
-
return S(
|
|
325
|
-
name:
|
|
326
|
-
abbrs:
|
|
327
|
-
offsets:
|
|
322
|
+
function s(z) {
|
|
323
|
+
var c = z.split("|"), W = c[2].split(" "), X = c[3].split(""), T = c[4].split(" ");
|
|
324
|
+
return S(W), S(X), S(T), Z(T, X.length), {
|
|
325
|
+
name: c[0],
|
|
326
|
+
abbrs: t(c[1].split(" "), X),
|
|
327
|
+
offsets: t(W, X),
|
|
328
328
|
untils: T,
|
|
329
|
-
population:
|
|
329
|
+
population: c[5] | 0
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
|
-
function
|
|
333
|
-
z && this._set(
|
|
332
|
+
function G(z) {
|
|
333
|
+
z && this._set(s(z));
|
|
334
334
|
}
|
|
335
|
-
function
|
|
336
|
-
var
|
|
337
|
-
if (z <
|
|
335
|
+
function m(z, c) {
|
|
336
|
+
var W = c.length;
|
|
337
|
+
if (z < c[0])
|
|
338
338
|
return 0;
|
|
339
|
-
if (
|
|
340
|
-
return
|
|
341
|
-
if (z >=
|
|
339
|
+
if (W > 1 && c[W - 1] === 1 / 0 && z >= c[W - 2])
|
|
340
|
+
return W - 1;
|
|
341
|
+
if (z >= c[W - 1])
|
|
342
342
|
return -1;
|
|
343
|
-
for (var X, T = 0, i =
|
|
344
|
-
X = Math.floor((T + i) / 2),
|
|
343
|
+
for (var X, T = 0, i = W - 1; i - T > 1; )
|
|
344
|
+
X = Math.floor((T + i) / 2), c[X] <= z ? T = X : i = X;
|
|
345
345
|
return i;
|
|
346
346
|
}
|
|
347
|
-
|
|
347
|
+
G.prototype = {
|
|
348
348
|
_set: function(z) {
|
|
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 (X =
|
|
352
|
+
var c = +z, W = this.untils, X;
|
|
353
|
+
if (X = m(c, W), X >= 0)
|
|
354
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(c) {
|
|
359
|
+
return o[c].zones.indexOf(z) !== -1;
|
|
360
360
|
});
|
|
361
361
|
},
|
|
362
362
|
parse: function(z) {
|
|
363
|
-
var
|
|
363
|
+
var c = +z, W = this.offsets, X = this.untils, T = X.length - 1, i, V, f, B;
|
|
364
364
|
for (B = 0; B < T; B++)
|
|
365
|
-
if (i =
|
|
366
|
-
return
|
|
367
|
-
return
|
|
365
|
+
if (i = W[B], V = W[B + 1], f = W[B && B - 1], i < V && U.moveAmbiguousForward ? i = V : i > f && U.moveInvalidForward && (i = f), c < X[B] - i * 6e4)
|
|
366
|
+
return W[B];
|
|
367
|
+
return W[T];
|
|
368
368
|
},
|
|
369
369
|
abbr: function(z) {
|
|
370
370
|
return this.abbrs[this._index(z)];
|
|
371
371
|
},
|
|
372
372
|
offset: function(z) {
|
|
373
|
-
return
|
|
373
|
+
return y("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(z)];
|
|
374
374
|
},
|
|
375
375
|
utcOffset: function(z) {
|
|
376
376
|
return this.offsets[this._index(z)];
|
|
377
377
|
}
|
|
378
378
|
};
|
|
379
|
-
function
|
|
380
|
-
this.name = z, this.zones =
|
|
379
|
+
function H(z, c) {
|
|
380
|
+
this.name = z, this.zones = c;
|
|
381
381
|
}
|
|
382
382
|
function I(z) {
|
|
383
|
-
var
|
|
384
|
-
|
|
383
|
+
var c = z.toTimeString(), W = c.match(/\([a-z ]+\)/i);
|
|
384
|
+
W && W[0] ? (W = W[0].match(/[A-Z]/g), W = W ? W.join("") : void 0) : (W = c.match(/[A-Z]{3,5}/g), W = W ? W[0] : void 0), W === "GMT" && (W = void 0), this.at = +z, this.abbr = W, this.offset = z.getTimezoneOffset();
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function C(z) {
|
|
387
387
|
this.zone = z, this.offsetScore = 0, this.abbrScore = 0;
|
|
388
388
|
}
|
|
389
|
-
|
|
389
|
+
C.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
|
|
393
|
-
for (var
|
|
394
|
-
|
|
392
|
+
function F(z, c) {
|
|
393
|
+
for (var W, X; X = ((c.at - z.at) / 12e4 | 0) * 6e4; )
|
|
394
|
+
W = new I(new Date(z.at + X)), W.offset === z.offset ? z = W : c = W;
|
|
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, c = new I(new Date(z, 0, 1)), W = c.offset, X = [c], T, i, V, f;
|
|
399
399
|
for (f = 1; f < 48; f++)
|
|
400
|
-
|
|
400
|
+
V = new Date(z, f, 1).getTimezoneOffset(), V !== W && (i = new I(new Date(z, f, 1)), T = F(c, i), X.push(T), X.push(new I(new Date(T.at + 6e4))), c = i, W = V);
|
|
401
401
|
for (f = 0; f < 4; f++)
|
|
402
402
|
X.push(new I(new Date(z + f, 0, 1))), X.push(new I(new Date(z + f, 6, 1)));
|
|
403
403
|
return X;
|
|
404
404
|
}
|
|
405
|
-
function
|
|
406
|
-
return z.offsetScore !==
|
|
405
|
+
function Q(z, c) {
|
|
406
|
+
return z.offsetScore !== c.offsetScore ? z.offsetScore - c.offsetScore : z.abbrScore !== c.abbrScore ? z.abbrScore - c.abbrScore : z.zone.population !== c.zone.population ? c.zone.population - z.zone.population : c.zone.name.localeCompare(z.zone.name);
|
|
407
407
|
}
|
|
408
|
-
function
|
|
409
|
-
var
|
|
410
|
-
for (S(
|
|
411
|
-
X =
|
|
408
|
+
function D(z, c) {
|
|
409
|
+
var W, X;
|
|
410
|
+
for (S(c), W = 0; W < c.length; W++)
|
|
411
|
+
X = c[W], A[X] = A[X] || {}, A[X][z] = !0;
|
|
412
412
|
}
|
|
413
|
-
function
|
|
414
|
-
var
|
|
415
|
-
for (i = 0; i <
|
|
413
|
+
function l(z) {
|
|
414
|
+
var c = z.length, W = {}, X = [], T = {}, i, V, f, B;
|
|
415
|
+
for (i = 0; i < c; i++)
|
|
416
416
|
if (f = z[i].offset, !T.hasOwnProperty(f)) {
|
|
417
|
-
B =
|
|
418
|
-
for (
|
|
419
|
-
B.hasOwnProperty(
|
|
417
|
+
B = A[f] || {};
|
|
418
|
+
for (V in B)
|
|
419
|
+
B.hasOwnProperty(V) && (W[V] = !0);
|
|
420
420
|
T[f] = !0;
|
|
421
421
|
}
|
|
422
|
-
for (i in
|
|
423
|
-
|
|
422
|
+
for (i in W)
|
|
423
|
+
W.hasOwnProperty(i) && X.push(Y[i]);
|
|
424
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
|
|
433
|
-
|
|
430
|
+
var c = Y[h(z)];
|
|
431
|
+
if (c)
|
|
432
|
+
return c;
|
|
433
|
+
y("Moment Timezone found " + z + " from the Intl api, but did not have that data loaded.");
|
|
434
434
|
}
|
|
435
435
|
} catch {
|
|
436
436
|
}
|
|
437
|
-
var
|
|
437
|
+
var W = P(), X = W.length, T = l(W), i = [], V, f, B;
|
|
438
438
|
for (f = 0; f < T.length; f++) {
|
|
439
|
-
for (
|
|
440
|
-
|
|
441
|
-
i.push(
|
|
439
|
+
for (V = new C(g(T[f])), B = 0; B < X; B++)
|
|
440
|
+
V.scoreOffsetAt(W[B]);
|
|
441
|
+
i.push(V);
|
|
442
442
|
}
|
|
443
|
-
return i.sort(
|
|
443
|
+
return i.sort(Q), i.length > 0 ? i[0].zone.name : void 0;
|
|
444
444
|
}
|
|
445
|
-
function
|
|
445
|
+
function w(z) {
|
|
446
446
|
return (!q || z) && (q = u()), q;
|
|
447
447
|
}
|
|
448
|
-
function
|
|
448
|
+
function h(z) {
|
|
449
449
|
return (z || "").toLowerCase().replace(/\//g, "_");
|
|
450
450
|
}
|
|
451
451
|
function z0(z) {
|
|
452
|
-
var
|
|
453
|
-
for (typeof z == "string" && (z = [z]),
|
|
454
|
-
X = z[
|
|
452
|
+
var c, W, X, T;
|
|
453
|
+
for (typeof z == "string" && (z = [z]), c = 0; c < z.length; c++)
|
|
454
|
+
X = z[c].split("|"), W = X[0], T = h(W), p[T] = z[c], Y[T] = W, D(T, X[2].split(" "));
|
|
455
455
|
}
|
|
456
|
-
function
|
|
457
|
-
z =
|
|
458
|
-
var
|
|
459
|
-
return
|
|
456
|
+
function g(z, c) {
|
|
457
|
+
z = h(z);
|
|
458
|
+
var W = p[z], X;
|
|
459
|
+
return W instanceof G ? W : typeof W == "string" ? (W = new G(W), p[z] = W, W) : O[z] && c !== g && (X = g(O[z], g)) ? (W = p[z] = new G(), W._set(X), W.name = Y[z], W) : null;
|
|
460
460
|
}
|
|
461
461
|
function q0() {
|
|
462
|
-
var z,
|
|
462
|
+
var z, c = [];
|
|
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] && c.push(Y[z]);
|
|
465
|
+
return c.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 c, W, X, T;
|
|
472
|
+
for (typeof z == "string" && (z = [z]), c = 0; c < z.length; c++)
|
|
473
|
+
W = z[c].split("|"), X = h(W[0]), T = h(W[1]), O[X] = T, Y[X] = W[0], O[T] = X, Y[T] = W[1];
|
|
474
474
|
}
|
|
475
475
|
function Y0(z) {
|
|
476
|
-
var
|
|
476
|
+
var c, W, X, T;
|
|
477
477
|
if (!(!z || !z.length))
|
|
478
|
-
for (
|
|
479
|
-
T = z[
|
|
480
|
-
|
|
478
|
+
for (c = 0; c < z.length; c++)
|
|
479
|
+
T = z[c].split("|"), W = T[0].toUpperCase(), X = T[1].split(" "), o[W] = new H(
|
|
480
|
+
W,
|
|
481
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, c) {
|
|
488
488
|
if (z = d0(z), !z)
|
|
489
489
|
return null;
|
|
490
|
-
var
|
|
491
|
-
return
|
|
492
|
-
var T =
|
|
490
|
+
var W = z.zones.sort();
|
|
491
|
+
return c ? W.map(function(X) {
|
|
492
|
+
var T = g(X);
|
|
493
493
|
return {
|
|
494
494
|
name: X,
|
|
495
495
|
offset: T.utcOffset(/* @__PURE__ */ new Date())
|
|
496
496
|
};
|
|
497
|
-
}) :
|
|
497
|
+
}) : W;
|
|
498
498
|
}
|
|
499
499
|
function X0(z) {
|
|
500
500
|
z0(z.zones), b0(z.links), Y0(z.countries), U.dataVersion = z.version;
|
|
501
501
|
}
|
|
502
502
|
function j(z) {
|
|
503
|
-
return j.didShowError || (j.didShowError = !0,
|
|
503
|
+
return j.didShowError || (j.didShowError = !0, y("moment.tz.zoneExists('" + z + "') has been deprecated in favor of !moment.tz.zone('" + z + "')")), !!g(z);
|
|
504
504
|
}
|
|
505
505
|
function x(z) {
|
|
506
|
-
var
|
|
507
|
-
return !!(z._a && z._tzm === void 0 && !
|
|
506
|
+
var c = z._f === "X" || z._f === "x";
|
|
507
|
+
return !!(z._a && z._tzm === void 0 && !c);
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function y(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(X) && (T =
|
|
513
|
+
var c = Array.prototype.slice.call(arguments, 0, -1), W = arguments[arguments.length - 1], X = M.utc.apply(null, c), T;
|
|
514
|
+
return !M.isMoment(z) && x(X) && (T = g(W)) && X.add(T.parse(X), "minutes"), X.tz(W), X;
|
|
515
515
|
}
|
|
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 =
|
|
517
|
-
var
|
|
518
|
-
M.tz = U, M.defaultZone = null, M.updateOffset = function(z,
|
|
519
|
-
var
|
|
520
|
-
if (z._z === void 0 && (
|
|
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 = g, U.zoneExists = j, U.guess = w, U.names = q0, U.Zone = G, U.unpack = s, U.unpackBase60 = N, U.needsOffset = x, U.moveInvalidForward = !0, U.moveAmbiguousForward = !1, U.countries = o0, U.zonesForCountry = a0;
|
|
517
|
+
var K = M.fn;
|
|
518
|
+
M.tz = U, M.defaultZone = null, M.updateOffset = function(z, c) {
|
|
519
|
+
var W = M.defaultZone, X;
|
|
520
|
+
if (z._z === void 0 && (W && x(z) && !z._isUTC && z.isValid() && (z._d = M.utc(z._a)._d, z.utc().add(W.parse(z), "minutes")), z._z = W), z._z)
|
|
521
521
|
if (X = z._z.utcOffset(z), Math.abs(X) < 16 && (X = X / 60), z.utcOffset !== void 0) {
|
|
522
522
|
var T = z._z;
|
|
523
|
-
z.utcOffset(-X,
|
|
523
|
+
z.utcOffset(-X, c), z._z = T;
|
|
524
524
|
} else
|
|
525
|
-
z.zone(X,
|
|
526
|
-
},
|
|
525
|
+
z.zone(X, c);
|
|
526
|
+
}, K.tz = function(z, c) {
|
|
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 =
|
|
530
|
+
return this._z = g(z), this._z ? M.updateOffset(this, c) : y("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;
|
|
@@ -547,8 +547,8 @@ var c0 = { exports: {} };
|
|
|
547
547
|
return arguments.length > 0 && (this._z = null), z.apply(this, arguments);
|
|
548
548
|
};
|
|
549
549
|
}
|
|
550
|
-
|
|
551
|
-
return (R < 2 || R === 2 && L < 9) &&
|
|
550
|
+
K.zoneName = p0(K.zoneName), K.zoneAbbr = p0(K.zoneAbbr), K.utc = O0(K.utc), K.local = O0(K.local), K.utcOffset = R0(K.utcOffset), M.tz.setDefault = function(z) {
|
|
551
|
+
return (R < 2 || R === 2 && L < 9) && y("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = z ? g(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;
|
|
@@ -1410,17 +1410,17 @@ const r0 = "2025b", U0 = [
|
|
|
1410
1410
|
};
|
|
1411
1411
|
var t0 = S0;
|
|
1412
1412
|
t0.tz.load(V0);
|
|
1413
|
-
let
|
|
1413
|
+
let E;
|
|
1414
1414
|
try {
|
|
1415
|
-
|
|
1415
|
+
E = M0.getLogger("meteo2");
|
|
1416
1416
|
} catch {
|
|
1417
1417
|
} finally {
|
|
1418
1418
|
}
|
|
1419
1419
|
class C0 {
|
|
1420
1420
|
constructor(M, b) {
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1421
|
+
_(this, "apikey");
|
|
1422
|
+
_(this, "debug");
|
|
1423
|
+
_(this, "FORECAST", {
|
|
1424
1424
|
OM_URL: "https://customer-api.open-meteo.com/v1/forecast",
|
|
1425
1425
|
ORM_URL: "https://meteo3.idmwx.com/v1/forecast",
|
|
1426
1426
|
OM_HISTORY_URL: "https://customer-historical-forecast-api.open-meteo.com/v1/forecast",
|
|
@@ -1437,27 +1437,27 @@ class C0 {
|
|
|
1437
1437
|
HOURLY: "wave_height,wave_direction,wave_period,wind_wave_height,wind_wave_direction,wind_wave_period,wind_wave_peak_period,swell_wave_height,swell_wave_direction,swell_wave_period,swell_wave_peak_period,ocean_current_velocity,ocean_current_direction,sea_level_height_msl,sea_surface_temperature"
|
|
1438
1438
|
}
|
|
1439
1439
|
});
|
|
1440
|
-
|
|
1440
|
+
_(this, "HISTORICAL", {
|
|
1441
1441
|
OM_URL: "https://customer-archive-api.open-meteo.com/v1/archive",
|
|
1442
1442
|
WEATHER_VARIABLES: {
|
|
1443
1443
|
HOURLY: "temperature_2m,apparent_temperature,precipitation,weather_code,pressure_msl,surface_pressure,wind_speed_10m,wind_direction_10m,wind_gusts_10m",
|
|
1444
1444
|
DAILY: "weather_code,temperature_2m_max,temperature_2m_min,temperature_2m_mean,precipitation_sum,precipitation_hours,wind_speed_10m_max,wind_gusts_10m_max,wind_direction_10m_dominant"
|
|
1445
1445
|
}
|
|
1446
1446
|
});
|
|
1447
|
-
|
|
1447
|
+
_(this, "CLIMATE", {
|
|
1448
1448
|
OM_URL: "https://customer-climate-api.open-meteo.com/v1/climate",
|
|
1449
1449
|
WEATHER_VARIABLES: {
|
|
1450
1450
|
DAILY: "temperature_2m_mean,temperature_2m_max,temperature_2m_min,wind_speed_10m_mean,wind_speed_10m_max,relative_humidity_2m_mean,relative_humidity_2m_max,relative_humidity_2m_min,precipitation_sum"
|
|
1451
1451
|
}
|
|
1452
1452
|
});
|
|
1453
|
-
|
|
1453
|
+
_(this, "SEASONAL", {
|
|
1454
1454
|
OM_URL: "https://seasonal-api.open-meteo.com/v1/seasonal",
|
|
1455
1455
|
WEATHER_VARIABLES: {
|
|
1456
1456
|
DAILY: "temperature_2m_max,temperature_2m_min,precipitation_sum,precipitation_hours,wind_direction_10m_dominant,wind_speed_10m_max",
|
|
1457
1457
|
SIX_HOURLY: "pressure_msl,temperature_2m,temperature_2m_max,temperature_2m_min,precipitation,wind_direction_10m,wind_speed_10m,relative_humidity_2m,showers,cloud_cover"
|
|
1458
1458
|
}
|
|
1459
1459
|
});
|
|
1460
|
-
|
|
1460
|
+
_(this, "METEO2_UPDATE", {
|
|
1461
1461
|
etime: n().unix(),
|
|
1462
1462
|
version: 0
|
|
1463
1463
|
});
|
|
@@ -1487,15 +1487,15 @@ class C0 {
|
|
|
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 &&
|
|
1490
|
+
const A = M.url[Y];
|
|
1491
|
+
this.debug && E.debug("[%s] fetch weather via %s with %j", b.requestId, A, {
|
|
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 $(A, M), a = await this.parseWeatherData(q, M, b);
|
|
1498
|
+
O ? await this.mergeSegments(O, a) : O = a;
|
|
1499
1499
|
}
|
|
1500
1500
|
else {
|
|
1501
1501
|
const Y = await $(M.url, M);
|
|
@@ -1503,9 +1503,9 @@ class C0 {
|
|
|
1503
1503
|
}
|
|
1504
1504
|
delete M.apikey;
|
|
1505
1505
|
const o = n();
|
|
1506
|
-
return this.debug &&
|
|
1506
|
+
return this.debug && E.info("[%s] fetch weather api (%j) cost: %d ms", b.requestId, M.url, o.diff(p, "ms")), O;
|
|
1507
1507
|
} catch (p) {
|
|
1508
|
-
return
|
|
1508
|
+
return E.warn("[%s] weather forecast failed: %s, with %j", b.requestId, p, M), [];
|
|
1509
1509
|
}
|
|
1510
1510
|
}
|
|
1511
1511
|
/**
|
|
@@ -1530,33 +1530,33 @@ class C0 {
|
|
|
1530
1530
|
const o = n();
|
|
1531
1531
|
let Y;
|
|
1532
1532
|
if (M.start_dates instanceof Array)
|
|
1533
|
-
for (let
|
|
1534
|
-
M.start_date = M.start_dates[
|
|
1535
|
-
const R = M.url[
|
|
1536
|
-
this.debug &&
|
|
1533
|
+
for (let a = 0; a < M.start_dates.length; a++) {
|
|
1534
|
+
M.start_date = M.start_dates[a], M.end_date = M.end_dates[a], M.fake = M.fakes[a];
|
|
1535
|
+
const R = M.url[a];
|
|
1536
|
+
this.debug && E.debug("[%s] fetch marine via %s with %j", b.requestId, R, {
|
|
1537
1537
|
start_date: M.start_date,
|
|
1538
1538
|
end_date: M.end_date,
|
|
1539
1539
|
fake: M.fake,
|
|
1540
|
-
step:
|
|
1540
|
+
step: a
|
|
1541
1541
|
});
|
|
1542
|
-
const L = await $(R, M),
|
|
1543
|
-
Y ? await this.mergeSegments(Y,
|
|
1542
|
+
const L = await $(R, M), d = await this.parseWeatherData(L, M, b);
|
|
1543
|
+
Y ? await this.mergeSegments(Y, d) : Y = d;
|
|
1544
1544
|
}
|
|
1545
1545
|
else {
|
|
1546
|
-
const
|
|
1547
|
-
Y = await this.parseWeatherData(
|
|
1546
|
+
const a = await $(M.url, M);
|
|
1547
|
+
Y = await this.parseWeatherData(a, M, b);
|
|
1548
1548
|
}
|
|
1549
1549
|
delete M.apikey;
|
|
1550
|
-
const
|
|
1551
|
-
this.debug &&
|
|
1550
|
+
const A = n();
|
|
1551
|
+
this.debug && E.info("[%s] fetch marine api (%j) cost: %d ms", b.requestId, M.url, A.diff(o, "ms"));
|
|
1552
1552
|
const q = await this.mergeMarineData(Y);
|
|
1553
1553
|
if (["gfswave", "ncep_gfswave025"].includes(b.marineModels)) {
|
|
1554
|
-
const
|
|
1555
|
-
return (O = (p =
|
|
1554
|
+
const a = q.find((L) => L.model === "ncep_gfswave016"), R = q.find((L) => L.model === "ncep_gfswave025");
|
|
1555
|
+
return (O = (p = a == null ? void 0 : a.hourly) == null ? void 0 : p.wave_height) != null && O.every((L) => L !== null) ? [a] : [R];
|
|
1556
1556
|
} else
|
|
1557
1557
|
return q;
|
|
1558
1558
|
} catch (o) {
|
|
1559
|
-
return
|
|
1559
|
+
return E.warn("[%s] marine forecast failed: %s, with %j", b.requestId, o, M), [];
|
|
1560
1560
|
}
|
|
1561
1561
|
}
|
|
1562
1562
|
/**
|
|
@@ -1567,65 +1567,65 @@ class C0 {
|
|
|
1567
1567
|
* @private
|
|
1568
1568
|
*/
|
|
1569
1569
|
async parseWeatherData(M, b, p = {}) {
|
|
1570
|
-
var Y,
|
|
1570
|
+
var Y, A, q, a, R, L, d, N, S, Z;
|
|
1571
1571
|
const O = [], o = Math.pow(10, p.precision || 6);
|
|
1572
|
-
for (let
|
|
1573
|
-
const
|
|
1574
|
-
if (P.timezone =
|
|
1575
|
-
const
|
|
1572
|
+
for (let t = 0; t < M.length; t++) {
|
|
1573
|
+
const s = M[t], G = s.utcOffsetSeconds(), m = s.timezone(), H = s.current(), I = s.hourly(), C = s.sixHourly(), F = s.daily(), P = {};
|
|
1574
|
+
if (P.timezone = m || void 0, P.offset = this.prettyTimezoneOffset(G), P.model = b.models instanceof Array ? (Y = b.models) == null ? void 0 : Y[t] : b.models || "best_match", H) {
|
|
1575
|
+
const Q = n();
|
|
1576
1576
|
P.current = {
|
|
1577
|
-
time: n.unix(Number(
|
|
1577
|
+
time: n.unix(Number(H.time())).utc().format()
|
|
1578
1578
|
};
|
|
1579
|
-
for (let
|
|
1580
|
-
const u =
|
|
1581
|
-
P.current[b.current[
|
|
1579
|
+
for (let l = 0; l < H.variablesLength(); l++) {
|
|
1580
|
+
const u = H.variables(l).value();
|
|
1581
|
+
P.current[b.current[l]] = isNaN(u) ? null : Math.round(u * o) / o;
|
|
1582
1582
|
}
|
|
1583
|
-
const
|
|
1584
|
-
this.debug &&
|
|
1583
|
+
const D = n();
|
|
1584
|
+
this.debug && E.debug("[%s] fetch current variables cost: %d ms", p.requestId, D.diff(Q, "ms"));
|
|
1585
1585
|
}
|
|
1586
1586
|
if (I) {
|
|
1587
|
-
const
|
|
1587
|
+
const Q = n(), D = n.unix(Number(I.time())).add(b.fake ? 1 : 0, "year");
|
|
1588
1588
|
P.hourly = {
|
|
1589
|
-
date:
|
|
1589
|
+
date: D.utc().format(),
|
|
1590
1590
|
time: this.range(Number(I.time()), Number(I.timeEnd()), I.interval()).map(
|
|
1591
|
-
(u) => n.unix(u).add(b.fake ? 1 : 0, "year").diff(
|
|
1591
|
+
(u) => n.unix(u).add(b.fake ? 1 : 0, "year").diff(D, "h")
|
|
1592
1592
|
)
|
|
1593
1593
|
};
|
|
1594
1594
|
for (let u = 0; u < I.variablesLength(); u++) {
|
|
1595
|
-
const
|
|
1596
|
-
P.hourly[b.hourly[u]] =
|
|
1595
|
+
const w = (a = (q = (A = I.variables(u).valuesArray()) == null ? void 0 : A.toString()) == null ? void 0 : q.split(",")) == null ? void 0 : a.map((h) => isNaN(h) ? null : Math.round(Number(h) * o) / o);
|
|
1596
|
+
P.hourly[b.hourly[u]] = w;
|
|
1597
1597
|
}
|
|
1598
|
-
const
|
|
1599
|
-
this.debug &&
|
|
1598
|
+
const l = n();
|
|
1599
|
+
this.debug && E.debug("[%s] fetch hourly variables cost: %d ms", p.requestId, l.diff(Q, "ms"));
|
|
1600
1600
|
}
|
|
1601
|
-
if (
|
|
1602
|
-
const
|
|
1601
|
+
if (C) {
|
|
1602
|
+
const Q = n(), D = n.unix(Number(C.time())).add(b.fake ? 1 : 0, "year");
|
|
1603
1603
|
P.sixHourly = {
|
|
1604
|
-
date:
|
|
1605
|
-
time: this.range(Number(
|
|
1606
|
-
(u) => n.unix(u).add(b.fake ? 1 : 0, "year").diff(
|
|
1604
|
+
date: D.utc().format(),
|
|
1605
|
+
time: this.range(Number(C.time()), Number(C.timeEnd()), C.interval()).map(
|
|
1606
|
+
(u) => n.unix(u).add(b.fake ? 1 : 0, "year").diff(D, "h")
|
|
1607
1607
|
)
|
|
1608
1608
|
};
|
|
1609
|
-
for (let u = 0; u <
|
|
1610
|
-
const
|
|
1611
|
-
|
|
1609
|
+
for (let u = 0; u < C.variablesLength(); u += p.memberLength ?? 1) {
|
|
1610
|
+
const w = (d = (L = (R = C.variables(u).valuesArray()) == null ? void 0 : R.toString()) == null ? void 0 : L.split(",")) == null ? void 0 : d.map((h) => isNaN(h) ? null : Math.round(Number(h) * o) / o);
|
|
1611
|
+
C.variables(u), P.sixHourly[b.six_hourly[u / (p.memberLength ?? 1)]] = w;
|
|
1612
1612
|
}
|
|
1613
|
-
const
|
|
1614
|
-
this.debug &&
|
|
1613
|
+
const l = n();
|
|
1614
|
+
this.debug && E.debug("[%s] fetch 6-hourly variables cost: %d ms", p.requestId, l.diff(Q, "ms"));
|
|
1615
1615
|
}
|
|
1616
|
-
if (
|
|
1617
|
-
const
|
|
1616
|
+
if (F) {
|
|
1617
|
+
const Q = n();
|
|
1618
1618
|
P.daily = {
|
|
1619
|
-
time: this.range(Number(
|
|
1620
|
-
(
|
|
1619
|
+
time: this.range(Number(F.time()), Number(F.timeEnd()), F.interval()).map(
|
|
1620
|
+
(l) => n.unix(l).add(b.fake ? 1 : 0, "year").utc().format()
|
|
1621
1621
|
)
|
|
1622
1622
|
};
|
|
1623
|
-
for (let
|
|
1624
|
-
const u = (
|
|
1625
|
-
P.daily[b.daily[
|
|
1623
|
+
for (let l = 0; l < F.variablesLength(); l += p.memberLength ?? 1) {
|
|
1624
|
+
const u = (Z = (S = (N = F.variables(l).valuesArray()) == null ? void 0 : N.toString()) == null ? void 0 : S.split(",")) == null ? void 0 : Z.map((w) => isNaN(w) ? null : Math.round(Number(w) * o) / o);
|
|
1625
|
+
P.daily[b.daily[l / (p.memberLength ?? 1)]] = u;
|
|
1626
1626
|
}
|
|
1627
|
-
const
|
|
1628
|
-
this.debug &&
|
|
1627
|
+
const D = n();
|
|
1628
|
+
this.debug && E.debug("[%s] fetch daily variables cost: %d ms", p.requestId, D.diff(Q, "ms"));
|
|
1629
1629
|
}
|
|
1630
1630
|
O.push(P);
|
|
1631
1631
|
}
|
|
@@ -1639,19 +1639,19 @@ class C0 {
|
|
|
1639
1639
|
if (M[p][O][o] instanceof Array)
|
|
1640
1640
|
if (o === "time" && O === "hourly") {
|
|
1641
1641
|
const Y = M[p][O][o].at(-1);
|
|
1642
|
-
b[p][O][o] = b[p][O][o].map((
|
|
1642
|
+
b[p][O][o] = b[p][O][o].map((A) => A + Y + 1), M[p][O][o].push(...b[p][O][o]);
|
|
1643
1643
|
} else
|
|
1644
1644
|
M[p][O][o].push(...b[p][O][o]);
|
|
1645
1645
|
}
|
|
1646
1646
|
return M;
|
|
1647
1647
|
}
|
|
1648
1648
|
async mergeMarineData(M) {
|
|
1649
|
-
var o, Y,
|
|
1650
|
-
const b = [], p = M.find((
|
|
1649
|
+
var o, Y, A, q;
|
|
1650
|
+
const b = [], p = M.find((a) => a.model === "best_match");
|
|
1651
1651
|
p && b.push(p);
|
|
1652
|
-
const O = M.find((
|
|
1653
|
-
for (const
|
|
1654
|
-
["best_match", "meteofrance_currents"].includes(
|
|
1652
|
+
const O = M.find((a) => a.model === "meteofrance_currents");
|
|
1653
|
+
for (const a of M)
|
|
1654
|
+
["best_match", "meteofrance_currents"].includes(a.model) || (a.hourly.ocean_current_velocity = (o = O == null ? void 0 : O.hourly) == null ? void 0 : o.ocean_current_velocity, a.hourly.ocean_current_direction = (Y = O == null ? void 0 : O.hourly) == null ? void 0 : Y.ocean_current_direction, a.hourly.sea_level_height_msl = (A = O == null ? void 0 : O.hourly) == null ? void 0 : A.sea_level_height_msl, a.hourly.sea_surface_temperature = (q = O == null ? void 0 : O.hourly) == null ? void 0 : q.sea_surface_temperature, b.push(a));
|
|
1655
1655
|
return b;
|
|
1656
1656
|
}
|
|
1657
1657
|
pickForecastUrl(M, b, p, O = {}) {
|
|
@@ -1663,14 +1663,14 @@ class C0 {
|
|
|
1663
1663
|
if (!(b != null && b.length))
|
|
1664
1664
|
return ["best_match"];
|
|
1665
1665
|
const p = [];
|
|
1666
|
-
for (let
|
|
1667
|
-
const q = b[
|
|
1666
|
+
for (let A = 0; A < b.length; A++) {
|
|
1667
|
+
const q = b[A];
|
|
1668
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");
|
|
1669
1669
|
}
|
|
1670
|
-
const O = p.reduce((
|
|
1671
|
-
return O.sort((
|
|
1672
|
-
const
|
|
1673
|
-
return
|
|
1670
|
+
const O = p.reduce((A, q) => (A.includes(q) || A.push(q), A), []), o = ["best_match", "meteofrance_currents", "meteofrance_wave", "ecmwf_wam025", "ncep_gfswave025", "gwam", "era5_ocean", "ewam", "ncep_gfswave016"];
|
|
1671
|
+
return O.sort((A, q) => {
|
|
1672
|
+
const a = o.indexOf(A), R = o.indexOf(q);
|
|
1673
|
+
return a - R;
|
|
1674
1674
|
}), O;
|
|
1675
1675
|
}
|
|
1676
1676
|
/**
|
|
@@ -1683,20 +1683,20 @@ class C0 {
|
|
|
1683
1683
|
*/
|
|
1684
1684
|
prepare(M, b, p, O = {}) {
|
|
1685
1685
|
var q;
|
|
1686
|
-
const o = n().utc(), Y = M ? n.utc(M) : void 0,
|
|
1686
|
+
const o = n().utc(), Y = M ? n.utc(M) : void 0, A = o.clone().utc().add(b && ((q = p.models) != null && q.includes("meteofrance_wave")) ? 10 : 15, "day");
|
|
1687
1687
|
if (M) {
|
|
1688
|
-
const
|
|
1689
|
-
|
|
1688
|
+
const a = Y.clone().utc().add(O.forecastDays ?? 1, "day");
|
|
1689
|
+
a.isAfter(A) ? (a.subtract(1, "year"), Y.isAfter(A) ? (Y.subtract(1, "year"), p.start_dates = [
|
|
1690
1690
|
Y.clone().subtract(O.pastDays || 0, "day").utc().format("YYYY-MM-DD")
|
|
1691
|
-
], p.end_dates = [
|
|
1691
|
+
], p.end_dates = [a.utc().format("YYYY-MM-DD")], p.fakes = [!0], p.url = [this.pickForecastUrl(b, O.selfHosted ?? !0, !0, O)]) : (p.start_dates = [
|
|
1692
1692
|
Y.clone().subtract(O.pastDays || 0, "day").utc().format("YYYY-MM-DD"),
|
|
1693
|
-
|
|
1694
|
-
], p.end_dates = [
|
|
1693
|
+
A.clone().subtract(1, "year").utc().format("YYYY-MM-DD")
|
|
1694
|
+
], p.end_dates = [A.clone().subtract(1, "day").utc().format("YYYY-MM-DD"), a.utc().format("YYYY-MM-DD")], p.fakes = [!1, !0], p.url = [
|
|
1695
1695
|
this.pickForecastUrl(b, O.selfHosted ?? !0, !1, O),
|
|
1696
1696
|
this.pickForecastUrl(b, O.selfHosted ?? !0, !0, O)
|
|
1697
1697
|
])) : (p.start_dates = [
|
|
1698
1698
|
Y.clone().subtract(O.pastDays || 0, "day").utc().format("YYYY-MM-DD")
|
|
1699
|
-
], p.end_dates = [
|
|
1699
|
+
], p.end_dates = [a.utc().format("YYYY-MM-DD")], p.fakes = [!1], p.url = [this.pickForecastUrl(b, O.selfHosted ?? !0, Y.isBefore(o.clone().subtract(30, "day")), O)]);
|
|
1700
1700
|
} else
|
|
1701
1701
|
p.forecast_days = O.forecastDays, p.past_days = O.pastDays, p.fake = !1, p.url = this.pickForecastUrl(b, O.selfHosted ?? !0, !1, O);
|
|
1702
1702
|
return p;
|
|
@@ -1746,41 +1746,41 @@ class C0 {
|
|
|
1746
1746
|
* @param withHourly
|
|
1747
1747
|
* @param options
|
|
1748
1748
|
*/
|
|
1749
|
-
async spotForecast(M, b, p, O = !0, o = !0, Y = !1,
|
|
1749
|
+
async spotForecast(M, b, p, O = !0, o = !0, Y = !1, A = {
|
|
1750
1750
|
forecastDays: 1,
|
|
1751
1751
|
pastDays: 0,
|
|
1752
1752
|
precision: 6,
|
|
1753
1753
|
selfHosted: !0
|
|
1754
1754
|
}) {
|
|
1755
|
-
var N, S,
|
|
1756
|
-
b = this.toStdLng(b), this.debug &&
|
|
1755
|
+
var N, S, Z, t, s, G;
|
|
1756
|
+
b = this.toStdLng(b), this.debug && E.info("[%s] spot forecast params: %j", A.requestId, { lat: M, lng: b, datetime: p, simplify: O, withDaily: o, withHourly: Y, options: A });
|
|
1757
1757
|
const q = {
|
|
1758
1758
|
apikey: this.apikey,
|
|
1759
1759
|
latitude: M,
|
|
1760
1760
|
longitude: b,
|
|
1761
1761
|
cell_selection: "sea",
|
|
1762
1762
|
wind_speed_unit: "kn",
|
|
1763
|
-
models: ((N =
|
|
1763
|
+
models: ((N = A.weatherModels) == null ? void 0 : N.split(",")) || ["best_match"],
|
|
1764
1764
|
timezone: "auto"
|
|
1765
1765
|
};
|
|
1766
|
-
let
|
|
1766
|
+
let a;
|
|
1767
1767
|
if (p) {
|
|
1768
|
-
const
|
|
1769
|
-
|
|
1768
|
+
const m = this.timezoneOffset(M, b);
|
|
1769
|
+
a = n.utc(p).utcOffset(m), a.subtract(m > 0 ? m : -m, "h");
|
|
1770
1770
|
}
|
|
1771
|
-
o && (q.daily = ((S = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : S.split(",")) || []),
|
|
1772
|
-
const R = await this.weatherForecast(q,
|
|
1771
|
+
o && (q.daily = ((S = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : S.split(",")) || []), a || (A.forecastDays = A.forecastDays || 1, A.pastDays = 0, Y = !0), Y && (q.hourly = ((Z = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : Z.split(",")) || []), A.pastDays = A.pastDays || 0, A.pastDays = A.pastDays > 7 ? 7 : A.pastDays < 0 ? 0 : A.pastDays, A.forecastDays = A.forecastDays ?? 1, A.forecastDays = A.forecastDays > 14 ? 14 : A.forecastDays < 0 ? 1 : A.forecastDays, this.prepare(a == null ? void 0 : a.utc().format(), !1, q, A);
|
|
1772
|
+
const R = await this.weatherForecast(q, A), L = {
|
|
1773
1773
|
apikey: this.apikey,
|
|
1774
1774
|
latitude: M,
|
|
1775
1775
|
longitude: b,
|
|
1776
1776
|
cell_selection: "sea",
|
|
1777
1777
|
timezone: "auto",
|
|
1778
1778
|
wind_speed_unit: "kn",
|
|
1779
|
-
models: this.pickMarineModels(
|
|
1779
|
+
models: this.pickMarineModels(A.marineModels)
|
|
1780
1780
|
};
|
|
1781
|
-
o && (L.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")),
|
|
1782
|
-
|
|
1783
|
-
return { weather: R, marine:
|
|
1781
|
+
o && (L.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), a || (A.forecastDays = A.forecastDays || 1, Y = !0), Y && (L.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), this.prepare(a == null ? void 0 : a.utc().format(), !0, L, A);
|
|
1782
|
+
let d = await this.marineForecast(L, A);
|
|
1783
|
+
return (G = (s = (t = d[0]) == null ? void 0 : t.hourly) == null ? void 0 : s.wave_height) != null && G.every((m) => m === null) && (delete L.models, delete A.marineModels, d = await this.marineForecast(L, A)), { weather: R, marine: d };
|
|
1784
1784
|
}
|
|
1785
1785
|
/**
|
|
1786
1786
|
* 历史再分析数据
|
|
@@ -1803,44 +1803,44 @@ class C0 {
|
|
|
1803
1803
|
* @param withMarine
|
|
1804
1804
|
* @param options
|
|
1805
1805
|
*/
|
|
1806
|
-
async spotHistorical(M, b, p, O, o = !0, Y = !0,
|
|
1806
|
+
async spotHistorical(M, b, p, O, o = !0, Y = !0, A = !1, q = {
|
|
1807
1807
|
precision: 6
|
|
1808
1808
|
}) {
|
|
1809
|
-
var
|
|
1810
|
-
b = this.toStdLng(b), this.debug &&
|
|
1811
|
-
const
|
|
1812
|
-
R.subtract(
|
|
1813
|
-
const
|
|
1809
|
+
var Z, t;
|
|
1810
|
+
b = this.toStdLng(b), this.debug && E.info("[%s] spot historical params: %j", q.requestId, { lat: M, lng: b, startDate: p, endDate: O, withMarine: A, options: q });
|
|
1811
|
+
const a = this.timezoneOffset(M, b), R = n.utc(p).utcOffset(a), L = n.utc(O).utcOffset(a);
|
|
1812
|
+
R.subtract(a > 0 ? a : -a, "h"), L.subtract(a > 0 ? a : -a, "h");
|
|
1813
|
+
const d = {
|
|
1814
1814
|
apikey: this.apikey,
|
|
1815
1815
|
latitude: M,
|
|
1816
1816
|
longitude: b,
|
|
1817
1817
|
cell_selection: "sea",
|
|
1818
1818
|
wind_speed_unit: "kn",
|
|
1819
|
-
models: ((
|
|
1819
|
+
models: ((Z = q.weatherModels) == null ? void 0 : Z.split(",")) || ["best_match"],
|
|
1820
1820
|
timezone: "auto",
|
|
1821
1821
|
url: this.HISTORICAL.OM_URL,
|
|
1822
1822
|
start_date: R.format("YYYY-MM-DD"),
|
|
1823
1823
|
end_date: L.format("YYYY-MM-DD")
|
|
1824
1824
|
};
|
|
1825
|
-
o && (
|
|
1826
|
-
const N = await this.weatherForecast(
|
|
1825
|
+
o && (d.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), Y && (d.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
|
|
1826
|
+
const N = await this.weatherForecast(d, q);
|
|
1827
1827
|
let S;
|
|
1828
|
-
if (
|
|
1829
|
-
const
|
|
1828
|
+
if (A) {
|
|
1829
|
+
const s = {
|
|
1830
1830
|
apikey: this.apikey,
|
|
1831
1831
|
latitude: M,
|
|
1832
1832
|
longitude: b,
|
|
1833
1833
|
cell_selection: "sea",
|
|
1834
1834
|
timezone: "auto",
|
|
1835
1835
|
wind_speed_unit: "kn",
|
|
1836
|
-
models: ((
|
|
1836
|
+
models: ((t = q.marineModels) == null ? void 0 : t.split(",")) || ["best_match"],
|
|
1837
1837
|
daily: this.FORECAST.MARINE_VARIABLES.DAILY.split(","),
|
|
1838
1838
|
hourly: this.FORECAST.MARINE_VARIABLES.HOURLY.split(","),
|
|
1839
1839
|
url: this.FORECAST.OM_MARINE_URL,
|
|
1840
1840
|
start_date: R.format("YYYY-MM-DD"),
|
|
1841
1841
|
end_date: L.format("YYYY-MM-DD")
|
|
1842
1842
|
};
|
|
1843
|
-
S = await this.marineForecast(
|
|
1843
|
+
S = await this.marineForecast(s, q);
|
|
1844
1844
|
}
|
|
1845
1845
|
return { weather: N, marine: S };
|
|
1846
1846
|
}
|
|
@@ -1858,9 +1858,9 @@ class C0 {
|
|
|
1858
1858
|
async spotSeasonal(M, b, p, O, o = !1, Y = {
|
|
1859
1859
|
precision: 6
|
|
1860
1860
|
}) {
|
|
1861
|
-
b = this.toStdLng(b), this.debug &&
|
|
1862
|
-
const
|
|
1863
|
-
q.subtract(
|
|
1861
|
+
b = this.toStdLng(b), this.debug && E.info("[%s] spot seasonal params: %j", Y.requestId, { lat: M, lng: b, startDate: p, endDate: O, options: Y });
|
|
1862
|
+
const A = this.timezoneOffset(M, b), q = n.utc(p).utcOffset(A), a = O ? n.utc(O).utcOffset(A) : q.clone().add(1, "month");
|
|
1863
|
+
q.subtract(A > 0 ? A : -A, "h"), a.subtract(A > 0 ? A : -A, "h");
|
|
1864
1864
|
const R = {
|
|
1865
1865
|
apikey: this.apikey,
|
|
1866
1866
|
latitude: M,
|
|
@@ -1870,7 +1870,7 @@ class C0 {
|
|
|
1870
1870
|
timezone: "auto",
|
|
1871
1871
|
url: this.SEASONAL.OM_URL,
|
|
1872
1872
|
start_date: q.format("YYYY-MM-DD"),
|
|
1873
|
-
end_date:
|
|
1873
|
+
end_date: a.format("YYYY-MM-DD"),
|
|
1874
1874
|
daily: this.SEASONAL.WEATHER_VARIABLES.DAILY.split(",")
|
|
1875
1875
|
};
|
|
1876
1876
|
return o && (R.six_hourly = this.SEASONAL.WEATHER_VARIABLES.SIX_HOURLY.split(",")), Y.memberLength = 4, { weather: await this.weatherForecast(R, Y) };
|
|
@@ -1899,10 +1899,10 @@ class C0 {
|
|
|
1899
1899
|
precision: 6
|
|
1900
1900
|
}) {
|
|
1901
1901
|
var L;
|
|
1902
|
-
b = this.toStdLng(b), this.debug &&
|
|
1903
|
-
const Y = this.timezoneOffset(M, b),
|
|
1904
|
-
q.subtract(Y > 0 ? Y : -Y, "h"),
|
|
1905
|
-
const
|
|
1902
|
+
b = this.toStdLng(b), this.debug && E.info("[%s] spot climate params: %j", o.requestId, { lat: M, lng: b, startDate: p, endDate: O, options: o });
|
|
1903
|
+
const Y = this.timezoneOffset(M, b), A = n.utc(p).utcOffset(Y), q = O ? n.utc(O).utcOffset(Y) : A.clone().add(1, "day");
|
|
1904
|
+
q.subtract(Y > 0 ? Y : -Y, "h"), A.subtract(Y > 0 ? Y : -Y, "h");
|
|
1905
|
+
const a = {
|
|
1906
1906
|
apikey: this.apikey,
|
|
1907
1907
|
latitude: M,
|
|
1908
1908
|
longitude: b,
|
|
@@ -1911,35 +1911,35 @@ class C0 {
|
|
|
1911
1911
|
models: ((L = o.weatherModels) == null ? void 0 : L.split(",")) || "EC_Earth3P_HR",
|
|
1912
1912
|
timezone: "auto",
|
|
1913
1913
|
url: this.CLIMATE.OM_URL,
|
|
1914
|
-
start_date:
|
|
1914
|
+
start_date: A.format("YYYY-MM-DD"),
|
|
1915
1915
|
end_date: q.format("YYYY-MM-DD"),
|
|
1916
1916
|
daily: this.CLIMATE.WEATHER_VARIABLES.DAILY.split(",")
|
|
1917
1917
|
};
|
|
1918
|
-
return { weather: await this.weatherForecast(
|
|
1918
|
+
return { weather: await this.weatherForecast(a, o) };
|
|
1919
1919
|
}
|
|
1920
1920
|
async update(M = {}) {
|
|
1921
1921
|
const b = n.unix(this.METEO2_UPDATE.etime), p = this.METEO2_UPDATE.version, O = n();
|
|
1922
1922
|
if (!p || b.clone().add(10, "minute").isBefore(O)) {
|
|
1923
|
-
const o = M.url || "https://meteo3agent.idmwx.com/api/agents/update",
|
|
1923
|
+
const o = M.url || "https://meteo3agent.idmwx.com/api/agents/update", A = await (await fetch(o, {
|
|
1924
1924
|
headers: {
|
|
1925
1925
|
"Content-Type": "application/json",
|
|
1926
1926
|
Authorization: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsYmY5M3I0YTAwMDE4Ymx0NWJ4emFwNWMiLCJyb2xlIjoyMDQ3LCJpYXQiOjE2NzA1NTM0NzAsImV4cCI6Mzg3ODA3MzQ3MH0.MxTv0yLGarZCtOSCZfJHMqrXNMNN0-OL4gBGKGcYcc8"
|
|
1927
1927
|
}
|
|
1928
1928
|
})).json();
|
|
1929
|
-
if (
|
|
1930
|
-
const q =
|
|
1931
|
-
for (const R of
|
|
1929
|
+
if (A.code === 0) {
|
|
1930
|
+
const q = A.data, a = k.standardWeatherModels();
|
|
1931
|
+
for (const R of a) {
|
|
1932
1932
|
const L = k.autoPickSubCategories(R.alias), N = q.filter((S) => L.includes(S.category)).map((S) => {
|
|
1933
|
-
var
|
|
1933
|
+
var Z, t, s, G, m, H;
|
|
1934
1934
|
return {
|
|
1935
1935
|
category: S.category,
|
|
1936
1936
|
meta: {
|
|
1937
|
-
endTime: n.unix((
|
|
1938
|
-
availabilityTime: n.unix((
|
|
1939
|
-
initialisationTime: n.unix((
|
|
1940
|
-
modificationTime: n.unix((
|
|
1941
|
-
temporalResolution: Math.round(((
|
|
1942
|
-
frequency: Math.round(((
|
|
1937
|
+
endTime: n.unix((Z = S.meta) == null ? void 0 : Z.data_end_time).utc().format(),
|
|
1938
|
+
availabilityTime: n.unix((t = S.meta) == null ? void 0 : t.last_run_availability_time).utc().format(),
|
|
1939
|
+
initialisationTime: n.unix((s = S.meta) == null ? void 0 : s.last_run_initialisation_time).utc().format(),
|
|
1940
|
+
modificationTime: n.unix((G = S.meta) == null ? void 0 : G.last_run_modification_time).utc().format(),
|
|
1941
|
+
temporalResolution: Math.round(((m = S.meta) == null ? void 0 : m.temporal_resolution_seconds) / 3600),
|
|
1942
|
+
frequency: Math.round(((H = S.meta) == null ? void 0 : H.update_interval_seconds) / 3600)
|
|
1943
1943
|
}
|
|
1944
1944
|
};
|
|
1945
1945
|
});
|
|
@@ -1959,8 +1959,8 @@ try {
|
|
|
1959
1959
|
}
|
|
1960
1960
|
class D0 {
|
|
1961
1961
|
constructor(M, b) {
|
|
1962
|
-
|
|
1963
|
-
|
|
1962
|
+
_(this, "apikey");
|
|
1963
|
+
_(this, "debug");
|
|
1964
1964
|
this.apikey = M || "aaf294e6-be27-40b8-82cb-0d7844d2dd74", this.debug = b;
|
|
1965
1965
|
}
|
|
1966
1966
|
toStdLng(M, b = 6) {
|
|
@@ -1995,27 +1995,27 @@ class D0 {
|
|
|
1995
1995
|
* @param datum
|
|
1996
1996
|
* @param options
|
|
1997
1997
|
*/
|
|
1998
|
-
async tidesForecast(M, b, p = 7, O = "today", o = !0, Y = !1,
|
|
1999
|
-
O = O || "today", p = p || 7, b = this.toStdLng(b), this.debug && W0.info("[%s] spot tides forecast params: %j",
|
|
1998
|
+
async tidesForecast(M, b, p = 7, O = "today", o = !0, Y = !1, A = !1, q = "CD", a = {}) {
|
|
1999
|
+
O = O || "today", p = p || 7, b = this.toStdLng(b), this.debug && W0.info("[%s] spot tides forecast params: %j", a.requestId, { lat: M, lng: b, date: O, extremes: o, heights: Y, datums: A, datum: q });
|
|
2000
2000
|
let R = `https://www.worldtides.info/api/v3?lat=${M}&lon=${b}&days=${p}&date=${O}&datum=${q}&key=${this.apikey}&localtime`;
|
|
2001
|
-
o && (R = `${R}&extremes`), Y && (R = `${R}&heights`),
|
|
2002
|
-
const
|
|
2003
|
-
return
|
|
2001
|
+
o && (R = `${R}&extremes`), Y && (R = `${R}&heights`), A && (R = `${R}&datums`);
|
|
2002
|
+
const d = await (await fetch(R)).json();
|
|
2003
|
+
return d.status === 200 ? {
|
|
2004
2004
|
rqt: {
|
|
2005
2005
|
lat: M,
|
|
2006
2006
|
lng: b
|
|
2007
2007
|
},
|
|
2008
2008
|
rsp: {
|
|
2009
|
-
lat:
|
|
2010
|
-
lng:
|
|
2009
|
+
lat: d.responseLat,
|
|
2010
|
+
lng: d.responseLon
|
|
2011
2011
|
},
|
|
2012
|
-
atlas:
|
|
2013
|
-
datum:
|
|
2014
|
-
extremes:
|
|
2015
|
-
heights:
|
|
2016
|
-
stations:
|
|
2017
|
-
datums:
|
|
2018
|
-
} :
|
|
2012
|
+
atlas: d.atlas,
|
|
2013
|
+
datum: d.responseDatum,
|
|
2014
|
+
extremes: d.extremes || [],
|
|
2015
|
+
heights: d.heights || [],
|
|
2016
|
+
stations: d.stations || [],
|
|
2017
|
+
datums: d.datums || []
|
|
2018
|
+
} : d;
|
|
2019
2019
|
}
|
|
2020
2020
|
}
|
|
2021
2021
|
export {
|