@idm-plugin/geo 1.6.1 → 1.6.3
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 +104 -82
- package/dist/index.umd.cjs +2 -2
- package/dist/lane/src/index.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as T from "@turf/turf";
|
|
2
|
-
import
|
|
2
|
+
import C from "moment";
|
|
3
3
|
import _ from "@log4js-node/log4js-api";
|
|
4
4
|
var X0 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
5
5
|
function a0(E) {
|
|
@@ -13,7 +13,7 @@ var j = { exports: {} };
|
|
|
13
13
|
//! license : MIT
|
|
14
14
|
//! github.com/moment/moment-timezone
|
|
15
15
|
(function(M, z) {
|
|
16
|
-
E.exports ? E.exports = z(
|
|
16
|
+
E.exports ? E.exports = z(C) : z(M.moment);
|
|
17
17
|
})(X0, function(M) {
|
|
18
18
|
M.version === void 0 && M.default && (M = M.default);
|
|
19
19
|
var z = "0.5.45", p = {}, O = {}, A = {}, b = {}, W = {}, q;
|
|
@@ -31,7 +31,7 @@ var j = { exports: {} };
|
|
|
31
31
|
f = f / 60, t = i(L.charCodeAt(d)), B += t * f;
|
|
32
32
|
return B * V;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function u(c) {
|
|
35
35
|
for (var d = 0; d < c.length; d++)
|
|
36
36
|
c[d] = e(c[d]);
|
|
37
37
|
}
|
|
@@ -48,7 +48,7 @@ var j = { exports: {} };
|
|
|
48
48
|
}
|
|
49
49
|
function P(c) {
|
|
50
50
|
var d = c.split("|"), X = d[2].split(" "), n = d[3].split(""), L = d[4].split(" ");
|
|
51
|
-
return
|
|
51
|
+
return u(X), u(n), u(L), S(L, n.length), {
|
|
52
52
|
name: d[0],
|
|
53
53
|
abbrs: s(d[1].split(" "), n),
|
|
54
54
|
offsets: s(X, n),
|
|
@@ -89,7 +89,7 @@ var j = { exports: {} };
|
|
|
89
89
|
parse: function(c) {
|
|
90
90
|
var d = +c, X = this.offsets, n = this.untils, L = n.length - 1, f, t, B, V;
|
|
91
91
|
for (V = 0; V < L; V++)
|
|
92
|
-
if (f = X[V], t = X[V + 1], B = X[V && V - 1], f < t &&
|
|
92
|
+
if (f = X[V], t = X[V + 1], B = X[V && V - 1], f < t && U.moveAmbiguousForward ? f = t : f > B && U.moveInvalidForward && (f = B), d < n[V] - f * 6e4)
|
|
93
93
|
return X[V];
|
|
94
94
|
return X[L];
|
|
95
95
|
},
|
|
@@ -134,7 +134,7 @@ var j = { exports: {} };
|
|
|
134
134
|
}
|
|
135
135
|
function z0(c, d) {
|
|
136
136
|
var X, n;
|
|
137
|
-
for (
|
|
137
|
+
for (u(d), X = 0; X < d.length; X++)
|
|
138
138
|
n = d[X], W[n] = W[n] || {}, W[n][c] = !0;
|
|
139
139
|
}
|
|
140
140
|
function b0(c) {
|
|
@@ -163,7 +163,7 @@ var j = { exports: {} };
|
|
|
163
163
|
}
|
|
164
164
|
var X = F(), n = X.length, L = b0(X), f = [], t, B, V;
|
|
165
165
|
for (B = 0; B < L.length; B++) {
|
|
166
|
-
for (t = new H(
|
|
166
|
+
for (t = new H(g(L[B])), V = 0; V < n; V++)
|
|
167
167
|
t.scoreOffsetAt(X[V]);
|
|
168
168
|
f.push(t);
|
|
169
169
|
}
|
|
@@ -180,10 +180,10 @@ var j = { exports: {} };
|
|
|
180
180
|
for (typeof c == "string" && (c = [c]), d = 0; d < c.length; d++)
|
|
181
181
|
n = c[d].split("|"), X = n[0], L = K(X), p[L] = c[d], b[L] = X, z0(L, n[2].split(" "));
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function g(c, d) {
|
|
184
184
|
c = K(c);
|
|
185
185
|
var X = p[c], n;
|
|
186
|
-
return X instanceof G ? X : typeof X == "string" ? (X = new G(X), p[c] = X, X) : O[c] && d !==
|
|
186
|
+
return X instanceof G ? X : typeof X == "string" ? (X = new G(X), p[c] = X, X) : O[c] && d !== g && (n = g(O[c], g)) ? (X = p[c] = new G(), X._set(n), X.name = b[c], X) : null;
|
|
187
187
|
}
|
|
188
188
|
function A0() {
|
|
189
189
|
var c, d = [];
|
|
@@ -216,7 +216,7 @@ var j = { exports: {} };
|
|
|
216
216
|
return null;
|
|
217
217
|
var X = c.zones.sort();
|
|
218
218
|
return d ? X.map(function(n) {
|
|
219
|
-
var L =
|
|
219
|
+
var L = g(n);
|
|
220
220
|
return {
|
|
221
221
|
name: n,
|
|
222
222
|
offset: L.utcOffset(/* @__PURE__ */ new Date())
|
|
@@ -224,10 +224,10 @@ var j = { exports: {} };
|
|
|
224
224
|
}) : X;
|
|
225
225
|
}
|
|
226
226
|
function Y0(c) {
|
|
227
|
-
k(c.zones), v(c.links), W0(c.countries),
|
|
227
|
+
k(c.zones), v(c.links), W0(c.countries), U.dataVersion = c.version;
|
|
228
228
|
}
|
|
229
229
|
function $(c) {
|
|
230
|
-
return $.didShowError || ($.didShowError = !0, D("moment.tz.zoneExists('" + c + "') has been deprecated in favor of !moment.tz.zone('" + c + "')")), !!
|
|
230
|
+
return $.didShowError || ($.didShowError = !0, D("moment.tz.zoneExists('" + c + "') has been deprecated in favor of !moment.tz.zone('" + c + "')")), !!g(c);
|
|
231
231
|
}
|
|
232
232
|
function J(c) {
|
|
233
233
|
var d = c._f === "X" || c._f === "x";
|
|
@@ -236,13 +236,13 @@ var j = { exports: {} };
|
|
|
236
236
|
function D(c) {
|
|
237
237
|
typeof console < "u" && typeof console.error == "function" && console.error(c);
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function U(c) {
|
|
240
240
|
var d = Array.prototype.slice.call(arguments, 0, -1), X = arguments[arguments.length - 1], n = M.utc.apply(null, d), L;
|
|
241
|
-
return !M.isMoment(c) && J(n) && (L =
|
|
241
|
+
return !M.isMoment(c) && J(n) && (L = g(X)) && n.add(L.parse(n), "minutes"), n.tz(X), n;
|
|
242
242
|
}
|
|
243
|
-
|
|
244
|
-
var
|
|
245
|
-
M.tz =
|
|
243
|
+
U.version = z, U.dataVersion = "", U._zones = p, U._links = O, U._names = b, U._countries = A, U.add = k, U.link = v, U.load = Y0, U.zone = g, U.zoneExists = $, U.guess = O0, U.names = A0, U.Zone = G, U.unpack = P, U.unpackBase60 = e, U.needsOffset = J, U.moveInvalidForward = !0, U.moveAmbiguousForward = !1, U.countries = c0, U.zonesForCountry = o0;
|
|
244
|
+
var m = M.fn;
|
|
245
|
+
M.tz = U, M.defaultZone = null, M.updateOffset = function(c, d) {
|
|
246
246
|
var X = M.defaultZone, n;
|
|
247
247
|
if (c._z === void 0 && (X && J(c) && !c._isUTC && c.isValid() && (c._d = M.utc(c._a)._d, c.utc().add(X.parse(c), "minutes")), c._z = X), c._z)
|
|
248
248
|
if (n = c._z.utcOffset(c), Math.abs(n) < 16 && (n = n / 60), c.utcOffset !== void 0) {
|
|
@@ -250,11 +250,11 @@ var j = { exports: {} };
|
|
|
250
250
|
c.utcOffset(-n, d), c._z = L;
|
|
251
251
|
} else
|
|
252
252
|
c.zone(n, d);
|
|
253
|
-
},
|
|
253
|
+
}, m.tz = function(c, d) {
|
|
254
254
|
if (c) {
|
|
255
255
|
if (typeof c != "string")
|
|
256
256
|
throw new Error("Time zone name must be a string, got " + c + " [" + typeof c + "]");
|
|
257
|
-
return this._z =
|
|
257
|
+
return this._z = g(c), this._z ? M.updateOffset(this, d) : D("Moment Timezone has no data for " + c + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
|
|
258
258
|
}
|
|
259
259
|
if (this._z)
|
|
260
260
|
return this._z.name;
|
|
@@ -274,8 +274,8 @@ var j = { exports: {} };
|
|
|
274
274
|
return arguments.length > 0 && (this._z = null), c.apply(this, arguments);
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
|
-
|
|
278
|
-
return (R < 2 || R === 2 && Y < 9) && D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = c ?
|
|
277
|
+
m.zoneName = y(m.zoneName), m.zoneAbbr = y(m.zoneAbbr), m.utc = w(m.utc), m.local = w(m.local), m.utcOffset = d0(m.utcOffset), M.tz.setDefault = function(c) {
|
|
278
|
+
return (R < 2 || R === 2 && Y < 9) && D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = c ? g(c) : null, M;
|
|
279
279
|
};
|
|
280
280
|
var h = M.momentProperties;
|
|
281
281
|
return Object.prototype.toString.call(h) === "[object Array]" ? (h.push("_z"), h.push("_a")) : h && (h._z = null), M;
|
|
@@ -1160,7 +1160,7 @@ class a {
|
|
|
1160
1160
|
* @param lat
|
|
1161
1161
|
*/
|
|
1162
1162
|
static guessTimeZoneOffset(M, z) {
|
|
1163
|
-
const p = B0(z, M), O =
|
|
1163
|
+
const p = B0(z, M), O = C().tz(p).utcOffset();
|
|
1164
1164
|
return this.roundPrecision(O / 60, 1);
|
|
1165
1165
|
}
|
|
1166
1166
|
/**
|
|
@@ -1310,7 +1310,7 @@ try {
|
|
|
1310
1310
|
} catch {
|
|
1311
1311
|
} finally {
|
|
1312
1312
|
}
|
|
1313
|
-
class
|
|
1313
|
+
class r {
|
|
1314
1314
|
/**
|
|
1315
1315
|
* 计算方位角
|
|
1316
1316
|
* @param from 坐标 {lng, lat}
|
|
@@ -1428,8 +1428,8 @@ class u {
|
|
|
1428
1428
|
const i = T.lineIntersect(R, Y);
|
|
1429
1429
|
let e;
|
|
1430
1430
|
if (i.features.length) {
|
|
1431
|
-
const
|
|
1432
|
-
e = a.roundPrecision(
|
|
1431
|
+
const u = T.getCoord(i.features[0]);
|
|
1432
|
+
e = a.roundPrecision(u[1], 8);
|
|
1433
1433
|
} else
|
|
1434
1434
|
e = M[W].lat;
|
|
1435
1435
|
q > 0 ? (p.push([180 - 1e-6, e]), O.push([...p]), p = [], p.push([-(180 - 1e-6), e])) : (p.push([-(180 - 1e-6), e]), O.push([...p]), p = [], p.push([180 - 1e-6, e]));
|
|
@@ -1508,8 +1508,8 @@ class u {
|
|
|
1508
1508
|
*/
|
|
1509
1509
|
static appendCoordinateToRoute(M, z) {
|
|
1510
1510
|
M.lng = a.convertToStdLng(M.lng, 8);
|
|
1511
|
-
const p =
|
|
1512
|
-
return p.push(M),
|
|
1511
|
+
const p = r.convertRouteToCoordinates(z);
|
|
1512
|
+
return p.push(M), r.divideAccordingToLng(p);
|
|
1513
1513
|
}
|
|
1514
1514
|
/**
|
|
1515
1515
|
* 向route头加1个坐标
|
|
@@ -1517,8 +1517,8 @@ class u {
|
|
|
1517
1517
|
* @param route
|
|
1518
1518
|
*/
|
|
1519
1519
|
static unshiftCoordinateToRoute(M, z) {
|
|
1520
|
-
const p =
|
|
1521
|
-
return p.unshift(M),
|
|
1520
|
+
const p = r.convertRouteToCoordinates(z);
|
|
1521
|
+
return p.unshift(M), r.divideAccordingToLng(p);
|
|
1522
1522
|
}
|
|
1523
1523
|
/**
|
|
1524
1524
|
* 合并多个waypoints进航线
|
|
@@ -1592,8 +1592,8 @@ class u {
|
|
|
1592
1592
|
* @return [[[lng, lat]]]
|
|
1593
1593
|
*/
|
|
1594
1594
|
static calculateSubRoute(M, z) {
|
|
1595
|
-
const p =
|
|
1596
|
-
|
|
1595
|
+
const p = r.convertRouteToCoordinates(z);
|
|
1596
|
+
r.mergeCoordinateToWaypoints(M, p, !0), z = r.divideAccordingToLng(p);
|
|
1597
1597
|
const { segIndex: O, minIndex: A } = this.calculateMinDistanceToRoute({ ...M }, z);
|
|
1598
1598
|
M.lng = a.convertToStdLng(M.lng);
|
|
1599
1599
|
const b = [];
|
|
@@ -1757,7 +1757,7 @@ class u {
|
|
|
1757
1757
|
var i;
|
|
1758
1758
|
const A = M.speed || 12, b = [];
|
|
1759
1759
|
let W = [], q = !1, o = 0, R = 0, Y;
|
|
1760
|
-
if (z && p.length ? (b.push(M), p.forEach((e,
|
|
1760
|
+
if (z && p.length ? (b.push(M), p.forEach((e, u) => {
|
|
1761
1761
|
if (q)
|
|
1762
1762
|
W.push(e);
|
|
1763
1763
|
else {
|
|
@@ -1781,7 +1781,7 @@ class u {
|
|
|
1781
1781
|
q = !0;
|
|
1782
1782
|
}
|
|
1783
1783
|
}
|
|
1784
|
-
S.length && W.push(S),
|
|
1784
|
+
S.length && W.push(S), u === p.length - 1 && !Y && (Y = s);
|
|
1785
1785
|
}
|
|
1786
1786
|
})) : (W = p, Y = { ...M }), Y)
|
|
1787
1787
|
if (b.push(Y), Y.distanceFromPrevious = R, Y.hourFromPrevious = Math.round(R / A * 1e4) / 1e4, ((i = W[0]) == null ? void 0 : i.length) > 1) {
|
|
@@ -1916,8 +1916,8 @@ class u {
|
|
|
1916
1916
|
const b = M[A - 1], W = M[A], q = M[A + 1];
|
|
1917
1917
|
let o = !1, R = !1;
|
|
1918
1918
|
if ((b.velocity || b.suspend || b.important || b.pilot || A === 1) && (o = !0, O.push(b)), W.gcToPrevious && (o || (o = !0, O.push(b)), R = !0, O.push(W), A++), q) {
|
|
1919
|
-
const Y =
|
|
1920
|
-
Math.round(Math.acos(
|
|
1919
|
+
const Y = r.calculateDistance(b, W, !0), i = r.calculateDistance(W, q, !0), e = r.calculateDistance(b, q, !0), u = (Math.pow(Y, 2) + Math.pow(i, 2) - Math.pow(e, 2)) / (2 * Y * i);
|
|
1920
|
+
Math.round(Math.acos(u) * 180 / Math.PI) < p && e > z && !R && (O.push(W), A++);
|
|
1921
1921
|
}
|
|
1922
1922
|
if (A >= M.length - 1) {
|
|
1923
1923
|
const Y = M.at(-1);
|
|
@@ -1933,11 +1933,31 @@ class u {
|
|
|
1933
1933
|
* @param waypoints 带时间的轨迹, 单位秒
|
|
1934
1934
|
*/
|
|
1935
1935
|
static nearestTSPointInWaypoints(M, z, p) {
|
|
1936
|
-
const O =
|
|
1936
|
+
const O = C.unix(M), A = p.filter(
|
|
1937
1937
|
(b) => O.clone().subtract(z, "hour").unix() <= (b.positionTime || 0) && O.clone().add(z, "h").unix() >= (b.positionTime || 0)
|
|
1938
1938
|
);
|
|
1939
1939
|
return A.sort((b, W) => (b.positionTime || 0) - (W.positionTime || 0)), A.at(-1);
|
|
1940
1940
|
}
|
|
1941
|
+
/**
|
|
1942
|
+
* 推测船位
|
|
1943
|
+
* @param ts 目标时间的船位,单位 s
|
|
1944
|
+
* @param positions 带时间(positionTime)的轨迹
|
|
1945
|
+
*/
|
|
1946
|
+
static deadReckoning(M, z) {
|
|
1947
|
+
var A;
|
|
1948
|
+
M > 1e12 && (M = Math.round(M / 1e3));
|
|
1949
|
+
const p = C.unix(M);
|
|
1950
|
+
let O = z.find((b) => b.positionTime === p.unix());
|
|
1951
|
+
if (!O) {
|
|
1952
|
+
const b = (A = z.filter((q) => (q == null ? void 0 : q.positionTime) < p.unix())) == null ? void 0 : A.at(-1), W = z.find((q) => (q == null ? void 0 : q.positionTime) > p.unix());
|
|
1953
|
+
if (b && W) {
|
|
1954
|
+
const q = r.calculateBearing(b, W, !0), o = r.calculateDistance(b, W), R = (p.unix() - b.positionTime) / (W.positionTime - b.positionTime);
|
|
1955
|
+
O = r.calculateCoordinate(b, q, o * R), O.positionTime = p.unix(), O.utc = p.format();
|
|
1956
|
+
} else
|
|
1957
|
+
O = b || W, O && (O.utc = C.unix(O == null ? void 0 : O.positionTime).utc().format());
|
|
1958
|
+
}
|
|
1959
|
+
return O;
|
|
1960
|
+
}
|
|
1941
1961
|
/**
|
|
1942
1962
|
* 翻转轨迹
|
|
1943
1963
|
* @param route
|
|
@@ -1971,9 +1991,9 @@ class V0 {
|
|
|
1971
1991
|
const A = (p = O.history) == null ? void 0 : p[0];
|
|
1972
1992
|
A && A.wind && (A.wind.spd = A.spd, A.wind.kts = A.kts);
|
|
1973
1993
|
for (const b of O.forecasts) {
|
|
1974
|
-
const W = [], q =
|
|
1994
|
+
const W = [], q = C(b.date).utc(), o = `${O.name}-${b.model}`;
|
|
1975
1995
|
if (A) {
|
|
1976
|
-
const R =
|
|
1996
|
+
const R = C(A.updated).utc(), Y = T.point([A.lng, A.lat], {
|
|
1977
1997
|
model: b.model,
|
|
1978
1998
|
name: O.name,
|
|
1979
1999
|
date: R.format(),
|
|
@@ -2020,7 +2040,7 @@ class V0 {
|
|
|
2020
2040
|
if (O.history) {
|
|
2021
2041
|
const A = [];
|
|
2022
2042
|
for (const W of O.history) {
|
|
2023
|
-
const q =
|
|
2043
|
+
const q = C(W.updated).utc(), o = T.point([W.lng, W.lat], {
|
|
2024
2044
|
name: O.name,
|
|
2025
2045
|
date: q.format(),
|
|
2026
2046
|
format: q.format("MMM-DD/HHmm[Z]"),
|
|
@@ -2062,12 +2082,12 @@ class V0 {
|
|
|
2062
2082
|
var A, b, W, q;
|
|
2063
2083
|
const p = (A = M == null ? void 0 : M.data) == null ? void 0 : A.features.filter((o) => o.geometry.type === "LineString" && o.properties.type === "forecast"), O = [];
|
|
2064
2084
|
for (const o of p) {
|
|
2065
|
-
const R = o.properties.name, Y = o.properties.model, i = o.properties.showCircle, e = o.properties.disabled,
|
|
2066
|
-
let S = z * 60 - (
|
|
2085
|
+
const R = o.properties.name, Y = o.properties.model, i = o.properties.showCircle, e = o.properties.disabled, u = C(o.properties.date).utc();
|
|
2086
|
+
let S = z * 60 - (u.get("hour") * 60 + u.get("minute")) % (z * 60);
|
|
2067
2087
|
const s = (b = M == null ? void 0 : M.data) == null ? void 0 : b.features.filter(
|
|
2068
2088
|
(l) => l.geometry.type === "Point" && l.properties.type === "forecast" && l.properties.category === `${R}-${Y}`
|
|
2069
2089
|
);
|
|
2070
|
-
let P, G =
|
|
2090
|
+
let P, G = u.clone().add(S, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2071
2091
|
for (; P = this.pickIndex(s, G), P <= s.length - 1; ) {
|
|
2072
2092
|
if (P > 0) {
|
|
2073
2093
|
const l = s[P], N = P === 0 ? void 0 : s[P - 1], I = (S / 60 - ((W = N == null ? void 0 : N.properties) == null ? void 0 : W.hour)) / (l.properties.hour - ((q = N == null ? void 0 : N.properties) == null ? void 0 : q.hour)), H = this.computeNumber(N == null ? void 0 : N.geometry.coordinates[0], l.geometry.coordinates[0], I), Q = this.computeNumber(N == null ? void 0 : N.geometry.coordinates[1], l.geometry.coordinates[1], I), F = T.point([H, Q], {
|
|
@@ -2087,7 +2107,7 @@ class V0 {
|
|
|
2087
2107
|
});
|
|
2088
2108
|
O.push(F);
|
|
2089
2109
|
}
|
|
2090
|
-
S += z * 60, G =
|
|
2110
|
+
S += z * 60, G = u.clone().add(S, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2091
2111
|
}
|
|
2092
2112
|
}
|
|
2093
2113
|
return O;
|
|
@@ -2117,19 +2137,19 @@ class V0 {
|
|
|
2117
2137
|
const { t1: A, t2: b, hr: W, hours: q } = this.tropicalCenterTwin(z, 24, O);
|
|
2118
2138
|
if (A && b) {
|
|
2119
2139
|
if (!O.debug) {
|
|
2120
|
-
const
|
|
2121
|
-
if (
|
|
2122
|
-
return Z == null || Z.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", O.requestId,
|
|
2140
|
+
const u = r.calculateDistance(M, A), S = r.calculateDistance(M, b);
|
|
2141
|
+
if (u > 2 * p && S > 2 * p)
|
|
2142
|
+
return Z == null || Z.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", O.requestId, u, S, {
|
|
2123
2143
|
from: M,
|
|
2124
2144
|
t1: A,
|
|
2125
2145
|
t2: b,
|
|
2126
2146
|
hr: W
|
|
2127
2147
|
}), {};
|
|
2128
2148
|
}
|
|
2129
|
-
const o =
|
|
2149
|
+
const o = r.calculateBearing(M, A), R = r.calculateBearing(A, b), Y = Math.abs(o - R);
|
|
2130
2150
|
let i = 0;
|
|
2131
2151
|
Y < 180 ? i = Y + 90 : Y >= 180 && (i = Y - 90);
|
|
2132
|
-
const e =
|
|
2152
|
+
const e = r.calculateCoordinate(A, i, p);
|
|
2133
2153
|
return Z == null || Z.info("[%s] the right tangent position: %j", O.requestId, {
|
|
2134
2154
|
from: M,
|
|
2135
2155
|
t1: A,
|
|
@@ -2156,17 +2176,17 @@ class V0 {
|
|
|
2156
2176
|
const { t1: A, t2: b, hr: W, hours: q } = this.tropicalCenterTwin(z, 24, O);
|
|
2157
2177
|
if (A && b) {
|
|
2158
2178
|
if (!O.debug) {
|
|
2159
|
-
const e =
|
|
2160
|
-
if (e > 2 * p &&
|
|
2161
|
-
return Z == null || Z.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", O.requestId, e,
|
|
2179
|
+
const e = r.calculateDistance(M, A), u = r.calculateDistance(M, b);
|
|
2180
|
+
if (e > 2 * p && u > 2 * p)
|
|
2181
|
+
return Z == null || Z.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", O.requestId, e, u, {
|
|
2162
2182
|
from: M,
|
|
2163
2183
|
t1: A,
|
|
2164
2184
|
t2: b,
|
|
2165
2185
|
hr: W
|
|
2166
2186
|
}), {};
|
|
2167
2187
|
}
|
|
2168
|
-
const o =
|
|
2169
|
-
return { at:
|
|
2188
|
+
const o = r.calculateBearing(M, A), R = r.calculateBearing(A, b), Y = r.calculateDistance(M, A);
|
|
2189
|
+
return { at: r.calculateCoordinate(A, o - R + 180, p < Y ? p : Y), t1: A, t2: b, hr: Number(W), hours: q };
|
|
2170
2190
|
} else
|
|
2171
2191
|
return Z == null || Z.info("[%s] no need drift: %j", O.requestId, { from: M, t1: A, t2: b, hr: W }), {};
|
|
2172
2192
|
}
|
|
@@ -2179,7 +2199,7 @@ class V0 {
|
|
|
2179
2199
|
* @private
|
|
2180
2200
|
*/
|
|
2181
2201
|
static tropicalCenterTwin(M, z = 24, p = {}) {
|
|
2182
|
-
var R, Y, i, e,
|
|
2202
|
+
var R, Y, i, e, u;
|
|
2183
2203
|
let O = {};
|
|
2184
2204
|
(R = M.forecasts) == null || R.forEach((S) => {
|
|
2185
2205
|
O = { ...S.hours, ...O };
|
|
@@ -2187,7 +2207,7 @@ class V0 {
|
|
|
2187
2207
|
const A = ((Y = M == null ? void 0 : M.history) == null ? void 0 : Y[0]) || (O == null ? void 0 : O[(i = Object.keys(O)) == null ? void 0 : i[0]]);
|
|
2188
2208
|
Z == null || Z.info("[%s] the first tropical center: %j", p.requestId, A);
|
|
2189
2209
|
let b = (e = Object.keys(O || {}).filter((S) => Number(S) <= (z < 0 ? 24 : z))) == null ? void 0 : e.at(-1);
|
|
2190
|
-
b || (b = (
|
|
2210
|
+
b || (b = (u = Object.keys(O || {}).filter((S) => Number(S) <= (z < 0 ? 24 : 2 * z))) == null ? void 0 : u.at(-1));
|
|
2191
2211
|
const W = O == null ? void 0 : O[b || -1];
|
|
2192
2212
|
Z == null || Z.info("[%s] the second tropical center: %j in %d hrs", p.requestId, W, b);
|
|
2193
2213
|
const q = Object.keys(O || {}).filter((S) => Number(S) <= Number(b)), o = { 0: A };
|
|
@@ -2198,7 +2218,7 @@ class V0 {
|
|
|
2198
2218
|
static pickIndex(M, z) {
|
|
2199
2219
|
let p = 0;
|
|
2200
2220
|
for (const O of M) {
|
|
2201
|
-
if (
|
|
2221
|
+
if (C(O.properties.date).isAfter(z))
|
|
2202
2222
|
return p === 0 ? -1 : p;
|
|
2203
2223
|
p++;
|
|
2204
2224
|
}
|
|
@@ -2243,52 +2263,54 @@ class t0 {
|
|
|
2243
2263
|
};
|
|
2244
2264
|
}
|
|
2245
2265
|
static inspectStoppages(M, z = 1) {
|
|
2246
|
-
const p =
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2266
|
+
const p = M.at(0).positionTime < M.at(-1).positionTime;
|
|
2267
|
+
p || M.sort((A, b) => A.positionTime - b.positionTime);
|
|
2268
|
+
const O = [];
|
|
2269
|
+
for (let A = 0; A < M.length - 1; A++) {
|
|
2270
|
+
const b = M[A];
|
|
2271
|
+
if (b.sog = b.sog || 0, b.sog < z) {
|
|
2272
|
+
const W = b;
|
|
2273
|
+
let q = M.at(-1);
|
|
2274
|
+
for (let o = A + 1; o < M.length; o++) {
|
|
2275
|
+
const R = M[o];
|
|
2276
|
+
if (R.sog = R.sog || 0, R.sog <= z) {
|
|
2277
|
+
A = o;
|
|
2256
2278
|
continue;
|
|
2257
2279
|
} else {
|
|
2258
|
-
|
|
2280
|
+
A = o - 1, q = M[o - 1];
|
|
2259
2281
|
break;
|
|
2260
2282
|
}
|
|
2261
2283
|
}
|
|
2262
|
-
if (
|
|
2263
|
-
const
|
|
2284
|
+
if (q.positionTime != W.positionTime) {
|
|
2285
|
+
const o = {
|
|
2264
2286
|
start: {
|
|
2265
|
-
lat: b.lat,
|
|
2266
|
-
lng: b.lng,
|
|
2267
|
-
sog: b.sog,
|
|
2268
|
-
positionTime: b.positionTime,
|
|
2269
|
-
utc: g.unix(b.positionTime).utc().format()
|
|
2270
|
-
},
|
|
2271
|
-
end: {
|
|
2272
2287
|
lat: W.lat,
|
|
2273
2288
|
lng: W.lng,
|
|
2274
2289
|
sog: W.sog,
|
|
2275
2290
|
positionTime: W.positionTime,
|
|
2276
|
-
utc:
|
|
2291
|
+
utc: C.unix(W.positionTime).utc().format()
|
|
2277
2292
|
},
|
|
2278
|
-
|
|
2279
|
-
|
|
2293
|
+
end: {
|
|
2294
|
+
lat: q.lat,
|
|
2295
|
+
lng: q.lng,
|
|
2296
|
+
sog: q.sog,
|
|
2297
|
+
positionTime: q.positionTime,
|
|
2298
|
+
utc: C.unix(q.positionTime).utc().format()
|
|
2299
|
+
},
|
|
2300
|
+
duration: q.positionTime - W.positionTime,
|
|
2301
|
+
distance: r.calculateDistance(W, q, !0, 4),
|
|
2280
2302
|
avgSog: 0
|
|
2281
2303
|
};
|
|
2282
|
-
|
|
2304
|
+
o.avgSog = Math.round(o.distance / (o.duration / 3600) * 100) / 100, O.push(o);
|
|
2283
2305
|
}
|
|
2284
2306
|
}
|
|
2285
2307
|
}
|
|
2286
|
-
return p;
|
|
2308
|
+
return p || M.sort((A, b) => b.positionTime - A.positionTime), O;
|
|
2287
2309
|
}
|
|
2288
2310
|
}
|
|
2289
2311
|
export {
|
|
2290
2312
|
t0 as AisHelper,
|
|
2291
|
-
|
|
2313
|
+
r as LaneHelper,
|
|
2292
2314
|
a as LngLatHelper,
|
|
2293
2315
|
V0 as TropicalHelper
|
|
2294
2316
|
};
|