@idm-plugin/geo 1.6.2 → 1.6.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 +301 -281
- package/dist/index.umd.cjs +2 -2
- package/dist/lane/src/index.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as T from "@turf/turf";
|
|
2
|
-
import
|
|
2
|
+
import C from "moment";
|
|
3
3
|
import _ from "@log4js-node/log4js-api";
|
|
4
4
|
var X0 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
5
5
|
function a0(E) {
|
|
@@ -13,42 +13,42 @@ var j = { exports: {} };
|
|
|
13
13
|
//! license : MIT
|
|
14
14
|
//! github.com/moment/moment-timezone
|
|
15
15
|
(function(M, z) {
|
|
16
|
-
E.exports ? E.exports = z(
|
|
16
|
+
E.exports ? E.exports = z(C) : z(M.moment);
|
|
17
17
|
})(X0, function(M) {
|
|
18
18
|
M.version === void 0 && M.default && (M = M.default);
|
|
19
|
-
var z = "0.5.45", p = {}, O = {}, A = {}, b = {},
|
|
19
|
+
var z = "0.5.45", p = {}, O = {}, A = {}, b = {}, c = {}, q;
|
|
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 o = M.version.split("."), R = +o[0], Y = +o[1];
|
|
22
22
|
(R < 2 || R === 2 && Y < 6) && D("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
|
|
23
|
-
function i(
|
|
24
|
-
return
|
|
23
|
+
function i(W) {
|
|
24
|
+
return W > 96 ? W - 87 : W > 64 ? W - 29 : W - 48;
|
|
25
25
|
}
|
|
26
|
-
function e(
|
|
27
|
-
var d = 0, X =
|
|
28
|
-
for (
|
|
26
|
+
function e(W) {
|
|
27
|
+
var d = 0, X = W.split("."), n = X[0], L = X[1] || "", f = 1, t, B = 0, V = 1;
|
|
28
|
+
for (W.charCodeAt(0) === 45 && (d = 1, V = -1), d; d < n.length; d++)
|
|
29
29
|
t = i(n.charCodeAt(d)), B = 60 * B + t;
|
|
30
30
|
for (d = 0; d < L.length; d++)
|
|
31
31
|
f = f / 60, t = i(L.charCodeAt(d)), B += t * f;
|
|
32
32
|
return B * V;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
for (var d = 0; d <
|
|
36
|
-
|
|
34
|
+
function u(W) {
|
|
35
|
+
for (var d = 0; d < W.length; d++)
|
|
36
|
+
W[d] = e(W[d]);
|
|
37
37
|
}
|
|
38
|
-
function S(
|
|
38
|
+
function S(W, d) {
|
|
39
39
|
for (var X = 0; X < d; X++)
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
W[X] = Math.round((W[X - 1] || 0) + W[X] * 6e4);
|
|
41
|
+
W[d - 1] = 1 / 0;
|
|
42
42
|
}
|
|
43
|
-
function s(
|
|
43
|
+
function s(W, d) {
|
|
44
44
|
var X = [], n;
|
|
45
45
|
for (n = 0; n < d.length; n++)
|
|
46
|
-
X[n] =
|
|
46
|
+
X[n] = W[d[n]];
|
|
47
47
|
return X;
|
|
48
48
|
}
|
|
49
|
-
function P(
|
|
50
|
-
var d =
|
|
51
|
-
return
|
|
49
|
+
function P(W) {
|
|
50
|
+
var d = W.split("|"), X = d[2].split(" "), n = d[3].split(""), L = d[4].split(" ");
|
|
51
|
+
return u(X), u(n), u(L), S(L, n.length), {
|
|
52
52
|
name: d[0],
|
|
53
53
|
abbrs: s(d[1].split(" "), n),
|
|
54
54
|
offsets: s(X, n),
|
|
@@ -56,92 +56,92 @@ var j = { exports: {} };
|
|
|
56
56
|
population: d[5] | 0
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function G(
|
|
60
|
-
|
|
59
|
+
function G(W) {
|
|
60
|
+
W && this._set(P(W));
|
|
61
61
|
}
|
|
62
|
-
function l(
|
|
62
|
+
function l(W, d) {
|
|
63
63
|
var X = d.length;
|
|
64
|
-
if (
|
|
64
|
+
if (W < d[0])
|
|
65
65
|
return 0;
|
|
66
|
-
if (X > 1 && d[X - 1] === 1 / 0 &&
|
|
66
|
+
if (X > 1 && d[X - 1] === 1 / 0 && W >= d[X - 2])
|
|
67
67
|
return X - 1;
|
|
68
|
-
if (
|
|
68
|
+
if (W >= d[X - 1])
|
|
69
69
|
return -1;
|
|
70
70
|
for (var n, L = 0, f = X - 1; f - L > 1; )
|
|
71
|
-
n = Math.floor((L + f) / 2), d[n] <=
|
|
71
|
+
n = Math.floor((L + f) / 2), d[n] <= W ? L = n : f = n;
|
|
72
72
|
return f;
|
|
73
73
|
}
|
|
74
74
|
G.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 d = +
|
|
78
|
+
_index: function(W) {
|
|
79
|
+
var d = +W, X = this.untils, n;
|
|
80
80
|
if (n = l(d, 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(d) {
|
|
86
|
-
return A[d].zones.indexOf(
|
|
86
|
+
return A[d].zones.indexOf(W) !== -1;
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
|
-
parse: function(
|
|
90
|
-
var d = +
|
|
89
|
+
parse: function(W) {
|
|
90
|
+
var d = +W, X = this.offsets, n = this.untils, L = n.length - 1, f, t, B, V;
|
|
91
91
|
for (V = 0; V < L; V++)
|
|
92
|
-
if (f = X[V], t = X[V + 1], B = X[V && V - 1], f < t &&
|
|
92
|
+
if (f = X[V], t = X[V + 1], B = X[V && V - 1], f < t && U.moveAmbiguousForward ? f = t : f > B && U.moveInvalidForward && (f = B), d < n[V] - f * 6e4)
|
|
93
93
|
return X[V];
|
|
94
94
|
return X[L];
|
|
95
95
|
},
|
|
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 N(
|
|
107
|
-
this.name =
|
|
106
|
+
function N(W, d) {
|
|
107
|
+
this.name = W, this.zones = d;
|
|
108
108
|
}
|
|
109
|
-
function I(
|
|
110
|
-
var d =
|
|
111
|
-
X && X[0] ? (X = X[0].match(/[A-Z]/g), X = X ? X.join("") : void 0) : (X = d.match(/[A-Z]{3,5}/g), X = X ? X[0] : void 0), X === "GMT" && (X = void 0), this.at = +
|
|
109
|
+
function I(W) {
|
|
110
|
+
var d = W.toTimeString(), X = d.match(/\([a-z ]+\)/i);
|
|
111
|
+
X && X[0] ? (X = X[0].match(/[A-Z]/g), X = X ? X.join("") : void 0) : (X = d.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 = ((d.at -
|
|
121
|
-
X = new I(new Date(
|
|
122
|
-
return
|
|
119
|
+
function Q(W, d) {
|
|
120
|
+
for (var X, n; n = ((d.at - W.at) / 12e4 | 0) * 6e4; )
|
|
121
|
+
X = new I(new Date(W.at + n)), X.offset === W.offset ? W = X : d = X;
|
|
122
|
+
return W;
|
|
123
123
|
}
|
|
124
124
|
function F() {
|
|
125
|
-
var
|
|
125
|
+
var W = (/* @__PURE__ */ new Date()).getFullYear() - 2, d = new I(new Date(W, 0, 1)), X = d.offset, n = [d], L, f, t, B;
|
|
126
126
|
for (B = 1; B < 48; B++)
|
|
127
|
-
t = new Date(
|
|
127
|
+
t = new Date(W, B, 1).getTimezoneOffset(), t !== X && (f = new I(new Date(W, B, 1)), L = Q(d, f), n.push(L), n.push(new I(new Date(L.at + 6e4))), d = f, X = t);
|
|
128
128
|
for (B = 0; B < 4; B++)
|
|
129
|
-
n.push(new I(new Date(
|
|
129
|
+
n.push(new I(new Date(W + B, 0, 1))), n.push(new I(new Date(W + B, 6, 1)));
|
|
130
130
|
return n;
|
|
131
131
|
}
|
|
132
|
-
function M0(
|
|
133
|
-
return
|
|
132
|
+
function M0(W, d) {
|
|
133
|
+
return W.offsetScore !== d.offsetScore ? W.offsetScore - d.offsetScore : W.abbrScore !== d.abbrScore ? W.abbrScore - d.abbrScore : W.zone.population !== d.zone.population ? d.zone.population - W.zone.population : d.zone.name.localeCompare(W.zone.name);
|
|
134
134
|
}
|
|
135
|
-
function z0(
|
|
135
|
+
function z0(W, d) {
|
|
136
136
|
var X, n;
|
|
137
|
-
for (
|
|
138
|
-
n = d[X],
|
|
137
|
+
for (u(d), X = 0; X < d.length; X++)
|
|
138
|
+
n = d[X], c[n] = c[n] || {}, c[n][W] = !0;
|
|
139
139
|
}
|
|
140
|
-
function b0(
|
|
141
|
-
var d =
|
|
140
|
+
function b0(W) {
|
|
141
|
+
var d = W.length, X = {}, n = [], L = {}, f, t, B, V;
|
|
142
142
|
for (f = 0; f < d; f++)
|
|
143
|
-
if (B =
|
|
144
|
-
V =
|
|
143
|
+
if (B = W[f].offset, !L.hasOwnProperty(B)) {
|
|
144
|
+
V = c[B] || {};
|
|
145
145
|
for (t in V)
|
|
146
146
|
V.hasOwnProperty(t) && (X[t] = !0);
|
|
147
147
|
L[B] = !0;
|
|
@@ -152,130 +152,130 @@ var j = { exports: {} };
|
|
|
152
152
|
}
|
|
153
153
|
function p0() {
|
|
154
154
|
try {
|
|
155
|
-
var
|
|
156
|
-
if (
|
|
157
|
-
var d = b[K(
|
|
155
|
+
var W = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
156
|
+
if (W && W.length > 3) {
|
|
157
|
+
var d = b[K(W)];
|
|
158
158
|
if (d)
|
|
159
159
|
return d;
|
|
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
164
|
var X = F(), n = X.length, L = b0(X), f = [], t, B, V;
|
|
165
165
|
for (B = 0; B < L.length; B++) {
|
|
166
|
-
for (t = new H(
|
|
166
|
+
for (t = new H(g(L[B])), V = 0; V < n; V++)
|
|
167
167
|
t.scoreOffsetAt(X[V]);
|
|
168
168
|
f.push(t);
|
|
169
169
|
}
|
|
170
170
|
return f.sort(M0), f.length > 0 ? f[0].zone.name : void 0;
|
|
171
171
|
}
|
|
172
|
-
function O0(
|
|
173
|
-
return (!q ||
|
|
172
|
+
function O0(W) {
|
|
173
|
+
return (!q || W) && (q = p0()), q;
|
|
174
174
|
}
|
|
175
|
-
function K(
|
|
176
|
-
return (
|
|
175
|
+
function K(W) {
|
|
176
|
+
return (W || "").toLowerCase().replace(/\//g, "_");
|
|
177
177
|
}
|
|
178
|
-
function k(
|
|
178
|
+
function k(W) {
|
|
179
179
|
var d, X, n, L;
|
|
180
|
-
for (typeof
|
|
181
|
-
n =
|
|
180
|
+
for (typeof W == "string" && (W = [W]), d = 0; d < W.length; d++)
|
|
181
|
+
n = W[d].split("|"), X = n[0], L = K(X), p[L] = W[d], b[L] = X, z0(L, n[2].split(" "));
|
|
182
182
|
}
|
|
183
|
-
function
|
|
184
|
-
|
|
185
|
-
var X = p[
|
|
186
|
-
return X instanceof G ? X : typeof X == "string" ? (X = new G(X), p[
|
|
183
|
+
function g(W, d) {
|
|
184
|
+
W = K(W);
|
|
185
|
+
var X = p[W], n;
|
|
186
|
+
return X instanceof G ? X : typeof X == "string" ? (X = new G(X), p[W] = X, X) : O[W] && d !== g && (n = g(O[W], g)) ? (X = p[W] = new G(), 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, d = [];
|
|
190
|
+
for (W in b)
|
|
191
|
+
b.hasOwnProperty(W) && (p[W] || p[O[W]]) && b[W] && d.push(b[W]);
|
|
192
192
|
return d.sort();
|
|
193
193
|
}
|
|
194
194
|
function c0() {
|
|
195
195
|
return Object.keys(A);
|
|
196
196
|
}
|
|
197
|
-
function v(
|
|
197
|
+
function v(W) {
|
|
198
198
|
var d, X, n, L;
|
|
199
|
-
for (typeof
|
|
200
|
-
X =
|
|
199
|
+
for (typeof W == "string" && (W = [W]), d = 0; d < W.length; d++)
|
|
200
|
+
X = W[d].split("|"), n = K(X[0]), L = K(X[1]), O[n] = L, b[n] = X[0], O[L] = n, b[L] = X[1];
|
|
201
201
|
}
|
|
202
|
-
function W0(
|
|
202
|
+
function W0(W) {
|
|
203
203
|
var d, X, n, L;
|
|
204
|
-
if (!(!
|
|
205
|
-
for (d = 0; d <
|
|
206
|
-
L =
|
|
204
|
+
if (!(!W || !W.length))
|
|
205
|
+
for (d = 0; d < W.length; d++)
|
|
206
|
+
L = W[d].split("|"), X = L[0].toUpperCase(), n = L[1].split(" "), A[X] = new N(
|
|
207
207
|
X,
|
|
208
208
|
n
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
|
-
function q0(
|
|
212
|
-
return
|
|
211
|
+
function q0(W) {
|
|
212
|
+
return W = W.toUpperCase(), A[W] || null;
|
|
213
213
|
}
|
|
214
|
-
function o0(
|
|
215
|
-
if (
|
|
214
|
+
function o0(W, d) {
|
|
215
|
+
if (W = q0(W), !W)
|
|
216
216
|
return null;
|
|
217
|
-
var X =
|
|
217
|
+
var X = W.zones.sort();
|
|
218
218
|
return d ? X.map(function(n) {
|
|
219
|
-
var L =
|
|
219
|
+
var L = g(n);
|
|
220
220
|
return {
|
|
221
221
|
name: n,
|
|
222
222
|
offset: L.utcOffset(/* @__PURE__ */ new Date())
|
|
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 d =
|
|
234
|
-
return !!(
|
|
232
|
+
function J(W) {
|
|
233
|
+
var d = W._f === "X" || W._f === "x";
|
|
234
|
+
return !!(W._a && W._tzm === void 0 && !d);
|
|
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
|
|
239
|
+
function U(W) {
|
|
240
240
|
var d = Array.prototype.slice.call(arguments, 0, -1), X = arguments[arguments.length - 1], n = M.utc.apply(null, d), L;
|
|
241
|
-
return !M.isMoment(
|
|
241
|
+
return !M.isMoment(W) && J(n) && (L = g(X)) && n.add(L.parse(n), "minutes"), n.tz(X), n;
|
|
242
242
|
}
|
|
243
|
-
|
|
244
|
-
var
|
|
245
|
-
M.tz =
|
|
243
|
+
U.version = z, U.dataVersion = "", U._zones = p, U._links = O, U._names = b, U._countries = A, U.add = k, U.link = v, U.load = Y0, U.zone = g, U.zoneExists = $, U.guess = O0, U.names = A0, U.Zone = G, U.unpack = P, U.unpackBase60 = e, U.needsOffset = J, U.moveInvalidForward = !0, U.moveAmbiguousForward = !1, U.countries = c0, U.zonesForCountry = o0;
|
|
244
|
+
var m = M.fn;
|
|
245
|
+
M.tz = U, M.defaultZone = null, M.updateOffset = function(W, d) {
|
|
246
246
|
var X = M.defaultZone, n;
|
|
247
|
-
if (
|
|
248
|
-
if (n =
|
|
249
|
-
var L =
|
|
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 L = W._z;
|
|
250
|
+
W.utcOffset(-n, d), W._z = L;
|
|
251
251
|
} else
|
|
252
|
-
|
|
253
|
-
},
|
|
254
|
-
if (
|
|
255
|
-
if (typeof
|
|
256
|
-
throw new Error("Time zone name must be a string, got " +
|
|
257
|
-
return this._z =
|
|
252
|
+
W.zone(n, d);
|
|
253
|
+
}, m.tz = function(W, d) {
|
|
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, d) : 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
|
-
|
|
278
|
-
return (R < 2 || R === 2 && Y < 9) && D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone =
|
|
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 (R < 2 || R === 2 && Y < 9) && D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = 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, q = 24 * (90 - z) / 180.00000000000003, o = 0 | c, R = 0 | q, Y = 96 * R + 2 * o;
|
|
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 * (R = 0 | (q = 2 * (q - R) % 2)) + 2 * (o = 0 | (
|
|
1149
|
+
Y = 56 * O.charCodeAt(Y = 8 * (b = b + Y + 1) + 4 * (R = 0 | (q = 2 * (q - R) % 2)) + 2 * (o = 0 | (c = 2 * (c - o) % 2)) + 2304) + O.charCodeAt(Y + 1) - 1995;
|
|
1150
1150
|
return A[Y + A.length - 3136];
|
|
1151
1151
|
}
|
|
1152
1152
|
E.exports = M;
|
|
@@ -1160,7 +1160,7 @@ class a {
|
|
|
1160
1160
|
* @param lat
|
|
1161
1161
|
*/
|
|
1162
1162
|
static guessTimeZoneOffset(M, z) {
|
|
1163
|
-
const p = B0(z, M), O =
|
|
1163
|
+
const p = B0(z, M), O = C().tz(p).utcOffset();
|
|
1164
1164
|
return this.roundPrecision(O / 60, 1);
|
|
1165
1165
|
}
|
|
1166
1166
|
/**
|
|
@@ -1176,9 +1176,9 @@ class a {
|
|
|
1176
1176
|
z = z < 6 ? 6 : z, M = a.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 i = `${p.replace(/S+/gi,
|
|
1179
|
+
let A = M * 3600, b, c, q, o, R, Y;
|
|
1180
|
+
b = A % 3600 % 60, p.indexOf("S") !== -1 && (A = A - b, c = a.padNumber(b, 2, 2)), q = A / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ? o = a.roundPrecision(q, z).toString().padStart(2, "0") : o = a.padNumber(q, 2, 2), A = A - q * 60), R = A / 3600, p.indexOf("M") !== -1 ? Y = a.roundPrecision(R, z).toString().padStart(3, "0") : Y = a.padNumber(R, 3, 2), Number(c) >= 60 && (o = Number(o) + 1, c = 0), Number(o) >= 60 && (Y = Number(Y) + 1, o = 0);
|
|
1181
|
+
const i = `${p.replace(/S+/gi, c).replace(/M+/gi, o).replace(/H+/gi, Y)}${O}`;
|
|
1182
1182
|
return {
|
|
1183
1183
|
direction: O,
|
|
1184
1184
|
degree: a.roundPrecision(R, z),
|
|
@@ -1197,9 +1197,9 @@ class a {
|
|
|
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 i = `${p.replace(/S+/gi,
|
|
1200
|
+
let A = M * 3600, b, c, q, o, R, Y;
|
|
1201
|
+
b = A % 3600 % 60, p.indexOf("S") !== -1 && (A = A - b, c = a.padNumber(b, 2, 2)), q = A / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ? o = a.roundPrecision(q, z).toString().padStart(2, "0") : o = a.padNumber(q, 2, 2), A = A - q * 60), R = A / 3600, p.indexOf("M") !== -1 ? Y = a.roundPrecision(R, z).toString().padStart(2, "0") : Y = a.padNumber(R, 2, 2), Number(c) >= 60 && (o = Number(o) + 1, c = 0), Number(o) >= 60 && (Y = Number(Y) + 1, o = 0);
|
|
1202
|
+
const i = `${p.replace(/S+/gi, c).replace(/M+/gi, o).replace(/H+/gi, Y)}${O}`;
|
|
1203
1203
|
return {
|
|
1204
1204
|
direction: O,
|
|
1205
1205
|
degree: a.roundPrecision(R, z),
|
|
@@ -1215,12 +1215,12 @@ class a {
|
|
|
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((q) => q !== "").map((q) => Number(q));
|
|
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 q = this.roundPrecision(b / 100, 0);
|
|
1221
|
-
|
|
1221
|
+
c = b - q * 100, b = q;
|
|
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 a.convertToStdLng(p, z);
|
|
@@ -1232,12 +1232,12 @@ class a {
|
|
|
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((q) => q !== "").map((q) => Number(q));
|
|
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 q = this.roundPrecision(b / 100, 0);
|
|
1238
|
-
|
|
1238
|
+
c = b - q * 100, b = q;
|
|
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
|
|
@@ -1310,7 +1310,7 @@ try {
|
|
|
1310
1310
|
} catch {
|
|
1311
1311
|
} finally {
|
|
1312
1312
|
}
|
|
1313
|
-
class
|
|
1313
|
+
class r {
|
|
1314
1314
|
/**
|
|
1315
1315
|
* 计算方位角
|
|
1316
1316
|
* @param from 坐标 {lng, lat}
|
|
@@ -1342,8 +1342,8 @@ class u {
|
|
|
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 = T.rhumbDistance(b.features[0], b.features[1], { units: A }) : c = T.distance(b.features[0], b.features[1], { units: A }), a.roundPrecision(c, O);
|
|
1347
1347
|
}
|
|
1348
1348
|
/**
|
|
1349
1349
|
* 计算航线距离
|
|
@@ -1354,10 +1354,10 @@ class u {
|
|
|
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 q = { lng: b[
|
|
1359
|
-
|
|
1360
|
-
const o = { lng: b[
|
|
1357
|
+
for (let c = 0; c < b.length - 1; c++) {
|
|
1358
|
+
const q = { lng: b[c][0], lat: b[c][1] };
|
|
1359
|
+
c === 0 && A && (O += this.calculateDistance(A, q, !0, z, p));
|
|
1360
|
+
const o = { lng: b[c + 1][0], lat: b[c + 1][1] };
|
|
1361
1361
|
O += this.calculateDistance(q, o, !0, z, p), A = o;
|
|
1362
1362
|
}
|
|
1363
1363
|
return a.roundPrecision(O, z);
|
|
@@ -1372,9 +1372,9 @@ class u {
|
|
|
1372
1372
|
*/
|
|
1373
1373
|
static calculateCoordinate(M, z, p, O = "nauticalmiles", A = !0) {
|
|
1374
1374
|
const b = T.point([M.lng, M.lat]);
|
|
1375
|
-
let
|
|
1376
|
-
A ?
|
|
1377
|
-
const q =
|
|
1375
|
+
let c;
|
|
1376
|
+
A ? c = T.rhumbDestination(b, p, z, { units: O }) : c = T.destination(b, p, z, { units: O });
|
|
1377
|
+
const q = c.geometry.coordinates;
|
|
1378
1378
|
return { lng: a.convertToStdLng(q[0], 8), lat: a.roundPrecision(q[1], 8) };
|
|
1379
1379
|
}
|
|
1380
1380
|
/**
|
|
@@ -1387,12 +1387,12 @@ class u {
|
|
|
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 = [], q = this.calculateBearing(M, z, !1), o = this.calculateDistance(M, z, !1, 8, b);
|
|
1391
|
+
O && c.push({ lng: M.lng, lat: M.lat });
|
|
1392
1392
|
let R = 0;
|
|
1393
1393
|
for (; R < o; )
|
|
1394
|
-
R += p, R < o &&
|
|
1395
|
-
return A &&
|
|
1394
|
+
R += p, R < o && c.push(this.calculateCoordinate(M, q, R, 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 u {
|
|
|
1412
1412
|
let p = [];
|
|
1413
1413
|
const O = [];
|
|
1414
1414
|
let A, b;
|
|
1415
|
-
for (let
|
|
1416
|
-
A = a.convertToStdLng(M[
|
|
1415
|
+
for (let c = 0; c < M.length - 1; c++) {
|
|
1416
|
+
A = a.convertToStdLng(M[c].lng, 8), b = a.convertToStdLng(M[c + 1].lng, 8), M[c].lat = a.roundPrecision(M[c].lat, 8), M[c + 1].lat = a.roundPrecision(M[c + 1].lat, 8), p.push([A, M[c].lat]);
|
|
1417
1417
|
const q = A - b;
|
|
1418
1418
|
if (Math.abs(q) > 180) {
|
|
1419
1419
|
const o = a.convertToMonotonicLng2([
|
|
1420
|
-
[A, M[
|
|
1421
|
-
[b, M[
|
|
1420
|
+
[A, M[c].lat],
|
|
1421
|
+
[b, M[c + 1].lat]
|
|
1422
1422
|
]);
|
|
1423
1423
|
let R, Y;
|
|
1424
1424
|
z ? (R = T.lineString(o), Y = T.lineString([
|
|
@@ -1428,13 +1428,13 @@ class u {
|
|
|
1428
1428
|
const i = T.lineIntersect(R, Y);
|
|
1429
1429
|
let e;
|
|
1430
1430
|
if (i.features.length) {
|
|
1431
|
-
const
|
|
1432
|
-
e = a.roundPrecision(
|
|
1431
|
+
const u = T.getCoord(i.features[0]);
|
|
1432
|
+
e = a.roundPrecision(u[1], 8);
|
|
1433
1433
|
} else
|
|
1434
|
-
e = M[
|
|
1434
|
+
e = M[c].lat;
|
|
1435
1435
|
q > 0 ? (p.push([180 - 1e-6, e]), O.push([...p]), p = [], p.push([-(180 - 1e-6), e])) : (p.push([-(180 - 1e-6), e]), O.push([...p]), p = [], p.push([180 - 1e-6, e]));
|
|
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 u {
|
|
|
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 u {
|
|
|
1493
1493
|
*/
|
|
1494
1494
|
static mergeCoordinateToRoute(M, z) {
|
|
1495
1495
|
M.lng = a.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((q, o) => {
|
|
1498
1498
|
for (let R = 0; R < q.length - 1; R++) {
|
|
1499
1499
|
const Y = { lng: q[R][0], lat: q[R][1] }, i = { lng: q[R + 1][0], lat: q[R + 1][1] }, e = this.calculatePointToLineDistance(M, Y, i);
|
|
1500
|
-
p > e && (p = e, A = R, O = o, b = this.calculateDistance(Y, M),
|
|
1500
|
+
p > e && (p = e, A = R, O = o, b = this.calculateDistance(Y, M), c = this.calculateDistance(i, 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个坐标
|
|
@@ -1508,8 +1508,8 @@ class u {
|
|
|
1508
1508
|
*/
|
|
1509
1509
|
static appendCoordinateToRoute(M, z) {
|
|
1510
1510
|
M.lng = a.convertToStdLng(M.lng, 8);
|
|
1511
|
-
const p =
|
|
1512
|
-
return p.push(M),
|
|
1511
|
+
const p = r.convertRouteToCoordinates(z);
|
|
1512
|
+
return p.push(M), r.divideAccordingToLng(p);
|
|
1513
1513
|
}
|
|
1514
1514
|
/**
|
|
1515
1515
|
* 向route头加1个坐标
|
|
@@ -1517,8 +1517,8 @@ class u {
|
|
|
1517
1517
|
* @param route
|
|
1518
1518
|
*/
|
|
1519
1519
|
static unshiftCoordinateToRoute(M, z) {
|
|
1520
|
-
const p =
|
|
1521
|
-
return p.unshift(M),
|
|
1520
|
+
const p = r.convertRouteToCoordinates(z);
|
|
1521
|
+
return p.unshift(M), r.divideAccordingToLng(p);
|
|
1522
1522
|
}
|
|
1523
1523
|
/**
|
|
1524
1524
|
* 合并多个waypoints进航线
|
|
@@ -1544,15 +1544,15 @@ class u {
|
|
|
1544
1544
|
return p.forEach((b) => {
|
|
1545
1545
|
if (A === 2)
|
|
1546
1546
|
return;
|
|
1547
|
-
const
|
|
1547
|
+
const c = [];
|
|
1548
1548
|
for (const q of b) {
|
|
1549
1549
|
if (a.roundPrecision(z.lng, 8) === a.roundPrecision(q[0], 8) && a.roundPrecision(z.lat, 8) === a.roundPrecision(q[1], 8)) {
|
|
1550
|
-
|
|
1550
|
+
c.push(q), A === 0 && c.push([M.lng, M.lat]), A = 2;
|
|
1551
1551
|
break;
|
|
1552
1552
|
}
|
|
1553
|
-
A === 1 ?
|
|
1553
|
+
A === 1 ? c.push(q) : a.roundPrecision(M.lng, 8) === a.roundPrecision(q[0], 8) && a.roundPrecision(M.lat, 8) === a.roundPrecision(q[1], 8) && (A = 1, c.push(q));
|
|
1554
1554
|
}
|
|
1555
|
-
|
|
1555
|
+
c.length && O.push(c);
|
|
1556
1556
|
}), O;
|
|
1557
1557
|
}
|
|
1558
1558
|
/**
|
|
@@ -1564,12 +1564,12 @@ class u {
|
|
|
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, ...O], A),
|
|
1567
|
+
const A = this.convertRouteToCoordinates(p, 0), b = this.mergeCoordinatesToWaypoints([M, z, ...O], A), c = b.findIndex(
|
|
1568
1568
|
(R) => a.roundPrecision(M.lng, 8) === a.roundPrecision(R.lng, 8) && a.roundPrecision(M.lat, 8) === a.roundPrecision(R.lat, 8)
|
|
1569
1569
|
), q = b.findIndex(
|
|
1570
1570
|
(R) => a.roundPrecision(z.lng, 8) === a.roundPrecision(R.lng, 8) && a.roundPrecision(z.lat, 8) === a.roundPrecision(R.lat, 8)
|
|
1571
1571
|
);
|
|
1572
|
-
return b.filter((R, Y) => Y >=
|
|
1572
|
+
return b.filter((R, Y) => Y >= c && Y <= q);
|
|
1573
1573
|
}
|
|
1574
1574
|
/**
|
|
1575
1575
|
* 计算坐标到航路上的最短距离
|
|
@@ -1578,10 +1578,10 @@ class u {
|
|
|
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 q = 0; q < b.length - 1; q++) {
|
|
1583
1583
|
const o = { lng: b[q][0], lat: b[q][1] }, R = { lng: b[q + 1][0], lat: b[q + 1][1] }, Y = this.calculatePointToLineDistance(M, o, R);
|
|
1584
|
-
p > Y && (p = Y, O = q, A =
|
|
1584
|
+
p > Y && (p = Y, O = q, A = c);
|
|
1585
1585
|
}
|
|
1586
1586
|
}), { minDist: p, segIndex: A, minIndex: O };
|
|
1587
1587
|
}
|
|
@@ -1592,19 +1592,19 @@ class u {
|
|
|
1592
1592
|
* @return [[[lng, lat]]]
|
|
1593
1593
|
*/
|
|
1594
1594
|
static calculateSubRoute(M, z) {
|
|
1595
|
-
const p =
|
|
1596
|
-
|
|
1595
|
+
const p = r.convertRouteToCoordinates(z);
|
|
1596
|
+
r.mergeCoordinateToWaypoints(M, p, !0), z = r.divideAccordingToLng(p);
|
|
1597
1597
|
const { segIndex: O, minIndex: A } = this.calculateMinDistanceToRoute({ ...M }, z);
|
|
1598
1598
|
M.lng = a.convertToStdLng(M.lng);
|
|
1599
1599
|
const b = [];
|
|
1600
|
-
let
|
|
1600
|
+
let c = !0;
|
|
1601
1601
|
for (let q = O; q < z.length; q++)
|
|
1602
|
-
if (
|
|
1602
|
+
if (c) {
|
|
1603
1603
|
const o = [];
|
|
1604
1604
|
o.push([M.lng, M.lat]);
|
|
1605
1605
|
for (let R = A + 1; R < z[q].length; R++)
|
|
1606
1606
|
M.lng === z[q][R][0] && M.lat === z[q][R][1] || o.push(z[q][R]);
|
|
1607
|
-
b.push(o),
|
|
1607
|
+
b.push(o), c = !1;
|
|
1608
1608
|
} else
|
|
1609
1609
|
b.push([...z[q]]);
|
|
1610
1610
|
return b;
|
|
@@ -1618,12 +1618,12 @@ class u {
|
|
|
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], q = z[b + 1];
|
|
1622
|
+
if (this.calculateDistance(M, c) === 0)
|
|
1623
1623
|
return z;
|
|
1624
1624
|
if (this.calculateDistance(M, q) === 0)
|
|
1625
1625
|
return z.filter((R, Y) => Y > 0);
|
|
1626
|
-
const o = this.calculatePointToLineDistance(M,
|
|
1626
|
+
const o = this.calculatePointToLineDistance(M, c, q);
|
|
1627
1627
|
p > o && (p = o, O = b);
|
|
1628
1628
|
}
|
|
1629
1629
|
M.lng = a.convertToStdLng(M.lng);
|
|
@@ -1646,8 +1646,8 @@ class u {
|
|
|
1646
1646
|
const b = T.lineString([
|
|
1647
1647
|
[z.lng, z.lat],
|
|
1648
1648
|
[p.lng, p.lat]
|
|
1649
|
-
]),
|
|
1650
|
-
return a.roundPrecision(Math.min(
|
|
1649
|
+
]), c = T.pointToLineDistance(T.point([M.lng, M.lat]), b, O), q = T.pointToLineDistance(T.point([M.lng > 0 ? M.lng - 360 : M.lng + 360, M.lat]), b, O);
|
|
1650
|
+
return a.roundPrecision(Math.min(c, q), 6);
|
|
1651
1651
|
}
|
|
1652
1652
|
/**
|
|
1653
1653
|
* 计算途经点的COG, Distance等属性
|
|
@@ -1686,15 +1686,15 @@ class u {
|
|
|
1686
1686
|
*/
|
|
1687
1687
|
static mergeCoordinateToWaypoints(M, z, p = !0) {
|
|
1688
1688
|
M.lng = a.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 q = 0; q < z.length - 1; q++) {
|
|
1694
1694
|
const o = { lng: z[q].lng, lat: z[q].lat }, R = { lng: z[q + 1].lng, lat: z[q + 1].lat }, Y = this.calculatePointToLineDistance(M, o, R);
|
|
1695
|
-
O >= Y && (O = Y, A = q, b = this.calculateDistance(o, M, !1, 6),
|
|
1695
|
+
O >= Y && (O = Y, A = q, b = this.calculateDistance(o, M, !1, 6), c = this.calculateDistance(R, 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) : c === 0 && p && z.splice(A + 1, 1, M);
|
|
1698
1698
|
}
|
|
1699
1699
|
return z.map((q) => (q.lng = a.convertToStdLng(q.lng), q));
|
|
1700
1700
|
}
|
|
@@ -1721,7 +1721,7 @@ class u {
|
|
|
1721
1721
|
* @param route [[[lng, lat]]]
|
|
1722
1722
|
*/
|
|
1723
1723
|
static nearestCoordinateInRoute(M, z) {
|
|
1724
|
-
const p = T.point([M.lng, M.lat]), A = this.convertRouteToCoordinates(z).map((o) => [o.lng, o.lat]), b = T.lineString(A),
|
|
1724
|
+
const p = T.point([M.lng, M.lat]), A = this.convertRouteToCoordinates(z).map((o) => [o.lng, o.lat]), b = T.lineString(A), c = T.nearestPointOnLine(b, p), q = T.getCoord(c);
|
|
1725
1725
|
return { lng: a.roundPrecision(q[0], 8), lat: a.roundPrecision(q[1], 8) };
|
|
1726
1726
|
}
|
|
1727
1727
|
/**
|
|
@@ -1756,10 +1756,10 @@ class u {
|
|
|
1756
1756
|
static calculateNextCoordinateAlongRoute(M, z, p, O = "nauticalmiles") {
|
|
1757
1757
|
var i;
|
|
1758
1758
|
const A = M.speed || 12, b = [];
|
|
1759
|
-
let
|
|
1760
|
-
if (z && p.length ? (b.push(M), p.forEach((e,
|
|
1759
|
+
let c = [], q = !1, o = 0, R = 0, Y;
|
|
1760
|
+
if (z && p.length ? (b.push(M), p.forEach((e, u) => {
|
|
1761
1761
|
if (q)
|
|
1762
|
-
|
|
1762
|
+
c.push(e);
|
|
1763
1763
|
else {
|
|
1764
1764
|
const S = [];
|
|
1765
1765
|
let s;
|
|
@@ -1781,15 +1781,15 @@ class u {
|
|
|
1781
1781
|
q = !0;
|
|
1782
1782
|
}
|
|
1783
1783
|
}
|
|
1784
|
-
S.length &&
|
|
1784
|
+
S.length && c.push(S), u === p.length - 1 && !Y && (Y = s);
|
|
1785
1785
|
}
|
|
1786
|
-
})) : (
|
|
1787
|
-
if (b.push(Y), Y.distanceFromPrevious = R, Y.hourFromPrevious = Math.round(R / A * 1e4) / 1e4, ((i =
|
|
1788
|
-
const e = { lng:
|
|
1786
|
+
})) : (c = p, Y = { ...M }), Y)
|
|
1787
|
+
if (b.push(Y), Y.distanceFromPrevious = R, Y.hourFromPrevious = Math.round(R / A * 1e4) / 1e4, ((i = c[0]) == null ? void 0 : i.length) > 1) {
|
|
1788
|
+
const e = { lng: c[0][1][0], lat: c[0][1][1] };
|
|
1789
1789
|
Y.bearing = this.calculateBearing(Y, e);
|
|
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 u {
|
|
|
1798
1798
|
* @param to {lng, lat}
|
|
1799
1799
|
*/
|
|
1800
1800
|
static nearestCoordinateInLine(M, z, p) {
|
|
1801
|
-
const O = a.convertToStdLng(M.lng, 6), A = T.point([O, M.lat]), b = a.convertToStdLng(z.lng, 6),
|
|
1801
|
+
const O = a.convertToStdLng(M.lng, 6), A = T.point([O, M.lat]), b = a.convertToStdLng(z.lng, 6), c = a.convertToStdLng(p.lng, 6), q = T.lineString([
|
|
1802
1802
|
[b, z.lat],
|
|
1803
|
-
[
|
|
1803
|
+
[c, p.lat]
|
|
1804
1804
|
]), o = T.nearestPointOnLine(q, A), R = T.getCoord(o), Y = a.roundPrecision(R[0], 6), i = a.roundPrecision(R[1], 6);
|
|
1805
|
-
return { lng: Y, lat: i, inline: !(Y === b && i === z.lat) && !(Y ===
|
|
1805
|
+
return { lng: Y, lat: i, inline: !(Y === b && i === z.lat) && !(Y === c && i === p.lat) };
|
|
1806
1806
|
}
|
|
1807
1807
|
/**
|
|
1808
1808
|
* 将route转coordinate
|
|
@@ -1813,8 +1813,8 @@ class u {
|
|
|
1813
1813
|
const p = [];
|
|
1814
1814
|
let O, A;
|
|
1815
1815
|
return M.forEach((b) => {
|
|
1816
|
-
b.forEach((
|
|
1817
|
-
const q = { lng: a.roundPrecision(
|
|
1816
|
+
b.forEach((c) => {
|
|
1817
|
+
const q = { lng: a.roundPrecision(c[0], 8), lat: a.roundPrecision(c[1], 8) };
|
|
1818
1818
|
if (!A)
|
|
1819
1819
|
p.push(q), A = q;
|
|
1820
1820
|
else if (A.bearing === void 0)
|
|
@@ -1849,8 +1849,8 @@ class u {
|
|
|
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 o = q - 1; o >
|
|
1852
|
+
const c = M.findIndex((o) => o.lng === A.lng && o.lat === A.lat), q = M.findIndex((o) => o.lng === b.lng && o.lat === b.lat);
|
|
1853
|
+
for (let o = q - 1; o > c; o--)
|
|
1854
1854
|
M.splice(o, 1);
|
|
1855
1855
|
}
|
|
1856
1856
|
}
|
|
@@ -1867,12 +1867,12 @@ class u {
|
|
|
1867
1867
|
*/
|
|
1868
1868
|
static calculateCenter(M) {
|
|
1869
1869
|
const z = [];
|
|
1870
|
-
for (const
|
|
1871
|
-
for (const q of
|
|
1870
|
+
for (const c of M)
|
|
1871
|
+
for (const q of c)
|
|
1872
1872
|
z.push(q);
|
|
1873
1873
|
const p = T.featureCollection([]), O = a.convertToMonotonicLng2(z);
|
|
1874
|
-
for (const
|
|
1875
|
-
p.features.push(T.point(
|
|
1874
|
+
for (const c of O)
|
|
1875
|
+
p.features.push(T.point(c));
|
|
1876
1876
|
const b = T.center(p).geometry.coordinates;
|
|
1877
1877
|
return { lng: a.convertToStdLng(b[0], 8), lat: a.roundPrecision(b[1], 8) };
|
|
1878
1878
|
}
|
|
@@ -1913,11 +1913,11 @@ class u {
|
|
|
1913
1913
|
static simplifyCoordinates(M, z = 10, p = 160) {
|
|
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], q = M[A + 1];
|
|
1917
1917
|
let o = !1, R = !1;
|
|
1918
|
-
if ((b.velocity || b.suspend || b.important || b.pilot || A === 1) && (o = !0, O.push(b)),
|
|
1919
|
-
const Y =
|
|
1920
|
-
Math.round(Math.acos(
|
|
1918
|
+
if ((b.velocity || b.suspend || b.important || b.pilot || A === 1) && (o = !0, O.push(b)), c.gcToPrevious && (o || (o = !0, O.push(b)), R = !0, O.push(c), A++), q) {
|
|
1919
|
+
const Y = r.calculateDistance(b, c, !0), i = r.calculateDistance(c, q, !0), e = r.calculateDistance(b, q, !0), u = (Math.pow(Y, 2) + Math.pow(i, 2) - Math.pow(e, 2)) / (2 * Y * i);
|
|
1920
|
+
Math.round(Math.acos(u) * 180 / Math.PI) < p && e > z && !R && (O.push(c), A++);
|
|
1921
1921
|
}
|
|
1922
1922
|
if (A >= M.length - 1) {
|
|
1923
1923
|
const Y = M.at(-1);
|
|
@@ -1933,10 +1933,30 @@ class u {
|
|
|
1933
1933
|
* @param waypoints 带时间的轨迹, 单位秒
|
|
1934
1934
|
*/
|
|
1935
1935
|
static nearestTSPointInWaypoints(M, z, p) {
|
|
1936
|
-
const O =
|
|
1936
|
+
const O = C.unix(M), A = p.filter(
|
|
1937
1937
|
(b) => O.clone().subtract(z, "hour").unix() <= (b.positionTime || 0) && O.clone().add(z, "h").unix() >= (b.positionTime || 0)
|
|
1938
1938
|
);
|
|
1939
|
-
return A.sort((b,
|
|
1939
|
+
return A.sort((b, c) => (b.positionTime || 0) - (c.positionTime || 0)), A.at(-1);
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* 推测船位
|
|
1943
|
+
* @param ts 目标时间的船位,单位 s
|
|
1944
|
+
* @param positions 带时间(positionTime)的轨迹
|
|
1945
|
+
*/
|
|
1946
|
+
static deadReckoning(M, z) {
|
|
1947
|
+
var A, b;
|
|
1948
|
+
M > 1e12 && (M = Math.round(M / 1e3));
|
|
1949
|
+
const p = C.unix(M);
|
|
1950
|
+
let O = z.find((c) => c.positionTime === p.unix());
|
|
1951
|
+
if (!O) {
|
|
1952
|
+
const c = (b = (A = z.filter((o) => (o == null ? void 0 : o.positionTime) < p.unix())) == null ? void 0 : A.sort((o, R) => (o.positionTime || 0) - (R.positionTime || 0))) == null ? void 0 : b.at(-1), q = z.find((o) => (o == null ? void 0 : o.positionTime) > p.unix());
|
|
1953
|
+
if (c && q) {
|
|
1954
|
+
const o = r.calculateBearing(c, q, !0), R = r.calculateDistance(c, q), Y = (p.unix() - c.positionTime) / (q.positionTime - c.positionTime);
|
|
1955
|
+
O = r.calculateCoordinate(c, o, R * Y), O.positionTime = p.unix(), O.utc = p.format(), O.cog = o, O.sog = Math.round(R / ((q.positionTime - c.positionTime) / 3600) * 100) / 100;
|
|
1956
|
+
} else
|
|
1957
|
+
O = c || q, O && (O.utc = C.unix(O == null ? void 0 : O.positionTime).utc().format());
|
|
1958
|
+
}
|
|
1959
|
+
return O;
|
|
1940
1960
|
}
|
|
1941
1961
|
/**
|
|
1942
1962
|
* 翻转轨迹
|
|
@@ -1971,9 +1991,9 @@ class V0 {
|
|
|
1971
1991
|
const A = (p = O.history) == null ? void 0 : p[0];
|
|
1972
1992
|
A && A.wind && (A.wind.spd = A.spd, A.wind.kts = A.kts);
|
|
1973
1993
|
for (const b of O.forecasts) {
|
|
1974
|
-
const
|
|
1994
|
+
const c = [], q = C(b.date).utc(), o = `${O.name}-${b.model}`;
|
|
1975
1995
|
if (A) {
|
|
1976
|
-
const R =
|
|
1996
|
+
const R = C(A.updated).utc(), Y = T.point([A.lng, A.lat], {
|
|
1977
1997
|
model: b.model,
|
|
1978
1998
|
name: O.name,
|
|
1979
1999
|
date: R.format(),
|
|
@@ -1984,7 +2004,7 @@ class V0 {
|
|
|
1984
2004
|
category: o,
|
|
1985
2005
|
type: "forecast"
|
|
1986
2006
|
});
|
|
1987
|
-
z.features.push(Y),
|
|
2007
|
+
z.features.push(Y), c.push(Y.geometry.coordinates);
|
|
1988
2008
|
}
|
|
1989
2009
|
for (const R in b == null ? void 0 : b.hours) {
|
|
1990
2010
|
const Y = b.hours[R];
|
|
@@ -2002,10 +2022,10 @@ class V0 {
|
|
|
2002
2022
|
category: o,
|
|
2003
2023
|
type: "forecast"
|
|
2004
2024
|
});
|
|
2005
|
-
z.features.push(e),
|
|
2025
|
+
z.features.push(e), c.push(e.geometry.coordinates);
|
|
2006
2026
|
}
|
|
2007
|
-
if ((
|
|
2008
|
-
const R = T.lineString(a.convertToMonotonicLng2(
|
|
2027
|
+
if ((c == null ? void 0 : c.length) > 1) {
|
|
2028
|
+
const R = T.lineString(a.convertToMonotonicLng2(c), {
|
|
2009
2029
|
date: b.date,
|
|
2010
2030
|
id: O.id || O.name,
|
|
2011
2031
|
model: b.model,
|
|
@@ -2019,25 +2039,25 @@ class V0 {
|
|
|
2019
2039
|
}
|
|
2020
2040
|
if (O.history) {
|
|
2021
2041
|
const A = [];
|
|
2022
|
-
for (const
|
|
2023
|
-
const q =
|
|
2042
|
+
for (const c of O.history) {
|
|
2043
|
+
const q = C(c.updated).utc(), o = T.point([c.lng, c.lat], {
|
|
2024
2044
|
name: O.name,
|
|
2025
2045
|
date: q.format(),
|
|
2026
2046
|
format: q.format("MMM-DD/HHmm[Z]"),
|
|
2027
|
-
pressure:
|
|
2028
|
-
spd:
|
|
2029
|
-
kts:
|
|
2030
|
-
source:
|
|
2031
|
-
level:
|
|
2047
|
+
pressure: c.pressure > 1e4 ? a.roundPrecision(c.pressure / 100, 0) : a.roundPrecision(c.pressure, 0),
|
|
2048
|
+
spd: c.speed || c.spd,
|
|
2049
|
+
kts: c.kts,
|
|
2050
|
+
source: c.source,
|
|
2051
|
+
level: c.type,
|
|
2032
2052
|
type: "history",
|
|
2033
2053
|
category: `${O.name}-history`,
|
|
2034
|
-
wind:
|
|
2054
|
+
wind: c.wind
|
|
2035
2055
|
});
|
|
2036
2056
|
z.features.push(o), A.push(o.geometry.coordinates);
|
|
2037
2057
|
}
|
|
2038
2058
|
const b = O.history[0];
|
|
2039
2059
|
if (A.length === 1 && A.push(A[0]), A.length > 1) {
|
|
2040
|
-
const
|
|
2060
|
+
const c = T.lineString(a.convertToMonotonicLng2(A), {
|
|
2041
2061
|
name: O.name,
|
|
2042
2062
|
type: "history",
|
|
2043
2063
|
updated: b == null ? void 0 : b.updated,
|
|
@@ -2047,7 +2067,7 @@ class V0 {
|
|
|
2047
2067
|
source: b == null ? void 0 : b.source,
|
|
2048
2068
|
level: b == null ? void 0 : b.type
|
|
2049
2069
|
});
|
|
2050
|
-
z.features.push(
|
|
2070
|
+
z.features.push(c);
|
|
2051
2071
|
}
|
|
2052
2072
|
}
|
|
2053
2073
|
}
|
|
@@ -2059,18 +2079,18 @@ class V0 {
|
|
|
2059
2079
|
* @param step
|
|
2060
2080
|
*/
|
|
2061
2081
|
static interpolate(M, z = 3) {
|
|
2062
|
-
var A, b,
|
|
2082
|
+
var A, b, c, q;
|
|
2063
2083
|
const p = (A = M == null ? void 0 : M.data) == null ? void 0 : A.features.filter((o) => o.geometry.type === "LineString" && o.properties.type === "forecast"), O = [];
|
|
2064
2084
|
for (const o of p) {
|
|
2065
|
-
const R = o.properties.name, Y = o.properties.model, i = o.properties.showCircle, e = o.properties.disabled,
|
|
2066
|
-
let S = z * 60 - (
|
|
2085
|
+
const R = o.properties.name, Y = o.properties.model, i = o.properties.showCircle, e = o.properties.disabled, u = C(o.properties.date).utc();
|
|
2086
|
+
let S = z * 60 - (u.get("hour") * 60 + u.get("minute")) % (z * 60);
|
|
2067
2087
|
const s = (b = M == null ? void 0 : M.data) == null ? void 0 : b.features.filter(
|
|
2068
2088
|
(l) => l.geometry.type === "Point" && l.properties.type === "forecast" && l.properties.category === `${R}-${Y}`
|
|
2069
2089
|
);
|
|
2070
|
-
let P, G =
|
|
2090
|
+
let P, G = u.clone().add(S, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2071
2091
|
for (; P = this.pickIndex(s, G), P <= s.length - 1; ) {
|
|
2072
2092
|
if (P > 0) {
|
|
2073
|
-
const l = s[P], N = P === 0 ? void 0 : s[P - 1], I = (S / 60 - ((
|
|
2093
|
+
const l = s[P], N = P === 0 ? void 0 : s[P - 1], I = (S / 60 - ((c = N == null ? void 0 : N.properties) == null ? void 0 : c.hour)) / (l.properties.hour - ((q = N == null ? void 0 : N.properties) == null ? void 0 : q.hour)), H = this.computeNumber(N == null ? void 0 : N.geometry.coordinates[0], l.geometry.coordinates[0], I), Q = this.computeNumber(N == null ? void 0 : N.geometry.coordinates[1], l.geometry.coordinates[1], I), F = T.point([H, Q], {
|
|
2074
2094
|
name: R,
|
|
2075
2095
|
model: Y,
|
|
2076
2096
|
category: l == null ? void 0 : l.properties.category,
|
|
@@ -2087,7 +2107,7 @@ class V0 {
|
|
|
2087
2107
|
});
|
|
2088
2108
|
O.push(F);
|
|
2089
2109
|
}
|
|
2090
|
-
S += z * 60, G =
|
|
2110
|
+
S += z * 60, G = u.clone().add(S, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2091
2111
|
}
|
|
2092
2112
|
}
|
|
2093
2113
|
return O;
|
|
@@ -2114,22 +2134,22 @@ class V0 {
|
|
|
2114
2134
|
* @param options
|
|
2115
2135
|
*/
|
|
2116
2136
|
static diversionPassageAt(M, z, p, O = {}) {
|
|
2117
|
-
const { t1: A, t2: b, hr:
|
|
2137
|
+
const { t1: A, t2: b, hr: c, hours: q } = this.tropicalCenterTwin(z, 24, O);
|
|
2118
2138
|
if (A && b) {
|
|
2119
2139
|
if (!O.debug) {
|
|
2120
|
-
const
|
|
2121
|
-
if (
|
|
2122
|
-
return Z == null || Z.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", O.requestId,
|
|
2140
|
+
const u = r.calculateDistance(M, A), S = r.calculateDistance(M, b);
|
|
2141
|
+
if (u > 2 * p && S > 2 * p)
|
|
2142
|
+
return Z == null || Z.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", O.requestId, u, S, {
|
|
2123
2143
|
from: M,
|
|
2124
2144
|
t1: A,
|
|
2125
2145
|
t2: b,
|
|
2126
|
-
hr:
|
|
2146
|
+
hr: c
|
|
2127
2147
|
}), {};
|
|
2128
2148
|
}
|
|
2129
|
-
const o =
|
|
2149
|
+
const o = r.calculateBearing(M, A), R = r.calculateBearing(A, b), Y = Math.abs(o - R);
|
|
2130
2150
|
let i = 0;
|
|
2131
2151
|
Y < 180 ? i = Y + 90 : Y >= 180 && (i = Y - 90);
|
|
2132
|
-
const e =
|
|
2152
|
+
const e = r.calculateCoordinate(A, i, p);
|
|
2133
2153
|
return Z == null || Z.info("[%s] the right tangent position: %j", O.requestId, {
|
|
2134
2154
|
from: M,
|
|
2135
2155
|
t1: A,
|
|
@@ -2138,7 +2158,7 @@ class V0 {
|
|
|
2138
2158
|
bearing1: o,
|
|
2139
2159
|
bearing2: R,
|
|
2140
2160
|
right: e
|
|
2141
|
-
}), { at: e, t1: A, t2: b, hr: Number(
|
|
2161
|
+
}), { at: e, t1: A, t2: b, hr: Number(c), hours: q };
|
|
2142
2162
|
}
|
|
2143
2163
|
return {};
|
|
2144
2164
|
}
|
|
@@ -2153,22 +2173,22 @@ class V0 {
|
|
|
2153
2173
|
* @param options
|
|
2154
2174
|
*/
|
|
2155
2175
|
static driftPassageAt(M, z, p, O = {}) {
|
|
2156
|
-
const { t1: A, t2: b, hr:
|
|
2176
|
+
const { t1: A, t2: b, hr: c, hours: q } = this.tropicalCenterTwin(z, 24, O);
|
|
2157
2177
|
if (A && b) {
|
|
2158
2178
|
if (!O.debug) {
|
|
2159
|
-
const e =
|
|
2160
|
-
if (e > 2 * p &&
|
|
2161
|
-
return Z == null || Z.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", O.requestId, e,
|
|
2179
|
+
const e = r.calculateDistance(M, A), u = r.calculateDistance(M, b);
|
|
2180
|
+
if (e > 2 * p && u > 2 * p)
|
|
2181
|
+
return Z == null || Z.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", O.requestId, e, u, {
|
|
2162
2182
|
from: M,
|
|
2163
2183
|
t1: A,
|
|
2164
2184
|
t2: b,
|
|
2165
|
-
hr:
|
|
2185
|
+
hr: c
|
|
2166
2186
|
}), {};
|
|
2167
2187
|
}
|
|
2168
|
-
const o =
|
|
2169
|
-
return { at:
|
|
2188
|
+
const o = r.calculateBearing(M, A), R = r.calculateBearing(A, b), Y = r.calculateDistance(M, A);
|
|
2189
|
+
return { at: r.calculateCoordinate(A, o - R + 180, p < Y ? p : Y), t1: A, t2: b, hr: Number(c), hours: q };
|
|
2170
2190
|
} else
|
|
2171
|
-
return Z == null || Z.info("[%s] no need drift: %j", O.requestId, { from: M, t1: A, t2: b, hr:
|
|
2191
|
+
return Z == null || Z.info("[%s] no need drift: %j", O.requestId, { from: M, t1: A, t2: b, hr: c }), {};
|
|
2172
2192
|
}
|
|
2173
2193
|
/**
|
|
2174
2194
|
* 获取台风中心点对
|
|
@@ -2179,7 +2199,7 @@ class V0 {
|
|
|
2179
2199
|
* @private
|
|
2180
2200
|
*/
|
|
2181
2201
|
static tropicalCenterTwin(M, z = 24, p = {}) {
|
|
2182
|
-
var R, Y, i, e,
|
|
2202
|
+
var R, Y, i, e, u;
|
|
2183
2203
|
let O = {};
|
|
2184
2204
|
(R = M.forecasts) == null || R.forEach((S) => {
|
|
2185
2205
|
O = { ...S.hours, ...O };
|
|
@@ -2187,18 +2207,18 @@ class V0 {
|
|
|
2187
2207
|
const A = ((Y = M == null ? void 0 : M.history) == null ? void 0 : Y[0]) || (O == null ? void 0 : O[(i = Object.keys(O)) == null ? void 0 : i[0]]);
|
|
2188
2208
|
Z == null || Z.info("[%s] the first tropical center: %j", p.requestId, A);
|
|
2189
2209
|
let b = (e = Object.keys(O || {}).filter((S) => Number(S) <= (z < 0 ? 24 : z))) == null ? void 0 : e.at(-1);
|
|
2190
|
-
b || (b = (
|
|
2191
|
-
const
|
|
2192
|
-
Z == null || Z.info("[%s] the second tropical center: %j in %d hrs", p.requestId,
|
|
2210
|
+
b || (b = (u = Object.keys(O || {}).filter((S) => Number(S) <= (z < 0 ? 24 : 2 * z))) == null ? void 0 : u.at(-1));
|
|
2211
|
+
const c = O == null ? void 0 : O[b || -1];
|
|
2212
|
+
Z == null || Z.info("[%s] the second tropical center: %j in %d hrs", p.requestId, c, b);
|
|
2193
2213
|
const q = Object.keys(O || {}).filter((S) => Number(S) <= Number(b)), o = { 0: A };
|
|
2194
2214
|
for (const S of q)
|
|
2195
2215
|
o[S] = O[S];
|
|
2196
|
-
return { t1: A, t2:
|
|
2216
|
+
return { t1: A, t2: c, hr: Number(b), hours: o };
|
|
2197
2217
|
}
|
|
2198
2218
|
static pickIndex(M, z) {
|
|
2199
2219
|
let p = 0;
|
|
2200
2220
|
for (const O of M) {
|
|
2201
|
-
if (
|
|
2221
|
+
if (C(O.properties.date).isAfter(z))
|
|
2202
2222
|
return p === 0 ? -1 : p;
|
|
2203
2223
|
p++;
|
|
2204
2224
|
}
|
|
@@ -2226,14 +2246,14 @@ class t0 {
|
|
|
2226
2246
|
return `${M.lat}|${M.lng}|${M.positionTime}|${M.sog}|${M.cog}|${M.hdg}|${M.draught}|${z}|${JSON.stringify(M.meteo || {})}|${M.vendor}|${M.deleted}`;
|
|
2227
2247
|
}
|
|
2228
2248
|
static str2Json(M) {
|
|
2229
|
-
const [z, p, O, A, b,
|
|
2249
|
+
const [z, p, O, A, b, c, q, o, R, Y, i] = M.split("|");
|
|
2230
2250
|
return {
|
|
2231
2251
|
lat: Number(z),
|
|
2232
2252
|
lng: Number(p),
|
|
2233
2253
|
positionTime: Number(O),
|
|
2234
2254
|
sog: Number(A),
|
|
2235
2255
|
cog: Number(b),
|
|
2236
|
-
hdg: Number(
|
|
2256
|
+
hdg: Number(c),
|
|
2237
2257
|
//@ts-ignore
|
|
2238
2258
|
draught: isNaN(q) ? null : Number(q),
|
|
2239
2259
|
type: o,
|
|
@@ -2249,7 +2269,7 @@ class t0 {
|
|
|
2249
2269
|
for (let A = 0; A < M.length - 1; A++) {
|
|
2250
2270
|
const b = M[A];
|
|
2251
2271
|
if (b.sog = b.sog || 0, b.sog < z) {
|
|
2252
|
-
const
|
|
2272
|
+
const c = b;
|
|
2253
2273
|
let q = M.at(-1);
|
|
2254
2274
|
for (let o = A + 1; o < M.length; o++) {
|
|
2255
2275
|
const R = M[o];
|
|
@@ -2261,24 +2281,24 @@ class t0 {
|
|
|
2261
2281
|
break;
|
|
2262
2282
|
}
|
|
2263
2283
|
}
|
|
2264
|
-
if (q.positionTime !=
|
|
2284
|
+
if (q.positionTime != c.positionTime) {
|
|
2265
2285
|
const o = {
|
|
2266
2286
|
start: {
|
|
2267
|
-
lat:
|
|
2268
|
-
lng:
|
|
2269
|
-
sog:
|
|
2270
|
-
positionTime:
|
|
2271
|
-
utc:
|
|
2287
|
+
lat: c.lat,
|
|
2288
|
+
lng: c.lng,
|
|
2289
|
+
sog: c.sog,
|
|
2290
|
+
positionTime: c.positionTime,
|
|
2291
|
+
utc: C.unix(c.positionTime).utc().format()
|
|
2272
2292
|
},
|
|
2273
2293
|
end: {
|
|
2274
2294
|
lat: q.lat,
|
|
2275
2295
|
lng: q.lng,
|
|
2276
2296
|
sog: q.sog,
|
|
2277
2297
|
positionTime: q.positionTime,
|
|
2278
|
-
utc:
|
|
2298
|
+
utc: C.unix(q.positionTime).utc().format()
|
|
2279
2299
|
},
|
|
2280
|
-
duration: q.positionTime -
|
|
2281
|
-
distance:
|
|
2300
|
+
duration: q.positionTime - c.positionTime,
|
|
2301
|
+
distance: r.calculateDistance(c, q, !0, 4),
|
|
2282
2302
|
avgSog: 0
|
|
2283
2303
|
};
|
|
2284
2304
|
o.avgSog = Math.round(o.distance / (o.duration / 3600) * 100) / 100, O.push(o);
|
|
@@ -2290,7 +2310,7 @@ class t0 {
|
|
|
2290
2310
|
}
|
|
2291
2311
|
export {
|
|
2292
2312
|
t0 as AisHelper,
|
|
2293
|
-
|
|
2313
|
+
r as LaneHelper,
|
|
2294
2314
|
a as LngLatHelper,
|
|
2295
2315
|
V0 as TropicalHelper
|
|
2296
2316
|
};
|