@idm-plugin/geo 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +449 -444
- package/dist/index.umd.cjs +6 -6
- package/dist/lane/src/index.d.ts +4 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as t from "@turf/turf";
|
|
2
|
+
import U from "moment";
|
|
3
3
|
import j from "@log4js-node/log4js-api";
|
|
4
4
|
var n0 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
5
5
|
function X0(m) {
|
|
@@ -13,208 +13,208 @@ var _ = { exports: {} };
|
|
|
13
13
|
//! license : MIT
|
|
14
14
|
//! github.com/moment/moment-timezone
|
|
15
15
|
(function(M, z) {
|
|
16
|
-
m.exports ? m.exports = z(
|
|
16
|
+
m.exports ? m.exports = z(U) : z(M.moment);
|
|
17
17
|
})(n0, function(M) {
|
|
18
18
|
M.version === void 0 && M.default && (M = M.default);
|
|
19
19
|
var z = "0.5.48", p = {}, b = {}, c = {}, O = {}, A = {}, W;
|
|
20
20
|
(!M || typeof M.version != "string") && D("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
21
|
-
var
|
|
22
|
-
(
|
|
23
|
-
function R(
|
|
24
|
-
return
|
|
21
|
+
var q = M.version.split("."), d = +q[0], Y = +q[1];
|
|
22
|
+
(d < 2 || d === 2 && Y < 6) && D("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
|
|
23
|
+
function R(o) {
|
|
24
|
+
return o > 96 ? o - 87 : o > 64 ? o - 29 : o - 48;
|
|
25
25
|
}
|
|
26
|
-
function T(
|
|
27
|
-
var n = 0, X =
|
|
28
|
-
for (
|
|
29
|
-
E = R(L.charCodeAt(n)),
|
|
26
|
+
function T(o) {
|
|
27
|
+
var n = 0, X = o.split("."), L = X[0], N = X[1] || "", V = 1, E, s = 0, P = 1;
|
|
28
|
+
for (o.charCodeAt(0) === 45 && (n = 1, P = -1), n; n < L.length; n++)
|
|
29
|
+
E = R(L.charCodeAt(n)), s = 60 * s + E;
|
|
30
30
|
for (n = 0; n < N.length; n++)
|
|
31
|
-
|
|
32
|
-
return
|
|
31
|
+
V = V / 60, E = R(N.charCodeAt(n)), s += E * V;
|
|
32
|
+
return s * P;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
for (var n = 0; n <
|
|
36
|
-
|
|
34
|
+
function e(o) {
|
|
35
|
+
for (var n = 0; n < o.length; n++)
|
|
36
|
+
o[n] = T(o[n]);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function f(o, n) {
|
|
39
39
|
for (var X = 0; X < n; X++)
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
o[X] = Math.round((o[X - 1] || 0) + o[X] * 6e4);
|
|
41
|
+
o[n - 1] = 1 / 0;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function i(o, n) {
|
|
44
44
|
var X = [], L;
|
|
45
45
|
for (L = 0; L < n.length; L++)
|
|
46
|
-
X[L] =
|
|
46
|
+
X[L] = o[n[L]];
|
|
47
47
|
return X;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
var n =
|
|
51
|
-
return
|
|
49
|
+
function S(o) {
|
|
50
|
+
var n = o.split("|"), X = n[2].split(" "), L = n[3].split(""), N = n[4].split(" ");
|
|
51
|
+
return e(X), e(L), e(N), f(N, L.length), {
|
|
52
52
|
name: n[0],
|
|
53
|
-
abbrs:
|
|
54
|
-
offsets:
|
|
53
|
+
abbrs: i(n[1].split(" "), L),
|
|
54
|
+
offsets: i(X, L),
|
|
55
55
|
untils: N,
|
|
56
56
|
population: n[5] | 0
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
59
|
+
function u(o) {
|
|
60
|
+
o && this._set(S(o));
|
|
61
61
|
}
|
|
62
|
-
function Z(
|
|
62
|
+
function Z(o, n) {
|
|
63
63
|
var X = n.length;
|
|
64
|
-
if (
|
|
64
|
+
if (o < n[0])
|
|
65
65
|
return 0;
|
|
66
|
-
if (X > 1 && n[X - 1] === 1 / 0 &&
|
|
66
|
+
if (X > 1 && n[X - 1] === 1 / 0 && o >= n[X - 2])
|
|
67
67
|
return X - 1;
|
|
68
|
-
if (
|
|
68
|
+
if (o >= n[X - 1])
|
|
69
69
|
return -1;
|
|
70
|
-
for (var L, N = 0,
|
|
71
|
-
L = Math.floor((N +
|
|
72
|
-
return
|
|
70
|
+
for (var L, N = 0, V = X - 1; V - N > 1; )
|
|
71
|
+
L = Math.floor((N + V) / 2), n[L] <= o ? N = L : V = L;
|
|
72
|
+
return V;
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
_set: function(
|
|
76
|
-
this.name =
|
|
74
|
+
u.prototype = {
|
|
75
|
+
_set: function(o) {
|
|
76
|
+
this.name = o.name, this.abbrs = o.abbrs, this.untils = o.untils, this.offsets = o.offsets, this.population = o.population;
|
|
77
77
|
},
|
|
78
|
-
_index: function(
|
|
79
|
-
var n = +
|
|
78
|
+
_index: function(o) {
|
|
79
|
+
var n = +o, X = this.untils, L;
|
|
80
80
|
if (L = Z(n, X), L >= 0)
|
|
81
81
|
return L;
|
|
82
82
|
},
|
|
83
83
|
countries: function() {
|
|
84
|
-
var
|
|
84
|
+
var o = this.name;
|
|
85
85
|
return Object.keys(c).filter(function(n) {
|
|
86
|
-
return c[n].zones.indexOf(
|
|
86
|
+
return c[n].zones.indexOf(o) !== -1;
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
|
-
parse: function(
|
|
90
|
-
var n = +
|
|
89
|
+
parse: function(o) {
|
|
90
|
+
var n = +o, X = this.offsets, L = this.untils, N = L.length - 1, V, E, s, P;
|
|
91
91
|
for (P = 0; P < N; P++)
|
|
92
|
-
if (
|
|
92
|
+
if (V = X[P], E = X[P + 1], s = X[P && P - 1], V < E && l.moveAmbiguousForward ? V = E : V > s && l.moveInvalidForward && (V = s), n < L[P] - V * 6e4)
|
|
93
93
|
return X[P];
|
|
94
94
|
return X[N];
|
|
95
95
|
},
|
|
96
|
-
abbr: function(
|
|
97
|
-
return this.abbrs[this._index(
|
|
96
|
+
abbr: function(o) {
|
|
97
|
+
return this.abbrs[this._index(o)];
|
|
98
98
|
},
|
|
99
|
-
offset: function(
|
|
100
|
-
return D("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(
|
|
99
|
+
offset: function(o) {
|
|
100
|
+
return D("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(o)];
|
|
101
101
|
},
|
|
102
|
-
utcOffset: function(
|
|
103
|
-
return this.offsets[this._index(
|
|
102
|
+
utcOffset: function(o) {
|
|
103
|
+
return this.offsets[this._index(o)];
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
function
|
|
107
|
-
this.name =
|
|
106
|
+
function B(o, n) {
|
|
107
|
+
this.name = o, this.zones = n;
|
|
108
108
|
}
|
|
109
|
-
function G(
|
|
110
|
-
var n =
|
|
111
|
-
X && X[0] ? (X = X[0].match(/[A-Z]/g), X = X ? X.join("") : void 0) : (X = n.match(/[A-Z]{3,5}/g), X = X ? X[0] : void 0), X === "GMT" && (X = void 0), this.at = +
|
|
109
|
+
function G(o) {
|
|
110
|
+
var n = o.toTimeString(), X = n.match(/\([a-z ]+\)/i);
|
|
111
|
+
X && X[0] ? (X = X[0].match(/[A-Z]/g), X = X ? X.join("") : void 0) : (X = n.match(/[A-Z]{3,5}/g), X = X ? X[0] : void 0), X === "GMT" && (X = void 0), this.at = +o, this.abbr = X, this.offset = o.getTimezoneOffset();
|
|
112
112
|
}
|
|
113
|
-
function
|
|
114
|
-
this.zone =
|
|
113
|
+
function Q(o) {
|
|
114
|
+
this.zone = o, this.offsetScore = 0, this.abbrScore = 0;
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
this.offsetScore += Math.abs(this.zone.utcOffset(
|
|
116
|
+
Q.prototype.scoreOffsetAt = function(o) {
|
|
117
|
+
this.offsetScore += Math.abs(this.zone.utcOffset(o.at) - o.offset), this.zone.abbr(o.at).replace(/[^A-Z]/g, "") !== o.abbr && this.abbrScore++;
|
|
118
118
|
};
|
|
119
|
-
function F(
|
|
120
|
-
for (var X, L; L = ((n.at -
|
|
121
|
-
X = new G(new Date(
|
|
122
|
-
return
|
|
119
|
+
function F(o, n) {
|
|
120
|
+
for (var X, L; L = ((n.at - o.at) / 12e4 | 0) * 6e4; )
|
|
121
|
+
X = new G(new Date(o.at + L)), X.offset === o.offset ? o = X : n = X;
|
|
122
|
+
return o;
|
|
123
123
|
}
|
|
124
124
|
function $() {
|
|
125
|
-
var
|
|
126
|
-
for (
|
|
127
|
-
E = new Date(
|
|
128
|
-
for (
|
|
129
|
-
L.push(new G(new Date(
|
|
125
|
+
var o = (/* @__PURE__ */ new Date()).getFullYear() - 2, n = new G(new Date(o, 0, 1)), X = n.offset, L = [n], N, V, E, s;
|
|
126
|
+
for (s = 1; s < 48; s++)
|
|
127
|
+
E = new Date(o, s, 1).getTimezoneOffset(), E !== X && (V = new G(new Date(o, s, 1)), N = F(n, V), L.push(N), L.push(new G(new Date(N.at + 6e4))), n = V, X = E);
|
|
128
|
+
for (s = 0; s < 4; s++)
|
|
129
|
+
L.push(new G(new Date(o + s, 0, 1))), L.push(new G(new Date(o + s, 6, 1)));
|
|
130
130
|
return L;
|
|
131
131
|
}
|
|
132
|
-
function z0(
|
|
133
|
-
return
|
|
132
|
+
function z0(o, n) {
|
|
133
|
+
return o.offsetScore !== n.offsetScore ? o.offsetScore - n.offsetScore : o.abbrScore !== n.abbrScore ? o.abbrScore - n.abbrScore : o.zone.population !== n.zone.population ? n.zone.population - o.zone.population : n.zone.name.localeCompare(o.zone.name);
|
|
134
134
|
}
|
|
135
|
-
function b0(
|
|
135
|
+
function b0(o, n) {
|
|
136
136
|
var X, L;
|
|
137
|
-
for (
|
|
138
|
-
L = n[X], A[L] = A[L] || {}, A[L][
|
|
137
|
+
for (e(n), X = 0; X < n.length; X++)
|
|
138
|
+
L = n[X], A[L] = A[L] || {}, A[L][o] = !0;
|
|
139
139
|
}
|
|
140
|
-
function p0(
|
|
141
|
-
var n =
|
|
142
|
-
for (
|
|
143
|
-
if (
|
|
144
|
-
P = A[
|
|
140
|
+
function p0(o) {
|
|
141
|
+
var n = o.length, X = {}, L = [], N = {}, V, E, s, P;
|
|
142
|
+
for (V = 0; V < n; V++)
|
|
143
|
+
if (s = o[V].offset, !N.hasOwnProperty(s)) {
|
|
144
|
+
P = A[s] || {};
|
|
145
145
|
for (E in P)
|
|
146
146
|
P.hasOwnProperty(E) && (X[E] = !0);
|
|
147
|
-
N[
|
|
147
|
+
N[s] = !0;
|
|
148
148
|
}
|
|
149
|
-
for (
|
|
150
|
-
X.hasOwnProperty(
|
|
149
|
+
for (V in X)
|
|
150
|
+
X.hasOwnProperty(V) && L.push(O[V]);
|
|
151
151
|
return L;
|
|
152
152
|
}
|
|
153
153
|
function O0() {
|
|
154
154
|
try {
|
|
155
|
-
var
|
|
156
|
-
if (
|
|
157
|
-
var n = O[h(
|
|
155
|
+
var o = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
156
|
+
if (o && o.length > 3) {
|
|
157
|
+
var n = O[h(o)];
|
|
158
158
|
if (n)
|
|
159
159
|
return n;
|
|
160
|
-
D("Moment Timezone found " +
|
|
160
|
+
D("Moment Timezone found " + o + " from the Intl api, but did not have that data loaded.");
|
|
161
161
|
}
|
|
162
162
|
} catch {
|
|
163
163
|
}
|
|
164
|
-
var X = $(), L = X.length, N = p0(X),
|
|
165
|
-
for (
|
|
166
|
-
for (E = new
|
|
164
|
+
var X = $(), L = X.length, N = p0(X), V = [], E, s, P;
|
|
165
|
+
for (s = 0; s < N.length; s++) {
|
|
166
|
+
for (E = new Q(g(N[s])), P = 0; P < L; P++)
|
|
167
167
|
E.scoreOffsetAt(X[P]);
|
|
168
|
-
|
|
168
|
+
V.push(E);
|
|
169
169
|
}
|
|
170
|
-
return
|
|
170
|
+
return V.sort(z0), V.length > 0 ? V[0].zone.name : void 0;
|
|
171
171
|
}
|
|
172
|
-
function A0(
|
|
173
|
-
return (!W ||
|
|
172
|
+
function A0(o) {
|
|
173
|
+
return (!W || o) && (W = O0()), W;
|
|
174
174
|
}
|
|
175
|
-
function h(
|
|
176
|
-
return (
|
|
175
|
+
function h(o) {
|
|
176
|
+
return (o || "").toLowerCase().replace(/\//g, "_");
|
|
177
177
|
}
|
|
178
|
-
function k(
|
|
178
|
+
function k(o) {
|
|
179
179
|
var n, X, L, N;
|
|
180
|
-
for (typeof
|
|
181
|
-
L =
|
|
180
|
+
for (typeof o == "string" && (o = [o]), n = 0; n < o.length; n++)
|
|
181
|
+
L = o[n].split("|"), X = L[0], N = h(X), p[N] = o[n], O[N] = X, b0(N, L[2].split(" "));
|
|
182
182
|
}
|
|
183
|
-
function g(
|
|
184
|
-
|
|
185
|
-
var X = p[
|
|
186
|
-
return X instanceof
|
|
183
|
+
function g(o, n) {
|
|
184
|
+
o = h(o);
|
|
185
|
+
var X = p[o], L;
|
|
186
|
+
return X instanceof u ? X : typeof X == "string" ? (X = new u(X), p[o] = X, X) : b[o] && n !== g && (L = g(b[o], g)) ? (X = p[o] = new u(), X._set(L), X.name = O[o], X) : null;
|
|
187
187
|
}
|
|
188
188
|
function c0() {
|
|
189
|
-
var
|
|
190
|
-
for (
|
|
191
|
-
O.hasOwnProperty(
|
|
189
|
+
var o, n = [];
|
|
190
|
+
for (o in O)
|
|
191
|
+
O.hasOwnProperty(o) && (p[o] || p[b[o]]) && O[o] && n.push(O[o]);
|
|
192
192
|
return n.sort();
|
|
193
193
|
}
|
|
194
194
|
function W0() {
|
|
195
195
|
return Object.keys(c);
|
|
196
196
|
}
|
|
197
|
-
function y(
|
|
197
|
+
function y(o) {
|
|
198
198
|
var n, X, L, N;
|
|
199
|
-
for (typeof
|
|
200
|
-
X =
|
|
199
|
+
for (typeof o == "string" && (o = [o]), n = 0; n < o.length; n++)
|
|
200
|
+
X = o[n].split("|"), L = h(X[0]), N = h(X[1]), b[L] = N, O[L] = X[0], b[N] = L, O[N] = X[1];
|
|
201
201
|
}
|
|
202
|
-
function o0(
|
|
202
|
+
function o0(o) {
|
|
203
203
|
var n, X, L, N;
|
|
204
|
-
if (!(!
|
|
205
|
-
for (n = 0; n <
|
|
206
|
-
N =
|
|
204
|
+
if (!(!o || !o.length))
|
|
205
|
+
for (n = 0; n < o.length; n++)
|
|
206
|
+
N = o[n].split("|"), X = N[0].toUpperCase(), L = N[1].split(" "), c[X] = new B(
|
|
207
207
|
X,
|
|
208
208
|
L
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
|
-
function q0(
|
|
212
|
-
return
|
|
211
|
+
function q0(o) {
|
|
212
|
+
return o = o.toUpperCase(), c[o] || null;
|
|
213
213
|
}
|
|
214
|
-
function Y0(
|
|
215
|
-
if (
|
|
214
|
+
function Y0(o, n) {
|
|
215
|
+
if (o = q0(o), !o)
|
|
216
216
|
return null;
|
|
217
|
-
var X =
|
|
217
|
+
var X = o.zones.sort();
|
|
218
218
|
return n ? X.map(function(L) {
|
|
219
219
|
var N = g(L);
|
|
220
220
|
return {
|
|
@@ -223,59 +223,59 @@ var _ = { exports: {} };
|
|
|
223
223
|
};
|
|
224
224
|
}) : X;
|
|
225
225
|
}
|
|
226
|
-
function d0(
|
|
227
|
-
k(
|
|
226
|
+
function d0(o) {
|
|
227
|
+
k(o.zones), y(o.links), o0(o.countries), l.dataVersion = o.version;
|
|
228
228
|
}
|
|
229
|
-
function J(
|
|
230
|
-
return J.didShowError || (J.didShowError = !0, D("moment.tz.zoneExists('" +
|
|
229
|
+
function J(o) {
|
|
230
|
+
return J.didShowError || (J.didShowError = !0, D("moment.tz.zoneExists('" + o + "') has been deprecated in favor of !moment.tz.zone('" + o + "')")), !!g(o);
|
|
231
231
|
}
|
|
232
|
-
function v(
|
|
233
|
-
var n =
|
|
234
|
-
return !!(
|
|
232
|
+
function v(o) {
|
|
233
|
+
var n = o._f === "X" || o._f === "x";
|
|
234
|
+
return !!(o._a && o._tzm === void 0 && !n);
|
|
235
235
|
}
|
|
236
|
-
function D(
|
|
237
|
-
typeof console < "u" && typeof console.error == "function" && console.error(
|
|
236
|
+
function D(o) {
|
|
237
|
+
typeof console < "u" && typeof console.error == "function" && console.error(o);
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function l(o) {
|
|
240
240
|
var n = Array.prototype.slice.call(arguments, 0, -1), X = arguments[arguments.length - 1], L = M.utc.apply(null, n), N;
|
|
241
|
-
return !M.isMoment(
|
|
241
|
+
return !M.isMoment(o) && v(L) && (N = g(X)) && L.add(N.parse(L), "minutes"), L.tz(X), L;
|
|
242
242
|
}
|
|
243
|
-
|
|
243
|
+
l.version = z, l.dataVersion = "", l._zones = p, l._links = b, l._names = O, l._countries = c, l.add = k, l.link = y, l.load = d0, l.zone = g, l.zoneExists = J, l.guess = A0, l.names = c0, l.Zone = u, l.unpack = S, l.unpackBase60 = T, l.needsOffset = v, l.moveInvalidForward = !0, l.moveAmbiguousForward = !1, l.countries = W0, l.zonesForCountry = Y0;
|
|
244
244
|
var C = M.fn;
|
|
245
|
-
M.tz =
|
|
245
|
+
M.tz = l, M.defaultZone = null, M.updateOffset = function(o, n) {
|
|
246
246
|
var X = M.defaultZone, L;
|
|
247
|
-
if (
|
|
248
|
-
if (L =
|
|
249
|
-
var N =
|
|
250
|
-
|
|
247
|
+
if (o._z === void 0 && (X && v(o) && !o._isUTC && o.isValid() && (o._d = M.utc(o._a)._d, o.utc().add(X.parse(o), "minutes")), o._z = X), o._z)
|
|
248
|
+
if (L = o._z.utcOffset(o), Math.abs(L) < 16 && (L = L / 60), o.utcOffset !== void 0) {
|
|
249
|
+
var N = o._z;
|
|
250
|
+
o.utcOffset(-L, n), o._z = N;
|
|
251
251
|
} else
|
|
252
|
-
|
|
253
|
-
}, C.tz = function(
|
|
254
|
-
if (
|
|
255
|
-
if (typeof
|
|
256
|
-
throw new Error("Time zone name must be a string, got " +
|
|
257
|
-
return this._z = g(
|
|
252
|
+
o.zone(L, n);
|
|
253
|
+
}, C.tz = function(o, n) {
|
|
254
|
+
if (o) {
|
|
255
|
+
if (typeof o != "string")
|
|
256
|
+
throw new Error("Time zone name must be a string, got " + o + " [" + typeof o + "]");
|
|
257
|
+
return this._z = g(o), this._z ? M.updateOffset(this, n) : D("Moment Timezone has no data for " + o + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
|
|
258
258
|
}
|
|
259
259
|
if (this._z)
|
|
260
260
|
return this._z.name;
|
|
261
261
|
};
|
|
262
|
-
function w(
|
|
262
|
+
function w(o) {
|
|
263
263
|
return function() {
|
|
264
|
-
return this._z ? this._z.abbr(this) :
|
|
264
|
+
return this._z ? this._z.abbr(this) : o.call(this);
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
|
-
function x(
|
|
267
|
+
function x(o) {
|
|
268
268
|
return function() {
|
|
269
|
-
return this._z = null,
|
|
269
|
+
return this._z = null, o.apply(this, arguments);
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
|
-
function a0(
|
|
272
|
+
function a0(o) {
|
|
273
273
|
return function() {
|
|
274
|
-
return arguments.length > 0 && (this._z = null),
|
|
274
|
+
return arguments.length > 0 && (this._z = null), o.apply(this, arguments);
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
|
-
C.zoneName = w(C.zoneName), C.zoneAbbr = w(C.zoneAbbr), C.utc = x(C.utc), C.local = x(C.local), C.utcOffset = a0(C.utcOffset), M.tz.setDefault = function(
|
|
278
|
-
return (
|
|
277
|
+
C.zoneName = w(C.zoneName), C.zoneAbbr = w(C.zoneAbbr), C.utc = x(C.utc), C.local = x(C.local), C.utcOffset = a0(C.utcOffset), M.tz.setDefault = function(o) {
|
|
278
|
+
return (d < 2 || d === 2 && Y < 9) && D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = o ? g(o) : null, M;
|
|
279
279
|
};
|
|
280
280
|
var K = M.momentProperties;
|
|
281
281
|
return Object.prototype.toString.call(K) === "[object Array]" ? (K.push("_z"), K.push("_a")) : K && (K._z = null), M;
|
|
@@ -1145,10 +1145,10 @@ var M0 = { exports: {} };
|
|
|
1145
1145
|
throw new RangeError("invalid coordinates");
|
|
1146
1146
|
if (90 <= z)
|
|
1147
1147
|
return "Etc/GMT";
|
|
1148
|
-
var O = -1, A = 48 * (180 + p) / 360.00000000000006, W = 24 * (90 - z) / 180.00000000000003,
|
|
1149
|
-
for (
|
|
1150
|
-
|
|
1151
|
-
return c[
|
|
1148
|
+
var O = -1, A = 48 * (180 + p) / 360.00000000000006, W = 24 * (90 - z) / 180.00000000000003, q = 0 | A, d = 0 | W, Y = 96 * d + 2 * q;
|
|
1149
|
+
for (Y = 56 * b.charCodeAt(Y) + b.charCodeAt(Y + 1) - 1995; Y + c.length < 3136; )
|
|
1150
|
+
Y = 56 * b.charCodeAt(Y = 8 * (O = O + Y + 1) + 4 * (d = 0 | (W = 2 * (W - d) % 2)) + 2 * (q = 0 | (A = 2 * (A - q) % 2)) + 2304) + b.charCodeAt(Y + 1) - 1995;
|
|
1151
|
+
return c[Y + c.length - 3136];
|
|
1152
1152
|
}
|
|
1153
1153
|
m.exports = M;
|
|
1154
1154
|
})(M0);
|
|
@@ -1162,7 +1162,7 @@ class a {
|
|
|
1162
1162
|
*/
|
|
1163
1163
|
static guessTimeZoneOffset(M, z) {
|
|
1164
1164
|
M = a.convertToStdLng(M);
|
|
1165
|
-
const p = S0(z, M), b =
|
|
1165
|
+
const p = S0(z, M), b = U().tz(p).utcOffset();
|
|
1166
1166
|
return a.roundPrecision(b / 60, 1);
|
|
1167
1167
|
}
|
|
1168
1168
|
/**
|
|
@@ -1183,18 +1183,18 @@ class a {
|
|
|
1183
1183
|
M = a.convertToStdLng(M, z);
|
|
1184
1184
|
let b = "E";
|
|
1185
1185
|
M < 0 && (b = "W"), M = Math.abs(M), p = p.toUpperCase();
|
|
1186
|
-
let c = M * 3600, O, A, W,
|
|
1187
|
-
O = c % 3600 % 60, p.indexOf("S") !== -1 && (c = c - O, A = a.padNumber(O, 2, 2)), W = c / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ?
|
|
1188
|
-
const R = `${p.replace(/S+/gi, A).replace(/M+/gi,
|
|
1186
|
+
let c = M * 3600, O, A, W, q, d, Y;
|
|
1187
|
+
O = c % 3600 % 60, p.indexOf("S") !== -1 && (c = c - O, A = a.padNumber(O, 2, 2)), W = c / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ? q = a.roundPrecision(W, z).toString().padStart(2, "0") : q = a.padNumber(W, 2, 3), c = c - W * 60), d = c / 3600, p.indexOf("M") !== -1 ? Y = a.roundPrecision(d, z).toString().padStart(3, "0") : Y = a.padNumber(d, 3, 6), Number(A) >= 60 && (q = Number(q) + 1, A = 0), Number(q) >= 60 && (Y = Number(Y) + 1, q = 0);
|
|
1188
|
+
const R = `${p.replace(/S+/gi, A).replace(/M+/gi, q).replace(/H+/gi, Y)}${b}`;
|
|
1189
1189
|
return {
|
|
1190
1190
|
direction: b,
|
|
1191
|
-
degree: a.roundPrecision(
|
|
1191
|
+
degree: a.roundPrecision(d, z),
|
|
1192
1192
|
minute: a.roundPrecision(W, z),
|
|
1193
1193
|
second: a.roundPrecision(O, z),
|
|
1194
1194
|
pretty: R,
|
|
1195
1195
|
S: A,
|
|
1196
|
-
M:
|
|
1197
|
-
H:
|
|
1196
|
+
M: q,
|
|
1197
|
+
H: Y
|
|
1198
1198
|
};
|
|
1199
1199
|
}
|
|
1200
1200
|
/**
|
|
@@ -1207,18 +1207,18 @@ class a {
|
|
|
1207
1207
|
M = M % 180;
|
|
1208
1208
|
let b = "N";
|
|
1209
1209
|
M < 0 && (b = "S"), M = Math.abs(M), p = p.toUpperCase();
|
|
1210
|
-
let c = M * 3600, O, A, W,
|
|
1211
|
-
O = c % 3600 % 60, p.indexOf("S") !== -1 && (c = c - O, A = a.padNumber(O, 2, 2)), W = c / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ?
|
|
1212
|
-
const R = `${p.replace(/S+/gi, A).replace(/M+/gi,
|
|
1210
|
+
let c = M * 3600, O, A, W, q, d, Y;
|
|
1211
|
+
O = c % 3600 % 60, p.indexOf("S") !== -1 && (c = c - O, A = a.padNumber(O, 2, 2)), W = c / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ? q = a.roundPrecision(W, z).toString().padStart(2, "0") : q = a.padNumber(W, 2, 3), c = c - W * 60), d = c / 3600, p.indexOf("M") !== -1 ? Y = a.roundPrecision(d, z).toString().padStart(2, "0") : Y = a.padNumber(d, 2, 6), Number(A) >= 60 && (q = Number(q) + 1, A = 0), Number(q) >= 60 && (Y = Number(Y) + 1, q = 0);
|
|
1212
|
+
const R = `${p.replace(/S+/gi, A).replace(/M+/gi, q).replace(/H+/gi, Y)}${b}`;
|
|
1213
1213
|
return {
|
|
1214
1214
|
direction: b,
|
|
1215
|
-
degree: a.roundPrecision(
|
|
1215
|
+
degree: a.roundPrecision(d, z),
|
|
1216
1216
|
minute: a.roundPrecision(W, z),
|
|
1217
1217
|
second: a.roundPrecision(O, z),
|
|
1218
1218
|
pretty: R,
|
|
1219
1219
|
S: A,
|
|
1220
|
-
M:
|
|
1221
|
-
H:
|
|
1220
|
+
M: q,
|
|
1221
|
+
H: Y
|
|
1222
1222
|
};
|
|
1223
1223
|
}
|
|
1224
1224
|
static str2Lng(M, z = 6) {
|
|
@@ -1227,11 +1227,11 @@ class a {
|
|
|
1227
1227
|
M = a.strReplace(M, "LNG");
|
|
1228
1228
|
const b = M[M.length - 1].toUpperCase();
|
|
1229
1229
|
M = M.substring(0, M.length - 1).trim();
|
|
1230
|
-
const c = M.split(" ").filter((
|
|
1230
|
+
const c = M.split(" ").filter((q) => q !== "").map((q) => Math.abs(Number(q)));
|
|
1231
1231
|
let [O, A, W] = c;
|
|
1232
1232
|
if (A = A || 0, A = A > 60 ? A / Math.pow(10, String(A).length - 2) : A, W = W || 0, W = W > 60 ? W / Math.pow(10, String(W).length - 2) : W, O > 360 && !A) {
|
|
1233
|
-
const
|
|
1234
|
-
A = O -
|
|
1233
|
+
const q = this.roundPrecision(O / 100, 0);
|
|
1234
|
+
A = O - q * 100, O = q;
|
|
1235
1235
|
}
|
|
1236
1236
|
p = O + A / 60 + W / 3600, b === "W" && (p = p * -1);
|
|
1237
1237
|
} else
|
|
@@ -1244,11 +1244,11 @@ class a {
|
|
|
1244
1244
|
M = a.strReplace(M, "LAT");
|
|
1245
1245
|
const b = M[M.length - 1].toUpperCase();
|
|
1246
1246
|
M = M.substring(0, M.length - 1).trim();
|
|
1247
|
-
const c = M.split(" ").filter((
|
|
1247
|
+
const c = M.split(" ").filter((q) => q !== "").map((q) => Math.abs(Number(q)));
|
|
1248
1248
|
let [O, A, W] = c;
|
|
1249
1249
|
if (W = W || 0, A = A || 0, A = A > 60 ? A / Math.pow(10, String(A).length - 2) : A, W = W > 60 ? W / Math.pow(10, String(W).length - 2) : W, O > 90 && !A) {
|
|
1250
|
-
const
|
|
1251
|
-
A = O -
|
|
1250
|
+
const q = this.roundPrecision(O / 100, 0);
|
|
1251
|
+
A = O - q * 100, O = q;
|
|
1252
1252
|
}
|
|
1253
1253
|
if (p = O + A / 60 + W / 3600, p > 90)
|
|
1254
1254
|
throw new Error(`latitude out of range: ${M}${b}`);
|
|
@@ -1320,7 +1320,7 @@ class t0 {
|
|
|
1320
1320
|
return `${M.lat}|${M.lng}|${M.positionTime}|${M.sog}|${M.cog}|${M.hdg}|${M.draught}|${z}|${JSON.stringify(M.meteo || {})}|${M.vendor}|${M.deleted}`;
|
|
1321
1321
|
}
|
|
1322
1322
|
static str2Json(M) {
|
|
1323
|
-
const [z, p, b, c, O, A, W,
|
|
1323
|
+
const [z, p, b, c, O, A, W, q, d, Y, R] = M.split("|");
|
|
1324
1324
|
return {
|
|
1325
1325
|
lat: Number(z),
|
|
1326
1326
|
lng: Number(p),
|
|
@@ -1330,57 +1330,57 @@ class t0 {
|
|
|
1330
1330
|
hdg: Number(A),
|
|
1331
1331
|
//@ts-ignore
|
|
1332
1332
|
draught: isNaN(W) ? null : Number(W),
|
|
1333
|
-
type:
|
|
1334
|
-
important:
|
|
1335
|
-
meteo:
|
|
1336
|
-
vendor:
|
|
1333
|
+
type: q,
|
|
1334
|
+
important: q !== "A",
|
|
1335
|
+
meteo: d ? JSON.parse(d) : void 0,
|
|
1336
|
+
vendor: Y,
|
|
1337
1337
|
deleted: R === "true"
|
|
1338
1338
|
};
|
|
1339
1339
|
}
|
|
1340
1340
|
static inspectStoppages(M, z = 1, p = !0) {
|
|
1341
1341
|
const b = M.at(0).positionTime < M.at(-1).positionTime;
|
|
1342
|
-
b || M.sort((W,
|
|
1342
|
+
b || M.sort((W, q) => W.positionTime - q.positionTime);
|
|
1343
1343
|
const c = [];
|
|
1344
1344
|
let O, A;
|
|
1345
1345
|
for (let W = 0; W < M.length - 1; W++) {
|
|
1346
|
-
const
|
|
1347
|
-
if (!(p && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(
|
|
1348
|
-
for (let
|
|
1349
|
-
const
|
|
1350
|
-
if (p && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(
|
|
1346
|
+
const q = M[W];
|
|
1347
|
+
if (!(p && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))) {
|
|
1348
|
+
for (let d = W + 1; d < M.length; d++) {
|
|
1349
|
+
const Y = M[d - 1], R = M[d];
|
|
1350
|
+
if (p && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))
|
|
1351
1351
|
continue;
|
|
1352
|
-
const T = R.positionTime -
|
|
1353
|
-
if (r.calculateDistance(R,
|
|
1354
|
-
O || (O =
|
|
1352
|
+
const T = R.positionTime - Y.positionTime;
|
|
1353
|
+
if (r.calculateDistance(R, Y, !0, 4) / (T / 3600) < z)
|
|
1354
|
+
O || (O = q), d === M.length - 1 && (A = R, W = d);
|
|
1355
1355
|
else {
|
|
1356
|
-
O && (A = M[
|
|
1356
|
+
O && (A = M[d - 1], W = d);
|
|
1357
1357
|
break;
|
|
1358
1358
|
}
|
|
1359
1359
|
}
|
|
1360
1360
|
if ((A == null ? void 0 : A.positionTime) > (O == null ? void 0 : O.positionTime) && O) {
|
|
1361
|
-
const
|
|
1361
|
+
const d = {
|
|
1362
1362
|
start: {
|
|
1363
1363
|
lat: O.lat,
|
|
1364
1364
|
lng: O.lng,
|
|
1365
1365
|
sog: O.sog,
|
|
1366
1366
|
positionTime: O.positionTime,
|
|
1367
|
-
utc:
|
|
1367
|
+
utc: U.unix(O.positionTime).utc().format()
|
|
1368
1368
|
},
|
|
1369
1369
|
end: {
|
|
1370
1370
|
lat: A.lat,
|
|
1371
1371
|
lng: A.lng,
|
|
1372
1372
|
sog: A.sog,
|
|
1373
1373
|
positionTime: A.positionTime,
|
|
1374
|
-
utc:
|
|
1374
|
+
utc: U.unix(A.positionTime).utc().format()
|
|
1375
1375
|
},
|
|
1376
1376
|
duration: A.positionTime - O.positionTime
|
|
1377
|
-
},
|
|
1378
|
-
|
|
1377
|
+
}, Y = M.filter((T) => T.positionTime >= d.start.positionTime && T.positionTime <= d.end.positionTime), R = r.divideAccordingToLng(Y);
|
|
1378
|
+
d.distance = r.calculateRouteDistance(R), d.hours = Math.round(d.duration / 3600 * 10) / 10, d.avgSog = Math.round(d.distance / d.hours * 10) / 10, c.push(d);
|
|
1379
1379
|
}
|
|
1380
1380
|
O = void 0, A = void 0;
|
|
1381
1381
|
}
|
|
1382
1382
|
}
|
|
1383
|
-
return b || M.sort((W,
|
|
1383
|
+
return b || M.sort((W, q) => q.positionTime - W.positionTime), c;
|
|
1384
1384
|
}
|
|
1385
1385
|
/**
|
|
1386
1386
|
* 计算轨迹摘要
|
|
@@ -1389,21 +1389,21 @@ class t0 {
|
|
|
1389
1389
|
* @param etm
|
|
1390
1390
|
*/
|
|
1391
1391
|
static inspectSummary(M, z, p) {
|
|
1392
|
-
const b =
|
|
1392
|
+
const b = U(z), c = U(p), O = M.filter((d) => d.positionTime >= b.unix() && d.positionTime <= c.unix());
|
|
1393
1393
|
let A = 0, W = 0;
|
|
1394
1394
|
if (O.length > 1)
|
|
1395
|
-
for (let
|
|
1396
|
-
const
|
|
1397
|
-
A += r.calculateDistance(
|
|
1395
|
+
for (let d = 0; d < O.length - 1; d++) {
|
|
1396
|
+
const Y = O[d], R = O[d + 1];
|
|
1397
|
+
A += r.calculateDistance(Y, R, !0, 4), W += Math.abs(R.positionTime - Y.positionTime);
|
|
1398
1398
|
}
|
|
1399
1399
|
A = Math.round(A * 100) / 100, W = Math.round(W / 3600 * 100) / 100;
|
|
1400
|
-
const
|
|
1401
|
-
return { distance: A, interval: W, avgSpd:
|
|
1400
|
+
const q = W ? Math.round(A / W * 100) / 100 : 0;
|
|
1401
|
+
return { distance: A, interval: W, avgSpd: q };
|
|
1402
1402
|
}
|
|
1403
1403
|
}
|
|
1404
|
-
let
|
|
1404
|
+
let H;
|
|
1405
1405
|
try {
|
|
1406
|
-
|
|
1406
|
+
H = j.getLogger("meteo");
|
|
1407
1407
|
} catch {
|
|
1408
1408
|
} finally {
|
|
1409
1409
|
}
|
|
@@ -1417,12 +1417,12 @@ class r {
|
|
|
1417
1417
|
* @returns {number} 单位度
|
|
1418
1418
|
*/
|
|
1419
1419
|
static calculateBearing(M, z, p = !0, b = 4) {
|
|
1420
|
-
const c =
|
|
1420
|
+
const c = t.points([
|
|
1421
1421
|
[M.lng, M.lat],
|
|
1422
1422
|
[z.lng, z.lat]
|
|
1423
1423
|
]);
|
|
1424
1424
|
let O;
|
|
1425
|
-
return p ? O =
|
|
1425
|
+
return p ? O = t.rhumbBearing(c.features[0], c.features[1]) : O = t.bearing(c.features[0], c.features[1]), O < 0 && (O += 360), a.roundPrecision(O, b);
|
|
1426
1426
|
}
|
|
1427
1427
|
/**
|
|
1428
1428
|
* 计算两点间距离
|
|
@@ -1435,12 +1435,12 @@ class r {
|
|
|
1435
1435
|
*/
|
|
1436
1436
|
static calculateDistance(M, z, p = !0, b = 4, c = "nauticalmiles") {
|
|
1437
1437
|
M = { ...M }, z = { ...z }, M.lng = a.convertToStdLng(M.lng, b), z.lng = a.convertToStdLng(z.lng, b);
|
|
1438
|
-
const O =
|
|
1438
|
+
const O = t.points([
|
|
1439
1439
|
[M.lng, M.lat],
|
|
1440
1440
|
[z.lng, z.lat]
|
|
1441
1441
|
]);
|
|
1442
1442
|
let A;
|
|
1443
|
-
return p ? A =
|
|
1443
|
+
return p ? A = t.rhumbDistance(O.features[0], O.features[1], { units: c }) : A = t.distance(O.features[0], O.features[1], { units: c }), a.roundPrecision(A, b);
|
|
1444
1444
|
}
|
|
1445
1445
|
/**
|
|
1446
1446
|
* 计算航线距离
|
|
@@ -1454,8 +1454,8 @@ class r {
|
|
|
1454
1454
|
for (let A = 0; A < O.length - 1; A++) {
|
|
1455
1455
|
const W = { lng: O[A][0], lat: O[A][1] };
|
|
1456
1456
|
A === 0 && c && (b += this.calculateDistance(c, W, !0, z, p));
|
|
1457
|
-
const
|
|
1458
|
-
b += this.calculateDistance(W,
|
|
1457
|
+
const q = { lng: O[A + 1][0], lat: O[A + 1][1] };
|
|
1458
|
+
b += this.calculateDistance(W, q, !0, z, p), c = q;
|
|
1459
1459
|
}
|
|
1460
1460
|
return a.roundPrecision(b, z);
|
|
1461
1461
|
}
|
|
@@ -1468,9 +1468,9 @@ class r {
|
|
|
1468
1468
|
* @param rhumb
|
|
1469
1469
|
*/
|
|
1470
1470
|
static calculateCoordinate(M, z, p, b = "nauticalmiles", c = !0) {
|
|
1471
|
-
const O =
|
|
1471
|
+
const O = t.point([M.lng, M.lat]);
|
|
1472
1472
|
let A;
|
|
1473
|
-
c ? A =
|
|
1473
|
+
c ? A = t.rhumbDestination(O, p, z, { units: b }) : A = t.destination(O, p, z, { units: b });
|
|
1474
1474
|
const W = A.geometry.coordinates;
|
|
1475
1475
|
return { lng: a.convertToStdLng(W[0], 8), lat: a.roundPrecision(W[1], 8) };
|
|
1476
1476
|
}
|
|
@@ -1484,11 +1484,11 @@ class r {
|
|
|
1484
1484
|
* @param units 单位,默认 nm(海里)
|
|
1485
1485
|
*/
|
|
1486
1486
|
static interpolateCoordinates(M, z, p, b = !0, c = !0, O = "nauticalmiles") {
|
|
1487
|
-
const A = [], W = this.calculateBearing(M, z, !1),
|
|
1487
|
+
const A = [], W = this.calculateBearing(M, z, !1), q = this.calculateDistance(M, z, !1, 8, O);
|
|
1488
1488
|
b && A.push({ lng: M.lng, lat: M.lat });
|
|
1489
|
-
let
|
|
1490
|
-
for (;
|
|
1491
|
-
|
|
1489
|
+
let d = 0;
|
|
1490
|
+
for (; d < q; )
|
|
1491
|
+
d += p, d < q && A.push(this.calculateCoordinate(M, W, d, O, !1));
|
|
1492
1492
|
return c && A.push({ lng: z.lng, lat: z.lat }), A;
|
|
1493
1493
|
}
|
|
1494
1494
|
/**
|
|
@@ -1512,25 +1512,25 @@ class r {
|
|
|
1512
1512
|
let O, A;
|
|
1513
1513
|
for (let W = 0; W < M.length - 1; W++) {
|
|
1514
1514
|
O = a.convertToStdLng(M[W].lng, 8), A = a.convertToStdLng(M[W + 1].lng, 8), M[W].lat = a.roundPrecision(M[W].lat, 8), M[W + 1].lat = a.roundPrecision(M[W + 1].lat, 8), b.push([O, M[W].lat]);
|
|
1515
|
-
const
|
|
1516
|
-
if (Math.abs(
|
|
1517
|
-
const
|
|
1515
|
+
const q = O - A;
|
|
1516
|
+
if (Math.abs(q) > 180) {
|
|
1517
|
+
const d = a.convertToMonotonicLng2([
|
|
1518
1518
|
[O, M[W].lat],
|
|
1519
1519
|
[A, M[W + 1].lat]
|
|
1520
1520
|
]);
|
|
1521
|
-
let
|
|
1522
|
-
z ? (
|
|
1523
|
-
[
|
|
1524
|
-
[
|
|
1525
|
-
])) : (
|
|
1526
|
-
const T =
|
|
1527
|
-
let
|
|
1521
|
+
let Y, R;
|
|
1522
|
+
z ? (Y = t.lineString(d), R = t.lineString([
|
|
1523
|
+
[q > 0 ? 180 : -180, 89],
|
|
1524
|
+
[q > 0 ? 180 : -180, -89]
|
|
1525
|
+
])) : (Y = t.greatCircle(d[0], d[1]), R = t.greatCircle([q > 0 ? 180 : -180, 89], [q > 0 ? 180 : -180, -89]));
|
|
1526
|
+
const T = t.lineIntersect(Y, R);
|
|
1527
|
+
let e;
|
|
1528
1528
|
if (T.features.length) {
|
|
1529
|
-
const
|
|
1530
|
-
|
|
1529
|
+
const f = t.getCoord(T.features[0]);
|
|
1530
|
+
e = a.roundPrecision(f[1], 8);
|
|
1531
1531
|
} else
|
|
1532
|
-
|
|
1533
|
-
|
|
1532
|
+
e = M[W].lat;
|
|
1533
|
+
q > 0 ? (b.push([180 - 1e-6, e]), c.push([...b]), b = [], b.push([-(180 - 1e-6), e])) : (b.push([-(180 - 1e-6), e]), c.push([...b]), b = [], b.push([180 - 1e-6, e]));
|
|
1534
1534
|
}
|
|
1535
1535
|
W === M.length - 2 && b.push([A, M[W + 1].lat]);
|
|
1536
1536
|
}
|
|
@@ -1592,10 +1592,10 @@ class r {
|
|
|
1592
1592
|
static mergeCoordinateToRoute(M, z) {
|
|
1593
1593
|
M.lng = a.convertToStdLng(M.lng, 8);
|
|
1594
1594
|
let p = Number.MAX_VALUE, b = 0, c = 0, O, A;
|
|
1595
|
-
return z.forEach((W,
|
|
1596
|
-
for (let
|
|
1597
|
-
const
|
|
1598
|
-
p > T && (p = T, c =
|
|
1595
|
+
return z.forEach((W, q) => {
|
|
1596
|
+
for (let d = 0; d < W.length - 1; d++) {
|
|
1597
|
+
const Y = { lng: W[d][0], lat: W[d][1] }, R = { lng: W[d + 1][0], lat: W[d + 1][1] }, T = this.calculatePointToLineDistance(M, Y, R);
|
|
1598
|
+
p > T && (p = T, c = d, b = q, O = this.calculateDistance(Y, M), A = this.calculateDistance(R, M));
|
|
1599
1599
|
}
|
|
1600
1600
|
}), O !== 0 && A !== 0 ? z[b].splice(c + 1, 0, [M.lng, M.lat]) : O === 0 ? z[b].splice(c, 1, [M.lng, M.lat]) : A === 0 && z[b].splice(c + 1, 1, [M.lng, M.lat]), z;
|
|
1601
1601
|
}
|
|
@@ -1663,11 +1663,11 @@ class r {
|
|
|
1663
1663
|
*/
|
|
1664
1664
|
static calculateRangeWaypoints(M, z, p, b = []) {
|
|
1665
1665
|
const c = this.convertRouteToCoordinates(p, 0), O = this.mergeCoordinatesToWaypoints([M, z], c.length ? c : b), A = O.findIndex(
|
|
1666
|
-
(
|
|
1666
|
+
(d) => a.roundPrecision(M.lng, 8) === a.roundPrecision(d.lng, 8) && a.roundPrecision(M.lat, 8) === a.roundPrecision(d.lat, 8)
|
|
1667
1667
|
), W = O.findIndex(
|
|
1668
|
-
(
|
|
1668
|
+
(d) => a.roundPrecision(z.lng, 8) === a.roundPrecision(d.lng, 8) && a.roundPrecision(z.lat, 8) === a.roundPrecision(d.lat, 8)
|
|
1669
1669
|
);
|
|
1670
|
-
return O.filter((
|
|
1670
|
+
return O.filter((d, Y) => Y >= A && Y <= W);
|
|
1671
1671
|
}
|
|
1672
1672
|
/**
|
|
1673
1673
|
* 计算坐标到航路上的最短距离
|
|
@@ -1678,8 +1678,8 @@ class r {
|
|
|
1678
1678
|
let p = Number.MAX_VALUE, b = 0, c = 0;
|
|
1679
1679
|
return z.forEach((O, A) => {
|
|
1680
1680
|
for (let W = 0; W < O.length - 1; W++) {
|
|
1681
|
-
const
|
|
1682
|
-
p >
|
|
1681
|
+
const q = { lng: O[W][0], lat: O[W][1] }, d = { lng: O[W + 1][0], lat: O[W + 1][1] }, Y = this.calculatePointToLineDistance(M, q, d);
|
|
1682
|
+
p > Y && (p = Y, b = W, c = A);
|
|
1683
1683
|
}
|
|
1684
1684
|
}), { minDist: p, segIndex: c, minIndex: b };
|
|
1685
1685
|
}
|
|
@@ -1698,11 +1698,11 @@ class r {
|
|
|
1698
1698
|
let A = !0;
|
|
1699
1699
|
for (let W = b; W < z.length; W++)
|
|
1700
1700
|
if (A) {
|
|
1701
|
-
const
|
|
1702
|
-
|
|
1703
|
-
for (let
|
|
1704
|
-
M.lng === z[W][
|
|
1705
|
-
O.push(
|
|
1701
|
+
const q = [];
|
|
1702
|
+
q.push([M.lng, M.lat]);
|
|
1703
|
+
for (let d = c + 1; d < z[W].length; d++)
|
|
1704
|
+
M.lng === z[W][d][0] && M.lat === z[W][d][1] || q.push(z[W][d]);
|
|
1705
|
+
O.push(q), A = !1;
|
|
1706
1706
|
} else
|
|
1707
1707
|
O.push([...z[W]]);
|
|
1708
1708
|
return O;
|
|
@@ -1720,9 +1720,9 @@ class r {
|
|
|
1720
1720
|
if (this.calculateDistance(M, A) === 0)
|
|
1721
1721
|
return z;
|
|
1722
1722
|
if (this.calculateDistance(M, W) === 0)
|
|
1723
|
-
return z.filter((
|
|
1724
|
-
const
|
|
1725
|
-
p >
|
|
1723
|
+
return z.filter((d, Y) => Y > 0);
|
|
1724
|
+
const q = this.calculatePointToLineDistance(M, A, W);
|
|
1725
|
+
p > q && (p = q, b = O);
|
|
1726
1726
|
}
|
|
1727
1727
|
M.lng = a.convertToStdLng(M.lng);
|
|
1728
1728
|
const c = [M];
|
|
@@ -1741,10 +1741,10 @@ class r {
|
|
|
1741
1741
|
M.lng = a.convertToStdLng(M.lng, 8), z = { ...z }, p = { ...p }, z.lng = a.convertToStdLng(z.lng, 8), p.lng = a.convertToStdLng(p.lng, 8);
|
|
1742
1742
|
const c = a.convertToMonotonicLng([z, p]);
|
|
1743
1743
|
z = c[0], p = c[1];
|
|
1744
|
-
const O =
|
|
1744
|
+
const O = t.lineString([
|
|
1745
1745
|
[z.lng, z.lat],
|
|
1746
1746
|
[p.lng, p.lat]
|
|
1747
|
-
]), A =
|
|
1747
|
+
]), A = t.pointToLineDistance(t.point([M.lng, M.lat]), O, b), W = t.pointToLineDistance(t.point([M.lng > 0 ? M.lng - 360 : M.lng + 360, M.lat]), O, b);
|
|
1748
1748
|
return a.roundPrecision(Math.min(A, W), 6);
|
|
1749
1749
|
}
|
|
1750
1750
|
/**
|
|
@@ -1789,17 +1789,17 @@ class r {
|
|
|
1789
1789
|
z.push(M);
|
|
1790
1790
|
else {
|
|
1791
1791
|
for (let W = 0; W < z.length - 1; W++) {
|
|
1792
|
-
const
|
|
1793
|
-
b >=
|
|
1792
|
+
const q = { lng: z[W].lng, lat: z[W].lat }, d = { lng: z[W + 1].lng, lat: z[W + 1].lat }, Y = this.calculatePointToLineDistance(M, q, d);
|
|
1793
|
+
b >= Y && (b = Y, c = W, O = this.calculateDistance(q, M, !1, 6), A = this.calculateDistance(d, M, !1, 6));
|
|
1794
1794
|
}
|
|
1795
1795
|
O !== 0 && A !== 0 ? O <= b && c === 0 ? z.unshift(M) : A <= b && c === z.length - 2 ? z.push(M) : z.splice(c + 1, 0, M) : O === 0 ? p ? z.splice(c, 1, M) : z.splice(c + 1, 0, M) : A === 0 && (p ? z.splice(c + 1, 1, M) : z.splice(c + 1, 0, M));
|
|
1796
1796
|
}
|
|
1797
|
-
return z.map((W,
|
|
1797
|
+
return z.map((W, q) => {
|
|
1798
1798
|
W.lng = a.convertToStdLng(W.lng);
|
|
1799
|
-
const
|
|
1800
|
-
if (
|
|
1801
|
-
const
|
|
1802
|
-
W.sog = a.roundPrecision(
|
|
1799
|
+
const d = z[q + 1];
|
|
1800
|
+
if (d && ((W.bearing === null || W.bearing === void 0) && ((W.positionTime || 0) > (d.positionTime || 0) ? W.bearing = this.calculateBearing(d, W, !0) : W.bearing = this.calculateBearing(W, d, !0)), W.cog = W.cog || W.bearing, !W.sog && W.positionTime && d.positionTime)) {
|
|
1801
|
+
const Y = this.calculateDistance(W, d, !0), R = Math.abs(d.positionTime - W.positionTime) / 3600;
|
|
1802
|
+
W.sog = a.roundPrecision(Y / R, 2);
|
|
1803
1803
|
}
|
|
1804
1804
|
return W;
|
|
1805
1805
|
});
|
|
@@ -1829,7 +1829,7 @@ class r {
|
|
|
1829
1829
|
* @param route [[[lng, lat]]]
|
|
1830
1830
|
*/
|
|
1831
1831
|
static nearestCoordinateInRoute(M, z) {
|
|
1832
|
-
const p =
|
|
1832
|
+
const p = t.point([M.lng, M.lat]), c = this.convertRouteToCoordinates(z).map((q) => [q.lng, q.lat]), O = t.lineString(c), A = t.nearestPointOnLine(O, p), W = t.getCoord(A);
|
|
1833
1833
|
return { lng: a.roundPrecision(W[0], 8), lat: a.roundPrecision(W[1], 8) };
|
|
1834
1834
|
}
|
|
1835
1835
|
/**
|
|
@@ -1864,40 +1864,40 @@ class r {
|
|
|
1864
1864
|
static calculateNextCoordinateAlongRoute(M, z, p, b = "nauticalmiles") {
|
|
1865
1865
|
var R;
|
|
1866
1866
|
const c = M.speed || 12, O = [];
|
|
1867
|
-
let A = [], W = !1,
|
|
1868
|
-
if (z && p.length ? (O.push(M), p.forEach((T,
|
|
1867
|
+
let A = [], W = !1, q = 0, d = 0, Y;
|
|
1868
|
+
if (z && p.length ? (O.push(M), p.forEach((T, e) => {
|
|
1869
1869
|
if (W)
|
|
1870
1870
|
A.push(T);
|
|
1871
1871
|
else {
|
|
1872
|
-
const
|
|
1873
|
-
let
|
|
1874
|
-
for (let
|
|
1875
|
-
if (
|
|
1876
|
-
|
|
1872
|
+
const f = [];
|
|
1873
|
+
let i;
|
|
1874
|
+
for (let S = 0; S < T.length; S++)
|
|
1875
|
+
if (Y)
|
|
1876
|
+
f.push(T[S]);
|
|
1877
1877
|
else {
|
|
1878
|
-
|
|
1879
|
-
const
|
|
1880
|
-
if (
|
|
1881
|
-
|
|
1878
|
+
i = { lng: T[S][0], lat: T[S][1] };
|
|
1879
|
+
const u = this.calculateDistance(M, i, !0, 8, b);
|
|
1880
|
+
if (q += u, q < z)
|
|
1881
|
+
d += u, u && O.push(i), M = i;
|
|
1882
1882
|
else {
|
|
1883
|
-
if (
|
|
1884
|
-
|
|
1883
|
+
if (d = z, q === z)
|
|
1884
|
+
Y = i, f.push([Y.lng, Y.lat]);
|
|
1885
1885
|
else {
|
|
1886
|
-
const Z =
|
|
1887
|
-
|
|
1886
|
+
const Z = q - z, B = this.calculateBearing(i, M);
|
|
1887
|
+
Y = this.calculateCoordinate(i, B, Z, b), f.push([Y.lng, Y.lat]), f.push([i.lng, i.lat]);
|
|
1888
1888
|
}
|
|
1889
1889
|
W = !0;
|
|
1890
1890
|
}
|
|
1891
1891
|
}
|
|
1892
|
-
|
|
1892
|
+
f.length && A.push(f), e === p.length - 1 && !Y && (Y = i);
|
|
1893
1893
|
}
|
|
1894
|
-
})) : (A = p,
|
|
1895
|
-
if (O.push(
|
|
1894
|
+
})) : (A = p, Y = { ...M }), Y)
|
|
1895
|
+
if (O.push(Y), Y.distanceFromPrevious = Math.round(d * 1e4) / 1e4, Y.hourFromPrevious = Math.round(d / c * 1e4) / 1e4, ((R = A[0]) == null ? void 0 : R.length) > 1) {
|
|
1896
1896
|
const T = { lng: A[0][1][0], lat: A[0][1][1] };
|
|
1897
|
-
|
|
1897
|
+
Y.bearing = this.calculateBearing(Y, T);
|
|
1898
1898
|
} else
|
|
1899
|
-
|
|
1900
|
-
return { coordinate:
|
|
1899
|
+
Y.bearing = 0;
|
|
1900
|
+
return { coordinate: Y, nextRoute: A, prevRoute: O };
|
|
1901
1901
|
}
|
|
1902
1902
|
/**
|
|
1903
1903
|
* 返回最近点及其是否为垂足(最近点不是起点或终点)
|
|
@@ -1906,11 +1906,11 @@ class r {
|
|
|
1906
1906
|
* @param to {lng, lat}
|
|
1907
1907
|
*/
|
|
1908
1908
|
static nearestCoordinateInLine(M, z, p) {
|
|
1909
|
-
const b = a.convertToStdLng(M.lng, 6), c =
|
|
1909
|
+
const b = a.convertToStdLng(M.lng, 6), c = t.point([b, M.lat]), O = a.convertToStdLng(z.lng, 6), A = a.convertToStdLng(p.lng, 6), W = t.lineString([
|
|
1910
1910
|
[O, z.lat],
|
|
1911
1911
|
[A, p.lat]
|
|
1912
|
-
]),
|
|
1913
|
-
return { lng:
|
|
1912
|
+
]), q = t.nearestPointOnLine(W, c), d = t.getCoord(q), Y = a.roundPrecision(d[0], 6), R = a.roundPrecision(d[1], 6);
|
|
1913
|
+
return { lng: Y, lat: R, inline: !(Y === O && R === z.lat) && !(Y === A && R === p.lat) };
|
|
1914
1914
|
}
|
|
1915
1915
|
/**
|
|
1916
1916
|
* 将route转coordinate
|
|
@@ -1928,8 +1928,8 @@ class r {
|
|
|
1928
1928
|
else if (c.bearing === void 0 || c.bearing === null)
|
|
1929
1929
|
c.bearing = this.calculateBearing(c, W, !0);
|
|
1930
1930
|
else {
|
|
1931
|
-
const
|
|
1932
|
-
|
|
1931
|
+
const q = this.calculateDistance(b, W, !0);
|
|
1932
|
+
q && q >= z && (b.bearing = this.calculateBearing(b, W, !0), p.push(b), c = b);
|
|
1933
1933
|
}
|
|
1934
1934
|
b = W;
|
|
1935
1935
|
});
|
|
@@ -1957,9 +1957,9 @@ class r {
|
|
|
1957
1957
|
for (let b = 1; b < z.length; b++) {
|
|
1958
1958
|
const c = z[b - 1], O = z[b];
|
|
1959
1959
|
if (O.gcToPrevious) {
|
|
1960
|
-
const A = M.findIndex((
|
|
1961
|
-
for (let
|
|
1962
|
-
M.splice(
|
|
1960
|
+
const A = M.findIndex((q) => q.lng === c.lng && q.lat === c.lat), W = M.findIndex((q) => q.lng === O.lng && q.lat === O.lat);
|
|
1961
|
+
for (let q = W - 1; q > A; q--)
|
|
1962
|
+
M.splice(q, 1);
|
|
1963
1963
|
}
|
|
1964
1964
|
}
|
|
1965
1965
|
let p = 0;
|
|
@@ -1978,10 +1978,10 @@ class r {
|
|
|
1978
1978
|
for (const A of M)
|
|
1979
1979
|
for (const W of A)
|
|
1980
1980
|
z.push(W);
|
|
1981
|
-
const p =
|
|
1981
|
+
const p = t.featureCollection([]), b = a.convertToMonotonicLng2(z);
|
|
1982
1982
|
for (const A of b)
|
|
1983
|
-
p.features.push(
|
|
1984
|
-
const O =
|
|
1983
|
+
p.features.push(t.point(A));
|
|
1984
|
+
const O = t.center(p).geometry.coordinates;
|
|
1985
1985
|
return { lng: a.convertToStdLng(O[0], 8), lat: a.roundPrecision(O[1], 8) };
|
|
1986
1986
|
}
|
|
1987
1987
|
/**
|
|
@@ -2001,8 +2001,8 @@ class r {
|
|
|
2001
2001
|
for (const c of M)
|
|
2002
2002
|
for (const O of c)
|
|
2003
2003
|
z.push(O);
|
|
2004
|
-
const p = a.convertToMonotonicLng2(z), b =
|
|
2005
|
-
return
|
|
2004
|
+
const p = a.convertToMonotonicLng2(z), b = t.lineString(p);
|
|
2005
|
+
return t.bbox(b);
|
|
2006
2006
|
}
|
|
2007
2007
|
/**
|
|
2008
2008
|
* 计算BBox
|
|
@@ -2022,14 +2022,14 @@ class r {
|
|
|
2022
2022
|
const b = [];
|
|
2023
2023
|
for (let c = 1; c < M.length; c++) {
|
|
2024
2024
|
const O = M[c - 1], A = M[c], W = M[c + 1];
|
|
2025
|
-
let
|
|
2026
|
-
if ((O.velocity || O.suspend || O.important || O.pilot || c === 1) && (
|
|
2027
|
-
const
|
|
2028
|
-
Math.round(Math.acos(
|
|
2025
|
+
let q = !1, d = !1;
|
|
2026
|
+
if ((O.velocity || O.suspend || O.important || O.pilot || c === 1) && (q = !0, b.push(O)), A.gcToPrevious && (q || (q = !0, b.push(O)), d = !0, b.push(A), c++), W) {
|
|
2027
|
+
const Y = r.calculateDistance(O, A, !0), R = r.calculateDistance(A, W, !0), T = r.calculateDistance(O, W, !0), e = (Math.pow(Y, 2) + Math.pow(R, 2) - Math.pow(T, 2)) / (2 * Y * R);
|
|
2028
|
+
Math.round(Math.acos(e) * 180 / Math.PI) < p && T > z && !d && (b.push(A), c++);
|
|
2029
2029
|
}
|
|
2030
2030
|
if (c >= M.length - 1) {
|
|
2031
|
-
const
|
|
2032
|
-
|
|
2031
|
+
const Y = M.at(-1);
|
|
2032
|
+
Y && b.push(Y);
|
|
2033
2033
|
}
|
|
2034
2034
|
}
|
|
2035
2035
|
return b;
|
|
@@ -2041,7 +2041,7 @@ class r {
|
|
|
2041
2041
|
* @param waypoints 带时间的轨迹, 单位秒
|
|
2042
2042
|
*/
|
|
2043
2043
|
static nearestTSPointInWaypoints(M, z, p) {
|
|
2044
|
-
const b =
|
|
2044
|
+
const b = U.unix(M), c = p.filter(
|
|
2045
2045
|
(O) => b.clone().subtract(z, "hour").unix() <= (O.positionTime || 0) && b.clone().add(z, "h").unix() >= (O.positionTime || 0)
|
|
2046
2046
|
);
|
|
2047
2047
|
return c.sort((O, A) => (O.positionTime || 0) - (A.positionTime || 0)), c.at(-1);
|
|
@@ -2054,15 +2054,15 @@ class r {
|
|
|
2054
2054
|
static deadReckoning(M, z) {
|
|
2055
2055
|
var c, O, A, W;
|
|
2056
2056
|
M > 1e12 && (M = Math.round(M / 1e3));
|
|
2057
|
-
const p =
|
|
2058
|
-
let b = z.find((
|
|
2057
|
+
const p = U.unix(M);
|
|
2058
|
+
let b = z.find((q) => q.positionTime === p.unix());
|
|
2059
2059
|
if (!b) {
|
|
2060
|
-
const
|
|
2061
|
-
if (
|
|
2062
|
-
const
|
|
2063
|
-
b = r.calculateCoordinate(
|
|
2060
|
+
const q = (O = (c = z.filter((Y) => (Y == null ? void 0 : Y.positionTime) < p.unix())) == null ? void 0 : c.sort((Y, R) => (Y.positionTime || 0) - (R.positionTime || 0))) == null ? void 0 : O.at(-1), d = (W = (A = z.filter((Y) => (Y == null ? void 0 : Y.positionTime) > p.unix())) == null ? void 0 : A.sort((Y, R) => (Y.positionTime || 0) - (R.positionTime || 0))) == null ? void 0 : W.at(0);
|
|
2061
|
+
if (q && d) {
|
|
2062
|
+
const Y = r.calculateBearing(q, d, !0), R = r.calculateDistance(q, d), T = (p.unix() - q.positionTime) / (d.positionTime - q.positionTime);
|
|
2063
|
+
b = r.calculateCoordinate(q, Y, R * T), b.positionTime = p.unix(), b.utc = p.utc().format(), b.cog = Y, b.sog = Math.round(R / ((d.positionTime - q.positionTime) / 3600) * 100) / 100;
|
|
2064
2064
|
} else
|
|
2065
|
-
b =
|
|
2065
|
+
b = q || d, b && (b.utc = U.unix(b == null ? void 0 : b.positionTime).utc().format());
|
|
2066
2066
|
}
|
|
2067
2067
|
return b;
|
|
2068
2068
|
}
|
|
@@ -2072,11 +2072,11 @@ class r {
|
|
|
2072
2072
|
* @param positions
|
|
2073
2073
|
*/
|
|
2074
2074
|
static deadReckoningTime(M, z) {
|
|
2075
|
-
z = JSON.parse(JSON.stringify(z)), z.sort((
|
|
2075
|
+
z = JSON.parse(JSON.stringify(z)), z.sort((q, d) => (q.positionTime || 0) - (d.positionTime || 0));
|
|
2076
2076
|
let p = Number.MAX_SAFE_INTEGER, b = Number.MAX_SAFE_INTEGER;
|
|
2077
|
-
for (let
|
|
2078
|
-
const
|
|
2079
|
-
R < p && (p = R, b =
|
|
2077
|
+
for (let q = 0; q < z.length - 1; q++) {
|
|
2078
|
+
const d = z[q], Y = z[q + 1], R = r.calculatePointToLineDistance(M, d, Y);
|
|
2079
|
+
R < p && (p = R, b = q);
|
|
2080
2080
|
}
|
|
2081
2081
|
const c = z[b], O = z[b + 1], A = r.calculateDistance(c, M), W = r.calculateDistance(O, M);
|
|
2082
2082
|
if (A === 0)
|
|
@@ -2084,10 +2084,10 @@ class r {
|
|
|
2084
2084
|
else if (W === 0)
|
|
2085
2085
|
M = O;
|
|
2086
2086
|
else {
|
|
2087
|
-
const
|
|
2088
|
-
M.positionTime = Math.round(
|
|
2087
|
+
const q = c.positionTime || 0, d = O.positionTime || 0, Y = r.calculateDistance(c, O);
|
|
2088
|
+
M.positionTime = Math.round(q + (d - q) * (A / Y));
|
|
2089
2089
|
}
|
|
2090
|
-
return M.utc = M.positionTime ?
|
|
2090
|
+
return M.utc = M.positionTime ? U.unix(M.positionTime).utc().format() : void 0, M.positionTime ? M : void 0;
|
|
2091
2091
|
}
|
|
2092
2092
|
/**
|
|
2093
2093
|
* 翻转轨迹
|
|
@@ -2132,46 +2132,51 @@ class r {
|
|
|
2132
2132
|
* @param waypoints 途径点
|
|
2133
2133
|
* @see https://cirm.org/rtz-xml-schemas
|
|
2134
2134
|
*/
|
|
2135
|
-
static waypoints2RTZ10(M, z) {
|
|
2136
|
-
const
|
|
2137
|
-
return
|
|
2135
|
+
static waypoints2RTZ10(M, z, p = !0) {
|
|
2136
|
+
const c = [];
|
|
2137
|
+
return c.push('<?xml version="1.0" encoding="UTF-8"?>'), c.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'), c.push(` <routeInfo routeName="${r.xmlEscape(M)}"></routeInfo>`), c.push(...r.toRTZWaypoints(z, 6, p)), c.push("</route>"), c.join(`
|
|
2138
2138
|
`);
|
|
2139
2139
|
}
|
|
2140
|
-
static toRTZWaypoints(M, z = 6) {
|
|
2141
|
-
const
|
|
2142
|
-
|
|
2143
|
-
for (let
|
|
2144
|
-
const
|
|
2145
|
-
if (
|
|
2146
|
-
const
|
|
2147
|
-
|
|
2140
|
+
static toRTZWaypoints(M, z = 6, p = !0) {
|
|
2141
|
+
const b = [];
|
|
2142
|
+
b.push(" <waypoints>");
|
|
2143
|
+
for (let c = 0; c < M.length; c++) {
|
|
2144
|
+
const O = M[c], A = c + 1, W = (O.lat ?? "").toFixed ? O.lat.toFixed(z).padEnd(z + 2, "0") : O.lat, q = (O.lng ?? "").toFixed ? O.lng.toFixed(z).padEnd(z + 2, "0") : O.lng, d = [`id="${A}"`, 'revision="0"'];
|
|
2145
|
+
if (O.name && d.push(`name="${r.xmlEscape(O.name)}"`), b.push(` <waypoint ${d.join(" ")}>`), b.push(` <position lat="${r.xmlEscape(W)}" lon="${r.xmlEscape(q)}" />`), c > 0) {
|
|
2146
|
+
const Y = O.gcToPrevious ? "Orthodrome" : "Loxodrome";
|
|
2147
|
+
b.push(` <leg geometryType="${Y}" />`);
|
|
2148
2148
|
}
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
Y.push(` <
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
}
|
|
2156
|
-
|
|
2157
|
-
|
|
2149
|
+
if (p) {
|
|
2150
|
+
const Y = [];
|
|
2151
|
+
if (O.description && Y.push(` <description>${r.xmlEscape(O.description)}</description>`), O.utc)
|
|
2152
|
+
Y.push(` <time>${r.xmlEscape(O.utc)}</time>`);
|
|
2153
|
+
else if (O.positionTime)
|
|
2154
|
+
try {
|
|
2155
|
+
Y.push(` <time>${r.xmlEscape(U.unix(O.positionTime).utc().format())}</time>`);
|
|
2156
|
+
} catch {
|
|
2157
|
+
}
|
|
2158
|
+
O.cog !== void 0 && Y.push(` <cog>${r.xmlEscape(O.cog)}</cog>`), O.sog !== void 0 && Y.push(` <sog>${r.xmlEscape(O.sog)}</sog>`), Y.length && (b.push(" <extensions>"), b.push(...Y), b.push(" </extensions>"));
|
|
2159
|
+
}
|
|
2160
|
+
b.push(" </waypoint>");
|
|
2158
2161
|
}
|
|
2159
|
-
return
|
|
2162
|
+
return b.push(" </waypoints>"), b;
|
|
2160
2163
|
}
|
|
2161
2164
|
/**
|
|
2162
2165
|
* 路径转通用CSV (纯十进制度数、无厂商头、RFC 4180标准)
|
|
2163
2166
|
* 大部分海图设备/导航软件均可导入此格式
|
|
2167
|
+
* @param name 兼容旧版本
|
|
2164
2168
|
* @param waypoints 途径点
|
|
2165
2169
|
* @param options.precision 经纬度小数位数,默认6
|
|
2166
2170
|
*/
|
|
2167
|
-
static waypoints2CSV(M, z) {
|
|
2168
|
-
|
|
2169
|
-
b
|
|
2171
|
+
static waypoints2CSV(M, z, p) {
|
|
2172
|
+
H.debug("keep name for waypoints2CSV for legacy compatibility only", M);
|
|
2173
|
+
const b = (p == null ? void 0 : p.precision) ?? 6, c = z.some((i) => i.name), O = z.some((i) => i.description), A = z.some((i) => i.port != null), W = z.some((i) => i.stbd != null), q = z.some((i) => i.arrRad != null), d = z.some((i) => i.speed != null), Y = z.some((i, S) => S > 0 && i.gcToPrevious != null), R = z.some((i) => i.bearing != null), T = z.some((i) => i.distanceFromPrevious != null), e = ["WPT No.", "Latitude", "Longitude"];
|
|
2174
|
+
c && e.push("Name"), O && e.push("Description"), Y && e.push("Leg"), R && e.push("Bearing[deg]"), T && e.push("Distance[NM]"), d && e.push("Speed[kn]"), A && e.push("PORT XTD[NM]"), W && e.push("STBD XTD[NM]"), q && e.push("Arr.Rad[NM]");
|
|
2170
2175
|
const f = [];
|
|
2171
|
-
f.push(
|
|
2172
|
-
for (let i = 0; i <
|
|
2173
|
-
const
|
|
2174
|
-
|
|
2176
|
+
f.push(e.map((i) => r.csvEscapeField(i)).join(","));
|
|
2177
|
+
for (let i = 0; i < z.length; i++) {
|
|
2178
|
+
const S = z[i], u = [];
|
|
2179
|
+
u.push((i + 1).toString()), u.push(S.lat.toFixed(b)), u.push(S.lng.toFixed(b)), c && u.push(S.name ?? ""), O && u.push(S.description ?? ""), Y && u.push(i === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), R && u.push(S.bearing != null ? String(S.bearing) : ""), T && u.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), d && u.push(S.speed != null ? String(S.speed) : ""), A && u.push(S.port != null ? String(S.port) : ""), W && u.push(S.stbd != null ? String(S.stbd) : ""), q && u.push(S.arrRad != null ? String(S.arrRad) : ""), f.push(u.map((Z) => r.csvEscapeField(Z)).join(","));
|
|
2175
2180
|
}
|
|
2176
2181
|
return f.join(`
|
|
2177
2182
|
`);
|
|
@@ -2213,8 +2218,8 @@ class r {
|
|
|
2213
2218
|
static waypoints2NMEA(M) {
|
|
2214
2219
|
const z = [];
|
|
2215
2220
|
for (let p = 0; p < M.length; p++) {
|
|
2216
|
-
const b = M[p], c = r.decimalToNmeaDm(b.lat, !0), O = r.decimalToNmeaDm(b.lng, !1), A = b.name ? String(b.name).slice(0, 6) : `WPT${(p + 1).toString().padStart(3, "0")}`, W = `GPWPL,${c.dm},${c.dir},${O.dm},${O.dir},${A}`,
|
|
2217
|
-
z.push(`$${W}*${
|
|
2221
|
+
const b = M[p], c = r.decimalToNmeaDm(b.lat, !0), O = r.decimalToNmeaDm(b.lng, !1), A = b.name ? String(b.name).slice(0, 6) : `WPT${(p + 1).toString().padStart(3, "0")}`, W = `GPWPL,${c.dm},${c.dir},${O.dm},${O.dir},${A}`, q = r.nmeaChecksum(W);
|
|
2222
|
+
z.push(`$${W}*${q}`);
|
|
2218
2223
|
}
|
|
2219
2224
|
return z.join(`\r
|
|
2220
2225
|
`);
|
|
@@ -2233,19 +2238,19 @@ class r {
|
|
|
2233
2238
|
*/
|
|
2234
2239
|
static coordinatesSummary(M, z = 3) {
|
|
2235
2240
|
if (M.length > 1) {
|
|
2236
|
-
const p = M[0], b = M[M.length - 1], c = (p == null ? void 0 : p.positionTime) < (b == null ? void 0 : b.positionTime) ?
|
|
2237
|
-
(T,
|
|
2241
|
+
const p = M[0], b = M[M.length - 1], c = (p == null ? void 0 : p.positionTime) < (b == null ? void 0 : b.positionTime) ? U.unix(p == null ? void 0 : p.positionTime) : U.unix(b == null ? void 0 : b.positionTime), O = (p == null ? void 0 : p.positionTime) > (b == null ? void 0 : b.positionTime) ? U.unix(p == null ? void 0 : p.positionTime) : U.unix(b == null ? void 0 : b.positionTime), A = Math.round(O.diff(c, "hours", !0) * 100) / 100, W = this.generateRouteAccordingToWaypoints(M, !0, !0), q = this.calculateRouteDistance(W), Y = t0.inspectStoppages(M, z).reduce(
|
|
2242
|
+
(T, e) => (T.duration += e.duration, T.distance += e.distance, T),
|
|
2238
2243
|
{ hours: 0, distance: 0, spd: 0, duration: 0 }
|
|
2239
2244
|
);
|
|
2240
|
-
|
|
2241
|
-
const R = A ? Math.round((
|
|
2245
|
+
Y.hours = Math.round(Y.duration / 3600 * 100) / 100, Y.distance = Math.round(Y.distance * 100) / 100, Y.spd = Y.hours ? Math.round(Y.distance / Y.hours * 100) / 100 : 0;
|
|
2246
|
+
const R = A ? Math.round((q - Y.distance) / (A - Y.hours) * 100) / 100 : 0;
|
|
2242
2247
|
return {
|
|
2243
2248
|
begin: c.utc().format(),
|
|
2244
2249
|
end: O.utc().format(),
|
|
2245
|
-
distance: Math.round((
|
|
2246
|
-
hours: Math.round((A -
|
|
2250
|
+
distance: Math.round((q - Y.distance) * 100) / 100,
|
|
2251
|
+
hours: Math.round((A - Y.hours) * 100) / 100,
|
|
2247
2252
|
avgSpeed: R,
|
|
2248
|
-
stoppage:
|
|
2253
|
+
stoppage: Y
|
|
2249
2254
|
};
|
|
2250
2255
|
}
|
|
2251
2256
|
return {
|
|
@@ -2266,24 +2271,24 @@ class r {
|
|
|
2266
2271
|
* }
|
|
2267
2272
|
*/
|
|
2268
2273
|
static pickUTCSampleFromSpeed(M, z) {
|
|
2269
|
-
var
|
|
2270
|
-
if (!((
|
|
2274
|
+
var d, Y, R;
|
|
2275
|
+
if (!((Y = (d = z == null ? void 0 : z.sample) == null ? void 0 : d.hours) != null && Y.length))
|
|
2271
2276
|
return { routes: [], hour: void 0 };
|
|
2272
|
-
const p = z.sample.hours.at(0), b =
|
|
2277
|
+
const p = z.sample.hours.at(0), b = U.utc(M), c = U.utc(z.eta), O = b.isAfter(c) ? c : b;
|
|
2273
2278
|
let A = z.sample.all.find((T) => T.eta === O.format());
|
|
2274
2279
|
if (!A) {
|
|
2275
|
-
const T = z.sample.all.filter((G) =>
|
|
2276
|
-
A = (R = this.calculateNextCoordinateAlongRoute(T, T.speed * O.diff(
|
|
2277
|
-
const { cFactor:
|
|
2280
|
+
const T = z.sample.all.filter((G) => U.utc(G.eta).isBefore(O)).at(-1), e = this.calculateSubRoute(T, z.route);
|
|
2281
|
+
A = (R = this.calculateNextCoordinateAlongRoute(T, T.speed * O.diff(U(T.etd), "hours", !0), e)) == null ? void 0 : R.coordinate;
|
|
2282
|
+
const { cFactor: f, cog: i, wxFactor: S, meteo: u } = T, Z = Math.round(A.distanceFromPrevious * 1e4) / 1e4, B = Math.round((Z + T.distanceFromStart) * 1e4) / 1e4;
|
|
2278
2283
|
A = {
|
|
2279
2284
|
...A,
|
|
2280
|
-
cFactor:
|
|
2281
|
-
cog:
|
|
2285
|
+
cFactor: f,
|
|
2286
|
+
cog: i,
|
|
2282
2287
|
speed: T.speed,
|
|
2283
|
-
wxFactor:
|
|
2284
|
-
distanceFromStart:
|
|
2288
|
+
wxFactor: S,
|
|
2289
|
+
distanceFromStart: B,
|
|
2285
2290
|
distanceFromPrevious: Z,
|
|
2286
|
-
meteo:
|
|
2291
|
+
meteo: u,
|
|
2287
2292
|
eta: O.format(),
|
|
2288
2293
|
etd: O.format()
|
|
2289
2294
|
};
|
|
@@ -2307,14 +2312,14 @@ class r {
|
|
|
2307
2312
|
*/
|
|
2308
2313
|
static pickUTCSampleFromRoute(M, z, p) {
|
|
2309
2314
|
var T;
|
|
2310
|
-
const b = this.calculateSubRoute(z, p), c = this.calculateRouteDistance(b), O = c / z.speed, A =
|
|
2311
|
-
|
|
2312
|
-
const
|
|
2313
|
-
|
|
2314
|
-
const
|
|
2315
|
+
const b = this.calculateSubRoute(z, p), c = this.calculateRouteDistance(b), O = c / z.speed, A = U.utc(M), W = U(z.etd), q = (T = this.calculateNextCoordinateAlongRoute(z, z.speed * A.diff(U(z.etd), "hours", !0), b)) == null ? void 0 : T.coordinate;
|
|
2316
|
+
q.speed = z.speed;
|
|
2317
|
+
const d = W.clone().add(q.hourFromPrevious, "hour");
|
|
2318
|
+
q.eta = Math.abs(d.diff(A, "second")) < 2 ? A.format() : d.format(), q.etd = q.eta, q.distanceFromStart = Math.round(q.distanceFromPrevious * 100) / 100, q.distanceToGo = Math.round((c - q.distanceFromStart) * 100) / 100, q.timeToGo = Math.round(W.clone().add(O, "hour").diff(U(q.etd), "hour") * 100) / 100;
|
|
2319
|
+
const Y = this.calculateRangeWaypoints(z, q, p);
|
|
2315
2320
|
return {
|
|
2316
|
-
routes: this.generateRouteAccordingToWaypoints(
|
|
2317
|
-
hour:
|
|
2321
|
+
routes: this.generateRouteAccordingToWaypoints(Y),
|
|
2322
|
+
hour: q
|
|
2318
2323
|
};
|
|
2319
2324
|
}
|
|
2320
2325
|
/**
|
|
@@ -2323,7 +2328,7 @@ class r {
|
|
|
2323
2328
|
* @param degree 要素角度,如 swell.degree
|
|
2324
2329
|
*/
|
|
2325
2330
|
static includedAngle(M, z) {
|
|
2326
|
-
|
|
2331
|
+
H == null || H.debug("calculate bearing via: %j", { bearing: M, degree: z });
|
|
2327
2332
|
let p = Math.abs(M % 360 - (z % 360 || 0));
|
|
2328
2333
|
return p = p > 180 ? 360 - p : p, p;
|
|
2329
2334
|
}
|
|
@@ -2341,80 +2346,80 @@ class V0 {
|
|
|
2341
2346
|
*/
|
|
2342
2347
|
static convert2Geojson(M) {
|
|
2343
2348
|
var p, b, c;
|
|
2344
|
-
const z =
|
|
2349
|
+
const z = t.featureCollection([]);
|
|
2345
2350
|
for (const O of M) {
|
|
2346
2351
|
const A = (p = O.history) == null ? void 0 : p[0];
|
|
2347
2352
|
if (O.forecasts) {
|
|
2348
2353
|
A && A.wind && (A.wind.kts = A.kts);
|
|
2349
2354
|
for (const W of O.forecasts) {
|
|
2350
|
-
let
|
|
2351
|
-
const
|
|
2352
|
-
for (const
|
|
2353
|
-
const
|
|
2354
|
-
|
|
2355
|
-
const
|
|
2355
|
+
let q;
|
|
2356
|
+
const d = [], Y = [], R = U(W.date).utc(), T = `${O.name}-${W.model}`;
|
|
2357
|
+
for (const f in W == null ? void 0 : W.hours) {
|
|
2358
|
+
const i = W.hours[f];
|
|
2359
|
+
q = q || i;
|
|
2360
|
+
const S = R.clone().add(Number(f), "hour"), u = t.point([i.lng, i.lat], {
|
|
2356
2361
|
model: W.model,
|
|
2357
2362
|
name: O.name,
|
|
2358
2363
|
nameCn: O.nameCn,
|
|
2359
|
-
date:
|
|
2360
|
-
hour: Number(
|
|
2361
|
-
format:
|
|
2362
|
-
pressure:
|
|
2363
|
-
gusts:
|
|
2364
|
-
wind:
|
|
2365
|
-
movement:
|
|
2364
|
+
date: S.format(),
|
|
2365
|
+
hour: Number(f),
|
|
2366
|
+
format: S.format("MMM-DD/HHmm[Z]"),
|
|
2367
|
+
pressure: i.pressure > 1e4 ? a.roundPrecision(i.pressure / 100, 0) : a.roundPrecision(i.pressure, 0),
|
|
2368
|
+
gusts: i.gusts,
|
|
2369
|
+
wind: i.wind || {},
|
|
2370
|
+
movement: i.movement,
|
|
2366
2371
|
category: T,
|
|
2367
2372
|
type: "forecast"
|
|
2368
2373
|
});
|
|
2369
|
-
|
|
2374
|
+
Y.push(u), d.push(u.geometry.coordinates);
|
|
2370
2375
|
}
|
|
2371
|
-
const
|
|
2376
|
+
const e = {
|
|
2372
2377
|
kts: void 0,
|
|
2373
2378
|
deg: void 0
|
|
2374
2379
|
};
|
|
2375
2380
|
if (A) {
|
|
2376
|
-
const
|
|
2377
|
-
if (
|
|
2378
|
-
const
|
|
2379
|
-
|
|
2381
|
+
const f = U(A.updated).utc();
|
|
2382
|
+
if (q) {
|
|
2383
|
+
const S = r.calculateDistance(A, q), u = U(q.utc || q.updated).diff(f, "h", !0);
|
|
2384
|
+
e.kts = Math.round(S / u * 100) / 100, e.deg = r.calculateBearing(A, q, !0, 0);
|
|
2380
2385
|
}
|
|
2381
|
-
const
|
|
2386
|
+
const i = t.point([A.lng, A.lat], {
|
|
2382
2387
|
model: W.model,
|
|
2383
2388
|
name: O.name,
|
|
2384
2389
|
nameCn: O.nameCn,
|
|
2385
|
-
date:
|
|
2390
|
+
date: f.format(),
|
|
2386
2391
|
hour: 0,
|
|
2387
|
-
format:
|
|
2392
|
+
format: f.format("MMM-DD/HHmm[Z]"),
|
|
2388
2393
|
pressure: A.pressure > 1e4 ? a.roundPrecision((A == null ? void 0 : A.pressure) / 100, 0) : a.roundPrecision(A.pressure, 0),
|
|
2389
2394
|
wind: A.wind,
|
|
2390
|
-
movement:
|
|
2395
|
+
movement: e,
|
|
2391
2396
|
category: T,
|
|
2392
2397
|
type: "forecast",
|
|
2393
2398
|
important: !0
|
|
2394
2399
|
// 第一个预报点为重要点
|
|
2395
2400
|
});
|
|
2396
|
-
|
|
2401
|
+
Y.unshift(i), d.unshift(i.geometry.coordinates);
|
|
2397
2402
|
}
|
|
2398
|
-
if (z.features.push(...
|
|
2399
|
-
const
|
|
2403
|
+
if (z.features.push(...Y), (d == null ? void 0 : d.length) > 1) {
|
|
2404
|
+
const f = t.lineString(a.convertToMonotonicLng2(d), {
|
|
2400
2405
|
date: (A == null ? void 0 : A.updated) || (R == null ? void 0 : R.format()),
|
|
2401
2406
|
id: O.id || O.name,
|
|
2402
2407
|
model: W.model,
|
|
2403
2408
|
name: O.name,
|
|
2404
2409
|
category: T,
|
|
2405
2410
|
type: "forecast",
|
|
2406
|
-
movement:
|
|
2411
|
+
movement: e
|
|
2407
2412
|
});
|
|
2408
|
-
z.features.push(
|
|
2413
|
+
z.features.push(f);
|
|
2409
2414
|
}
|
|
2410
2415
|
}
|
|
2411
2416
|
}
|
|
2412
|
-
if (z.features.sort((W,
|
|
2413
|
-
const W = [],
|
|
2417
|
+
if (z.features.sort((W, q) => W.properties.type === "forecast" && q.properties.type === "forecast" && W.geometry.type === "Point" && q.geometry.type === "Point" ? U(W.properties.date).valueOf() - U(q.properties.date).valueOf() : 0), (b = O.history) != null && b.length) {
|
|
2418
|
+
const W = [], q = U(A == null ? void 0 : A.updated).utc(), d = U((c = O.history) == null ? void 0 : c.at(-1).updated).utc(), Y = q.diff(d, "h") % 24 > 2 ? 24 : 12;
|
|
2414
2419
|
for (const R of O.history) {
|
|
2415
|
-
const T =
|
|
2416
|
-
|
|
2417
|
-
const
|
|
2420
|
+
const T = U(R.updated).utc(), e = T.isSameOrBefore(q) || T.isSame(d);
|
|
2421
|
+
e && q.add(-Y, "h");
|
|
2422
|
+
const f = t.point([R.lng, R.lat], {
|
|
2418
2423
|
name: O.name,
|
|
2419
2424
|
nameCn: O.nameCn,
|
|
2420
2425
|
date: T.format(),
|
|
@@ -2426,12 +2431,12 @@ class V0 {
|
|
|
2426
2431
|
category: `${O.name}-history`,
|
|
2427
2432
|
wind: R.wind,
|
|
2428
2433
|
movement: R.movement,
|
|
2429
|
-
important:
|
|
2434
|
+
important: e
|
|
2430
2435
|
});
|
|
2431
|
-
z.features.push(
|
|
2436
|
+
z.features.push(f), W.push(f.geometry.coordinates);
|
|
2432
2437
|
}
|
|
2433
2438
|
if (W.length === 1 && W.push(W[0]), W.length > 1) {
|
|
2434
|
-
const R =
|
|
2439
|
+
const R = t.lineString(a.convertToMonotonicLng2(W), {
|
|
2435
2440
|
name: O.name,
|
|
2436
2441
|
type: "history",
|
|
2437
2442
|
updated: A == null ? void 0 : A.updated,
|
|
@@ -2452,34 +2457,34 @@ class V0 {
|
|
|
2452
2457
|
*/
|
|
2453
2458
|
static interpolate(M, z = 3) {
|
|
2454
2459
|
var c, O, A, W;
|
|
2455
|
-
const p = (c = M == null ? void 0 : M.data) == null ? void 0 : c.features.filter((
|
|
2456
|
-
for (const
|
|
2457
|
-
const
|
|
2458
|
-
let
|
|
2459
|
-
const
|
|
2460
|
-
(Z) => Z.geometry.type === "Point" && Z.properties.type === "forecast" && Z.properties.category === `${
|
|
2460
|
+
const p = (c = M == null ? void 0 : M.data) == null ? void 0 : c.features.filter((q) => q.geometry.type === "LineString" && q.properties.type === "forecast"), b = [];
|
|
2461
|
+
for (const q of p) {
|
|
2462
|
+
const d = q.properties.name, Y = q.properties.model, R = q.properties.showCircle, T = q.properties.disabled, e = U(q.properties.date).utc();
|
|
2463
|
+
let f = z * 60;
|
|
2464
|
+
const i = (O = M == null ? void 0 : M.data) == null ? void 0 : O.features.filter(
|
|
2465
|
+
(Z) => Z.geometry.type === "Point" && Z.properties.type === "forecast" && Z.properties.category === `${d}-${Y}`
|
|
2461
2466
|
);
|
|
2462
|
-
let
|
|
2463
|
-
for (;
|
|
2464
|
-
if (
|
|
2465
|
-
const Z =
|
|
2466
|
-
name:
|
|
2467
|
-
model:
|
|
2467
|
+
let S, u = e.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2468
|
+
for (; S = this.pickIndex(i, u), S <= i.length - 1; ) {
|
|
2469
|
+
if (S > 0) {
|
|
2470
|
+
const Z = i[S], B = S === 0 ? void 0 : i[S - 1], G = (f / 60 - ((A = B == null ? void 0 : B.properties) == null ? void 0 : A.hour)) / (Z.properties.hour - ((W = B == null ? void 0 : B.properties) == null ? void 0 : W.hour)), Q = this.computeNumber(B == null ? void 0 : B.geometry.coordinates[0], Z.geometry.coordinates[0], G), F = this.computeNumber(B == null ? void 0 : B.geometry.coordinates[1], Z.geometry.coordinates[1], G), $ = t.point([Q, F], {
|
|
2471
|
+
name: d,
|
|
2472
|
+
model: Y,
|
|
2468
2473
|
category: Z == null ? void 0 : Z.properties.category,
|
|
2469
|
-
date:
|
|
2470
|
-
format:
|
|
2471
|
-
gusts: this.computeNumber(
|
|
2472
|
-
hour: this.computeNumber(
|
|
2473
|
-
movement: this.computeNumber(
|
|
2474
|
-
pressure: this.computeNumber(
|
|
2475
|
-
wind: this.computeNumber(
|
|
2474
|
+
date: u.format(),
|
|
2475
|
+
format: u.format("MMM-DD/HHmm[Z]"),
|
|
2476
|
+
gusts: this.computeNumber(B == null ? void 0 : B.properties.gusts, Z.properties.gusts, G),
|
|
2477
|
+
hour: this.computeNumber(B == null ? void 0 : B.properties.hour, Z.properties.hour, G),
|
|
2478
|
+
movement: this.computeNumber(B == null ? void 0 : B.properties.movement, Z.properties.movement, G),
|
|
2479
|
+
pressure: this.computeNumber(B == null ? void 0 : B.properties.pressure, Z.properties.pressure, G),
|
|
2480
|
+
wind: this.computeNumber(B == null ? void 0 : B.properties.wind, Z.properties.wind, G),
|
|
2476
2481
|
type: "forecast",
|
|
2477
2482
|
disabled: T,
|
|
2478
2483
|
showCircle: R
|
|
2479
2484
|
});
|
|
2480
2485
|
b.push($);
|
|
2481
2486
|
}
|
|
2482
|
-
|
|
2487
|
+
f += z * 60, u = e.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2483
2488
|
}
|
|
2484
2489
|
}
|
|
2485
2490
|
return b;
|
|
@@ -2509,26 +2514,26 @@ class V0 {
|
|
|
2509
2514
|
const { t1: c, t2: O, hr: A, hours: W } = this.tropicalCenterTwin(z, 24, b);
|
|
2510
2515
|
if (c && O) {
|
|
2511
2516
|
if (!b.debug) {
|
|
2512
|
-
const
|
|
2513
|
-
if (
|
|
2514
|
-
return I == null || I.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", b.requestId,
|
|
2517
|
+
const e = r.calculateDistance(M, c), f = r.calculateDistance(M, O);
|
|
2518
|
+
if (e > 2 * p && f > 2 * p)
|
|
2519
|
+
return I == null || I.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", b.requestId, e, f, {
|
|
2515
2520
|
from: M,
|
|
2516
2521
|
t1: c,
|
|
2517
2522
|
t2: O,
|
|
2518
2523
|
hr: A
|
|
2519
2524
|
}), {};
|
|
2520
2525
|
}
|
|
2521
|
-
const
|
|
2526
|
+
const q = r.calculateBearing(M, c), d = r.calculateBearing(c, O), Y = Math.abs(q - d);
|
|
2522
2527
|
let R = 0;
|
|
2523
|
-
|
|
2528
|
+
Y < 180 ? R = Y + 90 : Y >= 180 && (R = Y - 90);
|
|
2524
2529
|
const T = r.calculateCoordinate(c, R, p);
|
|
2525
2530
|
return I == null || I.info("[%s] the right tangent position: %j", b.requestId, {
|
|
2526
2531
|
from: M,
|
|
2527
2532
|
t1: c,
|
|
2528
2533
|
t2: O,
|
|
2529
2534
|
radius: p,
|
|
2530
|
-
bearing1:
|
|
2531
|
-
bearing2:
|
|
2535
|
+
bearing1: q,
|
|
2536
|
+
bearing2: d,
|
|
2532
2537
|
right: T
|
|
2533
2538
|
}), { at: T, t1: c, t2: O, hr: Number(A), hours: W };
|
|
2534
2539
|
}
|
|
@@ -2548,17 +2553,17 @@ class V0 {
|
|
|
2548
2553
|
const { t1: c, t2: O, hr: A, hours: W } = this.tropicalCenterTwin(z, 24, b);
|
|
2549
2554
|
if (c && O) {
|
|
2550
2555
|
if (!b.debug) {
|
|
2551
|
-
const T = r.calculateDistance(M, c),
|
|
2552
|
-
if (T > 2 * p &&
|
|
2553
|
-
return I == null || I.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", b.requestId, T,
|
|
2556
|
+
const T = r.calculateDistance(M, c), e = r.calculateDistance(M, O);
|
|
2557
|
+
if (T > 2 * p && e > 2 * p)
|
|
2558
|
+
return I == null || I.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", b.requestId, T, e, {
|
|
2554
2559
|
from: M,
|
|
2555
2560
|
t1: c,
|
|
2556
2561
|
t2: O,
|
|
2557
2562
|
hr: A
|
|
2558
2563
|
}), {};
|
|
2559
2564
|
}
|
|
2560
|
-
const
|
|
2561
|
-
return { at: r.calculateCoordinate(c,
|
|
2565
|
+
const q = r.calculateBearing(M, c), d = r.calculateBearing(c, O), Y = r.calculateDistance(M, c);
|
|
2566
|
+
return { at: r.calculateCoordinate(c, q - d + 180, p < Y ? p : Y), t1: c, t2: O, hr: Number(A), hours: W };
|
|
2562
2567
|
} else
|
|
2563
2568
|
return I == null || I.info("[%s] no need drift: %j", b.requestId, { from: M, t1: c, t2: O, hr: A }), {};
|
|
2564
2569
|
}
|
|
@@ -2571,26 +2576,26 @@ class V0 {
|
|
|
2571
2576
|
* @private
|
|
2572
2577
|
*/
|
|
2573
2578
|
static tropicalCenterTwin(M, z = 24, p = {}) {
|
|
2574
|
-
var
|
|
2579
|
+
var d, Y, R, T, e;
|
|
2575
2580
|
let b = {};
|
|
2576
|
-
(
|
|
2577
|
-
b = { ...
|
|
2581
|
+
(d = M.forecasts) == null || d.forEach((f) => {
|
|
2582
|
+
b = { ...f.hours, ...b };
|
|
2578
2583
|
});
|
|
2579
|
-
const c = ((
|
|
2584
|
+
const c = ((Y = M == null ? void 0 : M.history) == null ? void 0 : Y[0]) || (b == null ? void 0 : b[(R = Object.keys(b)) == null ? void 0 : R[0]]);
|
|
2580
2585
|
I == null || I.info("[%s] the first tropical center: %j", p.requestId, c);
|
|
2581
|
-
let O = (T = Object.keys(b || {}).filter((
|
|
2582
|
-
O || (O = (
|
|
2586
|
+
let O = (T = Object.keys(b || {}).filter((f) => Number(f) <= (z < 0 ? 24 : z))) == null ? void 0 : T.at(-1);
|
|
2587
|
+
O || (O = (e = Object.keys(b || {}).filter((f) => Number(f) <= (z < 0 ? 24 : 2 * z))) == null ? void 0 : e.at(-1));
|
|
2583
2588
|
const A = b == null ? void 0 : b[O || -1];
|
|
2584
2589
|
I == null || I.info("[%s] the second tropical center: %j in %d hrs", p.requestId, A, O);
|
|
2585
|
-
const W = Object.keys(b || {}).filter((
|
|
2586
|
-
for (const
|
|
2587
|
-
|
|
2588
|
-
return { t1: c, t2: A, hr: Number(O), hours:
|
|
2590
|
+
const W = Object.keys(b || {}).filter((f) => Number(f) <= Number(O)), q = { 0: c };
|
|
2591
|
+
for (const f of W)
|
|
2592
|
+
q[f] = b[f];
|
|
2593
|
+
return { t1: c, t2: A, hr: Number(O), hours: q };
|
|
2589
2594
|
}
|
|
2590
2595
|
static pickIndex(M, z) {
|
|
2591
2596
|
let p = 0;
|
|
2592
2597
|
for (const b of M) {
|
|
2593
|
-
if (
|
|
2598
|
+
if (U(b.properties.date).isAfter(z))
|
|
2594
2599
|
return p === 0 ? -1 : p;
|
|
2595
2600
|
p++;
|
|
2596
2601
|
}
|