@idm-plugin/meteo2 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +151 -137
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ var V0 = Object.defineProperty;
|
|
|
2
2
|
var l0 = (M, z, b) => z in M ? V0(M, z, { enumerable: !0, configurable: !0, writable: !0, value: b }) : M[z] = b;
|
|
3
3
|
var F = (M, z, b) => (l0(M, typeof z != "symbol" ? z + "" : z, b), b);
|
|
4
4
|
import e0 from "@log4js-node/log4js-api";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import L from "moment";
|
|
6
|
+
import x from "got";
|
|
7
7
|
import { fetchWeatherApi as t0 } from "openmeteo";
|
|
8
8
|
import { Meteo2Assist as D } from "@idm-plugin/meteo";
|
|
9
9
|
import Z0 from "xml2js";
|
|
@@ -27,7 +27,7 @@ class j0 {
|
|
|
27
27
|
*/
|
|
28
28
|
static async queryPointMeteo(z, b, p, W = !1, A = "", c = {}) {
|
|
29
29
|
typeof p == "number" && (p = p < 1e12 ? p * 1e3 : p);
|
|
30
|
-
const O =
|
|
30
|
+
const O = L(p), Y = {
|
|
31
31
|
searchParams: {
|
|
32
32
|
lng: z,
|
|
33
33
|
lat: b,
|
|
@@ -36,9 +36,9 @@ class j0 {
|
|
|
36
36
|
source: A == null ? void 0 : A.toLowerCase()
|
|
37
37
|
},
|
|
38
38
|
timeout: 3e4
|
|
39
|
-
}, a =
|
|
39
|
+
}, a = L(), n = a.valueOf();
|
|
40
40
|
O.isBefore(a.subtract(1, "month")) && (G == null || G.warn("[%s] get history meteo on %s: %j", c.requestId, O.format(), Y));
|
|
41
|
-
const X = "https://aod4idm.idmwx.com/api/ocean/point", d = await
|
|
41
|
+
const X = "https://aod4idm.idmwx.com/api/ocean/point", d = await x.get(X, Y).json(), t = L().valueOf();
|
|
42
42
|
if (G == null || G.info("[%s] get meteo(cost: %d ms) from %s with options: %j", c.requestId, t - n, X, Y), (d == null ? void 0 : d.code) === 0)
|
|
43
43
|
return {
|
|
44
44
|
...d.data,
|
|
@@ -62,7 +62,7 @@ class j0 {
|
|
|
62
62
|
*/
|
|
63
63
|
static async queryPointFactor(z, b, p, W = "wind,wave,current,watertemp,visibility", A = "", c = {}) {
|
|
64
64
|
typeof p == "number" && (p = p < 1e12 ? p * 1e3 : p);
|
|
65
|
-
const O =
|
|
65
|
+
const O = L(p), Y = {
|
|
66
66
|
searchParams: {
|
|
67
67
|
lng: z,
|
|
68
68
|
lat: b,
|
|
@@ -71,9 +71,9 @@ class j0 {
|
|
|
71
71
|
source: A == null ? void 0 : A.toLowerCase()
|
|
72
72
|
},
|
|
73
73
|
timeout: 3e4
|
|
74
|
-
}, a =
|
|
74
|
+
}, a = L(), n = a.valueOf();
|
|
75
75
|
O.isBefore(a.subtract(1, "month")) && (G == null || G.warn("[%s] get history factors on %s: %j", c.requestId, O.format(), Y));
|
|
76
|
-
const X = "https://aod4idm.idmwx.com/api/ocean/factor", d = await
|
|
76
|
+
const X = "https://aod4idm.idmwx.com/api/ocean/factor", d = await x.get(X, Y).json(), t = L().valueOf();
|
|
77
77
|
if (G == null || G.info("[%s] get factors(cost: %d ms) from %s with options: %j", c.requestId, t - n, X, Y), (d == null ? void 0 : d.code) === 0)
|
|
78
78
|
return {
|
|
79
79
|
...d.data,
|
|
@@ -88,8 +88,8 @@ class j0 {
|
|
|
88
88
|
static async queryWindyPointForecast(z, b, p, W = {}) {
|
|
89
89
|
const A = "https://api.windy.com/api/point-forecast/v2", c = [];
|
|
90
90
|
try {
|
|
91
|
-
let O =
|
|
92
|
-
const Y = await
|
|
91
|
+
let O = L().valueOf();
|
|
92
|
+
const Y = await x.post(A, {
|
|
93
93
|
headers: {
|
|
94
94
|
"Content-Type": "application/json"
|
|
95
95
|
},
|
|
@@ -118,9 +118,9 @@ class j0 {
|
|
|
118
118
|
levels: ["surface"]
|
|
119
119
|
}
|
|
120
120
|
}).json();
|
|
121
|
-
let a =
|
|
121
|
+
let a = L().valueOf();
|
|
122
122
|
G == null || G.info("[%s] get gfs-factors(cost: %d ms) from %s", W.requestId, a - O, A), O = a;
|
|
123
|
-
const n = await
|
|
123
|
+
const n = await x.post(A, {
|
|
124
124
|
headers: {
|
|
125
125
|
"Content-Type": "application/json"
|
|
126
126
|
},
|
|
@@ -133,11 +133,11 @@ class j0 {
|
|
|
133
133
|
levels: ["surface"]
|
|
134
134
|
}
|
|
135
135
|
}).json();
|
|
136
|
-
a =
|
|
136
|
+
a = L().valueOf(), G == null || G.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", W.requestId, a - O, A);
|
|
137
137
|
for (let d = 0; d < Y.ts.length; d++) {
|
|
138
138
|
const t = this.populateUVFactor(Y["wind_u-surface"][d], Y["wind_v-surface"][d], !1, W);
|
|
139
139
|
t.scale = this.calculateBeaufortWindForceScale(t.speed), c.push({
|
|
140
|
-
utc:
|
|
140
|
+
utc: L(Y.ts[d]).utc().format(),
|
|
141
141
|
temp: Y["temp-surface"][d] ? Math.round((Y["temp-surface"][d] - 273.15) * 100) / 100 : void 0,
|
|
142
142
|
dp_temp: Y["dewpoint-surface"][d] ? Math.round((Y["dewpoint-surface"][d] - 273.15) * 100) / 100 : void 0,
|
|
143
143
|
precip: {
|
|
@@ -162,7 +162,7 @@ class j0 {
|
|
|
162
162
|
for (let d = 0; d < n.ts.length; d++) {
|
|
163
163
|
const t = this.calculateDouglasScale(n["waves_height-surface"][d], n["waves_direction-surface"][d], n["waves_period-surface"][d]), r = this.calculateDouglasScale(n["wwaves_height-surface"][d], n["wwaves_direction-surface"][d], n["wwaves_period-surface"][d]), u = this.calculateDouglasScale(n["swell1_height-surface"][d], n["swell1_direction-surface"][d], n["swell1_period-surface"][d]), V = this.calculateDouglasScale(n["swell2_height-surface"][d], n["swell2_direction-surface"][d], n["swell2_period-surface"][d]);
|
|
164
164
|
X.push({
|
|
165
|
-
utc:
|
|
165
|
+
utc: L(n.ts[d]).utc().format(),
|
|
166
166
|
wave: {
|
|
167
167
|
sig: t,
|
|
168
168
|
wd: r,
|
|
@@ -288,13 +288,13 @@ var U0 = { exports: {} };
|
|
|
288
288
|
//! license : MIT
|
|
289
289
|
//! github.com/moment/moment-timezone
|
|
290
290
|
(function(z, b) {
|
|
291
|
-
M.exports ? M.exports = b(
|
|
291
|
+
M.exports ? M.exports = b(L) : b(z.moment);
|
|
292
292
|
})(E0, function(z) {
|
|
293
293
|
z.version === void 0 && z.default && (z = z.default);
|
|
294
294
|
var b = "0.5.48", p = {}, W = {}, A = {}, c = {}, O = {}, Y;
|
|
295
|
-
(!z || typeof z.version != "string") &&
|
|
295
|
+
(!z || typeof z.version != "string") && J("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
296
296
|
var a = z.version.split("."), n = +a[0], X = +a[1];
|
|
297
|
-
(n < 2 || n === 2 && X < 6) &&
|
|
297
|
+
(n < 2 || n === 2 && X < 6) && J("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + z.version + ". See momentjs.com");
|
|
298
298
|
function d(o) {
|
|
299
299
|
return o > 96 ? o - 87 : o > 64 ? o - 29 : o - 48;
|
|
300
300
|
}
|
|
@@ -331,7 +331,7 @@ var U0 = { exports: {} };
|
|
|
331
331
|
population: q[5] | 0
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function i(o) {
|
|
335
335
|
o && this._set(m(o));
|
|
336
336
|
}
|
|
337
337
|
function B(o, q) {
|
|
@@ -346,7 +346,7 @@ var U0 = { exports: {} };
|
|
|
346
346
|
R = Math.floor((T + s) / 2), q[R] <= o ? T = R : s = R;
|
|
347
347
|
return s;
|
|
348
348
|
}
|
|
349
|
-
|
|
349
|
+
i.prototype = {
|
|
350
350
|
_set: function(o) {
|
|
351
351
|
this.name = o.name, this.abbrs = o.abbrs, this.untils = o.untils, this.offsets = o.offsets, this.population = o.population;
|
|
352
352
|
},
|
|
@@ -372,7 +372,7 @@ var U0 = { exports: {} };
|
|
|
372
372
|
return this.abbrs[this._index(o)];
|
|
373
373
|
},
|
|
374
374
|
offset: function(o) {
|
|
375
|
-
return
|
|
375
|
+
return J("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(o)];
|
|
376
376
|
},
|
|
377
377
|
utcOffset: function(o) {
|
|
378
378
|
return this.offsets[this._index(o)];
|
|
@@ -425,14 +425,14 @@ var U0 = { exports: {} };
|
|
|
425
425
|
e.hasOwnProperty(s) && R.push(c[s]);
|
|
426
426
|
return R;
|
|
427
427
|
}
|
|
428
|
-
function
|
|
428
|
+
function v() {
|
|
429
429
|
try {
|
|
430
430
|
var o = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
431
431
|
if (o && o.length > 3) {
|
|
432
432
|
var q = c[j(o)];
|
|
433
433
|
if (q)
|
|
434
434
|
return q;
|
|
435
|
-
|
|
435
|
+
J("Moment Timezone found " + o + " from the Intl api, but did not have that data loaded.");
|
|
436
436
|
}
|
|
437
437
|
} catch {
|
|
438
438
|
}
|
|
@@ -445,7 +445,7 @@ var U0 = { exports: {} };
|
|
|
445
445
|
return s.sort(P), s.length > 0 ? s[0].zone.name : void 0;
|
|
446
446
|
}
|
|
447
447
|
function q0(o) {
|
|
448
|
-
return (!Y || o) && (Y =
|
|
448
|
+
return (!Y || o) && (Y = v()), Y;
|
|
449
449
|
}
|
|
450
450
|
function j(o) {
|
|
451
451
|
return (o || "").toLowerCase().replace(/\//g, "_");
|
|
@@ -458,7 +458,7 @@ var U0 = { exports: {} };
|
|
|
458
458
|
function g(o, q) {
|
|
459
459
|
o = j(o);
|
|
460
460
|
var e = p[o], R;
|
|
461
|
-
return e instanceof
|
|
461
|
+
return e instanceof i ? e : typeof e == "string" ? (e = new i(e), p[o] = e, e) : W[o] && q !== g && (R = g(W[o], g)) ? (e = p[o] = new i(), e._set(R), e.name = c[o], e) : null;
|
|
462
462
|
}
|
|
463
463
|
function Y0() {
|
|
464
464
|
var o, q = [];
|
|
@@ -502,20 +502,20 @@ var U0 = { exports: {} };
|
|
|
502
502
|
c0(o.zones), O0(o.links), X0(o.countries), I.dataVersion = o.version;
|
|
503
503
|
}
|
|
504
504
|
function W0(o) {
|
|
505
|
-
return W0.didShowError || (W0.didShowError = !0,
|
|
505
|
+
return W0.didShowError || (W0.didShowError = !0, J("moment.tz.zoneExists('" + o + "') has been deprecated in favor of !moment.tz.zone('" + o + "')")), !!g(o);
|
|
506
506
|
}
|
|
507
507
|
function o0(o) {
|
|
508
508
|
var q = o._f === "X" || o._f === "x";
|
|
509
509
|
return !!(o._a && o._tzm === void 0 && !q);
|
|
510
510
|
}
|
|
511
|
-
function
|
|
511
|
+
function J(o) {
|
|
512
512
|
typeof console < "u" && typeof console.error == "function" && console.error(o);
|
|
513
513
|
}
|
|
514
514
|
function I(o) {
|
|
515
515
|
var q = Array.prototype.slice.call(arguments, 0, -1), e = arguments[arguments.length - 1], R = z.utc.apply(null, q), T;
|
|
516
516
|
return !z.isMoment(o) && o0(R) && (T = g(e)) && R.add(T.parse(R), "minutes"), R.tz(e), R;
|
|
517
517
|
}
|
|
518
|
-
I.version = b, I.dataVersion = "", I._zones = p, I._links = W, I._names = c, I._countries = A, I.add = c0, I.link = O0, I.load = H, I.zone = g, I.zoneExists = W0, I.guess = q0, I.names = Y0, I.Zone =
|
|
518
|
+
I.version = b, I.dataVersion = "", I._zones = p, I._links = W, I._names = c, I._countries = A, I.add = c0, I.link = O0, I.load = H, I.zone = g, I.zoneExists = W0, I.guess = q0, I.names = Y0, I.Zone = i, I.unpack = m, I.unpackBase60 = t, I.needsOffset = o0, I.moveInvalidForward = !0, I.moveAmbiguousForward = !1, I.countries = p0, I.zonesForCountry = M0;
|
|
519
519
|
var y = z.fn;
|
|
520
520
|
z.tz = I, z.defaultZone = null, z.updateOffset = function(o, q) {
|
|
521
521
|
var e = z.defaultZone, R;
|
|
@@ -529,7 +529,7 @@ var U0 = { exports: {} };
|
|
|
529
529
|
if (o) {
|
|
530
530
|
if (typeof o != "string")
|
|
531
531
|
throw new Error("Time zone name must be a string, got " + o + " [" + typeof o + "]");
|
|
532
|
-
return this._z = g(o), this._z ? z.updateOffset(this, q) :
|
|
532
|
+
return this._z = g(o), this._z ? z.updateOffset(this, q) : J("Moment Timezone has no data for " + o + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
|
|
533
533
|
}
|
|
534
534
|
if (this._z)
|
|
535
535
|
return this._z.name;
|
|
@@ -544,13 +544,13 @@ var U0 = { exports: {} };
|
|
|
544
544
|
return this._z = null, o.apply(this, arguments);
|
|
545
545
|
};
|
|
546
546
|
}
|
|
547
|
-
function
|
|
547
|
+
function i0(o) {
|
|
548
548
|
return function() {
|
|
549
549
|
return arguments.length > 0 && (this._z = null), o.apply(this, arguments);
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
|
-
y.zoneName = d0(y.zoneName), y.zoneAbbr = d0(y.zoneAbbr), y.utc = a0(y.utc), y.local = a0(y.local), y.utcOffset =
|
|
553
|
-
return (n < 2 || n === 2 && X < 9) &&
|
|
552
|
+
y.zoneName = d0(y.zoneName), y.zoneAbbr = d0(y.zoneAbbr), y.utc = a0(y.utc), y.local = a0(y.local), y.utcOffset = i0(y.utcOffset), z.tz.setDefault = function(o) {
|
|
553
|
+
return (n < 2 || n === 2 && X < 9) && J("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + z.version + "."), z.defaultZone = o ? g(o) : null, z;
|
|
554
554
|
};
|
|
555
555
|
var b0 = z.momentProperties;
|
|
556
556
|
return Object.prototype.toString.call(b0) === "[object Array]" ? (b0.push("_z"), b0.push("_a")) : b0 && (b0._z = null), z;
|
|
@@ -1412,12 +1412,12 @@ const h0 = "2025b", C0 = [
|
|
|
1412
1412
|
};
|
|
1413
1413
|
var y0 = _0;
|
|
1414
1414
|
y0.tz.load(g0);
|
|
1415
|
-
var
|
|
1416
|
-
Object.defineProperty(
|
|
1417
|
-
var
|
|
1415
|
+
var L0 = {};
|
|
1416
|
+
Object.defineProperty(L0, "__esModule", { value: !0 });
|
|
1417
|
+
var k = L0.Variable = void 0, u0;
|
|
1418
1418
|
(function(M) {
|
|
1419
1419
|
M[M.undefined = 0] = "undefined", M[M.apparent_temperature = 1] = "apparent_temperature", M[M.cape = 2] = "cape", M[M.cloud_cover = 3] = "cloud_cover", M[M.cloud_cover_high = 4] = "cloud_cover_high", M[M.cloud_cover_low = 5] = "cloud_cover_low", M[M.cloud_cover_mid = 6] = "cloud_cover_mid", M[M.daylight_duration = 7] = "daylight_duration", M[M.dew_point = 8] = "dew_point", M[M.diffuse_radiation = 9] = "diffuse_radiation", M[M.diffuse_radiation_instant = 10] = "diffuse_radiation_instant", M[M.direct_normal_irradiance = 11] = "direct_normal_irradiance", M[M.direct_normal_irradiance_instant = 12] = "direct_normal_irradiance_instant", M[M.direct_radiation = 13] = "direct_radiation", M[M.direct_radiation_instant = 14] = "direct_radiation_instant", M[M.et0_fao_evapotranspiration = 15] = "et0_fao_evapotranspiration", M[M.evapotranspiration = 16] = "evapotranspiration", M[M.freezing_level_height = 17] = "freezing_level_height", M[M.growing_degree_days = 18] = "growing_degree_days", M[M.is_day = 19] = "is_day", M[M.latent_heat_flux = 20] = "latent_heat_flux", M[M.leaf_wetness_probability = 21] = "leaf_wetness_probability", M[M.lifted_index = 22] = "lifted_index", M[M.lightning_potential = 23] = "lightning_potential", M[M.precipitation = 24] = "precipitation", M[M.precipitation_hours = 25] = "precipitation_hours", M[M.precipitation_probability = 26] = "precipitation_probability", M[M.pressure_msl = 27] = "pressure_msl", M[M.rain = 28] = "rain", M[M.relative_humidity = 29] = "relative_humidity", M[M.runoff = 30] = "runoff", M[M.sensible_heat_flux = 31] = "sensible_heat_flux", M[M.shortwave_radiation = 32] = "shortwave_radiation", M[M.shortwave_radiation_instant = 33] = "shortwave_radiation_instant", M[M.showers = 34] = "showers", M[M.snow_depth = 35] = "snow_depth", M[M.snow_height = 36] = "snow_height", M[M.snowfall = 37] = "snowfall", M[M.snowfall_height = 38] = "snowfall_height", M[M.snowfall_water_equivalent = 39] = "snowfall_water_equivalent", M[M.sunrise = 40] = "sunrise", M[M.sunset = 41] = "sunset", M[M.soil_moisture = 42] = "soil_moisture", M[M.soil_moisture_index = 43] = "soil_moisture_index", M[M.soil_temperature = 44] = "soil_temperature", M[M.surface_pressure = 45] = "surface_pressure", M[M.surface_temperature = 46] = "surface_temperature", M[M.temperature = 47] = "temperature", M[M.terrestrial_radiation = 48] = "terrestrial_radiation", M[M.terrestrial_radiation_instant = 49] = "terrestrial_radiation_instant", M[M.total_column_integrated_water_vapour = 50] = "total_column_integrated_water_vapour", M[M.updraft = 51] = "updraft", M[M.uv_index = 52] = "uv_index", M[M.uv_index_clear_sky = 53] = "uv_index_clear_sky", M[M.vapour_pressure_deficit = 54] = "vapour_pressure_deficit", M[M.visibility = 55] = "visibility", M[M.weather_code = 56] = "weather_code", M[M.wind_direction = 57] = "wind_direction", M[M.wind_gusts = 58] = "wind_gusts", M[M.wind_speed = 59] = "wind_speed", M[M.vertical_velocity = 60] = "vertical_velocity", M[M.geopotential_height = 61] = "geopotential_height", M[M.wet_bulb_temperature = 62] = "wet_bulb_temperature", M[M.river_discharge = 63] = "river_discharge", M[M.wave_height = 64] = "wave_height", M[M.wave_period = 65] = "wave_period", M[M.wave_direction = 66] = "wave_direction", M[M.wind_wave_height = 67] = "wind_wave_height", M[M.wind_wave_period = 68] = "wind_wave_period", M[M.wind_wave_peak_period = 69] = "wind_wave_peak_period", M[M.wind_wave_direction = 70] = "wind_wave_direction", M[M.swell_wave_height = 71] = "swell_wave_height", M[M.swell_wave_period = 72] = "swell_wave_period", M[M.swell_wave_peak_period = 73] = "swell_wave_peak_period", M[M.swell_wave_direction = 74] = "swell_wave_direction", M[M.pm10 = 75] = "pm10", M[M.pm2p5 = 76] = "pm2p5", M[M.dust = 77] = "dust", M[M.aerosol_optical_depth = 78] = "aerosol_optical_depth", M[M.carbon_monoxide = 79] = "carbon_monoxide", M[M.nitrogen_dioxide = 80] = "nitrogen_dioxide", M[M.ammonia = 81] = "ammonia", M[M.ozone = 82] = "ozone", M[M.sulphur_dioxide = 83] = "sulphur_dioxide", M[M.alder_pollen = 84] = "alder_pollen", M[M.birch_pollen = 85] = "birch_pollen", M[M.grass_pollen = 86] = "grass_pollen", M[M.mugwort_pollen = 87] = "mugwort_pollen", M[M.olive_pollen = 88] = "olive_pollen", M[M.ragweed_pollen = 89] = "ragweed_pollen", M[M.european_aqi = 90] = "european_aqi", M[M.european_aqi_pm2p5 = 91] = "european_aqi_pm2p5", M[M.european_aqi_pm10 = 92] = "european_aqi_pm10", M[M.european_aqi_nitrogen_dioxide = 93] = "european_aqi_nitrogen_dioxide", M[M.european_aqi_ozone = 94] = "european_aqi_ozone", M[M.european_aqi_sulphur_dioxide = 95] = "european_aqi_sulphur_dioxide", M[M.us_aqi = 96] = "us_aqi", M[M.us_aqi_pm2p5 = 97] = "us_aqi_pm2p5", M[M.us_aqi_pm10 = 98] = "us_aqi_pm10", M[M.us_aqi_nitrogen_dioxide = 99] = "us_aqi_nitrogen_dioxide", M[M.us_aqi_ozone = 100] = "us_aqi_ozone", M[M.us_aqi_sulphur_dioxide = 101] = "us_aqi_sulphur_dioxide", M[M.us_aqi_carbon_monoxide = 102] = "us_aqi_carbon_monoxide", M[M.sunshine_duration = 103] = "sunshine_duration", M[M.convective_inhibition = 104] = "convective_inhibition", M[M.shortwave_radiation_clear_sky = 105] = "shortwave_radiation_clear_sky", M[M.global_tilted_irradiance = 106] = "global_tilted_irradiance", M[M.global_tilted_irradiance_instant = 107] = "global_tilted_irradiance_instant", M[M.ocean_current_velocity = 108] = "ocean_current_velocity", M[M.ocean_current_direction = 109] = "ocean_current_direction", M[M.cloud_base = 110] = "cloud_base", M[M.cloud_top = 111] = "cloud_top", M[M.mass_density = 112] = "mass_density", M[M.boundary_layer_height = 113] = "boundary_layer_height", M[M.formaldehyde = 114] = "formaldehyde", M[M.glyoxal = 115] = "glyoxal", M[M.non_methane_volatile_organic_compounds = 116] = "non_methane_volatile_organic_compounds", M[M.pm10_wildfires = 117] = "pm10_wildfires", M[M.peroxyacyl_nitrates = 118] = "peroxyacyl_nitrates", M[M.secondary_inorganic_aerosol = 119] = "secondary_inorganic_aerosol", M[M.residential_elementary_carbon = 120] = "residential_elementary_carbon", M[M.total_elementary_carbon = 121] = "total_elementary_carbon", M[M.pm2_5_total_organic_matter = 122] = "pm2_5_total_organic_matter", M[M.sea_salt_aerosol = 123] = "sea_salt_aerosol", M[M.nitrogen_monoxide = 124] = "nitrogen_monoxide", M[M.thunderstorm_probability = 125] = "thunderstorm_probability", M[M.rain_probability = 126] = "rain_probability", M[M.freezing_rain_probability = 127] = "freezing_rain_probability", M[M.ice_pellets_probability = 128] = "ice_pellets_probability", M[M.snowfall_probability = 129] = "snowfall_probability", M[M.carbon_dioxide = 130] = "carbon_dioxide", M[M.methane = 131] = "methane", M[M.sea_level_height_msl = 132] = "sea_level_height_msl", M[M.sea_surface_temperature = 133] = "sea_surface_temperature", M[M.invert_barometer_height = 134] = "invert_barometer_height", M[M.hail = 135] = "hail", M[M.albedo = 136] = "albedo", M[M.precipitation_type = 137] = "precipitation_type", M[M.convective_cloud_base = 138] = "convective_cloud_base", M[M.convective_cloud_top = 139] = "convective_cloud_top", M[M.snow_depth_water_equivalent = 140] = "snow_depth_water_equivalent", M[M.secondary_swell_wave_height = 141] = "secondary_swell_wave_height", M[M.secondary_swell_wave_period = 142] = "secondary_swell_wave_period", M[M.secondary_swell_wave_peak_period = 143] = "secondary_swell_wave_peak_period", M[M.secondary_swell_wave_direction = 144] = "secondary_swell_wave_direction", M[M.tertiary_swell_wave_height = 145] = "tertiary_swell_wave_height", M[M.tertiary_swell_wave_period = 146] = "tertiary_swell_wave_period", M[M.tertiary_swell_wave_peak_period = 147] = "tertiary_swell_wave_peak_period", M[M.tertiary_swell_wave_direction = 148] = "tertiary_swell_wave_direction", M[M.wind_u_component = 149] = "wind_u_component", M[M.wind_v_component = 150] = "wind_v_component", M[M.temperature_max24h = 151] = "temperature_max24h", M[M.temperature_min24h = 152] = "temperature_min24h", M[M.temperature_mean24h = 153] = "temperature_mean24h", M[M.snow_density = 154] = "snow_density", M[M.longwave_radiation = 155] = "longwave_radiation", M[M.sea_ice_cover = 156] = "sea_ice_cover", M[M.k_index = 157] = "k_index", M[M.roughness_length = 158] = "roughness_length", M[M.potential_evapotranspiration = 159] = "potential_evapotranspiration", M[M.wave_peak_period = 160] = "wave_peak_period", M[M.temperature_max6h = 161] = "temperature_max6h", M[M.temperature_min6h = 162] = "temperature_min6h", M[M.lightning_density = 163] = "lightning_density", M[M.sea_ice_thickness = 164] = "sea_ice_thickness", M[M.shortwave_radiation_clear_sky_instant = 165] = "shortwave_radiation_clear_sky_instant", M[M.sea_water_salinity = 166] = "sea_water_salinity";
|
|
1420
|
-
})(u0 || (
|
|
1420
|
+
})(u0 || (k = L0.Variable = u0 = {}));
|
|
1421
1421
|
var T0 = {};
|
|
1422
1422
|
Object.defineProperty(T0, "__esModule", { value: !0 });
|
|
1423
1423
|
var z0 = T0.Aggregation = void 0, N0;
|
|
@@ -1477,7 +1477,7 @@ class Q {
|
|
|
1477
1477
|
}
|
|
1478
1478
|
});
|
|
1479
1479
|
F(this, "METEO2_UPDATE", {
|
|
1480
|
-
etime:
|
|
1480
|
+
etime: L().unix(),
|
|
1481
1481
|
version: 0
|
|
1482
1482
|
});
|
|
1483
1483
|
this.apikey = z || "smE3JnDLHy3TizVv", this.debug = b;
|
|
@@ -1520,7 +1520,7 @@ class Q {
|
|
|
1520
1520
|
* @param options
|
|
1521
1521
|
*/
|
|
1522
1522
|
async weatherForecast(z, b, p, W, A, c = {}) {
|
|
1523
|
-
const { st: O, et: Y, interval: a } = await this.checkTimeInterval(z.start_date, z.end_date, !p && !W && !A, c), n =
|
|
1523
|
+
const { st: O, et: Y, interval: a } = await this.checkTimeInterval(z.start_date, z.end_date, !p && !W && !A, c), n = L();
|
|
1524
1524
|
try {
|
|
1525
1525
|
if (p) {
|
|
1526
1526
|
const X = this.SEASONAL.OM_URL;
|
|
@@ -1564,11 +1564,11 @@ class Q {
|
|
|
1564
1564
|
*/
|
|
1565
1565
|
async tryToFetchWeatherApi(z, b, p, W = 0, A = {}) {
|
|
1566
1566
|
try {
|
|
1567
|
-
const c =
|
|
1567
|
+
const c = L();
|
|
1568
1568
|
this.debug && _.info("[%s] fetch weather via %s with %j", A.requestId, z, b);
|
|
1569
1569
|
const O = await t0(z, b), Y = p ? await p(O, b, A) : await this.parseWeatherData(O, b, W, A);
|
|
1570
1570
|
delete b.apikey;
|
|
1571
|
-
const a =
|
|
1571
|
+
const a = L();
|
|
1572
1572
|
return this.debug && _.info("[%s] fetch weather api (%s) cost: %d ms", A.requestId, b.url, a.diff(c, "ms")), this.mergeWeatherData(Y);
|
|
1573
1573
|
} catch (c) {
|
|
1574
1574
|
throw _.warn("[%s] weather forecast failed: %s, with %j", A.requestId, c, b), c;
|
|
@@ -1590,8 +1590,8 @@ class Q {
|
|
|
1590
1590
|
* @param options
|
|
1591
1591
|
*/
|
|
1592
1592
|
async marineForecast(z, b = {}) {
|
|
1593
|
-
var u, V, m,
|
|
1594
|
-
const { st: p, et: W, interval: A } = await this.checkTimeInterval(z.start_date, z.end_date, !0, b), c =
|
|
1593
|
+
var u, V, m, i, B, E, N, Z;
|
|
1594
|
+
const { st: p, et: W, interval: A } = await this.checkTimeInterval(z.start_date, z.end_date, !0, b), c = L(), O = [];
|
|
1595
1595
|
let Y = 0;
|
|
1596
1596
|
if (!z.start_date && !z.end_date) {
|
|
1597
1597
|
const f = this.pickForecastUrl(!0, b.selfHosted, !1, b), U = await this.tryToFetchMarineApi(f, z, b);
|
|
@@ -1611,13 +1611,27 @@ class Q {
|
|
|
1611
1611
|
O.push(...P);
|
|
1612
1612
|
}
|
|
1613
1613
|
} catch (U) {
|
|
1614
|
-
const { start_date: P, end_date: w } = await this.matchDateRange(U == null ? void 0 : U.message, A, b), K = this.pickForecastUrl(!0, !0, !1, b)
|
|
1615
|
-
|
|
1614
|
+
const { start_date: P, end_date: w } = await this.matchDateRange(U == null ? void 0 : U.message, A, b), K = this.pickForecastUrl(!0, !0, !1, b);
|
|
1615
|
+
try {
|
|
1616
|
+
const v = await this.tryToFetchMarineApi(
|
|
1617
|
+
K,
|
|
1618
|
+
{
|
|
1619
|
+
...z,
|
|
1620
|
+
start_date: P,
|
|
1621
|
+
end_date: w,
|
|
1622
|
+
models: [f]
|
|
1623
|
+
},
|
|
1624
|
+
b
|
|
1625
|
+
);
|
|
1626
|
+
O.push(...v);
|
|
1627
|
+
} catch (v) {
|
|
1628
|
+
this.debug && _.warn("[%s] marine forecast for model %s failed: %s, just ignore", b.requestId, f, v);
|
|
1629
|
+
}
|
|
1616
1630
|
}
|
|
1617
1631
|
const a = await this.parseWeatherData(O, z, Y, b);
|
|
1618
1632
|
delete z.apikey;
|
|
1619
1633
|
const n = await this.mergeMarineData(a, p), X = n.find((f) => f.model === "ncep_gfswave016"), d = n.find((f) => f.model === "ncep_gfswave025"), t = n.find((f) => f.model === "meteofrance_wave"), r = n.find((f) => f.model === "best_match");
|
|
1620
|
-
return (V = (u = r == null ? void 0 : r.hourly) == null ? void 0 : u.wave_height) != null && V.every((f) => f !== null) ? [r] : (
|
|
1634
|
+
return (V = (u = r == null ? void 0 : r.hourly) == null ? void 0 : u.wave_height) != null && V.every((f) => f !== null) ? [r] : (i = (m = t == null ? void 0 : t.hourly) == null ? void 0 : m.wave_height) != null && i.every((f) => f !== null) ? [t] : (E = (B = X == null ? void 0 : X.hourly) == null ? void 0 : B.wave_height) != null && E.every((f) => f !== null) ? [X] : (Z = (N = d == null ? void 0 : d.hourly) == null ? void 0 : N.wave_height) != null && Z.every((f) => f !== null) ? [d] : n != null && n.length ? [n[0]] : [];
|
|
1621
1635
|
}
|
|
1622
1636
|
/**
|
|
1623
1637
|
* 尝试调用海洋接口
|
|
@@ -1628,9 +1642,9 @@ class Q {
|
|
|
1628
1642
|
*/
|
|
1629
1643
|
async tryToFetchMarineApi(z, b, p = {}) {
|
|
1630
1644
|
try {
|
|
1631
|
-
const W =
|
|
1645
|
+
const W = L();
|
|
1632
1646
|
this.debug && _.info("[%s] fetch marine via %s with %j", p.requestId, z, b);
|
|
1633
|
-
const A = await t0(z, b), c =
|
|
1647
|
+
const A = await t0(z, b), c = L();
|
|
1634
1648
|
return this.debug && _.info("[%s] fetch weather api (%s) cost: %d ms", p.requestId, b.url, c.diff(W, "ms")), A;
|
|
1635
1649
|
} catch (W) {
|
|
1636
1650
|
throw _.warn("[%s] marine forecast failed: %s, with %j", p.requestId, W, b), W;
|
|
@@ -1646,7 +1660,7 @@ class Q {
|
|
|
1646
1660
|
*/
|
|
1647
1661
|
async checkTimeInterval(z, b, p, W = {}) {
|
|
1648
1662
|
let A, c, O = 1;
|
|
1649
|
-
return p ? (z && b && (A =
|
|
1663
|
+
return p ? (z && b && (A = L.utc(z), c = L.utc(b), c.diff(A, "days") > 90 && (c = A.clone().add(90, "d")), O = c.diff(A, "day")), this.debug && _.info("[%s] check time interval: %s to %s, with interval: %d days", W.requestId, A == null ? void 0 : A.format(), c == null ? void 0 : c.format(), O)) : (A = L.utc(z), c = L.utc(b), O = c.diff(A, "day")), { st: A, et: c, interval: O };
|
|
1650
1664
|
}
|
|
1651
1665
|
/**
|
|
1652
1666
|
* 从消息中提取时间区间, 并调整为合理范围
|
|
@@ -1658,10 +1672,10 @@ class Q {
|
|
|
1658
1672
|
async matchDateRange(z, b = 1, p = {}) {
|
|
1659
1673
|
const W = z == null ? void 0 : z.match(/from (\d{4}-\d{2}-\d{2}) to (\d{4}-\d{2}-\d{2})/);
|
|
1660
1674
|
if (W) {
|
|
1661
|
-
const A =
|
|
1675
|
+
const A = L.utc(W[2]), c = W[2], O = A.subtract(b || 1, "day").format("YYYY-MM-DD");
|
|
1662
1676
|
return _.info("[%s] extract date range from message: %s to %s", p.requestId, O, c), { start_date: O, end_date: c };
|
|
1663
1677
|
} else {
|
|
1664
|
-
const A =
|
|
1678
|
+
const A = L.utc().add(7, "day"), c = A.format("YYYY-MM-DD"), O = A.clone().subtract(b, "day").format("YYYY-MM-DD");
|
|
1665
1679
|
return _.info("[%s] extract date range with interval (%d): %s to %s", p.requestId, b, O, c), { start_date: O, end_date: c };
|
|
1666
1680
|
}
|
|
1667
1681
|
}
|
|
@@ -1677,46 +1691,46 @@ class Q {
|
|
|
1677
1691
|
var O, Y, a, n, X, d, t;
|
|
1678
1692
|
const A = [], c = Math.pow(10, W.precision || 6);
|
|
1679
1693
|
for (let r = 0; r < z.length; r++) {
|
|
1680
|
-
const u = z[r], V = u.utcOffsetSeconds(), m = u.timezone(),
|
|
1681
|
-
if (N.timezone = m || void 0, N.offset = Q.prettyTimezoneOffset(V), N.model = b.models instanceof Array ? (O = b.models) == null ? void 0 : O[r] : b.models || "best_match",
|
|
1682
|
-
const Z =
|
|
1694
|
+
const u = z[r], V = u.utcOffsetSeconds(), m = u.timezone(), i = u.current(), B = u.hourly(), E = u.daily(), N = {};
|
|
1695
|
+
if (N.timezone = m || void 0, N.offset = Q.prettyTimezoneOffset(V), N.model = b.models instanceof Array ? (O = b.models) == null ? void 0 : O[r] : b.models || "best_match", i) {
|
|
1696
|
+
const Z = L();
|
|
1683
1697
|
N.current = {
|
|
1684
|
-
time:
|
|
1698
|
+
time: L.unix(Number(i.time())).utc().add(p, "year").format()
|
|
1685
1699
|
};
|
|
1686
|
-
for (let U = 0; U <
|
|
1687
|
-
const P =
|
|
1700
|
+
for (let U = 0; U < i.variablesLength(); U++) {
|
|
1701
|
+
const P = i.variables(U).value();
|
|
1688
1702
|
N.current[b.current[U]] = isNaN(P) ? null : Math.round(P * c) / c;
|
|
1689
1703
|
}
|
|
1690
|
-
const f =
|
|
1704
|
+
const f = L();
|
|
1691
1705
|
this.debug && _.debug("[%s] fetch current variables cost: %d ms", W.requestId, f.diff(Z, "ms"));
|
|
1692
1706
|
}
|
|
1693
1707
|
if (B) {
|
|
1694
|
-
const Z =
|
|
1708
|
+
const Z = L(), f = L.unix(Number(B.time())).add(p, "year");
|
|
1695
1709
|
N.hourly = {
|
|
1696
1710
|
date: f.utc().format(),
|
|
1697
1711
|
time: Q.range(Number(B.time()), Number(B.timeEnd()), B.interval()).map(
|
|
1698
|
-
(P) =>
|
|
1712
|
+
(P) => L.unix(P).add(p, "year").diff(f, "h")
|
|
1699
1713
|
)
|
|
1700
1714
|
};
|
|
1701
1715
|
for (let P = 0; P < B.variablesLength(); P++) {
|
|
1702
1716
|
const w = (n = (a = (Y = B.variables(P).valuesArray()) == null ? void 0 : Y.toString()) == null ? void 0 : a.split(",")) == null ? void 0 : n.map((K) => isNaN(K) ? null : Math.round(Number(K) * c) / c);
|
|
1703
1717
|
N.hourly[b.hourly[P]] = w;
|
|
1704
1718
|
}
|
|
1705
|
-
const U =
|
|
1719
|
+
const U = L();
|
|
1706
1720
|
this.debug && _.debug("[%s] fetch hourly variables cost: %d ms", W.requestId, U.diff(Z, "ms"));
|
|
1707
1721
|
}
|
|
1708
1722
|
if (E) {
|
|
1709
|
-
const Z =
|
|
1723
|
+
const Z = L();
|
|
1710
1724
|
N.daily = {
|
|
1711
1725
|
time: Q.range(Number(E.time()), Number(E.timeEnd()), E.interval()).map(
|
|
1712
|
-
(U) =>
|
|
1726
|
+
(U) => L.unix(U).add(p, "year").utc().format()
|
|
1713
1727
|
)
|
|
1714
1728
|
};
|
|
1715
1729
|
for (let U = 0; U < E.variablesLength(); U += W.memberLength ?? 1) {
|
|
1716
1730
|
const P = (t = (d = (X = E.variables(U).valuesArray()) == null ? void 0 : X.toString()) == null ? void 0 : d.split(",")) == null ? void 0 : t.map((w) => isNaN(w) ? null : Math.round(Number(w) * c) / c);
|
|
1717
1731
|
N.daily[b.daily[U / (W.memberLength ?? 1)]] = P;
|
|
1718
1732
|
}
|
|
1719
|
-
const f =
|
|
1733
|
+
const f = L();
|
|
1720
1734
|
this.debug && _.debug("[%s] fetch daily variables cost: %d ms", W.requestId, f.diff(Z, "ms"));
|
|
1721
1735
|
}
|
|
1722
1736
|
A.push(N);
|
|
@@ -1730,37 +1744,37 @@ class Q {
|
|
|
1730
1744
|
* @private
|
|
1731
1745
|
*/
|
|
1732
1746
|
async parseSeasonalDailyVariable(z, b, p = {}) {
|
|
1733
|
-
var c, O, Y, a, n, X, d, t, r, u, V, m,
|
|
1747
|
+
var c, O, Y, a, n, X, d, t, r, u, V, m, i, B, E, N, Z, f, U, P, w, K, v, q0, j, c0, g, Y0;
|
|
1734
1748
|
const W = [], A = Math.pow(10, p.precision || 6);
|
|
1735
1749
|
for (let p0 = 0; p0 < z.length; p0++) {
|
|
1736
1750
|
const O0 = z[p0], X0 = O0.utcOffsetSeconds(), R0 = O0.timezone(), M0 = O0.daily(), H = Array.from({ length: M0.variablesLength() }, (q, e) => M0.variables(e)), W0 = H.filter(
|
|
1737
|
-
(q) => (q == null ? void 0 : q.variable()) ===
|
|
1751
|
+
(q) => (q == null ? void 0 : q.variable()) === k.temperature && (q == null ? void 0 : q.altitude()) === 2 && (q == null ? void 0 : q.aggregation()) === z0.maximum
|
|
1738
1752
|
), o0 = H.filter(
|
|
1739
|
-
(q) => (q == null ? void 0 : q.variable()) ===
|
|
1740
|
-
),
|
|
1741
|
-
(q) => (q == null ? void 0 : q.variable()) ===
|
|
1742
|
-
), I = H.filter((q) => (q == null ? void 0 : q.variable()) ===
|
|
1743
|
-
(q) => (q == null ? void 0 : q.variable()) ===
|
|
1753
|
+
(q) => (q == null ? void 0 : q.variable()) === k.temperature && (q == null ? void 0 : q.altitude()) === 2 && (q == null ? void 0 : q.aggregation()) === z0.minimum
|
|
1754
|
+
), J = H.filter(
|
|
1755
|
+
(q) => (q == null ? void 0 : q.variable()) === k.temperature && (q == null ? void 0 : q.altitude()) === 2 && (q == null ? void 0 : q.aggregation()) === z0.mean
|
|
1756
|
+
), I = H.filter((q) => (q == null ? void 0 : q.variable()) === k.precipitation), y = H.filter((q) => (q == null ? void 0 : q.variable()) === k.weather_code), d0 = H.filter(
|
|
1757
|
+
(q) => (q == null ? void 0 : q.variable()) === k.wind_speed && (q == null ? void 0 : q.altitude()) === 10 && (q == null ? void 0 : q.aggregation()) === z0.mean
|
|
1744
1758
|
), a0 = H.filter(
|
|
1745
|
-
(q) => (q == null ? void 0 : q.variable()) ===
|
|
1746
|
-
),
|
|
1747
|
-
(q) => (q == null ? void 0 : q.variable()) ===
|
|
1759
|
+
(q) => (q == null ? void 0 : q.variable()) === k.wind_speed && (q == null ? void 0 : q.altitude()) === 10 && (q == null ? void 0 : q.aggregation()) === z0.maximum
|
|
1760
|
+
), i0 = H.filter(
|
|
1761
|
+
(q) => (q == null ? void 0 : q.variable()) === k.wind_gusts && (q == null ? void 0 : q.altitude()) === 10 && (q == null ? void 0 : q.aggregation()) === z0.maximum
|
|
1748
1762
|
), b0 = H.filter(
|
|
1749
|
-
(q) => (q == null ? void 0 : q.variable()) ===
|
|
1763
|
+
(q) => (q == null ? void 0 : q.variable()) === k.wind_direction && (q == null ? void 0 : q.altitude()) === 10 && (q == null ? void 0 : q.aggregation()) === z0.dominant
|
|
1750
1764
|
), o = {};
|
|
1751
1765
|
if (o.timezone = R0 || void 0, o.offset = Q.prettyTimezoneOffset(X0), o.model = b.models instanceof Array ? (c = b.models) == null ? void 0 : c[p0] : b.models || "best_match", M0) {
|
|
1752
|
-
const q =
|
|
1766
|
+
const q = L();
|
|
1753
1767
|
o.daily = {
|
|
1754
|
-
time: Q.range(Number(M0.time()), Number(M0.timeEnd()), M0.interval()).map((R) =>
|
|
1768
|
+
time: Q.range(Number(M0.time()), Number(M0.timeEnd()), M0.interval()).map((R) => L.unix(R).utc().format())
|
|
1755
1769
|
};
|
|
1756
1770
|
for (const R of W0)
|
|
1757
1771
|
o.daily.temperature_2m_max = (a = (Y = (O = R.valuesArray()) == null ? void 0 : O.toString()) == null ? void 0 : Y.split(",")) == null ? void 0 : a.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1758
1772
|
for (const R of o0)
|
|
1759
1773
|
o.daily.temperature_2m_min = (d = (X = (n = R.valuesArray()) == null ? void 0 : n.toString()) == null ? void 0 : X.split(",")) == null ? void 0 : d.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1760
|
-
for (const R of
|
|
1774
|
+
for (const R of J)
|
|
1761
1775
|
o.daily.temperature_2m_mean = (u = (r = (t = R.valuesArray()) == null ? void 0 : t.toString()) == null ? void 0 : r.split(",")) == null ? void 0 : u.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1762
1776
|
for (const R of I)
|
|
1763
|
-
o.daily.precipitation_sum = (
|
|
1777
|
+
o.daily.precipitation_sum = (i = (m = (V = R.valuesArray()) == null ? void 0 : V.toString()) == null ? void 0 : m.split(",")) == null ? void 0 : i.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1764
1778
|
for (const R of y)
|
|
1765
1779
|
o.daily.weather_code = (N = (E = (B = R.valuesArray()) == null ? void 0 : B.toString()) == null ? void 0 : E.split(",")) == null ? void 0 : N.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1766
1780
|
for (const R of b0)
|
|
@@ -1768,10 +1782,10 @@ class Q {
|
|
|
1768
1782
|
for (const R of d0)
|
|
1769
1783
|
o.daily.wind_speed_10m_mean = (K = (w = (P = R.valuesArray()) == null ? void 0 : P.toString()) == null ? void 0 : w.split(",")) == null ? void 0 : K.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1770
1784
|
for (const R of a0)
|
|
1771
|
-
o.daily.wind_speed_10m_max = (j = (q0 = (
|
|
1772
|
-
for (const R of
|
|
1785
|
+
o.daily.wind_speed_10m_max = (j = (q0 = (v = R.valuesArray()) == null ? void 0 : v.toString()) == null ? void 0 : q0.split(",")) == null ? void 0 : j.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1786
|
+
for (const R of i0)
|
|
1773
1787
|
o.daily.wind_gusts_10m_max = (Y0 = (g = (c0 = R.valuesArray()) == null ? void 0 : c0.toString()) == null ? void 0 : g.split(",")) == null ? void 0 : Y0.map((T) => isNaN(T) ? null : Math.round(Number(T) * A) / A);
|
|
1774
|
-
const e =
|
|
1788
|
+
const e = L();
|
|
1775
1789
|
_.debug("[%s] fetch daily variables cost: %d ms", p.requestId, e.diff(q, "ms"));
|
|
1776
1790
|
}
|
|
1777
1791
|
W.push(o);
|
|
@@ -1790,7 +1804,7 @@ class Q {
|
|
|
1790
1804
|
for (let c = z[p][W][A].length; c < b[p][W][A].length; c++)
|
|
1791
1805
|
z[p][W][A].push(b[p][W][A][c]);
|
|
1792
1806
|
} else {
|
|
1793
|
-
const c =
|
|
1807
|
+
const c = L(b[p][W].date), O = L(z[p][W].date);
|
|
1794
1808
|
for (let Y = 0; Y < b[p][W][A].length; Y++) {
|
|
1795
1809
|
const a = c.clone().add(Y, "h").diff(O, "h");
|
|
1796
1810
|
a < z[p][W][A].length ? z[p][W][A][a] === null && (z[p][W][A][a] = b[p][W][A][Y]) : A === "time" ? z[p][W][A].push(a) : z[p][W][A].push(b[p][W][A][Y]);
|
|
@@ -1825,30 +1839,30 @@ class Q {
|
|
|
1825
1839
|
async mergeMarineData(z, b) {
|
|
1826
1840
|
var Y, a, n, X, d, t, r, u, V, m;
|
|
1827
1841
|
if (b && (z == null ? void 0 : z.length) > 0) {
|
|
1828
|
-
let
|
|
1842
|
+
let i = z[0], B = Math.abs((a = L((Y = z[0].hourly) == null ? void 0 : Y.date)) == null ? void 0 : a.diff(b));
|
|
1829
1843
|
for (const N of z) {
|
|
1830
|
-
const Z = Math.abs((X =
|
|
1831
|
-
Z < B && (B = Z,
|
|
1844
|
+
const Z = Math.abs((X = L((n = N.hourly) == null ? void 0 : n.date)) == null ? void 0 : X.diff(b));
|
|
1845
|
+
Z < B && (B = Z, i = N);
|
|
1832
1846
|
}
|
|
1833
|
-
const E = (d =
|
|
1847
|
+
const E = (d = i == null ? void 0 : i.hourly) == null ? void 0 : d.date;
|
|
1834
1848
|
E && z.forEach((N) => {
|
|
1835
1849
|
N.hourly.date = E;
|
|
1836
1850
|
});
|
|
1837
1851
|
} else {
|
|
1838
1852
|
z.sort((B, E) => {
|
|
1839
1853
|
var N, Z, f, U;
|
|
1840
|
-
return ((Z =
|
|
1854
|
+
return ((Z = L((N = E.hourly) == null ? void 0 : N.date)) == null ? void 0 : Z.valueOf()) - ((U = L((f = B.hourly) == null ? void 0 : f.date)) == null ? void 0 : U.valueOf());
|
|
1841
1855
|
});
|
|
1842
|
-
const
|
|
1843
|
-
|
|
1844
|
-
B.hourly.date =
|
|
1856
|
+
const i = (t = z == null ? void 0 : z.at(0).hourly) == null ? void 0 : t.date;
|
|
1857
|
+
i && z.forEach((B) => {
|
|
1858
|
+
B.hourly.date = i;
|
|
1845
1859
|
});
|
|
1846
1860
|
}
|
|
1847
|
-
const p = [], W = z.find((
|
|
1861
|
+
const p = [], W = z.find((i) => i.model === "best_match");
|
|
1848
1862
|
W && p.push(W);
|
|
1849
|
-
const A = z.find((
|
|
1850
|
-
for (const
|
|
1851
|
-
["best_match", "meteofrance_currents"].includes(
|
|
1863
|
+
const A = z.find((i) => i.model === "meteofrance_currents"), c = z.find((i) => i.model === "ecmwf_wam025"), O = z.find((i) => i.model === "meteofrance_wave");
|
|
1864
|
+
for (const i of z)
|
|
1865
|
+
["best_match", "meteofrance_currents"].includes(i.model) || (i.hourly.ocean_current_velocity = (r = A == null ? void 0 : A.hourly) == null ? void 0 : r.ocean_current_velocity, i.hourly.ocean_current_direction = (u = A == null ? void 0 : A.hourly) == null ? void 0 : u.ocean_current_direction, i.hourly.sea_level_height_msl = (V = A == null ? void 0 : A.hourly) == null ? void 0 : V.sea_level_height_msl, i.hourly.sea_surface_temperature = (m = A == null ? void 0 : A.hourly) == null ? void 0 : m.sea_surface_temperature, p.push(i)), i.model === "meteofrance_wave" && c && (i.hourly.time = c.hourly.time, i.hourly.wave_height = c.hourly.wave_height, i.hourly.wave_direction = c.hourly.wave_direction, i.hourly.wave_period = c.hourly.wave_period, i.daily && c.daily && (i.daily.time = c.daily.time, i.daily.wave_height_max = c.daily.wave_height_max, i.daily.wave_direction_dominant = c.daily.wave_direction_dominant, i.daily.wave_period_max = c.daily.wave_period_max)), i.model === "ecmwf_wam025" && O && (i.hourly.swell_wave_height = O.hourly.swell_wave_height, i.hourly.swell_wave_direction = O.hourly.swell_wave_direction, i.hourly.swell_wave_period = O.hourly.swell_wave_period, i.hourly.wind_wave_height = O.hourly.wind_wave_height, i.hourly.wind_wave_direction = O.hourly.wind_wave_direction, i.hourly.wind_wave_period = O.hourly.wind_wave_period, i.daily && O.daily && (i.daily.swell_wave_height_max = O.daily.swell_wave_height_max, i.daily.swell_wave_period_max = O.daily.swell_wave_period_max, i.daily.swell_wave_direction_dominant = O.daily.swell_wave_direction_dominant, i.daily.wind_wave_height_max = O.daily.wind_wave_height_max, i.daily.wind_wave_direction_dominant = O.daily.wind_wave_direction_dominant, i.daily.wind_wave_period_max = O.daily.wind_wave_period_max));
|
|
1852
1866
|
return p;
|
|
1853
1867
|
}
|
|
1854
1868
|
/**
|
|
@@ -1909,7 +1923,7 @@ class Q {
|
|
|
1909
1923
|
*/
|
|
1910
1924
|
async prepare(z, b, p = {}) {
|
|
1911
1925
|
if (z) {
|
|
1912
|
-
const W =
|
|
1926
|
+
const W = L.utc(z);
|
|
1913
1927
|
b.start_date = W.clone().subtract(p.pastDays || 0, "day").utc().format("YYYY-MM-DD"), b.end_date = W.clone().add(p.forecastDays ?? 1, "day").utc().format("YYYY-MM-DD"), b.fake = !1;
|
|
1914
1928
|
} else
|
|
1915
1929
|
b.forecast_days = p.forecastDays, b.past_days = p.pastDays, b.fake = !1;
|
|
@@ -1921,7 +1935,7 @@ class Q {
|
|
|
1921
1935
|
return Math.round(z * p) / p;
|
|
1922
1936
|
}
|
|
1923
1937
|
timezoneOffset(z, b) {
|
|
1924
|
-
const p = G0(z, b), W =
|
|
1938
|
+
const p = G0(z, b), W = L().tz(p).utcOffset();
|
|
1925
1939
|
return Math.round(W / 60 * 10) / 10;
|
|
1926
1940
|
}
|
|
1927
1941
|
/**
|
|
@@ -1967,7 +1981,7 @@ class Q {
|
|
|
1967
1981
|
selfHosted: !0,
|
|
1968
1982
|
maxDays: 14
|
|
1969
1983
|
}) {
|
|
1970
|
-
var r, u, V, m,
|
|
1984
|
+
var r, u, V, m, i, B, E, N;
|
|
1971
1985
|
b = Q.toStdLng(b), this.debug && _.info("[%s] spot forecast params: %j", O.requestId, { lat: z, lng: b, datetime: p, simplify: W, withDaily: A, withHourly: c, options: O });
|
|
1972
1986
|
const Y = {
|
|
1973
1987
|
apikey: this.apikey,
|
|
@@ -1980,7 +1994,7 @@ class Q {
|
|
|
1980
1994
|
};
|
|
1981
1995
|
let a;
|
|
1982
1996
|
const n = this.timezoneOffset(z, b);
|
|
1983
|
-
p && (a =
|
|
1997
|
+
p && (a = L.utc(p).utcOffset(n), a.subtract(n > 0 ? n : -n, "h")), A && (Y.daily = ((r = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : r.split(",")) || []), a || (O.forecastDays = O.forecastDays || 1, O.pastDays = 0, c = !0), c && (Y.hourly = ((u = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : u.split(",")) || []), O.maxDays = O.maxDays || 14, O.pastDays = O.pastDays || 0, O.pastDays = O.pastDays > 7 ? 7 : O.pastDays < 0 ? 0 : O.pastDays, O.forecastDays = O.forecastDays ?? 1, O.forecastDays = O.forecastDays > O.maxDays ? O.maxDays : O.forecastDays < 0 ? 1 : O.forecastDays, await this.prepare((V = a == null ? void 0 : a.utc()) == null ? void 0 : V.format(), Y, O);
|
|
1984
1998
|
const X = await this.weatherForecast(Y, void 0, !1, !1, !1, O), d = {
|
|
1985
1999
|
apikey: this.apikey,
|
|
1986
2000
|
latitude: z,
|
|
@@ -1992,7 +2006,7 @@ class Q {
|
|
|
1992
2006
|
};
|
|
1993
2007
|
A && (d.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), a || (O.forecastDays = O.forecastDays || 1, c = !0), c && (d.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), await this.prepare((m = a == null ? void 0 : a.utc()) == null ? void 0 : m.format(), d, O);
|
|
1994
2008
|
let t = await this.marineForecast(d, O);
|
|
1995
|
-
return (E = (B = (
|
|
2009
|
+
return (E = (B = (i = t[0]) == null ? void 0 : i.hourly) == null ? void 0 : B.wave_height) != null && E.every((Z) => Z === null || Z === 0) && (d.models = this.pickMarineModels("best_match,ncep_gfswave025,ecmwf_wam025,meteofrance_wave"), t = await this.marineForecast(d, O)), { weather: X, marine: t, wparams: Y, mparams: d, datetime: (N = a == null ? void 0 : a.utc()) == null ? void 0 : N.format() };
|
|
1996
2010
|
}
|
|
1997
2011
|
/**
|
|
1998
2012
|
* 历史再分析数据
|
|
@@ -2021,7 +2035,7 @@ class Q {
|
|
|
2021
2035
|
precision: 6
|
|
2022
2036
|
}) {
|
|
2023
2037
|
b = Q.toStdLng(b), this.debug && _.info("[%s] spot historical params: %j", Y.requestId, { lat: z, lng: b, startDate: p, endDate: W, withMarine: O, options: Y });
|
|
2024
|
-
const a = this.timezoneOffset(z, b), n =
|
|
2038
|
+
const a = this.timezoneOffset(z, b), n = L.utc(p).utcOffset(a), X = L.utc(W).utcOffset(a);
|
|
2025
2039
|
n.subtract(a > 0 ? a : -a, "h"), X.subtract(a > 0 ? a : -a, "h");
|
|
2026
2040
|
const d = 730;
|
|
2027
2041
|
if (X.diff(n, "days") <= d)
|
|
@@ -2042,7 +2056,7 @@ class Q {
|
|
|
2042
2056
|
for (; u.isBefore(X); ) {
|
|
2043
2057
|
const V = u.clone().add(d, "days"), m = V.isAfter(X) ? X : V;
|
|
2044
2058
|
this.debug && _.debug("[%s] fetching chunk from %s to %s", Y.requestId, u.format("YYYY-MM-DD"), m.format("YYYY-MM-DD"));
|
|
2045
|
-
const
|
|
2059
|
+
const i = await this._fetchHistoricalData(
|
|
2046
2060
|
z,
|
|
2047
2061
|
b,
|
|
2048
2062
|
u.format("YYYY-MM-DD"),
|
|
@@ -2052,7 +2066,7 @@ class Q {
|
|
|
2052
2066
|
O,
|
|
2053
2067
|
Y
|
|
2054
2068
|
);
|
|
2055
|
-
r.push(
|
|
2069
|
+
r.push(i), u = m.clone().add(1, "second"), await new Promise((B) => setTimeout(B, 100));
|
|
2056
2070
|
}
|
|
2057
2071
|
return this._mergeHistoricalResults(r);
|
|
2058
2072
|
}
|
|
@@ -2134,7 +2148,7 @@ class Q {
|
|
|
2134
2148
|
precision: 6
|
|
2135
2149
|
}) {
|
|
2136
2150
|
b = Q.toStdLng(b), this.debug && _.info("[%s] spot seasonal params: %j", c.requestId, { lat: z, lng: b, startDate: p, endDate: W, options: c });
|
|
2137
|
-
const O = this.timezoneOffset(z, b), Y =
|
|
2151
|
+
const O = this.timezoneOffset(z, b), Y = L.utc(p).utcOffset(O), a = W ? L.utc(W).utcOffset(O) : Y.clone().add(1, "month");
|
|
2138
2152
|
Y.subtract(O > 0 ? O : -O, "h"), a.subtract(O > 0 ? O : -O, "h");
|
|
2139
2153
|
const n = {
|
|
2140
2154
|
apikey: this.apikey,
|
|
@@ -2174,7 +2188,7 @@ class Q {
|
|
|
2174
2188
|
precision: 6
|
|
2175
2189
|
}) {
|
|
2176
2190
|
b = Q.toStdLng(b), this.debug && _.info("[%s] spot climate params: %j", A.requestId, { lat: z, lng: b, startDate: p, endDate: W, options: A });
|
|
2177
|
-
const c = this.timezoneOffset(z, b), O =
|
|
2191
|
+
const c = this.timezoneOffset(z, b), O = L.utc(p).utcOffset(c), Y = W ? L.utc(W).utcOffset(c) : O.clone().add(1, "day");
|
|
2178
2192
|
Y.subtract(c > 0 ? c : -c, "h"), O.subtract(c > 0 ? c : -c, "h");
|
|
2179
2193
|
const a = 730;
|
|
2180
2194
|
if (Y.diff(O, "days") <= a)
|
|
@@ -2234,7 +2248,7 @@ class Q {
|
|
|
2234
2248
|
* @param options
|
|
2235
2249
|
*/
|
|
2236
2250
|
async update(z = {}) {
|
|
2237
|
-
const b =
|
|
2251
|
+
const b = L.unix(this.METEO2_UPDATE.etime), p = this.METEO2_UPDATE.version, W = L();
|
|
2238
2252
|
if (!p || b.clone().add(10, "minute").isBefore(W)) {
|
|
2239
2253
|
const A = z.url || "https://meteo3agent.idmwx.com/api/agents/update", c = await fetch(A, {
|
|
2240
2254
|
headers: {
|
|
@@ -2248,16 +2262,16 @@ class Q {
|
|
|
2248
2262
|
const Y = O.data, a = D.standardWeatherModels();
|
|
2249
2263
|
for (const n of a) {
|
|
2250
2264
|
const X = D.autoPickSubCategories(n.alias), t = Y.filter((r) => X.includes(r.category)).map((r) => {
|
|
2251
|
-
var
|
|
2252
|
-
const u =
|
|
2265
|
+
var i, B, E, N, Z, f;
|
|
2266
|
+
const u = L.unix((i = r.meta) == null ? void 0 : i.data_end_time).utc(), V = L.unix((B = r.meta) == null ? void 0 : B.last_run_availability_time).utc(), m = u.diff(V, "days");
|
|
2253
2267
|
return {
|
|
2254
2268
|
category: r.category,
|
|
2255
2269
|
meta: {
|
|
2256
2270
|
endTime: u.format(),
|
|
2257
2271
|
availabilityTime: V.format(),
|
|
2258
2272
|
days: m,
|
|
2259
|
-
initialisationTime:
|
|
2260
|
-
modificationTime:
|
|
2273
|
+
initialisationTime: L.unix((E = r.meta) == null ? void 0 : E.last_run_initialisation_time).utc().format(),
|
|
2274
|
+
modificationTime: L.unix((N = r.meta) == null ? void 0 : N.last_run_modification_time).utc().format(),
|
|
2261
2275
|
temporalResolution: Math.round(((Z = r.meta) == null ? void 0 : Z.temporal_resolution_seconds) / 3600),
|
|
2262
2276
|
frequency: Math.round(((f = r.meta) == null ? void 0 : f.update_interval_seconds) / 3600)
|
|
2263
2277
|
}
|
|
@@ -2286,7 +2300,7 @@ class Q {
|
|
|
2286
2300
|
if (p[A] instanceof Array)
|
|
2287
2301
|
for (const c of p[A])
|
|
2288
2302
|
z != null && z.includes(c.category) && W.push(c);
|
|
2289
|
-
return W.sort((A, c) =>
|
|
2303
|
+
return W.sort((A, c) => L(c.meta.endTime).unix() - L(A.meta.endTime).unix()), W;
|
|
2290
2304
|
}
|
|
2291
2305
|
}
|
|
2292
2306
|
let B0;
|
|
@@ -2363,7 +2377,7 @@ class A0 {
|
|
|
2363
2377
|
return z == null ? void 0 : z.map((b) => {
|
|
2364
2378
|
const p = Number(b.pressure / 100), W = Number(b.lat), A = Number(b.lon), c = Number(b.windSpeed * 3600 / 1852);
|
|
2365
2379
|
return {
|
|
2366
|
-
updated:
|
|
2380
|
+
updated: L.utc(b.time).format(),
|
|
2367
2381
|
lat: isNaN(W) ? null : W,
|
|
2368
2382
|
lng: isNaN(A) ? null : A,
|
|
2369
2383
|
pressure: isNaN(p) ? null : Math.round(p) || null,
|
|
@@ -2393,9 +2407,9 @@ class A0 {
|
|
|
2393
2407
|
static async parseForecast(z) {
|
|
2394
2408
|
return z.map((b) => {
|
|
2395
2409
|
var A;
|
|
2396
|
-
const p =
|
|
2410
|
+
const p = L.utc(b.reftime).format(), W = {};
|
|
2397
2411
|
return (A = b.records) == null || A.forEach((c) => {
|
|
2398
|
-
const O =
|
|
2412
|
+
const O = L.utc(c.time), Y = O.diff(p, "hour"), a = Number(c.pressure / 100), n = Number(c.lat), X = Number(c.lon), d = Number(c.windSpeed * 3600 / 1852);
|
|
2399
2413
|
W[Y] = {
|
|
2400
2414
|
lat: isNaN(n) ? null : n,
|
|
2401
2415
|
lng: isNaN(X) ? null : X,
|
|
@@ -2446,19 +2460,19 @@ class A0 {
|
|
|
2446
2460
|
return await S.tropicalMovement(A), A;
|
|
2447
2461
|
}
|
|
2448
2462
|
static async realtimeForecast() {
|
|
2449
|
-
const z = "https://node.windy.com/tc/v2/storms", b = await
|
|
2463
|
+
const z = "https://node.windy.com/tc/v2/storms", b = await x.get(z).json(), p = [];
|
|
2450
2464
|
for (const W of b.storms) {
|
|
2451
|
-
const A = `https://node.windy.com/tc/v2/storms/${W.id}`, c = await
|
|
2465
|
+
const A = `https://node.windy.com/tc/v2/storms/${W.id}`, c = await x.get(A).json(), O = await A0.parseTropical(c);
|
|
2452
2466
|
p.push(O);
|
|
2453
2467
|
}
|
|
2454
2468
|
return p;
|
|
2455
2469
|
}
|
|
2456
2470
|
}
|
|
2457
|
-
const
|
|
2471
|
+
const $ = class $ {
|
|
2458
2472
|
static async parseHistory(z) {
|
|
2459
|
-
const b = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${z}`, p = await
|
|
2473
|
+
const b = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${z}`, p = await x.post(b).text(), W = await $.parser.parseStringPromise(p), A = W.typhoon.position instanceof Array ? W.typhoon.position : [W.typhoon.position], c = [];
|
|
2460
2474
|
for (const O of A) {
|
|
2461
|
-
const Y =
|
|
2475
|
+
const Y = L(O.updatetime).utcOffset(8).utc().format(), a = Number(O.lat), n = Number(O.lon), X = Number(O.pressure), d = Number(O.windspeed * 3600 / 1852), t = S.parseWindCircle(O.c7quad1 / 1.852), r = S.parseWindCircle(O.c7quad2 / 1.852), u = S.parseWindCircle(O.c7quad3 / 1.852), V = S.parseWindCircle(O.c7quad4 / 1.852), m = S.parseWindCircle(O.c10quad1 / 1.852), i = S.parseWindCircle(O.c10quad2 / 1.852), B = S.parseWindCircle(O.c10quad3 / 1.852), E = S.parseWindCircle(O.c10quad4 / 1.852), N = S.parseWindCircle(O.c12quad1 / 1.852), Z = S.parseWindCircle(O.c12quad2 / 1.852), f = S.parseWindCircle(O.c12quad3 / 1.852), U = S.parseWindCircle(O.c12quad4 / 1.852), { r7: P, r10: w, r12: K } = S.estimateWindRadii(d, a), v = {
|
|
2462
2476
|
updated: Y,
|
|
2463
2477
|
lat: isNaN(a) ? null : a,
|
|
2464
2478
|
lng: isNaN(n) ? null : n,
|
|
@@ -2474,7 +2488,7 @@ const J = class J {
|
|
|
2474
2488
|
r7se: V,
|
|
2475
2489
|
r10: w,
|
|
2476
2490
|
r10ne: m,
|
|
2477
|
-
r10nw:
|
|
2491
|
+
r10nw: i,
|
|
2478
2492
|
r10sw: B,
|
|
2479
2493
|
r10se: E,
|
|
2480
2494
|
r12: K,
|
|
@@ -2484,22 +2498,22 @@ const J = class J {
|
|
|
2484
2498
|
r12se: U
|
|
2485
2499
|
}
|
|
2486
2500
|
};
|
|
2487
|
-
c.push(
|
|
2501
|
+
c.push(v);
|
|
2488
2502
|
}
|
|
2489
|
-
return c.sort((O, Y) =>
|
|
2503
|
+
return c.sort((O, Y) => L(Y.updated).unix() - L(O.updated).unix()), c;
|
|
2490
2504
|
}
|
|
2491
2505
|
static async parseForecast(z, b) {
|
|
2492
|
-
const p = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${z}`, W = await
|
|
2506
|
+
const p = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${z}`, W = await x.post(p).text(), A = await $.parser.parseStringPromise(W), c = A.list.forecast instanceof Array ? A.list.forecast : [A.list.forecast], O = [];
|
|
2493
2507
|
for (const Y of c)
|
|
2494
2508
|
if (Y.xuhao === z) {
|
|
2495
2509
|
const a = Y.positions.forecastposition instanceof Array ? Y.positions.forecastposition : [Y.positions.forecastposition];
|
|
2496
2510
|
if (a.length) {
|
|
2497
|
-
b = b ||
|
|
2511
|
+
b = b || L(a.at(0).forecasttime).utcOffset(8).utc();
|
|
2498
2512
|
const n = {};
|
|
2499
2513
|
for (const d of a) {
|
|
2500
|
-
const t =
|
|
2514
|
+
const t = L(d.forecasttime).utcOffset(8).utc(), r = t.diff(b, "hours");
|
|
2501
2515
|
if (r) {
|
|
2502
|
-
const u = Number(d.forelat), V = Number(d.forelon), m = Number(d.forepressure),
|
|
2516
|
+
const u = Number(d.forelat), V = Number(d.forelon), m = Number(d.forepressure), i = Number(d.forespeed * 3600 / 1852);
|
|
2503
2517
|
n[r] = {
|
|
2504
2518
|
lat: isNaN(u) ? null : u,
|
|
2505
2519
|
lng: isNaN(V) ? null : V,
|
|
@@ -2507,9 +2521,9 @@ const J = class J {
|
|
|
2507
2521
|
utc: t.format(),
|
|
2508
2522
|
wind: {
|
|
2509
2523
|
datetime: t.format(),
|
|
2510
|
-
kts: isNaN(
|
|
2511
|
-
bf: D.beaufort(D.kts2ms(
|
|
2512
|
-
...S.parseTropicalType(
|
|
2524
|
+
kts: isNaN(i) ? null : Math.round(i),
|
|
2525
|
+
bf: D.beaufort(D.kts2ms(i ?? 0)),
|
|
2526
|
+
...S.parseTropicalType(i),
|
|
2513
2527
|
r7: null,
|
|
2514
2528
|
r7ne: null,
|
|
2515
2529
|
r7nw: null,
|
|
@@ -2544,7 +2558,7 @@ const J = class J {
|
|
|
2544
2558
|
}
|
|
2545
2559
|
static async parseTropical(z) {
|
|
2546
2560
|
var c, O, Y;
|
|
2547
|
-
const b = await
|
|
2561
|
+
const b = await $.parseHistory(z.xuhao), p = (c = b.at(0)) == null ? void 0 : c.updated, W = await $.parseForecast(z.xuhao, p ? L(p) : void 0), A = {
|
|
2548
2562
|
id: (O = z.enname) == null ? void 0 : O.toLowerCase(),
|
|
2549
2563
|
name: (Y = z.enname) == null ? void 0 : Y.toLowerCase(),
|
|
2550
2564
|
cnName: z.name,
|
|
@@ -2554,17 +2568,17 @@ const J = class J {
|
|
|
2554
2568
|
return await S.tropicalMovement(A), A;
|
|
2555
2569
|
}
|
|
2556
2570
|
static async realtimeForecast() {
|
|
2557
|
-
const z = "https://hifleet.com/hifleetapi/getCurrentTyphoon2.do", b = await
|
|
2571
|
+
const z = "https://hifleet.com/hifleetapi/getCurrentTyphoon2.do", b = await x.post(z).text(), p = await $.parser.parseStringPromise(b), W = [], A = p.typhoon.position instanceof Array ? p.typhoon.position : [p.typhoon.position];
|
|
2558
2572
|
for (const c of A)
|
|
2559
2573
|
if (c) {
|
|
2560
|
-
const O = await
|
|
2574
|
+
const O = await $.parseTropical(c);
|
|
2561
2575
|
W.push(O);
|
|
2562
2576
|
}
|
|
2563
2577
|
return W;
|
|
2564
2578
|
}
|
|
2565
2579
|
};
|
|
2566
|
-
F(
|
|
2567
|
-
let n0 =
|
|
2580
|
+
F($, "parser", Z0.Parser({ explicitArray: !1, mergeAttrs: !0, trim: !0 }));
|
|
2581
|
+
let n0 = $;
|
|
2568
2582
|
var r0 = /* @__PURE__ */ ((M) => (M.CMA = "CMA", M.CNTW = "CNTW", M.CNHK = "CNHK", M.JMA = "JMA", M.KMA = "KMA", M.ECMWF = "ECMWF", M.NOAA_AT = "NOAA-AT", M.NOAA_CP = "NOAA-CP", M.NOAA_EP = "NOAA-EP", M.UKM = "UKM", M.IMD = "IMD", M.GFS = "GFS", M.BOM_ACCESS = "BOM-ACCESS", M.BOM_BULLETIN_EAST = "BOM-BULLETIN-EAST", M.BOM_BULLETIN_NORTH = "BOM-BULLETIN-NORTH", M.BOM_BULLETIN_WEST = "BOM-BULLETIN-WEST", M.OTHER = "OTHER", M))(r0 || {});
|
|
2569
2583
|
class S {
|
|
2570
2584
|
/**
|
|
@@ -2593,7 +2607,7 @@ class S {
|
|
|
2593
2607
|
return ((X = n.name) == null ? void 0 : X.toLowerCase()) === ((d = O.name) == null ? void 0 : d.toLowerCase());
|
|
2594
2608
|
});
|
|
2595
2609
|
if (Y) {
|
|
2596
|
-
O.cnName = Y.cnName, (A = Y.history) != null && A.length && (O.history = Y.history), O.history.sort((n, X) =>
|
|
2610
|
+
O.cnName = Y.cnName, (A = Y.history) != null && A.length && (O.history = Y.history), O.history.sort((n, X) => L(X.updated).valueOf() - L(n.updated).valueOf());
|
|
2597
2611
|
for (const n of Y.forecasts)
|
|
2598
2612
|
["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((c = n.model) == null ? void 0 : c.toUpperCase()) && !O.forecasts.find((X) => X.model.toLowerCase() === n.model.toLowerCase()) && O.forecasts.push(n);
|
|
2599
2613
|
}
|
|
@@ -2601,9 +2615,9 @@ class S {
|
|
|
2601
2615
|
const a = O.history[0];
|
|
2602
2616
|
a && O.forecasts.forEach((n) => {
|
|
2603
2617
|
n.date = a.updated;
|
|
2604
|
-
const X =
|
|
2618
|
+
const X = L(a.updated), d = {};
|
|
2605
2619
|
for (const t in n.hours) {
|
|
2606
|
-
const r = n.hours[t], u =
|
|
2620
|
+
const r = n.hours[t], u = L(r.utc).diff(X, "h");
|
|
2607
2621
|
u > 0 && (d[u] = r);
|
|
2608
2622
|
}
|
|
2609
2623
|
n.hours = d;
|
|
@@ -2649,7 +2663,7 @@ class S {
|
|
|
2649
2663
|
return z;
|
|
2650
2664
|
}
|
|
2651
2665
|
static calculateMovement(z, b) {
|
|
2652
|
-
const p = f0.calculateDistance(z, b), W =
|
|
2666
|
+
const p = f0.calculateDistance(z, b), W = L(b.utc || b.updated).diff(z.utc || z.updated, "h", !0);
|
|
2653
2667
|
return {
|
|
2654
2668
|
kts: Math.round(p / W * 100) / 100,
|
|
2655
2669
|
deg: f0.calculateBearing(z, b, !0, 0)
|