@idm-plugin/geo 2.2.1 → 2.2.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 +152 -151
- package/dist/index.umd.cjs +6 -6
- package/dist/json/src/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as f from "@turf/turf";
|
|
2
2
|
import b from "moment";
|
|
3
|
-
import
|
|
3
|
+
import F from "@log4js-node/log4js-api";
|
|
4
4
|
import "moment-timezone";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import G from "tz-lookup";
|
|
6
|
+
import z from "shpjs";
|
|
7
7
|
class d {
|
|
8
8
|
/**
|
|
9
9
|
* 基于输入的经度,计算出时区
|
|
@@ -12,7 +12,7 @@ class d {
|
|
|
12
12
|
*/
|
|
13
13
|
static guessTimeZoneOffset(t, e) {
|
|
14
14
|
t = d.convertToStdLng(t);
|
|
15
|
-
const n =
|
|
15
|
+
const n = G(e, t), i = b().tz(n).utcOffset();
|
|
16
16
|
return d.roundPrecision(i / 60, 1);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
@@ -164,7 +164,7 @@ class d {
|
|
|
164
164
|
return i >= 1 ? o : n > 0 ? `${o}.${Math.trunc(i * Math.pow(10, n)).toString().padStart(n, "0")}` : o;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
class
|
|
167
|
+
class J {
|
|
168
168
|
static json2Str(t) {
|
|
169
169
|
const e = t.type ? t.type[0].toUpperCase() : "A";
|
|
170
170
|
return `${t.lat}|${t.lng}|${t.positionTime}|${t.sog}|${t.cog}|${t.hdg}|${t.draught}|${e}|${JSON.stringify(t.meteo || {})}|${t.vendor}|${t.deleted}`;
|
|
@@ -200,7 +200,7 @@ class j {
|
|
|
200
200
|
if (n && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(a.type))
|
|
201
201
|
continue;
|
|
202
202
|
const h = g.positionTime - l.positionTime;
|
|
203
|
-
if (
|
|
203
|
+
if (v.calculateDistance(g, l, !0, 4) / (h / 3600) < e)
|
|
204
204
|
r || (r = a), u === t.length - 1 && (s = g, c = u);
|
|
205
205
|
else {
|
|
206
206
|
r && (s = t[u - 1], c = u);
|
|
@@ -224,8 +224,8 @@ class j {
|
|
|
224
224
|
utc: b.unix(s.positionTime).utc().format()
|
|
225
225
|
},
|
|
226
226
|
duration: s.positionTime - r.positionTime
|
|
227
|
-
}, l = t.filter((h) => h.positionTime >= u.start.positionTime && h.positionTime <= u.end.positionTime), g =
|
|
228
|
-
u.distance =
|
|
227
|
+
}, l = t.filter((h) => h.positionTime >= u.start.positionTime && h.positionTime <= u.end.positionTime), g = v.divideAccordingToLng(l);
|
|
228
|
+
u.distance = v.calculateRouteDistance(g), u.hours = Math.round(u.duration / 3600 * 10) / 10, u.avgSog = Math.round(u.distance / u.hours * 10) / 10, o.push(u);
|
|
229
229
|
}
|
|
230
230
|
r = void 0, s = void 0;
|
|
231
231
|
}
|
|
@@ -244,7 +244,7 @@ class j {
|
|
|
244
244
|
if (r.length > 1)
|
|
245
245
|
for (let u = 0; u < r.length - 1; u++) {
|
|
246
246
|
const l = r[u], g = r[u + 1];
|
|
247
|
-
s +=
|
|
247
|
+
s += v.calculateDistance(l, g, !0, 4), c += Math.abs(g.positionTime - l.positionTime);
|
|
248
248
|
}
|
|
249
249
|
s = Math.round(s * 100) / 100, c = Math.round(c / 3600 * 100) / 100;
|
|
250
250
|
const a = c ? Math.round(s / c * 100) / 100 : 0;
|
|
@@ -253,11 +253,11 @@ class j {
|
|
|
253
253
|
}
|
|
254
254
|
let I;
|
|
255
255
|
try {
|
|
256
|
-
I =
|
|
256
|
+
I = F.getLogger("meteo");
|
|
257
257
|
} catch {
|
|
258
258
|
} finally {
|
|
259
259
|
}
|
|
260
|
-
class
|
|
260
|
+
class v {
|
|
261
261
|
/**
|
|
262
262
|
* 计算方位角
|
|
263
263
|
* @param from 坐标 {lng, lat}
|
|
@@ -374,13 +374,13 @@ class y {
|
|
|
374
374
|
[a > 0 ? 180 : -180, -89]
|
|
375
375
|
])) : (l = f.greatCircle(u[0], u[1]), g = f.greatCircle([a > 0 ? 180 : -180, 89], [a > 0 ? 180 : -180, -89]));
|
|
376
376
|
const h = f.lineIntersect(l, g);
|
|
377
|
-
let
|
|
377
|
+
let p;
|
|
378
378
|
if (h.features.length) {
|
|
379
379
|
const S = f.getCoord(h.features[0]);
|
|
380
|
-
|
|
380
|
+
p = d.roundPrecision(S[1], 8);
|
|
381
381
|
} else
|
|
382
|
-
|
|
383
|
-
a > 0 ? (i.push([180 - 1e-6,
|
|
382
|
+
p = t[c].lat;
|
|
383
|
+
a > 0 ? (i.push([180 - 1e-6, p]), o.push([...i]), i = [], i.push([-(180 - 1e-6), p])) : (i.push([-(180 - 1e-6), p]), o.push([...i]), i = [], i.push([180 - 1e-6, p]));
|
|
384
384
|
}
|
|
385
385
|
c === t.length - 2 && i.push([s, t[c + 1].lat]);
|
|
386
386
|
}
|
|
@@ -456,8 +456,8 @@ class y {
|
|
|
456
456
|
*/
|
|
457
457
|
static appendCoordinateToRoute(t, e) {
|
|
458
458
|
t.lng = d.convertToStdLng(t.lng, 8);
|
|
459
|
-
const n =
|
|
460
|
-
return n.push(t),
|
|
459
|
+
const n = v.convertRouteToCoordinates(e);
|
|
460
|
+
return n.push(t), v.divideAccordingToLng(n);
|
|
461
461
|
}
|
|
462
462
|
/**
|
|
463
463
|
* 向route头加1个坐标
|
|
@@ -465,8 +465,8 @@ class y {
|
|
|
465
465
|
* @param route
|
|
466
466
|
*/
|
|
467
467
|
static unshiftCoordinateToRoute(t, e) {
|
|
468
|
-
const n =
|
|
469
|
-
return n.unshift(t),
|
|
468
|
+
const n = v.convertRouteToCoordinates(e);
|
|
469
|
+
return n.unshift(t), v.divideAccordingToLng(n);
|
|
470
470
|
}
|
|
471
471
|
/**
|
|
472
472
|
* 合并多个waypoints进航线
|
|
@@ -540,8 +540,8 @@ class y {
|
|
|
540
540
|
* @return [[[lng, lat]]]
|
|
541
541
|
*/
|
|
542
542
|
static calculateSubRoute(t, e) {
|
|
543
|
-
const n =
|
|
544
|
-
|
|
543
|
+
const n = v.convertRouteToCoordinates(e);
|
|
544
|
+
v.mergeCoordinateToWaypoints(t, n, !0), e = v.divideAccordingToLng(n);
|
|
545
545
|
const { segIndex: i, minIndex: o } = this.calculateMinDistanceToRoute({ ...t }, e);
|
|
546
546
|
t.lng = d.convertToStdLng(t.lng);
|
|
547
547
|
const r = [];
|
|
@@ -715,17 +715,17 @@ class y {
|
|
|
715
715
|
var g;
|
|
716
716
|
const o = t.speed || 12, r = [];
|
|
717
717
|
let s = [], c = !1, a = 0, u = 0, l;
|
|
718
|
-
if (e && n.length ? (r.push(t), n.forEach((h,
|
|
718
|
+
if (e && n.length ? (r.push(t), n.forEach((h, p) => {
|
|
719
719
|
if (c)
|
|
720
720
|
s.push(h);
|
|
721
721
|
else {
|
|
722
722
|
const S = [];
|
|
723
723
|
let m;
|
|
724
|
-
for (let
|
|
724
|
+
for (let y = 0; y < h.length; y++)
|
|
725
725
|
if (l)
|
|
726
|
-
S.push(h[
|
|
726
|
+
S.push(h[y]);
|
|
727
727
|
else {
|
|
728
|
-
m = { lng: h[
|
|
728
|
+
m = { lng: h[y][0], lat: h[y][1] };
|
|
729
729
|
const P = this.calculateDistance(t, m, !0, 8, i);
|
|
730
730
|
if (a += P, a < e)
|
|
731
731
|
u += P, P && r.push(m), t = m;
|
|
@@ -733,13 +733,13 @@ class y {
|
|
|
733
733
|
if (u = e, a === e)
|
|
734
734
|
l = m, S.push([l.lng, l.lat]);
|
|
735
735
|
else {
|
|
736
|
-
const M = a - e,
|
|
737
|
-
l = this.calculateCoordinate(m,
|
|
736
|
+
const M = a - e, T = this.calculateBearing(m, t);
|
|
737
|
+
l = this.calculateCoordinate(m, T, M, i), S.push([l.lng, l.lat]), S.push([m.lng, m.lat]);
|
|
738
738
|
}
|
|
739
739
|
c = !0;
|
|
740
740
|
}
|
|
741
741
|
}
|
|
742
|
-
S.length && s.push(S),
|
|
742
|
+
S.length && s.push(S), p === n.length - 1 && !l && (l = m);
|
|
743
743
|
}
|
|
744
744
|
})) : (s = n, l = { ...t }), l)
|
|
745
745
|
if (r.push(l), l.distanceFromPrevious = Math.round(u * 1e4) / 1e4, l.hourFromPrevious = Math.round(u / o * 1e4) / 1e4, ((g = s[0]) == null ? void 0 : g.length) > 1) {
|
|
@@ -874,8 +874,8 @@ class y {
|
|
|
874
874
|
const r = t[o - 1], s = t[o], c = t[o + 1];
|
|
875
875
|
let a = !1, u = !1;
|
|
876
876
|
if ((r.velocity || r.suspend || r.important || r.pilot || o === 1) && (a = !0, i.push(r)), s.gcToPrevious && (a || (a = !0, i.push(r)), u = !0, i.push(s), o++), c) {
|
|
877
|
-
const l =
|
|
878
|
-
Math.round(Math.acos(
|
|
877
|
+
const l = v.calculateDistance(r, s, !0), g = v.calculateDistance(s, c, !0), h = v.calculateDistance(r, c, !0), p = (Math.pow(l, 2) + Math.pow(g, 2) - Math.pow(h, 2)) / (2 * l * g);
|
|
878
|
+
Math.round(Math.acos(p) * 180 / Math.PI) < n && h > e && !u && (i.push(s), o++);
|
|
879
879
|
}
|
|
880
880
|
if (o >= t.length - 1) {
|
|
881
881
|
const l = t.at(-1);
|
|
@@ -909,8 +909,8 @@ class y {
|
|
|
909
909
|
if (!i) {
|
|
910
910
|
const a = (r = (o = e.filter((l) => (l == null ? void 0 : l.positionTime) < n.unix())) == null ? void 0 : o.sort((l, g) => (l.positionTime || 0) - (g.positionTime || 0))) == null ? void 0 : r.at(-1), u = (c = (s = e.filter((l) => (l == null ? void 0 : l.positionTime) > n.unix())) == null ? void 0 : s.sort((l, g) => (l.positionTime || 0) - (g.positionTime || 0))) == null ? void 0 : c.at(0);
|
|
911
911
|
if (a && u) {
|
|
912
|
-
const l =
|
|
913
|
-
i =
|
|
912
|
+
const l = v.calculateBearing(a, u, !0), g = v.calculateDistance(a, u), h = (n.unix() - a.positionTime) / (u.positionTime - a.positionTime);
|
|
913
|
+
i = v.calculateCoordinate(a, l, g * h), i.positionTime = n.unix(), i.utc = n.utc().format(), i.cog = l, i.sog = Math.round(g / ((u.positionTime - a.positionTime) / 3600) * 100) / 100;
|
|
914
914
|
} else
|
|
915
915
|
i = a || u, i && (i.utc = b.unix(i == null ? void 0 : i.positionTime).utc().format());
|
|
916
916
|
}
|
|
@@ -925,16 +925,16 @@ class y {
|
|
|
925
925
|
e = JSON.parse(JSON.stringify(e)), e.sort((a, u) => (a.positionTime || 0) - (u.positionTime || 0));
|
|
926
926
|
let n = Number.MAX_SAFE_INTEGER, i = Number.MAX_SAFE_INTEGER;
|
|
927
927
|
for (let a = 0; a < e.length - 1; a++) {
|
|
928
|
-
const u = e[a], l = e[a + 1], g =
|
|
928
|
+
const u = e[a], l = e[a + 1], g = v.calculatePointToLineDistance(t, u, l);
|
|
929
929
|
g < n && (n = g, i = a);
|
|
930
930
|
}
|
|
931
|
-
const o = e[i], r = e[i + 1], s =
|
|
931
|
+
const o = e[i], r = e[i + 1], s = v.calculateDistance(o, t), c = v.calculateDistance(r, t);
|
|
932
932
|
if (s === 0)
|
|
933
933
|
t = o;
|
|
934
934
|
else if (c === 0)
|
|
935
935
|
t = r;
|
|
936
936
|
else {
|
|
937
|
-
const a = o.positionTime || 0, u = r.positionTime || 0, l =
|
|
937
|
+
const a = o.positionTime || 0, u = r.positionTime || 0, l = v.calculateDistance(o, r);
|
|
938
938
|
t.positionTime = Math.round(a + (u - a) * (s / l));
|
|
939
939
|
}
|
|
940
940
|
return t.utc = t.positionTime ? b.unix(t.positionTime).utc().format() : void 0, t.positionTime ? t : void 0;
|
|
@@ -973,7 +973,7 @@ class y {
|
|
|
973
973
|
*/
|
|
974
974
|
static waypoints2RTZ(t, e) {
|
|
975
975
|
const i = [];
|
|
976
|
-
return i.push('<?xml version="1.0" encoding="UTF-8"?>'), i.push('<route xmlns="http://www.cirm.org/RTZ/1/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2">'), i.push(` <routeInfo routeName="${
|
|
976
|
+
return i.push('<?xml version="1.0" encoding="UTF-8"?>'), i.push('<route xmlns="http://www.cirm.org/RTZ/1/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2">'), i.push(` <routeInfo routeName="${v.xmlEscape(t)}"></routeInfo>`), i.push(...v.toRTZWaypoints(e, 6)), i.push("</route>"), i.join(`
|
|
977
977
|
`);
|
|
978
978
|
}
|
|
979
979
|
/**
|
|
@@ -984,7 +984,7 @@ class y {
|
|
|
984
984
|
*/
|
|
985
985
|
static waypoints2RTZ10(t, e, n = !0) {
|
|
986
986
|
const o = [];
|
|
987
|
-
return o.push('<?xml version="1.0" encoding="UTF-8"?>'), o.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'), o.push(` <routeInfo routeName="${
|
|
987
|
+
return o.push('<?xml version="1.0" encoding="UTF-8"?>'), o.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'), o.push(` <routeInfo routeName="${v.xmlEscape(t)}"></routeInfo>`), o.push(...v.toRTZWaypoints(e, 6, n)), o.push("</route>"), o.join(`
|
|
988
988
|
`);
|
|
989
989
|
}
|
|
990
990
|
static toRTZWaypoints(t, e = 6, n = !0) {
|
|
@@ -992,20 +992,20 @@ class y {
|
|
|
992
992
|
i.push(" <waypoints>");
|
|
993
993
|
for (let o = 0; o < t.length; o++) {
|
|
994
994
|
const r = t[o], s = o + 1, c = (r.lat ?? "").toFixed ? r.lat.toFixed(e).padEnd(e + 2, "0") : r.lat, a = (r.lng ?? "").toFixed ? r.lng.toFixed(e).padEnd(e + 2, "0") : r.lng, u = [`id="${s}"`, 'revision="0"'];
|
|
995
|
-
if (r.name && u.push(`name="${
|
|
995
|
+
if (r.name && u.push(`name="${v.xmlEscape(r.name)}"`), i.push(` <waypoint ${u.join(" ")}>`), i.push(` <position lat="${v.xmlEscape(c)}" lon="${v.xmlEscape(a)}" />`), o > 0) {
|
|
996
996
|
const l = r.gcToPrevious ? "Orthodrome" : "Loxodrome";
|
|
997
997
|
i.push(` <leg geometryType="${l}" />`);
|
|
998
998
|
}
|
|
999
999
|
if (n) {
|
|
1000
1000
|
const l = [];
|
|
1001
|
-
if (r.description && l.push(` <description>${
|
|
1002
|
-
l.push(` <time>${
|
|
1001
|
+
if (r.description && l.push(` <description>${v.xmlEscape(r.description)}</description>`), r.utc)
|
|
1002
|
+
l.push(` <time>${v.xmlEscape(r.utc)}</time>`);
|
|
1003
1003
|
else if (r.positionTime)
|
|
1004
1004
|
try {
|
|
1005
|
-
l.push(` <time>${
|
|
1005
|
+
l.push(` <time>${v.xmlEscape(b.unix(r.positionTime).utc().format())}</time>`);
|
|
1006
1006
|
} catch {
|
|
1007
1007
|
}
|
|
1008
|
-
r.cog !== void 0 && l.push(` <cog>${
|
|
1008
|
+
r.cog !== void 0 && l.push(` <cog>${v.xmlEscape(r.cog)}</cog>`), r.sog !== void 0 && l.push(` <sog>${v.xmlEscape(r.sog)}</sog>`), l.length && (i.push(" <extensions>"), i.push(...l), i.push(" </extensions>"));
|
|
1009
1009
|
}
|
|
1010
1010
|
i.push(" </waypoint>");
|
|
1011
1011
|
}
|
|
@@ -1020,13 +1020,13 @@ class y {
|
|
|
1020
1020
|
*/
|
|
1021
1021
|
static waypoints2CSV(t, e, n) {
|
|
1022
1022
|
I.debug("keep name for waypoints2CSV for legacy compatibility only", t);
|
|
1023
|
-
const i = (n == null ? void 0 : n.precision) ?? 6, o = e.some((m) => m.name), r = e.some((m) => m.description), s = e.some((m) => m.port != null), c = e.some((m) => m.stbd != null), a = e.some((m) => m.arrRad != null), u = e.some((m) => m.speed != null), l = e.some((m,
|
|
1024
|
-
o &&
|
|
1023
|
+
const i = (n == null ? void 0 : n.precision) ?? 6, o = e.some((m) => m.name), r = e.some((m) => m.description), s = e.some((m) => m.port != null), c = e.some((m) => m.stbd != null), a = e.some((m) => m.arrRad != null), u = e.some((m) => m.speed != null), l = e.some((m, y) => y > 0 && m.gcToPrevious != null), g = e.some((m) => m.bearing != null), h = e.some((m) => m.distanceFromPrevious != null), p = ["WPT No.", "Latitude", "Longitude"];
|
|
1024
|
+
o && p.push("Name"), r && p.push("Description"), l && p.push("Leg"), g && p.push("Bearing[deg]"), h && p.push("Distance[NM]"), u && p.push("Speed[kn]"), s && p.push("PORT XTD[NM]"), c && p.push("STBD XTD[NM]"), a && p.push("Arr.Rad[NM]");
|
|
1025
1025
|
const S = [];
|
|
1026
|
-
S.push(
|
|
1026
|
+
S.push(p.map((m) => v.csvEscapeField(m)).join(","));
|
|
1027
1027
|
for (let m = 0; m < e.length; m++) {
|
|
1028
|
-
const
|
|
1029
|
-
P.push((m + 1).toString()), P.push(
|
|
1028
|
+
const y = e[m], P = [];
|
|
1029
|
+
P.push((m + 1).toString()), P.push(y.lat.toFixed(i)), P.push(y.lng.toFixed(i)), o && P.push(y.name ?? ""), r && P.push(y.description ?? ""), l && P.push(m === 0 ? "" : y.gcToPrevious ? "GC" : "RL"), g && P.push(y.bearing != null ? String(y.bearing) : ""), h && P.push(y.distanceFromPrevious != null ? String(y.distanceFromPrevious) : ""), u && P.push(y.speed != null ? String(y.speed) : ""), s && P.push(y.port != null ? String(y.port) : ""), c && P.push(y.stbd != null ? String(y.stbd) : ""), a && P.push(y.arrRad != null ? String(y.arrRad) : ""), S.push(P.map((M) => v.csvEscapeField(M)).join(","));
|
|
1030
1030
|
}
|
|
1031
1031
|
return S.join(`
|
|
1032
1032
|
`);
|
|
@@ -1068,7 +1068,7 @@ class y {
|
|
|
1068
1068
|
static waypoints2NMEA(t) {
|
|
1069
1069
|
const e = [];
|
|
1070
1070
|
for (let n = 0; n < t.length; n++) {
|
|
1071
|
-
const i = t[n], o =
|
|
1071
|
+
const i = t[n], o = v.decimalToNmeaDm(i.lat, !0), r = v.decimalToNmeaDm(i.lng, !1), s = i.name ? String(i.name).slice(0, 6) : `WPT${(n + 1).toString().padStart(3, "0")}`, c = `GPWPL,${o.dm},${o.dir},${r.dm},${r.dir},${s}`, a = v.nmeaChecksum(c);
|
|
1072
1072
|
e.push(`$${c}*${a}`);
|
|
1073
1073
|
}
|
|
1074
1074
|
return e.join(`\r
|
|
@@ -1088,8 +1088,8 @@ class y {
|
|
|
1088
1088
|
*/
|
|
1089
1089
|
static coordinatesSummary(t, e = 3) {
|
|
1090
1090
|
if (t.length > 1) {
|
|
1091
|
-
const n = t[0], i = t[t.length - 1], o = (n == null ? void 0 : n.positionTime) < (i == null ? void 0 : i.positionTime) ? b.unix(n == null ? void 0 : n.positionTime) : b.unix(i == null ? void 0 : i.positionTime), r = (n == null ? void 0 : n.positionTime) > (i == null ? void 0 : i.positionTime) ? b.unix(n == null ? void 0 : n.positionTime) : b.unix(i == null ? void 0 : i.positionTime), s = Math.round(r.diff(o, "hours", !0) * 100) / 100, c = this.generateRouteAccordingToWaypoints(t, !0, !0), a = this.calculateRouteDistance(c), l =
|
|
1092
|
-
(h,
|
|
1091
|
+
const n = t[0], i = t[t.length - 1], o = (n == null ? void 0 : n.positionTime) < (i == null ? void 0 : i.positionTime) ? b.unix(n == null ? void 0 : n.positionTime) : b.unix(i == null ? void 0 : i.positionTime), r = (n == null ? void 0 : n.positionTime) > (i == null ? void 0 : i.positionTime) ? b.unix(n == null ? void 0 : n.positionTime) : b.unix(i == null ? void 0 : i.positionTime), s = Math.round(r.diff(o, "hours", !0) * 100) / 100, c = this.generateRouteAccordingToWaypoints(t, !0, !0), a = this.calculateRouteDistance(c), l = J.inspectStoppages(t, e).reduce(
|
|
1092
|
+
(h, p) => (h.duration += p.duration, h.distance += p.distance, h),
|
|
1093
1093
|
{ hours: 0, distance: 0, spd: 0, duration: 0 }
|
|
1094
1094
|
);
|
|
1095
1095
|
l.hours = Math.round(l.duration / 3600 * 100) / 100, l.distance = Math.round(l.distance * 100) / 100, l.spd = l.hours ? Math.round(l.distance / l.hours * 100) / 100 : 0;
|
|
@@ -1127,16 +1127,16 @@ class y {
|
|
|
1127
1127
|
const n = e.sample.hours.at(0), i = b.utc(t), o = b.utc(e.eta), r = i.isAfter(o) ? o : i;
|
|
1128
1128
|
let s = e.sample.all.find((h) => h.eta === r.format());
|
|
1129
1129
|
if (!s) {
|
|
1130
|
-
const h = e.sample.all.filter((N) => b.utc(N.eta).isBefore(r)).at(-1),
|
|
1131
|
-
s = (g = this.calculateNextCoordinateAlongRoute(h, h.speed * r.diff(b(h.etd), "hours", !0),
|
|
1132
|
-
const { cFactor: S, cog: m, wxFactor:
|
|
1130
|
+
const h = e.sample.all.filter((N) => b.utc(N.eta).isBefore(r)).at(-1), p = this.calculateSubRoute(h, e.route);
|
|
1131
|
+
s = (g = this.calculateNextCoordinateAlongRoute(h, h.speed * r.diff(b(h.etd), "hours", !0), p)) == null ? void 0 : g.coordinate;
|
|
1132
|
+
const { cFactor: S, cog: m, wxFactor: y, meteo: P } = h, M = Math.round(s.distanceFromPrevious * 1e4) / 1e4, T = Math.round((M + h.distanceFromStart) * 1e4) / 1e4;
|
|
1133
1133
|
s = {
|
|
1134
1134
|
...s,
|
|
1135
1135
|
cFactor: S,
|
|
1136
1136
|
cog: m,
|
|
1137
1137
|
speed: h.speed,
|
|
1138
|
-
wxFactor:
|
|
1139
|
-
distanceFromStart:
|
|
1138
|
+
wxFactor: y,
|
|
1139
|
+
distanceFromStart: T,
|
|
1140
1140
|
distanceFromPrevious: M,
|
|
1141
1141
|
meteo: P,
|
|
1142
1142
|
eta: r.format(),
|
|
@@ -1185,11 +1185,11 @@ class y {
|
|
|
1185
1185
|
}
|
|
1186
1186
|
let C;
|
|
1187
1187
|
try {
|
|
1188
|
-
C =
|
|
1188
|
+
C = F.getLogger("vessel");
|
|
1189
1189
|
} catch {
|
|
1190
1190
|
} finally {
|
|
1191
1191
|
}
|
|
1192
|
-
class
|
|
1192
|
+
class H {
|
|
1193
1193
|
/**
|
|
1194
1194
|
* 将原始数据转换为geojson
|
|
1195
1195
|
* @param raw
|
|
@@ -1207,13 +1207,13 @@ class X {
|
|
|
1207
1207
|
for (const S in c == null ? void 0 : c.hours) {
|
|
1208
1208
|
const m = c.hours[S];
|
|
1209
1209
|
a = a || m;
|
|
1210
|
-
const
|
|
1210
|
+
const y = g.clone().add(Number(S), "hour"), P = f.point([m.lng, m.lat], {
|
|
1211
1211
|
model: c.model,
|
|
1212
1212
|
name: r.name,
|
|
1213
1213
|
nameCn: r.nameCn,
|
|
1214
|
-
date:
|
|
1214
|
+
date: y.format(),
|
|
1215
1215
|
hour: Number(S),
|
|
1216
|
-
format:
|
|
1216
|
+
format: y.format("MMM-DD/HHmm[Z]"),
|
|
1217
1217
|
pressure: m.pressure > 1e4 ? d.roundPrecision(m.pressure / 100, 0) : d.roundPrecision(m.pressure, 0),
|
|
1218
1218
|
gusts: m.gusts,
|
|
1219
1219
|
wind: m.wind || {},
|
|
@@ -1223,15 +1223,15 @@ class X {
|
|
|
1223
1223
|
});
|
|
1224
1224
|
l.push(P), u.push(P.geometry.coordinates);
|
|
1225
1225
|
}
|
|
1226
|
-
const
|
|
1226
|
+
const p = {
|
|
1227
1227
|
kts: void 0,
|
|
1228
1228
|
deg: void 0
|
|
1229
1229
|
};
|
|
1230
1230
|
if (s) {
|
|
1231
1231
|
const S = b(s.updated).utc();
|
|
1232
1232
|
if (a) {
|
|
1233
|
-
const
|
|
1234
|
-
|
|
1233
|
+
const y = v.calculateDistance(s, a), P = b(a.utc || a.updated).diff(S, "h", !0);
|
|
1234
|
+
p.kts = Math.round(y / P * 100) / 100, p.deg = v.calculateBearing(s, a, !0, 0);
|
|
1235
1235
|
}
|
|
1236
1236
|
const m = f.point([s.lng, s.lat], {
|
|
1237
1237
|
model: c.model,
|
|
@@ -1242,7 +1242,7 @@ class X {
|
|
|
1242
1242
|
format: S.format("MMM-DD/HHmm[Z]"),
|
|
1243
1243
|
pressure: s.pressure > 1e4 ? d.roundPrecision((s == null ? void 0 : s.pressure) / 100, 0) : d.roundPrecision(s.pressure, 0),
|
|
1244
1244
|
wind: s.wind,
|
|
1245
|
-
movement:
|
|
1245
|
+
movement: p,
|
|
1246
1246
|
category: h,
|
|
1247
1247
|
type: "forecast",
|
|
1248
1248
|
important: !0
|
|
@@ -1258,7 +1258,7 @@ class X {
|
|
|
1258
1258
|
name: r.name,
|
|
1259
1259
|
category: h,
|
|
1260
1260
|
type: "forecast",
|
|
1261
|
-
movement:
|
|
1261
|
+
movement: p
|
|
1262
1262
|
});
|
|
1263
1263
|
e.features.push(S);
|
|
1264
1264
|
}
|
|
@@ -1267,8 +1267,8 @@ class X {
|
|
|
1267
1267
|
if (e.features.sort((c, a) => c.properties.type === "forecast" && a.properties.type === "forecast" && c.geometry.type === "Point" && a.geometry.type === "Point" ? b(c.properties.date).valueOf() - b(a.properties.date).valueOf() : 0), (i = r.history) != null && i.length) {
|
|
1268
1268
|
const c = [], a = b(s == null ? void 0 : s.updated).utc(), u = b((o = r.history) == null ? void 0 : o.at(-1).updated).utc(), l = a.diff(u, "h") % 24 > 2 ? 24 : 12;
|
|
1269
1269
|
for (const g of r.history) {
|
|
1270
|
-
const h = b(g.updated).utc(),
|
|
1271
|
-
|
|
1270
|
+
const h = b(g.updated).utc(), p = h.isSameOrBefore(a) || h.isSame(u);
|
|
1271
|
+
p && a.add(-l, "h");
|
|
1272
1272
|
const S = f.point([g.lng, g.lat], {
|
|
1273
1273
|
name: r.name,
|
|
1274
1274
|
nameCn: r.nameCn,
|
|
@@ -1281,7 +1281,7 @@ class X {
|
|
|
1281
1281
|
category: `${r.name}-history`,
|
|
1282
1282
|
wind: g.wind,
|
|
1283
1283
|
movement: g.movement,
|
|
1284
|
-
important:
|
|
1284
|
+
important: p
|
|
1285
1285
|
});
|
|
1286
1286
|
e.features.push(S), c.push(S.geometry.coordinates);
|
|
1287
1287
|
}
|
|
@@ -1309,32 +1309,32 @@ class X {
|
|
|
1309
1309
|
var o, r, s, c;
|
|
1310
1310
|
const n = (o = t == null ? void 0 : t.data) == null ? void 0 : o.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), i = [];
|
|
1311
1311
|
for (const a of n) {
|
|
1312
|
-
const u = a.properties.name, l = a.properties.model, g = a.properties.showCircle, h = a.properties.disabled,
|
|
1312
|
+
const u = a.properties.name, l = a.properties.model, g = a.properties.showCircle, h = a.properties.disabled, p = b(a.properties.date).utc();
|
|
1313
1313
|
let S = e * 60;
|
|
1314
1314
|
const m = (r = t == null ? void 0 : t.data) == null ? void 0 : r.features.filter(
|
|
1315
1315
|
(M) => M.geometry.type === "Point" && M.properties.type === "forecast" && M.properties.category === `${u}-${l}`
|
|
1316
1316
|
);
|
|
1317
|
-
let
|
|
1318
|
-
for (;
|
|
1319
|
-
if (
|
|
1320
|
-
const M = m[
|
|
1317
|
+
let y, P = p.clone().add(S, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
1318
|
+
for (; y = this.pickIndex(m, P), y <= m.length - 1; ) {
|
|
1319
|
+
if (y > 0) {
|
|
1320
|
+
const M = m[y], T = y === 0 ? void 0 : m[y - 1], N = (S / 60 - ((s = T == null ? void 0 : T.properties) == null ? void 0 : s.hour)) / (M.properties.hour - ((c = T == null ? void 0 : T.properties) == null ? void 0 : c.hour)), $ = this.computeNumber(T == null ? void 0 : T.geometry.coordinates[0], M.geometry.coordinates[0], N), E = this.computeNumber(T == null ? void 0 : T.geometry.coordinates[1], M.geometry.coordinates[1], N), O = f.point([$, E], {
|
|
1321
1321
|
name: u,
|
|
1322
1322
|
model: l,
|
|
1323
1323
|
category: M == null ? void 0 : M.properties.category,
|
|
1324
1324
|
date: P.format(),
|
|
1325
1325
|
format: P.format("MMM-DD/HHmm[Z]"),
|
|
1326
|
-
gusts: this.computeNumber(
|
|
1327
|
-
hour: this.computeNumber(
|
|
1328
|
-
movement: this.computeNumber(
|
|
1329
|
-
pressure: this.computeNumber(
|
|
1330
|
-
wind: this.computeNumber(
|
|
1326
|
+
gusts: this.computeNumber(T == null ? void 0 : T.properties.gusts, M.properties.gusts, N),
|
|
1327
|
+
hour: this.computeNumber(T == null ? void 0 : T.properties.hour, M.properties.hour, N),
|
|
1328
|
+
movement: this.computeNumber(T == null ? void 0 : T.properties.movement, M.properties.movement, N),
|
|
1329
|
+
pressure: this.computeNumber(T == null ? void 0 : T.properties.pressure, M.properties.pressure, N),
|
|
1330
|
+
wind: this.computeNumber(T == null ? void 0 : T.properties.wind, M.properties.wind, N),
|
|
1331
1331
|
type: "forecast",
|
|
1332
1332
|
disabled: h,
|
|
1333
1333
|
showCircle: g
|
|
1334
1334
|
});
|
|
1335
|
-
i.push(
|
|
1335
|
+
i.push(O);
|
|
1336
1336
|
}
|
|
1337
|
-
S += e * 60, P =
|
|
1337
|
+
S += e * 60, P = p.clone().add(S, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
1338
1338
|
}
|
|
1339
1339
|
}
|
|
1340
1340
|
return i;
|
|
@@ -1364,19 +1364,19 @@ class X {
|
|
|
1364
1364
|
const { t1: o, t2: r, hr: s, hours: c } = this.tropicalCenterTwin(e, 24, i);
|
|
1365
1365
|
if (o && r) {
|
|
1366
1366
|
if (!i.debug) {
|
|
1367
|
-
const
|
|
1368
|
-
if (
|
|
1369
|
-
return C == null || C.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", i.requestId,
|
|
1367
|
+
const p = v.calculateDistance(t, o), S = v.calculateDistance(t, r);
|
|
1368
|
+
if (p > 2 * n && S > 2 * n)
|
|
1369
|
+
return C == null || C.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", i.requestId, p, S, {
|
|
1370
1370
|
from: t,
|
|
1371
1371
|
t1: o,
|
|
1372
1372
|
t2: r,
|
|
1373
1373
|
hr: s
|
|
1374
1374
|
}), {};
|
|
1375
1375
|
}
|
|
1376
|
-
const a =
|
|
1376
|
+
const a = v.calculateBearing(t, o), u = v.calculateBearing(o, r), l = Math.abs(a - u);
|
|
1377
1377
|
let g = 0;
|
|
1378
1378
|
l < 180 ? g = l + 90 : l >= 180 && (g = l - 90);
|
|
1379
|
-
const h =
|
|
1379
|
+
const h = v.calculateCoordinate(o, g, n);
|
|
1380
1380
|
return C == null || C.info("[%s] the right tangent position: %j", i.requestId, {
|
|
1381
1381
|
from: t,
|
|
1382
1382
|
t1: o,
|
|
@@ -1403,17 +1403,17 @@ class X {
|
|
|
1403
1403
|
const { t1: o, t2: r, hr: s, hours: c } = this.tropicalCenterTwin(e, 24, i);
|
|
1404
1404
|
if (o && r) {
|
|
1405
1405
|
if (!i.debug) {
|
|
1406
|
-
const h =
|
|
1407
|
-
if (h > 2 * n &&
|
|
1408
|
-
return C == null || C.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", i.requestId, h,
|
|
1406
|
+
const h = v.calculateDistance(t, o), p = v.calculateDistance(t, r);
|
|
1407
|
+
if (h > 2 * n && p > 2 * n)
|
|
1408
|
+
return C == null || C.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", i.requestId, h, p, {
|
|
1409
1409
|
from: t,
|
|
1410
1410
|
t1: o,
|
|
1411
1411
|
t2: r,
|
|
1412
1412
|
hr: s
|
|
1413
1413
|
}), {};
|
|
1414
1414
|
}
|
|
1415
|
-
const a =
|
|
1416
|
-
return { at:
|
|
1415
|
+
const a = v.calculateBearing(t, o), u = v.calculateBearing(o, r), l = v.calculateDistance(t, o);
|
|
1416
|
+
return { at: v.calculateCoordinate(o, a - u + 180, n < l ? n : l), t1: o, t2: r, hr: Number(s), hours: c };
|
|
1417
1417
|
} else
|
|
1418
1418
|
return C == null || C.info("[%s] no need drift: %j", i.requestId, { from: t, t1: o, t2: r, hr: s }), {};
|
|
1419
1419
|
}
|
|
@@ -1426,7 +1426,7 @@ class X {
|
|
|
1426
1426
|
* @private
|
|
1427
1427
|
*/
|
|
1428
1428
|
static tropicalCenterTwin(t, e = 24, n = {}) {
|
|
1429
|
-
var u, l, g, h,
|
|
1429
|
+
var u, l, g, h, p;
|
|
1430
1430
|
let i = {};
|
|
1431
1431
|
(u = t.forecasts) == null || u.forEach((S) => {
|
|
1432
1432
|
i = { ...S.hours, ...i };
|
|
@@ -1434,7 +1434,7 @@ class X {
|
|
|
1434
1434
|
const o = ((l = t == null ? void 0 : t.history) == null ? void 0 : l[0]) || (i == null ? void 0 : i[(g = Object.keys(i)) == null ? void 0 : g[0]]);
|
|
1435
1435
|
C == null || C.info("[%s] the first tropical center: %j", n.requestId, o);
|
|
1436
1436
|
let r = (h = Object.keys(i || {}).filter((S) => Number(S) <= (e < 0 ? 24 : e))) == null ? void 0 : h.at(-1);
|
|
1437
|
-
r || (r = (
|
|
1437
|
+
r || (r = (p = Object.keys(i || {}).filter((S) => Number(S) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : p.at(-1));
|
|
1438
1438
|
const s = i == null ? void 0 : i[r || -1];
|
|
1439
1439
|
C == null || C.info("[%s] the second tropical center: %j in %d hrs", n.requestId, s, r);
|
|
1440
1440
|
const c = Object.keys(i || {}).filter((S) => Number(S) <= Number(r)), a = { 0: o };
|
|
@@ -1483,11 +1483,11 @@ typeof globalThis < "u" && typeof globalThis.Buffer > "u" && (globalThis.Buffer
|
|
|
1483
1483
|
});
|
|
1484
1484
|
let x;
|
|
1485
1485
|
try {
|
|
1486
|
-
x =
|
|
1486
|
+
x = F.getLogger("meteo");
|
|
1487
1487
|
} catch {
|
|
1488
1488
|
} finally {
|
|
1489
1489
|
}
|
|
1490
|
-
function
|
|
1490
|
+
function X() {
|
|
1491
1491
|
if (typeof DOMParser < "u")
|
|
1492
1492
|
return new DOMParser();
|
|
1493
1493
|
const { JSDOM: D } = require("jsdom"), { DOMParser: t } = new D("").window;
|
|
@@ -1593,8 +1593,8 @@ class R {
|
|
|
1593
1593
|
const u = (n == null ? void 0 : n.units) || "nauticalmiles";
|
|
1594
1594
|
let l = n == null ? void 0 : n.radius;
|
|
1595
1595
|
if (!l) {
|
|
1596
|
-
const
|
|
1597
|
-
l = f.pointToLineDistance(c,
|
|
1596
|
+
const p = f.polygonToLine(t);
|
|
1597
|
+
l = f.pointToLineDistance(c, p, { units: u });
|
|
1598
1598
|
}
|
|
1599
1599
|
a = "end";
|
|
1600
1600
|
const g = ((o = n == null ? void 0 : n.end) == null ? void 0 : o.length) == 2 ? f.point(n.end) : f.destination(c, l, 90, { units: u });
|
|
@@ -1684,52 +1684,53 @@ class R {
|
|
|
1684
1684
|
}
|
|
1685
1685
|
/**
|
|
1686
1686
|
* 从 ZIP ArrayBuffer 中异步解析所有文件条目(浏览器 DecompressionStream)。
|
|
1687
|
+
* 使用 Central Directory 解析,避免 Data Descriptor 导致的大小不准问题。
|
|
1687
1688
|
*/
|
|
1688
1689
|
static async _parseZipEntries(t) {
|
|
1689
|
-
var
|
|
1690
|
+
var g;
|
|
1690
1691
|
const e = new Uint8Array(t), n = e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), i = new DataView(n), o = new Uint8Array(n), r = /* @__PURE__ */ new Map();
|
|
1691
|
-
let s =
|
|
1692
|
-
for (
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
if ((u & 8) !== 0 || g === 0) {
|
|
1697
|
-
let p = v;
|
|
1698
|
-
for (; p + 4 <= n.byteLength; ) {
|
|
1699
|
-
const N = i.getUint32(p, !0);
|
|
1700
|
-
if (N === 67324752 || N === 33639248)
|
|
1701
|
-
break;
|
|
1702
|
-
p++;
|
|
1703
|
-
}
|
|
1704
|
-
g = p - v;
|
|
1692
|
+
let s = -1;
|
|
1693
|
+
for (let h = n.byteLength - 22; h >= 0; h--)
|
|
1694
|
+
if (i.getUint32(h, !0) === 101010256) {
|
|
1695
|
+
s = h;
|
|
1696
|
+
break;
|
|
1705
1697
|
}
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1698
|
+
if (s < 0)
|
|
1699
|
+
throw new Error("Invalid ZIP file: EOCD not found");
|
|
1700
|
+
i.getUint16(s + 8, !0);
|
|
1701
|
+
const c = i.getUint32(s + 12, !0), a = i.getUint32(s + 16, !0);
|
|
1702
|
+
let u = a;
|
|
1703
|
+
const l = a + c;
|
|
1704
|
+
for (; u < l; ) {
|
|
1705
|
+
if (i.getUint32(u, !0) !== 33639248)
|
|
1706
|
+
throw new Error(`Invalid ZIP file: Central Directory signature mismatch at offset ${u}`);
|
|
1707
|
+
const p = i.getUint16(u + 10, !0), S = i.getUint32(u + 20, !0), m = i.getUint16(u + 28, !0), y = i.getUint16(u + 30, !0), P = i.getUint16(u + 32, !0), M = i.getUint32(u + 42, !0), T = o.slice(u + 46, u + 46 + m), N = new TextDecoder().decode(T), $ = i.getUint16(M + 26, !0), E = i.getUint16(M + 28, !0), O = M + 30 + $ + E, w = o.slice(O, O + S);
|
|
1708
|
+
if (p === 0)
|
|
1709
|
+
r.set(N, w);
|
|
1710
|
+
else if (p === 8) {
|
|
1710
1711
|
if (typeof DecompressionStream < "u") {
|
|
1711
|
-
const
|
|
1712
|
-
|
|
1713
|
-
const
|
|
1714
|
-
let
|
|
1712
|
+
const B = new DecompressionStream("deflate-raw"), k = B.writable.getWriter(), Z = B.readable.getReader();
|
|
1713
|
+
k.write(w), k.close();
|
|
1714
|
+
const W = [];
|
|
1715
|
+
let U = 0;
|
|
1715
1716
|
for (; ; ) {
|
|
1716
|
-
const { done:
|
|
1717
|
-
if (
|
|
1717
|
+
const { done: A, value: L } = await Z.read();
|
|
1718
|
+
if (A)
|
|
1718
1719
|
break;
|
|
1719
|
-
|
|
1720
|
+
W.push(L), U += L.length;
|
|
1720
1721
|
}
|
|
1721
|
-
const
|
|
1722
|
-
let
|
|
1723
|
-
for (const
|
|
1724
|
-
|
|
1725
|
-
r.set(
|
|
1726
|
-
} else if (typeof process < "u" && ((
|
|
1722
|
+
const q = new Uint8Array(U);
|
|
1723
|
+
let j = 0;
|
|
1724
|
+
for (const A of W)
|
|
1725
|
+
q.set(A, j), j += A.length;
|
|
1726
|
+
r.set(N, q);
|
|
1727
|
+
} else if (typeof process < "u" && ((g = process.versions) != null && g.node))
|
|
1727
1728
|
try {
|
|
1728
|
-
r.set(
|
|
1729
|
+
r.set(N, R._inflateRawSync(w));
|
|
1729
1730
|
} catch {
|
|
1730
1731
|
}
|
|
1731
1732
|
}
|
|
1732
|
-
|
|
1733
|
+
u += 46 + m + y + P;
|
|
1733
1734
|
}
|
|
1734
1735
|
return r;
|
|
1735
1736
|
}
|
|
@@ -1745,39 +1746,39 @@ class R {
|
|
|
1745
1746
|
static async convertKML2GeoJSON(t, e = {}) {
|
|
1746
1747
|
var s, c;
|
|
1747
1748
|
x.info("[%s] convert kml to geojson", e == null ? void 0 : e.requestId);
|
|
1748
|
-
const i =
|
|
1749
|
+
const i = X().parseFromString(t, "application/xml"), o = Array.from(i.querySelectorAll("Placemark")), r = [];
|
|
1749
1750
|
for (const a of o) {
|
|
1750
1751
|
const u = {}, l = Array.from(a.querySelectorAll("ExtendedData > Data"));
|
|
1751
|
-
for (const
|
|
1752
|
-
const N =
|
|
1752
|
+
for (const T of l) {
|
|
1753
|
+
const N = T.getAttribute("name"), $ = (c = (s = T.querySelector("value")) == null ? void 0 : s.textContent) == null ? void 0 : c.trim();
|
|
1753
1754
|
N && $ !== void 0 && $ !== null && (u[N] = $);
|
|
1754
1755
|
}
|
|
1755
|
-
const g = b.utc(), h = Object.keys(u).find((
|
|
1756
|
+
const g = b.utc(), h = Object.keys(u).find((T) => T.toLowerCase().indexOf("name") !== -1), p = h ? u[h] : void 0, S = `${g.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, m = (T) => T.trim().split(/[\s\n]+/).filter((N) => N.length > 0).map((N) => {
|
|
1756
1757
|
const $ = N.split(",").map(Number);
|
|
1757
1758
|
return [$[0], $[1]];
|
|
1758
|
-
}),
|
|
1759
|
-
if (
|
|
1760
|
-
const
|
|
1761
|
-
if (
|
|
1762
|
-
const N = f.lineString(
|
|
1759
|
+
}), y = a.querySelector("LineString > coordinates");
|
|
1760
|
+
if (y) {
|
|
1761
|
+
const T = m(y.textContent || "");
|
|
1762
|
+
if (T.length >= 2) {
|
|
1763
|
+
const N = f.lineString(T, { ...u, shape: "line", id: S, name: p });
|
|
1763
1764
|
r.push(N);
|
|
1764
1765
|
}
|
|
1765
1766
|
continue;
|
|
1766
1767
|
}
|
|
1767
1768
|
const P = a.querySelector("Polygon outerBoundaryIs LinearRing > coordinates");
|
|
1768
1769
|
if (P) {
|
|
1769
|
-
const
|
|
1770
|
-
if (
|
|
1771
|
-
const N =
|
|
1770
|
+
const T = m(P.textContent || "");
|
|
1771
|
+
if (T.length >= 4) {
|
|
1772
|
+
const N = T[0][0] === T[T.length - 1][0] && T[0][1] === T[T.length - 1][1] ? T : [...T, T[0]], $ = f.polygon([N], { ...u, shape: "polygon", id: S, name: p });
|
|
1772
1773
|
r.push($);
|
|
1773
1774
|
}
|
|
1774
1775
|
continue;
|
|
1775
1776
|
}
|
|
1776
1777
|
const M = a.querySelector("Point > coordinates");
|
|
1777
1778
|
if (M) {
|
|
1778
|
-
const
|
|
1779
|
-
if (
|
|
1780
|
-
const N = f.point(
|
|
1779
|
+
const T = m(M.textContent || "");
|
|
1780
|
+
if (T.length >= 1) {
|
|
1781
|
+
const N = f.point(T[0], { ...u, shape: "point", id: S, name: p });
|
|
1781
1782
|
r.push(N);
|
|
1782
1783
|
}
|
|
1783
1784
|
continue;
|
|
@@ -1835,7 +1836,7 @@ class R {
|
|
|
1835
1836
|
x.info("[%s] convert shp zip to geojson", e == null ? void 0 : e.requestId);
|
|
1836
1837
|
try {
|
|
1837
1838
|
typeof Buffer < "u" && Buffer.isBuffer(t) && (t = R.toArrayBuffer(t));
|
|
1838
|
-
const n = await
|
|
1839
|
+
const n = await z(t);
|
|
1839
1840
|
if (Array.isArray(n)) {
|
|
1840
1841
|
const i = n.flatMap((c) => c.features || []), o = b.utc(), r = (e == null ? void 0 : e.id) || o.valueOf().toString(), s = {
|
|
1841
1842
|
Point: "point",
|
|
@@ -1846,8 +1847,8 @@ class R {
|
|
|
1846
1847
|
MultiPolygon: "polygon"
|
|
1847
1848
|
};
|
|
1848
1849
|
return i.forEach((c, a) => {
|
|
1849
|
-
var
|
|
1850
|
-
const u = ((
|
|
1850
|
+
var p;
|
|
1851
|
+
const u = ((p = c.geometry) == null ? void 0 : p.type) || "", l = s[u] || u.toLowerCase();
|
|
1851
1852
|
c.properties = c.properties || {}, c.properties.shape = l, c.properties.parentId = r, c.properties.id = `${r}_${a}`;
|
|
1852
1853
|
const g = Object.keys(c.properties).find((S) => S.toLowerCase().indexOf("name") !== -1), h = g ? c.properties[g] : void 0;
|
|
1853
1854
|
c.properties.name = h || `${l}_${o.format()}_${a}`;
|
|
@@ -1860,9 +1861,9 @@ class R {
|
|
|
1860
1861
|
}
|
|
1861
1862
|
}
|
|
1862
1863
|
export {
|
|
1863
|
-
|
|
1864
|
+
J as AisHelper,
|
|
1864
1865
|
R as GeoJsonHelper,
|
|
1865
|
-
|
|
1866
|
+
v as LaneHelper,
|
|
1866
1867
|
d as LngLatHelper,
|
|
1867
|
-
|
|
1868
|
+
H as TropicalHelper
|
|
1868
1869
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function($,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("@turf/turf"),require("moment"),require("@log4js-node/log4js-api"),require("moment-timezone"),require("tz-lookup"),require("shpjs")):typeof define=="function"&&define.amd?define(["exports","@turf/turf","moment","@log4js-node/log4js-api","moment-timezone","tz-lookup","shpjs"],I):($=typeof globalThis<"u"?globalThis:$||self,I($["idm-plugin-rabbitmq"]={},$["@turf/turf"],$.moment,$["@log4js-node/log4js-api"],$["moment-timezone"],$["tz-lookup"],$.shpjs))})(this,function($,I,b,F,J,U,L){"use strict";function z(C){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(C){for(const t in C)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(C,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>C[t]})}}return e.default=C,Object.freeze(e)}const h=z(I);class d{static guessTimeZoneOffset(e,t){e=d.convertToStdLng(e);const n=U(t,e),i=b().tz(n).utcOffset();return d.roundPrecision(i/60,1)}static prettyTimeZoneOffset(e){let t=Math.floor(Math.abs(e)),n=Math.round((Math.abs(e)-t)*60);return n=n>9?n:`0${n}`,t=t>9?t:`0${t}`,e>0?`+${t}:${n}`:`-${t}:${n}`}static lng2pretty(e,t=6,n="H°M′"){e=d.convertToStdLng(e,t);let i="E";e<0&&(i="W"),e=Math.abs(e),n=n.toUpperCase();let o=e*3600,r,s,c,a,u,l;r=o%3600%60,n.indexOf("S")!==-1&&(o=o-r,s=d.padNumber(r,2,2)),c=o/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?a=d.roundPrecision(c,t).toString().padStart(2,"0"):a=d.padNumber(c,2,3),o=o-c*60),u=o/3600,n.indexOf("M")!==-1?l=d.roundPrecision(u,t).toString().padStart(3,"0"):l=d.padNumber(u,3,6),Number(s)>=60&&(a=Number(a)+1,s=0),Number(a)>=60&&(l=Number(l)+1,a=0);const g=`${n.replace(/S+/gi,s).replace(/M+/gi,a).replace(/H+/gi,l)}${i}`;return{direction:i,degree:d.roundPrecision(u,t),minute:d.roundPrecision(c,t),second:d.roundPrecision(r,t),pretty:g,S:s,M:a,H:l}}static lat2pretty(e,t=6,n="H°M′"){e=e%180;let i="N";e<0&&(i="S"),e=Math.abs(e),n=n.toUpperCase();let o=e*3600,r,s,c,a,u,l;r=o%3600%60,n.indexOf("S")!==-1&&(o=o-r,s=d.padNumber(r,2,2)),c=o/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?a=d.roundPrecision(c,t).toString().padStart(2,"0"):a=d.padNumber(c,2,3),o=o-c*60),u=o/3600,n.indexOf("M")!==-1?l=d.roundPrecision(u,t).toString().padStart(2,"0"):l=d.padNumber(u,2,6),Number(s)>=60&&(a=Number(a)+1,s=0),Number(a)>=60&&(l=Number(l)+1,a=0);const g=`${n.replace(/S+/gi,s).replace(/M+/gi,a).replace(/H+/gi,l)}${i}`;return{direction:i,degree:d.roundPrecision(u,t),minute:d.roundPrecision(c,t),second:d.roundPrecision(r,t),pretty:g,S:s,M:a,H:l}}static str2Lng(e,t=6){let n;if(isNaN(e)){e=d.strReplace(e,"LNG");const i=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const o=e.split(" ").filter(a=>a!=="").map(a=>Math.abs(Number(a)));let[r,s,c]=o;if(s=s||0,s=s>60?s/Math.pow(10,String(s).length-2):s,c=c||0,c=c>60?c/Math.pow(10,String(c).length-2):c,r>360&&!s){const a=this.roundPrecision(r/100,0);s=r-a*100,r=a}n=r+s/60+c/3600,i==="W"&&(n=n*-1)}else n=Number(e);return d.convertToStdLng(n,t)}static str2Lat(e,t=6){let n;if(isNaN(e)){e=d.strReplace(e,"LAT");const i=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const o=e.split(" ").filter(a=>a!=="").map(a=>Math.abs(Number(a)));let[r,s,c]=o;if(c=c||0,s=s||0,s=s>60?s/Math.pow(10,String(s).length-2):s,c=c>60?c/Math.pow(10,String(c).length-2):c,r>90&&!s){const a=this.roundPrecision(r/100,0);s=r-a*100,r=a}if(n=r+s/60+c/3600,n>90)throw new Error(`latitude out of range: ${e}${i}`);i==="S"&&(n=n*-1)}else n=Number(e);return d.roundPrecision(n,t)}static str2LngOrLat(e,t=6,n="LAT"){e=d.strReplace(e,n);const i=e[e.length-1].toUpperCase();return["N","S"].includes(i)?{lat:d.str2Lat(e,t)}:{lng:d.str2Lng(e,t)}}static convertToStdLng(e,t=6){return e>180?(e=e%360,e=e>180?e-360:e):e<-180&&(e=e%360,e=e<-180?e+360:e),d.roundPrecision(e,t)}static roundPrecision(e,t=6){const n=Number("1".padEnd(t+1,"0"));return Math.round(e*n)/n}static convertToMonotonicLng2(e){for(let t=1;t<e.length;t++)e[t][0]+=Math.round((e[t-1][0]-e[t][0])/360)*360;return e}static convertToMonotonicLng(e){for(let t=1;t<e.length;t++)e[t].lng+=Math.round((e[t-1].lng-e[t].lng)/360)*360;return e}static strReplace(e,t="LAT"){e=e.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g,"$1 $2").replace(/([0-9]+)-([0-9]+\.[0-9]+)/g,"$1 $2").replace(/°/," ").replace(/(\d+)-(\d?)/g,"$1 $2").replace(/'/g," ").replace(/′/g," ").replace(/"/g," ").replace(/∼/g," ").replace(/°/g," ").replace(/,/g,".").replace(/^ /g,"").replace(/ $/g,"").trim();const n=e[e.length-1].toUpperCase();if(!["N","S","E","W"].includes(n)){const i=e,o=Number(i.split(" ")[0]);if(isNaN(o))throw new Error(`invalid Lat/Lng: ${e}`);o>=90?e=`${i}E`:o<=-90?e=`${i}W`:["LAN","LNG"].includes(t==null?void 0:t.toUpperCase())?e=`${i}${o>0?"E":"W"}`:e=`${i}${o>0?"N":"S"}`}return e}static padNumber(e,t=2,n=2){const i=d.roundPrecision(e-Math.trunc(e),n),o=i>=1?Math.trunc(e+1).toString().padStart(t,"0"):Math.trunc(e).toString().padStart(t,"0");return i>=1?o:n>0?`${o}.${Math.trunc(i*Math.pow(10,n)).toString().padStart(n,"0")}`:o}}class B{static json2Str(e){const t=e.type?e.type[0].toUpperCase():"A";return`${e.lat}|${e.lng}|${e.positionTime}|${e.sog}|${e.cog}|${e.hdg}|${e.draught}|${t}|${JSON.stringify(e.meteo||{})}|${e.vendor}|${e.deleted}`}static str2Json(e){const[t,n,i,o,r,s,c,a,u,l,g]=e.split("|");return{lat:Number(t),lng:Number(n),positionTime:Number(i),sog:Number(o),cog:Number(r),hdg:Number(s),draught:isNaN(c)?null:Number(c),type:a,important:a!=="A",meteo:u?JSON.parse(u):void 0,vendor:l,deleted:g==="true"}}static inspectStoppages(e,t=1,n=!0){const i=e.at(0).positionTime<e.at(-1).positionTime;i||e.sort((c,a)=>c.positionTime-a.positionTime);const o=[];let r,s;for(let c=0;c<e.length-1;c++){const a=e[c];if(!(n&&["N","B","E","NOON","BOSP","EOSP"].includes(a.type))){for(let u=c+1;u<e.length;u++){const l=e[u-1],g=e[u];if(n&&["N","B","E","NOON","BOSP","EOSP"].includes(a.type))continue;const f=g.positionTime-l.positionTime;if(y.calculateDistance(g,l,!0,4)/(f/3600)<t)r||(r=a),u===e.length-1&&(s=g,c=u);else{r&&(s=e[u-1],c=u);break}}if((s==null?void 0:s.positionTime)>(r==null?void 0:r.positionTime)&&r){const u={start:{lat:r.lat,lng:r.lng,sog:r.sog,positionTime:r.positionTime,utc:b.unix(r.positionTime).utc().format()},end:{lat:s.lat,lng:s.lng,sog:s.sog,positionTime:s.positionTime,utc:b.unix(s.positionTime).utc().format()},duration:s.positionTime-r.positionTime},l=e.filter(f=>f.positionTime>=u.start.positionTime&&f.positionTime<=u.end.positionTime),g=y.divideAccordingToLng(l);u.distance=y.calculateRouteDistance(g),u.hours=Math.round(u.duration/3600*10)/10,u.avgSog=Math.round(u.distance/u.hours*10)/10,o.push(u)}r=void 0,s=void 0}}return i||e.sort((c,a)=>a.positionTime-c.positionTime),o}static inspectSummary(e,t,n){const i=b(t),o=b(n),r=e.filter(u=>u.positionTime>=i.unix()&&u.positionTime<=o.unix());let s=0,c=0;if(r.length>1)for(let u=0;u<r.length-1;u++){const l=r[u],g=r[u+1];s+=y.calculateDistance(l,g,!0,4),c+=Math.abs(g.positionTime-l.positionTime)}s=Math.round(s*100)/100,c=Math.round(c/3600*100)/100;const a=c?Math.round(s/c*100)/100:0;return{distance:s,interval:c,avgSpd:a}}}let A;try{A=F.getLogger("meteo")}catch{}finally{}class y{static calculateBearing(e,t,n=!0,i=4){const o=h.points([[e.lng,e.lat],[t.lng,t.lat]]);let r;return n?r=h.rhumbBearing(o.features[0],o.features[1]):r=h.bearing(o.features[0],o.features[1]),r<0&&(r+=360),d.roundPrecision(r,i)}static calculateDistance(e,t,n=!0,i=4,o="nauticalmiles"){e={...e},t={...t},e.lng=d.convertToStdLng(e.lng,i),t.lng=d.convertToStdLng(t.lng,i);const r=h.points([[e.lng,e.lat],[t.lng,t.lat]]);let s;return n?s=h.rhumbDistance(r.features[0],r.features[1],{units:o}):s=h.distance(r.features[0],r.features[1],{units:o}),d.roundPrecision(s,i)}static calculateRouteDistance(e,t=4,n="nauticalmiles"){let i=0,o;for(const r of e)for(let s=0;s<r.length-1;s++){const c={lng:r[s][0],lat:r[s][1]};s===0&&o&&(i+=this.calculateDistance(o,c,!0,t,n));const a={lng:r[s+1][0],lat:r[s+1][1]};i+=this.calculateDistance(c,a,!0,t,n),o=a}return d.roundPrecision(i,t)}static calculateCoordinate(e,t,n,i="nauticalmiles",o=!0){const r=h.point([e.lng,e.lat]);let s;o?s=h.rhumbDestination(r,n,t,{units:i}):s=h.destination(r,n,t,{units:i});const c=s.geometry.coordinates;return{lng:d.convertToStdLng(c[0],8),lat:d.roundPrecision(c[1],8)}}static interpolateCoordinates(e,t,n,i=!0,o=!0,r="nauticalmiles"){const s=[],c=this.calculateBearing(e,t,!1),a=this.calculateDistance(e,t,!1,8,r);i&&s.push({lng:e.lng,lat:e.lat});let u=0;for(;u<a;)u+=n,u<a&&s.push(this.calculateCoordinate(e,c,u,r,!1));return o&&s.push({lng:t.lng,lat:t.lat}),s}static divideAccordingToLng(e,t=!1,n=!0){if((e==null?void 0:e.length)<2)return[];e=n?this.deduplicateCoordinates(e):e;let i=[];const o=[];let r,s;for(let c=0;c<e.length-1;c++){r=d.convertToStdLng(e[c].lng,8),s=d.convertToStdLng(e[c+1].lng,8),e[c].lat=d.roundPrecision(e[c].lat,8),e[c+1].lat=d.roundPrecision(e[c+1].lat,8),i.push([r,e[c].lat]);const a=r-s;if(Math.abs(a)>180){const u=d.convertToMonotonicLng2([[r,e[c].lat],[s,e[c+1].lat]]);let l,g;t?(l=h.lineString(u),g=h.lineString([[a>0?180:-180,89],[a>0?180:-180,-89]])):(l=h.greatCircle(u[0],u[1]),g=h.greatCircle([a>0?180:-180,89],[a>0?180:-180,-89]));const f=h.lineIntersect(l,g);let T;if(f.features.length){const S=h.getCoord(f.features[0]);T=d.roundPrecision(S[1],8)}else T=e[c].lat;a>0?(i.push([180-1e-6,T]),o.push([...i]),i=[],i.push([-(180-1e-6),T])):(i.push([-(180-1e-6),T]),o.push([...i]),i=[],i.push([180-1e-6,T]))}c===e.length-2&&i.push([s,e[c+1].lat])}return o.push(i),o}static deduplicateRoute(e){const t=[];for(const n of e){const i=n.reduce((o,r)=>(o.findIndex(s=>s[0]===r[0]&&s[1]===r[1])===-1&&o.push(r),o),[]);t.push(i)}return t}static deduplicateCoordinates(e){return e.reduce((t,n)=>(t.findIndex(i=>i.lat===n.lat&&i.lng===n.lng)===-1&&t.push(n),t),[])}static removeCoordinateFromRoute(e,t){e.lng=d.convertToStdLng(e.lng,8);for(const n of t)for(let i=n.length-1;i>=0;i--)d.roundPrecision(n[i][0],8)===e.lng&&d.roundPrecision(n[i][1],8)===d.roundPrecision(e.lat,8)&&n.splice(i,1);return t}static removeCoordinateFromWaypoints(e,t){e.lng=d.convertToStdLng(e.lng,8);for(let n=t.length-1;n>=0;n--)d.roundPrecision(t[n].lng,8)===e.lng&&d.roundPrecision(t[n].lat,8)===d.roundPrecision(e.lat,8)&&t.splice(n,1);return t}static mergeCoordinateToRoute(e,t){e.lng=d.convertToStdLng(e.lng,8);let n=Number.MAX_VALUE,i=0,o=0,r,s;return t.forEach((c,a)=>{for(let u=0;u<c.length-1;u++){const l={lng:c[u][0],lat:c[u][1]},g={lng:c[u+1][0],lat:c[u+1][1]},f=this.calculatePointToLineDistance(e,l,g);n>f&&(n=f,o=u,i=a,r=this.calculateDistance(l,e),s=this.calculateDistance(g,e))}}),r!==0&&s!==0?t[i].splice(o+1,0,[e.lng,e.lat]):r===0?t[i].splice(o,1,[e.lng,e.lat]):s===0&&t[i].splice(o+1,1,[e.lng,e.lat]),t}static appendCoordinateToRoute(e,t){e.lng=d.convertToStdLng(e.lng,8);const n=y.convertRouteToCoordinates(t);return n.push(e),y.divideAccordingToLng(n)}static unshiftCoordinateToRoute(e,t){const n=y.convertRouteToCoordinates(t);return n.unshift(e),y.divideAccordingToLng(n)}static mergeWaypointsToRoute(e,t){for(const n of e)t=this.mergeCoordinateToRoute(n,t);return t}static calculateRangeRoute(e,t,n){n=this.mergeWaypointsToRoute([e,t],n);const i=[];let o=0;return n.forEach(r=>{if(o===2)return;const s=[];for(const c of r){if(d.roundPrecision(t.lng,8)===d.roundPrecision(c[0],8)&&d.roundPrecision(t.lat,8)===d.roundPrecision(c[1],8)){s.push(c),o===0&&s.push([e.lng,e.lat]),o=2;break}o===1?s.push(c):d.roundPrecision(e.lng,8)===d.roundPrecision(c[0],8)&&d.roundPrecision(e.lat,8)===d.roundPrecision(c[1],8)&&(o=1,s.push(c))}s.length&&i.push(s)}),i}static calculateRangeWaypoints(e,t,n,i=[]){const o=this.convertRouteToCoordinates(n,0),r=this.mergeCoordinatesToWaypoints([e,t],o.length?o:i),s=r.findIndex(u=>d.roundPrecision(e.lng,8)===d.roundPrecision(u.lng,8)&&d.roundPrecision(e.lat,8)===d.roundPrecision(u.lat,8)),c=r.findIndex(u=>d.roundPrecision(t.lng,8)===d.roundPrecision(u.lng,8)&&d.roundPrecision(t.lat,8)===d.roundPrecision(u.lat,8));return r.filter((u,l)=>l>=s&&l<=c)}static calculateMinDistanceToRoute(e,t){let n=Number.MAX_VALUE,i=0,o=0;return t.forEach((r,s)=>{for(let c=0;c<r.length-1;c++){const a={lng:r[c][0],lat:r[c][1]},u={lng:r[c+1][0],lat:r[c+1][1]},l=this.calculatePointToLineDistance(e,a,u);n>l&&(n=l,i=c,o=s)}}),{minDist:n,segIndex:o,minIndex:i}}static calculateSubRoute(e,t){const n=y.convertRouteToCoordinates(t);y.mergeCoordinateToWaypoints(e,n,!0),t=y.divideAccordingToLng(n);const{segIndex:i,minIndex:o}=this.calculateMinDistanceToRoute({...e},t);e.lng=d.convertToStdLng(e.lng);const r=[];let s=!0;for(let c=i;c<t.length;c++)if(s){const a=[];a.push([e.lng,e.lat]);for(let u=o+1;u<t[c].length;u++)e.lng===t[c][u][0]&&e.lat===t[c][u][1]||a.push(t[c][u]);r.push(a),s=!1}else r.push([...t[c]]);return r}static calculateSubWaypoints(e,t){let n=Number.MAX_VALUE,i=0;for(let r=0;r<t.length-1;r++){const s=t[r],c=t[r+1];if(this.calculateDistance(e,s)===0)return t;if(this.calculateDistance(e,c)===0)return t.filter((u,l)=>l>0);const a=this.calculatePointToLineDistance(e,s,c);n>a&&(n=a,i=r)}e.lng=d.convertToStdLng(e.lng);const o=[e];for(let r=i+1;r<t.length;r++)o.push(t[r]);return o}static calculatePointToLineDistance(e,t,n,i={units:"nauticalmiles",method:"geodesic"}){e.lng=d.convertToStdLng(e.lng,8),t={...t},n={...n},t.lng=d.convertToStdLng(t.lng,8),n.lng=d.convertToStdLng(n.lng,8);const o=d.convertToMonotonicLng([t,n]);t=o[0],n=o[1];const r=h.lineString([[t.lng,t.lat],[n.lng,n.lat]]),s=h.pointToLineDistance(h.point([e.lng,e.lat]),r,i),c=h.pointToLineDistance(h.point([e.lng>0?e.lng-360:e.lng+360,e.lat]),r,i);return d.roundPrecision(Math.min(s,c),6)}static calculateWaypointsPropInRoute(e,t){t=this.mergeWaypointsToRoute(e,t);for(let n=0;n<e.length-1;n++){const i=e[n],o=e[n+1],r=this.calculateRangeRoute(i,o,t);n===0&&(i.distanceFromPrevious=0,i.distanceFromStart=0),o.distanceFromPrevious=this.calculateRouteDistance(r),o.distanceFromStart=d.roundPrecision((i.distanceFromStart||0)+o.distanceFromPrevious)}return e}static mergeCoordinatesToWaypoints(e,t,n=!0){for(const i of e)this.mergeCoordinateToWaypoints(i,t,n);return t}static mergeCoordinateToWaypoints(e,t,n=!0){e.lng=d.convertToStdLng(e.lng,8);let i=Number.MAX_VALUE,o=0,r=0,s=0;if(t.length<2)t.push(e);else{for(let c=0;c<t.length-1;c++){const a={lng:t[c].lng,lat:t[c].lat},u={lng:t[c+1].lng,lat:t[c+1].lat},l=this.calculatePointToLineDistance(e,a,u);i>=l&&(i=l,o=c,r=this.calculateDistance(a,e,!1,6),s=this.calculateDistance(u,e,!1,6))}r!==0&&s!==0?r<=i&&o===0?t.unshift(e):s<=i&&o===t.length-2?t.push(e):t.splice(o+1,0,e):r===0?n?t.splice(o,1,e):t.splice(o+1,0,e):s===0&&(n?t.splice(o+1,1,e):t.splice(o+1,0,e))}return t.map((c,a)=>{c.lng=d.convertToStdLng(c.lng);const u=t[a+1];if(u&&((c.bearing===null||c.bearing===void 0)&&((c.positionTime||0)>(u.positionTime||0)?c.bearing=this.calculateBearing(u,c,!0):c.bearing=this.calculateBearing(c,u,!0)),c.cog=c.cog||c.bearing,!c.sog&&c.positionTime&&u.positionTime)){const l=this.calculateDistance(c,u,!0),g=Math.abs(u.positionTime-c.positionTime)/3600;c.sog=d.roundPrecision(l/g,2)}return c})}static generateRouteAccordingToWaypoints(e,t=!0,n=!0){const i=[];for(let o=1;o<e.length;o++){const r=e[o-1],s=e[o];if(o===1&&i.push(r),s.gcToPrevious){const c=this.interpolateCoordinates(r,s,200,!1,!0,"nauticalmiles");i.push(...c)}else i.push(s)}return this.divideAccordingToLng(i,t,n)}static nearestCoordinateInRoute(e,t){const n=h.point([e.lng,e.lat]),o=this.convertRouteToCoordinates(t).map(a=>[a.lng,a.lat]),r=h.lineString(o),s=h.nearestPointOnLine(r,n),c=h.getCoord(s);return{lng:d.roundPrecision(c[0],8),lat:d.roundPrecision(c[1],8)}}static calculatePrevWaypoint(e,t){let n=0;this.mergeCoordinateToWaypoints(e,t);for(let i=0;i<t.length-1;i++){const o=t[i],r=t[i+1];if(this.calculateDistance(e,o)===0){n=i;break}if(this.calculateDistance(e,r)===0){n=i+1;break}}return t[n===0?0:n-1]}static calculateNextCoordinateAlongRoute(e,t,n,i="nauticalmiles"){var g;const o=e.speed||12,r=[];let s=[],c=!1,a=0,u=0,l;if(t&&n.length?(r.push(e),n.forEach((f,T)=>{if(c)s.push(f);else{const S=[];let p;for(let v=0;v<f.length;v++)if(l)S.push(f[v]);else{p={lng:f[v][0],lat:f[v][1]};const P=this.calculateDistance(e,p,!0,8,i);if(a+=P,a<t)u+=P,P&&r.push(p),e=p;else{if(u=t,a===t)l=p,S.push([l.lng,l.lat]);else{const M=a-t,m=this.calculateBearing(p,e);l=this.calculateCoordinate(p,m,M,i),S.push([l.lng,l.lat]),S.push([p.lng,p.lat])}c=!0}}S.length&&s.push(S),T===n.length-1&&!l&&(l=p)}})):(s=n,l={...e}),l)if(r.push(l),l.distanceFromPrevious=Math.round(u*1e4)/1e4,l.hourFromPrevious=Math.round(u/o*1e4)/1e4,((g=s[0])==null?void 0:g.length)>1){const f={lng:s[0][1][0],lat:s[0][1][1]};l.bearing=this.calculateBearing(l,f)}else l.bearing=0;return{coordinate:l,nextRoute:s,prevRoute:r}}static nearestCoordinateInLine(e,t,n){const i=d.convertToStdLng(e.lng,6),o=h.point([i,e.lat]),r=d.convertToStdLng(t.lng,6),s=d.convertToStdLng(n.lng,6),c=h.lineString([[r,t.lat],[s,n.lat]]),a=h.nearestPointOnLine(c,o),u=h.getCoord(a),l=d.roundPrecision(u[0],6),g=d.roundPrecision(u[1],6);return{lng:l,lat:g,inline:!(l===r&&g===t.lat)&&!(l===s&&g===n.lat)}}static convertRouteToCoordinates(e,t=0){const n=[];let i,o;return e.forEach(r=>{r.forEach(s=>{const c={lng:d.roundPrecision(s[0],8),lat:d.roundPrecision(s[1],8)};if(!o)n.push(c),o=c;else if(o.bearing===void 0||o.bearing===null)o.bearing=this.calculateBearing(o,c,!0);else{const a=this.calculateDistance(i,c,!0);a&&a>=t&&(i.bearing=this.calculateBearing(i,c,!0),n.push(i),o=i)}i=c})}),i&&n.push(i),n}static simplifyRouteToCoordinates(e,t,n=1){let i=this.convertRouteToCoordinates(e,n);return i=this.simplifyGCCoordinates(i,t),i}static simplifyGCCoordinates(e,t){t.forEach(i=>{this.mergeCoordinateToWaypoints(i,e,!0)});for(let i=1;i<t.length;i++){const o=t[i-1],r=t[i];if(r.gcToPrevious){const s=e.findIndex(a=>a.lng===o.lng&&a.lat===o.lat),c=e.findIndex(a=>a.lng===r.lng&&a.lat===r.lat);for(let a=c-1;a>s;a--)e.splice(a,1)}}let n=0;for(let i=1;i<e.length;i++){const o=e[i-1],r=e[i];r.gcToPrevious?(o.bearing=this.calculateBearing(o,r,!1),r.distanceFromPrevious=this.calculateDistance(o,r,!1)):(o.bearing=this.calculateBearing(o,r,!0),r.distanceFromPrevious=this.calculateDistance(o,r,!0)),n=d.roundPrecision(n+r.distanceFromPrevious),r.distanceFromStart=n}return e.map(i=>(i.lng=d.convertToStdLng(i.lng),i))}static calculateCenter(e){const t=[];for(const s of e)for(const c of s)t.push(c);const n=h.featureCollection([]),i=d.convertToMonotonicLng2(t);for(const s of i)n.features.push(h.point(s));const r=h.center(n).geometry.coordinates;return{lng:d.convertToStdLng(r[0],8),lat:d.roundPrecision(r[1],8)}}static calculateCenter2(e){const t=this.generateRouteAccordingToWaypoints(e);return this.calculateCenter(t)}static calculateBBox(e){const t=[];for(const o of e)for(const r of o)t.push(r);const n=d.convertToMonotonicLng2(t),i=h.lineString(n);return h.bbox(i)}static calculateBBox2(e){const t=this.generateRouteAccordingToWaypoints(e);return this.calculateBBox(t)}static simplifyCoordinates(e,t=1,n=180){const i=[];for(let o=1;o<e.length;o++){const r=e[o-1],s=e[o],c=e[o+1];let a=!1,u=!1;if((r.velocity||r.suspend||r.important||r.pilot||o===1)&&(a=!0,i.push(r)),s.gcToPrevious&&(a||(a=!0,i.push(r)),u=!0,i.push(s),o++),c){const l=y.calculateDistance(r,s,!0),g=y.calculateDistance(s,c,!0),f=y.calculateDistance(r,c,!0),T=(Math.pow(l,2)+Math.pow(g,2)-Math.pow(f,2))/(2*l*g);Math.round(Math.acos(T)*180/Math.PI)<n&&f>t&&!u&&(i.push(s),o++)}if(o>=e.length-1){const l=e.at(-1);l&&i.push(l)}}return i}static nearestTSPointInWaypoints(e,t,n){const i=b.unix(e),o=n.filter(r=>i.clone().subtract(t,"hour").unix()<=(r.positionTime||0)&&i.clone().add(t,"h").unix()>=(r.positionTime||0));return o.sort((r,s)=>(r.positionTime||0)-(s.positionTime||0)),o.at(-1)}static deadReckoning(e,t){var o,r,s,c;e>1e12&&(e=Math.round(e/1e3));const n=b.unix(e);let i=t.find(a=>a.positionTime===n.unix());if(!i){const a=(r=(o=t.filter(l=>(l==null?void 0:l.positionTime)<n.unix()))==null?void 0:o.sort((l,g)=>(l.positionTime||0)-(g.positionTime||0)))==null?void 0:r.at(-1),u=(c=(s=t.filter(l=>(l==null?void 0:l.positionTime)>n.unix()))==null?void 0:s.sort((l,g)=>(l.positionTime||0)-(g.positionTime||0)))==null?void 0:c.at(0);if(a&&u){const l=y.calculateBearing(a,u,!0),g=y.calculateDistance(a,u),f=(n.unix()-a.positionTime)/(u.positionTime-a.positionTime);i=y.calculateCoordinate(a,l,g*f),i.positionTime=n.unix(),i.utc=n.utc().format(),i.cog=l,i.sog=Math.round(g/((u.positionTime-a.positionTime)/3600)*100)/100}else i=a||u,i&&(i.utc=b.unix(i==null?void 0:i.positionTime).utc().format())}return i}static deadReckoningTime(e,t){t=JSON.parse(JSON.stringify(t)),t.sort((a,u)=>(a.positionTime||0)-(u.positionTime||0));let n=Number.MAX_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER;for(let a=0;a<t.length-1;a++){const u=t[a],l=t[a+1],g=y.calculatePointToLineDistance(e,u,l);g<n&&(n=g,i=a)}const o=t[i],r=t[i+1],s=y.calculateDistance(o,e),c=y.calculateDistance(r,e);if(s===0)e=o;else if(c===0)e=r;else{const a=o.positionTime||0,u=r.positionTime||0,l=y.calculateDistance(o,r);e.positionTime=Math.round(a+(u-a)*(s/l))}return e.utc=e.positionTime?b.unix(e.positionTime).utc().format():void 0,e.positionTime?e:void 0}static reverseRoute(e){const t=[];for(const n of e)t.push(n.reverse());return t}static reverseCoordinates(e){return e.reverse()}static xmlEscape(e){return e==null?"":String(e).trim().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}static waypoints2RTZ(e,t){const i=[];return i.push('<?xml version="1.0" encoding="UTF-8"?>'),i.push('<route xmlns="http://www.cirm.org/RTZ/1/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2">'),i.push(` <routeInfo routeName="${y.xmlEscape(e)}"></routeInfo>`),i.push(...y.toRTZWaypoints(t,6)),i.push("</route>"),i.join(`
|
|
2
|
-
`)}static waypoints2RTZ10(e,
|
|
3
|
-
`)}static toRTZWaypoints(e
|
|
4
|
-
`)}static csvEscapeField(
|
|
5
|
-
`)||
|
|
6
|
-
`)}static coordinatesSummary(e,t=3){if(e.length>1){const n=e[0],i=e[e.length-1],o=(n==null?void 0:n.positionTime)<(i==null?void 0:i.positionTime)?b.unix(n==null?void 0:n.positionTime):b.unix(i==null?void 0:i.positionTime),r=(n==null?void 0:n.positionTime)>(i==null?void 0:i.positionTime)?b.unix(n==null?void 0:n.positionTime):b.unix(i==null?void 0:i.positionTime),s=Math.round(r.diff(o,"hours",!0)*100)/100,c=this.generateRouteAccordingToWaypoints(e,!0,!0),a=this.calculateRouteDistance(c),l=B.inspectStoppages(e,t).reduce((f,T)=>(f.duration+=T.duration,f.distance+=T.distance,f),{hours:0,distance:0,spd:0,duration:0});l.hours=Math.round(l.duration/3600*100)/100,l.distance=Math.round(l.distance*100)/100,l.spd=l.hours?Math.round(l.distance/l.hours*100)/100:0;const g=s?Math.round((a-l.distance)/(s-l.hours)*100)/100:0;return{begin:o.utc().format(),end:r.utc().format(),distance:Math.round((a-l.distance)*100)/100,hours:Math.round((s-l.hours)*100)/100,avgSpeed:g,stoppage:l}}return{begin:void 0,end:void 0,distance:0,hours:0,avgSpeed:0}}static pickUTCSampleFromSpeed(e,t){var u,l,g;if(!((l=(u=t==null?void 0:t.sample)==null?void 0:u.hours)!=null&&l.length))return{routes:[],hour:void 0};const n=t.sample.hours.at(0),i=b.utc(e),o=b.utc(t.eta),r=i.isAfter(o)?o:i;let s=t.sample.all.find(f=>f.eta===r.format());if(!s){const f=t.sample.all.filter(N=>b.utc(N.eta).isBefore(r)).at(-1),T=this.calculateSubRoute(f,t.route);s=(g=this.calculateNextCoordinateAlongRoute(f,f.speed*r.diff(b(f.etd),"hours",!0),T))==null?void 0:g.coordinate;const{cFactor:S,cog:p,wxFactor:v,meteo:P}=f,M=Math.round(s.distanceFromPrevious*1e4)/1e4,m=Math.round((M+f.distanceFromStart)*1e4)/1e4;s={...s,cFactor:S,cog:p,speed:f.speed,wxFactor:v,distanceFromStart:m,distanceFromPrevious:M,meteo:P,eta:r.format(),etd:r.format()}}s.distanceToGo=Math.round((t.distance-s.distanceFromStart)*100)/100,s.timeToGo=Math.round(o.diff(s.etd,"hours",!0)*100)/100;const c=this.calculateRangeWaypoints(n,s,t.route);return{routes:this.generateRouteAccordingToWaypoints(c),hour:s}}static pickUTCSampleFromRoute(e,t,n){var f;const i=this.calculateSubRoute(t,n),o=this.calculateRouteDistance(i),r=o/t.speed,s=b.utc(e),c=b(t.etd),a=(f=this.calculateNextCoordinateAlongRoute(t,t.speed*s.diff(b(t.etd),"hours",!0),i))==null?void 0:f.coordinate;a.speed=t.speed;const u=c.clone().add(a.hourFromPrevious,"hour");a.eta=Math.abs(u.diff(s,"second"))<2?s.format():u.format(),a.etd=a.eta,a.distanceFromStart=Math.round(a.distanceFromPrevious*100)/100,a.distanceToGo=Math.round((o-a.distanceFromStart)*100)/100,a.timeToGo=Math.round(c.clone().add(r,"hour").diff(b(a.etd),"hour")*100)/100;const l=this.calculateRangeWaypoints(t,a,n);return{routes:this.generateRouteAccordingToWaypoints(l),hour:a}}static includedAngle(e,t){A==null||A.debug("calculate bearing via: %j",{bearing:e,degree:t});let n=Math.abs(e%360-(t%360||0));return n=n>180?360-n:n,n}}let D;try{D=F.getLogger("vessel")}catch{}finally{}class Z{static convert2Geojson(e){var n,i,o;const t=h.featureCollection([]);for(const r of e){const s=(n=r.history)==null?void 0:n[0];if(r.forecasts){s&&s.wind&&(s.wind.kts=s.kts);for(const c of r.forecasts){let a;const u=[],l=[],g=b(c.date).utc(),f=`${r.name}-${c.model}`;for(const S in c==null?void 0:c.hours){const p=c.hours[S];a=a||p;const v=g.clone().add(Number(S),"hour"),P=h.point([p.lng,p.lat],{model:c.model,name:r.name,nameCn:r.nameCn,date:v.format(),hour:Number(S),format:v.format("MMM-DD/HHmm[Z]"),pressure:p.pressure>1e4?d.roundPrecision(p.pressure/100,0):d.roundPrecision(p.pressure,0),gusts:p.gusts,wind:p.wind||{},movement:p.movement,category:f,type:"forecast"});l.push(P),u.push(P.geometry.coordinates)}const T={kts:void 0,deg:void 0};if(s){const S=b(s.updated).utc();if(a){const v=y.calculateDistance(s,a),P=b(a.utc||a.updated).diff(S,"h",!0);T.kts=Math.round(v/P*100)/100,T.deg=y.calculateBearing(s,a,!0,0)}const p=h.point([s.lng,s.lat],{model:c.model,name:r.name,nameCn:r.nameCn,date:S.format(),hour:0,format:S.format("MMM-DD/HHmm[Z]"),pressure:s.pressure>1e4?d.roundPrecision((s==null?void 0:s.pressure)/100,0):d.roundPrecision(s.pressure,0),wind:s.wind,movement:T,category:f,type:"forecast",important:!0});l.unshift(p),u.unshift(p.geometry.coordinates)}if(t.features.push(...l),(u==null?void 0:u.length)>1){const S=h.lineString(d.convertToMonotonicLng2(u),{date:(s==null?void 0:s.updated)||(g==null?void 0:g.format()),id:r.id||r.name,model:c.model,name:r.name,category:f,type:"forecast",movement:T});t.features.push(S)}}}if(t.features.sort((c,a)=>c.properties.type==="forecast"&&a.properties.type==="forecast"&&c.geometry.type==="Point"&&a.geometry.type==="Point"?b(c.properties.date).valueOf()-b(a.properties.date).valueOf():0),(i=r.history)!=null&&i.length){const c=[],a=b(s==null?void 0:s.updated).utc(),u=b((o=r.history)==null?void 0:o.at(-1).updated).utc(),l=a.diff(u,"h")%24>2?24:12;for(const g of r.history){const f=b(g.updated).utc(),T=f.isSameOrBefore(a)||f.isSame(u);T&&a.add(-l,"h");const S=h.point([g.lng,g.lat],{name:r.name,nameCn:r.nameCn,date:f.format(),format:f.format("MMM-DD/HHmm[Z]"),pressure:g.pressure>1e4?d.roundPrecision(g.pressure/100,0):d.roundPrecision(g.pressure,0),kts:g.kts,level:g.type,type:"history",category:`${r.name}-history`,wind:g.wind,movement:g.movement,important:T});t.features.push(S),c.push(S.geometry.coordinates)}if(c.length===1&&c.push(c[0]),c.length>1){const g=h.lineString(d.convertToMonotonicLng2(c),{name:r.name,type:"history",updated:s==null?void 0:s.updated,pressure:(s==null?void 0:s.pressure)>1e4?d.roundPrecision((s==null?void 0:s.pressure)/100,0):d.roundPrecision(s==null?void 0:s.pressure,0),kts:s==null?void 0:s.kts,level:s==null?void 0:s.type});t.features.push(g)}}}return t}static interpolate(e,t=3){var o,r,s,c;const n=(o=e==null?void 0:e.data)==null?void 0:o.features.filter(a=>a.geometry.type==="LineString"&&a.properties.type==="forecast"),i=[];for(const a of n){const u=a.properties.name,l=a.properties.model,g=a.properties.showCircle,f=a.properties.disabled,T=b(a.properties.date).utc();let S=t*60;const p=(r=e==null?void 0:e.data)==null?void 0:r.features.filter(M=>M.geometry.type==="Point"&&M.properties.type==="forecast"&&M.properties.category===`${u}-${l}`);let v,P=T.clone().add(S,"minute").set({minute:0,second:0,millisecond:0});for(;v=this.pickIndex(p,P),v<=p.length-1;){if(v>0){const M=p[v],m=v===0?void 0:p[v-1],N=(S/60-((s=m==null?void 0:m.properties)==null?void 0:s.hour))/(M.properties.hour-((c=m==null?void 0:m.properties)==null?void 0:c.hour)),R=this.computeNumber(m==null?void 0:m.geometry.coordinates[0],M.geometry.coordinates[0],N),E=this.computeNumber(m==null?void 0:m.geometry.coordinates[1],M.geometry.coordinates[1],N),k=h.point([R,E],{name:u,model:l,category:M==null?void 0:M.properties.category,date:P.format(),format:P.format("MMM-DD/HHmm[Z]"),gusts:this.computeNumber(m==null?void 0:m.properties.gusts,M.properties.gusts,N),hour:this.computeNumber(m==null?void 0:m.properties.hour,M.properties.hour,N),movement:this.computeNumber(m==null?void 0:m.properties.movement,M.properties.movement,N),pressure:this.computeNumber(m==null?void 0:m.properties.pressure,M.properties.pressure,N),wind:this.computeNumber(m==null?void 0:m.properties.wind,M.properties.wind,N),type:"forecast",disabled:f,showCircle:g});i.push(k)}S+=t*60,P=T.clone().add(S,"minute").set({minute:0,second:0,millisecond:0})}}return i}static accelPassageAt(e,t){const{t1:n,t2:i,hr:o,hours:r}=this.tropicalCenterTwin(e,24,t);return{t1:n,t2:i,hr:o,hours:r}}static diversionPassageAt(e,t,n,i={}){const{t1:o,t2:r,hr:s,hours:c}=this.tropicalCenterTwin(t,24,i);if(o&&r){if(!i.debug){const T=y.calculateDistance(e,o),S=y.calculateDistance(e,r);if(T>2*n&&S>2*n)return D==null||D.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j",i.requestId,T,S,{from:e,t1:o,t2:r,hr:s}),{}}const a=y.calculateBearing(e,o),u=y.calculateBearing(o,r),l=Math.abs(a-u);let g=0;l<180?g=l+90:l>=180&&(g=l-90);const f=y.calculateCoordinate(o,g,n);return D==null||D.info("[%s] the right tangent position: %j",i.requestId,{from:e,t1:o,t2:r,radius:n,bearing1:a,bearing2:u,right:f}),{at:f,t1:o,t2:r,hr:Number(s),hours:c}}return{}}static driftPassageAt(e,t,n,i={}){const{t1:o,t2:r,hr:s,hours:c}=this.tropicalCenterTwin(t,24,i);if(o&&r){if(!i.debug){const f=y.calculateDistance(e,o),T=y.calculateDistance(e,r);if(f>2*n&&T>2*n)return D==null||D.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j",i.requestId,f,T,{from:e,t1:o,t2:r,hr:s}),{}}const a=y.calculateBearing(e,o),u=y.calculateBearing(o,r),l=y.calculateDistance(e,o);return{at:y.calculateCoordinate(o,a-u+180,n<l?n:l),t1:o,t2:r,hr:Number(s),hours:c}}else return D==null||D.info("[%s] no need drift: %j",i.requestId,{from:e,t1:o,t2:r,hr:s}),{}}static tropicalCenterTwin(e,t=24,n={}){var u,l,g,f,T;let i={};(u=e.forecasts)==null||u.forEach(S=>{i={...S.hours,...i}});const o=((l=e==null?void 0:e.history)==null?void 0:l[0])||(i==null?void 0:i[(g=Object.keys(i))==null?void 0:g[0]]);D==null||D.info("[%s] the first tropical center: %j",n.requestId,o);let r=(f=Object.keys(i||{}).filter(S=>Number(S)<=(t<0?24:t)))==null?void 0:f.at(-1);r||(r=(T=Object.keys(i||{}).filter(S=>Number(S)<=(t<0?24:2*t)))==null?void 0:T.at(-1));const s=i==null?void 0:i[r||-1];D==null||D.info("[%s] the second tropical center: %j in %d hrs",n.requestId,s,r);const c=Object.keys(i||{}).filter(S=>Number(S)<=Number(r)),a={0:o};for(const S of c)a[S]=i[S];return{t1:o,t2:s,hr:Number(r),hours:a}}static pickIndex(e,t){let n=0;for(const i of e){if(b(i.properties.date).isAfter(t))return n===0?-1:n;n++}return n}static computeNumber(e,t,n){if(e)if(t){if(isNaN(e)&&isNaN(t)&&typeof e!="string"&&typeof t!="string"){const i={};for(const o in e)i[o]=this.computeNumber(e[o],t[o],n);return i}return Math.round((e+(t-e)*n)*100)/100}else return e;else return t}}typeof globalThis<"u"&&typeof globalThis.Buffer>"u"&&(globalThis.Buffer={isBuffer(C){return C instanceof Uint8Array},from(C,e){if(typeof C=="string")return new TextEncoder().encode(C);if(C instanceof ArrayBuffer)return new Uint8Array(C);if(Array.isArray(C))return new Uint8Array(C);throw new TypeError("Buffer.from: unsupported source type")}});let x;try{x=F.getLogger("meteo")}catch{}finally{}function G(){if(typeof DOMParser<"u")return new DOMParser;const{JSDOM:C}=require("jsdom"),{DOMParser:e}=new C("").window;return new e}class O{static toArrayBuffer(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}static drawCircle(e,t,n,i={}){const o=(i==null?void 0:i.steps)??64,r=(i==null?void 0:i.units)??"nauticalmiles",s=(i==null?void 0:i.properties)??{},c=h.point([e,t]),a=h.destination(c,n,90,{units:r}),u=b.utc();s.id=(i==null?void 0:i.id)||u.valueOf().toString();const l="circle";return s.name=(i==null?void 0:i.name)||`${l}_${u.format()}`,s.radius=n,s.center=[e,t],s.end=a.geometry.coordinates.map(g=>d.roundPrecision(g,9)),s.units=r,s.steps=o,s.shape="circle",x.info("[%s] draw circle with %j",i==null?void 0:i.requestId,s),h.circle(c,n,{steps:o,units:r,properties:s})}static drawRect(e,t,n={}){const i=(n==null?void 0:n.properties)??{},o=b.utc();i.id=(n==null?void 0:n.id)||o.valueOf().toString();const r="rect";i.name=(n==null?void 0:n.name)||`${r}_${o.format()}`,i.start=e.map(u=>d.roundPrecision(u,9)),i.end=t.map(u=>d.roundPrecision(u,9)),i.shape="rect",x.info("[%s] draw rect with %j",n==null?void 0:n.requestId,i);const[s,c]=d.convertToMonotonicLng2([e,t]),a=[Math.min(s[0],c[0]),Math.min(s[1],c[1]),Math.max(s[0],c[0]),Math.max(s[1],c[1])];return h.bboxPolygon(a,{properties:i})}static drawLine(e,t={}){const n=(t==null?void 0:t.properties)??{},i=b.utc();n.id=(t==null?void 0:t.id)||i.valueOf().toString();const o="line";n.name=(t==null?void 0:t.name)||`${o}_${i.format()}`,n.shape="line",x.info("[%s] draw line with %j",t==null?void 0:t.requestId,n);const r=d.convertToMonotonicLng2(e);return h.lineString(r,n)}static drawPolygon(e,t={}){const n=(t==null?void 0:t.properties)??{},i=b.utc();n.id=(t==null?void 0:t.id)||i.valueOf().toString();const o="polygon";n.name=(t==null?void 0:t.name)||`${o}_${i.format()}`,n.coordinates=e.map(s=>s.map(c=>d.roundPrecision(c,9))),n.shape="polygon",x.info("[%s] draw polygon with %j",t==null?void 0:t.requestId,n);const r=d.convertToMonotonicLng2(e);return h.polygon([r],n)}static drawPoint(e,t,n={}){const i=(n==null?void 0:n.properties)??{},o=b.utc();i.id=(n==null?void 0:n.id)||o.valueOf().toString();const r="point";return i.name=(n==null?void 0:n.name)||`${r}_${o.format()}`,i.shape="point",x.info("[%s] draw point with %j",n==null?void 0:n.requestId,i),h.point([t,e],i)}static parseCircle(e,t={}){var i,o;x.info("[%s] parse circle with %j",t==null?void 0:t.requestId,e.properties);const n=e.properties||{};if(n.shape=="circle"){const r=b.utc();n.id=(n==null?void 0:n.id)||r.valueOf().toString();const s=n==null?void 0:n.id,c=((i=n==null?void 0:n.center)==null?void 0:i.length)==2?h.point(n.center):h.centroid(e);let a="center";c.properties={id:`${a}_${s}`,parentId:s,name:a};const u=(n==null?void 0:n.units)||"nauticalmiles";let l=n==null?void 0:n.radius;if(!l){const T=h.polygonToLine(e);l=h.pointToLineDistance(c,T,{units:u})}a="end";const g=((o=n==null?void 0:n.end)==null?void 0:o.length)==2?h.point(n.end):h.destination(c,l,90,{units:u});g.properties={id:`${a}_${s}`,parentId:s,name:a,radius:l,units:u};const f=h.lineString([c.geometry.coordinates,g.geometry.coordinates]);return a="edge",f.properties={id:`${a}_${s}`,parentId:s,name:a,radius:l,units:u},h.featureCollection([c,g,f,e])}else return x.warn("[%s] not a orm-std circle, just return the original feature",t==null?void 0:t.requestId),h.featureCollection([e])}static parseRect(e,t={}){x.info("[%s] parse rect with %j",t==null?void 0:t.requestId,e.properties);const n=e.properties||{};if(n.shape=="rect"){const i=b.utc();n.id=(n==null?void 0:n.id)||i.valueOf().toString();const o=n==null?void 0:n.id,r=e.geometry.coordinates[0],c=["sw","nw","ne","se"].map((a,u)=>{const l=h.point(r[u]);return l.properties={id:`${a}_${o}`,parentId:o,name:a},l});return h.featureCollection([...c,e])}else return x.warn("[%s] not a orm-std rect, just return the original feature",t==null?void 0:t.requestId),h.featureCollection([e])}static parseLine(e,t={}){x.info("[%s] parse line with %j",t==null?void 0:t.requestId,e.properties);const n=e.properties||{};if(n.shape=="line"){const i=b.utc();n.id=(n==null?void 0:n.id)||i.valueOf().toString();const o=n==null?void 0:n.id,s=e.geometry.coordinates.map((c,a)=>{const u=`point_${a}`,l=h.point(c);return l.properties={id:`${u}_${o}`,parentId:o,name:u,index:a},l});return h.featureCollection([...s,e])}else return x.warn("[%s] not a orm-std line, just return the original feature",t==null?void 0:t.requestId),h.featureCollection([e])}static parsePolygon(e,t={}){x.info("[%s] parse polygon with %j",t==null?void 0:t.requestId,e.properties);const n=e.properties||{};if(n.shape=="polygon"){const i=b.utc();n.id=(n==null?void 0:n.id)||i.valueOf().toString();const o=n==null?void 0:n.id,s=e.geometry.coordinates[0].map((c,a)=>{const u=h.point(c),l=`corner_${a}`;return u.properties={id:`${l}_${o}`,parentId:o,name:l,index:a},u});return h.featureCollection([...s,e])}else return x.warn("[%s] not a orm-std polygon, just return the original feature",t==null?void 0:t.requestId),h.featureCollection([e])}static _inflateRawSync(e){var t;if(typeof process<"u"&&((t=process.versions)!=null&&t.node)){const n=require("zlib");return new Uint8Array(n.inflateRawSync(Buffer.from(e)))}throw new Error("Sync inflate is not supported in browser; use the async convertKMZ2GeoJSONAsync / convertZIP2GeoJSONAsync instead")}static async _parseZipEntries(e){var c;const t=new Uint8Array(e),n=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),i=new DataView(n),o=new Uint8Array(n),r=new Map;let s=0;for(;s+4<=n.byteLength&&i.getUint32(s,!0)===67324752;){const u=i.getUint16(s+6,!0),l=i.getUint16(s+8,!0);let g=i.getUint32(s+18,!0);const f=i.getUint16(s+26,!0),T=i.getUint16(s+28,!0),S=o.slice(s+30,s+30+f),p=new TextDecoder().decode(S),v=s+30+f+T;if((u&8)!==0||g===0){let m=v;for(;m+4<=n.byteLength;){const N=i.getUint32(m,!0);if(N===67324752||N===33639248)break;m++}g=m-v}const M=o.slice(v,v+g);if(l===0)r.set(p,M);else if(l===8){if(typeof DecompressionStream<"u"){const m=new DecompressionStream("deflate-raw"),N=m.writable.getWriter(),R=m.readable.getReader();N.write(M),N.close();const E=[];let k=0;for(;;){const{done:w,value:W}=await R.read();if(w)break;E.push(W),k+=W.length}const j=new Uint8Array(k);let q=0;for(const w of E)j.set(w,q),q+=w.length;r.set(p,j)}else if(typeof process<"u"&&((c=process.versions)!=null&&c.node))try{r.set(p,O._inflateRawSync(M))}catch{}}s=v+g}return r}static async convertKML2GeoJSON(e,t={}){var s,c;x.info("[%s] convert kml to geojson",t==null?void 0:t.requestId);const i=G().parseFromString(e,"application/xml"),o=Array.from(i.querySelectorAll("Placemark")),r=[];for(const a of o){const u={},l=Array.from(a.querySelectorAll("ExtendedData > Data"));for(const m of l){const N=m.getAttribute("name"),R=(c=(s=m.querySelector("value"))==null?void 0:s.textContent)==null?void 0:c.trim();N&&R!==void 0&&R!==null&&(u[N]=R)}const g=b.utc(),f=Object.keys(u).find(m=>m.toLowerCase().indexOf("name")!==-1),T=f?u[f]:void 0,S=`${g.valueOf().toString()}_${Math.random().toString(36).slice(2,8)}`,p=m=>m.trim().split(/[\s\n]+/).filter(N=>N.length>0).map(N=>{const R=N.split(",").map(Number);return[R[0],R[1]]}),v=a.querySelector("LineString > coordinates");if(v){const m=p(v.textContent||"");if(m.length>=2){const N=h.lineString(m,{...u,shape:"line",id:S,name:T});r.push(N)}continue}const P=a.querySelector("Polygon outerBoundaryIs LinearRing > coordinates");if(P){const m=p(P.textContent||"");if(m.length>=4){const N=m[0][0]===m[m.length-1][0]&&m[0][1]===m[m.length-1][1]?m:[...m,m[0]],R=h.polygon([N],{...u,shape:"polygon",id:S,name:T});r.push(R)}continue}const M=a.querySelector("Point > coordinates");if(M){const m=p(M.textContent||"");if(m.length>=1){const N=h.point(m[0],{...u,shape:"point",id:S,name:T});r.push(N)}continue}}return h.featureCollection(r)}static async convertKMZ2GeoJSON(e,t={}){var r;x.info("[%s] convert kmz to geojson (async)",t==null?void 0:t.requestId),typeof Buffer<"u"&&Buffer.isBuffer(e)&&(e=O.toArrayBuffer(e));const n=await O._parseZipEntries(e),i=n.get("doc.kml")??((r=[...n.entries()].find(([s])=>s.toLowerCase().endsWith(".kml")))==null?void 0:r[1]);if(!i)return x.warn("[%s] no .kml file found in kmz",t==null?void 0:t.requestId),h.featureCollection([]);const o=new TextDecoder().decode(i);return O.convertKML2GeoJSON(o,t)}static async convertZIP2GeoJSON(e,t={}){x.info("[%s] convert zip to geojson (async)",t==null?void 0:t.requestId),typeof Buffer<"u"&&Buffer.isBuffer(e)&&(e=O.toArrayBuffer(e));const n=await O._parseZipEntries(e),i=[];for(const[o,r]of n){if(!o.toLowerCase().endsWith(".kml"))continue;const s=new TextDecoder().decode(r),c=await O.convertKML2GeoJSON(s,t);i.push(...c.features)}return i.length===0?(x.warn("[%s] no .kml files found in zip",t==null?void 0:t.requestId),this.convertSHP2GeoJSON(e,t)):h.featureCollection(i)}static async convertSHP2GeoJSON(e,t={}){x.info("[%s] convert shp zip to geojson",t==null?void 0:t.requestId);try{typeof Buffer<"u"&&Buffer.isBuffer(e)&&(e=O.toArrayBuffer(e));const n=await L(e);if(Array.isArray(n)){const i=n.flatMap(c=>c.features||[]),o=b.utc(),r=(t==null?void 0:t.id)||o.valueOf().toString(),s={Point:"point",MultiPoint:"point",LineString:"line",MultiLineString:"line",Polygon:"polygon",MultiPolygon:"polygon"};return i.forEach((c,a)=>{var T;const u=((T=c.geometry)==null?void 0:T.type)||"",l=s[u]||u.toLowerCase();c.properties=c.properties||{},c.properties.shape=l,c.properties.parentId=r,c.properties.id=`${r}_${a}`;const g=Object.keys(c.properties).find(S=>S.toLowerCase().indexOf("name")!==-1),f=g?c.properties[g]:void 0;c.properties.name=f||`${l}_${o.format()}_${a}`}),h.featureCollection(i)}return n}catch(n){return x.warn("[%s] failed to convert shp zip: %s",t==null?void 0:t.requestId,n),h.featureCollection([])}}}$.AisHelper=B,$.GeoJsonHelper=O,$.LaneHelper=y,$.LngLatHelper=d,$.TropicalHelper=Z,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function($,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("@turf/turf"),require("moment"),require("@log4js-node/log4js-api"),require("moment-timezone"),require("tz-lookup"),require("shpjs")):typeof define=="function"&&define.amd?define(["exports","@turf/turf","moment","@log4js-node/log4js-api","moment-timezone","tz-lookup","shpjs"],I):($=typeof globalThis<"u"?globalThis:$||self,I($["idm-plugin-rabbitmq"]={},$["@turf/turf"],$.moment,$["@log4js-node/log4js-api"],$["moment-timezone"],$["tz-lookup"],$.shpjs))})(this,function($,I,b,k,_,J,X){"use strict";function V(C){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(C){for(const e in C)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(C,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>C[e]})}}return t.default=C,Object.freeze(t)}const h=V(I);class d{static guessTimeZoneOffset(t,e){t=d.convertToStdLng(t);const n=J(e,t),i=b().tz(n).utcOffset();return d.roundPrecision(i/60,1)}static prettyTimeZoneOffset(t){let e=Math.floor(Math.abs(t)),n=Math.round((Math.abs(t)-e)*60);return n=n>9?n:`0${n}`,e=e>9?e:`0${e}`,t>0?`+${e}:${n}`:`-${e}:${n}`}static lng2pretty(t,e=6,n="H°M′"){t=d.convertToStdLng(t,e);let i="E";t<0&&(i="W"),t=Math.abs(t),n=n.toUpperCase();let o=t*3600,r,s,c,a,u,l;r=o%3600%60,n.indexOf("S")!==-1&&(o=o-r,s=d.padNumber(r,2,2)),c=o/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?a=d.roundPrecision(c,e).toString().padStart(2,"0"):a=d.padNumber(c,2,3),o=o-c*60),u=o/3600,n.indexOf("M")!==-1?l=d.roundPrecision(u,e).toString().padStart(3,"0"):l=d.padNumber(u,3,6),Number(s)>=60&&(a=Number(a)+1,s=0),Number(a)>=60&&(l=Number(l)+1,a=0);const g=`${n.replace(/S+/gi,s).replace(/M+/gi,a).replace(/H+/gi,l)}${i}`;return{direction:i,degree:d.roundPrecision(u,e),minute:d.roundPrecision(c,e),second:d.roundPrecision(r,e),pretty:g,S:s,M:a,H:l}}static lat2pretty(t,e=6,n="H°M′"){t=t%180;let i="N";t<0&&(i="S"),t=Math.abs(t),n=n.toUpperCase();let o=t*3600,r,s,c,a,u,l;r=o%3600%60,n.indexOf("S")!==-1&&(o=o-r,s=d.padNumber(r,2,2)),c=o/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?a=d.roundPrecision(c,e).toString().padStart(2,"0"):a=d.padNumber(c,2,3),o=o-c*60),u=o/3600,n.indexOf("M")!==-1?l=d.roundPrecision(u,e).toString().padStart(2,"0"):l=d.padNumber(u,2,6),Number(s)>=60&&(a=Number(a)+1,s=0),Number(a)>=60&&(l=Number(l)+1,a=0);const g=`${n.replace(/S+/gi,s).replace(/M+/gi,a).replace(/H+/gi,l)}${i}`;return{direction:i,degree:d.roundPrecision(u,e),minute:d.roundPrecision(c,e),second:d.roundPrecision(r,e),pretty:g,S:s,M:a,H:l}}static str2Lng(t,e=6){let n;if(isNaN(t)){t=d.strReplace(t,"LNG");const i=t[t.length-1].toUpperCase();t=t.substring(0,t.length-1).trim();const o=t.split(" ").filter(a=>a!=="").map(a=>Math.abs(Number(a)));let[r,s,c]=o;if(s=s||0,s=s>60?s/Math.pow(10,String(s).length-2):s,c=c||0,c=c>60?c/Math.pow(10,String(c).length-2):c,r>360&&!s){const a=this.roundPrecision(r/100,0);s=r-a*100,r=a}n=r+s/60+c/3600,i==="W"&&(n=n*-1)}else n=Number(t);return d.convertToStdLng(n,e)}static str2Lat(t,e=6){let n;if(isNaN(t)){t=d.strReplace(t,"LAT");const i=t[t.length-1].toUpperCase();t=t.substring(0,t.length-1).trim();const o=t.split(" ").filter(a=>a!=="").map(a=>Math.abs(Number(a)));let[r,s,c]=o;if(c=c||0,s=s||0,s=s>60?s/Math.pow(10,String(s).length-2):s,c=c>60?c/Math.pow(10,String(c).length-2):c,r>90&&!s){const a=this.roundPrecision(r/100,0);s=r-a*100,r=a}if(n=r+s/60+c/3600,n>90)throw new Error(`latitude out of range: ${t}${i}`);i==="S"&&(n=n*-1)}else n=Number(t);return d.roundPrecision(n,e)}static str2LngOrLat(t,e=6,n="LAT"){t=d.strReplace(t,n);const i=t[t.length-1].toUpperCase();return["N","S"].includes(i)?{lat:d.str2Lat(t,e)}:{lng:d.str2Lng(t,e)}}static convertToStdLng(t,e=6){return t>180?(t=t%360,t=t>180?t-360:t):t<-180&&(t=t%360,t=t<-180?t+360:t),d.roundPrecision(t,e)}static roundPrecision(t,e=6){const n=Number("1".padEnd(e+1,"0"));return Math.round(t*n)/n}static convertToMonotonicLng2(t){for(let e=1;e<t.length;e++)t[e][0]+=Math.round((t[e-1][0]-t[e][0])/360)*360;return t}static convertToMonotonicLng(t){for(let e=1;e<t.length;e++)t[e].lng+=Math.round((t[e-1].lng-t[e].lng)/360)*360;return t}static strReplace(t,e="LAT"){t=t.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g,"$1 $2").replace(/([0-9]+)-([0-9]+\.[0-9]+)/g,"$1 $2").replace(/°/," ").replace(/(\d+)-(\d?)/g,"$1 $2").replace(/'/g," ").replace(/′/g," ").replace(/"/g," ").replace(/∼/g," ").replace(/°/g," ").replace(/,/g,".").replace(/^ /g,"").replace(/ $/g,"").trim();const n=t[t.length-1].toUpperCase();if(!["N","S","E","W"].includes(n)){const i=t,o=Number(i.split(" ")[0]);if(isNaN(o))throw new Error(`invalid Lat/Lng: ${t}`);o>=90?t=`${i}E`:o<=-90?t=`${i}W`:["LAN","LNG"].includes(e==null?void 0:e.toUpperCase())?t=`${i}${o>0?"E":"W"}`:t=`${i}${o>0?"N":"S"}`}return t}static padNumber(t,e=2,n=2){const i=d.roundPrecision(t-Math.trunc(t),n),o=i>=1?Math.trunc(t+1).toString().padStart(e,"0"):Math.trunc(t).toString().padStart(e,"0");return i>=1?o:n>0?`${o}.${Math.trunc(i*Math.pow(10,n)).toString().padStart(n,"0")}`:o}}class j{static json2Str(t){const e=t.type?t.type[0].toUpperCase():"A";return`${t.lat}|${t.lng}|${t.positionTime}|${t.sog}|${t.cog}|${t.hdg}|${t.draught}|${e}|${JSON.stringify(t.meteo||{})}|${t.vendor}|${t.deleted}`}static str2Json(t){const[e,n,i,o,r,s,c,a,u,l,g]=t.split("|");return{lat:Number(e),lng:Number(n),positionTime:Number(i),sog:Number(o),cog:Number(r),hdg:Number(s),draught:isNaN(c)?null:Number(c),type:a,important:a!=="A",meteo:u?JSON.parse(u):void 0,vendor:l,deleted:g==="true"}}static inspectStoppages(t,e=1,n=!0){const i=t.at(0).positionTime<t.at(-1).positionTime;i||t.sort((c,a)=>c.positionTime-a.positionTime);const o=[];let r,s;for(let c=0;c<t.length-1;c++){const a=t[c];if(!(n&&["N","B","E","NOON","BOSP","EOSP"].includes(a.type))){for(let u=c+1;u<t.length;u++){const l=t[u-1],g=t[u];if(n&&["N","B","E","NOON","BOSP","EOSP"].includes(a.type))continue;const f=g.positionTime-l.positionTime;if(y.calculateDistance(g,l,!0,4)/(f/3600)<e)r||(r=a),u===t.length-1&&(s=g,c=u);else{r&&(s=t[u-1],c=u);break}}if((s==null?void 0:s.positionTime)>(r==null?void 0:r.positionTime)&&r){const u={start:{lat:r.lat,lng:r.lng,sog:r.sog,positionTime:r.positionTime,utc:b.unix(r.positionTime).utc().format()},end:{lat:s.lat,lng:s.lng,sog:s.sog,positionTime:s.positionTime,utc:b.unix(s.positionTime).utc().format()},duration:s.positionTime-r.positionTime},l=t.filter(f=>f.positionTime>=u.start.positionTime&&f.positionTime<=u.end.positionTime),g=y.divideAccordingToLng(l);u.distance=y.calculateRouteDistance(g),u.hours=Math.round(u.duration/3600*10)/10,u.avgSog=Math.round(u.distance/u.hours*10)/10,o.push(u)}r=void 0,s=void 0}}return i||t.sort((c,a)=>a.positionTime-c.positionTime),o}static inspectSummary(t,e,n){const i=b(e),o=b(n),r=t.filter(u=>u.positionTime>=i.unix()&&u.positionTime<=o.unix());let s=0,c=0;if(r.length>1)for(let u=0;u<r.length-1;u++){const l=r[u],g=r[u+1];s+=y.calculateDistance(l,g,!0,4),c+=Math.abs(g.positionTime-l.positionTime)}s=Math.round(s*100)/100,c=Math.round(c/3600*100)/100;const a=c?Math.round(s/c*100)/100:0;return{distance:s,interval:c,avgSpd:a}}}let A;try{A=k.getLogger("meteo")}catch{}finally{}class y{static calculateBearing(t,e,n=!0,i=4){const o=h.points([[t.lng,t.lat],[e.lng,e.lat]]);let r;return n?r=h.rhumbBearing(o.features[0],o.features[1]):r=h.bearing(o.features[0],o.features[1]),r<0&&(r+=360),d.roundPrecision(r,i)}static calculateDistance(t,e,n=!0,i=4,o="nauticalmiles"){t={...t},e={...e},t.lng=d.convertToStdLng(t.lng,i),e.lng=d.convertToStdLng(e.lng,i);const r=h.points([[t.lng,t.lat],[e.lng,e.lat]]);let s;return n?s=h.rhumbDistance(r.features[0],r.features[1],{units:o}):s=h.distance(r.features[0],r.features[1],{units:o}),d.roundPrecision(s,i)}static calculateRouteDistance(t,e=4,n="nauticalmiles"){let i=0,o;for(const r of t)for(let s=0;s<r.length-1;s++){const c={lng:r[s][0],lat:r[s][1]};s===0&&o&&(i+=this.calculateDistance(o,c,!0,e,n));const a={lng:r[s+1][0],lat:r[s+1][1]};i+=this.calculateDistance(c,a,!0,e,n),o=a}return d.roundPrecision(i,e)}static calculateCoordinate(t,e,n,i="nauticalmiles",o=!0){const r=h.point([t.lng,t.lat]);let s;o?s=h.rhumbDestination(r,n,e,{units:i}):s=h.destination(r,n,e,{units:i});const c=s.geometry.coordinates;return{lng:d.convertToStdLng(c[0],8),lat:d.roundPrecision(c[1],8)}}static interpolateCoordinates(t,e,n,i=!0,o=!0,r="nauticalmiles"){const s=[],c=this.calculateBearing(t,e,!1),a=this.calculateDistance(t,e,!1,8,r);i&&s.push({lng:t.lng,lat:t.lat});let u=0;for(;u<a;)u+=n,u<a&&s.push(this.calculateCoordinate(t,c,u,r,!1));return o&&s.push({lng:e.lng,lat:e.lat}),s}static divideAccordingToLng(t,e=!1,n=!0){if((t==null?void 0:t.length)<2)return[];t=n?this.deduplicateCoordinates(t):t;let i=[];const o=[];let r,s;for(let c=0;c<t.length-1;c++){r=d.convertToStdLng(t[c].lng,8),s=d.convertToStdLng(t[c+1].lng,8),t[c].lat=d.roundPrecision(t[c].lat,8),t[c+1].lat=d.roundPrecision(t[c+1].lat,8),i.push([r,t[c].lat]);const a=r-s;if(Math.abs(a)>180){const u=d.convertToMonotonicLng2([[r,t[c].lat],[s,t[c+1].lat]]);let l,g;e?(l=h.lineString(u),g=h.lineString([[a>0?180:-180,89],[a>0?180:-180,-89]])):(l=h.greatCircle(u[0],u[1]),g=h.greatCircle([a>0?180:-180,89],[a>0?180:-180,-89]));const f=h.lineIntersect(l,g);let m;if(f.features.length){const S=h.getCoord(f.features[0]);m=d.roundPrecision(S[1],8)}else m=t[c].lat;a>0?(i.push([180-1e-6,m]),o.push([...i]),i=[],i.push([-(180-1e-6),m])):(i.push([-(180-1e-6),m]),o.push([...i]),i=[],i.push([180-1e-6,m]))}c===t.length-2&&i.push([s,t[c+1].lat])}return o.push(i),o}static deduplicateRoute(t){const e=[];for(const n of t){const i=n.reduce((o,r)=>(o.findIndex(s=>s[0]===r[0]&&s[1]===r[1])===-1&&o.push(r),o),[]);e.push(i)}return e}static deduplicateCoordinates(t){return t.reduce((e,n)=>(e.findIndex(i=>i.lat===n.lat&&i.lng===n.lng)===-1&&e.push(n),e),[])}static removeCoordinateFromRoute(t,e){t.lng=d.convertToStdLng(t.lng,8);for(const n of e)for(let i=n.length-1;i>=0;i--)d.roundPrecision(n[i][0],8)===t.lng&&d.roundPrecision(n[i][1],8)===d.roundPrecision(t.lat,8)&&n.splice(i,1);return e}static removeCoordinateFromWaypoints(t,e){t.lng=d.convertToStdLng(t.lng,8);for(let n=e.length-1;n>=0;n--)d.roundPrecision(e[n].lng,8)===t.lng&&d.roundPrecision(e[n].lat,8)===d.roundPrecision(t.lat,8)&&e.splice(n,1);return e}static mergeCoordinateToRoute(t,e){t.lng=d.convertToStdLng(t.lng,8);let n=Number.MAX_VALUE,i=0,o=0,r,s;return e.forEach((c,a)=>{for(let u=0;u<c.length-1;u++){const l={lng:c[u][0],lat:c[u][1]},g={lng:c[u+1][0],lat:c[u+1][1]},f=this.calculatePointToLineDistance(t,l,g);n>f&&(n=f,o=u,i=a,r=this.calculateDistance(l,t),s=this.calculateDistance(g,t))}}),r!==0&&s!==0?e[i].splice(o+1,0,[t.lng,t.lat]):r===0?e[i].splice(o,1,[t.lng,t.lat]):s===0&&e[i].splice(o+1,1,[t.lng,t.lat]),e}static appendCoordinateToRoute(t,e){t.lng=d.convertToStdLng(t.lng,8);const n=y.convertRouteToCoordinates(e);return n.push(t),y.divideAccordingToLng(n)}static unshiftCoordinateToRoute(t,e){const n=y.convertRouteToCoordinates(e);return n.unshift(t),y.divideAccordingToLng(n)}static mergeWaypointsToRoute(t,e){for(const n of t)e=this.mergeCoordinateToRoute(n,e);return e}static calculateRangeRoute(t,e,n){n=this.mergeWaypointsToRoute([t,e],n);const i=[];let o=0;return n.forEach(r=>{if(o===2)return;const s=[];for(const c of r){if(d.roundPrecision(e.lng,8)===d.roundPrecision(c[0],8)&&d.roundPrecision(e.lat,8)===d.roundPrecision(c[1],8)){s.push(c),o===0&&s.push([t.lng,t.lat]),o=2;break}o===1?s.push(c):d.roundPrecision(t.lng,8)===d.roundPrecision(c[0],8)&&d.roundPrecision(t.lat,8)===d.roundPrecision(c[1],8)&&(o=1,s.push(c))}s.length&&i.push(s)}),i}static calculateRangeWaypoints(t,e,n,i=[]){const o=this.convertRouteToCoordinates(n,0),r=this.mergeCoordinatesToWaypoints([t,e],o.length?o:i),s=r.findIndex(u=>d.roundPrecision(t.lng,8)===d.roundPrecision(u.lng,8)&&d.roundPrecision(t.lat,8)===d.roundPrecision(u.lat,8)),c=r.findIndex(u=>d.roundPrecision(e.lng,8)===d.roundPrecision(u.lng,8)&&d.roundPrecision(e.lat,8)===d.roundPrecision(u.lat,8));return r.filter((u,l)=>l>=s&&l<=c)}static calculateMinDistanceToRoute(t,e){let n=Number.MAX_VALUE,i=0,o=0;return e.forEach((r,s)=>{for(let c=0;c<r.length-1;c++){const a={lng:r[c][0],lat:r[c][1]},u={lng:r[c+1][0],lat:r[c+1][1]},l=this.calculatePointToLineDistance(t,a,u);n>l&&(n=l,i=c,o=s)}}),{minDist:n,segIndex:o,minIndex:i}}static calculateSubRoute(t,e){const n=y.convertRouteToCoordinates(e);y.mergeCoordinateToWaypoints(t,n,!0),e=y.divideAccordingToLng(n);const{segIndex:i,minIndex:o}=this.calculateMinDistanceToRoute({...t},e);t.lng=d.convertToStdLng(t.lng);const r=[];let s=!0;for(let c=i;c<e.length;c++)if(s){const a=[];a.push([t.lng,t.lat]);for(let u=o+1;u<e[c].length;u++)t.lng===e[c][u][0]&&t.lat===e[c][u][1]||a.push(e[c][u]);r.push(a),s=!1}else r.push([...e[c]]);return r}static calculateSubWaypoints(t,e){let n=Number.MAX_VALUE,i=0;for(let r=0;r<e.length-1;r++){const s=e[r],c=e[r+1];if(this.calculateDistance(t,s)===0)return e;if(this.calculateDistance(t,c)===0)return e.filter((u,l)=>l>0);const a=this.calculatePointToLineDistance(t,s,c);n>a&&(n=a,i=r)}t.lng=d.convertToStdLng(t.lng);const o=[t];for(let r=i+1;r<e.length;r++)o.push(e[r]);return o}static calculatePointToLineDistance(t,e,n,i={units:"nauticalmiles",method:"geodesic"}){t.lng=d.convertToStdLng(t.lng,8),e={...e},n={...n},e.lng=d.convertToStdLng(e.lng,8),n.lng=d.convertToStdLng(n.lng,8);const o=d.convertToMonotonicLng([e,n]);e=o[0],n=o[1];const r=h.lineString([[e.lng,e.lat],[n.lng,n.lat]]),s=h.pointToLineDistance(h.point([t.lng,t.lat]),r,i),c=h.pointToLineDistance(h.point([t.lng>0?t.lng-360:t.lng+360,t.lat]),r,i);return d.roundPrecision(Math.min(s,c),6)}static calculateWaypointsPropInRoute(t,e){e=this.mergeWaypointsToRoute(t,e);for(let n=0;n<t.length-1;n++){const i=t[n],o=t[n+1],r=this.calculateRangeRoute(i,o,e);n===0&&(i.distanceFromPrevious=0,i.distanceFromStart=0),o.distanceFromPrevious=this.calculateRouteDistance(r),o.distanceFromStart=d.roundPrecision((i.distanceFromStart||0)+o.distanceFromPrevious)}return t}static mergeCoordinatesToWaypoints(t,e,n=!0){for(const i of t)this.mergeCoordinateToWaypoints(i,e,n);return e}static mergeCoordinateToWaypoints(t,e,n=!0){t.lng=d.convertToStdLng(t.lng,8);let i=Number.MAX_VALUE,o=0,r=0,s=0;if(e.length<2)e.push(t);else{for(let c=0;c<e.length-1;c++){const a={lng:e[c].lng,lat:e[c].lat},u={lng:e[c+1].lng,lat:e[c+1].lat},l=this.calculatePointToLineDistance(t,a,u);i>=l&&(i=l,o=c,r=this.calculateDistance(a,t,!1,6),s=this.calculateDistance(u,t,!1,6))}r!==0&&s!==0?r<=i&&o===0?e.unshift(t):s<=i&&o===e.length-2?e.push(t):e.splice(o+1,0,t):r===0?n?e.splice(o,1,t):e.splice(o+1,0,t):s===0&&(n?e.splice(o+1,1,t):e.splice(o+1,0,t))}return e.map((c,a)=>{c.lng=d.convertToStdLng(c.lng);const u=e[a+1];if(u&&((c.bearing===null||c.bearing===void 0)&&((c.positionTime||0)>(u.positionTime||0)?c.bearing=this.calculateBearing(u,c,!0):c.bearing=this.calculateBearing(c,u,!0)),c.cog=c.cog||c.bearing,!c.sog&&c.positionTime&&u.positionTime)){const l=this.calculateDistance(c,u,!0),g=Math.abs(u.positionTime-c.positionTime)/3600;c.sog=d.roundPrecision(l/g,2)}return c})}static generateRouteAccordingToWaypoints(t,e=!0,n=!0){const i=[];for(let o=1;o<t.length;o++){const r=t[o-1],s=t[o];if(o===1&&i.push(r),s.gcToPrevious){const c=this.interpolateCoordinates(r,s,200,!1,!0,"nauticalmiles");i.push(...c)}else i.push(s)}return this.divideAccordingToLng(i,e,n)}static nearestCoordinateInRoute(t,e){const n=h.point([t.lng,t.lat]),o=this.convertRouteToCoordinates(e).map(a=>[a.lng,a.lat]),r=h.lineString(o),s=h.nearestPointOnLine(r,n),c=h.getCoord(s);return{lng:d.roundPrecision(c[0],8),lat:d.roundPrecision(c[1],8)}}static calculatePrevWaypoint(t,e){let n=0;this.mergeCoordinateToWaypoints(t,e);for(let i=0;i<e.length-1;i++){const o=e[i],r=e[i+1];if(this.calculateDistance(t,o)===0){n=i;break}if(this.calculateDistance(t,r)===0){n=i+1;break}}return e[n===0?0:n-1]}static calculateNextCoordinateAlongRoute(t,e,n,i="nauticalmiles"){var g;const o=t.speed||12,r=[];let s=[],c=!1,a=0,u=0,l;if(e&&n.length?(r.push(t),n.forEach((f,m)=>{if(c)s.push(f);else{const S=[];let p;for(let v=0;v<f.length;v++)if(l)S.push(f[v]);else{p={lng:f[v][0],lat:f[v][1]};const P=this.calculateDistance(t,p,!0,8,i);if(a+=P,a<e)u+=P,P&&r.push(p),t=p;else{if(u=e,a===e)l=p,S.push([l.lng,l.lat]);else{const M=a-e,T=this.calculateBearing(p,t);l=this.calculateCoordinate(p,T,M,i),S.push([l.lng,l.lat]),S.push([p.lng,p.lat])}c=!0}}S.length&&s.push(S),m===n.length-1&&!l&&(l=p)}})):(s=n,l={...t}),l)if(r.push(l),l.distanceFromPrevious=Math.round(u*1e4)/1e4,l.hourFromPrevious=Math.round(u/o*1e4)/1e4,((g=s[0])==null?void 0:g.length)>1){const f={lng:s[0][1][0],lat:s[0][1][1]};l.bearing=this.calculateBearing(l,f)}else l.bearing=0;return{coordinate:l,nextRoute:s,prevRoute:r}}static nearestCoordinateInLine(t,e,n){const i=d.convertToStdLng(t.lng,6),o=h.point([i,t.lat]),r=d.convertToStdLng(e.lng,6),s=d.convertToStdLng(n.lng,6),c=h.lineString([[r,e.lat],[s,n.lat]]),a=h.nearestPointOnLine(c,o),u=h.getCoord(a),l=d.roundPrecision(u[0],6),g=d.roundPrecision(u[1],6);return{lng:l,lat:g,inline:!(l===r&&g===e.lat)&&!(l===s&&g===n.lat)}}static convertRouteToCoordinates(t,e=0){const n=[];let i,o;return t.forEach(r=>{r.forEach(s=>{const c={lng:d.roundPrecision(s[0],8),lat:d.roundPrecision(s[1],8)};if(!o)n.push(c),o=c;else if(o.bearing===void 0||o.bearing===null)o.bearing=this.calculateBearing(o,c,!0);else{const a=this.calculateDistance(i,c,!0);a&&a>=e&&(i.bearing=this.calculateBearing(i,c,!0),n.push(i),o=i)}i=c})}),i&&n.push(i),n}static simplifyRouteToCoordinates(t,e,n=1){let i=this.convertRouteToCoordinates(t,n);return i=this.simplifyGCCoordinates(i,e),i}static simplifyGCCoordinates(t,e){e.forEach(i=>{this.mergeCoordinateToWaypoints(i,t,!0)});for(let i=1;i<e.length;i++){const o=e[i-1],r=e[i];if(r.gcToPrevious){const s=t.findIndex(a=>a.lng===o.lng&&a.lat===o.lat),c=t.findIndex(a=>a.lng===r.lng&&a.lat===r.lat);for(let a=c-1;a>s;a--)t.splice(a,1)}}let n=0;for(let i=1;i<t.length;i++){const o=t[i-1],r=t[i];r.gcToPrevious?(o.bearing=this.calculateBearing(o,r,!1),r.distanceFromPrevious=this.calculateDistance(o,r,!1)):(o.bearing=this.calculateBearing(o,r,!0),r.distanceFromPrevious=this.calculateDistance(o,r,!0)),n=d.roundPrecision(n+r.distanceFromPrevious),r.distanceFromStart=n}return t.map(i=>(i.lng=d.convertToStdLng(i.lng),i))}static calculateCenter(t){const e=[];for(const s of t)for(const c of s)e.push(c);const n=h.featureCollection([]),i=d.convertToMonotonicLng2(e);for(const s of i)n.features.push(h.point(s));const r=h.center(n).geometry.coordinates;return{lng:d.convertToStdLng(r[0],8),lat:d.roundPrecision(r[1],8)}}static calculateCenter2(t){const e=this.generateRouteAccordingToWaypoints(t);return this.calculateCenter(e)}static calculateBBox(t){const e=[];for(const o of t)for(const r of o)e.push(r);const n=d.convertToMonotonicLng2(e),i=h.lineString(n);return h.bbox(i)}static calculateBBox2(t){const e=this.generateRouteAccordingToWaypoints(t);return this.calculateBBox(e)}static simplifyCoordinates(t,e=1,n=180){const i=[];for(let o=1;o<t.length;o++){const r=t[o-1],s=t[o],c=t[o+1];let a=!1,u=!1;if((r.velocity||r.suspend||r.important||r.pilot||o===1)&&(a=!0,i.push(r)),s.gcToPrevious&&(a||(a=!0,i.push(r)),u=!0,i.push(s),o++),c){const l=y.calculateDistance(r,s,!0),g=y.calculateDistance(s,c,!0),f=y.calculateDistance(r,c,!0),m=(Math.pow(l,2)+Math.pow(g,2)-Math.pow(f,2))/(2*l*g);Math.round(Math.acos(m)*180/Math.PI)<n&&f>e&&!u&&(i.push(s),o++)}if(o>=t.length-1){const l=t.at(-1);l&&i.push(l)}}return i}static nearestTSPointInWaypoints(t,e,n){const i=b.unix(t),o=n.filter(r=>i.clone().subtract(e,"hour").unix()<=(r.positionTime||0)&&i.clone().add(e,"h").unix()>=(r.positionTime||0));return o.sort((r,s)=>(r.positionTime||0)-(s.positionTime||0)),o.at(-1)}static deadReckoning(t,e){var o,r,s,c;t>1e12&&(t=Math.round(t/1e3));const n=b.unix(t);let i=e.find(a=>a.positionTime===n.unix());if(!i){const a=(r=(o=e.filter(l=>(l==null?void 0:l.positionTime)<n.unix()))==null?void 0:o.sort((l,g)=>(l.positionTime||0)-(g.positionTime||0)))==null?void 0:r.at(-1),u=(c=(s=e.filter(l=>(l==null?void 0:l.positionTime)>n.unix()))==null?void 0:s.sort((l,g)=>(l.positionTime||0)-(g.positionTime||0)))==null?void 0:c.at(0);if(a&&u){const l=y.calculateBearing(a,u,!0),g=y.calculateDistance(a,u),f=(n.unix()-a.positionTime)/(u.positionTime-a.positionTime);i=y.calculateCoordinate(a,l,g*f),i.positionTime=n.unix(),i.utc=n.utc().format(),i.cog=l,i.sog=Math.round(g/((u.positionTime-a.positionTime)/3600)*100)/100}else i=a||u,i&&(i.utc=b.unix(i==null?void 0:i.positionTime).utc().format())}return i}static deadReckoningTime(t,e){e=JSON.parse(JSON.stringify(e)),e.sort((a,u)=>(a.positionTime||0)-(u.positionTime||0));let n=Number.MAX_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER;for(let a=0;a<e.length-1;a++){const u=e[a],l=e[a+1],g=y.calculatePointToLineDistance(t,u,l);g<n&&(n=g,i=a)}const o=e[i],r=e[i+1],s=y.calculateDistance(o,t),c=y.calculateDistance(r,t);if(s===0)t=o;else if(c===0)t=r;else{const a=o.positionTime||0,u=r.positionTime||0,l=y.calculateDistance(o,r);t.positionTime=Math.round(a+(u-a)*(s/l))}return t.utc=t.positionTime?b.unix(t.positionTime).utc().format():void 0,t.positionTime?t:void 0}static reverseRoute(t){const e=[];for(const n of t)e.push(n.reverse());return e}static reverseCoordinates(t){return t.reverse()}static xmlEscape(t){return t==null?"":String(t).trim().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}static waypoints2RTZ(t,e){const i=[];return i.push('<?xml version="1.0" encoding="UTF-8"?>'),i.push('<route xmlns="http://www.cirm.org/RTZ/1/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2">'),i.push(` <routeInfo routeName="${y.xmlEscape(t)}"></routeInfo>`),i.push(...y.toRTZWaypoints(e,6)),i.push("</route>"),i.join(`
|
|
2
|
+
`)}static waypoints2RTZ10(t,e,n=!0){const o=[];return o.push('<?xml version="1.0" encoding="UTF-8"?>'),o.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'),o.push(` <routeInfo routeName="${y.xmlEscape(t)}"></routeInfo>`),o.push(...y.toRTZWaypoints(e,6,n)),o.push("</route>"),o.join(`
|
|
3
|
+
`)}static toRTZWaypoints(t,e=6,n=!0){const i=[];i.push(" <waypoints>");for(let o=0;o<t.length;o++){const r=t[o],s=o+1,c=(r.lat??"").toFixed?r.lat.toFixed(e).padEnd(e+2,"0"):r.lat,a=(r.lng??"").toFixed?r.lng.toFixed(e).padEnd(e+2,"0"):r.lng,u=[`id="${s}"`,'revision="0"'];if(r.name&&u.push(`name="${y.xmlEscape(r.name)}"`),i.push(` <waypoint ${u.join(" ")}>`),i.push(` <position lat="${y.xmlEscape(c)}" lon="${y.xmlEscape(a)}" />`),o>0){const l=r.gcToPrevious?"Orthodrome":"Loxodrome";i.push(` <leg geometryType="${l}" />`)}if(n){const l=[];if(r.description&&l.push(` <description>${y.xmlEscape(r.description)}</description>`),r.utc)l.push(` <time>${y.xmlEscape(r.utc)}</time>`);else if(r.positionTime)try{l.push(` <time>${y.xmlEscape(b.unix(r.positionTime).utc().format())}</time>`)}catch{}r.cog!==void 0&&l.push(` <cog>${y.xmlEscape(r.cog)}</cog>`),r.sog!==void 0&&l.push(` <sog>${y.xmlEscape(r.sog)}</sog>`),l.length&&(i.push(" <extensions>"),i.push(...l),i.push(" </extensions>"))}i.push(" </waypoint>")}return i.push(" </waypoints>"),i}static waypoints2CSV(t,e,n){A.debug("keep name for waypoints2CSV for legacy compatibility only",t);const i=(n==null?void 0:n.precision)??6,o=e.some(p=>p.name),r=e.some(p=>p.description),s=e.some(p=>p.port!=null),c=e.some(p=>p.stbd!=null),a=e.some(p=>p.arrRad!=null),u=e.some(p=>p.speed!=null),l=e.some((p,v)=>v>0&&p.gcToPrevious!=null),g=e.some(p=>p.bearing!=null),f=e.some(p=>p.distanceFromPrevious!=null),m=["WPT No.","Latitude","Longitude"];o&&m.push("Name"),r&&m.push("Description"),l&&m.push("Leg"),g&&m.push("Bearing[deg]"),f&&m.push("Distance[NM]"),u&&m.push("Speed[kn]"),s&&m.push("PORT XTD[NM]"),c&&m.push("STBD XTD[NM]"),a&&m.push("Arr.Rad[NM]");const S=[];S.push(m.map(p=>y.csvEscapeField(p)).join(","));for(let p=0;p<e.length;p++){const v=e[p],P=[];P.push((p+1).toString()),P.push(v.lat.toFixed(i)),P.push(v.lng.toFixed(i)),o&&P.push(v.name??""),r&&P.push(v.description??""),l&&P.push(p===0?"":v.gcToPrevious?"GC":"RL"),g&&P.push(v.bearing!=null?String(v.bearing):""),f&&P.push(v.distanceFromPrevious!=null?String(v.distanceFromPrevious):""),u&&P.push(v.speed!=null?String(v.speed):""),s&&P.push(v.port!=null?String(v.port):""),c&&P.push(v.stbd!=null?String(v.stbd):""),a&&P.push(v.arrRad!=null?String(v.arrRad):""),S.push(P.map(M=>y.csvEscapeField(M)).join(","))}return S.join(`
|
|
4
|
+
`)}static csvEscapeField(t){if(t==null)return"";const e=String(t);return e.includes(",")||e.includes('"')||e.includes(`
|
|
5
|
+
`)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}static decimalToNmeaDm(t,e){const n=Math.abs(t),i=Math.floor(n),o=(n-i)*60,r=e?`${i.toString().padStart(2,"0")}${o.toFixed(2).padStart(5,"0")}`:`${i.toString().padStart(3,"0")}${o.toFixed(2).padStart(5,"0")}`,s=e?t>=0?"N":"S":t>=0?"E":"W";return{dm:r,dir:s}}static nmeaChecksum(t){let e=0;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n);return e.toString(16).toUpperCase().padStart(2,"0")}static waypoints2NMEA(t){const e=[];for(let n=0;n<t.length;n++){const i=t[n],o=y.decimalToNmeaDm(i.lat,!0),r=y.decimalToNmeaDm(i.lng,!1),s=i.name?String(i.name).slice(0,6):`WPT${(n+1).toString().padStart(3,"0")}`,c=`GPWPL,${o.dm},${o.dir},${r.dm},${r.dir},${s}`,a=y.nmeaChecksum(c);e.push(`$${c}*${a}`)}return e.join(`\r
|
|
6
|
+
`)}static coordinatesSummary(t,e=3){if(t.length>1){const n=t[0],i=t[t.length-1],o=(n==null?void 0:n.positionTime)<(i==null?void 0:i.positionTime)?b.unix(n==null?void 0:n.positionTime):b.unix(i==null?void 0:i.positionTime),r=(n==null?void 0:n.positionTime)>(i==null?void 0:i.positionTime)?b.unix(n==null?void 0:n.positionTime):b.unix(i==null?void 0:i.positionTime),s=Math.round(r.diff(o,"hours",!0)*100)/100,c=this.generateRouteAccordingToWaypoints(t,!0,!0),a=this.calculateRouteDistance(c),l=j.inspectStoppages(t,e).reduce((f,m)=>(f.duration+=m.duration,f.distance+=m.distance,f),{hours:0,distance:0,spd:0,duration:0});l.hours=Math.round(l.duration/3600*100)/100,l.distance=Math.round(l.distance*100)/100,l.spd=l.hours?Math.round(l.distance/l.hours*100)/100:0;const g=s?Math.round((a-l.distance)/(s-l.hours)*100)/100:0;return{begin:o.utc().format(),end:r.utc().format(),distance:Math.round((a-l.distance)*100)/100,hours:Math.round((s-l.hours)*100)/100,avgSpeed:g,stoppage:l}}return{begin:void 0,end:void 0,distance:0,hours:0,avgSpeed:0}}static pickUTCSampleFromSpeed(t,e){var u,l,g;if(!((l=(u=e==null?void 0:e.sample)==null?void 0:u.hours)!=null&&l.length))return{routes:[],hour:void 0};const n=e.sample.hours.at(0),i=b.utc(t),o=b.utc(e.eta),r=i.isAfter(o)?o:i;let s=e.sample.all.find(f=>f.eta===r.format());if(!s){const f=e.sample.all.filter(N=>b.utc(N.eta).isBefore(r)).at(-1),m=this.calculateSubRoute(f,e.route);s=(g=this.calculateNextCoordinateAlongRoute(f,f.speed*r.diff(b(f.etd),"hours",!0),m))==null?void 0:g.coordinate;const{cFactor:S,cog:p,wxFactor:v,meteo:P}=f,M=Math.round(s.distanceFromPrevious*1e4)/1e4,T=Math.round((M+f.distanceFromStart)*1e4)/1e4;s={...s,cFactor:S,cog:p,speed:f.speed,wxFactor:v,distanceFromStart:T,distanceFromPrevious:M,meteo:P,eta:r.format(),etd:r.format()}}s.distanceToGo=Math.round((e.distance-s.distanceFromStart)*100)/100,s.timeToGo=Math.round(o.diff(s.etd,"hours",!0)*100)/100;const c=this.calculateRangeWaypoints(n,s,e.route);return{routes:this.generateRouteAccordingToWaypoints(c),hour:s}}static pickUTCSampleFromRoute(t,e,n){var f;const i=this.calculateSubRoute(e,n),o=this.calculateRouteDistance(i),r=o/e.speed,s=b.utc(t),c=b(e.etd),a=(f=this.calculateNextCoordinateAlongRoute(e,e.speed*s.diff(b(e.etd),"hours",!0),i))==null?void 0:f.coordinate;a.speed=e.speed;const u=c.clone().add(a.hourFromPrevious,"hour");a.eta=Math.abs(u.diff(s,"second"))<2?s.format():u.format(),a.etd=a.eta,a.distanceFromStart=Math.round(a.distanceFromPrevious*100)/100,a.distanceToGo=Math.round((o-a.distanceFromStart)*100)/100,a.timeToGo=Math.round(c.clone().add(r,"hour").diff(b(a.etd),"hour")*100)/100;const l=this.calculateRangeWaypoints(e,a,n);return{routes:this.generateRouteAccordingToWaypoints(l),hour:a}}static includedAngle(t,e){A==null||A.debug("calculate bearing via: %j",{bearing:t,degree:e});let n=Math.abs(t%360-(e%360||0));return n=n>180?360-n:n,n}}let D;try{D=k.getLogger("vessel")}catch{}finally{}class K{static convert2Geojson(t){var n,i,o;const e=h.featureCollection([]);for(const r of t){const s=(n=r.history)==null?void 0:n[0];if(r.forecasts){s&&s.wind&&(s.wind.kts=s.kts);for(const c of r.forecasts){let a;const u=[],l=[],g=b(c.date).utc(),f=`${r.name}-${c.model}`;for(const S in c==null?void 0:c.hours){const p=c.hours[S];a=a||p;const v=g.clone().add(Number(S),"hour"),P=h.point([p.lng,p.lat],{model:c.model,name:r.name,nameCn:r.nameCn,date:v.format(),hour:Number(S),format:v.format("MMM-DD/HHmm[Z]"),pressure:p.pressure>1e4?d.roundPrecision(p.pressure/100,0):d.roundPrecision(p.pressure,0),gusts:p.gusts,wind:p.wind||{},movement:p.movement,category:f,type:"forecast"});l.push(P),u.push(P.geometry.coordinates)}const m={kts:void 0,deg:void 0};if(s){const S=b(s.updated).utc();if(a){const v=y.calculateDistance(s,a),P=b(a.utc||a.updated).diff(S,"h",!0);m.kts=Math.round(v/P*100)/100,m.deg=y.calculateBearing(s,a,!0,0)}const p=h.point([s.lng,s.lat],{model:c.model,name:r.name,nameCn:r.nameCn,date:S.format(),hour:0,format:S.format("MMM-DD/HHmm[Z]"),pressure:s.pressure>1e4?d.roundPrecision((s==null?void 0:s.pressure)/100,0):d.roundPrecision(s.pressure,0),wind:s.wind,movement:m,category:f,type:"forecast",important:!0});l.unshift(p),u.unshift(p.geometry.coordinates)}if(e.features.push(...l),(u==null?void 0:u.length)>1){const S=h.lineString(d.convertToMonotonicLng2(u),{date:(s==null?void 0:s.updated)||(g==null?void 0:g.format()),id:r.id||r.name,model:c.model,name:r.name,category:f,type:"forecast",movement:m});e.features.push(S)}}}if(e.features.sort((c,a)=>c.properties.type==="forecast"&&a.properties.type==="forecast"&&c.geometry.type==="Point"&&a.geometry.type==="Point"?b(c.properties.date).valueOf()-b(a.properties.date).valueOf():0),(i=r.history)!=null&&i.length){const c=[],a=b(s==null?void 0:s.updated).utc(),u=b((o=r.history)==null?void 0:o.at(-1).updated).utc(),l=a.diff(u,"h")%24>2?24:12;for(const g of r.history){const f=b(g.updated).utc(),m=f.isSameOrBefore(a)||f.isSame(u);m&&a.add(-l,"h");const S=h.point([g.lng,g.lat],{name:r.name,nameCn:r.nameCn,date:f.format(),format:f.format("MMM-DD/HHmm[Z]"),pressure:g.pressure>1e4?d.roundPrecision(g.pressure/100,0):d.roundPrecision(g.pressure,0),kts:g.kts,level:g.type,type:"history",category:`${r.name}-history`,wind:g.wind,movement:g.movement,important:m});e.features.push(S),c.push(S.geometry.coordinates)}if(c.length===1&&c.push(c[0]),c.length>1){const g=h.lineString(d.convertToMonotonicLng2(c),{name:r.name,type:"history",updated:s==null?void 0:s.updated,pressure:(s==null?void 0:s.pressure)>1e4?d.roundPrecision((s==null?void 0:s.pressure)/100,0):d.roundPrecision(s==null?void 0:s.pressure,0),kts:s==null?void 0:s.kts,level:s==null?void 0:s.type});e.features.push(g)}}}return e}static interpolate(t,e=3){var o,r,s,c;const n=(o=t==null?void 0:t.data)==null?void 0:o.features.filter(a=>a.geometry.type==="LineString"&&a.properties.type==="forecast"),i=[];for(const a of n){const u=a.properties.name,l=a.properties.model,g=a.properties.showCircle,f=a.properties.disabled,m=b(a.properties.date).utc();let S=e*60;const p=(r=t==null?void 0:t.data)==null?void 0:r.features.filter(M=>M.geometry.type==="Point"&&M.properties.type==="forecast"&&M.properties.category===`${u}-${l}`);let v,P=m.clone().add(S,"minute").set({minute:0,second:0,millisecond:0});for(;v=this.pickIndex(p,P),v<=p.length-1;){if(v>0){const M=p[v],T=v===0?void 0:p[v-1],N=(S/60-((s=T==null?void 0:T.properties)==null?void 0:s.hour))/(M.properties.hour-((c=T==null?void 0:T.properties)==null?void 0:c.hour)),R=this.computeNumber(T==null?void 0:T.geometry.coordinates[0],M.geometry.coordinates[0],N),F=this.computeNumber(T==null?void 0:T.geometry.coordinates[1],M.geometry.coordinates[1],N),E=h.point([R,F],{name:u,model:l,category:M==null?void 0:M.properties.category,date:P.format(),format:P.format("MMM-DD/HHmm[Z]"),gusts:this.computeNumber(T==null?void 0:T.properties.gusts,M.properties.gusts,N),hour:this.computeNumber(T==null?void 0:T.properties.hour,M.properties.hour,N),movement:this.computeNumber(T==null?void 0:T.properties.movement,M.properties.movement,N),pressure:this.computeNumber(T==null?void 0:T.properties.pressure,M.properties.pressure,N),wind:this.computeNumber(T==null?void 0:T.properties.wind,M.properties.wind,N),type:"forecast",disabled:f,showCircle:g});i.push(E)}S+=e*60,P=m.clone().add(S,"minute").set({minute:0,second:0,millisecond:0})}}return i}static accelPassageAt(t,e){const{t1:n,t2:i,hr:o,hours:r}=this.tropicalCenterTwin(t,24,e);return{t1:n,t2:i,hr:o,hours:r}}static diversionPassageAt(t,e,n,i={}){const{t1:o,t2:r,hr:s,hours:c}=this.tropicalCenterTwin(e,24,i);if(o&&r){if(!i.debug){const m=y.calculateDistance(t,o),S=y.calculateDistance(t,r);if(m>2*n&&S>2*n)return D==null||D.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j",i.requestId,m,S,{from:t,t1:o,t2:r,hr:s}),{}}const a=y.calculateBearing(t,o),u=y.calculateBearing(o,r),l=Math.abs(a-u);let g=0;l<180?g=l+90:l>=180&&(g=l-90);const f=y.calculateCoordinate(o,g,n);return D==null||D.info("[%s] the right tangent position: %j",i.requestId,{from:t,t1:o,t2:r,radius:n,bearing1:a,bearing2:u,right:f}),{at:f,t1:o,t2:r,hr:Number(s),hours:c}}return{}}static driftPassageAt(t,e,n,i={}){const{t1:o,t2:r,hr:s,hours:c}=this.tropicalCenterTwin(e,24,i);if(o&&r){if(!i.debug){const f=y.calculateDistance(t,o),m=y.calculateDistance(t,r);if(f>2*n&&m>2*n)return D==null||D.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j",i.requestId,f,m,{from:t,t1:o,t2:r,hr:s}),{}}const a=y.calculateBearing(t,o),u=y.calculateBearing(o,r),l=y.calculateDistance(t,o);return{at:y.calculateCoordinate(o,a-u+180,n<l?n:l),t1:o,t2:r,hr:Number(s),hours:c}}else return D==null||D.info("[%s] no need drift: %j",i.requestId,{from:t,t1:o,t2:r,hr:s}),{}}static tropicalCenterTwin(t,e=24,n={}){var u,l,g,f,m;let i={};(u=t.forecasts)==null||u.forEach(S=>{i={...S.hours,...i}});const o=((l=t==null?void 0:t.history)==null?void 0:l[0])||(i==null?void 0:i[(g=Object.keys(i))==null?void 0:g[0]]);D==null||D.info("[%s] the first tropical center: %j",n.requestId,o);let r=(f=Object.keys(i||{}).filter(S=>Number(S)<=(e<0?24:e)))==null?void 0:f.at(-1);r||(r=(m=Object.keys(i||{}).filter(S=>Number(S)<=(e<0?24:2*e)))==null?void 0:m.at(-1));const s=i==null?void 0:i[r||-1];D==null||D.info("[%s] the second tropical center: %j in %d hrs",n.requestId,s,r);const c=Object.keys(i||{}).filter(S=>Number(S)<=Number(r)),a={0:o};for(const S of c)a[S]=i[S];return{t1:o,t2:s,hr:Number(r),hours:a}}static pickIndex(t,e){let n=0;for(const i of t){if(b(i.properties.date).isAfter(e))return n===0?-1:n;n++}return n}static computeNumber(t,e,n){if(t)if(e){if(isNaN(t)&&isNaN(e)&&typeof t!="string"&&typeof e!="string"){const i={};for(const o in t)i[o]=this.computeNumber(t[o],e[o],n);return i}return Math.round((t+(e-t)*n)*100)/100}else return t;else return e}}typeof globalThis<"u"&&typeof globalThis.Buffer>"u"&&(globalThis.Buffer={isBuffer(C){return C instanceof Uint8Array},from(C,t){if(typeof C=="string")return new TextEncoder().encode(C);if(C instanceof ArrayBuffer)return new Uint8Array(C);if(Array.isArray(C))return new Uint8Array(C);throw new TypeError("Buffer.from: unsupported source type")}});let x;try{x=k.getLogger("meteo")}catch{}finally{}function Q(){if(typeof DOMParser<"u")return new DOMParser;const{JSDOM:C}=require("jsdom"),{DOMParser:t}=new C("").window;return new t}class O{static toArrayBuffer(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}static drawCircle(t,e,n,i={}){const o=(i==null?void 0:i.steps)??64,r=(i==null?void 0:i.units)??"nauticalmiles",s=(i==null?void 0:i.properties)??{},c=h.point([t,e]),a=h.destination(c,n,90,{units:r}),u=b.utc();s.id=(i==null?void 0:i.id)||u.valueOf().toString();const l="circle";return s.name=(i==null?void 0:i.name)||`${l}_${u.format()}`,s.radius=n,s.center=[t,e],s.end=a.geometry.coordinates.map(g=>d.roundPrecision(g,9)),s.units=r,s.steps=o,s.shape="circle",x.info("[%s] draw circle with %j",i==null?void 0:i.requestId,s),h.circle(c,n,{steps:o,units:r,properties:s})}static drawRect(t,e,n={}){const i=(n==null?void 0:n.properties)??{},o=b.utc();i.id=(n==null?void 0:n.id)||o.valueOf().toString();const r="rect";i.name=(n==null?void 0:n.name)||`${r}_${o.format()}`,i.start=t.map(u=>d.roundPrecision(u,9)),i.end=e.map(u=>d.roundPrecision(u,9)),i.shape="rect",x.info("[%s] draw rect with %j",n==null?void 0:n.requestId,i);const[s,c]=d.convertToMonotonicLng2([t,e]),a=[Math.min(s[0],c[0]),Math.min(s[1],c[1]),Math.max(s[0],c[0]),Math.max(s[1],c[1])];return h.bboxPolygon(a,{properties:i})}static drawLine(t,e={}){const n=(e==null?void 0:e.properties)??{},i=b.utc();n.id=(e==null?void 0:e.id)||i.valueOf().toString();const o="line";n.name=(e==null?void 0:e.name)||`${o}_${i.format()}`,n.shape="line",x.info("[%s] draw line with %j",e==null?void 0:e.requestId,n);const r=d.convertToMonotonicLng2(t);return h.lineString(r,n)}static drawPolygon(t,e={}){const n=(e==null?void 0:e.properties)??{},i=b.utc();n.id=(e==null?void 0:e.id)||i.valueOf().toString();const o="polygon";n.name=(e==null?void 0:e.name)||`${o}_${i.format()}`,n.coordinates=t.map(s=>s.map(c=>d.roundPrecision(c,9))),n.shape="polygon",x.info("[%s] draw polygon with %j",e==null?void 0:e.requestId,n);const r=d.convertToMonotonicLng2(t);return h.polygon([r],n)}static drawPoint(t,e,n={}){const i=(n==null?void 0:n.properties)??{},o=b.utc();i.id=(n==null?void 0:n.id)||o.valueOf().toString();const r="point";return i.name=(n==null?void 0:n.name)||`${r}_${o.format()}`,i.shape="point",x.info("[%s] draw point with %j",n==null?void 0:n.requestId,i),h.point([e,t],i)}static parseCircle(t,e={}){var i,o;x.info("[%s] parse circle with %j",e==null?void 0:e.requestId,t.properties);const n=t.properties||{};if(n.shape=="circle"){const r=b.utc();n.id=(n==null?void 0:n.id)||r.valueOf().toString();const s=n==null?void 0:n.id,c=((i=n==null?void 0:n.center)==null?void 0:i.length)==2?h.point(n.center):h.centroid(t);let a="center";c.properties={id:`${a}_${s}`,parentId:s,name:a};const u=(n==null?void 0:n.units)||"nauticalmiles";let l=n==null?void 0:n.radius;if(!l){const m=h.polygonToLine(t);l=h.pointToLineDistance(c,m,{units:u})}a="end";const g=((o=n==null?void 0:n.end)==null?void 0:o.length)==2?h.point(n.end):h.destination(c,l,90,{units:u});g.properties={id:`${a}_${s}`,parentId:s,name:a,radius:l,units:u};const f=h.lineString([c.geometry.coordinates,g.geometry.coordinates]);return a="edge",f.properties={id:`${a}_${s}`,parentId:s,name:a,radius:l,units:u},h.featureCollection([c,g,f,t])}else return x.warn("[%s] not a orm-std circle, just return the original feature",e==null?void 0:e.requestId),h.featureCollection([t])}static parseRect(t,e={}){x.info("[%s] parse rect with %j",e==null?void 0:e.requestId,t.properties);const n=t.properties||{};if(n.shape=="rect"){const i=b.utc();n.id=(n==null?void 0:n.id)||i.valueOf().toString();const o=n==null?void 0:n.id,r=t.geometry.coordinates[0],c=["sw","nw","ne","se"].map((a,u)=>{const l=h.point(r[u]);return l.properties={id:`${a}_${o}`,parentId:o,name:a},l});return h.featureCollection([...c,t])}else return x.warn("[%s] not a orm-std rect, just return the original feature",e==null?void 0:e.requestId),h.featureCollection([t])}static parseLine(t,e={}){x.info("[%s] parse line with %j",e==null?void 0:e.requestId,t.properties);const n=t.properties||{};if(n.shape=="line"){const i=b.utc();n.id=(n==null?void 0:n.id)||i.valueOf().toString();const o=n==null?void 0:n.id,s=t.geometry.coordinates.map((c,a)=>{const u=`point_${a}`,l=h.point(c);return l.properties={id:`${u}_${o}`,parentId:o,name:u,index:a},l});return h.featureCollection([...s,t])}else return x.warn("[%s] not a orm-std line, just return the original feature",e==null?void 0:e.requestId),h.featureCollection([t])}static parsePolygon(t,e={}){x.info("[%s] parse polygon with %j",e==null?void 0:e.requestId,t.properties);const n=t.properties||{};if(n.shape=="polygon"){const i=b.utc();n.id=(n==null?void 0:n.id)||i.valueOf().toString();const o=n==null?void 0:n.id,s=t.geometry.coordinates[0].map((c,a)=>{const u=h.point(c),l=`corner_${a}`;return u.properties={id:`${l}_${o}`,parentId:o,name:l,index:a},u});return h.featureCollection([...s,t])}else return x.warn("[%s] not a orm-std polygon, just return the original feature",e==null?void 0:e.requestId),h.featureCollection([t])}static _inflateRawSync(t){var e;if(typeof process<"u"&&((e=process.versions)!=null&&e.node)){const n=require("zlib");return new Uint8Array(n.inflateRawSync(Buffer.from(t)))}throw new Error("Sync inflate is not supported in browser; use the async convertKMZ2GeoJSONAsync / convertZIP2GeoJSONAsync instead")}static async _parseZipEntries(t){var g;const e=new Uint8Array(t),n=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),i=new DataView(n),o=new Uint8Array(n),r=new Map;let s=-1;for(let f=n.byteLength-22;f>=0;f--)if(i.getUint32(f,!0)===101010256){s=f;break}if(s<0)throw new Error("Invalid ZIP file: EOCD not found");i.getUint16(s+8,!0);const c=i.getUint32(s+12,!0),a=i.getUint32(s+16,!0);let u=a;const l=a+c;for(;u<l;){if(i.getUint32(u,!0)!==33639248)throw new Error(`Invalid ZIP file: Central Directory signature mismatch at offset ${u}`);const m=i.getUint16(u+10,!0),S=i.getUint32(u+20,!0),p=i.getUint16(u+28,!0),v=i.getUint16(u+30,!0),P=i.getUint16(u+32,!0),M=i.getUint32(u+42,!0),T=o.slice(u+46,u+46+p),N=new TextDecoder().decode(T),R=i.getUint16(M+26,!0),F=i.getUint16(M+28,!0),E=M+30+R+F,B=o.slice(E,E+S);if(m===0)r.set(N,B);else if(m===8){if(typeof DecompressionStream<"u"){const q=new DecompressionStream("deflate-raw"),W=q.writable.getWriter(),Y=q.readable.getReader();W.write(B),W.close();const U=[];let L=0;for(;;){const{done:w,value:G}=await Y.read();if(w)break;U.push(G),L+=G.length}const Z=new Uint8Array(L);let z=0;for(const w of U)Z.set(w,z),z+=w.length;r.set(N,Z)}else if(typeof process<"u"&&((g=process.versions)!=null&&g.node))try{r.set(N,O._inflateRawSync(B))}catch{}}u+=46+p+v+P}return r}static async convertKML2GeoJSON(t,e={}){var s,c;x.info("[%s] convert kml to geojson",e==null?void 0:e.requestId);const i=Q().parseFromString(t,"application/xml"),o=Array.from(i.querySelectorAll("Placemark")),r=[];for(const a of o){const u={},l=Array.from(a.querySelectorAll("ExtendedData > Data"));for(const T of l){const N=T.getAttribute("name"),R=(c=(s=T.querySelector("value"))==null?void 0:s.textContent)==null?void 0:c.trim();N&&R!==void 0&&R!==null&&(u[N]=R)}const g=b.utc(),f=Object.keys(u).find(T=>T.toLowerCase().indexOf("name")!==-1),m=f?u[f]:void 0,S=`${g.valueOf().toString()}_${Math.random().toString(36).slice(2,8)}`,p=T=>T.trim().split(/[\s\n]+/).filter(N=>N.length>0).map(N=>{const R=N.split(",").map(Number);return[R[0],R[1]]}),v=a.querySelector("LineString > coordinates");if(v){const T=p(v.textContent||"");if(T.length>=2){const N=h.lineString(T,{...u,shape:"line",id:S,name:m});r.push(N)}continue}const P=a.querySelector("Polygon outerBoundaryIs LinearRing > coordinates");if(P){const T=p(P.textContent||"");if(T.length>=4){const N=T[0][0]===T[T.length-1][0]&&T[0][1]===T[T.length-1][1]?T:[...T,T[0]],R=h.polygon([N],{...u,shape:"polygon",id:S,name:m});r.push(R)}continue}const M=a.querySelector("Point > coordinates");if(M){const T=p(M.textContent||"");if(T.length>=1){const N=h.point(T[0],{...u,shape:"point",id:S,name:m});r.push(N)}continue}}return h.featureCollection(r)}static async convertKMZ2GeoJSON(t,e={}){var r;x.info("[%s] convert kmz to geojson (async)",e==null?void 0:e.requestId),typeof Buffer<"u"&&Buffer.isBuffer(t)&&(t=O.toArrayBuffer(t));const n=await O._parseZipEntries(t),i=n.get("doc.kml")??((r=[...n.entries()].find(([s])=>s.toLowerCase().endsWith(".kml")))==null?void 0:r[1]);if(!i)return x.warn("[%s] no .kml file found in kmz",e==null?void 0:e.requestId),h.featureCollection([]);const o=new TextDecoder().decode(i);return O.convertKML2GeoJSON(o,e)}static async convertZIP2GeoJSON(t,e={}){x.info("[%s] convert zip to geojson (async)",e==null?void 0:e.requestId),typeof Buffer<"u"&&Buffer.isBuffer(t)&&(t=O.toArrayBuffer(t));const n=await O._parseZipEntries(t),i=[];for(const[o,r]of n){if(!o.toLowerCase().endsWith(".kml"))continue;const s=new TextDecoder().decode(r),c=await O.convertKML2GeoJSON(s,e);i.push(...c.features)}return i.length===0?(x.warn("[%s] no .kml files found in zip",e==null?void 0:e.requestId),this.convertSHP2GeoJSON(t,e)):h.featureCollection(i)}static async convertSHP2GeoJSON(t,e={}){x.info("[%s] convert shp zip to geojson",e==null?void 0:e.requestId);try{typeof Buffer<"u"&&Buffer.isBuffer(t)&&(t=O.toArrayBuffer(t));const n=await X(t);if(Array.isArray(n)){const i=n.flatMap(c=>c.features||[]),o=b.utc(),r=(e==null?void 0:e.id)||o.valueOf().toString(),s={Point:"point",MultiPoint:"point",LineString:"line",MultiLineString:"line",Polygon:"polygon",MultiPolygon:"polygon"};return i.forEach((c,a)=>{var m;const u=((m=c.geometry)==null?void 0:m.type)||"",l=s[u]||u.toLowerCase();c.properties=c.properties||{},c.properties.shape=l,c.properties.parentId=r,c.properties.id=`${r}_${a}`;const g=Object.keys(c.properties).find(S=>S.toLowerCase().indexOf("name")!==-1),f=g?c.properties[g]:void 0;c.properties.name=f||`${l}_${o.format()}_${a}`}),h.featureCollection(i)}return n}catch(n){return x.warn("[%s] failed to convert shp zip: %s",e==null?void 0:e.requestId,n),h.featureCollection([])}}}$.AisHelper=j,$.GeoJsonHelper=O,$.LaneHelper=y,$.LngLatHelper=d,$.TropicalHelper=K,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});
|
package/dist/json/src/index.d.ts
CHANGED
|
@@ -101,6 +101,7 @@ export declare class GeoJsonHelper {
|
|
|
101
101
|
private static _inflateRawSync;
|
|
102
102
|
/**
|
|
103
103
|
* 从 ZIP ArrayBuffer 中异步解析所有文件条目(浏览器 DecompressionStream)。
|
|
104
|
+
* 使用 Central Directory 解析,避免 Data Descriptor 导致的大小不准问题。
|
|
104
105
|
*/
|
|
105
106
|
private static _parseZipEntries;
|
|
106
107
|
/**
|