@idm-plugin/geo 1.6.9 → 1.7.0
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/ais/src/index.d.ts +1 -19
- package/dist/index.js +155 -160
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/ais/src/index.d.ts
CHANGED
|
@@ -31,23 +31,5 @@ export interface AISRecord {
|
|
|
31
31
|
export declare class AisHelper {
|
|
32
32
|
static json2Str(json: AISRecord): string;
|
|
33
33
|
static str2Json(str: string): AISRecord;
|
|
34
|
-
static inspectStoppages(rows: AISRecord[], threshold?: number):
|
|
35
|
-
start: {
|
|
36
|
-
lat: any;
|
|
37
|
-
lng: any;
|
|
38
|
-
sog: any;
|
|
39
|
-
positionTime: any;
|
|
40
|
-
utc: string;
|
|
41
|
-
};
|
|
42
|
-
end: {
|
|
43
|
-
lat: any;
|
|
44
|
-
lng: any;
|
|
45
|
-
sog: any;
|
|
46
|
-
positionTime: any;
|
|
47
|
-
utc: string;
|
|
48
|
-
};
|
|
49
|
-
duration: number;
|
|
50
|
-
distance: number;
|
|
51
|
-
avgSog: number;
|
|
52
|
-
}[];
|
|
34
|
+
static inspectStoppages(rows: AISRecord[], threshold?: number): any[];
|
|
53
35
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as e from "@turf/turf";
|
|
2
2
|
import C from "moment";
|
|
3
3
|
import _ from "@log4js-node/log4js-api";
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var a0 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
5
|
+
function X0(E) {
|
|
6
6
|
return E && E.__esModule && Object.prototype.hasOwnProperty.call(E, "default") ? E.default : E;
|
|
7
7
|
}
|
|
8
8
|
var j = { exports: {} };
|
|
@@ -14,7 +14,7 @@ var j = { exports: {} };
|
|
|
14
14
|
//! github.com/moment/moment-timezone
|
|
15
15
|
(function(M, z) {
|
|
16
16
|
E.exports ? E.exports = z(C) : z(M.moment);
|
|
17
|
-
})(
|
|
17
|
+
})(a0, 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;
|
|
20
20
|
(!M || typeof M.version != "string") && D("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
@@ -24,74 +24,74 @@ var j = { exports: {} };
|
|
|
24
24
|
return c > 96 ? c - 87 : c > 64 ? c - 29 : c - 48;
|
|
25
25
|
}
|
|
26
26
|
function i(c) {
|
|
27
|
-
var
|
|
28
|
-
for (c.charCodeAt(0) === 45 && (
|
|
29
|
-
t = L(n.charCodeAt(
|
|
30
|
-
for (
|
|
31
|
-
|
|
27
|
+
var a = 0, X = c.split("."), n = X[0], T = X[1] || "", N = 1, t, S = 0, V = 1;
|
|
28
|
+
for (c.charCodeAt(0) === 45 && (a = 1, V = -1), a; a < n.length; a++)
|
|
29
|
+
t = L(n.charCodeAt(a)), S = 60 * S + t;
|
|
30
|
+
for (a = 0; a < T.length; a++)
|
|
31
|
+
N = N / 60, t = L(T.charCodeAt(a)), S += t * N;
|
|
32
32
|
return S * V;
|
|
33
33
|
}
|
|
34
34
|
function U(c) {
|
|
35
|
-
for (var
|
|
36
|
-
c[
|
|
35
|
+
for (var a = 0; a < c.length; a++)
|
|
36
|
+
c[a] = i(c[a]);
|
|
37
37
|
}
|
|
38
|
-
function r(c,
|
|
39
|
-
for (var
|
|
40
|
-
c[
|
|
41
|
-
c[
|
|
38
|
+
function r(c, a) {
|
|
39
|
+
for (var X = 0; X < a; X++)
|
|
40
|
+
c[X] = Math.round((c[X - 1] || 0) + c[X] * 6e4);
|
|
41
|
+
c[a - 1] = 1 / 0;
|
|
42
42
|
}
|
|
43
|
-
function s(c,
|
|
44
|
-
var
|
|
45
|
-
for (n = 0; n <
|
|
46
|
-
|
|
47
|
-
return
|
|
43
|
+
function s(c, a) {
|
|
44
|
+
var X = [], n;
|
|
45
|
+
for (n = 0; n < a.length; n++)
|
|
46
|
+
X[n] = c[a[n]];
|
|
47
|
+
return X;
|
|
48
48
|
}
|
|
49
49
|
function P(c) {
|
|
50
|
-
var
|
|
51
|
-
return U(
|
|
52
|
-
name:
|
|
53
|
-
abbrs: s(
|
|
54
|
-
offsets: s(
|
|
50
|
+
var a = c.split("|"), X = a[2].split(" "), n = a[3].split(""), T = a[4].split(" ");
|
|
51
|
+
return U(X), U(n), U(T), r(T, n.length), {
|
|
52
|
+
name: a[0],
|
|
53
|
+
abbrs: s(a[1].split(" "), n),
|
|
54
|
+
offsets: s(X, n),
|
|
55
55
|
untils: T,
|
|
56
|
-
population:
|
|
56
|
+
population: a[5] | 0
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
function G(c) {
|
|
60
60
|
c && this._set(P(c));
|
|
61
61
|
}
|
|
62
|
-
function l(c,
|
|
63
|
-
var
|
|
64
|
-
if (c <
|
|
62
|
+
function l(c, a) {
|
|
63
|
+
var X = a.length;
|
|
64
|
+
if (c < a[0])
|
|
65
65
|
return 0;
|
|
66
|
-
if (
|
|
67
|
-
return
|
|
68
|
-
if (c >= X
|
|
66
|
+
if (X > 1 && a[X - 1] === 1 / 0 && c >= a[X - 2])
|
|
67
|
+
return X - 1;
|
|
68
|
+
if (c >= a[X - 1])
|
|
69
69
|
return -1;
|
|
70
|
-
for (var n, T = 0,
|
|
71
|
-
n = Math.floor((T +
|
|
72
|
-
return
|
|
70
|
+
for (var n, T = 0, N = X - 1; N - T > 1; )
|
|
71
|
+
n = Math.floor((T + N) / 2), a[n] <= c ? T = n : N = n;
|
|
72
|
+
return N;
|
|
73
73
|
}
|
|
74
74
|
G.prototype = {
|
|
75
75
|
_set: function(c) {
|
|
76
76
|
this.name = c.name, this.abbrs = c.abbrs, this.untils = c.untils, this.offsets = c.offsets, this.population = c.population;
|
|
77
77
|
},
|
|
78
78
|
_index: function(c) {
|
|
79
|
-
var
|
|
80
|
-
if (n = l(
|
|
79
|
+
var a = +c, X = this.untils, n;
|
|
80
|
+
if (n = l(a, X), n >= 0)
|
|
81
81
|
return n;
|
|
82
82
|
},
|
|
83
83
|
countries: function() {
|
|
84
84
|
var c = this.name;
|
|
85
|
-
return Object.keys(A).filter(function(
|
|
86
|
-
return A[
|
|
85
|
+
return Object.keys(A).filter(function(a) {
|
|
86
|
+
return A[a].zones.indexOf(c) !== -1;
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
89
|
parse: function(c) {
|
|
90
|
-
var
|
|
90
|
+
var a = +c, X = this.offsets, n = this.untils, T = n.length - 1, N, t, S, V;
|
|
91
91
|
for (V = 0; V < T; V++)
|
|
92
|
-
if (
|
|
93
|
-
return
|
|
94
|
-
return
|
|
92
|
+
if (N = X[V], t = X[V + 1], S = X[V && V - 1], N < t && u.moveAmbiguousForward ? N = t : N > S && u.moveInvalidForward && (N = S), a < n[V] - N * 6e4)
|
|
93
|
+
return X[V];
|
|
94
|
+
return X[T];
|
|
95
95
|
},
|
|
96
96
|
abbr: function(c) {
|
|
97
97
|
return this.abbrs[this._index(c)];
|
|
@@ -103,12 +103,12 @@ var j = { exports: {} };
|
|
|
103
103
|
return this.offsets[this._index(c)];
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
function B(c,
|
|
107
|
-
this.name = c, this.zones =
|
|
106
|
+
function B(c, a) {
|
|
107
|
+
this.name = c, this.zones = a;
|
|
108
108
|
}
|
|
109
109
|
function I(c) {
|
|
110
|
-
var
|
|
111
|
-
|
|
110
|
+
var a = c.toTimeString(), X = a.match(/\([a-z ]+\)/i);
|
|
111
|
+
X && X[0] ? (X = X[0].match(/[A-Z]/g), X = X ? X.join("") : void 0) : (X = a.match(/[A-Z]{3,5}/g), X = X ? X[0] : void 0), X === "GMT" && (X = void 0), this.at = +c, this.abbr = X, this.offset = c.getTimezoneOffset();
|
|
112
112
|
}
|
|
113
113
|
function H(c) {
|
|
114
114
|
this.zone = c, this.offsetScore = 0, this.abbrScore = 0;
|
|
@@ -116,58 +116,58 @@ var j = { exports: {} };
|
|
|
116
116
|
H.prototype.scoreOffsetAt = function(c) {
|
|
117
117
|
this.offsetScore += Math.abs(this.zone.utcOffset(c.at) - c.offset), this.zone.abbr(c.at).replace(/[^A-Z]/g, "") !== c.abbr && this.abbrScore++;
|
|
118
118
|
};
|
|
119
|
-
function Q(c,
|
|
120
|
-
for (var
|
|
121
|
-
|
|
119
|
+
function Q(c, a) {
|
|
120
|
+
for (var X, n; n = ((a.at - c.at) / 12e4 | 0) * 6e4; )
|
|
121
|
+
X = new I(new Date(c.at + n)), X.offset === c.offset ? c = X : a = X;
|
|
122
122
|
return c;
|
|
123
123
|
}
|
|
124
124
|
function F() {
|
|
125
|
-
var c = (/* @__PURE__ */ new Date()).getFullYear() - 2,
|
|
125
|
+
var c = (/* @__PURE__ */ new Date()).getFullYear() - 2, a = new I(new Date(c, 0, 1)), X = a.offset, n = [a], T, N, t, S;
|
|
126
126
|
for (S = 1; S < 48; S++)
|
|
127
|
-
t = new Date(c, S, 1).getTimezoneOffset(), t !==
|
|
127
|
+
t = new Date(c, S, 1).getTimezoneOffset(), t !== X && (N = new I(new Date(c, S, 1)), T = Q(a, N), n.push(T), n.push(new I(new Date(T.at + 6e4))), a = N, X = t);
|
|
128
128
|
for (S = 0; S < 4; S++)
|
|
129
129
|
n.push(new I(new Date(c + S, 0, 1))), n.push(new I(new Date(c + S, 6, 1)));
|
|
130
130
|
return n;
|
|
131
131
|
}
|
|
132
|
-
function M0(c,
|
|
133
|
-
return c.offsetScore !==
|
|
132
|
+
function M0(c, a) {
|
|
133
|
+
return c.offsetScore !== a.offsetScore ? c.offsetScore - a.offsetScore : c.abbrScore !== a.abbrScore ? c.abbrScore - a.abbrScore : c.zone.population !== a.zone.population ? a.zone.population - c.zone.population : a.zone.name.localeCompare(c.zone.name);
|
|
134
134
|
}
|
|
135
|
-
function z0(c,
|
|
136
|
-
var
|
|
137
|
-
for (U(
|
|
138
|
-
n = X
|
|
135
|
+
function z0(c, a) {
|
|
136
|
+
var X, n;
|
|
137
|
+
for (U(a), X = 0; X < a.length; X++)
|
|
138
|
+
n = a[X], W[n] = W[n] || {}, W[n][c] = !0;
|
|
139
139
|
}
|
|
140
140
|
function b0(c) {
|
|
141
|
-
var
|
|
142
|
-
for (
|
|
143
|
-
if (S = c[
|
|
141
|
+
var a = c.length, X = {}, n = [], T = {}, N, t, S, V;
|
|
142
|
+
for (N = 0; N < a; N++)
|
|
143
|
+
if (S = c[N].offset, !T.hasOwnProperty(S)) {
|
|
144
144
|
V = W[S] || {};
|
|
145
145
|
for (t in V)
|
|
146
|
-
V.hasOwnProperty(t) && (
|
|
146
|
+
V.hasOwnProperty(t) && (X[t] = !0);
|
|
147
147
|
T[S] = !0;
|
|
148
148
|
}
|
|
149
|
-
for (
|
|
150
|
-
|
|
149
|
+
for (N in X)
|
|
150
|
+
X.hasOwnProperty(N) && n.push(b[N]);
|
|
151
151
|
return n;
|
|
152
152
|
}
|
|
153
153
|
function p0() {
|
|
154
154
|
try {
|
|
155
155
|
var c = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
156
156
|
if (c && c.length > 3) {
|
|
157
|
-
var
|
|
158
|
-
if (
|
|
159
|
-
return
|
|
157
|
+
var a = b[K(c)];
|
|
158
|
+
if (a)
|
|
159
|
+
return a;
|
|
160
160
|
D("Moment Timezone found " + c + " from the Intl api, but did not have that data loaded.");
|
|
161
161
|
}
|
|
162
162
|
} catch {
|
|
163
163
|
}
|
|
164
|
-
var
|
|
164
|
+
var X = F(), n = X.length, T = b0(X), N = [], t, S, V;
|
|
165
165
|
for (S = 0; S < T.length; S++) {
|
|
166
166
|
for (t = new H(g(T[S])), V = 0; V < n; V++)
|
|
167
|
-
t.scoreOffsetAt(
|
|
168
|
-
|
|
167
|
+
t.scoreOffsetAt(X[V]);
|
|
168
|
+
N.push(t);
|
|
169
169
|
}
|
|
170
|
-
return
|
|
170
|
+
return N.sort(M0), N.length > 0 ? N[0].zone.name : void 0;
|
|
171
171
|
}
|
|
172
172
|
function O0(c) {
|
|
173
173
|
return (!q || c) && (q = p0()), q;
|
|
@@ -176,52 +176,52 @@ var j = { exports: {} };
|
|
|
176
176
|
return (c || "").toLowerCase().replace(/\//g, "_");
|
|
177
177
|
}
|
|
178
178
|
function k(c) {
|
|
179
|
-
var
|
|
180
|
-
for (typeof c == "string" && (c = [c]),
|
|
181
|
-
n = c[
|
|
179
|
+
var a, X, n, T;
|
|
180
|
+
for (typeof c == "string" && (c = [c]), a = 0; a < c.length; a++)
|
|
181
|
+
n = c[a].split("|"), X = n[0], T = K(X), p[T] = c[a], b[T] = X, z0(T, n[2].split(" "));
|
|
182
182
|
}
|
|
183
|
-
function g(c,
|
|
183
|
+
function g(c, a) {
|
|
184
184
|
c = K(c);
|
|
185
|
-
var
|
|
186
|
-
return
|
|
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] && a !== 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
|
-
var c,
|
|
189
|
+
var c, a = [];
|
|
190
190
|
for (c in b)
|
|
191
|
-
b.hasOwnProperty(c) && (p[c] || p[O[c]]) && b[c] &&
|
|
192
|
-
return
|
|
191
|
+
b.hasOwnProperty(c) && (p[c] || p[O[c]]) && b[c] && a.push(b[c]);
|
|
192
|
+
return a.sort();
|
|
193
193
|
}
|
|
194
194
|
function c0() {
|
|
195
195
|
return Object.keys(A);
|
|
196
196
|
}
|
|
197
197
|
function v(c) {
|
|
198
|
-
var
|
|
199
|
-
for (typeof c == "string" && (c = [c]),
|
|
200
|
-
|
|
198
|
+
var a, X, n, T;
|
|
199
|
+
for (typeof c == "string" && (c = [c]), a = 0; a < c.length; a++)
|
|
200
|
+
X = c[a].split("|"), n = K(X[0]), T = K(X[1]), O[n] = T, b[n] = X[0], O[T] = n, b[T] = X[1];
|
|
201
201
|
}
|
|
202
202
|
function W0(c) {
|
|
203
|
-
var
|
|
203
|
+
var a, X, n, T;
|
|
204
204
|
if (!(!c || !c.length))
|
|
205
|
-
for (
|
|
206
|
-
T = c[
|
|
207
|
-
|
|
205
|
+
for (a = 0; a < c.length; a++)
|
|
206
|
+
T = c[a].split("|"), X = T[0].toUpperCase(), n = T[1].split(" "), A[X] = new B(
|
|
207
|
+
X,
|
|
208
208
|
n
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
211
|
function q0(c) {
|
|
212
212
|
return c = c.toUpperCase(), A[c] || null;
|
|
213
213
|
}
|
|
214
|
-
function o0(c,
|
|
214
|
+
function o0(c, a) {
|
|
215
215
|
if (c = q0(c), !c)
|
|
216
216
|
return null;
|
|
217
|
-
var
|
|
218
|
-
return
|
|
217
|
+
var X = c.zones.sort();
|
|
218
|
+
return a ? X.map(function(n) {
|
|
219
219
|
var T = g(n);
|
|
220
220
|
return {
|
|
221
221
|
name: n,
|
|
222
222
|
offset: T.utcOffset(/* @__PURE__ */ new Date())
|
|
223
223
|
};
|
|
224
|
-
}) :
|
|
224
|
+
}) : X;
|
|
225
225
|
}
|
|
226
226
|
function Y0(c) {
|
|
227
227
|
k(c.zones), v(c.links), W0(c.countries), u.dataVersion = c.version;
|
|
@@ -230,31 +230,31 @@ var j = { exports: {} };
|
|
|
230
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
|
-
var
|
|
234
|
-
return !!(c._a && c._tzm === void 0 && !
|
|
233
|
+
var a = c._f === "X" || c._f === "x";
|
|
234
|
+
return !!(c._a && c._tzm === void 0 && !a);
|
|
235
235
|
}
|
|
236
236
|
function D(c) {
|
|
237
237
|
typeof console < "u" && typeof console.error == "function" && console.error(c);
|
|
238
238
|
}
|
|
239
239
|
function u(c) {
|
|
240
|
-
var
|
|
241
|
-
return !M.isMoment(c) && J(n) && (T = g(
|
|
240
|
+
var a = Array.prototype.slice.call(arguments, 0, -1), X = arguments[arguments.length - 1], n = M.utc.apply(null, a), T;
|
|
241
|
+
return !M.isMoment(c) && J(n) && (T = g(X)) && n.add(T.parse(n), "minutes"), n.tz(X), n;
|
|
242
242
|
}
|
|
243
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 = i, u.needsOffset = J, u.moveInvalidForward = !0, u.moveAmbiguousForward = !1, u.countries = c0, u.zonesForCountry = o0;
|
|
244
244
|
var m = M.fn;
|
|
245
|
-
M.tz = u, M.defaultZone = null, M.updateOffset = function(c,
|
|
246
|
-
var
|
|
247
|
-
if (c._z === void 0 && (
|
|
245
|
+
M.tz = u, M.defaultZone = null, M.updateOffset = function(c, a) {
|
|
246
|
+
var X = M.defaultZone, n;
|
|
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) {
|
|
249
249
|
var T = c._z;
|
|
250
|
-
c.utcOffset(-n,
|
|
250
|
+
c.utcOffset(-n, a), c._z = T;
|
|
251
251
|
} else
|
|
252
|
-
c.zone(n,
|
|
253
|
-
}, m.tz = function(c,
|
|
252
|
+
c.zone(n, a);
|
|
253
|
+
}, m.tz = function(c, a) {
|
|
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 = g(c), this._z ? M.updateOffset(this,
|
|
257
|
+
return this._z = g(c), this._z ? M.updateOffset(this, a) : 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;
|
|
@@ -1152,7 +1152,7 @@ var x = { exports: {} };
|
|
|
1152
1152
|
E.exports = M;
|
|
1153
1153
|
})(x);
|
|
1154
1154
|
var N0 = x.exports;
|
|
1155
|
-
const B0 = /* @__PURE__ */
|
|
1155
|
+
const B0 = /* @__PURE__ */ X0(N0);
|
|
1156
1156
|
class R {
|
|
1157
1157
|
/**
|
|
1158
1158
|
* 基于输入的经度,计算出时区
|
|
@@ -1310,7 +1310,7 @@ try {
|
|
|
1310
1310
|
} catch {
|
|
1311
1311
|
} finally {
|
|
1312
1312
|
}
|
|
1313
|
-
class
|
|
1313
|
+
class f {
|
|
1314
1314
|
/**
|
|
1315
1315
|
* 计算方位角
|
|
1316
1316
|
* @param from 坐标 {lng, lat}
|
|
@@ -1508,8 +1508,8 @@ class N {
|
|
|
1508
1508
|
*/
|
|
1509
1509
|
static appendCoordinateToRoute(M, z) {
|
|
1510
1510
|
M.lng = R.convertToStdLng(M.lng, 8);
|
|
1511
|
-
const p =
|
|
1512
|
-
return p.push(M),
|
|
1511
|
+
const p = f.convertRouteToCoordinates(z);
|
|
1512
|
+
return p.push(M), f.divideAccordingToLng(p);
|
|
1513
1513
|
}
|
|
1514
1514
|
/**
|
|
1515
1515
|
* 向route头加1个坐标
|
|
@@ -1517,8 +1517,8 @@ class N {
|
|
|
1517
1517
|
* @param route
|
|
1518
1518
|
*/
|
|
1519
1519
|
static unshiftCoordinateToRoute(M, z) {
|
|
1520
|
-
const p =
|
|
1521
|
-
return p.unshift(M),
|
|
1520
|
+
const p = f.convertRouteToCoordinates(z);
|
|
1521
|
+
return p.unshift(M), f.divideAccordingToLng(p);
|
|
1522
1522
|
}
|
|
1523
1523
|
/**
|
|
1524
1524
|
* 合并多个waypoints进航线
|
|
@@ -1592,8 +1592,8 @@ class N {
|
|
|
1592
1592
|
* @return [[[lng, lat]]]
|
|
1593
1593
|
*/
|
|
1594
1594
|
static calculateSubRoute(M, z) {
|
|
1595
|
-
const p =
|
|
1596
|
-
|
|
1595
|
+
const p = f.convertRouteToCoordinates(z);
|
|
1596
|
+
f.mergeCoordinateToWaypoints(M, p, !0), z = f.divideAccordingToLng(p);
|
|
1597
1597
|
const { segIndex: O, minIndex: A } = this.calculateMinDistanceToRoute({ ...M }, z);
|
|
1598
1598
|
M.lng = R.convertToStdLng(M.lng);
|
|
1599
1599
|
const b = [];
|
|
@@ -1916,7 +1916,7 @@ class N {
|
|
|
1916
1916
|
const b = M[A - 1], W = M[A], q = M[A + 1];
|
|
1917
1917
|
let o = !1, d = !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)), d = !0, O.push(W), A++), q) {
|
|
1919
|
-
const Y =
|
|
1919
|
+
const Y = f.calculateDistance(b, W, !0), L = f.calculateDistance(W, q, !0), i = f.calculateDistance(b, q, !0), U = (Math.pow(Y, 2) + Math.pow(L, 2) - Math.pow(i, 2)) / (2 * Y * L);
|
|
1920
1920
|
Math.round(Math.acos(U) * 180 / Math.PI) < p && i > z && !d && (O.push(W), A++);
|
|
1921
1921
|
}
|
|
1922
1922
|
if (A >= M.length - 1) {
|
|
@@ -1951,8 +1951,8 @@ class N {
|
|
|
1951
1951
|
if (!O) {
|
|
1952
1952
|
const o = (b = (A = z.filter((Y) => (Y == null ? void 0 : Y.positionTime) < p.unix())) == null ? void 0 : A.sort((Y, L) => (Y.positionTime || 0) - (L.positionTime || 0))) == null ? void 0 : b.at(-1), d = (q = (W = z.filter((Y) => (Y == null ? void 0 : Y.positionTime) > p.unix())) == null ? void 0 : W.sort((Y, L) => (Y.positionTime || 0) - (L.positionTime || 0))) == null ? void 0 : q.at(0);
|
|
1953
1953
|
if (o && d) {
|
|
1954
|
-
const Y =
|
|
1955
|
-
O =
|
|
1954
|
+
const Y = f.calculateBearing(o, d, !0), L = f.calculateDistance(o, d), i = (p.unix() - o.positionTime) / (d.positionTime - o.positionTime);
|
|
1955
|
+
O = f.calculateCoordinate(o, Y, L * i), O.positionTime = p.unix(), O.utc = p.format(), O.cog = Y, O.sog = Math.round(L / ((d.positionTime - o.positionTime) / 3600) * 100) / 100;
|
|
1956
1956
|
} else
|
|
1957
1957
|
O = o || d, O && (O.utc = C.unix(O == null ? void 0 : O.positionTime).utc().format());
|
|
1958
1958
|
}
|
|
@@ -1967,16 +1967,16 @@ class N {
|
|
|
1967
1967
|
z = JSON.parse(JSON.stringify(z)), z.sort((o, d) => o.positionTime - d.positionTime);
|
|
1968
1968
|
let p = Number.MAX_SAFE_INTEGER, O = Number.MAX_SAFE_INTEGER;
|
|
1969
1969
|
for (let o = 0; o < z.length - 1; o++) {
|
|
1970
|
-
const d = z[o], Y = z[o + 1], L =
|
|
1970
|
+
const d = z[o], Y = z[o + 1], L = f.calculatePointToLineDistance(M, d, Y);
|
|
1971
1971
|
L < p && (p = L, O = o);
|
|
1972
1972
|
}
|
|
1973
|
-
const A = z[O], b = z[O + 1], W =
|
|
1973
|
+
const A = z[O], b = z[O + 1], W = f.calculateDistance(A, M), q = f.calculateDistance(b, M);
|
|
1974
1974
|
if (W === 0)
|
|
1975
1975
|
M = A;
|
|
1976
1976
|
else if (q === 0)
|
|
1977
1977
|
M = b;
|
|
1978
1978
|
else {
|
|
1979
|
-
const o =
|
|
1979
|
+
const o = f.nearestCoordinateInLine(M, A, b), d = A.positionTime, Y = b.positionTime, L = f.calculateDistance(A, o), i = f.calculateDistance(A, b), U = Math.round(d + (Y - d) * (L / i));
|
|
1980
1980
|
M.positionTime = U;
|
|
1981
1981
|
}
|
|
1982
1982
|
return M.utc = M.positionTime ? C.unix(M.positionTime).utc().format() : void 0, M.positionTime ? M : void 0;
|
|
@@ -2160,7 +2160,7 @@ class V0 {
|
|
|
2160
2160
|
const { t1: A, t2: b, hr: W, hours: q } = this.tropicalCenterTwin(z, 24, O);
|
|
2161
2161
|
if (A && b) {
|
|
2162
2162
|
if (!O.debug) {
|
|
2163
|
-
const U =
|
|
2163
|
+
const U = f.calculateDistance(M, A), r = f.calculateDistance(M, b);
|
|
2164
2164
|
if (U > 2 * p && r > 2 * p)
|
|
2165
2165
|
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, r, {
|
|
2166
2166
|
from: M,
|
|
@@ -2169,10 +2169,10 @@ class V0 {
|
|
|
2169
2169
|
hr: W
|
|
2170
2170
|
}), {};
|
|
2171
2171
|
}
|
|
2172
|
-
const o =
|
|
2172
|
+
const o = f.calculateBearing(M, A), d = f.calculateBearing(A, b), Y = Math.abs(o - d);
|
|
2173
2173
|
let L = 0;
|
|
2174
2174
|
Y < 180 ? L = Y + 90 : Y >= 180 && (L = Y - 90);
|
|
2175
|
-
const i =
|
|
2175
|
+
const i = f.calculateCoordinate(A, L, p);
|
|
2176
2176
|
return Z == null || Z.info("[%s] the right tangent position: %j", O.requestId, {
|
|
2177
2177
|
from: M,
|
|
2178
2178
|
t1: A,
|
|
@@ -2199,7 +2199,7 @@ class V0 {
|
|
|
2199
2199
|
const { t1: A, t2: b, hr: W, hours: q } = this.tropicalCenterTwin(z, 24, O);
|
|
2200
2200
|
if (A && b) {
|
|
2201
2201
|
if (!O.debug) {
|
|
2202
|
-
const i =
|
|
2202
|
+
const i = f.calculateDistance(M, A), U = f.calculateDistance(M, b);
|
|
2203
2203
|
if (i > 2 * p && U > 2 * p)
|
|
2204
2204
|
return Z == null || Z.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", O.requestId, i, U, {
|
|
2205
2205
|
from: M,
|
|
@@ -2208,8 +2208,8 @@ class V0 {
|
|
|
2208
2208
|
hr: W
|
|
2209
2209
|
}), {};
|
|
2210
2210
|
}
|
|
2211
|
-
const o =
|
|
2212
|
-
return { at:
|
|
2211
|
+
const o = f.calculateBearing(M, A), d = f.calculateBearing(A, b), Y = f.calculateDistance(M, A);
|
|
2212
|
+
return { at: f.calculateCoordinate(A, o - d + 180, p < Y ? p : Y), t1: A, t2: b, hr: Number(W), hours: q };
|
|
2213
2213
|
} else
|
|
2214
2214
|
return Z == null || Z.info("[%s] no need drift: %j", O.requestId, { from: M, t1: A, t2: b, hr: W }), {};
|
|
2215
2215
|
}
|
|
@@ -2287,53 +2287,48 @@ class t0 {
|
|
|
2287
2287
|
}
|
|
2288
2288
|
static inspectStoppages(M, z = 1) {
|
|
2289
2289
|
const p = M.at(0).positionTime < M.at(-1).positionTime;
|
|
2290
|
-
p || M.sort((
|
|
2290
|
+
p || M.sort((W, q) => W.positionTime - q.positionTime);
|
|
2291
2291
|
const O = [];
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
} else {
|
|
2303
|
-
A = o - 1, q = M[o - 1];
|
|
2304
|
-
break;
|
|
2305
|
-
}
|
|
2306
|
-
}
|
|
2307
|
-
if (q.positionTime != W.positionTime) {
|
|
2308
|
-
const o = {
|
|
2309
|
-
start: {
|
|
2310
|
-
lat: W.lat,
|
|
2311
|
-
lng: W.lng,
|
|
2312
|
-
sog: W.sog,
|
|
2313
|
-
positionTime: W.positionTime,
|
|
2314
|
-
utc: C.unix(W.positionTime).utc().format()
|
|
2315
|
-
},
|
|
2316
|
-
end: {
|
|
2317
|
-
lat: q.lat,
|
|
2318
|
-
lng: q.lng,
|
|
2319
|
-
sog: q.sog,
|
|
2320
|
-
positionTime: q.positionTime,
|
|
2321
|
-
utc: C.unix(q.positionTime).utc().format()
|
|
2322
|
-
},
|
|
2323
|
-
duration: q.positionTime - W.positionTime,
|
|
2324
|
-
distance: N.calculateDistance(W, q, !0, 4),
|
|
2325
|
-
avgSog: 0
|
|
2326
|
-
};
|
|
2327
|
-
o.avgSog = Math.round(o.distance / (o.duration / 3600) * 100) / 100, O.push(o);
|
|
2292
|
+
let A, b;
|
|
2293
|
+
for (let W = 0; W < M.length - 1; W++) {
|
|
2294
|
+
const q = M[W];
|
|
2295
|
+
for (let o = W + 1; o < M.length; o++) {
|
|
2296
|
+
const d = M[o - 1], Y = M[o], L = Y.positionTime - d.positionTime;
|
|
2297
|
+
if (f.calculateDistance(q, Y, !0, 4) / (L / 3600) < z)
|
|
2298
|
+
A || (A = q), o === M.length - 1 && (b = Y, W = o);
|
|
2299
|
+
else {
|
|
2300
|
+
A && (b = M[o - 1], W = o);
|
|
2301
|
+
break;
|
|
2328
2302
|
}
|
|
2329
2303
|
}
|
|
2304
|
+
if ((b == null ? void 0 : b.positionTime) > (A == null ? void 0 : A.positionTime)) {
|
|
2305
|
+
const o = {
|
|
2306
|
+
start: {
|
|
2307
|
+
lat: A.lat,
|
|
2308
|
+
lng: A.lng,
|
|
2309
|
+
sog: A.sog,
|
|
2310
|
+
positionTime: A.positionTime,
|
|
2311
|
+
utc: C.unix(A.positionTime).utc().format()
|
|
2312
|
+
},
|
|
2313
|
+
end: {
|
|
2314
|
+
lat: b.lat,
|
|
2315
|
+
lng: b.lng,
|
|
2316
|
+
sog: b.sog,
|
|
2317
|
+
positionTime: b.positionTime,
|
|
2318
|
+
utc: C.unix(b.positionTime).utc().format()
|
|
2319
|
+
},
|
|
2320
|
+
duration: b.positionTime - A.positionTime
|
|
2321
|
+
}, d = M.filter((L) => L.positionTime >= o.start.positionTime && L.positionTime <= o.end.positionTime), Y = f.divideAccordingToLng(d);
|
|
2322
|
+
o.distance = f.calculateRouteDistance(Y), o.hours = Math.round(o.duration / 3600 * 10) / 10, o.avgSog = Math.round(o.distance / o.hours * 10) / 10, O.push(o);
|
|
2323
|
+
}
|
|
2324
|
+
A = void 0, b = void 0;
|
|
2330
2325
|
}
|
|
2331
|
-
return p || M.sort((
|
|
2326
|
+
return p || M.sort((W, q) => q.positionTime - W.positionTime), O;
|
|
2332
2327
|
}
|
|
2333
2328
|
}
|
|
2334
2329
|
export {
|
|
2335
2330
|
t0 as AisHelper,
|
|
2336
|
-
|
|
2331
|
+
f as LaneHelper,
|
|
2337
2332
|
R as LngLatHelper,
|
|
2338
2333
|
V0 as TropicalHelper
|
|
2339
2334
|
};
|