@idm-plugin/geo 1.6.6 → 1.6.8
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 +302 -302
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as i from "@turf/turf";
|
|
2
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 : {};
|
|
@@ -16,135 +16,135 @@ var j = { exports: {} };
|
|
|
16
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 = {}, W = {}, 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
|
|
24
|
-
return
|
|
23
|
+
function L(c) {
|
|
24
|
+
return c > 96 ? c - 87 : c > 64 ? c - 29 : c - 48;
|
|
25
25
|
}
|
|
26
|
-
function e(
|
|
27
|
-
var d = 0, X =
|
|
28
|
-
for (
|
|
29
|
-
t =
|
|
30
|
-
for (d = 0; d <
|
|
31
|
-
f = f / 60, t =
|
|
26
|
+
function e(c) {
|
|
27
|
+
var d = 0, X = c.split("."), n = X[0], T = X[1] || "", f = 1, t, B = 0, V = 1;
|
|
28
|
+
for (c.charCodeAt(0) === 45 && (d = 1, V = -1), d; d < n.length; d++)
|
|
29
|
+
t = L(n.charCodeAt(d)), B = 60 * B + t;
|
|
30
|
+
for (d = 0; d < T.length; d++)
|
|
31
|
+
f = f / 60, t = L(T.charCodeAt(d)), B += t * f;
|
|
32
32
|
return B * V;
|
|
33
33
|
}
|
|
34
|
-
function u(
|
|
35
|
-
for (var d = 0; d <
|
|
36
|
-
|
|
34
|
+
function u(c) {
|
|
35
|
+
for (var d = 0; d < c.length; d++)
|
|
36
|
+
c[d] = e(c[d]);
|
|
37
37
|
}
|
|
38
|
-
function S(
|
|
38
|
+
function S(c, d) {
|
|
39
39
|
for (var X = 0; X < d; X++)
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
c[X] = Math.round((c[X - 1] || 0) + c[X] * 6e4);
|
|
41
|
+
c[d - 1] = 1 / 0;
|
|
42
42
|
}
|
|
43
|
-
function s(
|
|
43
|
+
function s(c, d) {
|
|
44
44
|
var X = [], n;
|
|
45
45
|
for (n = 0; n < d.length; n++)
|
|
46
|
-
X[n] =
|
|
46
|
+
X[n] = c[d[n]];
|
|
47
47
|
return X;
|
|
48
48
|
}
|
|
49
|
-
function P(
|
|
50
|
-
var d =
|
|
51
|
-
return u(X), u(n), u(
|
|
49
|
+
function P(c) {
|
|
50
|
+
var d = c.split("|"), X = d[2].split(" "), n = d[3].split(""), T = d[4].split(" ");
|
|
51
|
+
return u(X), u(n), u(T), S(T, n.length), {
|
|
52
52
|
name: d[0],
|
|
53
53
|
abbrs: s(d[1].split(" "), n),
|
|
54
54
|
offsets: s(X, n),
|
|
55
|
-
untils:
|
|
55
|
+
untils: T,
|
|
56
56
|
population: d[5] | 0
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function G(
|
|
60
|
-
|
|
59
|
+
function G(c) {
|
|
60
|
+
c && this._set(P(c));
|
|
61
61
|
}
|
|
62
|
-
function l(
|
|
62
|
+
function l(c, d) {
|
|
63
63
|
var X = d.length;
|
|
64
|
-
if (
|
|
64
|
+
if (c < d[0])
|
|
65
65
|
return 0;
|
|
66
|
-
if (X > 1 && d[X - 1] === 1 / 0 &&
|
|
66
|
+
if (X > 1 && d[X - 1] === 1 / 0 && c >= d[X - 2])
|
|
67
67
|
return X - 1;
|
|
68
|
-
if (
|
|
68
|
+
if (c >= d[X - 1])
|
|
69
69
|
return -1;
|
|
70
|
-
for (var n,
|
|
71
|
-
n = Math.floor((
|
|
70
|
+
for (var n, T = 0, f = X - 1; f - T > 1; )
|
|
71
|
+
n = Math.floor((T + f) / 2), d[n] <= c ? T = n : f = n;
|
|
72
72
|
return f;
|
|
73
73
|
}
|
|
74
74
|
G.prototype = {
|
|
75
|
-
_set: function(
|
|
76
|
-
this.name =
|
|
75
|
+
_set: function(c) {
|
|
76
|
+
this.name = c.name, this.abbrs = c.abbrs, this.untils = c.untils, this.offsets = c.offsets, this.population = c.population;
|
|
77
77
|
},
|
|
78
|
-
_index: function(
|
|
79
|
-
var d = +
|
|
78
|
+
_index: function(c) {
|
|
79
|
+
var d = +c, 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 c = this.name;
|
|
85
85
|
return Object.keys(A).filter(function(d) {
|
|
86
|
-
return A[d].zones.indexOf(
|
|
86
|
+
return A[d].zones.indexOf(c) !== -1;
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
|
-
parse: function(
|
|
90
|
-
var d = +
|
|
91
|
-
for (V = 0; V <
|
|
89
|
+
parse: function(c) {
|
|
90
|
+
var d = +c, X = this.offsets, n = this.untils, T = n.length - 1, f, t, B, V;
|
|
91
|
+
for (V = 0; V < T; V++)
|
|
92
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
|
-
return X[
|
|
94
|
+
return X[T];
|
|
95
95
|
},
|
|
96
|
-
abbr: function(
|
|
97
|
-
return this.abbrs[this._index(
|
|
96
|
+
abbr: function(c) {
|
|
97
|
+
return this.abbrs[this._index(c)];
|
|
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(c) {
|
|
100
|
+
return D("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(c)];
|
|
101
101
|
},
|
|
102
|
-
utcOffset: function(
|
|
103
|
-
return this.offsets[this._index(
|
|
102
|
+
utcOffset: function(c) {
|
|
103
|
+
return this.offsets[this._index(c)];
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
function N(
|
|
107
|
-
this.name =
|
|
106
|
+
function N(c, d) {
|
|
107
|
+
this.name = c, 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(c) {
|
|
110
|
+
var d = c.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 = +c, this.abbr = X, this.offset = c.getTimezoneOffset();
|
|
112
112
|
}
|
|
113
|
-
function H(
|
|
114
|
-
this.zone =
|
|
113
|
+
function H(c) {
|
|
114
|
+
this.zone = c, 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(c) {
|
|
117
|
+
this.offsetScore += Math.abs(this.zone.utcOffset(c.at) - c.offset), this.zone.abbr(c.at).replace(/[^A-Z]/g, "") !== c.abbr && this.abbrScore++;
|
|
118
118
|
};
|
|
119
|
-
function Q(
|
|
120
|
-
for (var X, n; n = ((d.at -
|
|
121
|
-
X = new I(new Date(
|
|
122
|
-
return
|
|
119
|
+
function Q(c, d) {
|
|
120
|
+
for (var X, n; n = ((d.at - c.at) / 12e4 | 0) * 6e4; )
|
|
121
|
+
X = new I(new Date(c.at + n)), X.offset === c.offset ? c = X : d = X;
|
|
122
|
+
return c;
|
|
123
123
|
}
|
|
124
124
|
function F() {
|
|
125
|
-
var
|
|
125
|
+
var c = (/* @__PURE__ */ new Date()).getFullYear() - 2, d = new I(new Date(c, 0, 1)), X = d.offset, n = [d], T, f, t, B;
|
|
126
126
|
for (B = 1; B < 48; B++)
|
|
127
|
-
t = new Date(
|
|
127
|
+
t = new Date(c, B, 1).getTimezoneOffset(), t !== X && (f = new I(new Date(c, B, 1)), T = Q(d, f), n.push(T), n.push(new I(new Date(T.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(c + B, 0, 1))), n.push(new I(new Date(c + B, 6, 1)));
|
|
130
130
|
return n;
|
|
131
131
|
}
|
|
132
|
-
function M0(
|
|
133
|
-
return
|
|
132
|
+
function M0(c, d) {
|
|
133
|
+
return c.offsetScore !== d.offsetScore ? c.offsetScore - d.offsetScore : c.abbrScore !== d.abbrScore ? c.abbrScore - d.abbrScore : c.zone.population !== d.zone.population ? d.zone.population - c.zone.population : d.zone.name.localeCompare(c.zone.name);
|
|
134
134
|
}
|
|
135
|
-
function z0(
|
|
135
|
+
function z0(c, d) {
|
|
136
136
|
var X, n;
|
|
137
137
|
for (u(d), X = 0; X < d.length; X++)
|
|
138
|
-
n = d[X],
|
|
138
|
+
n = d[X], W[n] = W[n] || {}, W[n][c] = !0;
|
|
139
139
|
}
|
|
140
|
-
function b0(
|
|
141
|
-
var d =
|
|
140
|
+
function b0(c) {
|
|
141
|
+
var d = c.length, X = {}, n = [], T = {}, f, t, B, V;
|
|
142
142
|
for (f = 0; f < d; f++)
|
|
143
|
-
if (B =
|
|
144
|
-
V =
|
|
143
|
+
if (B = c[f].offset, !T.hasOwnProperty(B)) {
|
|
144
|
+
V = W[B] || {};
|
|
145
145
|
for (t in V)
|
|
146
146
|
V.hasOwnProperty(t) && (X[t] = !0);
|
|
147
|
-
|
|
147
|
+
T[B] = !0;
|
|
148
148
|
}
|
|
149
149
|
for (f in X)
|
|
150
150
|
X.hasOwnProperty(f) && n.push(b[f]);
|
|
@@ -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 c = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
156
|
+
if (c && c.length > 3) {
|
|
157
|
+
var d = b[K(c)];
|
|
158
158
|
if (d)
|
|
159
159
|
return d;
|
|
160
|
-
D("Moment Timezone found " +
|
|
160
|
+
D("Moment Timezone found " + c + " from the Intl api, but did not have that data loaded.");
|
|
161
161
|
}
|
|
162
162
|
} catch {
|
|
163
163
|
}
|
|
164
|
-
var X = F(), n = X.length,
|
|
165
|
-
for (B = 0; B <
|
|
166
|
-
for (t = new H(g(
|
|
164
|
+
var X = F(), n = X.length, T = b0(X), f = [], t, B, V;
|
|
165
|
+
for (B = 0; B < T.length; B++) {
|
|
166
|
+
for (t = new H(g(T[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(c) {
|
|
173
|
+
return (!q || c) && (q = p0()), q;
|
|
174
174
|
}
|
|
175
|
-
function K(
|
|
176
|
-
return (
|
|
175
|
+
function K(c) {
|
|
176
|
+
return (c || "").toLowerCase().replace(/\//g, "_");
|
|
177
177
|
}
|
|
178
|
-
function k(
|
|
179
|
-
var d, X, n,
|
|
180
|
-
for (typeof
|
|
181
|
-
n =
|
|
178
|
+
function k(c) {
|
|
179
|
+
var d, X, n, T;
|
|
180
|
+
for (typeof c == "string" && (c = [c]), d = 0; d < c.length; d++)
|
|
181
|
+
n = c[d].split("|"), X = n[0], T = K(X), p[T] = c[d], b[T] = X, z0(T, n[2].split(" "));
|
|
182
182
|
}
|
|
183
|
-
function g(
|
|
184
|
-
|
|
185
|
-
var X = p[
|
|
186
|
-
return X instanceof G ? X : typeof X == "string" ? (X = new G(X), p[
|
|
183
|
+
function g(c, d) {
|
|
184
|
+
c = K(c);
|
|
185
|
+
var X = p[c], n;
|
|
186
|
+
return X instanceof G ? X : typeof X == "string" ? (X = new G(X), p[c] = X, X) : O[c] && d !== g && (n = g(O[c], g)) ? (X = p[c] = new G(), X._set(n), X.name = b[c], X) : null;
|
|
187
187
|
}
|
|
188
188
|
function A0() {
|
|
189
|
-
var
|
|
190
|
-
for (
|
|
191
|
-
b.hasOwnProperty(
|
|
189
|
+
var c, d = [];
|
|
190
|
+
for (c in b)
|
|
191
|
+
b.hasOwnProperty(c) && (p[c] || p[O[c]]) && b[c] && d.push(b[c]);
|
|
192
192
|
return d.sort();
|
|
193
193
|
}
|
|
194
194
|
function c0() {
|
|
195
195
|
return Object.keys(A);
|
|
196
196
|
}
|
|
197
|
-
function v(
|
|
198
|
-
var d, X, n,
|
|
199
|
-
for (typeof
|
|
200
|
-
X =
|
|
197
|
+
function v(c) {
|
|
198
|
+
var d, X, n, T;
|
|
199
|
+
for (typeof c == "string" && (c = [c]), d = 0; d < c.length; d++)
|
|
200
|
+
X = c[d].split("|"), n = K(X[0]), T = K(X[1]), O[n] = T, b[n] = X[0], O[T] = n, b[T] = X[1];
|
|
201
201
|
}
|
|
202
|
-
function W0(
|
|
203
|
-
var d, X, n,
|
|
204
|
-
if (!(!
|
|
205
|
-
for (d = 0; d <
|
|
206
|
-
|
|
202
|
+
function W0(c) {
|
|
203
|
+
var d, X, n, T;
|
|
204
|
+
if (!(!c || !c.length))
|
|
205
|
+
for (d = 0; d < c.length; d++)
|
|
206
|
+
T = c[d].split("|"), X = T[0].toUpperCase(), n = T[1].split(" "), A[X] = new N(
|
|
207
207
|
X,
|
|
208
208
|
n
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
|
-
function q0(
|
|
212
|
-
return
|
|
211
|
+
function q0(c) {
|
|
212
|
+
return c = c.toUpperCase(), A[c] || null;
|
|
213
213
|
}
|
|
214
|
-
function o0(
|
|
215
|
-
if (
|
|
214
|
+
function o0(c, d) {
|
|
215
|
+
if (c = q0(c), !c)
|
|
216
216
|
return null;
|
|
217
|
-
var X =
|
|
217
|
+
var X = c.zones.sort();
|
|
218
218
|
return d ? X.map(function(n) {
|
|
219
|
-
var
|
|
219
|
+
var T = g(n);
|
|
220
220
|
return {
|
|
221
221
|
name: n,
|
|
222
|
-
offset:
|
|
222
|
+
offset: T.utcOffset(/* @__PURE__ */ new Date())
|
|
223
223
|
};
|
|
224
224
|
}) : X;
|
|
225
225
|
}
|
|
226
|
-
function Y0(
|
|
227
|
-
k(
|
|
226
|
+
function Y0(c) {
|
|
227
|
+
k(c.zones), v(c.links), W0(c.countries), U.dataVersion = c.version;
|
|
228
228
|
}
|
|
229
|
-
function $(
|
|
230
|
-
return $.didShowError || ($.didShowError = !0, D("moment.tz.zoneExists('" +
|
|
229
|
+
function $(c) {
|
|
230
|
+
return $.didShowError || ($.didShowError = !0, D("moment.tz.zoneExists('" + c + "') has been deprecated in favor of !moment.tz.zone('" + c + "')")), !!g(c);
|
|
231
231
|
}
|
|
232
|
-
function J(
|
|
233
|
-
var d =
|
|
234
|
-
return !!(
|
|
232
|
+
function J(c) {
|
|
233
|
+
var d = c._f === "X" || c._f === "x";
|
|
234
|
+
return !!(c._a && c._tzm === void 0 && !d);
|
|
235
235
|
}
|
|
236
|
-
function D(
|
|
237
|
-
typeof console < "u" && typeof console.error == "function" && console.error(
|
|
236
|
+
function D(c) {
|
|
237
|
+
typeof console < "u" && typeof console.error == "function" && console.error(c);
|
|
238
238
|
}
|
|
239
|
-
function U(
|
|
240
|
-
var d = Array.prototype.slice.call(arguments, 0, -1), X = arguments[arguments.length - 1], n = M.utc.apply(null, d),
|
|
241
|
-
return !M.isMoment(
|
|
239
|
+
function U(c) {
|
|
240
|
+
var d = Array.prototype.slice.call(arguments, 0, -1), X = arguments[arguments.length - 1], n = M.utc.apply(null, d), T;
|
|
241
|
+
return !M.isMoment(c) && J(n) && (T = g(X)) && n.add(T.parse(n), "minutes"), n.tz(X), n;
|
|
242
242
|
}
|
|
243
243
|
U.version = z, U.dataVersion = "", U._zones = p, U._links = O, U._names = b, U._countries = A, U.add = k, U.link = v, U.load = Y0, U.zone = g, U.zoneExists = $, U.guess = O0, U.names = A0, U.Zone = G, U.unpack = P, U.unpackBase60 = e, U.needsOffset = J, U.moveInvalidForward = !0, U.moveAmbiguousForward = !1, U.countries = c0, U.zonesForCountry = o0;
|
|
244
244
|
var m = M.fn;
|
|
245
|
-
M.tz = U, M.defaultZone = null, M.updateOffset = function(
|
|
245
|
+
M.tz = U, M.defaultZone = null, M.updateOffset = function(c, d) {
|
|
246
246
|
var X = M.defaultZone, n;
|
|
247
|
-
if (
|
|
248
|
-
if (n =
|
|
249
|
-
var
|
|
250
|
-
|
|
247
|
+
if (c._z === void 0 && (X && J(c) && !c._isUTC && c.isValid() && (c._d = M.utc(c._a)._d, c.utc().add(X.parse(c), "minutes")), c._z = X), c._z)
|
|
248
|
+
if (n = c._z.utcOffset(c), Math.abs(n) < 16 && (n = n / 60), c.utcOffset !== void 0) {
|
|
249
|
+
var T = c._z;
|
|
250
|
+
c.utcOffset(-n, d), c._z = T;
|
|
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
|
+
c.zone(n, d);
|
|
253
|
+
}, m.tz = function(c, d) {
|
|
254
|
+
if (c) {
|
|
255
|
+
if (typeof c != "string")
|
|
256
|
+
throw new Error("Time zone name must be a string, got " + c + " [" + typeof c + "]");
|
|
257
|
+
return this._z = g(c), this._z ? M.updateOffset(this, d) : D("Moment Timezone has no data for " + c + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
|
|
258
258
|
}
|
|
259
259
|
if (this._z)
|
|
260
260
|
return this._z.name;
|
|
261
261
|
};
|
|
262
|
-
function y(
|
|
262
|
+
function y(c) {
|
|
263
263
|
return function() {
|
|
264
|
-
return this._z ? this._z.abbr(this) :
|
|
264
|
+
return this._z ? this._z.abbr(this) : c.call(this);
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
|
-
function w(
|
|
267
|
+
function w(c) {
|
|
268
268
|
return function() {
|
|
269
|
-
return this._z = null,
|
|
269
|
+
return this._z = null, c.apply(this, arguments);
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
|
-
function d0(
|
|
272
|
+
function d0(c) {
|
|
273
273
|
return function() {
|
|
274
|
-
return arguments.length > 0 && (this._z = null),
|
|
274
|
+
return arguments.length > 0 && (this._z = null), c.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 (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(c) {
|
|
278
|
+
return (R < 2 || R === 2 && Y < 9) && D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = c ? g(c) : null, M;
|
|
279
279
|
};
|
|
280
280
|
var h = M.momentProperties;
|
|
281
281
|
return Object.prototype.toString.call(h) === "[object Array]" ? (h.push("_z"), h.push("_a")) : h && (h._z = null), M;
|
|
@@ -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, W = 48 * (180 + p) / 360.00000000000006, q = 24 * (90 - z) / 180.00000000000003, o = 0 | W, 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 | (W = 2 * (W - o) % 2)) + 2304) + O.charCodeAt(Y + 1) - 1995;
|
|
1150
1150
|
return A[Y + A.length - 3136];
|
|
1151
1151
|
}
|
|
1152
1152
|
E.exports = M;
|
|
@@ -1176,15 +1176,15 @@ 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
|
|
1179
|
+
let A = M * 3600, b, W, q, o, R, Y;
|
|
1180
|
+
b = A % 3600 % 60, p.indexOf("S") !== -1 && (A = A - b, W = 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(W) >= 60 && (o = Number(o) + 1, W = 0), Number(o) >= 60 && (Y = Number(Y) + 1, o = 0);
|
|
1181
|
+
const L = `${p.replace(/S+/gi, W).replace(/M+/gi, o).replace(/H+/gi, Y)}${O}`;
|
|
1182
1182
|
return {
|
|
1183
1183
|
direction: O,
|
|
1184
1184
|
degree: a.roundPrecision(R, z),
|
|
1185
1185
|
minute: a.roundPrecision(q, z),
|
|
1186
1186
|
second: a.roundPrecision(b, z),
|
|
1187
|
-
pretty:
|
|
1187
|
+
pretty: L
|
|
1188
1188
|
};
|
|
1189
1189
|
}
|
|
1190
1190
|
/**
|
|
@@ -1197,15 +1197,15 @@ 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
|
|
1200
|
+
let A = M * 3600, b, W, q, o, R, Y;
|
|
1201
|
+
b = A % 3600 % 60, p.indexOf("S") !== -1 && (A = A - b, W = 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(W) >= 60 && (o = Number(o) + 1, W = 0), Number(o) >= 60 && (Y = Number(Y) + 1, o = 0);
|
|
1202
|
+
const L = `${p.replace(/S+/gi, W).replace(/M+/gi, o).replace(/H+/gi, Y)}${O}`;
|
|
1203
1203
|
return {
|
|
1204
1204
|
direction: O,
|
|
1205
1205
|
degree: a.roundPrecision(R, z),
|
|
1206
1206
|
minute: a.roundPrecision(q, z),
|
|
1207
1207
|
second: a.roundPrecision(b, z),
|
|
1208
|
-
pretty:
|
|
1208
|
+
pretty: L
|
|
1209
1209
|
};
|
|
1210
1210
|
}
|
|
1211
1211
|
static str2Lng(M, z = 6) {
|
|
@@ -1214,13 +1214,13 @@ class a {
|
|
|
1214
1214
|
M = a.strReplace(M, "LNG");
|
|
1215
1215
|
const O = M[M.length - 1].toUpperCase();
|
|
1216
1216
|
M = M.substring(0, M.length - 1).trim();
|
|
1217
|
-
const A = M.split(" ").filter((q) => q !== "").map((q) => Number(q));
|
|
1218
|
-
let [b,
|
|
1219
|
-
if (
|
|
1217
|
+
const A = M.split(" ").filter((q) => q !== "").map((q) => Math.abs(Number(q)));
|
|
1218
|
+
let [b, W] = A;
|
|
1219
|
+
if (W = W > 60 ? W / Math.pow(10, String(W).length - 2) : W, b > 360 && !W) {
|
|
1220
1220
|
const q = this.roundPrecision(b / 100, 0);
|
|
1221
|
-
|
|
1221
|
+
W = b - q * 100, b = q;
|
|
1222
1222
|
}
|
|
1223
|
-
p = b + (
|
|
1223
|
+
p = b + (W ?? 0) / 60, O === "W" && (p = p * -1);
|
|
1224
1224
|
} else
|
|
1225
1225
|
p = Number(M);
|
|
1226
1226
|
return a.convertToStdLng(p, z);
|
|
@@ -1231,13 +1231,13 @@ class a {
|
|
|
1231
1231
|
M = a.strReplace(M, "LAT");
|
|
1232
1232
|
const O = M[M.length - 1].toUpperCase();
|
|
1233
1233
|
M = M.substring(0, M.length - 1).trim();
|
|
1234
|
-
const A = M.split(" ").filter((q) => q !== "").map((q) => Number(q));
|
|
1235
|
-
let [b,
|
|
1236
|
-
if (
|
|
1234
|
+
const A = M.split(" ").filter((q) => q !== "").map((q) => Math.abs(Number(q)));
|
|
1235
|
+
let [b, W] = A;
|
|
1236
|
+
if (W = W > 60 ? W / Math.pow(10, String(W).length - 2) : W, b > 90 && !W) {
|
|
1237
1237
|
const q = this.roundPrecision(b / 100, 0);
|
|
1238
|
-
|
|
1238
|
+
W = b - q * 100, b = q;
|
|
1239
1239
|
}
|
|
1240
|
-
if (p = b + (
|
|
1240
|
+
if (p = b + (W ?? 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
|
|
@@ -1282,7 +1282,7 @@ class a {
|
|
|
1282
1282
|
return M;
|
|
1283
1283
|
}
|
|
1284
1284
|
static strReplace(M, z = "LAT") {
|
|
1285
|
-
M = M.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g, "$1 $2").replace(
|
|
1285
|
+
M = M.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g, "$1 $2").replace(/([0-9]+)-([0-9]+\.[0-9]+)/g, "$1 $2").replace(/°/, " ").replace(/'/g, " ").replace(/′/g, " ").replace(/"/g, " ").replace(/∼/g, " ").replace(/°/g, " ").replace(/,/g, ".").replace(/^ /g, "").replace(/ $/g, "").trim();
|
|
1286
1286
|
const p = M[M.length - 1].toUpperCase();
|
|
1287
1287
|
if (!["N", "S", "E", "W"].includes(p)) {
|
|
1288
1288
|
const O = M, A = Number(O.split(" ")[0]);
|
|
@@ -1320,12 +1320,12 @@ class r {
|
|
|
1320
1320
|
* @returns {number} 单位度
|
|
1321
1321
|
*/
|
|
1322
1322
|
static calculateBearing(M, z, p = !0, O = 4) {
|
|
1323
|
-
const A =
|
|
1323
|
+
const A = i.points([
|
|
1324
1324
|
[M.lng, M.lat],
|
|
1325
1325
|
[z.lng, z.lat]
|
|
1326
1326
|
]);
|
|
1327
1327
|
let b;
|
|
1328
|
-
return p ? b =
|
|
1328
|
+
return p ? b = i.rhumbBearing(A.features[0], A.features[1]) : b = i.bearing(A.features[0], A.features[1]), b < 0 && (b += 360), a.roundPrecision(b, O);
|
|
1329
1329
|
}
|
|
1330
1330
|
/**
|
|
1331
1331
|
* 计算两点间距离
|
|
@@ -1338,12 +1338,12 @@ class r {
|
|
|
1338
1338
|
*/
|
|
1339
1339
|
static calculateDistance(M, z, p = !0, O = 4, A = "nauticalmiles") {
|
|
1340
1340
|
M = { ...M }, z = { ...z }, M.lng = a.convertToStdLng(M.lng, O), z.lng = a.convertToStdLng(z.lng, O);
|
|
1341
|
-
const b =
|
|
1341
|
+
const b = i.points([
|
|
1342
1342
|
[M.lng, M.lat],
|
|
1343
1343
|
[z.lng, z.lat]
|
|
1344
1344
|
]);
|
|
1345
|
-
let
|
|
1346
|
-
return p ?
|
|
1345
|
+
let W;
|
|
1346
|
+
return p ? W = i.rhumbDistance(b.features[0], b.features[1], { units: A }) : W = i.distance(b.features[0], b.features[1], { units: A }), a.roundPrecision(W, O);
|
|
1347
1347
|
}
|
|
1348
1348
|
/**
|
|
1349
1349
|
* 计算航线距离
|
|
@@ -1354,10 +1354,10 @@ class r {
|
|
|
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 W = 0; W < b.length - 1; W++) {
|
|
1358
|
+
const q = { lng: b[W][0], lat: b[W][1] };
|
|
1359
|
+
W === 0 && A && (O += this.calculateDistance(A, q, !0, z, p));
|
|
1360
|
+
const o = { lng: b[W + 1][0], lat: b[W + 1][1] };
|
|
1361
1361
|
O += this.calculateDistance(q, o, !0, z, p), A = o;
|
|
1362
1362
|
}
|
|
1363
1363
|
return a.roundPrecision(O, z);
|
|
@@ -1371,10 +1371,10 @@ class r {
|
|
|
1371
1371
|
* @param rhumb
|
|
1372
1372
|
*/
|
|
1373
1373
|
static calculateCoordinate(M, z, p, O = "nauticalmiles", A = !0) {
|
|
1374
|
-
const b =
|
|
1375
|
-
let
|
|
1376
|
-
A ?
|
|
1377
|
-
const q =
|
|
1374
|
+
const b = i.point([M.lng, M.lat]);
|
|
1375
|
+
let W;
|
|
1376
|
+
A ? W = i.rhumbDestination(b, p, z, { units: O }) : W = i.destination(b, p, z, { units: O });
|
|
1377
|
+
const q = W.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 r {
|
|
|
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 W = [], q = this.calculateBearing(M, z, !1), o = this.calculateDistance(M, z, !1, 8, b);
|
|
1391
|
+
O && W.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 && W.push(this.calculateCoordinate(M, q, R, b, !1));
|
|
1395
|
+
return A && W.push({ lng: z.lng, lat: z.lat }), W;
|
|
1396
1396
|
}
|
|
1397
1397
|
/**
|
|
1398
1398
|
* 分组坐标(如相邻两个坐标经度差超180度,需以180为界将坐标分为两组)
|
|
@@ -1412,29 +1412,29 @@ class r {
|
|
|
1412
1412
|
let p = [];
|
|
1413
1413
|
const O = [];
|
|
1414
1414
|
let A, b;
|
|
1415
|
-
for (let
|
|
1416
|
-
A = a.convertToStdLng(M[
|
|
1415
|
+
for (let W = 0; W < M.length - 1; W++) {
|
|
1416
|
+
A = a.convertToStdLng(M[W].lng, 8), b = a.convertToStdLng(M[W + 1].lng, 8), M[W].lat = a.roundPrecision(M[W].lat, 8), M[W + 1].lat = a.roundPrecision(M[W + 1].lat, 8), p.push([A, M[W].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[W].lat],
|
|
1421
|
+
[b, M[W + 1].lat]
|
|
1422
1422
|
]);
|
|
1423
1423
|
let R, Y;
|
|
1424
|
-
z ? (R =
|
|
1424
|
+
z ? (R = i.lineString(o), Y = i.lineString([
|
|
1425
1425
|
[q > 0 ? 180 : -180, 89],
|
|
1426
1426
|
[q > 0 ? 180 : -180, -89]
|
|
1427
|
-
])) : (R =
|
|
1428
|
-
const
|
|
1427
|
+
])) : (R = i.greatCircle(o[0], o[1]), Y = i.greatCircle([q > 0 ? 180 : -180, 89], [q > 0 ? 180 : -180, -89]));
|
|
1428
|
+
const L = i.lineIntersect(R, Y);
|
|
1429
1429
|
let e;
|
|
1430
|
-
if (
|
|
1431
|
-
const u =
|
|
1430
|
+
if (L.features.length) {
|
|
1431
|
+
const u = i.getCoord(L.features[0]);
|
|
1432
1432
|
e = a.roundPrecision(u[1], 8);
|
|
1433
1433
|
} else
|
|
1434
|
-
e = M[
|
|
1434
|
+
e = M[W].lat;
|
|
1435
1435
|
q > 0 ? (p.push([180 - 1e-6, e]), O.push([...p]), p = [], p.push([-(180 - 1e-6), e])) : (p.push([-(180 - 1e-6), e]), O.push([...p]), p = [], p.push([180 - 1e-6, e]));
|
|
1436
1436
|
}
|
|
1437
|
-
|
|
1437
|
+
W === M.length - 2 && p.push([b, M[W + 1].lat]);
|
|
1438
1438
|
}
|
|
1439
1439
|
return O.push(p), O;
|
|
1440
1440
|
}
|
|
@@ -1445,7 +1445,7 @@ class r {
|
|
|
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((W) => W[0] === b[0] && W[1] === b[1]) === -1 && A.push(b), A), []);
|
|
1449
1449
|
z.push(O);
|
|
1450
1450
|
}
|
|
1451
1451
|
return z;
|
|
@@ -1493,13 +1493,13 @@ class r {
|
|
|
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, W;
|
|
1497
1497
|
return z.forEach((q, o) => {
|
|
1498
1498
|
for (let R = 0; R < q.length - 1; R++) {
|
|
1499
|
-
const Y = { lng: q[R][0], lat: q[R][1] },
|
|
1500
|
-
p > e && (p = e, A = R, O = o, b = this.calculateDistance(Y, M),
|
|
1499
|
+
const Y = { lng: q[R][0], lat: q[R][1] }, L = { lng: q[R + 1][0], lat: q[R + 1][1] }, e = this.calculatePointToLineDistance(M, Y, L);
|
|
1500
|
+
p > e && (p = e, A = R, O = o, b = this.calculateDistance(Y, M), W = this.calculateDistance(L, M));
|
|
1501
1501
|
}
|
|
1502
|
-
}), b !== 0 &&
|
|
1502
|
+
}), b !== 0 && W !== 0 ? z[O].splice(A + 1, 0, [M.lng, M.lat]) : b === 0 ? z[O].splice(A, 1, [M.lng, M.lat]) : W === 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 r {
|
|
|
1544
1544
|
return p.forEach((b) => {
|
|
1545
1545
|
if (A === 2)
|
|
1546
1546
|
return;
|
|
1547
|
-
const
|
|
1547
|
+
const W = [];
|
|
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
|
+
W.push(q), A === 0 && W.push([M.lng, M.lat]), A = 2;
|
|
1551
1551
|
break;
|
|
1552
1552
|
}
|
|
1553
|
-
A === 1 ?
|
|
1553
|
+
A === 1 ? W.push(q) : a.roundPrecision(M.lng, 8) === a.roundPrecision(q[0], 8) && a.roundPrecision(M.lat, 8) === a.roundPrecision(q[1], 8) && (A = 1, W.push(q));
|
|
1554
1554
|
}
|
|
1555
|
-
|
|
1555
|
+
W.length && O.push(W);
|
|
1556
1556
|
}), O;
|
|
1557
1557
|
}
|
|
1558
1558
|
/**
|
|
@@ -1564,12 +1564,12 @@ class r {
|
|
|
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), W = 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 >= W && Y <= q);
|
|
1573
1573
|
}
|
|
1574
1574
|
/**
|
|
1575
1575
|
* 计算坐标到航路上的最短距离
|
|
@@ -1578,10 +1578,10 @@ class r {
|
|
|
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, W) => {
|
|
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 = W);
|
|
1585
1585
|
}
|
|
1586
1586
|
}), { minDist: p, segIndex: A, minIndex: O };
|
|
1587
1587
|
}
|
|
@@ -1597,14 +1597,14 @@ class r {
|
|
|
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 W = !0;
|
|
1601
1601
|
for (let q = O; q < z.length; q++)
|
|
1602
|
-
if (
|
|
1602
|
+
if (W) {
|
|
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), W = !1;
|
|
1608
1608
|
} else
|
|
1609
1609
|
b.push([...z[q]]);
|
|
1610
1610
|
return b;
|
|
@@ -1618,12 +1618,12 @@ class r {
|
|
|
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 W = z[b], q = z[b + 1];
|
|
1622
|
+
if (this.calculateDistance(M, W) === 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, W, q);
|
|
1627
1627
|
p > o && (p = o, O = b);
|
|
1628
1628
|
}
|
|
1629
1629
|
M.lng = a.convertToStdLng(M.lng);
|
|
@@ -1643,11 +1643,11 @@ class r {
|
|
|
1643
1643
|
M.lng = a.convertToStdLng(M.lng, 8), z = { ...z }, p = { ...p }, z.lng = a.convertToStdLng(z.lng, 8), p.lng = a.convertToStdLng(p.lng, 8);
|
|
1644
1644
|
const A = a.convertToMonotonicLng([z, p]);
|
|
1645
1645
|
z = A[0], p = A[1];
|
|
1646
|
-
const b =
|
|
1646
|
+
const b = i.lineString([
|
|
1647
1647
|
[z.lng, z.lat],
|
|
1648
1648
|
[p.lng, p.lat]
|
|
1649
|
-
]),
|
|
1650
|
-
return a.roundPrecision(Math.min(
|
|
1649
|
+
]), W = i.pointToLineDistance(i.point([M.lng, M.lat]), b, O), q = i.pointToLineDistance(i.point([M.lng > 0 ? M.lng - 360 : M.lng + 360, M.lat]), b, O);
|
|
1650
|
+
return a.roundPrecision(Math.min(W, q), 6);
|
|
1651
1651
|
}
|
|
1652
1652
|
/**
|
|
1653
1653
|
* 计算途经点的COG, Distance等属性
|
|
@@ -1686,15 +1686,15 @@ class r {
|
|
|
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, W = 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), W = this.calculateDistance(R, M, !1, 6));
|
|
1696
1696
|
}
|
|
1697
|
-
b !== 0 &&
|
|
1697
|
+
b !== 0 && W !== 0 ? b < O || b === O && A === 0 ? z.unshift(M) : W < O || W === 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) : W === 0 && (p ? z.splice(A + 1, 1, M) : z.splice(A + 1, 0, M));
|
|
1698
1698
|
}
|
|
1699
1699
|
return z.map((q) => (q.lng = a.convertToStdLng(q.lng), q));
|
|
1700
1700
|
}
|
|
@@ -1721,7 +1721,7 @@ class r {
|
|
|
1721
1721
|
* @param route [[[lng, lat]]]
|
|
1722
1722
|
*/
|
|
1723
1723
|
static nearestCoordinateInRoute(M, z) {
|
|
1724
|
-
const p =
|
|
1724
|
+
const p = i.point([M.lng, M.lat]), A = this.convertRouteToCoordinates(z).map((o) => [o.lng, o.lat]), b = i.lineString(A), W = i.nearestPointOnLine(b, p), q = i.getCoord(W);
|
|
1725
1725
|
return { lng: a.roundPrecision(q[0], 8), lat: a.roundPrecision(q[1], 8) };
|
|
1726
1726
|
}
|
|
1727
1727
|
/**
|
|
@@ -1754,12 +1754,12 @@ class r {
|
|
|
1754
1754
|
* @return { coordinate: {lng, lat}, route: [[[lng, lat]]]}
|
|
1755
1755
|
*/
|
|
1756
1756
|
static calculateNextCoordinateAlongRoute(M, z, p, O = "nauticalmiles") {
|
|
1757
|
-
var
|
|
1757
|
+
var L;
|
|
1758
1758
|
const A = M.speed || 12, b = [];
|
|
1759
|
-
let
|
|
1759
|
+
let W = [], q = !1, o = 0, R = 0, Y;
|
|
1760
1760
|
if (z && p.length ? (b.push(M), p.forEach((e, u) => {
|
|
1761
1761
|
if (q)
|
|
1762
|
-
|
|
1762
|
+
W.push(e);
|
|
1763
1763
|
else {
|
|
1764
1764
|
const S = [];
|
|
1765
1765
|
let s;
|
|
@@ -1781,15 +1781,15 @@ class r {
|
|
|
1781
1781
|
q = !0;
|
|
1782
1782
|
}
|
|
1783
1783
|
}
|
|
1784
|
-
S.length &&
|
|
1784
|
+
S.length && W.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, ((
|
|
1788
|
-
const e = { lng:
|
|
1786
|
+
})) : (W = p, Y = { ...M }), Y)
|
|
1787
|
+
if (b.push(Y), Y.distanceFromPrevious = R, Y.hourFromPrevious = Math.round(R / A * 1e4) / 1e4, ((L = W[0]) == null ? void 0 : L.length) > 1) {
|
|
1788
|
+
const e = { lng: W[0][1][0], lat: W[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: W, prevRoute: b };
|
|
1793
1793
|
}
|
|
1794
1794
|
/**
|
|
1795
1795
|
* 返回最近点及其是否为垂足(最近点不是起点或终点)
|
|
@@ -1798,11 +1798,11 @@ class r {
|
|
|
1798
1798
|
* @param to {lng, lat}
|
|
1799
1799
|
*/
|
|
1800
1800
|
static nearestCoordinateInLine(M, z, p) {
|
|
1801
|
-
const O = a.convertToStdLng(M.lng, 6), A =
|
|
1801
|
+
const O = a.convertToStdLng(M.lng, 6), A = i.point([O, M.lat]), b = a.convertToStdLng(z.lng, 6), W = a.convertToStdLng(p.lng, 6), q = i.lineString([
|
|
1802
1802
|
[b, z.lat],
|
|
1803
|
-
[
|
|
1804
|
-
]), o =
|
|
1805
|
-
return { lng: Y, lat:
|
|
1803
|
+
[W, p.lat]
|
|
1804
|
+
]), o = i.nearestPointOnLine(q, A), R = i.getCoord(o), Y = a.roundPrecision(R[0], 6), L = a.roundPrecision(R[1], 6);
|
|
1805
|
+
return { lng: Y, lat: L, inline: !(Y === b && L === z.lat) && !(Y === W && L === p.lat) };
|
|
1806
1806
|
}
|
|
1807
1807
|
/**
|
|
1808
1808
|
* 将route转coordinate
|
|
@@ -1813,8 +1813,8 @@ class r {
|
|
|
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((W) => {
|
|
1817
|
+
const q = { lng: a.roundPrecision(W[0], 8), lat: a.roundPrecision(W[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 r {
|
|
|
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 W = 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 > W; o--)
|
|
1854
1854
|
M.splice(o, 1);
|
|
1855
1855
|
}
|
|
1856
1856
|
}
|
|
@@ -1867,13 +1867,13 @@ class r {
|
|
|
1867
1867
|
*/
|
|
1868
1868
|
static calculateCenter(M) {
|
|
1869
1869
|
const z = [];
|
|
1870
|
-
for (const
|
|
1871
|
-
for (const q of
|
|
1870
|
+
for (const W of M)
|
|
1871
|
+
for (const q of W)
|
|
1872
1872
|
z.push(q);
|
|
1873
|
-
const p =
|
|
1874
|
-
for (const
|
|
1875
|
-
p.features.push(
|
|
1876
|
-
const b =
|
|
1873
|
+
const p = i.featureCollection([]), O = a.convertToMonotonicLng2(z);
|
|
1874
|
+
for (const W of O)
|
|
1875
|
+
p.features.push(i.point(W));
|
|
1876
|
+
const b = i.center(p).geometry.coordinates;
|
|
1877
1877
|
return { lng: a.convertToStdLng(b[0], 8), lat: a.roundPrecision(b[1], 8) };
|
|
1878
1878
|
}
|
|
1879
1879
|
/**
|
|
@@ -1893,8 +1893,8 @@ class r {
|
|
|
1893
1893
|
for (const A of M)
|
|
1894
1894
|
for (const b of A)
|
|
1895
1895
|
z.push(b);
|
|
1896
|
-
const p = a.convertToMonotonicLng2(z), O =
|
|
1897
|
-
return
|
|
1896
|
+
const p = a.convertToMonotonicLng2(z), O = i.lineString(p);
|
|
1897
|
+
return i.bbox(O);
|
|
1898
1898
|
}
|
|
1899
1899
|
/**
|
|
1900
1900
|
* 计算BBox
|
|
@@ -1913,11 +1913,11 @@ class r {
|
|
|
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], W = 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 = r.calculateDistance(b,
|
|
1920
|
-
Math.round(Math.acos(u) * 180 / Math.PI) < p && e > z && !R && (O.push(
|
|
1918
|
+
if ((b.velocity || b.suspend || b.important || b.pilot || A === 1) && (o = !0, O.push(b)), W.gcToPrevious && (o || (o = !0, O.push(b)), R = !0, O.push(W), A++), q) {
|
|
1919
|
+
const Y = r.calculateDistance(b, W, !0), L = r.calculateDistance(W, q, !0), e = r.calculateDistance(b, q, !0), u = (Math.pow(Y, 2) + Math.pow(L, 2) - Math.pow(e, 2)) / (2 * Y * L);
|
|
1920
|
+
Math.round(Math.acos(u) * 180 / Math.PI) < p && e > z && !R && (O.push(W), A++);
|
|
1921
1921
|
}
|
|
1922
1922
|
if (A >= M.length - 1) {
|
|
1923
1923
|
const Y = M.at(-1);
|
|
@@ -1936,7 +1936,7 @@ class r {
|
|
|
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, W) => (b.positionTime || 0) - (W.positionTime || 0)), A.at(-1);
|
|
1940
1940
|
}
|
|
1941
1941
|
/**
|
|
1942
1942
|
* 推测船位
|
|
@@ -1944,17 +1944,17 @@ class r {
|
|
|
1944
1944
|
* @param positions 带时间(positionTime)的轨迹
|
|
1945
1945
|
*/
|
|
1946
1946
|
static deadReckoning(M, z) {
|
|
1947
|
-
var A, b;
|
|
1947
|
+
var A, b, W, q;
|
|
1948
1948
|
M > 1e12 && (M = Math.round(M / 1e3));
|
|
1949
1949
|
const p = C.unix(M);
|
|
1950
|
-
let O = z.find((
|
|
1950
|
+
let O = z.find((o) => o.positionTime === p.unix());
|
|
1951
1951
|
if (!O) {
|
|
1952
|
-
const
|
|
1953
|
-
if (
|
|
1954
|
-
const
|
|
1955
|
-
O = r.calculateCoordinate(
|
|
1952
|
+
const o = (b = (A = z.filter((Y) => (Y == null ? void 0 : Y.positionTime) < p.unix())) == null ? void 0 : A.sort((Y, L) => (Y.positionTime || 0) - (L.positionTime || 0))) == null ? void 0 : b.at(-1), R = (q = (W = z.filter((Y) => (Y == null ? void 0 : Y.positionTime) > p.unix())) == null ? void 0 : W.sort((Y, L) => (Y.positionTime || 0) - (L.positionTime || 0))) == null ? void 0 : q.at(0);
|
|
1953
|
+
if (o && R) {
|
|
1954
|
+
const Y = r.calculateBearing(o, R, !0), L = r.calculateDistance(o, R), e = (p.unix() - o.positionTime) / (R.positionTime - o.positionTime);
|
|
1955
|
+
O = r.calculateCoordinate(o, Y, L * e), O.positionTime = p.unix(), O.utc = p.format(), O.cog = Y, O.sog = Math.round(L / ((R.positionTime - o.positionTime) / 3600) * 100) / 100;
|
|
1956
1956
|
} else
|
|
1957
|
-
O =
|
|
1957
|
+
O = o || R, O && (O.utc = C.unix(O == null ? void 0 : O.positionTime).utc().format());
|
|
1958
1958
|
}
|
|
1959
1959
|
return O;
|
|
1960
1960
|
}
|
|
@@ -1985,15 +1985,15 @@ class V0 {
|
|
|
1985
1985
|
*/
|
|
1986
1986
|
static convert2Geojson(M) {
|
|
1987
1987
|
var p;
|
|
1988
|
-
const z =
|
|
1988
|
+
const z = i.featureCollection([]);
|
|
1989
1989
|
for (const O of M) {
|
|
1990
1990
|
if (O.forecasts) {
|
|
1991
1991
|
const A = (p = O.history) == null ? void 0 : p[0];
|
|
1992
1992
|
A && A.wind && (A.wind.spd = A.spd, A.wind.kts = A.kts);
|
|
1993
1993
|
for (const b of O.forecasts) {
|
|
1994
|
-
const
|
|
1994
|
+
const W = [], q = C(b.date).utc(), o = `${O.name}-${b.model}`;
|
|
1995
1995
|
if (A) {
|
|
1996
|
-
const R = C(A.updated).utc(), Y =
|
|
1996
|
+
const R = C(A.updated).utc(), Y = i.point([A.lng, A.lat], {
|
|
1997
1997
|
model: b.model,
|
|
1998
1998
|
name: O.name,
|
|
1999
1999
|
date: R.format(),
|
|
@@ -2004,17 +2004,17 @@ class V0 {
|
|
|
2004
2004
|
category: o,
|
|
2005
2005
|
type: "forecast"
|
|
2006
2006
|
});
|
|
2007
|
-
z.features.push(Y),
|
|
2007
|
+
z.features.push(Y), W.push(Y.geometry.coordinates);
|
|
2008
2008
|
}
|
|
2009
2009
|
for (const R in b == null ? void 0 : b.hours) {
|
|
2010
2010
|
const Y = b.hours[R];
|
|
2011
2011
|
Y.wind.spd = Y.wind.spd || Y.wind.speed;
|
|
2012
|
-
const
|
|
2012
|
+
const L = q.clone().add(Number(R), "hour"), e = i.point([Y.lng, Y.lat], {
|
|
2013
2013
|
model: b.model,
|
|
2014
2014
|
name: O.name,
|
|
2015
|
-
date:
|
|
2015
|
+
date: L.format(),
|
|
2016
2016
|
hour: Number(R),
|
|
2017
|
-
format:
|
|
2017
|
+
format: L.format("MMM-DD/HHmm[Z]"),
|
|
2018
2018
|
pressure: Y.pressure > 1e4 ? a.roundPrecision(Y.pressure / 100, 0) : a.roundPrecision(Y.pressure, 0),
|
|
2019
2019
|
gusts: Y.gusts,
|
|
2020
2020
|
wind: Y.wind || {},
|
|
@@ -2022,10 +2022,10 @@ class V0 {
|
|
|
2022
2022
|
category: o,
|
|
2023
2023
|
type: "forecast"
|
|
2024
2024
|
});
|
|
2025
|
-
z.features.push(e),
|
|
2025
|
+
z.features.push(e), W.push(e.geometry.coordinates);
|
|
2026
2026
|
}
|
|
2027
|
-
if ((
|
|
2028
|
-
const R =
|
|
2027
|
+
if ((W == null ? void 0 : W.length) > 1) {
|
|
2028
|
+
const R = i.lineString(a.convertToMonotonicLng2(W), {
|
|
2029
2029
|
date: b.date,
|
|
2030
2030
|
id: O.id || O.name,
|
|
2031
2031
|
model: b.model,
|
|
@@ -2039,25 +2039,25 @@ class V0 {
|
|
|
2039
2039
|
}
|
|
2040
2040
|
if (O.history) {
|
|
2041
2041
|
const A = [];
|
|
2042
|
-
for (const
|
|
2043
|
-
const q = C(
|
|
2042
|
+
for (const W of O.history) {
|
|
2043
|
+
const q = C(W.updated).utc(), o = i.point([W.lng, W.lat], {
|
|
2044
2044
|
name: O.name,
|
|
2045
2045
|
date: q.format(),
|
|
2046
2046
|
format: q.format("MMM-DD/HHmm[Z]"),
|
|
2047
|
-
pressure:
|
|
2048
|
-
spd:
|
|
2049
|
-
kts:
|
|
2050
|
-
source:
|
|
2051
|
-
level:
|
|
2047
|
+
pressure: W.pressure > 1e4 ? a.roundPrecision(W.pressure / 100, 0) : a.roundPrecision(W.pressure, 0),
|
|
2048
|
+
spd: W.speed || W.spd,
|
|
2049
|
+
kts: W.kts,
|
|
2050
|
+
source: W.source,
|
|
2051
|
+
level: W.type,
|
|
2052
2052
|
type: "history",
|
|
2053
2053
|
category: `${O.name}-history`,
|
|
2054
|
-
wind:
|
|
2054
|
+
wind: W.wind
|
|
2055
2055
|
});
|
|
2056
2056
|
z.features.push(o), A.push(o.geometry.coordinates);
|
|
2057
2057
|
}
|
|
2058
2058
|
const b = O.history[0];
|
|
2059
2059
|
if (A.length === 1 && A.push(A[0]), A.length > 1) {
|
|
2060
|
-
const
|
|
2060
|
+
const W = i.lineString(a.convertToMonotonicLng2(A), {
|
|
2061
2061
|
name: O.name,
|
|
2062
2062
|
type: "history",
|
|
2063
2063
|
updated: b == null ? void 0 : b.updated,
|
|
@@ -2067,7 +2067,7 @@ class V0 {
|
|
|
2067
2067
|
source: b == null ? void 0 : b.source,
|
|
2068
2068
|
level: b == null ? void 0 : b.type
|
|
2069
2069
|
});
|
|
2070
|
-
z.features.push(
|
|
2070
|
+
z.features.push(W);
|
|
2071
2071
|
}
|
|
2072
2072
|
}
|
|
2073
2073
|
}
|
|
@@ -2079,10 +2079,10 @@ class V0 {
|
|
|
2079
2079
|
* @param step
|
|
2080
2080
|
*/
|
|
2081
2081
|
static interpolate(M, z = 3) {
|
|
2082
|
-
var A, b,
|
|
2082
|
+
var A, b, W, q;
|
|
2083
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 = [];
|
|
2084
2084
|
for (const o of p) {
|
|
2085
|
-
const R = o.properties.name, Y = o.properties.model,
|
|
2085
|
+
const R = o.properties.name, Y = o.properties.model, L = o.properties.showCircle, e = o.properties.disabled, u = C(o.properties.date).utc();
|
|
2086
2086
|
let S = z * 60 - (u.get("hour") * 60 + u.get("minute")) % (z * 60);
|
|
2087
2087
|
const s = (b = M == null ? void 0 : M.data) == null ? void 0 : b.features.filter(
|
|
2088
2088
|
(l) => l.geometry.type === "Point" && l.properties.type === "forecast" && l.properties.category === `${R}-${Y}`
|
|
@@ -2090,7 +2090,7 @@ class V0 {
|
|
|
2090
2090
|
let P, G = u.clone().add(S, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2091
2091
|
for (; P = this.pickIndex(s, G), P <= s.length - 1; ) {
|
|
2092
2092
|
if (P > 0) {
|
|
2093
|
-
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 - ((W = N == null ? void 0 : N.properties) == null ? void 0 : W.hour)) / (l.properties.hour - ((q = N == null ? void 0 : N.properties) == null ? void 0 : q.hour)), H = this.computeNumber(N == null ? void 0 : N.geometry.coordinates[0], l.geometry.coordinates[0], I), Q = this.computeNumber(N == null ? void 0 : N.geometry.coordinates[1], l.geometry.coordinates[1], I), F = i.point([H, Q], {
|
|
2094
2094
|
name: R,
|
|
2095
2095
|
model: Y,
|
|
2096
2096
|
category: l == null ? void 0 : l.properties.category,
|
|
@@ -2103,7 +2103,7 @@ class V0 {
|
|
|
2103
2103
|
wind: this.computeNumber(N == null ? void 0 : N.properties.wind, l.properties.wind, I),
|
|
2104
2104
|
type: "forecast",
|
|
2105
2105
|
disabled: e,
|
|
2106
|
-
showCircle:
|
|
2106
|
+
showCircle: L
|
|
2107
2107
|
});
|
|
2108
2108
|
O.push(F);
|
|
2109
2109
|
}
|
|
@@ -2134,7 +2134,7 @@ class V0 {
|
|
|
2134
2134
|
* @param options
|
|
2135
2135
|
*/
|
|
2136
2136
|
static diversionPassageAt(M, z, p, O = {}) {
|
|
2137
|
-
const { t1: A, t2: b, hr:
|
|
2137
|
+
const { t1: A, t2: b, hr: W, hours: q } = this.tropicalCenterTwin(z, 24, O);
|
|
2138
2138
|
if (A && b) {
|
|
2139
2139
|
if (!O.debug) {
|
|
2140
2140
|
const u = r.calculateDistance(M, A), S = r.calculateDistance(M, b);
|
|
@@ -2143,13 +2143,13 @@ class V0 {
|
|
|
2143
2143
|
from: M,
|
|
2144
2144
|
t1: A,
|
|
2145
2145
|
t2: b,
|
|
2146
|
-
hr:
|
|
2146
|
+
hr: W
|
|
2147
2147
|
}), {};
|
|
2148
2148
|
}
|
|
2149
2149
|
const o = r.calculateBearing(M, A), R = r.calculateBearing(A, b), Y = Math.abs(o - R);
|
|
2150
|
-
let
|
|
2151
|
-
Y < 180 ?
|
|
2152
|
-
const e = r.calculateCoordinate(A,
|
|
2150
|
+
let L = 0;
|
|
2151
|
+
Y < 180 ? L = Y + 90 : Y >= 180 && (L = Y - 90);
|
|
2152
|
+
const e = r.calculateCoordinate(A, L, p);
|
|
2153
2153
|
return Z == null || Z.info("[%s] the right tangent position: %j", O.requestId, {
|
|
2154
2154
|
from: M,
|
|
2155
2155
|
t1: A,
|
|
@@ -2158,7 +2158,7 @@ class V0 {
|
|
|
2158
2158
|
bearing1: o,
|
|
2159
2159
|
bearing2: R,
|
|
2160
2160
|
right: e
|
|
2161
|
-
}), { at: e, t1: A, t2: b, hr: Number(
|
|
2161
|
+
}), { at: e, t1: A, t2: b, hr: Number(W), hours: q };
|
|
2162
2162
|
}
|
|
2163
2163
|
return {};
|
|
2164
2164
|
}
|
|
@@ -2173,7 +2173,7 @@ class V0 {
|
|
|
2173
2173
|
* @param options
|
|
2174
2174
|
*/
|
|
2175
2175
|
static driftPassageAt(M, z, p, O = {}) {
|
|
2176
|
-
const { t1: A, t2: b, hr:
|
|
2176
|
+
const { t1: A, t2: b, hr: W, hours: q } = this.tropicalCenterTwin(z, 24, O);
|
|
2177
2177
|
if (A && b) {
|
|
2178
2178
|
if (!O.debug) {
|
|
2179
2179
|
const e = r.calculateDistance(M, A), u = r.calculateDistance(M, b);
|
|
@@ -2182,13 +2182,13 @@ class V0 {
|
|
|
2182
2182
|
from: M,
|
|
2183
2183
|
t1: A,
|
|
2184
2184
|
t2: b,
|
|
2185
|
-
hr:
|
|
2185
|
+
hr: W
|
|
2186
2186
|
}), {};
|
|
2187
2187
|
}
|
|
2188
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(
|
|
2189
|
+
return { at: r.calculateCoordinate(A, o - R + 180, p < Y ? p : Y), t1: A, t2: b, hr: Number(W), hours: q };
|
|
2190
2190
|
} else
|
|
2191
|
-
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: W }), {};
|
|
2192
2192
|
}
|
|
2193
2193
|
/**
|
|
2194
2194
|
* 获取台风中心点对
|
|
@@ -2199,21 +2199,21 @@ class V0 {
|
|
|
2199
2199
|
* @private
|
|
2200
2200
|
*/
|
|
2201
2201
|
static tropicalCenterTwin(M, z = 24, p = {}) {
|
|
2202
|
-
var R, Y,
|
|
2202
|
+
var R, Y, L, e, u;
|
|
2203
2203
|
let O = {};
|
|
2204
2204
|
(R = M.forecasts) == null || R.forEach((S) => {
|
|
2205
2205
|
O = { ...S.hours, ...O };
|
|
2206
2206
|
});
|
|
2207
|
-
const A = ((Y = M == null ? void 0 : M.history) == null ? void 0 : Y[0]) || (O == null ? void 0 : O[(
|
|
2207
|
+
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]]);
|
|
2208
2208
|
Z == null || Z.info("[%s] the first tropical center: %j", p.requestId, A);
|
|
2209
2209
|
let b = (e = Object.keys(O || {}).filter((S) => Number(S) <= (z < 0 ? 24 : z))) == null ? void 0 : e.at(-1);
|
|
2210
2210
|
b || (b = (u = Object.keys(O || {}).filter((S) => Number(S) <= (z < 0 ? 24 : 2 * z))) == null ? void 0 : u.at(-1));
|
|
2211
|
-
const
|
|
2212
|
-
Z == null || Z.info("[%s] the second tropical center: %j in %d hrs", p.requestId,
|
|
2211
|
+
const W = O == null ? void 0 : O[b || -1];
|
|
2212
|
+
Z == null || Z.info("[%s] the second tropical center: %j in %d hrs", p.requestId, W, b);
|
|
2213
2213
|
const q = Object.keys(O || {}).filter((S) => Number(S) <= Number(b)), o = { 0: A };
|
|
2214
2214
|
for (const S of q)
|
|
2215
2215
|
o[S] = O[S];
|
|
2216
|
-
return { t1: A, t2:
|
|
2216
|
+
return { t1: A, t2: W, hr: Number(b), hours: o };
|
|
2217
2217
|
}
|
|
2218
2218
|
static pickIndex(M, z) {
|
|
2219
2219
|
let p = 0;
|
|
@@ -2246,20 +2246,20 @@ class t0 {
|
|
|
2246
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}`;
|
|
2247
2247
|
}
|
|
2248
2248
|
static str2Json(M) {
|
|
2249
|
-
const [z, p, O, A, b,
|
|
2249
|
+
const [z, p, O, A, b, W, q, o, R, Y, L] = M.split("|");
|
|
2250
2250
|
return {
|
|
2251
2251
|
lat: Number(z),
|
|
2252
2252
|
lng: Number(p),
|
|
2253
2253
|
positionTime: Number(O),
|
|
2254
2254
|
sog: Number(A),
|
|
2255
2255
|
cog: Number(b),
|
|
2256
|
-
hdg: Number(
|
|
2256
|
+
hdg: Number(W),
|
|
2257
2257
|
//@ts-ignore
|
|
2258
2258
|
draught: isNaN(q) ? null : Number(q),
|
|
2259
2259
|
type: o,
|
|
2260
2260
|
meteo: R ? JSON.parse(R) : void 0,
|
|
2261
2261
|
vendor: Y,
|
|
2262
|
-
deleted:
|
|
2262
|
+
deleted: L === "true"
|
|
2263
2263
|
};
|
|
2264
2264
|
}
|
|
2265
2265
|
static inspectStoppages(M, z = 1) {
|
|
@@ -2269,7 +2269,7 @@ class t0 {
|
|
|
2269
2269
|
for (let A = 0; A < M.length - 1; A++) {
|
|
2270
2270
|
const b = M[A];
|
|
2271
2271
|
if (b.sog = b.sog || 0, b.sog < z) {
|
|
2272
|
-
const
|
|
2272
|
+
const W = b;
|
|
2273
2273
|
let q = M.at(-1);
|
|
2274
2274
|
for (let o = A + 1; o < M.length; o++) {
|
|
2275
2275
|
const R = M[o];
|
|
@@ -2281,14 +2281,14 @@ class t0 {
|
|
|
2281
2281
|
break;
|
|
2282
2282
|
}
|
|
2283
2283
|
}
|
|
2284
|
-
if (q.positionTime !=
|
|
2284
|
+
if (q.positionTime != W.positionTime) {
|
|
2285
2285
|
const o = {
|
|
2286
2286
|
start: {
|
|
2287
|
-
lat:
|
|
2288
|
-
lng:
|
|
2289
|
-
sog:
|
|
2290
|
-
positionTime:
|
|
2291
|
-
utc: C.unix(
|
|
2287
|
+
lat: W.lat,
|
|
2288
|
+
lng: W.lng,
|
|
2289
|
+
sog: W.sog,
|
|
2290
|
+
positionTime: W.positionTime,
|
|
2291
|
+
utc: C.unix(W.positionTime).utc().format()
|
|
2292
2292
|
},
|
|
2293
2293
|
end: {
|
|
2294
2294
|
lat: q.lat,
|
|
@@ -2297,8 +2297,8 @@ class t0 {
|
|
|
2297
2297
|
positionTime: q.positionTime,
|
|
2298
2298
|
utc: C.unix(q.positionTime).utc().format()
|
|
2299
2299
|
},
|
|
2300
|
-
duration: q.positionTime -
|
|
2301
|
-
distance: r.calculateDistance(
|
|
2300
|
+
duration: q.positionTime - W.positionTime,
|
|
2301
|
+
distance: r.calculateDistance(W, q, !0, 4),
|
|
2302
2302
|
avgSog: 0
|
|
2303
2303
|
};
|
|
2304
2304
|
o.avgSog = Math.round(o.distance / (o.duration / 3600) * 100) / 100, O.push(o);
|