@idm-plugin/geo 1.8.3 → 1.8.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 +327 -326
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as f from "@turf/turf";
|
|
2
|
+
import s from "moment";
|
|
3
3
|
import _ from "@log4js-node/log4js-api";
|
|
4
4
|
var a0 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
5
5
|
function X0(I) {
|
|
@@ -13,41 +13,41 @@ var j = { exports: {} };
|
|
|
13
13
|
//! license : MIT
|
|
14
14
|
//! github.com/moment/moment-timezone
|
|
15
15
|
(function(M, z) {
|
|
16
|
-
I.exports ? I.exports = z(
|
|
16
|
+
I.exports ? I.exports = z(s) : z(M.moment);
|
|
17
17
|
})(a0, function(M) {
|
|
18
18
|
M.version === void 0 && M.default && (M = M.default);
|
|
19
|
-
var z = "0.5.48", b = {}, O = {}, c = {}, p = {}, A = {},
|
|
19
|
+
var z = "0.5.48", b = {}, O = {}, c = {}, p = {}, A = {}, W;
|
|
20
20
|
(!M || typeof M.version != "string") && D("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
21
21
|
var q = M.version.split("."), Y = +q[0], d = +q[1];
|
|
22
22
|
(Y < 2 || Y === 2 && d < 6) && D("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
|
|
23
|
-
function L(
|
|
24
|
-
return
|
|
23
|
+
function L(o) {
|
|
24
|
+
return o > 96 ? o - 87 : o > 64 ? o - 29 : o - 48;
|
|
25
25
|
}
|
|
26
|
-
function T(
|
|
27
|
-
var a = 0, n =
|
|
28
|
-
for (
|
|
29
|
-
|
|
26
|
+
function T(o) {
|
|
27
|
+
var a = 0, n = o.split("."), R = n[0], e = n[1] || "", r = 1, Z, U = 0, V = 1;
|
|
28
|
+
for (o.charCodeAt(0) === 45 && (a = 1, V = -1), a; a < R.length; a++)
|
|
29
|
+
Z = L(R.charCodeAt(a)), U = 60 * U + Z;
|
|
30
30
|
for (a = 0; a < e.length; a++)
|
|
31
|
-
r = r / 60,
|
|
31
|
+
r = r / 60, Z = L(e.charCodeAt(a)), U += Z * r;
|
|
32
32
|
return U * V;
|
|
33
33
|
}
|
|
34
|
-
function N(
|
|
35
|
-
for (var a = 0; a <
|
|
36
|
-
|
|
34
|
+
function N(o) {
|
|
35
|
+
for (var a = 0; a < o.length; a++)
|
|
36
|
+
o[a] = T(o[a]);
|
|
37
37
|
}
|
|
38
|
-
function i(
|
|
38
|
+
function i(o, a) {
|
|
39
39
|
for (var n = 0; n < a; n++)
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
o[n] = Math.round((o[n - 1] || 0) + o[n] * 6e4);
|
|
41
|
+
o[a - 1] = 1 / 0;
|
|
42
42
|
}
|
|
43
|
-
function t(
|
|
43
|
+
function t(o, a) {
|
|
44
44
|
var n = [], R;
|
|
45
45
|
for (R = 0; R < a.length; R++)
|
|
46
|
-
n[R] =
|
|
46
|
+
n[R] = o[a[R]];
|
|
47
47
|
return n;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
var a =
|
|
49
|
+
function l(o) {
|
|
50
|
+
var a = o.split("|"), n = a[2].split(" "), R = a[3].split(""), e = a[4].split(" ");
|
|
51
51
|
return N(n), N(R), N(e), i(e, R.length), {
|
|
52
52
|
name: a[0],
|
|
53
53
|
abbrs: t(a[1].split(" "), R),
|
|
@@ -56,94 +56,94 @@ var j = { exports: {} };
|
|
|
56
56
|
population: a[5] | 0
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function G(
|
|
60
|
-
|
|
59
|
+
function G(o) {
|
|
60
|
+
o && this._set(l(o));
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function P(o, a) {
|
|
63
63
|
var n = a.length;
|
|
64
|
-
if (
|
|
64
|
+
if (o < a[0])
|
|
65
65
|
return 0;
|
|
66
|
-
if (n > 1 && a[n - 1] === 1 / 0 &&
|
|
66
|
+
if (n > 1 && a[n - 1] === 1 / 0 && o >= a[n - 2])
|
|
67
67
|
return n - 1;
|
|
68
|
-
if (
|
|
68
|
+
if (o >= a[n - 1])
|
|
69
69
|
return -1;
|
|
70
70
|
for (var R, e = 0, r = n - 1; r - e > 1; )
|
|
71
|
-
R = Math.floor((e + r) / 2), a[R] <=
|
|
71
|
+
R = Math.floor((e + r) / 2), a[R] <= o ? e = R : r = R;
|
|
72
72
|
return r;
|
|
73
73
|
}
|
|
74
74
|
G.prototype = {
|
|
75
|
-
_set: function(
|
|
76
|
-
this.name =
|
|
75
|
+
_set: function(o) {
|
|
76
|
+
this.name = o.name, this.abbrs = o.abbrs, this.untils = o.untils, this.offsets = o.offsets, this.population = o.population;
|
|
77
77
|
},
|
|
78
|
-
_index: function(
|
|
79
|
-
var a = +
|
|
80
|
-
if (R =
|
|
78
|
+
_index: function(o) {
|
|
79
|
+
var a = +o, n = this.untils, R;
|
|
80
|
+
if (R = P(a, n), R >= 0)
|
|
81
81
|
return R;
|
|
82
82
|
},
|
|
83
83
|
countries: function() {
|
|
84
|
-
var
|
|
84
|
+
var o = this.name;
|
|
85
85
|
return Object.keys(c).filter(function(a) {
|
|
86
|
-
return c[a].zones.indexOf(
|
|
86
|
+
return c[a].zones.indexOf(o) !== -1;
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
|
-
parse: function(
|
|
90
|
-
var a = +
|
|
89
|
+
parse: function(o) {
|
|
90
|
+
var a = +o, n = this.offsets, R = this.untils, e = R.length - 1, r, Z, U, V;
|
|
91
91
|
for (V = 0; V < e; V++)
|
|
92
|
-
if (r = n[V],
|
|
92
|
+
if (r = n[V], Z = n[V + 1], U = n[V && V - 1], r < Z && u.moveAmbiguousForward ? r = Z : r > U && u.moveInvalidForward && (r = U), a < R[V] - r * 6e4)
|
|
93
93
|
return n[V];
|
|
94
94
|
return n[e];
|
|
95
95
|
},
|
|
96
|
-
abbr: function(
|
|
97
|
-
return this.abbrs[this._index(
|
|
96
|
+
abbr: function(o) {
|
|
97
|
+
return this.abbrs[this._index(o)];
|
|
98
98
|
},
|
|
99
|
-
offset: function(
|
|
100
|
-
return D("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(
|
|
99
|
+
offset: function(o) {
|
|
100
|
+
return D("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(o)];
|
|
101
101
|
},
|
|
102
|
-
utcOffset: function(
|
|
103
|
-
return this.offsets[this._index(
|
|
102
|
+
utcOffset: function(o) {
|
|
103
|
+
return this.offsets[this._index(o)];
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
function B(
|
|
107
|
-
this.name =
|
|
106
|
+
function B(o, a) {
|
|
107
|
+
this.name = o, this.zones = a;
|
|
108
108
|
}
|
|
109
|
-
function m(
|
|
110
|
-
var a =
|
|
111
|
-
n && n[0] ? (n = n[0].match(/[A-Z]/g), n = n ? n.join("") : void 0) : (n = a.match(/[A-Z]{3,5}/g), n = n ? n[0] : void 0), n === "GMT" && (n = void 0), this.at = +
|
|
109
|
+
function m(o) {
|
|
110
|
+
var a = o.toTimeString(), n = a.match(/\([a-z ]+\)/i);
|
|
111
|
+
n && n[0] ? (n = n[0].match(/[A-Z]/g), n = n ? n.join("") : void 0) : (n = a.match(/[A-Z]{3,5}/g), n = n ? n[0] : void 0), n === "GMT" && (n = void 0), this.at = +o, this.abbr = n, this.offset = o.getTimezoneOffset();
|
|
112
112
|
}
|
|
113
|
-
function H(
|
|
114
|
-
this.zone =
|
|
113
|
+
function H(o) {
|
|
114
|
+
this.zone = o, 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(o) {
|
|
117
|
+
this.offsetScore += Math.abs(this.zone.utcOffset(o.at) - o.offset), this.zone.abbr(o.at).replace(/[^A-Z]/g, "") !== o.abbr && this.abbrScore++;
|
|
118
118
|
};
|
|
119
|
-
function Q(
|
|
120
|
-
for (var n, R; R = ((a.at -
|
|
121
|
-
n = new m(new Date(
|
|
122
|
-
return
|
|
119
|
+
function Q(o, a) {
|
|
120
|
+
for (var n, R; R = ((a.at - o.at) / 12e4 | 0) * 6e4; )
|
|
121
|
+
n = new m(new Date(o.at + R)), n.offset === o.offset ? o = n : a = n;
|
|
122
|
+
return o;
|
|
123
123
|
}
|
|
124
124
|
function F() {
|
|
125
|
-
var
|
|
125
|
+
var o = (/* @__PURE__ */ new Date()).getFullYear() - 2, a = new m(new Date(o, 0, 1)), n = a.offset, R = [a], e, r, Z, U;
|
|
126
126
|
for (U = 1; U < 48; U++)
|
|
127
|
-
|
|
127
|
+
Z = new Date(o, U, 1).getTimezoneOffset(), Z !== n && (r = new m(new Date(o, U, 1)), e = Q(a, r), R.push(e), R.push(new m(new Date(e.at + 6e4))), a = r, n = Z);
|
|
128
128
|
for (U = 0; U < 4; U++)
|
|
129
|
-
R.push(new m(new Date(
|
|
129
|
+
R.push(new m(new Date(o + U, 0, 1))), R.push(new m(new Date(o + U, 6, 1)));
|
|
130
130
|
return R;
|
|
131
131
|
}
|
|
132
|
-
function M0(
|
|
133
|
-
return
|
|
132
|
+
function M0(o, a) {
|
|
133
|
+
return o.offsetScore !== a.offsetScore ? o.offsetScore - a.offsetScore : o.abbrScore !== a.abbrScore ? o.abbrScore - a.abbrScore : o.zone.population !== a.zone.population ? a.zone.population - o.zone.population : a.zone.name.localeCompare(o.zone.name);
|
|
134
134
|
}
|
|
135
|
-
function z0(
|
|
135
|
+
function z0(o, a) {
|
|
136
136
|
var n, R;
|
|
137
137
|
for (N(a), n = 0; n < a.length; n++)
|
|
138
|
-
R = a[n], A[R] = A[R] || {}, A[R][
|
|
138
|
+
R = a[n], A[R] = A[R] || {}, A[R][o] = !0;
|
|
139
139
|
}
|
|
140
|
-
function b0(
|
|
141
|
-
var a =
|
|
140
|
+
function b0(o) {
|
|
141
|
+
var a = o.length, n = {}, R = [], e = {}, r, Z, U, V;
|
|
142
142
|
for (r = 0; r < a; r++)
|
|
143
|
-
if (U =
|
|
143
|
+
if (U = o[r].offset, !e.hasOwnProperty(U)) {
|
|
144
144
|
V = A[U] || {};
|
|
145
|
-
for (
|
|
146
|
-
V.hasOwnProperty(
|
|
145
|
+
for (Z in V)
|
|
146
|
+
V.hasOwnProperty(Z) && (n[Z] = !0);
|
|
147
147
|
e[U] = !0;
|
|
148
148
|
}
|
|
149
149
|
for (r in n)
|
|
@@ -152,69 +152,69 @@ var j = { exports: {} };
|
|
|
152
152
|
}
|
|
153
153
|
function p0() {
|
|
154
154
|
try {
|
|
155
|
-
var
|
|
156
|
-
if (
|
|
157
|
-
var a = p[
|
|
155
|
+
var o = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
156
|
+
if (o && o.length > 3) {
|
|
157
|
+
var a = p[h(o)];
|
|
158
158
|
if (a)
|
|
159
159
|
return a;
|
|
160
|
-
D("Moment Timezone found " +
|
|
160
|
+
D("Moment Timezone found " + o + " from the Intl api, but did not have that data loaded.");
|
|
161
161
|
}
|
|
162
162
|
} catch {
|
|
163
163
|
}
|
|
164
|
-
var n = F(), R = n.length, e = b0(n), r = [],
|
|
164
|
+
var n = F(), R = n.length, e = b0(n), r = [], Z, U, V;
|
|
165
165
|
for (U = 0; U < e.length; U++) {
|
|
166
|
-
for (
|
|
167
|
-
|
|
168
|
-
r.push(
|
|
166
|
+
for (Z = new H(g(e[U])), V = 0; V < R; V++)
|
|
167
|
+
Z.scoreOffsetAt(n[V]);
|
|
168
|
+
r.push(Z);
|
|
169
169
|
}
|
|
170
170
|
return r.sort(M0), r.length > 0 ? r[0].zone.name : void 0;
|
|
171
171
|
}
|
|
172
|
-
function O0(
|
|
173
|
-
return (!
|
|
172
|
+
function O0(o) {
|
|
173
|
+
return (!W || o) && (W = p0()), W;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
176
|
-
return (
|
|
175
|
+
function h(o) {
|
|
176
|
+
return (o || "").toLowerCase().replace(/\//g, "_");
|
|
177
177
|
}
|
|
178
|
-
function k(
|
|
178
|
+
function k(o) {
|
|
179
179
|
var a, n, R, e;
|
|
180
|
-
for (typeof
|
|
181
|
-
R =
|
|
180
|
+
for (typeof o == "string" && (o = [o]), a = 0; a < o.length; a++)
|
|
181
|
+
R = o[a].split("|"), n = R[0], e = h(n), b[e] = o[a], p[e] = n, z0(e, R[2].split(" "));
|
|
182
182
|
}
|
|
183
|
-
function g(
|
|
184
|
-
|
|
185
|
-
var n = b[
|
|
186
|
-
return n instanceof G ? n : typeof n == "string" ? (n = new G(n), b[
|
|
183
|
+
function g(o, a) {
|
|
184
|
+
o = h(o);
|
|
185
|
+
var n = b[o], R;
|
|
186
|
+
return n instanceof G ? n : typeof n == "string" ? (n = new G(n), b[o] = n, n) : O[o] && a !== g && (R = g(O[o], g)) ? (n = b[o] = new G(), n._set(R), n.name = p[o], n) : null;
|
|
187
187
|
}
|
|
188
188
|
function A0() {
|
|
189
|
-
var
|
|
190
|
-
for (
|
|
191
|
-
p.hasOwnProperty(
|
|
189
|
+
var o, a = [];
|
|
190
|
+
for (o in p)
|
|
191
|
+
p.hasOwnProperty(o) && (b[o] || b[O[o]]) && p[o] && a.push(p[o]);
|
|
192
192
|
return a.sort();
|
|
193
193
|
}
|
|
194
194
|
function c0() {
|
|
195
195
|
return Object.keys(c);
|
|
196
196
|
}
|
|
197
|
-
function v(
|
|
197
|
+
function v(o) {
|
|
198
198
|
var a, n, R, e;
|
|
199
|
-
for (typeof
|
|
200
|
-
n =
|
|
199
|
+
for (typeof o == "string" && (o = [o]), a = 0; a < o.length; a++)
|
|
200
|
+
n = o[a].split("|"), R = h(n[0]), e = h(n[1]), O[R] = e, p[R] = n[0], O[e] = R, p[e] = n[1];
|
|
201
201
|
}
|
|
202
|
-
function W0(
|
|
202
|
+
function W0(o) {
|
|
203
203
|
var a, n, R, e;
|
|
204
|
-
if (!(!
|
|
205
|
-
for (a = 0; a <
|
|
206
|
-
e =
|
|
204
|
+
if (!(!o || !o.length))
|
|
205
|
+
for (a = 0; a < o.length; a++)
|
|
206
|
+
e = o[a].split("|"), n = e[0].toUpperCase(), R = e[1].split(" "), c[n] = new B(
|
|
207
207
|
n,
|
|
208
208
|
R
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
|
-
function o0(
|
|
212
|
-
return
|
|
211
|
+
function o0(o) {
|
|
212
|
+
return o = o.toUpperCase(), c[o] || null;
|
|
213
213
|
}
|
|
214
|
-
function q0(
|
|
215
|
-
if (
|
|
214
|
+
function q0(o, a) {
|
|
215
|
+
if (o = o0(o), !o)
|
|
216
216
|
return null;
|
|
217
|
-
var n =
|
|
217
|
+
var n = o.zones.sort();
|
|
218
218
|
return a ? n.map(function(R) {
|
|
219
219
|
var e = g(R);
|
|
220
220
|
return {
|
|
@@ -223,62 +223,62 @@ var j = { exports: {} };
|
|
|
223
223
|
};
|
|
224
224
|
}) : n;
|
|
225
225
|
}
|
|
226
|
-
function Y0(
|
|
227
|
-
k(
|
|
226
|
+
function Y0(o) {
|
|
227
|
+
k(o.zones), v(o.links), W0(o.countries), u.dataVersion = o.version;
|
|
228
228
|
}
|
|
229
|
-
function $(
|
|
230
|
-
return $.didShowError || ($.didShowError = !0, D("moment.tz.zoneExists('" +
|
|
229
|
+
function $(o) {
|
|
230
|
+
return $.didShowError || ($.didShowError = !0, D("moment.tz.zoneExists('" + o + "') has been deprecated in favor of !moment.tz.zone('" + o + "')")), !!g(o);
|
|
231
231
|
}
|
|
232
|
-
function J(
|
|
233
|
-
var a =
|
|
234
|
-
return !!(
|
|
232
|
+
function J(o) {
|
|
233
|
+
var a = o._f === "X" || o._f === "x";
|
|
234
|
+
return !!(o._a && o._tzm === void 0 && !a);
|
|
235
235
|
}
|
|
236
|
-
function D(
|
|
237
|
-
typeof console < "u" && typeof console.error == "function" && console.error(
|
|
236
|
+
function D(o) {
|
|
237
|
+
typeof console < "u" && typeof console.error == "function" && console.error(o);
|
|
238
238
|
}
|
|
239
|
-
function u(
|
|
239
|
+
function u(o) {
|
|
240
240
|
var a = Array.prototype.slice.call(arguments, 0, -1), n = arguments[arguments.length - 1], R = M.utc.apply(null, a), e;
|
|
241
|
-
return !M.isMoment(
|
|
241
|
+
return !M.isMoment(o) && J(R) && (e = g(n)) && R.add(e.parse(R), "minutes"), R.tz(n), R;
|
|
242
242
|
}
|
|
243
|
-
u.version = z, u.dataVersion = "", u._zones = b, u._links = O, u._names = p, u._countries = c, 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 =
|
|
243
|
+
u.version = z, u.dataVersion = "", u._zones = b, u._links = O, u._names = p, u._countries = c, 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 = l, u.unpackBase60 = T, u.needsOffset = J, u.moveInvalidForward = !0, u.moveAmbiguousForward = !1, u.countries = c0, u.zonesForCountry = q0;
|
|
244
244
|
var C = M.fn;
|
|
245
|
-
M.tz = u, M.defaultZone = null, M.updateOffset = function(
|
|
245
|
+
M.tz = u, M.defaultZone = null, M.updateOffset = function(o, a) {
|
|
246
246
|
var n = M.defaultZone, R;
|
|
247
|
-
if (
|
|
248
|
-
if (R =
|
|
249
|
-
var e =
|
|
250
|
-
|
|
247
|
+
if (o._z === void 0 && (n && J(o) && !o._isUTC && o.isValid() && (o._d = M.utc(o._a)._d, o.utc().add(n.parse(o), "minutes")), o._z = n), o._z)
|
|
248
|
+
if (R = o._z.utcOffset(o), Math.abs(R) < 16 && (R = R / 60), o.utcOffset !== void 0) {
|
|
249
|
+
var e = o._z;
|
|
250
|
+
o.utcOffset(-R, a), o._z = e;
|
|
251
251
|
} else
|
|
252
|
-
|
|
253
|
-
}, C.tz = function(
|
|
254
|
-
if (
|
|
255
|
-
if (typeof
|
|
256
|
-
throw new Error("Time zone name must be a string, got " +
|
|
257
|
-
return this._z = g(
|
|
252
|
+
o.zone(R, a);
|
|
253
|
+
}, C.tz = function(o, a) {
|
|
254
|
+
if (o) {
|
|
255
|
+
if (typeof o != "string")
|
|
256
|
+
throw new Error("Time zone name must be a string, got " + o + " [" + typeof o + "]");
|
|
257
|
+
return this._z = g(o), this._z ? M.updateOffset(this, a) : D("Moment Timezone has no data for " + o + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
|
|
258
258
|
}
|
|
259
259
|
if (this._z)
|
|
260
260
|
return this._z.name;
|
|
261
261
|
};
|
|
262
|
-
function y(
|
|
262
|
+
function y(o) {
|
|
263
263
|
return function() {
|
|
264
|
-
return this._z ? this._z.abbr(this) :
|
|
264
|
+
return this._z ? this._z.abbr(this) : o.call(this);
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
|
-
function w(
|
|
267
|
+
function w(o) {
|
|
268
268
|
return function() {
|
|
269
|
-
return this._z = null,
|
|
269
|
+
return this._z = null, o.apply(this, arguments);
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
|
-
function d0(
|
|
272
|
+
function d0(o) {
|
|
273
273
|
return function() {
|
|
274
|
-
return arguments.length > 0 && (this._z = null),
|
|
274
|
+
return arguments.length > 0 && (this._z = null), o.apply(this, arguments);
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
|
-
C.zoneName = y(C.zoneName), C.zoneAbbr = y(C.zoneAbbr), C.utc = w(C.utc), C.local = w(C.local), C.utcOffset = d0(C.utcOffset), M.tz.setDefault = function(
|
|
278
|
-
return (Y < 2 || Y === 2 && d < 9) && D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone =
|
|
277
|
+
C.zoneName = y(C.zoneName), C.zoneAbbr = y(C.zoneAbbr), C.utc = w(C.utc), C.local = w(C.local), C.utcOffset = d0(C.utcOffset), M.tz.setDefault = function(o) {
|
|
278
|
+
return (Y < 2 || Y === 2 && d < 9) && D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = o ? g(o) : null, M;
|
|
279
279
|
};
|
|
280
|
-
var
|
|
281
|
-
return Object.prototype.toString.call(
|
|
280
|
+
var K = M.momentProperties;
|
|
281
|
+
return Object.prototype.toString.call(K) === "[object Array]" ? (K.push("_z"), K.push("_a")) : K && (K._z = null), M;
|
|
282
282
|
});
|
|
283
283
|
})(j);
|
|
284
284
|
var n0 = j.exports;
|
|
@@ -1145,15 +1145,15 @@ var x = { exports: {} };
|
|
|
1145
1145
|
throw new RangeError("invalid coordinates");
|
|
1146
1146
|
if (90 <= z)
|
|
1147
1147
|
return "Etc/GMT";
|
|
1148
|
-
var p = -1, A = 48 * (180 + b) / 360.00000000000006,
|
|
1148
|
+
var p = -1, A = 48 * (180 + b) / 360.00000000000006, W = 24 * (90 - z) / 180.00000000000003, q = 0 | A, Y = 0 | W, d = 96 * Y + 2 * q;
|
|
1149
1149
|
for (d = 56 * O.charCodeAt(d) + O.charCodeAt(d + 1) - 1995; d + c.length < 3136; )
|
|
1150
|
-
d = 56 * O.charCodeAt(d = 8 * (p = p + d + 1) + 4 * (Y = 0 | (
|
|
1150
|
+
d = 56 * O.charCodeAt(d = 8 * (p = p + d + 1) + 4 * (Y = 0 | (W = 2 * (W - Y) % 2)) + 2 * (q = 0 | (A = 2 * (A - q) % 2)) + 2304) + O.charCodeAt(d + 1) - 1995;
|
|
1151
1151
|
return c[d + c.length - 3136];
|
|
1152
1152
|
}
|
|
1153
1153
|
I.exports = M;
|
|
1154
1154
|
})(x);
|
|
1155
|
-
var
|
|
1156
|
-
const
|
|
1155
|
+
var f0 = x.exports;
|
|
1156
|
+
const S0 = /* @__PURE__ */ X0(f0);
|
|
1157
1157
|
class X {
|
|
1158
1158
|
/**
|
|
1159
1159
|
* 基于输入的经度,计算出时区
|
|
@@ -1161,7 +1161,7 @@ class X {
|
|
|
1161
1161
|
* @param lat
|
|
1162
1162
|
*/
|
|
1163
1163
|
static guessTimeZoneOffset(M, z) {
|
|
1164
|
-
const b =
|
|
1164
|
+
const b = S0(z, M), O = s().tz(b).utcOffset();
|
|
1165
1165
|
return this.roundPrecision(O / 60, 1);
|
|
1166
1166
|
}
|
|
1167
1167
|
/**
|
|
@@ -1177,13 +1177,13 @@ class X {
|
|
|
1177
1177
|
z = z < 6 ? 6 : z, M = X.convertToStdLng(M, z);
|
|
1178
1178
|
let O = "E";
|
|
1179
1179
|
M < 0 && (O = "W"), M = Math.abs(M), b = b.toUpperCase();
|
|
1180
|
-
let c = M * 3600, p, A,
|
|
1181
|
-
p = c % 3600 % 60, b.indexOf("S") !== -1 && (c = c - p, A = X.padNumber(p, 2, 2)),
|
|
1180
|
+
let c = M * 3600, p, A, W, q, Y, d;
|
|
1181
|
+
p = c % 3600 % 60, b.indexOf("S") !== -1 && (c = c - p, A = X.padNumber(p, 2, 2)), W = c / 60 % 60, b.indexOf("M") !== -1 && (b.indexOf("S") !== -1 ? q = X.roundPrecision(W, z).toString().padStart(2, "0") : q = X.padNumber(W, 2, 2), c = c - W * 60), Y = c / 3600, b.indexOf("M") !== -1 ? d = X.roundPrecision(Y, z).toString().padStart(3, "0") : d = X.padNumber(Y, 3, 2), Number(A) >= 60 && (q = Number(q) + 1, A = 0), Number(q) >= 60 && (d = Number(d) + 1, q = 0);
|
|
1182
1182
|
const L = `${b.replace(/S+/gi, A).replace(/M+/gi, q).replace(/H+/gi, d)}${O}`;
|
|
1183
1183
|
return {
|
|
1184
1184
|
direction: O,
|
|
1185
1185
|
degree: X.roundPrecision(Y, z),
|
|
1186
|
-
minute: X.roundPrecision(
|
|
1186
|
+
minute: X.roundPrecision(W, z),
|
|
1187
1187
|
second: X.roundPrecision(p, z),
|
|
1188
1188
|
pretty: L
|
|
1189
1189
|
};
|
|
@@ -1198,13 +1198,13 @@ class X {
|
|
|
1198
1198
|
z = z < 6 ? 6 : z, M = M % 180;
|
|
1199
1199
|
let O = "N";
|
|
1200
1200
|
M < 0 && (O = "S"), M = Math.abs(M), b = b.toUpperCase();
|
|
1201
|
-
let c = M * 3600, p, A,
|
|
1202
|
-
p = c % 3600 % 60, b.indexOf("S") !== -1 && (c = c - p, A = X.padNumber(p, 2, 2)),
|
|
1201
|
+
let c = M * 3600, p, A, W, q, Y, d;
|
|
1202
|
+
p = c % 3600 % 60, b.indexOf("S") !== -1 && (c = c - p, A = X.padNumber(p, 2, 2)), W = c / 60 % 60, b.indexOf("M") !== -1 && (b.indexOf("S") !== -1 ? q = X.roundPrecision(W, z).toString().padStart(2, "0") : q = X.padNumber(W, 2, 2), c = c - W * 60), Y = c / 3600, b.indexOf("M") !== -1 ? d = X.roundPrecision(Y, z).toString().padStart(2, "0") : d = X.padNumber(Y, 2, 2), Number(A) >= 60 && (q = Number(q) + 1, A = 0), Number(q) >= 60 && (d = Number(d) + 1, q = 0);
|
|
1203
1203
|
const L = `${b.replace(/S+/gi, A).replace(/M+/gi, q).replace(/H+/gi, d)}${O}`;
|
|
1204
1204
|
return {
|
|
1205
1205
|
direction: O,
|
|
1206
1206
|
degree: X.roundPrecision(Y, z),
|
|
1207
|
-
minute: X.roundPrecision(
|
|
1207
|
+
minute: X.roundPrecision(W, z),
|
|
1208
1208
|
second: X.roundPrecision(p, z),
|
|
1209
1209
|
pretty: L
|
|
1210
1210
|
};
|
|
@@ -1215,11 +1215,11 @@ class X {
|
|
|
1215
1215
|
M = X.strReplace(M, "LNG");
|
|
1216
1216
|
const O = M[M.length - 1].toUpperCase();
|
|
1217
1217
|
M = M.substring(0, M.length - 1).trim();
|
|
1218
|
-
const c = M.split(" ").filter((
|
|
1218
|
+
const c = M.split(" ").filter((W) => W !== "").map((W) => Math.abs(Number(W)));
|
|
1219
1219
|
let [p, A] = c;
|
|
1220
1220
|
if (A = A > 60 ? A / Math.pow(10, String(A).length - 2) : A, p > 360 && !A) {
|
|
1221
|
-
const
|
|
1222
|
-
A = p -
|
|
1221
|
+
const W = this.roundPrecision(p / 100, 0);
|
|
1222
|
+
A = p - W * 100, p = W;
|
|
1223
1223
|
}
|
|
1224
1224
|
b = p + (A ?? 0) / 60, O === "W" && (b = b * -1);
|
|
1225
1225
|
} else
|
|
@@ -1232,11 +1232,11 @@ class X {
|
|
|
1232
1232
|
M = X.strReplace(M, "LAT");
|
|
1233
1233
|
const O = M[M.length - 1].toUpperCase();
|
|
1234
1234
|
M = M.substring(0, M.length - 1).trim();
|
|
1235
|
-
const c = M.split(" ").filter((
|
|
1235
|
+
const c = M.split(" ").filter((W) => W !== "").map((W) => Math.abs(Number(W)));
|
|
1236
1236
|
let [p, A] = c;
|
|
1237
1237
|
if (A = A > 60 ? A / Math.pow(10, String(A).length - 2) : A, p > 90 && !A) {
|
|
1238
|
-
const
|
|
1239
|
-
A = p -
|
|
1238
|
+
const W = this.roundPrecision(p / 100, 0);
|
|
1239
|
+
A = p - W * 100, p = W;
|
|
1240
1240
|
}
|
|
1241
1241
|
if (b = p + (A ?? 0) / 60, b > 90)
|
|
1242
1242
|
throw new Error(`latitude out of range: ${M}${O}`);
|
|
@@ -1311,7 +1311,7 @@ try {
|
|
|
1311
1311
|
} catch {
|
|
1312
1312
|
} finally {
|
|
1313
1313
|
}
|
|
1314
|
-
class
|
|
1314
|
+
class S {
|
|
1315
1315
|
/**
|
|
1316
1316
|
* 计算方位角
|
|
1317
1317
|
* @param from 坐标 {lng, lat}
|
|
@@ -1321,12 +1321,12 @@ class f {
|
|
|
1321
1321
|
* @returns {number} 单位度
|
|
1322
1322
|
*/
|
|
1323
1323
|
static calculateBearing(M, z, b = !0, O = 4) {
|
|
1324
|
-
const c =
|
|
1324
|
+
const c = f.points([
|
|
1325
1325
|
[M.lng, M.lat],
|
|
1326
1326
|
[z.lng, z.lat]
|
|
1327
1327
|
]);
|
|
1328
1328
|
let p;
|
|
1329
|
-
return b ? p =
|
|
1329
|
+
return b ? p = f.rhumbBearing(c.features[0], c.features[1]) : p = f.bearing(c.features[0], c.features[1]), p < 0 && (p += 360), X.roundPrecision(p, O);
|
|
1330
1330
|
}
|
|
1331
1331
|
/**
|
|
1332
1332
|
* 计算两点间距离
|
|
@@ -1339,12 +1339,12 @@ class f {
|
|
|
1339
1339
|
*/
|
|
1340
1340
|
static calculateDistance(M, z, b = !0, O = 4, c = "nauticalmiles") {
|
|
1341
1341
|
M = { ...M }, z = { ...z }, M.lng = X.convertToStdLng(M.lng, O), z.lng = X.convertToStdLng(z.lng, O);
|
|
1342
|
-
const p =
|
|
1342
|
+
const p = f.points([
|
|
1343
1343
|
[M.lng, M.lat],
|
|
1344
1344
|
[z.lng, z.lat]
|
|
1345
1345
|
]);
|
|
1346
1346
|
let A;
|
|
1347
|
-
return b ? A =
|
|
1347
|
+
return b ? A = f.rhumbDistance(p.features[0], p.features[1], { units: c }) : A = f.distance(p.features[0], p.features[1], { units: c }), X.roundPrecision(A, O);
|
|
1348
1348
|
}
|
|
1349
1349
|
/**
|
|
1350
1350
|
* 计算航线距离
|
|
@@ -1356,10 +1356,10 @@ class f {
|
|
|
1356
1356
|
let O = 0, c;
|
|
1357
1357
|
for (const p of M)
|
|
1358
1358
|
for (let A = 0; A < p.length - 1; A++) {
|
|
1359
|
-
const
|
|
1360
|
-
A === 0 && c && (O += this.calculateDistance(c,
|
|
1359
|
+
const W = { lng: p[A][0], lat: p[A][1] };
|
|
1360
|
+
A === 0 && c && (O += this.calculateDistance(c, W, !0, z, b));
|
|
1361
1361
|
const q = { lng: p[A + 1][0], lat: p[A + 1][1] };
|
|
1362
|
-
O += this.calculateDistance(
|
|
1362
|
+
O += this.calculateDistance(W, q, !0, z, b), c = q;
|
|
1363
1363
|
}
|
|
1364
1364
|
return X.roundPrecision(O, z);
|
|
1365
1365
|
}
|
|
@@ -1372,11 +1372,11 @@ class f {
|
|
|
1372
1372
|
* @param rhumb
|
|
1373
1373
|
*/
|
|
1374
1374
|
static calculateCoordinate(M, z, b, O = "nauticalmiles", c = !0) {
|
|
1375
|
-
const p =
|
|
1375
|
+
const p = f.point([M.lng, M.lat]);
|
|
1376
1376
|
let A;
|
|
1377
|
-
c ? A =
|
|
1378
|
-
const
|
|
1379
|
-
return { lng: X.convertToStdLng(
|
|
1377
|
+
c ? A = f.rhumbDestination(p, b, z, { units: O }) : A = f.destination(p, b, z, { units: O });
|
|
1378
|
+
const W = A.geometry.coordinates;
|
|
1379
|
+
return { lng: X.convertToStdLng(W[0], 8), lat: X.roundPrecision(W[1], 8) };
|
|
1380
1380
|
}
|
|
1381
1381
|
/**
|
|
1382
1382
|
* 插值大圆坐标(基于两点方位角和间距)
|
|
@@ -1388,11 +1388,11 @@ class f {
|
|
|
1388
1388
|
* @param units 单位,默认 nm(海里)
|
|
1389
1389
|
*/
|
|
1390
1390
|
static interpolateCoordinates(M, z, b, O = !0, c = !0, p = "nauticalmiles") {
|
|
1391
|
-
const A = [],
|
|
1391
|
+
const A = [], W = this.calculateBearing(M, z, !1), q = this.calculateDistance(M, z, !1, 8, p);
|
|
1392
1392
|
O && A.push({ lng: M.lng, lat: M.lat });
|
|
1393
1393
|
let Y = 0;
|
|
1394
1394
|
for (; Y < q; )
|
|
1395
|
-
Y += b, Y < q && A.push(this.calculateCoordinate(M,
|
|
1395
|
+
Y += b, Y < q && A.push(this.calculateCoordinate(M, W, Y, p, !1));
|
|
1396
1396
|
return c && A.push({ lng: z.lng, lat: z.lat }), A;
|
|
1397
1397
|
}
|
|
1398
1398
|
/**
|
|
@@ -1415,25 +1415,25 @@ class f {
|
|
|
1415
1415
|
let c, p;
|
|
1416
1416
|
for (let A = 0; A < M.length - 1; A++) {
|
|
1417
1417
|
c = X.convertToStdLng(M[A].lng, 8), p = X.convertToStdLng(M[A + 1].lng, 8), M[A].lat = X.roundPrecision(M[A].lat, 8), M[A + 1].lat = X.roundPrecision(M[A + 1].lat, 8), b.push([c, M[A].lat]);
|
|
1418
|
-
const
|
|
1419
|
-
if (Math.abs(
|
|
1418
|
+
const W = c - p;
|
|
1419
|
+
if (Math.abs(W) > 180) {
|
|
1420
1420
|
const q = X.convertToMonotonicLng2([
|
|
1421
1421
|
[c, M[A].lat],
|
|
1422
1422
|
[p, M[A + 1].lat]
|
|
1423
1423
|
]);
|
|
1424
1424
|
let Y, d;
|
|
1425
|
-
z ? (Y =
|
|
1426
|
-
[
|
|
1427
|
-
[
|
|
1428
|
-
])) : (Y =
|
|
1429
|
-
const L =
|
|
1425
|
+
z ? (Y = f.lineString(q), d = f.lineString([
|
|
1426
|
+
[W > 0 ? 180 : -180, 89],
|
|
1427
|
+
[W > 0 ? 180 : -180, -89]
|
|
1428
|
+
])) : (Y = f.greatCircle(q[0], q[1]), d = f.greatCircle([W > 0 ? 180 : -180, 89], [W > 0 ? 180 : -180, -89]));
|
|
1429
|
+
const L = f.lineIntersect(Y, d);
|
|
1430
1430
|
let T;
|
|
1431
1431
|
if (L.features.length) {
|
|
1432
|
-
const N =
|
|
1432
|
+
const N = f.getCoord(L.features[0]);
|
|
1433
1433
|
T = X.roundPrecision(N[1], 8);
|
|
1434
1434
|
} else
|
|
1435
1435
|
T = M[A].lat;
|
|
1436
|
-
|
|
1436
|
+
W > 0 ? (b.push([180 - 1e-6, T]), O.push([...b]), b = [], b.push([-(180 - 1e-6), T])) : (b.push([-(180 - 1e-6), T]), O.push([...b]), b = [], b.push([180 - 1e-6, T]));
|
|
1437
1437
|
}
|
|
1438
1438
|
A === M.length - 2 && b.push([p, M[A + 1].lat]);
|
|
1439
1439
|
}
|
|
@@ -1495,9 +1495,9 @@ class f {
|
|
|
1495
1495
|
static mergeCoordinateToRoute(M, z) {
|
|
1496
1496
|
M.lng = X.convertToStdLng(M.lng, 8);
|
|
1497
1497
|
let b = Number.MAX_VALUE, O = 0, c = 0, p, A;
|
|
1498
|
-
return z.forEach((
|
|
1499
|
-
for (let Y = 0; Y <
|
|
1500
|
-
const d = { lng:
|
|
1498
|
+
return z.forEach((W, q) => {
|
|
1499
|
+
for (let Y = 0; Y < W.length - 1; Y++) {
|
|
1500
|
+
const d = { lng: W[Y][0], lat: W[Y][1] }, L = { lng: W[Y + 1][0], lat: W[Y + 1][1] }, T = this.calculatePointToLineDistance(M, d, L);
|
|
1501
1501
|
b > T && (b = T, c = Y, O = q, p = this.calculateDistance(d, M), A = this.calculateDistance(L, M));
|
|
1502
1502
|
}
|
|
1503
1503
|
}), p !== 0 && A !== 0 ? z[O].splice(c + 1, 0, [M.lng, M.lat]) : p === 0 ? z[O].splice(c, 1, [M.lng, M.lat]) : A === 0 && z[O].splice(c + 1, 1, [M.lng, M.lat]), z;
|
|
@@ -1509,8 +1509,8 @@ class f {
|
|
|
1509
1509
|
*/
|
|
1510
1510
|
static appendCoordinateToRoute(M, z) {
|
|
1511
1511
|
M.lng = X.convertToStdLng(M.lng, 8);
|
|
1512
|
-
const b =
|
|
1513
|
-
return b.push(M),
|
|
1512
|
+
const b = S.convertRouteToCoordinates(z);
|
|
1513
|
+
return b.push(M), S.divideAccordingToLng(b);
|
|
1514
1514
|
}
|
|
1515
1515
|
/**
|
|
1516
1516
|
* 向route头加1个坐标
|
|
@@ -1518,8 +1518,8 @@ class f {
|
|
|
1518
1518
|
* @param route
|
|
1519
1519
|
*/
|
|
1520
1520
|
static unshiftCoordinateToRoute(M, z) {
|
|
1521
|
-
const b =
|
|
1522
|
-
return b.unshift(M),
|
|
1521
|
+
const b = S.convertRouteToCoordinates(z);
|
|
1522
|
+
return b.unshift(M), S.divideAccordingToLng(b);
|
|
1523
1523
|
}
|
|
1524
1524
|
/**
|
|
1525
1525
|
* 合并多个waypoints进航线
|
|
@@ -1546,12 +1546,12 @@ class f {
|
|
|
1546
1546
|
if (c === 2)
|
|
1547
1547
|
return;
|
|
1548
1548
|
const A = [];
|
|
1549
|
-
for (const
|
|
1550
|
-
if (X.roundPrecision(z.lng, 8) === X.roundPrecision(
|
|
1551
|
-
A.push(
|
|
1549
|
+
for (const W of p) {
|
|
1550
|
+
if (X.roundPrecision(z.lng, 8) === X.roundPrecision(W[0], 8) && X.roundPrecision(z.lat, 8) === X.roundPrecision(W[1], 8)) {
|
|
1551
|
+
A.push(W), c === 0 && A.push([M.lng, M.lat]), c = 2;
|
|
1552
1552
|
break;
|
|
1553
1553
|
}
|
|
1554
|
-
c === 1 ? A.push(
|
|
1554
|
+
c === 1 ? A.push(W) : X.roundPrecision(M.lng, 8) === X.roundPrecision(W[0], 8) && X.roundPrecision(M.lat, 8) === X.roundPrecision(W[1], 8) && (c = 1, A.push(W));
|
|
1555
1555
|
}
|
|
1556
1556
|
A.length && O.push(A);
|
|
1557
1557
|
}), O;
|
|
@@ -1567,10 +1567,10 @@ class f {
|
|
|
1567
1567
|
static calculateRangeWaypoints(M, z, b, O = []) {
|
|
1568
1568
|
const c = this.convertRouteToCoordinates(b, 0), p = this.mergeCoordinatesToWaypoints([M, z], c.length ? c : O), A = p.findIndex(
|
|
1569
1569
|
(Y) => X.roundPrecision(M.lng, 8) === X.roundPrecision(Y.lng, 8) && X.roundPrecision(M.lat, 8) === X.roundPrecision(Y.lat, 8)
|
|
1570
|
-
),
|
|
1570
|
+
), W = p.findIndex(
|
|
1571
1571
|
(Y) => X.roundPrecision(z.lng, 8) === X.roundPrecision(Y.lng, 8) && X.roundPrecision(z.lat, 8) === X.roundPrecision(Y.lat, 8)
|
|
1572
1572
|
);
|
|
1573
|
-
return p.filter((Y, d) => d >= A && d <=
|
|
1573
|
+
return p.filter((Y, d) => d >= A && d <= W);
|
|
1574
1574
|
}
|
|
1575
1575
|
/**
|
|
1576
1576
|
* 计算坐标到航路上的最短距离
|
|
@@ -1580,9 +1580,9 @@ class f {
|
|
|
1580
1580
|
static calculateMinDistanceToRoute(M, z) {
|
|
1581
1581
|
let b = Number.MAX_VALUE, O = 0, c = 0;
|
|
1582
1582
|
return z.forEach((p, A) => {
|
|
1583
|
-
for (let
|
|
1584
|
-
const q = { lng: p[
|
|
1585
|
-
b > d && (b = d, O =
|
|
1583
|
+
for (let W = 0; W < p.length - 1; W++) {
|
|
1584
|
+
const q = { lng: p[W][0], lat: p[W][1] }, Y = { lng: p[W + 1][0], lat: p[W + 1][1] }, d = this.calculatePointToLineDistance(M, q, Y);
|
|
1585
|
+
b > d && (b = d, O = W, c = A);
|
|
1586
1586
|
}
|
|
1587
1587
|
}), { minDist: b, segIndex: c, minIndex: O };
|
|
1588
1588
|
}
|
|
@@ -1593,21 +1593,21 @@ class f {
|
|
|
1593
1593
|
* @return [[[lng, lat]]]
|
|
1594
1594
|
*/
|
|
1595
1595
|
static calculateSubRoute(M, z) {
|
|
1596
|
-
const b =
|
|
1597
|
-
|
|
1596
|
+
const b = S.convertRouteToCoordinates(z);
|
|
1597
|
+
S.mergeCoordinateToWaypoints(M, b, !0), z = S.divideAccordingToLng(b);
|
|
1598
1598
|
const { segIndex: O, minIndex: c } = this.calculateMinDistanceToRoute({ ...M }, z);
|
|
1599
1599
|
M.lng = X.convertToStdLng(M.lng);
|
|
1600
1600
|
const p = [];
|
|
1601
1601
|
let A = !0;
|
|
1602
|
-
for (let
|
|
1602
|
+
for (let W = O; W < z.length; W++)
|
|
1603
1603
|
if (A) {
|
|
1604
1604
|
const q = [];
|
|
1605
1605
|
q.push([M.lng, M.lat]);
|
|
1606
|
-
for (let Y = c + 1; Y < z[
|
|
1607
|
-
M.lng === z[
|
|
1606
|
+
for (let Y = c + 1; Y < z[W].length; Y++)
|
|
1607
|
+
M.lng === z[W][Y][0] && M.lat === z[W][Y][1] || q.push(z[W][Y]);
|
|
1608
1608
|
p.push(q), A = !1;
|
|
1609
1609
|
} else
|
|
1610
|
-
p.push([...z[
|
|
1610
|
+
p.push([...z[W]]);
|
|
1611
1611
|
return p;
|
|
1612
1612
|
}
|
|
1613
1613
|
/**
|
|
@@ -1619,12 +1619,12 @@ class f {
|
|
|
1619
1619
|
static calculateSubWaypoints(M, z) {
|
|
1620
1620
|
let b = Number.MAX_VALUE, O = 0;
|
|
1621
1621
|
for (let p = 0; p < z.length - 1; p++) {
|
|
1622
|
-
const A = z[p],
|
|
1622
|
+
const A = z[p], W = z[p + 1];
|
|
1623
1623
|
if (this.calculateDistance(M, A) === 0)
|
|
1624
1624
|
return z;
|
|
1625
|
-
if (this.calculateDistance(M,
|
|
1625
|
+
if (this.calculateDistance(M, W) === 0)
|
|
1626
1626
|
return z.filter((Y, d) => d > 0);
|
|
1627
|
-
const q = this.calculatePointToLineDistance(M, A,
|
|
1627
|
+
const q = this.calculatePointToLineDistance(M, A, W);
|
|
1628
1628
|
b > q && (b = q, O = p);
|
|
1629
1629
|
}
|
|
1630
1630
|
M.lng = X.convertToStdLng(M.lng);
|
|
@@ -1644,11 +1644,11 @@ class f {
|
|
|
1644
1644
|
M.lng = X.convertToStdLng(M.lng, 8), z = { ...z }, b = { ...b }, z.lng = X.convertToStdLng(z.lng, 8), b.lng = X.convertToStdLng(b.lng, 8);
|
|
1645
1645
|
const c = X.convertToMonotonicLng([z, b]);
|
|
1646
1646
|
z = c[0], b = c[1];
|
|
1647
|
-
const p =
|
|
1647
|
+
const p = f.lineString([
|
|
1648
1648
|
[z.lng, z.lat],
|
|
1649
1649
|
[b.lng, b.lat]
|
|
1650
|
-
]), A =
|
|
1651
|
-
return X.roundPrecision(Math.min(A,
|
|
1650
|
+
]), A = f.pointToLineDistance(f.point([M.lng, M.lat]), p, O), W = f.pointToLineDistance(f.point([M.lng > 0 ? M.lng - 360 : M.lng + 360, M.lat]), p, O);
|
|
1651
|
+
return X.roundPrecision(Math.min(A, W), 6);
|
|
1652
1652
|
}
|
|
1653
1653
|
/**
|
|
1654
1654
|
* 计算途经点的COG, Distance等属性
|
|
@@ -1691,20 +1691,20 @@ class f {
|
|
|
1691
1691
|
if (z.length < 2)
|
|
1692
1692
|
z.push(M);
|
|
1693
1693
|
else {
|
|
1694
|
-
for (let
|
|
1695
|
-
const q = { lng: z[
|
|
1696
|
-
O >= d && (O = d, c =
|
|
1694
|
+
for (let W = 0; W < z.length - 1; W++) {
|
|
1695
|
+
const q = { lng: z[W].lng, lat: z[W].lat }, Y = { lng: z[W + 1].lng, lat: z[W + 1].lat }, d = this.calculatePointToLineDistance(M, q, Y);
|
|
1696
|
+
O >= d && (O = d, c = W, p = this.calculateDistance(q, M, !1, 6), A = this.calculateDistance(Y, M, !1, 6));
|
|
1697
1697
|
}
|
|
1698
1698
|
p !== 0 && A !== 0 ? p < O || p === O && c === 0 ? z.unshift(M) : A < O || A === O && c === z.length - 2 ? z.push(M) : z.splice(c + 1, 0, M) : p === 0 ? b ? z.splice(c, 1, M) : z.splice(c + 1, 0, M) : A === 0 && (b ? z.splice(c + 1, 1, M) : z.splice(c + 1, 0, M));
|
|
1699
1699
|
}
|
|
1700
|
-
return z.map((
|
|
1701
|
-
|
|
1700
|
+
return z.map((W, q) => {
|
|
1701
|
+
W.lng = X.convertToStdLng(W.lng);
|
|
1702
1702
|
const Y = z[q + 1];
|
|
1703
|
-
if (Y && (
|
|
1704
|
-
const d = this.calculateDistance(
|
|
1705
|
-
|
|
1703
|
+
if (Y && (W.bearing || ((W.positionTime || 0) > (Y.positionTime || 0) ? W.bearing = this.calculateBearing(Y, W, !0) : W.bearing = this.calculateBearing(W, Y, !0)), W.cog = W.cog || W.bearing, !W.sog && W.positionTime && Y.positionTime)) {
|
|
1704
|
+
const d = this.calculateDistance(W, Y, !0), L = Math.abs(Y.positionTime - W.positionTime) / 3600;
|
|
1705
|
+
W.sog = X.roundPrecision(d / L, 2);
|
|
1706
1706
|
}
|
|
1707
|
-
return
|
|
1707
|
+
return W;
|
|
1708
1708
|
});
|
|
1709
1709
|
}
|
|
1710
1710
|
/**
|
|
@@ -1730,8 +1730,8 @@ class f {
|
|
|
1730
1730
|
* @param route [[[lng, lat]]]
|
|
1731
1731
|
*/
|
|
1732
1732
|
static nearestCoordinateInRoute(M, z) {
|
|
1733
|
-
const b =
|
|
1734
|
-
return { lng: X.roundPrecision(
|
|
1733
|
+
const b = f.point([M.lng, M.lat]), c = this.convertRouteToCoordinates(z).map((q) => [q.lng, q.lat]), p = f.lineString(c), A = f.nearestPointOnLine(p, b), W = f.getCoord(A);
|
|
1734
|
+
return { lng: X.roundPrecision(W[0], 8), lat: X.roundPrecision(W[1], 8) };
|
|
1735
1735
|
}
|
|
1736
1736
|
/**
|
|
1737
1737
|
* 计算经过方向上的最后一个waypoint
|
|
@@ -1765,18 +1765,18 @@ class f {
|
|
|
1765
1765
|
static calculateNextCoordinateAlongRoute(M, z, b, O = "nauticalmiles") {
|
|
1766
1766
|
var L;
|
|
1767
1767
|
const c = M.speed || 12, p = [];
|
|
1768
|
-
let A = [],
|
|
1768
|
+
let A = [], W = !1, q = 0, Y = 0, d;
|
|
1769
1769
|
if (z && b.length ? (p.push(M), b.forEach((T, N) => {
|
|
1770
|
-
if (
|
|
1770
|
+
if (W)
|
|
1771
1771
|
A.push(T);
|
|
1772
1772
|
else {
|
|
1773
1773
|
const i = [];
|
|
1774
1774
|
let t;
|
|
1775
|
-
for (let
|
|
1775
|
+
for (let l = 0; l < T.length; l++)
|
|
1776
1776
|
if (d)
|
|
1777
|
-
i.push(T[
|
|
1777
|
+
i.push(T[l]);
|
|
1778
1778
|
else {
|
|
1779
|
-
t = { lng: T[
|
|
1779
|
+
t = { lng: T[l][0], lat: T[l][1] };
|
|
1780
1780
|
const G = this.calculateDistance(M, t, !0, 8, O);
|
|
1781
1781
|
if (q += G, q < z)
|
|
1782
1782
|
Y += G, G && p.push(t), M = t;
|
|
@@ -1784,10 +1784,10 @@ class f {
|
|
|
1784
1784
|
if (Y = z, q === z)
|
|
1785
1785
|
d = t, i.push([d.lng, d.lat]);
|
|
1786
1786
|
else {
|
|
1787
|
-
const
|
|
1788
|
-
d = this.calculateCoordinate(t, B,
|
|
1787
|
+
const P = q - z, B = this.calculateBearing(t, M);
|
|
1788
|
+
d = this.calculateCoordinate(t, B, P, O), i.push([d.lng, d.lat]), i.push([t.lng, t.lat]);
|
|
1789
1789
|
}
|
|
1790
|
-
|
|
1790
|
+
W = !0;
|
|
1791
1791
|
}
|
|
1792
1792
|
}
|
|
1793
1793
|
i.length && A.push(i), N === b.length - 1 && !d && (d = t);
|
|
@@ -1807,10 +1807,10 @@ class f {
|
|
|
1807
1807
|
* @param to {lng, lat}
|
|
1808
1808
|
*/
|
|
1809
1809
|
static nearestCoordinateInLine(M, z, b) {
|
|
1810
|
-
const O = X.convertToStdLng(M.lng, 6), c =
|
|
1810
|
+
const O = X.convertToStdLng(M.lng, 6), c = f.point([O, M.lat]), p = X.convertToStdLng(z.lng, 6), A = X.convertToStdLng(b.lng, 6), W = f.lineString([
|
|
1811
1811
|
[p, z.lat],
|
|
1812
1812
|
[A, b.lat]
|
|
1813
|
-
]), q =
|
|
1813
|
+
]), q = f.nearestPointOnLine(W, c), Y = f.getCoord(q), d = X.roundPrecision(Y[0], 6), L = X.roundPrecision(Y[1], 6);
|
|
1814
1814
|
return { lng: d, lat: L, inline: !(d === p && L === z.lat) && !(d === A && L === b.lat) };
|
|
1815
1815
|
}
|
|
1816
1816
|
/**
|
|
@@ -1823,16 +1823,16 @@ class f {
|
|
|
1823
1823
|
let O, c;
|
|
1824
1824
|
return M.forEach((p) => {
|
|
1825
1825
|
p.forEach((A) => {
|
|
1826
|
-
const
|
|
1826
|
+
const W = { lng: X.roundPrecision(A[0], 8), lat: X.roundPrecision(A[1], 8) };
|
|
1827
1827
|
if (!c)
|
|
1828
|
-
b.push(
|
|
1828
|
+
b.push(W), c = W;
|
|
1829
1829
|
else if (c.bearing === void 0)
|
|
1830
|
-
c.bearing = this.calculateBearing(c,
|
|
1830
|
+
c.bearing = this.calculateBearing(c, W, !0);
|
|
1831
1831
|
else {
|
|
1832
|
-
const q = this.calculateDistance(O,
|
|
1833
|
-
q && q >= z && (O.bearing = this.calculateBearing(O,
|
|
1832
|
+
const q = this.calculateDistance(O, W, !0);
|
|
1833
|
+
q && q >= z && (O.bearing = this.calculateBearing(O, W, !0), b.push(O), c = O);
|
|
1834
1834
|
}
|
|
1835
|
-
O =
|
|
1835
|
+
O = W;
|
|
1836
1836
|
});
|
|
1837
1837
|
}), O && b.push(O), b;
|
|
1838
1838
|
}
|
|
@@ -1858,8 +1858,8 @@ class f {
|
|
|
1858
1858
|
for (let O = 1; O < z.length; O++) {
|
|
1859
1859
|
const c = z[O - 1], p = z[O];
|
|
1860
1860
|
if (p.gcToPrevious) {
|
|
1861
|
-
const A = M.findIndex((q) => q.lng === c.lng && q.lat === c.lat),
|
|
1862
|
-
for (let q =
|
|
1861
|
+
const A = M.findIndex((q) => q.lng === c.lng && q.lat === c.lat), W = M.findIndex((q) => q.lng === p.lng && q.lat === p.lat);
|
|
1862
|
+
for (let q = W - 1; q > A; q--)
|
|
1863
1863
|
M.splice(q, 1);
|
|
1864
1864
|
}
|
|
1865
1865
|
}
|
|
@@ -1877,12 +1877,12 @@ class f {
|
|
|
1877
1877
|
static calculateCenter(M) {
|
|
1878
1878
|
const z = [];
|
|
1879
1879
|
for (const A of M)
|
|
1880
|
-
for (const
|
|
1881
|
-
z.push(
|
|
1882
|
-
const b =
|
|
1880
|
+
for (const W of A)
|
|
1881
|
+
z.push(W);
|
|
1882
|
+
const b = f.featureCollection([]), O = X.convertToMonotonicLng2(z);
|
|
1883
1883
|
for (const A of O)
|
|
1884
|
-
b.features.push(
|
|
1885
|
-
const p =
|
|
1884
|
+
b.features.push(f.point(A));
|
|
1885
|
+
const p = f.center(b).geometry.coordinates;
|
|
1886
1886
|
return { lng: X.convertToStdLng(p[0], 8), lat: X.roundPrecision(p[1], 8) };
|
|
1887
1887
|
}
|
|
1888
1888
|
/**
|
|
@@ -1902,8 +1902,8 @@ class f {
|
|
|
1902
1902
|
for (const c of M)
|
|
1903
1903
|
for (const p of c)
|
|
1904
1904
|
z.push(p);
|
|
1905
|
-
const b = X.convertToMonotonicLng2(z), O =
|
|
1906
|
-
return
|
|
1905
|
+
const b = X.convertToMonotonicLng2(z), O = f.lineString(b);
|
|
1906
|
+
return f.bbox(O);
|
|
1907
1907
|
}
|
|
1908
1908
|
/**
|
|
1909
1909
|
* 计算BBox
|
|
@@ -1922,10 +1922,10 @@ class f {
|
|
|
1922
1922
|
static simplifyCoordinates(M, z = 1, b = 180) {
|
|
1923
1923
|
const O = [];
|
|
1924
1924
|
for (let c = 1; c < M.length; c++) {
|
|
1925
|
-
const p = M[c - 1], A = M[c],
|
|
1925
|
+
const p = M[c - 1], A = M[c], W = M[c + 1];
|
|
1926
1926
|
let q = !1, Y = !1;
|
|
1927
|
-
if ((p.velocity || p.suspend || p.important || p.pilot || c === 1) && (q = !0, O.push(p)), A.gcToPrevious && (q || (q = !0, O.push(p)), Y = !0, O.push(A), c++),
|
|
1928
|
-
const d =
|
|
1927
|
+
if ((p.velocity || p.suspend || p.important || p.pilot || c === 1) && (q = !0, O.push(p)), A.gcToPrevious && (q || (q = !0, O.push(p)), Y = !0, O.push(A), c++), W) {
|
|
1928
|
+
const d = S.calculateDistance(p, A, !0), L = S.calculateDistance(A, W, !0), T = S.calculateDistance(p, W, !0), N = (Math.pow(d, 2) + Math.pow(L, 2) - Math.pow(T, 2)) / (2 * d * L);
|
|
1929
1929
|
Math.round(Math.acos(N) * 180 / Math.PI) < b && T > z && !Y && (O.push(A), c++);
|
|
1930
1930
|
}
|
|
1931
1931
|
if (c >= M.length - 1) {
|
|
@@ -1942,7 +1942,7 @@ class f {
|
|
|
1942
1942
|
* @param waypoints 带时间的轨迹, 单位秒
|
|
1943
1943
|
*/
|
|
1944
1944
|
static nearestTSPointInWaypoints(M, z, b) {
|
|
1945
|
-
const O =
|
|
1945
|
+
const O = s.unix(M), c = b.filter(
|
|
1946
1946
|
(p) => O.clone().subtract(z, "hour").unix() <= (p.positionTime || 0) && O.clone().add(z, "h").unix() >= (p.positionTime || 0)
|
|
1947
1947
|
);
|
|
1948
1948
|
return c.sort((p, A) => (p.positionTime || 0) - (A.positionTime || 0)), c.at(-1);
|
|
@@ -1953,17 +1953,17 @@ class f {
|
|
|
1953
1953
|
* @param positions 带时间(positionTime)的轨迹
|
|
1954
1954
|
*/
|
|
1955
1955
|
static deadReckoning(M, z) {
|
|
1956
|
-
var c, p, A,
|
|
1956
|
+
var c, p, A, W;
|
|
1957
1957
|
M > 1e12 && (M = Math.round(M / 1e3));
|
|
1958
|
-
const b =
|
|
1958
|
+
const b = s.unix(M);
|
|
1959
1959
|
let O = z.find((q) => q.positionTime === b.unix());
|
|
1960
1960
|
if (!O) {
|
|
1961
|
-
const q = (p = (c = z.filter((d) => (d == null ? void 0 : d.positionTime) < b.unix())) == null ? void 0 : c.sort((d, L) => (d.positionTime || 0) - (L.positionTime || 0))) == null ? void 0 : p.at(-1), Y = (
|
|
1961
|
+
const q = (p = (c = z.filter((d) => (d == null ? void 0 : d.positionTime) < b.unix())) == null ? void 0 : c.sort((d, L) => (d.positionTime || 0) - (L.positionTime || 0))) == null ? void 0 : p.at(-1), Y = (W = (A = z.filter((d) => (d == null ? void 0 : d.positionTime) > b.unix())) == null ? void 0 : A.sort((d, L) => (d.positionTime || 0) - (L.positionTime || 0))) == null ? void 0 : W.at(0);
|
|
1962
1962
|
if (q && Y) {
|
|
1963
|
-
const d =
|
|
1964
|
-
O =
|
|
1963
|
+
const d = S.calculateBearing(q, Y, !0), L = S.calculateDistance(q, Y), T = (b.unix() - q.positionTime) / (Y.positionTime - q.positionTime);
|
|
1964
|
+
O = S.calculateCoordinate(q, d, L * T), O.positionTime = b.unix(), O.utc = b.utc().format(), O.cog = d, O.sog = Math.round(L / ((Y.positionTime - q.positionTime) / 3600) * 100) / 100;
|
|
1965
1965
|
} else
|
|
1966
|
-
O = q || Y, O && (O.utc =
|
|
1966
|
+
O = q || Y, O && (O.utc = s.unix(O == null ? void 0 : O.positionTime).utc().format());
|
|
1967
1967
|
}
|
|
1968
1968
|
return O;
|
|
1969
1969
|
}
|
|
@@ -1976,19 +1976,19 @@ class f {
|
|
|
1976
1976
|
z = JSON.parse(JSON.stringify(z)), z.sort((q, Y) => q.positionTime - Y.positionTime);
|
|
1977
1977
|
let b = Number.MAX_SAFE_INTEGER, O = Number.MAX_SAFE_INTEGER;
|
|
1978
1978
|
for (let q = 0; q < z.length - 1; q++) {
|
|
1979
|
-
const Y = z[q], d = z[q + 1], L =
|
|
1979
|
+
const Y = z[q], d = z[q + 1], L = S.calculatePointToLineDistance(M, Y, d);
|
|
1980
1980
|
L < b && (b = L, O = q);
|
|
1981
1981
|
}
|
|
1982
|
-
const c = z[O], p = z[O + 1], A =
|
|
1982
|
+
const c = z[O], p = z[O + 1], A = S.calculateDistance(c, M), W = S.calculateDistance(p, M);
|
|
1983
1983
|
if (A === 0)
|
|
1984
1984
|
M = c;
|
|
1985
|
-
else if (
|
|
1985
|
+
else if (W === 0)
|
|
1986
1986
|
M = p;
|
|
1987
1987
|
else {
|
|
1988
|
-
const q =
|
|
1988
|
+
const q = S.nearestCoordinateInLine(M, c, p), Y = c.positionTime, d = p.positionTime, L = S.calculateDistance(c, q), T = S.calculateDistance(c, p), N = Math.round(Y + (d - Y) * (L / T));
|
|
1989
1989
|
M.positionTime = N;
|
|
1990
1990
|
}
|
|
1991
|
-
return M.utc = M.positionTime ?
|
|
1991
|
+
return M.utc = M.positionTime ? s.unix(M.positionTime).utc().format() : void 0, M.positionTime ? M : void 0;
|
|
1992
1992
|
}
|
|
1993
1993
|
/**
|
|
1994
1994
|
* 翻转轨迹
|
|
@@ -2004,9 +2004,9 @@ class f {
|
|
|
2004
2004
|
return M.reverse();
|
|
2005
2005
|
}
|
|
2006
2006
|
}
|
|
2007
|
-
let
|
|
2007
|
+
let E;
|
|
2008
2008
|
try {
|
|
2009
|
-
|
|
2009
|
+
E = _.getLogger("vessel");
|
|
2010
2010
|
} catch {
|
|
2011
2011
|
} finally {
|
|
2012
2012
|
}
|
|
@@ -2017,19 +2017,19 @@ class t0 {
|
|
|
2017
2017
|
*/
|
|
2018
2018
|
static convert2Geojson(M) {
|
|
2019
2019
|
var b, O, c;
|
|
2020
|
-
const z =
|
|
2020
|
+
const z = f.featureCollection([]);
|
|
2021
2021
|
for (const p of M) {
|
|
2022
2022
|
const A = (b = p.history) == null ? void 0 : b[0];
|
|
2023
2023
|
if (p.forecasts) {
|
|
2024
2024
|
A && A.wind && (A.wind.kts = A.kts);
|
|
2025
|
-
for (const
|
|
2025
|
+
for (const W of p.forecasts) {
|
|
2026
2026
|
let q;
|
|
2027
|
-
const Y = [], d =
|
|
2028
|
-
for (const N in
|
|
2029
|
-
const i =
|
|
2027
|
+
const Y = [], d = s(W.date).utc(), L = `${p.name}-${W.model}`;
|
|
2028
|
+
for (const N in W == null ? void 0 : W.hours) {
|
|
2029
|
+
const i = W.hours[N];
|
|
2030
2030
|
q = q || i;
|
|
2031
|
-
const t = d.clone().add(Number(N), "hour"),
|
|
2032
|
-
model:
|
|
2031
|
+
const t = d.clone().add(Number(N), "hour"), l = f.point([i.lng, i.lat], {
|
|
2032
|
+
model: W.model,
|
|
2033
2033
|
name: p.name,
|
|
2034
2034
|
date: t.format(),
|
|
2035
2035
|
hour: Number(N),
|
|
@@ -2041,20 +2041,20 @@ class t0 {
|
|
|
2041
2041
|
category: L,
|
|
2042
2042
|
type: "forecast"
|
|
2043
2043
|
});
|
|
2044
|
-
z.features.push(
|
|
2044
|
+
z.features.push(l), Y.push(l.geometry.coordinates);
|
|
2045
2045
|
}
|
|
2046
2046
|
const T = {
|
|
2047
2047
|
kts: void 0,
|
|
2048
2048
|
deg: void 0
|
|
2049
2049
|
};
|
|
2050
2050
|
if (A) {
|
|
2051
|
-
const N =
|
|
2051
|
+
const N = s(A.updated).utc();
|
|
2052
2052
|
if (q) {
|
|
2053
|
-
const t =
|
|
2054
|
-
T.kts = Math.round(t /
|
|
2053
|
+
const t = S.calculateDistance(A, q), l = s(q.utc || q.updated).diff(N, "h", !0);
|
|
2054
|
+
T.kts = Math.round(t / l * 100) / 100, T.deg = S.calculateBearing(A, q, !0, 0);
|
|
2055
2055
|
}
|
|
2056
|
-
const i =
|
|
2057
|
-
model:
|
|
2056
|
+
const i = f.point([A.lng, A.lat], {
|
|
2057
|
+
model: W.model,
|
|
2058
2058
|
name: p.name,
|
|
2059
2059
|
date: N.format(),
|
|
2060
2060
|
hour: 0,
|
|
@@ -2070,10 +2070,10 @@ class t0 {
|
|
|
2070
2070
|
z.features.push(i), Y.unshift(i.geometry.coordinates);
|
|
2071
2071
|
}
|
|
2072
2072
|
if ((Y == null ? void 0 : Y.length) > 1) {
|
|
2073
|
-
const N =
|
|
2074
|
-
date:
|
|
2073
|
+
const N = f.lineString(X.convertToMonotonicLng2(Y), {
|
|
2074
|
+
date: A.updated,
|
|
2075
2075
|
id: p.id || p.name,
|
|
2076
|
-
model:
|
|
2076
|
+
model: W.model,
|
|
2077
2077
|
name: p.name,
|
|
2078
2078
|
category: L,
|
|
2079
2079
|
type: "forecast",
|
|
@@ -2083,12 +2083,12 @@ class t0 {
|
|
|
2083
2083
|
}
|
|
2084
2084
|
}
|
|
2085
2085
|
}
|
|
2086
|
-
if ((O = p.history) != null && O.length) {
|
|
2087
|
-
const
|
|
2086
|
+
if (z.features.sort((W, q) => W.properties.type === "forecast" && q.properties.type === "forecast" && W.geometry.type === "Point" && q.geometry.type === "Point" ? s(W.properties.date).valueOf() - s(q.properties.date).valueOf() : 0), (O = p.history) != null && O.length) {
|
|
2087
|
+
const W = [], q = s(A == null ? void 0 : A.updated).utc(), Y = s((c = p.history) == null ? void 0 : c.at(-1).updated).utc(), d = q.diff(Y, "h") % 24 > 2 ? 24 : 12;
|
|
2088
2088
|
for (const L of p.history) {
|
|
2089
|
-
const T =
|
|
2089
|
+
const T = s(L.updated).utc(), N = T.isSameOrBefore(q) || T.isSame(Y);
|
|
2090
2090
|
N && q.add(-d, "h");
|
|
2091
|
-
const i =
|
|
2091
|
+
const i = f.point([L.lng, L.lat], {
|
|
2092
2092
|
name: p.name,
|
|
2093
2093
|
date: T.format(),
|
|
2094
2094
|
format: T.format("MMM-DD/HHmm[Z]"),
|
|
@@ -2101,10 +2101,10 @@ class t0 {
|
|
|
2101
2101
|
movement: L.movement,
|
|
2102
2102
|
important: N
|
|
2103
2103
|
});
|
|
2104
|
-
z.features.push(i),
|
|
2104
|
+
z.features.push(i), W.push(i.geometry.coordinates);
|
|
2105
2105
|
}
|
|
2106
|
-
if (
|
|
2107
|
-
const L =
|
|
2106
|
+
if (W.length === 1 && W.push(W[0]), W.length > 1) {
|
|
2107
|
+
const L = f.lineString(X.convertToMonotonicLng2(W), {
|
|
2108
2108
|
name: p.name,
|
|
2109
2109
|
type: "history",
|
|
2110
2110
|
updated: A == null ? void 0 : A.updated,
|
|
@@ -2115,6 +2115,7 @@ class t0 {
|
|
|
2115
2115
|
z.features.push(L);
|
|
2116
2116
|
}
|
|
2117
2117
|
}
|
|
2118
|
+
z.features.sort((W, q) => W.properties.type === "forecast" && q.properties.type === "forecast" && W.geometry.type === "Point" && q.geometry.type === "Point" ? s(W.properties.date).valueOf() - s(q.properties.date).valueOf() : W.properties.type === "history" && q.properties.type === "history" && W.geometry.type === "Point" && q.geometry.type === "Point" ? s(q.properties.date).valueOf() - s(W.properties.date).valueOf() : 0);
|
|
2118
2119
|
}
|
|
2119
2120
|
return z;
|
|
2120
2121
|
}
|
|
@@ -2124,28 +2125,28 @@ class t0 {
|
|
|
2124
2125
|
* @param step
|
|
2125
2126
|
*/
|
|
2126
2127
|
static interpolate(M, z = 3) {
|
|
2127
|
-
var c, p, A,
|
|
2128
|
+
var c, p, A, W;
|
|
2128
2129
|
const b = (c = M == null ? void 0 : M.data) == null ? void 0 : c.features.filter((q) => q.geometry.type === "LineString" && q.properties.type === "forecast"), O = [];
|
|
2129
2130
|
for (const q of b) {
|
|
2130
|
-
const Y = q.properties.name, d = q.properties.model, L = q.properties.showCircle, T = q.properties.disabled, N =
|
|
2131
|
+
const Y = q.properties.name, d = q.properties.model, L = q.properties.showCircle, T = q.properties.disabled, N = s(q.properties.date).utc();
|
|
2131
2132
|
let i = z * 60 - (N.get("hour") * 60 + N.get("minute")) % (z * 60);
|
|
2132
2133
|
const t = (p = M == null ? void 0 : M.data) == null ? void 0 : p.features.filter(
|
|
2133
|
-
(
|
|
2134
|
+
(P) => P.geometry.type === "Point" && P.properties.type === "forecast" && P.properties.category === `${Y}-${d}`
|
|
2134
2135
|
);
|
|
2135
|
-
let
|
|
2136
|
-
for (;
|
|
2137
|
-
if (
|
|
2138
|
-
const
|
|
2136
|
+
let l, G = N.clone().add(i, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2137
|
+
for (; l = this.pickIndex(t, G), l <= t.length - 1; ) {
|
|
2138
|
+
if (l > 0) {
|
|
2139
|
+
const P = t[l], B = l === 0 ? void 0 : t[l - 1], m = (i / 60 - ((A = B == null ? void 0 : B.properties) == null ? void 0 : A.hour)) / (P.properties.hour - ((W = B == null ? void 0 : B.properties) == null ? void 0 : W.hour)), H = this.computeNumber(B == null ? void 0 : B.geometry.coordinates[0], P.geometry.coordinates[0], m), Q = this.computeNumber(B == null ? void 0 : B.geometry.coordinates[1], P.geometry.coordinates[1], m), F = f.point([H, Q], {
|
|
2139
2140
|
name: Y,
|
|
2140
2141
|
model: d,
|
|
2141
|
-
category:
|
|
2142
|
+
category: P == null ? void 0 : P.properties.category,
|
|
2142
2143
|
date: G.format(),
|
|
2143
2144
|
format: G.format("MMM-DD/HHmm[Z]"),
|
|
2144
|
-
gusts: this.computeNumber(B == null ? void 0 : B.properties.gusts,
|
|
2145
|
-
hour: this.computeNumber(B == null ? void 0 : B.properties.hour,
|
|
2146
|
-
movement: this.computeNumber(B == null ? void 0 : B.properties.movement,
|
|
2147
|
-
pressure: this.computeNumber(B == null ? void 0 : B.properties.pressure,
|
|
2148
|
-
wind: this.computeNumber(B == null ? void 0 : B.properties.wind,
|
|
2145
|
+
gusts: this.computeNumber(B == null ? void 0 : B.properties.gusts, P.properties.gusts, m),
|
|
2146
|
+
hour: this.computeNumber(B == null ? void 0 : B.properties.hour, P.properties.hour, m),
|
|
2147
|
+
movement: this.computeNumber(B == null ? void 0 : B.properties.movement, P.properties.movement, m),
|
|
2148
|
+
pressure: this.computeNumber(B == null ? void 0 : B.properties.pressure, P.properties.pressure, m),
|
|
2149
|
+
wind: this.computeNumber(B == null ? void 0 : B.properties.wind, P.properties.wind, m),
|
|
2149
2150
|
type: "forecast",
|
|
2150
2151
|
disabled: T,
|
|
2151
2152
|
showCircle: L
|
|
@@ -2179,23 +2180,23 @@ class t0 {
|
|
|
2179
2180
|
* @param options
|
|
2180
2181
|
*/
|
|
2181
2182
|
static diversionPassageAt(M, z, b, O = {}) {
|
|
2182
|
-
const { t1: c, t2: p, hr: A, hours:
|
|
2183
|
+
const { t1: c, t2: p, hr: A, hours: W } = this.tropicalCenterTwin(z, 24, O);
|
|
2183
2184
|
if (c && p) {
|
|
2184
2185
|
if (!O.debug) {
|
|
2185
|
-
const N =
|
|
2186
|
+
const N = S.calculateDistance(M, c), i = S.calculateDistance(M, p);
|
|
2186
2187
|
if (N > 2 * b && i > 2 * b)
|
|
2187
|
-
return
|
|
2188
|
+
return E == null || E.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", O.requestId, N, i, {
|
|
2188
2189
|
from: M,
|
|
2189
2190
|
t1: c,
|
|
2190
2191
|
t2: p,
|
|
2191
2192
|
hr: A
|
|
2192
2193
|
}), {};
|
|
2193
2194
|
}
|
|
2194
|
-
const q =
|
|
2195
|
+
const q = S.calculateBearing(M, c), Y = S.calculateBearing(c, p), d = Math.abs(q - Y);
|
|
2195
2196
|
let L = 0;
|
|
2196
2197
|
d < 180 ? L = d + 90 : d >= 180 && (L = d - 90);
|
|
2197
|
-
const T =
|
|
2198
|
-
return
|
|
2198
|
+
const T = S.calculateCoordinate(c, L, b);
|
|
2199
|
+
return E == null || E.info("[%s] the right tangent position: %j", O.requestId, {
|
|
2199
2200
|
from: M,
|
|
2200
2201
|
t1: c,
|
|
2201
2202
|
t2: p,
|
|
@@ -2203,7 +2204,7 @@ class t0 {
|
|
|
2203
2204
|
bearing1: q,
|
|
2204
2205
|
bearing2: Y,
|
|
2205
2206
|
right: T
|
|
2206
|
-
}), { at: T, t1: c, t2: p, hr: Number(A), hours:
|
|
2207
|
+
}), { at: T, t1: c, t2: p, hr: Number(A), hours: W };
|
|
2207
2208
|
}
|
|
2208
2209
|
return {};
|
|
2209
2210
|
}
|
|
@@ -2218,22 +2219,22 @@ class t0 {
|
|
|
2218
2219
|
* @param options
|
|
2219
2220
|
*/
|
|
2220
2221
|
static driftPassageAt(M, z, b, O = {}) {
|
|
2221
|
-
const { t1: c, t2: p, hr: A, hours:
|
|
2222
|
+
const { t1: c, t2: p, hr: A, hours: W } = this.tropicalCenterTwin(z, 24, O);
|
|
2222
2223
|
if (c && p) {
|
|
2223
2224
|
if (!O.debug) {
|
|
2224
|
-
const T =
|
|
2225
|
+
const T = S.calculateDistance(M, c), N = S.calculateDistance(M, p);
|
|
2225
2226
|
if (T > 2 * b && N > 2 * b)
|
|
2226
|
-
return
|
|
2227
|
+
return E == null || E.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", O.requestId, T, N, {
|
|
2227
2228
|
from: M,
|
|
2228
2229
|
t1: c,
|
|
2229
2230
|
t2: p,
|
|
2230
2231
|
hr: A
|
|
2231
2232
|
}), {};
|
|
2232
2233
|
}
|
|
2233
|
-
const q =
|
|
2234
|
-
return { at:
|
|
2234
|
+
const q = S.calculateBearing(M, c), Y = S.calculateBearing(c, p), d = S.calculateDistance(M, c);
|
|
2235
|
+
return { at: S.calculateCoordinate(c, q - Y + 180, b < d ? b : d), t1: c, t2: p, hr: Number(A), hours: W };
|
|
2235
2236
|
} else
|
|
2236
|
-
return
|
|
2237
|
+
return E == null || E.info("[%s] no need drift: %j", O.requestId, { from: M, t1: c, t2: p, hr: A }), {};
|
|
2237
2238
|
}
|
|
2238
2239
|
/**
|
|
2239
2240
|
* 获取台风中心点对
|
|
@@ -2250,20 +2251,20 @@ class t0 {
|
|
|
2250
2251
|
O = { ...i.hours, ...O };
|
|
2251
2252
|
});
|
|
2252
2253
|
const c = ((d = M == null ? void 0 : M.history) == null ? void 0 : d[0]) || (O == null ? void 0 : O[(L = Object.keys(O)) == null ? void 0 : L[0]]);
|
|
2253
|
-
|
|
2254
|
+
E == null || E.info("[%s] the first tropical center: %j", b.requestId, c);
|
|
2254
2255
|
let p = (T = Object.keys(O || {}).filter((i) => Number(i) <= (z < 0 ? 24 : z))) == null ? void 0 : T.at(-1);
|
|
2255
2256
|
p || (p = (N = Object.keys(O || {}).filter((i) => Number(i) <= (z < 0 ? 24 : 2 * z))) == null ? void 0 : N.at(-1));
|
|
2256
2257
|
const A = O == null ? void 0 : O[p || -1];
|
|
2257
|
-
|
|
2258
|
-
const
|
|
2259
|
-
for (const i of
|
|
2258
|
+
E == null || E.info("[%s] the second tropical center: %j in %d hrs", b.requestId, A, p);
|
|
2259
|
+
const W = Object.keys(O || {}).filter((i) => Number(i) <= Number(p)), q = { 0: c };
|
|
2260
|
+
for (const i of W)
|
|
2260
2261
|
q[i] = O[i];
|
|
2261
2262
|
return { t1: c, t2: A, hr: Number(p), hours: q };
|
|
2262
2263
|
}
|
|
2263
2264
|
static pickIndex(M, z) {
|
|
2264
2265
|
let b = 0;
|
|
2265
2266
|
for (const O of M) {
|
|
2266
|
-
if (
|
|
2267
|
+
if (s(O.properties.date).isAfter(z))
|
|
2267
2268
|
return b === 0 ? -1 : b;
|
|
2268
2269
|
b++;
|
|
2269
2270
|
}
|
|
@@ -2291,7 +2292,7 @@ class V0 {
|
|
|
2291
2292
|
return `${M.lat}|${M.lng}|${M.positionTime}|${M.sog}|${M.cog}|${M.hdg}|${M.draught}|${z}|${JSON.stringify(M.meteo || {})}|${M.vendor}|${M.deleted}`;
|
|
2292
2293
|
}
|
|
2293
2294
|
static str2Json(M) {
|
|
2294
|
-
const [z, b, O, c, p, A,
|
|
2295
|
+
const [z, b, O, c, p, A, W, q, Y, d, L] = M.split("|");
|
|
2295
2296
|
return {
|
|
2296
2297
|
lat: Number(z),
|
|
2297
2298
|
lng: Number(b),
|
|
@@ -2300,7 +2301,7 @@ class V0 {
|
|
|
2300
2301
|
cog: Number(p),
|
|
2301
2302
|
hdg: Number(A),
|
|
2302
2303
|
//@ts-ignore
|
|
2303
|
-
draught: isNaN(
|
|
2304
|
+
draught: isNaN(W) ? null : Number(W),
|
|
2304
2305
|
type: q,
|
|
2305
2306
|
important: q !== "A",
|
|
2306
2307
|
meteo: Y ? JSON.parse(Y) : void 0,
|
|
@@ -2310,21 +2311,21 @@ class V0 {
|
|
|
2310
2311
|
}
|
|
2311
2312
|
static inspectStoppages(M, z = 1, b = !0) {
|
|
2312
2313
|
const O = M.at(0).positionTime < M.at(-1).positionTime;
|
|
2313
|
-
O || M.sort((
|
|
2314
|
+
O || M.sort((W, q) => W.positionTime - q.positionTime);
|
|
2314
2315
|
const c = [];
|
|
2315
2316
|
let p, A;
|
|
2316
|
-
for (let
|
|
2317
|
-
const q = M[
|
|
2317
|
+
for (let W = 0; W < M.length - 1; W++) {
|
|
2318
|
+
const q = M[W];
|
|
2318
2319
|
if (!(b && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))) {
|
|
2319
|
-
for (let Y =
|
|
2320
|
+
for (let Y = W + 1; Y < M.length; Y++) {
|
|
2320
2321
|
const d = M[Y - 1], L = M[Y];
|
|
2321
2322
|
if (b && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))
|
|
2322
2323
|
continue;
|
|
2323
2324
|
const T = L.positionTime - d.positionTime;
|
|
2324
|
-
if (
|
|
2325
|
-
p || (p = q), Y === M.length - 1 && (A = L,
|
|
2325
|
+
if (S.calculateDistance(L, d, !0, 4) / (T / 3600) < z)
|
|
2326
|
+
p || (p = q), Y === M.length - 1 && (A = L, W = Y);
|
|
2326
2327
|
else {
|
|
2327
|
-
p && (A = M[Y - 1],
|
|
2328
|
+
p && (A = M[Y - 1], W = Y);
|
|
2328
2329
|
break;
|
|
2329
2330
|
}
|
|
2330
2331
|
}
|
|
@@ -2335,28 +2336,28 @@ class V0 {
|
|
|
2335
2336
|
lng: p.lng,
|
|
2336
2337
|
sog: p.sog,
|
|
2337
2338
|
positionTime: p.positionTime,
|
|
2338
|
-
utc:
|
|
2339
|
+
utc: s.unix(p.positionTime).utc().format()
|
|
2339
2340
|
},
|
|
2340
2341
|
end: {
|
|
2341
2342
|
lat: A.lat,
|
|
2342
2343
|
lng: A.lng,
|
|
2343
2344
|
sog: A.sog,
|
|
2344
2345
|
positionTime: A.positionTime,
|
|
2345
|
-
utc:
|
|
2346
|
+
utc: s.unix(A.positionTime).utc().format()
|
|
2346
2347
|
},
|
|
2347
2348
|
duration: A.positionTime - p.positionTime
|
|
2348
|
-
}, d = M.filter((T) => T.positionTime >= Y.start.positionTime && T.positionTime <= Y.end.positionTime), L =
|
|
2349
|
-
Y.distance =
|
|
2349
|
+
}, d = M.filter((T) => T.positionTime >= Y.start.positionTime && T.positionTime <= Y.end.positionTime), L = S.divideAccordingToLng(d);
|
|
2350
|
+
Y.distance = S.calculateRouteDistance(L), Y.hours = Math.round(Y.duration / 3600 * 10) / 10, Y.avgSog = Math.round(Y.distance / Y.hours * 10) / 10, c.push(Y);
|
|
2350
2351
|
}
|
|
2351
2352
|
p = void 0, A = void 0;
|
|
2352
2353
|
}
|
|
2353
2354
|
}
|
|
2354
|
-
return O || M.sort((
|
|
2355
|
+
return O || M.sort((W, q) => q.positionTime - W.positionTime), c;
|
|
2355
2356
|
}
|
|
2356
2357
|
}
|
|
2357
2358
|
export {
|
|
2358
2359
|
V0 as AisHelper,
|
|
2359
|
-
|
|
2360
|
+
S as LaneHelper,
|
|
2360
2361
|
X as LngLatHelper,
|
|
2361
2362
|
t0 as TropicalHelper
|
|
2362
2363
|
};
|