@idm-plugin/geo 1.7.3 → 1.7.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/ais/src/index.d.ts +1 -1
- package/dist/index.js +337 -332
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16,135 +16,135 @@ var j = { exports: {} };
|
|
|
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
|
-
var z = "0.5.47", p = {}, O = {}, A = {}, b = {},
|
|
19
|
+
var z = "0.5.47", p = {}, O = {}, A = {}, b = {}, c = {}, o;
|
|
20
20
|
(!M || typeof M.version != "string") && D("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
21
21
|
var q = M.version.split("."), d = +q[0], Y = +q[1];
|
|
22
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 L(
|
|
24
|
-
return
|
|
23
|
+
function L(W) {
|
|
24
|
+
return W > 96 ? W - 87 : W > 64 ? W - 29 : W - 48;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
var a = 0, X =
|
|
28
|
-
for (
|
|
29
|
-
t = L(n.charCodeAt(a)),
|
|
30
|
-
for (a = 0; a <
|
|
31
|
-
S = S / 60, t = L(
|
|
32
|
-
return
|
|
26
|
+
function T(W) {
|
|
27
|
+
var a = 0, X = W.split("."), n = X[0], i = X[1] || "", S = 1, t, B = 0, V = 1;
|
|
28
|
+
for (W.charCodeAt(0) === 45 && (a = 1, V = -1), a; a < n.length; a++)
|
|
29
|
+
t = L(n.charCodeAt(a)), B = 60 * B + t;
|
|
30
|
+
for (a = 0; a < i.length; a++)
|
|
31
|
+
S = S / 60, t = L(i.charCodeAt(a)), B += t * S;
|
|
32
|
+
return B * V;
|
|
33
33
|
}
|
|
34
|
-
function U(
|
|
35
|
-
for (var a = 0; a <
|
|
36
|
-
|
|
34
|
+
function U(W) {
|
|
35
|
+
for (var a = 0; a < W.length; a++)
|
|
36
|
+
W[a] = T(W[a]);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function r(W, a) {
|
|
39
39
|
for (var X = 0; X < a; X++)
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
W[X] = Math.round((W[X - 1] || 0) + W[X] * 6e4);
|
|
41
|
+
W[a - 1] = 1 / 0;
|
|
42
42
|
}
|
|
43
|
-
function s(
|
|
43
|
+
function s(W, a) {
|
|
44
44
|
var X = [], n;
|
|
45
45
|
for (n = 0; n < a.length; n++)
|
|
46
|
-
X[n] =
|
|
46
|
+
X[n] = W[a[n]];
|
|
47
47
|
return X;
|
|
48
48
|
}
|
|
49
|
-
function P(
|
|
50
|
-
var a =
|
|
51
|
-
return U(X), U(n), U(
|
|
49
|
+
function P(W) {
|
|
50
|
+
var a = W.split("|"), X = a[2].split(" "), n = a[3].split(""), i = a[4].split(" ");
|
|
51
|
+
return U(X), U(n), U(i), r(i, n.length), {
|
|
52
52
|
name: a[0],
|
|
53
53
|
abbrs: s(a[1].split(" "), n),
|
|
54
54
|
offsets: s(X, n),
|
|
55
|
-
untils:
|
|
55
|
+
untils: i,
|
|
56
56
|
population: a[5] | 0
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function I(
|
|
60
|
-
|
|
59
|
+
function I(W) {
|
|
60
|
+
W && this._set(P(W));
|
|
61
61
|
}
|
|
62
|
-
function l(
|
|
62
|
+
function l(W, a) {
|
|
63
63
|
var X = a.length;
|
|
64
|
-
if (
|
|
64
|
+
if (W < a[0])
|
|
65
65
|
return 0;
|
|
66
|
-
if (X > 1 && a[X - 1] === 1 / 0 &&
|
|
66
|
+
if (X > 1 && a[X - 1] === 1 / 0 && W >= a[X - 2])
|
|
67
67
|
return X - 1;
|
|
68
|
-
if (
|
|
68
|
+
if (W >= a[X - 1])
|
|
69
69
|
return -1;
|
|
70
|
-
for (var n,
|
|
71
|
-
n = Math.floor((
|
|
70
|
+
for (var n, i = 0, S = X - 1; S - i > 1; )
|
|
71
|
+
n = Math.floor((i + S) / 2), a[n] <= W ? i = n : S = n;
|
|
72
72
|
return S;
|
|
73
73
|
}
|
|
74
74
|
I.prototype = {
|
|
75
|
-
_set: function(
|
|
76
|
-
this.name =
|
|
75
|
+
_set: function(W) {
|
|
76
|
+
this.name = W.name, this.abbrs = W.abbrs, this.untils = W.untils, this.offsets = W.offsets, this.population = W.population;
|
|
77
77
|
},
|
|
78
|
-
_index: function(
|
|
79
|
-
var a = +
|
|
78
|
+
_index: function(W) {
|
|
79
|
+
var a = +W, X = this.untils, n;
|
|
80
80
|
if (n = l(a, X), n >= 0)
|
|
81
81
|
return n;
|
|
82
82
|
},
|
|
83
83
|
countries: function() {
|
|
84
|
-
var
|
|
84
|
+
var W = this.name;
|
|
85
85
|
return Object.keys(A).filter(function(a) {
|
|
86
|
-
return A[a].zones.indexOf(
|
|
86
|
+
return A[a].zones.indexOf(W) !== -1;
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
|
-
parse: function(
|
|
90
|
-
var a = +
|
|
91
|
-
for (V = 0; V <
|
|
92
|
-
if (S = X[V], t = X[V + 1],
|
|
89
|
+
parse: function(W) {
|
|
90
|
+
var a = +W, X = this.offsets, n = this.untils, i = n.length - 1, S, t, B, V;
|
|
91
|
+
for (V = 0; V < i; V++)
|
|
92
|
+
if (S = X[V], t = X[V + 1], B = X[V && V - 1], S < t && u.moveAmbiguousForward ? S = t : S > B && u.moveInvalidForward && (S = B), a < n[V] - S * 6e4)
|
|
93
93
|
return X[V];
|
|
94
|
-
return X[
|
|
94
|
+
return X[i];
|
|
95
95
|
},
|
|
96
|
-
abbr: function(
|
|
97
|
-
return this.abbrs[this._index(
|
|
96
|
+
abbr: function(W) {
|
|
97
|
+
return this.abbrs[this._index(W)];
|
|
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(W) {
|
|
100
|
+
return D("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(W)];
|
|
101
101
|
},
|
|
102
|
-
utcOffset: function(
|
|
103
|
-
return this.offsets[this._index(
|
|
102
|
+
utcOffset: function(W) {
|
|
103
|
+
return this.offsets[this._index(W)];
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
function f(
|
|
107
|
-
this.name =
|
|
106
|
+
function f(W, a) {
|
|
107
|
+
this.name = W, this.zones = a;
|
|
108
108
|
}
|
|
109
|
-
function G(
|
|
110
|
-
var a =
|
|
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 = +
|
|
109
|
+
function G(W) {
|
|
110
|
+
var a = W.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 = +W, this.abbr = X, this.offset = W.getTimezoneOffset();
|
|
112
112
|
}
|
|
113
|
-
function H(
|
|
114
|
-
this.zone =
|
|
113
|
+
function H(W) {
|
|
114
|
+
this.zone = W, this.offsetScore = 0, this.abbrScore = 0;
|
|
115
115
|
}
|
|
116
|
-
H.prototype.scoreOffsetAt = function(
|
|
117
|
-
this.offsetScore += Math.abs(this.zone.utcOffset(
|
|
116
|
+
H.prototype.scoreOffsetAt = function(W) {
|
|
117
|
+
this.offsetScore += Math.abs(this.zone.utcOffset(W.at) - W.offset), this.zone.abbr(W.at).replace(/[^A-Z]/g, "") !== W.abbr && this.abbrScore++;
|
|
118
118
|
};
|
|
119
|
-
function Q(
|
|
120
|
-
for (var X, n; n = ((a.at -
|
|
121
|
-
X = new G(new Date(
|
|
122
|
-
return
|
|
119
|
+
function Q(W, a) {
|
|
120
|
+
for (var X, n; n = ((a.at - W.at) / 12e4 | 0) * 6e4; )
|
|
121
|
+
X = new G(new Date(W.at + n)), X.offset === W.offset ? W = X : a = X;
|
|
122
|
+
return W;
|
|
123
123
|
}
|
|
124
124
|
function F() {
|
|
125
|
-
var
|
|
126
|
-
for (
|
|
127
|
-
t = new Date(
|
|
128
|
-
for (
|
|
129
|
-
n.push(new G(new Date(
|
|
125
|
+
var W = (/* @__PURE__ */ new Date()).getFullYear() - 2, a = new G(new Date(W, 0, 1)), X = a.offset, n = [a], i, S, t, B;
|
|
126
|
+
for (B = 1; B < 48; B++)
|
|
127
|
+
t = new Date(W, B, 1).getTimezoneOffset(), t !== X && (S = new G(new Date(W, B, 1)), i = Q(a, S), n.push(i), n.push(new G(new Date(i.at + 6e4))), a = S, X = t);
|
|
128
|
+
for (B = 0; B < 4; B++)
|
|
129
|
+
n.push(new G(new Date(W + B, 0, 1))), n.push(new G(new Date(W + B, 6, 1)));
|
|
130
130
|
return n;
|
|
131
131
|
}
|
|
132
|
-
function M0(
|
|
133
|
-
return
|
|
132
|
+
function M0(W, a) {
|
|
133
|
+
return W.offsetScore !== a.offsetScore ? W.offsetScore - a.offsetScore : W.abbrScore !== a.abbrScore ? W.abbrScore - a.abbrScore : W.zone.population !== a.zone.population ? a.zone.population - W.zone.population : a.zone.name.localeCompare(W.zone.name);
|
|
134
134
|
}
|
|
135
|
-
function z0(
|
|
135
|
+
function z0(W, a) {
|
|
136
136
|
var X, n;
|
|
137
137
|
for (U(a), X = 0; X < a.length; X++)
|
|
138
|
-
n = a[X],
|
|
138
|
+
n = a[X], c[n] = c[n] || {}, c[n][W] = !0;
|
|
139
139
|
}
|
|
140
|
-
function b0(
|
|
141
|
-
var a =
|
|
140
|
+
function b0(W) {
|
|
141
|
+
var a = W.length, X = {}, n = [], i = {}, S, t, B, V;
|
|
142
142
|
for (S = 0; S < a; S++)
|
|
143
|
-
if (
|
|
144
|
-
V =
|
|
143
|
+
if (B = W[S].offset, !i.hasOwnProperty(B)) {
|
|
144
|
+
V = c[B] || {};
|
|
145
145
|
for (t in V)
|
|
146
146
|
V.hasOwnProperty(t) && (X[t] = !0);
|
|
147
|
-
|
|
147
|
+
i[B] = !0;
|
|
148
148
|
}
|
|
149
149
|
for (S in X)
|
|
150
150
|
X.hasOwnProperty(S) && n.push(b[S]);
|
|
@@ -152,130 +152,130 @@ var j = { exports: {} };
|
|
|
152
152
|
}
|
|
153
153
|
function p0() {
|
|
154
154
|
try {
|
|
155
|
-
var
|
|
156
|
-
if (
|
|
157
|
-
var a = b[K(
|
|
155
|
+
var W = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
156
|
+
if (W && W.length > 3) {
|
|
157
|
+
var a = b[K(W)];
|
|
158
158
|
if (a)
|
|
159
159
|
return a;
|
|
160
|
-
D("Moment Timezone found " +
|
|
160
|
+
D("Moment Timezone found " + W + " from the Intl api, but did not have that data loaded.");
|
|
161
161
|
}
|
|
162
162
|
} catch {
|
|
163
163
|
}
|
|
164
|
-
var X = F(), n = X.length,
|
|
165
|
-
for (
|
|
166
|
-
for (t = new H(g(
|
|
164
|
+
var X = F(), n = X.length, i = b0(X), S = [], t, B, V;
|
|
165
|
+
for (B = 0; B < i.length; B++) {
|
|
166
|
+
for (t = new H(g(i[B])), V = 0; V < n; V++)
|
|
167
167
|
t.scoreOffsetAt(X[V]);
|
|
168
168
|
S.push(t);
|
|
169
169
|
}
|
|
170
170
|
return S.sort(M0), S.length > 0 ? S[0].zone.name : void 0;
|
|
171
171
|
}
|
|
172
|
-
function O0(
|
|
173
|
-
return (!o ||
|
|
172
|
+
function O0(W) {
|
|
173
|
+
return (!o || W) && (o = p0()), o;
|
|
174
174
|
}
|
|
175
|
-
function K(
|
|
176
|
-
return (
|
|
175
|
+
function K(W) {
|
|
176
|
+
return (W || "").toLowerCase().replace(/\//g, "_");
|
|
177
177
|
}
|
|
178
|
-
function k(
|
|
179
|
-
var a, X, n,
|
|
180
|
-
for (typeof
|
|
181
|
-
n =
|
|
178
|
+
function k(W) {
|
|
179
|
+
var a, X, n, i;
|
|
180
|
+
for (typeof W == "string" && (W = [W]), a = 0; a < W.length; a++)
|
|
181
|
+
n = W[a].split("|"), X = n[0], i = K(X), p[i] = W[a], b[i] = X, z0(i, n[2].split(" "));
|
|
182
182
|
}
|
|
183
|
-
function g(
|
|
184
|
-
|
|
185
|
-
var X = p[
|
|
186
|
-
return X instanceof I ? X : typeof X == "string" ? (X = new I(X), p[
|
|
183
|
+
function g(W, a) {
|
|
184
|
+
W = K(W);
|
|
185
|
+
var X = p[W], n;
|
|
186
|
+
return X instanceof I ? X : typeof X == "string" ? (X = new I(X), p[W] = X, X) : O[W] && a !== g && (n = g(O[W], g)) ? (X = p[W] = new I(), X._set(n), X.name = b[W], X) : null;
|
|
187
187
|
}
|
|
188
188
|
function A0() {
|
|
189
|
-
var
|
|
190
|
-
for (
|
|
191
|
-
b.hasOwnProperty(
|
|
189
|
+
var W, a = [];
|
|
190
|
+
for (W in b)
|
|
191
|
+
b.hasOwnProperty(W) && (p[W] || p[O[W]]) && b[W] && a.push(b[W]);
|
|
192
192
|
return a.sort();
|
|
193
193
|
}
|
|
194
194
|
function c0() {
|
|
195
195
|
return Object.keys(A);
|
|
196
196
|
}
|
|
197
|
-
function v(
|
|
198
|
-
var a, X, n,
|
|
199
|
-
for (typeof
|
|
200
|
-
X =
|
|
197
|
+
function v(W) {
|
|
198
|
+
var a, X, n, i;
|
|
199
|
+
for (typeof W == "string" && (W = [W]), a = 0; a < W.length; a++)
|
|
200
|
+
X = W[a].split("|"), n = K(X[0]), i = K(X[1]), O[n] = i, b[n] = X[0], O[i] = n, b[i] = X[1];
|
|
201
201
|
}
|
|
202
|
-
function W0(
|
|
203
|
-
var a, X, n,
|
|
204
|
-
if (!(!
|
|
205
|
-
for (a = 0; a <
|
|
206
|
-
|
|
202
|
+
function W0(W) {
|
|
203
|
+
var a, X, n, i;
|
|
204
|
+
if (!(!W || !W.length))
|
|
205
|
+
for (a = 0; a < W.length; a++)
|
|
206
|
+
i = W[a].split("|"), X = i[0].toUpperCase(), n = i[1].split(" "), A[X] = new f(
|
|
207
207
|
X,
|
|
208
208
|
n
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
|
-
function o0(
|
|
212
|
-
return
|
|
211
|
+
function o0(W) {
|
|
212
|
+
return W = W.toUpperCase(), A[W] || null;
|
|
213
213
|
}
|
|
214
|
-
function q0(
|
|
215
|
-
if (
|
|
214
|
+
function q0(W, a) {
|
|
215
|
+
if (W = o0(W), !W)
|
|
216
216
|
return null;
|
|
217
|
-
var X =
|
|
217
|
+
var X = W.zones.sort();
|
|
218
218
|
return a ? X.map(function(n) {
|
|
219
|
-
var
|
|
219
|
+
var i = g(n);
|
|
220
220
|
return {
|
|
221
221
|
name: n,
|
|
222
|
-
offset:
|
|
222
|
+
offset: i.utcOffset(/* @__PURE__ */ new Date())
|
|
223
223
|
};
|
|
224
224
|
}) : X;
|
|
225
225
|
}
|
|
226
|
-
function Y0(
|
|
227
|
-
k(
|
|
226
|
+
function Y0(W) {
|
|
227
|
+
k(W.zones), v(W.links), W0(W.countries), u.dataVersion = W.version;
|
|
228
228
|
}
|
|
229
|
-
function $(
|
|
230
|
-
return $.didShowError || ($.didShowError = !0, D("moment.tz.zoneExists('" +
|
|
229
|
+
function $(W) {
|
|
230
|
+
return $.didShowError || ($.didShowError = !0, D("moment.tz.zoneExists('" + W + "') has been deprecated in favor of !moment.tz.zone('" + W + "')")), !!g(W);
|
|
231
231
|
}
|
|
232
|
-
function J(
|
|
233
|
-
var a =
|
|
234
|
-
return !!(
|
|
232
|
+
function J(W) {
|
|
233
|
+
var a = W._f === "X" || W._f === "x";
|
|
234
|
+
return !!(W._a && W._tzm === void 0 && !a);
|
|
235
235
|
}
|
|
236
|
-
function D(
|
|
237
|
-
typeof console < "u" && typeof console.error == "function" && console.error(
|
|
236
|
+
function D(W) {
|
|
237
|
+
typeof console < "u" && typeof console.error == "function" && console.error(W);
|
|
238
238
|
}
|
|
239
|
-
function u(
|
|
240
|
-
var a = Array.prototype.slice.call(arguments, 0, -1), X = arguments[arguments.length - 1], n = M.utc.apply(null, a),
|
|
241
|
-
return !M.isMoment(
|
|
239
|
+
function u(W) {
|
|
240
|
+
var a = Array.prototype.slice.call(arguments, 0, -1), X = arguments[arguments.length - 1], n = M.utc.apply(null, a), i;
|
|
241
|
+
return !M.isMoment(W) && J(n) && (i = g(X)) && n.add(i.parse(n), "minutes"), n.tz(X), n;
|
|
242
242
|
}
|
|
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 = I, u.unpack = P, u.unpackBase60 =
|
|
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 = I, u.unpack = P, u.unpackBase60 = T, u.needsOffset = J, u.moveInvalidForward = !0, u.moveAmbiguousForward = !1, u.countries = c0, u.zonesForCountry = q0;
|
|
244
244
|
var m = M.fn;
|
|
245
|
-
M.tz = u, M.defaultZone = null, M.updateOffset = function(
|
|
245
|
+
M.tz = u, M.defaultZone = null, M.updateOffset = function(W, a) {
|
|
246
246
|
var X = M.defaultZone, n;
|
|
247
|
-
if (
|
|
248
|
-
if (n =
|
|
249
|
-
var
|
|
250
|
-
|
|
247
|
+
if (W._z === void 0 && (X && J(W) && !W._isUTC && W.isValid() && (W._d = M.utc(W._a)._d, W.utc().add(X.parse(W), "minutes")), W._z = X), W._z)
|
|
248
|
+
if (n = W._z.utcOffset(W), Math.abs(n) < 16 && (n = n / 60), W.utcOffset !== void 0) {
|
|
249
|
+
var i = W._z;
|
|
250
|
+
W.utcOffset(-n, a), W._z = i;
|
|
251
251
|
} else
|
|
252
|
-
|
|
253
|
-
}, m.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
|
+
W.zone(n, a);
|
|
253
|
+
}, m.tz = function(W, a) {
|
|
254
|
+
if (W) {
|
|
255
|
+
if (typeof W != "string")
|
|
256
|
+
throw new Error("Time zone name must be a string, got " + W + " [" + typeof W + "]");
|
|
257
|
+
return this._z = g(W), this._z ? M.updateOffset(this, a) : D("Moment Timezone has no data for " + W + ". 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 y(
|
|
262
|
+
function y(W) {
|
|
263
263
|
return function() {
|
|
264
|
-
return this._z ? this._z.abbr(this) :
|
|
264
|
+
return this._z ? this._z.abbr(this) : W.call(this);
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
|
-
function w(
|
|
267
|
+
function w(W) {
|
|
268
268
|
return function() {
|
|
269
|
-
return this._z = null,
|
|
269
|
+
return this._z = null, W.apply(this, arguments);
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
|
-
function d0(
|
|
272
|
+
function d0(W) {
|
|
273
273
|
return function() {
|
|
274
|
-
return arguments.length > 0 && (this._z = null),
|
|
274
|
+
return arguments.length > 0 && (this._z = null), W.apply(this, arguments);
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
|
-
m.zoneName = y(m.zoneName), m.zoneAbbr = y(m.zoneAbbr), m.utc = w(m.utc), m.local = w(m.local), m.utcOffset = d0(m.utcOffset), M.tz.setDefault = function(
|
|
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 =
|
|
277
|
+
m.zoneName = y(m.zoneName), m.zoneAbbr = y(m.zoneAbbr), m.utc = w(m.utc), m.local = w(m.local), m.utcOffset = d0(m.utcOffset), M.tz.setDefault = function(W) {
|
|
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 = W ? g(W) : null, M;
|
|
279
279
|
};
|
|
280
280
|
var h = M.momentProperties;
|
|
281
281
|
return Object.prototype.toString.call(h) === "[object Array]" ? (h.push("_z"), h.push("_a")) : h && (h._z = null), M;
|
|
@@ -1144,9 +1144,9 @@ var x = { exports: {} };
|
|
|
1144
1144
|
throw new RangeError("invalid coordinates");
|
|
1145
1145
|
if (90 <= z)
|
|
1146
1146
|
return "Etc/GMT";
|
|
1147
|
-
var b = -1,
|
|
1147
|
+
var b = -1, c = 48 * (180 + p) / 360.00000000000006, o = 24 * (90 - z) / 180.00000000000003, q = 0 | c, d = 0 | o, Y = 96 * d + 2 * q;
|
|
1148
1148
|
for (Y = 56 * O.charCodeAt(Y) + O.charCodeAt(Y + 1) - 1995; Y + A.length < 3136; )
|
|
1149
|
-
Y = 56 * O.charCodeAt(Y = 8 * (b = b + Y + 1) + 4 * (d = 0 | (o = 2 * (o - d) % 2)) + 2 * (q = 0 | (
|
|
1149
|
+
Y = 56 * O.charCodeAt(Y = 8 * (b = b + Y + 1) + 4 * (d = 0 | (o = 2 * (o - d) % 2)) + 2 * (q = 0 | (c = 2 * (c - q) % 2)) + 2304) + O.charCodeAt(Y + 1) - 1995;
|
|
1150
1150
|
return A[Y + A.length - 3136];
|
|
1151
1151
|
}
|
|
1152
1152
|
E.exports = M;
|
|
@@ -1176,9 +1176,9 @@ class R {
|
|
|
1176
1176
|
z = z < 6 ? 6 : z, M = R.convertToStdLng(M, z);
|
|
1177
1177
|
let O = "E";
|
|
1178
1178
|
M < 0 && (O = "W"), M = Math.abs(M), p = p.toUpperCase();
|
|
1179
|
-
let A = M * 3600, b,
|
|
1180
|
-
b = A % 3600 % 60, p.indexOf("S") !== -1 && (A = A - b,
|
|
1181
|
-
const L = `${p.replace(/S+/gi,
|
|
1179
|
+
let A = M * 3600, b, c, o, q, d, Y;
|
|
1180
|
+
b = A % 3600 % 60, p.indexOf("S") !== -1 && (A = A - b, c = R.padNumber(b, 2, 2)), o = A / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ? q = R.roundPrecision(o, z).toString().padStart(2, "0") : q = R.padNumber(o, 2, 2), A = A - o * 60), d = A / 3600, p.indexOf("M") !== -1 ? Y = R.roundPrecision(d, z).toString().padStart(3, "0") : Y = R.padNumber(d, 3, 2), Number(c) >= 60 && (q = Number(q) + 1, c = 0), Number(q) >= 60 && (Y = Number(Y) + 1, q = 0);
|
|
1181
|
+
const L = `${p.replace(/S+/gi, c).replace(/M+/gi, q).replace(/H+/gi, Y)}${O}`;
|
|
1182
1182
|
return {
|
|
1183
1183
|
direction: O,
|
|
1184
1184
|
degree: R.roundPrecision(d, z),
|
|
@@ -1197,9 +1197,9 @@ class R {
|
|
|
1197
1197
|
z = z < 6 ? 6 : z, M = M % 180;
|
|
1198
1198
|
let O = "N";
|
|
1199
1199
|
M < 0 && (O = "S"), M = Math.abs(M), p = p.toUpperCase();
|
|
1200
|
-
let A = M * 3600, b,
|
|
1201
|
-
b = A % 3600 % 60, p.indexOf("S") !== -1 && (A = A - b,
|
|
1202
|
-
const L = `${p.replace(/S+/gi,
|
|
1200
|
+
let A = M * 3600, b, c, o, q, d, Y;
|
|
1201
|
+
b = A % 3600 % 60, p.indexOf("S") !== -1 && (A = A - b, c = R.padNumber(b, 2, 2)), o = A / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ? q = R.roundPrecision(o, z).toString().padStart(2, "0") : q = R.padNumber(o, 2, 2), A = A - o * 60), d = A / 3600, p.indexOf("M") !== -1 ? Y = R.roundPrecision(d, z).toString().padStart(2, "0") : Y = R.padNumber(d, 2, 2), Number(c) >= 60 && (q = Number(q) + 1, c = 0), Number(q) >= 60 && (Y = Number(Y) + 1, q = 0);
|
|
1202
|
+
const L = `${p.replace(/S+/gi, c).replace(/M+/gi, q).replace(/H+/gi, Y)}${O}`;
|
|
1203
1203
|
return {
|
|
1204
1204
|
direction: O,
|
|
1205
1205
|
degree: R.roundPrecision(d, z),
|
|
@@ -1215,12 +1215,12 @@ class R {
|
|
|
1215
1215
|
const O = M[M.length - 1].toUpperCase();
|
|
1216
1216
|
M = M.substring(0, M.length - 1).trim();
|
|
1217
1217
|
const A = M.split(" ").filter((o) => o !== "").map((o) => Math.abs(Number(o)));
|
|
1218
|
-
let [b,
|
|
1219
|
-
if (
|
|
1218
|
+
let [b, c] = A;
|
|
1219
|
+
if (c = c > 60 ? c / Math.pow(10, String(c).length - 2) : c, b > 360 && !c) {
|
|
1220
1220
|
const o = this.roundPrecision(b / 100, 0);
|
|
1221
|
-
|
|
1221
|
+
c = b - o * 100, b = o;
|
|
1222
1222
|
}
|
|
1223
|
-
p = b + (
|
|
1223
|
+
p = b + (c ?? 0) / 60, O === "W" && (p = p * -1);
|
|
1224
1224
|
} else
|
|
1225
1225
|
p = Number(M);
|
|
1226
1226
|
return R.convertToStdLng(p, z);
|
|
@@ -1232,12 +1232,12 @@ class R {
|
|
|
1232
1232
|
const O = M[M.length - 1].toUpperCase();
|
|
1233
1233
|
M = M.substring(0, M.length - 1).trim();
|
|
1234
1234
|
const A = M.split(" ").filter((o) => o !== "").map((o) => Math.abs(Number(o)));
|
|
1235
|
-
let [b,
|
|
1236
|
-
if (
|
|
1235
|
+
let [b, c] = A;
|
|
1236
|
+
if (c = c > 60 ? c / Math.pow(10, String(c).length - 2) : c, b > 90 && !c) {
|
|
1237
1237
|
const o = this.roundPrecision(b / 100, 0);
|
|
1238
|
-
|
|
1238
|
+
c = b - o * 100, b = o;
|
|
1239
1239
|
}
|
|
1240
|
-
if (p = b + (
|
|
1240
|
+
if (p = b + (c ?? 0) / 60, p > 90)
|
|
1241
1241
|
throw new Error(`latitude out of range: ${M}${O}`);
|
|
1242
1242
|
O === "S" && (p = p * -1);
|
|
1243
1243
|
} else
|
|
@@ -1342,8 +1342,8 @@ class N {
|
|
|
1342
1342
|
[M.lng, M.lat],
|
|
1343
1343
|
[z.lng, z.lat]
|
|
1344
1344
|
]);
|
|
1345
|
-
let
|
|
1346
|
-
return p ?
|
|
1345
|
+
let c;
|
|
1346
|
+
return p ? c = e.rhumbDistance(b.features[0], b.features[1], { units: A }) : c = e.distance(b.features[0], b.features[1], { units: A }), R.roundPrecision(c, O);
|
|
1347
1347
|
}
|
|
1348
1348
|
/**
|
|
1349
1349
|
* 计算航线距离
|
|
@@ -1354,10 +1354,10 @@ class N {
|
|
|
1354
1354
|
static calculateRouteDistance(M, z = 4, p = "nauticalmiles") {
|
|
1355
1355
|
let O = 0, A;
|
|
1356
1356
|
for (const b of M)
|
|
1357
|
-
for (let
|
|
1358
|
-
const o = { lng: b[
|
|
1359
|
-
|
|
1360
|
-
const q = { lng: b[
|
|
1357
|
+
for (let c = 0; c < b.length - 1; c++) {
|
|
1358
|
+
const o = { lng: b[c][0], lat: b[c][1] };
|
|
1359
|
+
c === 0 && A && (O += this.calculateDistance(A, o, !0, z, p));
|
|
1360
|
+
const q = { lng: b[c + 1][0], lat: b[c + 1][1] };
|
|
1361
1361
|
O += this.calculateDistance(o, q, !0, z, p), A = q;
|
|
1362
1362
|
}
|
|
1363
1363
|
return R.roundPrecision(O, z);
|
|
@@ -1372,9 +1372,9 @@ class N {
|
|
|
1372
1372
|
*/
|
|
1373
1373
|
static calculateCoordinate(M, z, p, O = "nauticalmiles", A = !0) {
|
|
1374
1374
|
const b = e.point([M.lng, M.lat]);
|
|
1375
|
-
let
|
|
1376
|
-
A ?
|
|
1377
|
-
const o =
|
|
1375
|
+
let c;
|
|
1376
|
+
A ? c = e.rhumbDestination(b, p, z, { units: O }) : c = e.destination(b, p, z, { units: O });
|
|
1377
|
+
const o = c.geometry.coordinates;
|
|
1378
1378
|
return { lng: R.convertToStdLng(o[0], 8), lat: R.roundPrecision(o[1], 8) };
|
|
1379
1379
|
}
|
|
1380
1380
|
/**
|
|
@@ -1387,12 +1387,12 @@ class N {
|
|
|
1387
1387
|
* @param units 单位,默认 nm(海里)
|
|
1388
1388
|
*/
|
|
1389
1389
|
static interpolateCoordinates(M, z, p, O = !0, A = !0, b = "nauticalmiles") {
|
|
1390
|
-
const
|
|
1391
|
-
O &&
|
|
1390
|
+
const c = [], o = this.calculateBearing(M, z, !1), q = this.calculateDistance(M, z, !1, 8, b);
|
|
1391
|
+
O && c.push({ lng: M.lng, lat: M.lat });
|
|
1392
1392
|
let d = 0;
|
|
1393
1393
|
for (; d < q; )
|
|
1394
|
-
d += p, d < q &&
|
|
1395
|
-
return A &&
|
|
1394
|
+
d += p, d < q && c.push(this.calculateCoordinate(M, o, d, b, !1));
|
|
1395
|
+
return A && c.push({ lng: z.lng, lat: z.lat }), c;
|
|
1396
1396
|
}
|
|
1397
1397
|
/**
|
|
1398
1398
|
* 分组坐标(如相邻两个坐标经度差超180度,需以180为界将坐标分为两组)
|
|
@@ -1412,13 +1412,13 @@ class N {
|
|
|
1412
1412
|
let p = [];
|
|
1413
1413
|
const O = [];
|
|
1414
1414
|
let A, b;
|
|
1415
|
-
for (let
|
|
1416
|
-
A = R.convertToStdLng(M[
|
|
1415
|
+
for (let c = 0; c < M.length - 1; c++) {
|
|
1416
|
+
A = R.convertToStdLng(M[c].lng, 8), b = R.convertToStdLng(M[c + 1].lng, 8), M[c].lat = R.roundPrecision(M[c].lat, 8), M[c + 1].lat = R.roundPrecision(M[c + 1].lat, 8), p.push([A, M[c].lat]);
|
|
1417
1417
|
const o = A - b;
|
|
1418
1418
|
if (Math.abs(o) > 180) {
|
|
1419
1419
|
const q = R.convertToMonotonicLng2([
|
|
1420
|
-
[A, M[
|
|
1421
|
-
[b, M[
|
|
1420
|
+
[A, M[c].lat],
|
|
1421
|
+
[b, M[c + 1].lat]
|
|
1422
1422
|
]);
|
|
1423
1423
|
let d, Y;
|
|
1424
1424
|
z ? (d = e.lineString(q), Y = e.lineString([
|
|
@@ -1426,15 +1426,15 @@ class N {
|
|
|
1426
1426
|
[o > 0 ? 180 : -180, -89]
|
|
1427
1427
|
])) : (d = e.greatCircle(q[0], q[1]), Y = e.greatCircle([o > 0 ? 180 : -180, 89], [o > 0 ? 180 : -180, -89]));
|
|
1428
1428
|
const L = e.lineIntersect(d, Y);
|
|
1429
|
-
let
|
|
1429
|
+
let T;
|
|
1430
1430
|
if (L.features.length) {
|
|
1431
1431
|
const U = e.getCoord(L.features[0]);
|
|
1432
|
-
|
|
1432
|
+
T = R.roundPrecision(U[1], 8);
|
|
1433
1433
|
} else
|
|
1434
|
-
|
|
1435
|
-
o > 0 ? (p.push([180 - 1e-6,
|
|
1434
|
+
T = M[c].lat;
|
|
1435
|
+
o > 0 ? (p.push([180 - 1e-6, T]), O.push([...p]), p = [], p.push([-(180 - 1e-6), T])) : (p.push([-(180 - 1e-6), T]), O.push([...p]), p = [], p.push([180 - 1e-6, T]));
|
|
1436
1436
|
}
|
|
1437
|
-
|
|
1437
|
+
c === M.length - 2 && p.push([b, M[c + 1].lat]);
|
|
1438
1438
|
}
|
|
1439
1439
|
return O.push(p), O;
|
|
1440
1440
|
}
|
|
@@ -1445,7 +1445,7 @@ class N {
|
|
|
1445
1445
|
static deduplicateRoute(M) {
|
|
1446
1446
|
const z = [];
|
|
1447
1447
|
for (const p of M) {
|
|
1448
|
-
const O = p.reduce((A, b) => (A.findIndex((
|
|
1448
|
+
const O = p.reduce((A, b) => (A.findIndex((c) => c[0] === b[0] && c[1] === b[1]) === -1 && A.push(b), A), []);
|
|
1449
1449
|
z.push(O);
|
|
1450
1450
|
}
|
|
1451
1451
|
return z;
|
|
@@ -1493,13 +1493,13 @@ class N {
|
|
|
1493
1493
|
*/
|
|
1494
1494
|
static mergeCoordinateToRoute(M, z) {
|
|
1495
1495
|
M.lng = R.convertToStdLng(M.lng, 8);
|
|
1496
|
-
let p = Number.MAX_VALUE, O = 0, A = 0, b,
|
|
1496
|
+
let p = Number.MAX_VALUE, O = 0, A = 0, b, c;
|
|
1497
1497
|
return z.forEach((o, q) => {
|
|
1498
1498
|
for (let d = 0; d < o.length - 1; d++) {
|
|
1499
|
-
const Y = { lng: o[d][0], lat: o[d][1] }, L = { lng: o[d + 1][0], lat: o[d + 1][1] },
|
|
1500
|
-
p >
|
|
1499
|
+
const Y = { lng: o[d][0], lat: o[d][1] }, L = { lng: o[d + 1][0], lat: o[d + 1][1] }, T = this.calculatePointToLineDistance(M, Y, L);
|
|
1500
|
+
p > T && (p = T, A = d, O = q, b = this.calculateDistance(Y, M), c = this.calculateDistance(L, M));
|
|
1501
1501
|
}
|
|
1502
|
-
}), b !== 0 &&
|
|
1502
|
+
}), b !== 0 && c !== 0 ? z[O].splice(A + 1, 0, [M.lng, M.lat]) : b === 0 ? z[O].splice(A, 1, [M.lng, M.lat]) : c === 0 && z[O].splice(A + 1, 1, [M.lng, M.lat]), z;
|
|
1503
1503
|
}
|
|
1504
1504
|
/**
|
|
1505
1505
|
* 向Route尾加1个坐标
|
|
@@ -1544,15 +1544,15 @@ class N {
|
|
|
1544
1544
|
return p.forEach((b) => {
|
|
1545
1545
|
if (A === 2)
|
|
1546
1546
|
return;
|
|
1547
|
-
const
|
|
1547
|
+
const c = [];
|
|
1548
1548
|
for (const o of b) {
|
|
1549
1549
|
if (R.roundPrecision(z.lng, 8) === R.roundPrecision(o[0], 8) && R.roundPrecision(z.lat, 8) === R.roundPrecision(o[1], 8)) {
|
|
1550
|
-
|
|
1550
|
+
c.push(o), A === 0 && c.push([M.lng, M.lat]), A = 2;
|
|
1551
1551
|
break;
|
|
1552
1552
|
}
|
|
1553
|
-
A === 1 ?
|
|
1553
|
+
A === 1 ? c.push(o) : R.roundPrecision(M.lng, 8) === R.roundPrecision(o[0], 8) && R.roundPrecision(M.lat, 8) === R.roundPrecision(o[1], 8) && (A = 1, c.push(o));
|
|
1554
1554
|
}
|
|
1555
|
-
|
|
1555
|
+
c.length && O.push(c);
|
|
1556
1556
|
}), O;
|
|
1557
1557
|
}
|
|
1558
1558
|
/**
|
|
@@ -1564,12 +1564,12 @@ class N {
|
|
|
1564
1564
|
* @return [{lng, lat}]
|
|
1565
1565
|
*/
|
|
1566
1566
|
static calculateRangeWaypoints(M, z, p, O = []) {
|
|
1567
|
-
const A = this.convertRouteToCoordinates(p, 0), b = this.mergeCoordinatesToWaypoints([M, z], A.length ? A : O),
|
|
1567
|
+
const A = this.convertRouteToCoordinates(p, 0), b = this.mergeCoordinatesToWaypoints([M, z], A.length ? A : O), c = b.findIndex(
|
|
1568
1568
|
(d) => R.roundPrecision(M.lng, 8) === R.roundPrecision(d.lng, 8) && R.roundPrecision(M.lat, 8) === R.roundPrecision(d.lat, 8)
|
|
1569
1569
|
), o = b.findIndex(
|
|
1570
1570
|
(d) => R.roundPrecision(z.lng, 8) === R.roundPrecision(d.lng, 8) && R.roundPrecision(z.lat, 8) === R.roundPrecision(d.lat, 8)
|
|
1571
1571
|
);
|
|
1572
|
-
return b.filter((d, Y) => Y >=
|
|
1572
|
+
return b.filter((d, Y) => Y >= c && Y <= o);
|
|
1573
1573
|
}
|
|
1574
1574
|
/**
|
|
1575
1575
|
* 计算坐标到航路上的最短距离
|
|
@@ -1578,10 +1578,10 @@ class N {
|
|
|
1578
1578
|
*/
|
|
1579
1579
|
static calculateMinDistanceToRoute(M, z) {
|
|
1580
1580
|
let p = Number.MAX_VALUE, O = 0, A = 0;
|
|
1581
|
-
return z.forEach((b,
|
|
1581
|
+
return z.forEach((b, c) => {
|
|
1582
1582
|
for (let o = 0; o < b.length - 1; o++) {
|
|
1583
1583
|
const q = { lng: b[o][0], lat: b[o][1] }, d = { lng: b[o + 1][0], lat: b[o + 1][1] }, Y = this.calculatePointToLineDistance(M, q, d);
|
|
1584
|
-
p > Y && (p = Y, O = o, A =
|
|
1584
|
+
p > Y && (p = Y, O = o, A = c);
|
|
1585
1585
|
}
|
|
1586
1586
|
}), { minDist: p, segIndex: A, minIndex: O };
|
|
1587
1587
|
}
|
|
@@ -1597,14 +1597,14 @@ class N {
|
|
|
1597
1597
|
const { segIndex: O, minIndex: A } = this.calculateMinDistanceToRoute({ ...M }, z);
|
|
1598
1598
|
M.lng = R.convertToStdLng(M.lng);
|
|
1599
1599
|
const b = [];
|
|
1600
|
-
let
|
|
1600
|
+
let c = !0;
|
|
1601
1601
|
for (let o = O; o < z.length; o++)
|
|
1602
|
-
if (
|
|
1602
|
+
if (c) {
|
|
1603
1603
|
const q = [];
|
|
1604
1604
|
q.push([M.lng, M.lat]);
|
|
1605
1605
|
for (let d = A + 1; d < z[o].length; d++)
|
|
1606
1606
|
M.lng === z[o][d][0] && M.lat === z[o][d][1] || q.push(z[o][d]);
|
|
1607
|
-
b.push(q),
|
|
1607
|
+
b.push(q), c = !1;
|
|
1608
1608
|
} else
|
|
1609
1609
|
b.push([...z[o]]);
|
|
1610
1610
|
return b;
|
|
@@ -1618,12 +1618,12 @@ class N {
|
|
|
1618
1618
|
static calculateSubWaypoints(M, z) {
|
|
1619
1619
|
let p = Number.MAX_VALUE, O = 0;
|
|
1620
1620
|
for (let b = 0; b < z.length - 1; b++) {
|
|
1621
|
-
const
|
|
1622
|
-
if (this.calculateDistance(M,
|
|
1621
|
+
const c = z[b], o = z[b + 1];
|
|
1622
|
+
if (this.calculateDistance(M, c) === 0)
|
|
1623
1623
|
return z;
|
|
1624
1624
|
if (this.calculateDistance(M, o) === 0)
|
|
1625
1625
|
return z.filter((d, Y) => Y > 0);
|
|
1626
|
-
const q = this.calculatePointToLineDistance(M,
|
|
1626
|
+
const q = this.calculatePointToLineDistance(M, c, o);
|
|
1627
1627
|
p > q && (p = q, O = b);
|
|
1628
1628
|
}
|
|
1629
1629
|
M.lng = R.convertToStdLng(M.lng);
|
|
@@ -1646,8 +1646,8 @@ class N {
|
|
|
1646
1646
|
const b = e.lineString([
|
|
1647
1647
|
[z.lng, z.lat],
|
|
1648
1648
|
[p.lng, p.lat]
|
|
1649
|
-
]),
|
|
1650
|
-
return R.roundPrecision(Math.min(
|
|
1649
|
+
]), c = e.pointToLineDistance(e.point([M.lng, M.lat]), b, O), o = e.pointToLineDistance(e.point([M.lng > 0 ? M.lng - 360 : M.lng + 360, M.lat]), b, O);
|
|
1650
|
+
return R.roundPrecision(Math.min(c, o), 6);
|
|
1651
1651
|
}
|
|
1652
1652
|
/**
|
|
1653
1653
|
* 计算途经点的COG, Distance等属性
|
|
@@ -1686,15 +1686,15 @@ class N {
|
|
|
1686
1686
|
*/
|
|
1687
1687
|
static mergeCoordinateToWaypoints(M, z, p = !0) {
|
|
1688
1688
|
M.lng = R.convertToStdLng(M.lng, 8);
|
|
1689
|
-
let O = Number.MAX_VALUE, A = 0, b = 0,
|
|
1689
|
+
let O = Number.MAX_VALUE, A = 0, b = 0, c = 0;
|
|
1690
1690
|
if (z.length < 2)
|
|
1691
1691
|
z.push(M);
|
|
1692
1692
|
else {
|
|
1693
1693
|
for (let o = 0; o < z.length - 1; o++) {
|
|
1694
1694
|
const q = { lng: z[o].lng, lat: z[o].lat }, d = { lng: z[o + 1].lng, lat: z[o + 1].lat }, Y = this.calculatePointToLineDistance(M, q, d);
|
|
1695
|
-
O >= Y && (O = Y, A = o, b = this.calculateDistance(q, M, !1, 6),
|
|
1695
|
+
O >= Y && (O = Y, A = o, b = this.calculateDistance(q, M, !1, 6), c = this.calculateDistance(d, M, !1, 6));
|
|
1696
1696
|
}
|
|
1697
|
-
b !== 0 &&
|
|
1697
|
+
b !== 0 && c !== 0 ? b < O || b === O && A === 0 ? z.unshift(M) : c < O || c === O && A === z.length - 2 ? z.push(M) : z.splice(A + 1, 0, M) : b === 0 ? p ? z.splice(A, 1, M) : z.splice(A + 1, 0, M) : c === 0 && (p ? z.splice(A + 1, 1, M) : z.splice(A + 1, 0, M));
|
|
1698
1698
|
}
|
|
1699
1699
|
return z.map((o) => (o.lng = R.convertToStdLng(o.lng), o));
|
|
1700
1700
|
}
|
|
@@ -1721,7 +1721,7 @@ class N {
|
|
|
1721
1721
|
* @param route [[[lng, lat]]]
|
|
1722
1722
|
*/
|
|
1723
1723
|
static nearestCoordinateInRoute(M, z) {
|
|
1724
|
-
const p = e.point([M.lng, M.lat]), A = this.convertRouteToCoordinates(z).map((q) => [q.lng, q.lat]), b = e.lineString(A),
|
|
1724
|
+
const p = e.point([M.lng, M.lat]), A = this.convertRouteToCoordinates(z).map((q) => [q.lng, q.lat]), b = e.lineString(A), c = e.nearestPointOnLine(b, p), o = e.getCoord(c);
|
|
1725
1725
|
return { lng: R.roundPrecision(o[0], 8), lat: R.roundPrecision(o[1], 8) };
|
|
1726
1726
|
}
|
|
1727
1727
|
/**
|
|
@@ -1756,40 +1756,40 @@ class N {
|
|
|
1756
1756
|
static calculateNextCoordinateAlongRoute(M, z, p, O = "nauticalmiles") {
|
|
1757
1757
|
var L;
|
|
1758
1758
|
const A = M.speed || 12, b = [];
|
|
1759
|
-
let
|
|
1760
|
-
if (z && p.length ? (b.push(M), p.forEach((
|
|
1759
|
+
let c = [], o = !1, q = 0, d = 0, Y;
|
|
1760
|
+
if (z && p.length ? (b.push(M), p.forEach((T, U) => {
|
|
1761
1761
|
if (o)
|
|
1762
|
-
|
|
1762
|
+
c.push(T);
|
|
1763
1763
|
else {
|
|
1764
|
-
const
|
|
1764
|
+
const r = [];
|
|
1765
1765
|
let s;
|
|
1766
|
-
for (let P = 0; P <
|
|
1766
|
+
for (let P = 0; P < T.length; P++)
|
|
1767
1767
|
if (Y)
|
|
1768
|
-
|
|
1768
|
+
r.push(T[P]);
|
|
1769
1769
|
else {
|
|
1770
|
-
s = { lng:
|
|
1770
|
+
s = { lng: T[P][0], lat: T[P][1] };
|
|
1771
1771
|
const I = this.calculateDistance(M, s, !0, 8, O);
|
|
1772
1772
|
if (q += I, q < z)
|
|
1773
1773
|
d += I, I && b.push(s), M = s;
|
|
1774
1774
|
else {
|
|
1775
1775
|
if (d = z, q === z)
|
|
1776
|
-
Y = s,
|
|
1776
|
+
Y = s, r.push([Y.lng, Y.lat]);
|
|
1777
1777
|
else {
|
|
1778
1778
|
const l = q - z, f = this.calculateBearing(s, M);
|
|
1779
|
-
Y = this.calculateCoordinate(s, f, l, O),
|
|
1779
|
+
Y = this.calculateCoordinate(s, f, l, O), r.push([Y.lng, Y.lat]), r.push([s.lng, s.lat]);
|
|
1780
1780
|
}
|
|
1781
1781
|
o = !0;
|
|
1782
1782
|
}
|
|
1783
1783
|
}
|
|
1784
|
-
|
|
1784
|
+
r.length && c.push(r), U === p.length - 1 && !Y && (Y = s);
|
|
1785
1785
|
}
|
|
1786
|
-
})) : (
|
|
1787
|
-
if (b.push(Y), Y.distanceFromPrevious = d, Y.hourFromPrevious = Math.round(d / A * 1e4) / 1e4, ((L =
|
|
1788
|
-
const
|
|
1789
|
-
Y.bearing = this.calculateBearing(Y,
|
|
1786
|
+
})) : (c = p, Y = { ...M }), Y)
|
|
1787
|
+
if (b.push(Y), Y.distanceFromPrevious = d, Y.hourFromPrevious = Math.round(d / A * 1e4) / 1e4, ((L = c[0]) == null ? void 0 : L.length) > 1) {
|
|
1788
|
+
const T = { lng: c[0][1][0], lat: c[0][1][1] };
|
|
1789
|
+
Y.bearing = this.calculateBearing(Y, T);
|
|
1790
1790
|
} else
|
|
1791
1791
|
Y.bearing = 0;
|
|
1792
|
-
return { coordinate: Y, nextRoute:
|
|
1792
|
+
return { coordinate: Y, nextRoute: c, prevRoute: b };
|
|
1793
1793
|
}
|
|
1794
1794
|
/**
|
|
1795
1795
|
* 返回最近点及其是否为垂足(最近点不是起点或终点)
|
|
@@ -1798,11 +1798,11 @@ class N {
|
|
|
1798
1798
|
* @param to {lng, lat}
|
|
1799
1799
|
*/
|
|
1800
1800
|
static nearestCoordinateInLine(M, z, p) {
|
|
1801
|
-
const O = R.convertToStdLng(M.lng, 6), A = e.point([O, M.lat]), b = R.convertToStdLng(z.lng, 6),
|
|
1801
|
+
const O = R.convertToStdLng(M.lng, 6), A = e.point([O, M.lat]), b = R.convertToStdLng(z.lng, 6), c = R.convertToStdLng(p.lng, 6), o = e.lineString([
|
|
1802
1802
|
[b, z.lat],
|
|
1803
|
-
[
|
|
1803
|
+
[c, p.lat]
|
|
1804
1804
|
]), q = e.nearestPointOnLine(o, A), d = e.getCoord(q), Y = R.roundPrecision(d[0], 6), L = R.roundPrecision(d[1], 6);
|
|
1805
|
-
return { lng: Y, lat: L, inline: !(Y === b && L === z.lat) && !(Y ===
|
|
1805
|
+
return { lng: Y, lat: L, inline: !(Y === b && L === z.lat) && !(Y === c && L === p.lat) };
|
|
1806
1806
|
}
|
|
1807
1807
|
/**
|
|
1808
1808
|
* 将route转coordinate
|
|
@@ -1813,8 +1813,8 @@ class N {
|
|
|
1813
1813
|
const p = [];
|
|
1814
1814
|
let O, A;
|
|
1815
1815
|
return M.forEach((b) => {
|
|
1816
|
-
b.forEach((
|
|
1817
|
-
const o = { lng: R.roundPrecision(
|
|
1816
|
+
b.forEach((c) => {
|
|
1817
|
+
const o = { lng: R.roundPrecision(c[0], 8), lat: R.roundPrecision(c[1], 8) };
|
|
1818
1818
|
if (!A)
|
|
1819
1819
|
p.push(o), A = o;
|
|
1820
1820
|
else if (A.bearing === void 0)
|
|
@@ -1849,8 +1849,8 @@ class N {
|
|
|
1849
1849
|
for (let O = 1; O < z.length; O++) {
|
|
1850
1850
|
const A = z[O - 1], b = z[O];
|
|
1851
1851
|
if (b.gcToPrevious) {
|
|
1852
|
-
const
|
|
1853
|
-
for (let q = o - 1; q >
|
|
1852
|
+
const c = M.findIndex((q) => q.lng === A.lng && q.lat === A.lat), o = M.findIndex((q) => q.lng === b.lng && q.lat === b.lat);
|
|
1853
|
+
for (let q = o - 1; q > c; q--)
|
|
1854
1854
|
M.splice(q, 1);
|
|
1855
1855
|
}
|
|
1856
1856
|
}
|
|
@@ -1867,12 +1867,12 @@ class N {
|
|
|
1867
1867
|
*/
|
|
1868
1868
|
static calculateCenter(M) {
|
|
1869
1869
|
const z = [];
|
|
1870
|
-
for (const
|
|
1871
|
-
for (const o of
|
|
1870
|
+
for (const c of M)
|
|
1871
|
+
for (const o of c)
|
|
1872
1872
|
z.push(o);
|
|
1873
1873
|
const p = e.featureCollection([]), O = R.convertToMonotonicLng2(z);
|
|
1874
|
-
for (const
|
|
1875
|
-
p.features.push(e.point(
|
|
1874
|
+
for (const c of O)
|
|
1875
|
+
p.features.push(e.point(c));
|
|
1876
1876
|
const b = e.center(p).geometry.coordinates;
|
|
1877
1877
|
return { lng: R.convertToStdLng(b[0], 8), lat: R.roundPrecision(b[1], 8) };
|
|
1878
1878
|
}
|
|
@@ -1913,11 +1913,11 @@ class N {
|
|
|
1913
1913
|
static simplifyCoordinates(M, z = 1, p = 180) {
|
|
1914
1914
|
const O = [];
|
|
1915
1915
|
for (let A = 1; A < M.length; A++) {
|
|
1916
|
-
const b = M[A - 1],
|
|
1916
|
+
const b = M[A - 1], c = M[A], o = M[A + 1];
|
|
1917
1917
|
let q = !1, d = !1;
|
|
1918
|
-
if ((b.velocity || b.suspend || b.important || b.pilot || A === 1) && (q = !0, O.push(b)),
|
|
1919
|
-
const Y = N.calculateDistance(b,
|
|
1920
|
-
Math.round(Math.acos(U) * 180 / Math.PI) < p &&
|
|
1918
|
+
if ((b.velocity || b.suspend || b.important || b.pilot || A === 1) && (q = !0, O.push(b)), c.gcToPrevious && (q || (q = !0, O.push(b)), d = !0, O.push(c), A++), o) {
|
|
1919
|
+
const Y = N.calculateDistance(b, c, !0), L = N.calculateDistance(c, o, !0), T = N.calculateDistance(b, o, !0), U = (Math.pow(Y, 2) + Math.pow(L, 2) - Math.pow(T, 2)) / (2 * Y * L);
|
|
1920
|
+
Math.round(Math.acos(U) * 180 / Math.PI) < p && T > z && !d && (O.push(c), A++);
|
|
1921
1921
|
}
|
|
1922
1922
|
if (A >= M.length - 1) {
|
|
1923
1923
|
const Y = M.at(-1);
|
|
@@ -1936,7 +1936,7 @@ class N {
|
|
|
1936
1936
|
const O = C.unix(M), A = p.filter(
|
|
1937
1937
|
(b) => O.clone().subtract(z, "hour").unix() <= (b.positionTime || 0) && O.clone().add(z, "h").unix() >= (b.positionTime || 0)
|
|
1938
1938
|
);
|
|
1939
|
-
return A.sort((b,
|
|
1939
|
+
return A.sort((b, c) => (b.positionTime || 0) - (c.positionTime || 0)), A.at(-1);
|
|
1940
1940
|
}
|
|
1941
1941
|
/**
|
|
1942
1942
|
* 推测船位
|
|
@@ -1944,15 +1944,15 @@ class N {
|
|
|
1944
1944
|
* @param positions 带时间(positionTime)的轨迹
|
|
1945
1945
|
*/
|
|
1946
1946
|
static deadReckoning(M, z) {
|
|
1947
|
-
var A, b,
|
|
1947
|
+
var A, b, c, o;
|
|
1948
1948
|
M > 1e12 && (M = Math.round(M / 1e3));
|
|
1949
1949
|
const p = C.unix(M);
|
|
1950
1950
|
let O = z.find((q) => q.positionTime === p.unix());
|
|
1951
1951
|
if (!O) {
|
|
1952
|
-
const q = (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 = (o = (
|
|
1952
|
+
const q = (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 = (o = (c = z.filter((Y) => (Y == null ? void 0 : Y.positionTime) > p.unix())) == null ? void 0 : c.sort((Y, L) => (Y.positionTime || 0) - (L.positionTime || 0))) == null ? void 0 : o.at(0);
|
|
1953
1953
|
if (q && d) {
|
|
1954
|
-
const Y = N.calculateBearing(q, d, !0), L = N.calculateDistance(q, d),
|
|
1955
|
-
O = N.calculateCoordinate(q, Y, L *
|
|
1954
|
+
const Y = N.calculateBearing(q, d, !0), L = N.calculateDistance(q, d), T = (p.unix() - q.positionTime) / (d.positionTime - q.positionTime);
|
|
1955
|
+
O = N.calculateCoordinate(q, Y, L * T), O.positionTime = p.unix(), O.utc = p.utc().format(), O.cog = Y, O.sog = Math.round(L / ((d.positionTime - q.positionTime) / 3600) * 100) / 100;
|
|
1956
1956
|
} else
|
|
1957
1957
|
O = q || d, O && (O.utc = C.unix(O == null ? void 0 : O.positionTime).utc().format());
|
|
1958
1958
|
}
|
|
@@ -1970,13 +1970,13 @@ class N {
|
|
|
1970
1970
|
const d = z[q], Y = z[q + 1], L = N.calculatePointToLineDistance(M, d, Y);
|
|
1971
1971
|
L < p && (p = L, O = q);
|
|
1972
1972
|
}
|
|
1973
|
-
const A = z[O], b = z[O + 1],
|
|
1974
|
-
if (
|
|
1973
|
+
const A = z[O], b = z[O + 1], c = N.calculateDistance(A, M), o = N.calculateDistance(b, M);
|
|
1974
|
+
if (c === 0)
|
|
1975
1975
|
M = A;
|
|
1976
1976
|
else if (o === 0)
|
|
1977
1977
|
M = b;
|
|
1978
1978
|
else {
|
|
1979
|
-
const q = N.nearestCoordinateInLine(M, A, b), d = A.positionTime, Y = b.positionTime, L = N.calculateDistance(A, q),
|
|
1979
|
+
const q = N.nearestCoordinateInLine(M, A, b), d = A.positionTime, Y = b.positionTime, L = N.calculateDistance(A, q), T = N.calculateDistance(A, b), U = Math.round(d + (Y - d) * (L / T));
|
|
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;
|
|
@@ -2014,7 +2014,7 @@ class V0 {
|
|
|
2014
2014
|
const A = (p = O.history) == null ? void 0 : p[0];
|
|
2015
2015
|
A && A.wind && (A.wind.spd = A.spd, A.wind.kts = A.kts);
|
|
2016
2016
|
for (const b of O.forecasts) {
|
|
2017
|
-
const
|
|
2017
|
+
const c = [], o = C(b.date).utc(), q = `${O.name}-${b.model}`;
|
|
2018
2018
|
if (A) {
|
|
2019
2019
|
const d = C(A.updated).utc(), Y = e.point([A.lng, A.lat], {
|
|
2020
2020
|
model: b.model,
|
|
@@ -2027,12 +2027,12 @@ class V0 {
|
|
|
2027
2027
|
category: q,
|
|
2028
2028
|
type: "forecast"
|
|
2029
2029
|
});
|
|
2030
|
-
z.features.push(Y),
|
|
2030
|
+
z.features.push(Y), c.push(Y.geometry.coordinates);
|
|
2031
2031
|
}
|
|
2032
2032
|
for (const d in b == null ? void 0 : b.hours) {
|
|
2033
2033
|
const Y = b.hours[d];
|
|
2034
2034
|
Y.wind.spd = Y.wind.spd || Y.wind.speed;
|
|
2035
|
-
const L = o.clone().add(Number(d), "hour"),
|
|
2035
|
+
const L = o.clone().add(Number(d), "hour"), T = e.point([Y.lng, Y.lat], {
|
|
2036
2036
|
model: b.model,
|
|
2037
2037
|
name: O.name,
|
|
2038
2038
|
date: L.format(),
|
|
@@ -2045,10 +2045,10 @@ class V0 {
|
|
|
2045
2045
|
category: q,
|
|
2046
2046
|
type: "forecast"
|
|
2047
2047
|
});
|
|
2048
|
-
z.features.push(
|
|
2048
|
+
z.features.push(T), c.push(T.geometry.coordinates);
|
|
2049
2049
|
}
|
|
2050
|
-
if ((
|
|
2051
|
-
const d = e.lineString(R.convertToMonotonicLng2(
|
|
2050
|
+
if ((c == null ? void 0 : c.length) > 1) {
|
|
2051
|
+
const d = e.lineString(R.convertToMonotonicLng2(c), {
|
|
2052
2052
|
date: b.date,
|
|
2053
2053
|
id: O.id || O.name,
|
|
2054
2054
|
model: b.model,
|
|
@@ -2062,25 +2062,25 @@ class V0 {
|
|
|
2062
2062
|
}
|
|
2063
2063
|
if (O.history) {
|
|
2064
2064
|
const A = [];
|
|
2065
|
-
for (const
|
|
2066
|
-
const o = C(
|
|
2065
|
+
for (const c of O.history) {
|
|
2066
|
+
const o = C(c.updated).utc(), q = e.point([c.lng, c.lat], {
|
|
2067
2067
|
name: O.name,
|
|
2068
2068
|
date: o.format(),
|
|
2069
2069
|
format: o.format("MMM-DD/HHmm[Z]"),
|
|
2070
|
-
pressure:
|
|
2071
|
-
spd:
|
|
2072
|
-
kts:
|
|
2073
|
-
source:
|
|
2074
|
-
level:
|
|
2070
|
+
pressure: c.pressure > 1e4 ? R.roundPrecision(c.pressure / 100, 0) : R.roundPrecision(c.pressure, 0),
|
|
2071
|
+
spd: c.speed || c.spd,
|
|
2072
|
+
kts: c.kts,
|
|
2073
|
+
source: c.source,
|
|
2074
|
+
level: c.type,
|
|
2075
2075
|
type: "history",
|
|
2076
2076
|
category: `${O.name}-history`,
|
|
2077
|
-
wind:
|
|
2077
|
+
wind: c.wind
|
|
2078
2078
|
});
|
|
2079
2079
|
z.features.push(q), A.push(q.geometry.coordinates);
|
|
2080
2080
|
}
|
|
2081
2081
|
const b = O.history[0];
|
|
2082
2082
|
if (A.length === 1 && A.push(A[0]), A.length > 1) {
|
|
2083
|
-
const
|
|
2083
|
+
const c = e.lineString(R.convertToMonotonicLng2(A), {
|
|
2084
2084
|
name: O.name,
|
|
2085
2085
|
type: "history",
|
|
2086
2086
|
updated: b == null ? void 0 : b.updated,
|
|
@@ -2090,7 +2090,7 @@ class V0 {
|
|
|
2090
2090
|
source: b == null ? void 0 : b.source,
|
|
2091
2091
|
level: b == null ? void 0 : b.type
|
|
2092
2092
|
});
|
|
2093
|
-
z.features.push(
|
|
2093
|
+
z.features.push(c);
|
|
2094
2094
|
}
|
|
2095
2095
|
}
|
|
2096
2096
|
}
|
|
@@ -2102,18 +2102,18 @@ class V0 {
|
|
|
2102
2102
|
* @param step
|
|
2103
2103
|
*/
|
|
2104
2104
|
static interpolate(M, z = 3) {
|
|
2105
|
-
var A, b,
|
|
2105
|
+
var A, b, c, o;
|
|
2106
2106
|
const p = (A = M == null ? void 0 : M.data) == null ? void 0 : A.features.filter((q) => q.geometry.type === "LineString" && q.properties.type === "forecast"), O = [];
|
|
2107
2107
|
for (const q of p) {
|
|
2108
|
-
const d = q.properties.name, Y = q.properties.model, L = q.properties.showCircle,
|
|
2109
|
-
let
|
|
2108
|
+
const d = q.properties.name, Y = q.properties.model, L = q.properties.showCircle, T = q.properties.disabled, U = C(q.properties.date).utc();
|
|
2109
|
+
let r = z * 60 - (U.get("hour") * 60 + U.get("minute")) % (z * 60);
|
|
2110
2110
|
const s = (b = M == null ? void 0 : M.data) == null ? void 0 : b.features.filter(
|
|
2111
2111
|
(l) => l.geometry.type === "Point" && l.properties.type === "forecast" && l.properties.category === `${d}-${Y}`
|
|
2112
2112
|
);
|
|
2113
|
-
let P, I = U.clone().add(
|
|
2113
|
+
let P, I = U.clone().add(r, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2114
2114
|
for (; P = this.pickIndex(s, I), P <= s.length - 1; ) {
|
|
2115
2115
|
if (P > 0) {
|
|
2116
|
-
const l = s[P], f = P === 0 ? void 0 : s[P - 1], G = (
|
|
2116
|
+
const l = s[P], f = P === 0 ? void 0 : s[P - 1], G = (r / 60 - ((c = f == null ? void 0 : f.properties) == null ? void 0 : c.hour)) / (l.properties.hour - ((o = f == null ? void 0 : f.properties) == null ? void 0 : o.hour)), H = this.computeNumber(f == null ? void 0 : f.geometry.coordinates[0], l.geometry.coordinates[0], G), Q = this.computeNumber(f == null ? void 0 : f.geometry.coordinates[1], l.geometry.coordinates[1], G), F = e.point([H, Q], {
|
|
2117
2117
|
name: d,
|
|
2118
2118
|
model: Y,
|
|
2119
2119
|
category: l == null ? void 0 : l.properties.category,
|
|
@@ -2125,12 +2125,12 @@ class V0 {
|
|
|
2125
2125
|
pressure: this.computeNumber(f == null ? void 0 : f.properties.pressure, l.properties.pressure, G),
|
|
2126
2126
|
wind: this.computeNumber(f == null ? void 0 : f.properties.wind, l.properties.wind, G),
|
|
2127
2127
|
type: "forecast",
|
|
2128
|
-
disabled:
|
|
2128
|
+
disabled: T,
|
|
2129
2129
|
showCircle: L
|
|
2130
2130
|
});
|
|
2131
2131
|
O.push(F);
|
|
2132
2132
|
}
|
|
2133
|
-
|
|
2133
|
+
r += z * 60, I = U.clone().add(r, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2134
2134
|
}
|
|
2135
2135
|
}
|
|
2136
2136
|
return O;
|
|
@@ -2157,22 +2157,22 @@ class V0 {
|
|
|
2157
2157
|
* @param options
|
|
2158
2158
|
*/
|
|
2159
2159
|
static diversionPassageAt(M, z, p, O = {}) {
|
|
2160
|
-
const { t1: A, t2: b, hr:
|
|
2160
|
+
const { t1: A, t2: b, hr: c, hours: o } = this.tropicalCenterTwin(z, 24, O);
|
|
2161
2161
|
if (A && b) {
|
|
2162
2162
|
if (!O.debug) {
|
|
2163
|
-
const U = N.calculateDistance(M, A),
|
|
2164
|
-
if (U > 2 * p &&
|
|
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,
|
|
2163
|
+
const U = N.calculateDistance(M, A), r = N.calculateDistance(M, b);
|
|
2164
|
+
if (U > 2 * p && r > 2 * p)
|
|
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,
|
|
2167
2167
|
t1: A,
|
|
2168
2168
|
t2: b,
|
|
2169
|
-
hr:
|
|
2169
|
+
hr: c
|
|
2170
2170
|
}), {};
|
|
2171
2171
|
}
|
|
2172
2172
|
const q = N.calculateBearing(M, A), d = N.calculateBearing(A, b), Y = Math.abs(q - d);
|
|
2173
2173
|
let L = 0;
|
|
2174
2174
|
Y < 180 ? L = Y + 90 : Y >= 180 && (L = Y - 90);
|
|
2175
|
-
const
|
|
2175
|
+
const T = N.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,
|
|
@@ -2180,8 +2180,8 @@ class V0 {
|
|
|
2180
2180
|
radius: p,
|
|
2181
2181
|
bearing1: q,
|
|
2182
2182
|
bearing2: d,
|
|
2183
|
-
right:
|
|
2184
|
-
}), { at:
|
|
2183
|
+
right: T
|
|
2184
|
+
}), { at: T, t1: A, t2: b, hr: Number(c), hours: o };
|
|
2185
2185
|
}
|
|
2186
2186
|
return {};
|
|
2187
2187
|
}
|
|
@@ -2196,22 +2196,22 @@ class V0 {
|
|
|
2196
2196
|
* @param options
|
|
2197
2197
|
*/
|
|
2198
2198
|
static driftPassageAt(M, z, p, O = {}) {
|
|
2199
|
-
const { t1: A, t2: b, hr:
|
|
2199
|
+
const { t1: A, t2: b, hr: c, hours: o } = this.tropicalCenterTwin(z, 24, O);
|
|
2200
2200
|
if (A && b) {
|
|
2201
2201
|
if (!O.debug) {
|
|
2202
|
-
const
|
|
2203
|
-
if (
|
|
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,
|
|
2202
|
+
const T = N.calculateDistance(M, A), U = N.calculateDistance(M, b);
|
|
2203
|
+
if (T > 2 * p && U > 2 * p)
|
|
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, T, U, {
|
|
2205
2205
|
from: M,
|
|
2206
2206
|
t1: A,
|
|
2207
2207
|
t2: b,
|
|
2208
|
-
hr:
|
|
2208
|
+
hr: c
|
|
2209
2209
|
}), {};
|
|
2210
2210
|
}
|
|
2211
2211
|
const q = N.calculateBearing(M, A), d = N.calculateBearing(A, b), Y = N.calculateDistance(M, A);
|
|
2212
|
-
return { at: N.calculateCoordinate(A, q - d + 180, p < Y ? p : Y), t1: A, t2: b, hr: Number(
|
|
2212
|
+
return { at: N.calculateCoordinate(A, q - d + 180, p < Y ? p : Y), t1: A, t2: b, hr: Number(c), hours: o };
|
|
2213
2213
|
} else
|
|
2214
|
-
return Z == null || Z.info("[%s] no need drift: %j", O.requestId, { from: M, t1: A, t2: b, hr:
|
|
2214
|
+
return Z == null || Z.info("[%s] no need drift: %j", O.requestId, { from: M, t1: A, t2: b, hr: c }), {};
|
|
2215
2215
|
}
|
|
2216
2216
|
/**
|
|
2217
2217
|
* 获取台风中心点对
|
|
@@ -2222,21 +2222,21 @@ class V0 {
|
|
|
2222
2222
|
* @private
|
|
2223
2223
|
*/
|
|
2224
2224
|
static tropicalCenterTwin(M, z = 24, p = {}) {
|
|
2225
|
-
var d, Y, L,
|
|
2225
|
+
var d, Y, L, T, U;
|
|
2226
2226
|
let O = {};
|
|
2227
|
-
(d = M.forecasts) == null || d.forEach((
|
|
2228
|
-
O = { ...
|
|
2227
|
+
(d = M.forecasts) == null || d.forEach((r) => {
|
|
2228
|
+
O = { ...r.hours, ...O };
|
|
2229
2229
|
});
|
|
2230
2230
|
const A = ((Y = M == null ? void 0 : M.history) == null ? void 0 : Y[0]) || (O == null ? void 0 : O[(L = Object.keys(O)) == null ? void 0 : L[0]]);
|
|
2231
2231
|
Z == null || Z.info("[%s] the first tropical center: %j", p.requestId, A);
|
|
2232
|
-
let b = (
|
|
2233
|
-
b || (b = (U = Object.keys(O || {}).filter((
|
|
2234
|
-
const
|
|
2235
|
-
Z == null || Z.info("[%s] the second tropical center: %j in %d hrs", p.requestId,
|
|
2236
|
-
const o = Object.keys(O || {}).filter((
|
|
2237
|
-
for (const
|
|
2238
|
-
q[
|
|
2239
|
-
return { t1: A, t2:
|
|
2232
|
+
let b = (T = Object.keys(O || {}).filter((r) => Number(r) <= (z < 0 ? 24 : z))) == null ? void 0 : T.at(-1);
|
|
2233
|
+
b || (b = (U = Object.keys(O || {}).filter((r) => Number(r) <= (z < 0 ? 24 : 2 * z))) == null ? void 0 : U.at(-1));
|
|
2234
|
+
const c = O == null ? void 0 : O[b || -1];
|
|
2235
|
+
Z == null || Z.info("[%s] the second tropical center: %j in %d hrs", p.requestId, c, b);
|
|
2236
|
+
const o = Object.keys(O || {}).filter((r) => Number(r) <= Number(b)), q = { 0: A };
|
|
2237
|
+
for (const r of o)
|
|
2238
|
+
q[r] = O[r];
|
|
2239
|
+
return { t1: A, t2: c, hr: Number(b), hours: q };
|
|
2240
2240
|
}
|
|
2241
2241
|
static pickIndex(M, z) {
|
|
2242
2242
|
let p = 0;
|
|
@@ -2269,14 +2269,14 @@ class t0 {
|
|
|
2269
2269
|
return `${M.lat}|${M.lng}|${M.positionTime}|${M.sog}|${M.cog}|${M.hdg}|${M.draught}|${z}|${JSON.stringify(M.meteo || {})}|${M.vendor}|${M.deleted}`;
|
|
2270
2270
|
}
|
|
2271
2271
|
static str2Json(M) {
|
|
2272
|
-
const [z, p, O, A, b,
|
|
2272
|
+
const [z, p, O, A, b, c, o, q, d, Y, L] = M.split("|");
|
|
2273
2273
|
return {
|
|
2274
2274
|
lat: Number(z),
|
|
2275
2275
|
lng: Number(p),
|
|
2276
2276
|
positionTime: Number(O),
|
|
2277
2277
|
sog: Number(A),
|
|
2278
2278
|
cog: Number(b),
|
|
2279
|
-
hdg: Number(
|
|
2279
|
+
hdg: Number(c),
|
|
2280
2280
|
//@ts-ignore
|
|
2281
2281
|
draught: isNaN(o) ? null : Number(o),
|
|
2282
2282
|
type: q,
|
|
@@ -2285,45 +2285,50 @@ class t0 {
|
|
|
2285
2285
|
deleted: L === "true"
|
|
2286
2286
|
};
|
|
2287
2287
|
}
|
|
2288
|
-
static inspectStoppages(M, z = 1) {
|
|
2289
|
-
const
|
|
2290
|
-
|
|
2291
|
-
const
|
|
2292
|
-
let
|
|
2293
|
-
for (let
|
|
2294
|
-
const
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2288
|
+
static inspectStoppages(M, z = 1, p = !0) {
|
|
2289
|
+
const O = M.at(0).positionTime < M.at(-1).positionTime;
|
|
2290
|
+
O || M.sort((o, q) => o.positionTime - q.positionTime);
|
|
2291
|
+
const A = [];
|
|
2292
|
+
let b, c;
|
|
2293
|
+
for (let o = 0; o < M.length - 1; o++) {
|
|
2294
|
+
const q = M[o];
|
|
2295
|
+
if (!(p && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))) {
|
|
2296
|
+
for (let d = o + 1; d < M.length; d++) {
|
|
2297
|
+
const Y = M[d - 1], L = M[d];
|
|
2298
|
+
if (p && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))
|
|
2299
|
+
continue;
|
|
2300
|
+
const T = L.positionTime - Y.positionTime;
|
|
2301
|
+
if (N.calculateDistance(L, Y, !0, 4) / (T / 3600) < z)
|
|
2302
|
+
b || (b = q), d === M.length - 1 && (c = L, o = d);
|
|
2303
|
+
else {
|
|
2304
|
+
b && (c = M[d - 1], o = d);
|
|
2305
|
+
break;
|
|
2306
|
+
}
|
|
2302
2307
|
}
|
|
2308
|
+
if ((c == null ? void 0 : c.positionTime) > (b == null ? void 0 : b.positionTime) && b) {
|
|
2309
|
+
const d = {
|
|
2310
|
+
start: {
|
|
2311
|
+
lat: b.lat,
|
|
2312
|
+
lng: b.lng,
|
|
2313
|
+
sog: b.sog,
|
|
2314
|
+
positionTime: b.positionTime,
|
|
2315
|
+
utc: C.unix(b.positionTime).utc().format()
|
|
2316
|
+
},
|
|
2317
|
+
end: {
|
|
2318
|
+
lat: c.lat,
|
|
2319
|
+
lng: c.lng,
|
|
2320
|
+
sog: c.sog,
|
|
2321
|
+
positionTime: c.positionTime,
|
|
2322
|
+
utc: C.unix(c.positionTime).utc().format()
|
|
2323
|
+
},
|
|
2324
|
+
duration: c.positionTime - b.positionTime
|
|
2325
|
+
}, Y = M.filter((T) => T.positionTime >= d.start.positionTime && T.positionTime <= d.end.positionTime), L = N.divideAccordingToLng(Y);
|
|
2326
|
+
d.distance = N.calculateRouteDistance(L), d.hours = Math.round(d.duration / 3600 * 10) / 10, d.avgSog = Math.round(d.distance / d.hours * 10) / 10, A.push(d);
|
|
2327
|
+
}
|
|
2328
|
+
b = void 0, c = void 0;
|
|
2303
2329
|
}
|
|
2304
|
-
if ((b == null ? void 0 : b.positionTime) > (A == null ? void 0 : A.positionTime)) {
|
|
2305
|
-
const q = {
|
|
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 >= q.start.positionTime && L.positionTime <= q.end.positionTime), Y = N.divideAccordingToLng(d);
|
|
2322
|
-
q.distance = N.calculateRouteDistance(Y), q.hours = Math.round(q.duration / 3600 * 10) / 10, q.avgSog = Math.round(q.distance / q.hours * 10) / 10, O.push(q);
|
|
2323
|
-
}
|
|
2324
|
-
A = void 0, b = void 0;
|
|
2325
2330
|
}
|
|
2326
|
-
return
|
|
2331
|
+
return O || M.sort((o, q) => q.positionTime - o.positionTime), A;
|
|
2327
2332
|
}
|
|
2328
2333
|
}
|
|
2329
2334
|
export {
|