@idm-plugin/geo 1.9.3 → 1.9.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 +183 -172
- package/dist/index.umd.cjs +3 -3
- package/dist/lane/src/index.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as N from "@turf/turf";
|
|
2
|
-
import
|
|
2
|
+
import u 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 n0(m) {
|
|
@@ -13,23 +13,23 @@ var j = { exports: {} };
|
|
|
13
13
|
//! license : MIT
|
|
14
14
|
//! github.com/moment/moment-timezone
|
|
15
15
|
(function(M, z) {
|
|
16
|
-
m.exports ? m.exports = z(
|
|
16
|
+
m.exports ? m.exports = z(u) : z(M.moment);
|
|
17
17
|
})(a0, function(M) {
|
|
18
18
|
M.version === void 0 && M.default && (M = M.default);
|
|
19
19
|
var z = "0.5.48", b = {}, p = {}, c = {}, O = {}, A = {}, W;
|
|
20
20
|
(!M || typeof M.version != "string") && D("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
|
|
21
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
|
|
23
|
+
function R(o) {
|
|
24
24
|
return o > 96 ? o - 87 : o > 64 ? o - 29 : o - 48;
|
|
25
25
|
}
|
|
26
26
|
function T(o) {
|
|
27
|
-
var a = 0, X = o.split("."),
|
|
28
|
-
for (o.charCodeAt(0) === 45 && (a = 1, l = -1), a; a <
|
|
29
|
-
E = L
|
|
27
|
+
var a = 0, X = o.split("."), L = X[0], e = X[1] || "", U = 1, E, t = 0, l = 1;
|
|
28
|
+
for (o.charCodeAt(0) === 45 && (a = 1, l = -1), a; a < L.length; a++)
|
|
29
|
+
E = R(L.charCodeAt(a)), t = 60 * t + E;
|
|
30
30
|
for (a = 0; a < e.length; a++)
|
|
31
|
-
U = U / 60, E =
|
|
32
|
-
return
|
|
31
|
+
U = U / 60, E = R(e.charCodeAt(a)), t += E * U;
|
|
32
|
+
return t * l;
|
|
33
33
|
}
|
|
34
34
|
function f(o) {
|
|
35
35
|
for (var a = 0; a < o.length; a++)
|
|
@@ -40,18 +40,18 @@ var j = { exports: {} };
|
|
|
40
40
|
o[X] = Math.round((o[X - 1] || 0) + o[X] * 6e4);
|
|
41
41
|
o[a - 1] = 1 / 0;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
var X = [],
|
|
45
|
-
for (
|
|
46
|
-
X[
|
|
43
|
+
function S(o, a) {
|
|
44
|
+
var X = [], L;
|
|
45
|
+
for (L = 0; L < a.length; L++)
|
|
46
|
+
X[L] = o[a[L]];
|
|
47
47
|
return X;
|
|
48
48
|
}
|
|
49
49
|
function s(o) {
|
|
50
|
-
var a = o.split("|"), X = a[2].split(" "),
|
|
51
|
-
return f(X), f(
|
|
50
|
+
var a = o.split("|"), X = a[2].split(" "), L = a[3].split(""), e = a[4].split(" ");
|
|
51
|
+
return f(X), f(L), f(e), i(e, L.length), {
|
|
52
52
|
name: a[0],
|
|
53
|
-
abbrs:
|
|
54
|
-
offsets:
|
|
53
|
+
abbrs: S(a[1].split(" "), L),
|
|
54
|
+
offsets: S(X, L),
|
|
55
55
|
untils: e,
|
|
56
56
|
population: a[5] | 0
|
|
57
57
|
};
|
|
@@ -67,8 +67,8 @@ var j = { exports: {} };
|
|
|
67
67
|
return X - 1;
|
|
68
68
|
if (o >= a[X - 1])
|
|
69
69
|
return -1;
|
|
70
|
-
for (var
|
|
71
|
-
|
|
70
|
+
for (var L, e = 0, U = X - 1; U - e > 1; )
|
|
71
|
+
L = Math.floor((e + U) / 2), a[L] <= o ? e = L : U = L;
|
|
72
72
|
return U;
|
|
73
73
|
}
|
|
74
74
|
Z.prototype = {
|
|
@@ -76,9 +76,9 @@ var j = { exports: {} };
|
|
|
76
76
|
this.name = o.name, this.abbrs = o.abbrs, this.untils = o.untils, this.offsets = o.offsets, this.population = o.population;
|
|
77
77
|
},
|
|
78
78
|
_index: function(o) {
|
|
79
|
-
var a = +o, X = this.untils,
|
|
80
|
-
if (
|
|
81
|
-
return
|
|
79
|
+
var a = +o, X = this.untils, L;
|
|
80
|
+
if (L = P(a, X), L >= 0)
|
|
81
|
+
return L;
|
|
82
82
|
},
|
|
83
83
|
countries: function() {
|
|
84
84
|
var o = this.name;
|
|
@@ -87,9 +87,9 @@ var j = { exports: {} };
|
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
89
|
parse: function(o) {
|
|
90
|
-
var a = +o, X = this.offsets,
|
|
90
|
+
var a = +o, X = this.offsets, L = this.untils, e = L.length - 1, U, E, t, l;
|
|
91
91
|
for (l = 0; l < e; l++)
|
|
92
|
-
if (U = X[l], E = X[l + 1],
|
|
92
|
+
if (U = X[l], E = X[l + 1], t = X[l && l - 1], U < E && V.moveAmbiguousForward ? U = E : U > t && V.moveInvalidForward && (U = t), a < L[l] - U * 6e4)
|
|
93
93
|
return X[l];
|
|
94
94
|
return X[e];
|
|
95
95
|
},
|
|
@@ -103,7 +103,7 @@ var j = { exports: {} };
|
|
|
103
103
|
return this.offsets[this._index(o)];
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
function
|
|
106
|
+
function r(o, a) {
|
|
107
107
|
this.name = o, this.zones = a;
|
|
108
108
|
}
|
|
109
109
|
function G(o) {
|
|
@@ -117,38 +117,38 @@ var j = { exports: {} };
|
|
|
117
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
119
|
function Q(o, a) {
|
|
120
|
-
for (var X,
|
|
121
|
-
X = new G(new Date(o.at +
|
|
120
|
+
for (var X, L; L = ((a.at - o.at) / 12e4 | 0) * 6e4; )
|
|
121
|
+
X = new G(new Date(o.at + L)), X.offset === o.offset ? o = X : a = X;
|
|
122
122
|
return o;
|
|
123
123
|
}
|
|
124
124
|
function F() {
|
|
125
|
-
var o = (/* @__PURE__ */ new Date()).getFullYear() - 2, a = new G(new Date(o, 0, 1)), X = a.offset,
|
|
126
|
-
for (
|
|
127
|
-
E = new Date(o,
|
|
128
|
-
for (
|
|
129
|
-
|
|
130
|
-
return
|
|
125
|
+
var o = (/* @__PURE__ */ new Date()).getFullYear() - 2, a = new G(new Date(o, 0, 1)), X = a.offset, L = [a], e, U, E, t;
|
|
126
|
+
for (t = 1; t < 48; t++)
|
|
127
|
+
E = new Date(o, t, 1).getTimezoneOffset(), E !== X && (U = new G(new Date(o, t, 1)), e = Q(a, U), L.push(e), L.push(new G(new Date(e.at + 6e4))), a = U, X = E);
|
|
128
|
+
for (t = 0; t < 4; t++)
|
|
129
|
+
L.push(new G(new Date(o + t, 0, 1))), L.push(new G(new Date(o + t, 6, 1)));
|
|
130
|
+
return L;
|
|
131
131
|
}
|
|
132
132
|
function M0(o, a) {
|
|
133
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
135
|
function z0(o, a) {
|
|
136
|
-
var X,
|
|
136
|
+
var X, L;
|
|
137
137
|
for (f(a), X = 0; X < a.length; X++)
|
|
138
|
-
|
|
138
|
+
L = a[X], A[L] = A[L] || {}, A[L][o] = !0;
|
|
139
139
|
}
|
|
140
140
|
function b0(o) {
|
|
141
|
-
var a = o.length, X = {},
|
|
141
|
+
var a = o.length, X = {}, L = [], e = {}, U, E, t, l;
|
|
142
142
|
for (U = 0; U < a; U++)
|
|
143
|
-
if (
|
|
144
|
-
l = A[
|
|
143
|
+
if (t = o[U].offset, !e.hasOwnProperty(t)) {
|
|
144
|
+
l = A[t] || {};
|
|
145
145
|
for (E in l)
|
|
146
146
|
l.hasOwnProperty(E) && (X[E] = !0);
|
|
147
|
-
e[
|
|
147
|
+
e[t] = !0;
|
|
148
148
|
}
|
|
149
149
|
for (U in X)
|
|
150
|
-
X.hasOwnProperty(U) &&
|
|
151
|
-
return
|
|
150
|
+
X.hasOwnProperty(U) && L.push(O[U]);
|
|
151
|
+
return L;
|
|
152
152
|
}
|
|
153
153
|
function p0() {
|
|
154
154
|
try {
|
|
@@ -161,9 +161,9 @@ var j = { exports: {} };
|
|
|
161
161
|
}
|
|
162
162
|
} catch {
|
|
163
163
|
}
|
|
164
|
-
var X = F(),
|
|
165
|
-
for (
|
|
166
|
-
for (E = new h(g(e[
|
|
164
|
+
var X = F(), L = X.length, e = b0(X), U = [], E, t, l;
|
|
165
|
+
for (t = 0; t < e.length; t++) {
|
|
166
|
+
for (E = new h(g(e[t])), l = 0; l < L; l++)
|
|
167
167
|
E.scoreOffsetAt(X[l]);
|
|
168
168
|
U.push(E);
|
|
169
169
|
}
|
|
@@ -176,14 +176,14 @@ var j = { exports: {} };
|
|
|
176
176
|
return (o || "").toLowerCase().replace(/\//g, "_");
|
|
177
177
|
}
|
|
178
178
|
function k(o) {
|
|
179
|
-
var a, X,
|
|
179
|
+
var a, X, L, e;
|
|
180
180
|
for (typeof o == "string" && (o = [o]), a = 0; a < o.length; a++)
|
|
181
|
-
|
|
181
|
+
L = o[a].split("|"), X = L[0], e = K(X), b[e] = o[a], O[e] = X, z0(e, L[2].split(" "));
|
|
182
182
|
}
|
|
183
183
|
function g(o, a) {
|
|
184
184
|
o = K(o);
|
|
185
|
-
var X = b[o],
|
|
186
|
-
return X instanceof Z ? X : typeof X == "string" ? (X = new Z(X), b[o] = X, X) : p[o] && a !== g && (
|
|
185
|
+
var X = b[o], L;
|
|
186
|
+
return X instanceof Z ? X : typeof X == "string" ? (X = new Z(X), b[o] = X, X) : p[o] && a !== g && (L = g(p[o], g)) ? (X = b[o] = new Z(), X._set(L), X.name = O[o], X) : null;
|
|
187
187
|
}
|
|
188
188
|
function A0() {
|
|
189
189
|
var o, a = [];
|
|
@@ -195,17 +195,17 @@ var j = { exports: {} };
|
|
|
195
195
|
return Object.keys(c);
|
|
196
196
|
}
|
|
197
197
|
function v(o) {
|
|
198
|
-
var a, X,
|
|
198
|
+
var a, X, L, e;
|
|
199
199
|
for (typeof o == "string" && (o = [o]), a = 0; a < o.length; a++)
|
|
200
|
-
X = o[a].split("|"),
|
|
200
|
+
X = o[a].split("|"), L = K(X[0]), e = K(X[1]), p[L] = e, O[L] = X[0], p[e] = L, O[e] = X[1];
|
|
201
201
|
}
|
|
202
202
|
function W0(o) {
|
|
203
|
-
var a, X,
|
|
203
|
+
var a, X, L, e;
|
|
204
204
|
if (!(!o || !o.length))
|
|
205
205
|
for (a = 0; a < o.length; a++)
|
|
206
|
-
e = o[a].split("|"), X = e[0].toUpperCase(),
|
|
206
|
+
e = o[a].split("|"), X = e[0].toUpperCase(), L = e[1].split(" "), c[X] = new r(
|
|
207
207
|
X,
|
|
208
|
-
|
|
208
|
+
L
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
211
|
function o0(o) {
|
|
@@ -215,10 +215,10 @@ var j = { exports: {} };
|
|
|
215
215
|
if (o = o0(o), !o)
|
|
216
216
|
return null;
|
|
217
217
|
var X = o.zones.sort();
|
|
218
|
-
return a ? X.map(function(
|
|
219
|
-
var e = g(
|
|
218
|
+
return a ? X.map(function(L) {
|
|
219
|
+
var e = g(L);
|
|
220
220
|
return {
|
|
221
|
-
name:
|
|
221
|
+
name: L,
|
|
222
222
|
offset: e.utcOffset(/* @__PURE__ */ new Date())
|
|
223
223
|
};
|
|
224
224
|
}) : X;
|
|
@@ -237,19 +237,19 @@ var j = { exports: {} };
|
|
|
237
237
|
typeof console < "u" && typeof console.error == "function" && console.error(o);
|
|
238
238
|
}
|
|
239
239
|
function V(o) {
|
|
240
|
-
var a = Array.prototype.slice.call(arguments, 0, -1), X = arguments[arguments.length - 1],
|
|
241
|
-
return !M.isMoment(o) && J(
|
|
240
|
+
var a = Array.prototype.slice.call(arguments, 0, -1), X = arguments[arguments.length - 1], L = M.utc.apply(null, a), e;
|
|
241
|
+
return !M.isMoment(o) && J(L) && (e = g(X)) && L.add(e.parse(L), "minutes"), L.tz(X), L;
|
|
242
242
|
}
|
|
243
243
|
V.version = z, V.dataVersion = "", V._zones = b, V._links = p, V._names = O, V._countries = c, V.add = k, V.link = v, V.load = Y0, V.zone = g, V.zoneExists = $, V.guess = O0, V.names = A0, V.Zone = Z, V.unpack = s, V.unpackBase60 = T, V.needsOffset = J, V.moveInvalidForward = !0, V.moveAmbiguousForward = !1, V.countries = c0, V.zonesForCountry = q0;
|
|
244
244
|
var C = M.fn;
|
|
245
245
|
M.tz = V, M.defaultZone = null, M.updateOffset = function(o, a) {
|
|
246
|
-
var X = M.defaultZone,
|
|
246
|
+
var X = M.defaultZone, L;
|
|
247
247
|
if (o._z === void 0 && (X && J(o) && !o._isUTC && o.isValid() && (o._d = M.utc(o._a)._d, o.utc().add(X.parse(o), "minutes")), o._z = X), o._z)
|
|
248
|
-
if (
|
|
248
|
+
if (L = o._z.utcOffset(o), Math.abs(L) < 16 && (L = L / 60), o.utcOffset !== void 0) {
|
|
249
249
|
var e = o._z;
|
|
250
|
-
o.utcOffset(-
|
|
250
|
+
o.utcOffset(-L, a), o._z = e;
|
|
251
251
|
} else
|
|
252
|
-
o.zone(
|
|
252
|
+
o.zone(L, a);
|
|
253
253
|
}, C.tz = function(o, a) {
|
|
254
254
|
if (o) {
|
|
255
255
|
if (typeof o != "string")
|
|
@@ -1161,7 +1161,7 @@ class n {
|
|
|
1161
1161
|
* @param lat
|
|
1162
1162
|
*/
|
|
1163
1163
|
static guessTimeZoneOffset(M, z) {
|
|
1164
|
-
const b = S0(z, M), p =
|
|
1164
|
+
const b = S0(z, M), p = u().tz(b).utcOffset();
|
|
1165
1165
|
return this.roundPrecision(p / 60, 1);
|
|
1166
1166
|
}
|
|
1167
1167
|
/**
|
|
@@ -1184,13 +1184,13 @@ class n {
|
|
|
1184
1184
|
M < 0 && (p = "W"), M = Math.abs(M), b = b.toUpperCase();
|
|
1185
1185
|
let c = M * 3600, O, A, W, q, Y, d;
|
|
1186
1186
|
O = c % 3600 % 60, b.indexOf("S") !== -1 && (c = c - O, A = n.padNumber(O, 2, 2)), W = c / 60 % 60, b.indexOf("M") !== -1 && (b.indexOf("S") !== -1 ? q = n.roundPrecision(W, z).toString().padStart(2, "0") : q = n.padNumber(W, 2, 2), c = c - W * 60), Y = c / 3600, b.indexOf("M") !== -1 ? d = n.roundPrecision(Y, z).toString().padStart(3, "0") : d = n.padNumber(Y, 3, 2), Number(A) >= 60 && (q = Number(q) + 1, A = 0), Number(q) >= 60 && (d = Number(d) + 1, q = 0);
|
|
1187
|
-
const
|
|
1187
|
+
const R = `${b.replace(/S+/gi, A).replace(/M+/gi, q).replace(/H+/gi, d)}${p}`;
|
|
1188
1188
|
return {
|
|
1189
1189
|
direction: p,
|
|
1190
1190
|
degree: n.roundPrecision(Y, z),
|
|
1191
1191
|
minute: n.roundPrecision(W, z),
|
|
1192
1192
|
second: n.roundPrecision(O, z),
|
|
1193
|
-
pretty:
|
|
1193
|
+
pretty: R
|
|
1194
1194
|
};
|
|
1195
1195
|
}
|
|
1196
1196
|
/**
|
|
@@ -1205,13 +1205,13 @@ class n {
|
|
|
1205
1205
|
M < 0 && (p = "S"), M = Math.abs(M), b = b.toUpperCase();
|
|
1206
1206
|
let c = M * 3600, O, A, W, q, Y, d;
|
|
1207
1207
|
O = c % 3600 % 60, b.indexOf("S") !== -1 && (c = c - O, A = n.padNumber(O, 2, 2)), W = c / 60 % 60, b.indexOf("M") !== -1 && (b.indexOf("S") !== -1 ? q = n.roundPrecision(W, z).toString().padStart(2, "0") : q = n.padNumber(W, 2, 2), c = c - W * 60), Y = c / 3600, b.indexOf("M") !== -1 ? d = n.roundPrecision(Y, z).toString().padStart(2, "0") : d = n.padNumber(Y, 2, 2), Number(A) >= 60 && (q = Number(q) + 1, A = 0), Number(q) >= 60 && (d = Number(d) + 1, q = 0);
|
|
1208
|
-
const
|
|
1208
|
+
const R = `${b.replace(/S+/gi, A).replace(/M+/gi, q).replace(/H+/gi, d)}${p}`;
|
|
1209
1209
|
return {
|
|
1210
1210
|
direction: p,
|
|
1211
1211
|
degree: n.roundPrecision(Y, z),
|
|
1212
1212
|
minute: n.roundPrecision(W, z),
|
|
1213
1213
|
second: n.roundPrecision(O, z),
|
|
1214
|
-
pretty:
|
|
1214
|
+
pretty: R
|
|
1215
1215
|
};
|
|
1216
1216
|
}
|
|
1217
1217
|
static str2Lng(M, z = 6) {
|
|
@@ -1313,7 +1313,7 @@ try {
|
|
|
1313
1313
|
} catch {
|
|
1314
1314
|
} finally {
|
|
1315
1315
|
}
|
|
1316
|
-
class
|
|
1316
|
+
class B {
|
|
1317
1317
|
/**
|
|
1318
1318
|
* 计算方位角
|
|
1319
1319
|
* @param from 坐标 {lng, lat}
|
|
@@ -1424,12 +1424,12 @@ class S {
|
|
|
1424
1424
|
[O, M[W].lat],
|
|
1425
1425
|
[A, M[W + 1].lat]
|
|
1426
1426
|
]);
|
|
1427
|
-
let d,
|
|
1428
|
-
z ? (d = N.lineString(Y),
|
|
1427
|
+
let d, R;
|
|
1428
|
+
z ? (d = N.lineString(Y), R = N.lineString([
|
|
1429
1429
|
[q > 0 ? 180 : -180, 89],
|
|
1430
1430
|
[q > 0 ? 180 : -180, -89]
|
|
1431
|
-
])) : (d = N.greatCircle(Y[0], Y[1]),
|
|
1432
|
-
const T = N.lineIntersect(d,
|
|
1431
|
+
])) : (d = N.greatCircle(Y[0], Y[1]), R = N.greatCircle([q > 0 ? 180 : -180, 89], [q > 0 ? 180 : -180, -89]));
|
|
1432
|
+
const T = N.lineIntersect(d, R);
|
|
1433
1433
|
let f;
|
|
1434
1434
|
if (T.features.length) {
|
|
1435
1435
|
const i = N.getCoord(T.features[0]);
|
|
@@ -1500,8 +1500,8 @@ class S {
|
|
|
1500
1500
|
let b = Number.MAX_VALUE, p = 0, c = 0, O, A;
|
|
1501
1501
|
return z.forEach((W, q) => {
|
|
1502
1502
|
for (let Y = 0; Y < W.length - 1; Y++) {
|
|
1503
|
-
const d = { lng: W[Y][0], lat: W[Y][1] },
|
|
1504
|
-
b > T && (b = T, c = Y, p = q, O = this.calculateDistance(d, M), A = this.calculateDistance(
|
|
1503
|
+
const d = { lng: W[Y][0], lat: W[Y][1] }, R = { lng: W[Y + 1][0], lat: W[Y + 1][1] }, T = this.calculatePointToLineDistance(M, d, R);
|
|
1504
|
+
b > T && (b = T, c = Y, p = q, O = this.calculateDistance(d, M), A = this.calculateDistance(R, M));
|
|
1505
1505
|
}
|
|
1506
1506
|
}), O !== 0 && A !== 0 ? z[p].splice(c + 1, 0, [M.lng, M.lat]) : O === 0 ? z[p].splice(c, 1, [M.lng, M.lat]) : A === 0 && z[p].splice(c + 1, 1, [M.lng, M.lat]), z;
|
|
1507
1507
|
}
|
|
@@ -1512,8 +1512,8 @@ class S {
|
|
|
1512
1512
|
*/
|
|
1513
1513
|
static appendCoordinateToRoute(M, z) {
|
|
1514
1514
|
M.lng = n.convertToStdLng(M.lng, 8);
|
|
1515
|
-
const b =
|
|
1516
|
-
return b.push(M),
|
|
1515
|
+
const b = B.convertRouteToCoordinates(z);
|
|
1516
|
+
return b.push(M), B.divideAccordingToLng(b);
|
|
1517
1517
|
}
|
|
1518
1518
|
/**
|
|
1519
1519
|
* 向route头加1个坐标
|
|
@@ -1521,8 +1521,8 @@ class S {
|
|
|
1521
1521
|
* @param route
|
|
1522
1522
|
*/
|
|
1523
1523
|
static unshiftCoordinateToRoute(M, z) {
|
|
1524
|
-
const b =
|
|
1525
|
-
return b.unshift(M),
|
|
1524
|
+
const b = B.convertRouteToCoordinates(z);
|
|
1525
|
+
return b.unshift(M), B.divideAccordingToLng(b);
|
|
1526
1526
|
}
|
|
1527
1527
|
/**
|
|
1528
1528
|
* 合并多个waypoints进航线
|
|
@@ -1596,8 +1596,8 @@ class S {
|
|
|
1596
1596
|
* @return [[[lng, lat]]]
|
|
1597
1597
|
*/
|
|
1598
1598
|
static calculateSubRoute(M, z) {
|
|
1599
|
-
const b =
|
|
1600
|
-
|
|
1599
|
+
const b = B.convertRouteToCoordinates(z);
|
|
1600
|
+
B.mergeCoordinateToWaypoints(M, b, !0), z = B.divideAccordingToLng(b);
|
|
1601
1601
|
const { segIndex: p, minIndex: c } = this.calculateMinDistanceToRoute({ ...M }, z);
|
|
1602
1602
|
M.lng = n.convertToStdLng(M.lng);
|
|
1603
1603
|
const O = [];
|
|
@@ -1704,8 +1704,8 @@ class S {
|
|
|
1704
1704
|
W.lng = n.convertToStdLng(W.lng);
|
|
1705
1705
|
const Y = z[q + 1];
|
|
1706
1706
|
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)) {
|
|
1707
|
-
const d = this.calculateDistance(W, Y, !0),
|
|
1708
|
-
W.sog = n.roundPrecision(d /
|
|
1707
|
+
const d = this.calculateDistance(W, Y, !0), R = Math.abs(Y.positionTime - W.positionTime) / 3600;
|
|
1708
|
+
W.sog = n.roundPrecision(d / R, 2);
|
|
1709
1709
|
}
|
|
1710
1710
|
return W;
|
|
1711
1711
|
});
|
|
@@ -1768,7 +1768,7 @@ class S {
|
|
|
1768
1768
|
* @return { coordinate: {lng, lat}, route: [[[lng, lat]]]}
|
|
1769
1769
|
*/
|
|
1770
1770
|
static calculateNextCoordinateAlongRoute(M, z, b, p = "nauticalmiles") {
|
|
1771
|
-
var
|
|
1771
|
+
var R;
|
|
1772
1772
|
const c = M.speed || 12, O = [];
|
|
1773
1773
|
let A = [], W = !1, q = 0, Y = 0, d;
|
|
1774
1774
|
if (z && b.length ? (O.push(M), b.forEach((T, f) => {
|
|
@@ -1776,29 +1776,29 @@ class S {
|
|
|
1776
1776
|
A.push(T);
|
|
1777
1777
|
else {
|
|
1778
1778
|
const i = [];
|
|
1779
|
-
let
|
|
1779
|
+
let S;
|
|
1780
1780
|
for (let s = 0; s < T.length; s++)
|
|
1781
1781
|
if (d)
|
|
1782
1782
|
i.push(T[s]);
|
|
1783
1783
|
else {
|
|
1784
|
-
|
|
1785
|
-
const Z = this.calculateDistance(M,
|
|
1784
|
+
S = { lng: T[s][0], lat: T[s][1] };
|
|
1785
|
+
const Z = this.calculateDistance(M, S, !0, 8, p);
|
|
1786
1786
|
if (q += Z, q < z)
|
|
1787
|
-
Y += Z, Z && O.push(
|
|
1787
|
+
Y += Z, Z && O.push(S), M = S;
|
|
1788
1788
|
else {
|
|
1789
1789
|
if (Y = z, q === z)
|
|
1790
|
-
d =
|
|
1790
|
+
d = S, i.push([d.lng, d.lat]);
|
|
1791
1791
|
else {
|
|
1792
|
-
const P = q - z,
|
|
1793
|
-
d = this.calculateCoordinate(
|
|
1792
|
+
const P = q - z, r = this.calculateBearing(S, M);
|
|
1793
|
+
d = this.calculateCoordinate(S, r, P, p), i.push([d.lng, d.lat]), i.push([S.lng, S.lat]);
|
|
1794
1794
|
}
|
|
1795
1795
|
W = !0;
|
|
1796
1796
|
}
|
|
1797
1797
|
}
|
|
1798
|
-
i.length && A.push(i), f === b.length - 1 && !d && (d =
|
|
1798
|
+
i.length && A.push(i), f === b.length - 1 && !d && (d = S);
|
|
1799
1799
|
}
|
|
1800
1800
|
})) : (A = b, d = { ...M }), d)
|
|
1801
|
-
if (O.push(d), d.distanceFromPrevious = Y, d.hourFromPrevious = Math.round(Y / c * 1e4) / 1e4, ((
|
|
1801
|
+
if (O.push(d), d.distanceFromPrevious = Math.round(Y * 1e4) / 1e4, d.hourFromPrevious = Math.round(Y / c * 1e4) / 1e4, ((R = A[0]) == null ? void 0 : R.length) > 1) {
|
|
1802
1802
|
const T = { lng: A[0][1][0], lat: A[0][1][1] };
|
|
1803
1803
|
d.bearing = this.calculateBearing(d, T);
|
|
1804
1804
|
} else
|
|
@@ -1815,8 +1815,8 @@ class S {
|
|
|
1815
1815
|
const p = n.convertToStdLng(M.lng, 6), c = N.point([p, M.lat]), O = n.convertToStdLng(z.lng, 6), A = n.convertToStdLng(b.lng, 6), W = N.lineString([
|
|
1816
1816
|
[O, z.lat],
|
|
1817
1817
|
[A, b.lat]
|
|
1818
|
-
]), q = N.nearestPointOnLine(W, c), Y = N.getCoord(q), d = n.roundPrecision(Y[0], 6),
|
|
1819
|
-
return { lng: d, lat:
|
|
1818
|
+
]), q = N.nearestPointOnLine(W, c), Y = N.getCoord(q), d = n.roundPrecision(Y[0], 6), R = n.roundPrecision(Y[1], 6);
|
|
1819
|
+
return { lng: d, lat: R, inline: !(d === O && R === z.lat) && !(d === A && R === b.lat) };
|
|
1820
1820
|
}
|
|
1821
1821
|
/**
|
|
1822
1822
|
* 将route转coordinate
|
|
@@ -1930,7 +1930,7 @@ class S {
|
|
|
1930
1930
|
const O = M[c - 1], A = M[c], W = M[c + 1];
|
|
1931
1931
|
let q = !1, Y = !1;
|
|
1932
1932
|
if ((O.velocity || O.suspend || O.important || O.pilot || c === 1) && (q = !0, p.push(O)), A.gcToPrevious && (q || (q = !0, p.push(O)), Y = !0, p.push(A), c++), W) {
|
|
1933
|
-
const d =
|
|
1933
|
+
const d = B.calculateDistance(O, A, !0), R = B.calculateDistance(A, W, !0), T = B.calculateDistance(O, W, !0), f = (Math.pow(d, 2) + Math.pow(R, 2) - Math.pow(T, 2)) / (2 * d * R);
|
|
1934
1934
|
Math.round(Math.acos(f) * 180 / Math.PI) < b && T > z && !Y && (p.push(A), c++);
|
|
1935
1935
|
}
|
|
1936
1936
|
if (c >= M.length - 1) {
|
|
@@ -1947,7 +1947,7 @@ class S {
|
|
|
1947
1947
|
* @param waypoints 带时间的轨迹, 单位秒
|
|
1948
1948
|
*/
|
|
1949
1949
|
static nearestTSPointInWaypoints(M, z, b) {
|
|
1950
|
-
const p =
|
|
1950
|
+
const p = u.unix(M), c = b.filter(
|
|
1951
1951
|
(O) => p.clone().subtract(z, "hour").unix() <= (O.positionTime || 0) && p.clone().add(z, "h").unix() >= (O.positionTime || 0)
|
|
1952
1952
|
);
|
|
1953
1953
|
return c.sort((O, A) => (O.positionTime || 0) - (A.positionTime || 0)), c.at(-1);
|
|
@@ -1960,15 +1960,15 @@ class S {
|
|
|
1960
1960
|
static deadReckoning(M, z) {
|
|
1961
1961
|
var c, O, A, W;
|
|
1962
1962
|
M > 1e12 && (M = Math.round(M / 1e3));
|
|
1963
|
-
const b =
|
|
1963
|
+
const b = u.unix(M);
|
|
1964
1964
|
let p = z.find((q) => q.positionTime === b.unix());
|
|
1965
1965
|
if (!p) {
|
|
1966
|
-
const q = (O = (c = z.filter((d) => (d == null ? void 0 : d.positionTime) < b.unix())) == null ? void 0 : c.sort((d,
|
|
1966
|
+
const q = (O = (c = z.filter((d) => (d == null ? void 0 : d.positionTime) < b.unix())) == null ? void 0 : c.sort((d, R) => (d.positionTime || 0) - (R.positionTime || 0))) == null ? void 0 : O.at(-1), Y = (W = (A = z.filter((d) => (d == null ? void 0 : d.positionTime) > b.unix())) == null ? void 0 : A.sort((d, R) => (d.positionTime || 0) - (R.positionTime || 0))) == null ? void 0 : W.at(0);
|
|
1967
1967
|
if (q && Y) {
|
|
1968
|
-
const d =
|
|
1969
|
-
p =
|
|
1968
|
+
const d = B.calculateBearing(q, Y, !0), R = B.calculateDistance(q, Y), T = (b.unix() - q.positionTime) / (Y.positionTime - q.positionTime);
|
|
1969
|
+
p = B.calculateCoordinate(q, d, R * T), p.positionTime = b.unix(), p.utc = b.utc().format(), p.cog = d, p.sog = Math.round(R / ((Y.positionTime - q.positionTime) / 3600) * 100) / 100;
|
|
1970
1970
|
} else
|
|
1971
|
-
p = q || Y, p && (p.utc =
|
|
1971
|
+
p = q || Y, p && (p.utc = u.unix(p == null ? void 0 : p.positionTime).utc().format());
|
|
1972
1972
|
}
|
|
1973
1973
|
return p;
|
|
1974
1974
|
}
|
|
@@ -1981,19 +1981,19 @@ class S {
|
|
|
1981
1981
|
z = JSON.parse(JSON.stringify(z)), z.sort((q, Y) => (q.positionTime || 0) - (Y.positionTime || 0));
|
|
1982
1982
|
let b = Number.MAX_SAFE_INTEGER, p = Number.MAX_SAFE_INTEGER;
|
|
1983
1983
|
for (let q = 0; q < z.length - 1; q++) {
|
|
1984
|
-
const Y = z[q], d = z[q + 1],
|
|
1985
|
-
|
|
1984
|
+
const Y = z[q], d = z[q + 1], R = B.calculatePointToLineDistance(M, Y, d);
|
|
1985
|
+
R < b && (b = R, p = q);
|
|
1986
1986
|
}
|
|
1987
|
-
const c = z[p], O = z[p + 1], A =
|
|
1987
|
+
const c = z[p], O = z[p + 1], A = B.calculateDistance(c, M), W = B.calculateDistance(O, M);
|
|
1988
1988
|
if (A === 0)
|
|
1989
1989
|
M = c;
|
|
1990
1990
|
else if (W === 0)
|
|
1991
1991
|
M = O;
|
|
1992
1992
|
else {
|
|
1993
|
-
const q = c.positionTime || 0, Y = O.positionTime || 0, d =
|
|
1993
|
+
const q = c.positionTime || 0, Y = O.positionTime || 0, d = B.calculateDistance(c, O);
|
|
1994
1994
|
M.positionTime = Math.round(q + (Y - q) * (A / d));
|
|
1995
1995
|
}
|
|
1996
|
-
return M.utc = M.positionTime ?
|
|
1996
|
+
return M.utc = M.positionTime ? u.unix(M.positionTime).utc().format() : void 0, M.positionTime ? M : void 0;
|
|
1997
1997
|
}
|
|
1998
1998
|
/**
|
|
1999
1999
|
* 翻转轨迹
|
|
@@ -2040,7 +2040,7 @@ class S {
|
|
|
2040
2040
|
*/
|
|
2041
2041
|
static coordinatesSummary(M) {
|
|
2042
2042
|
if (M.length > 1) {
|
|
2043
|
-
const z = M[0], b = M[M.length - 1], p = (z == null ? void 0 : z.positionTime) < (b == null ? void 0 : b.positionTime) ?
|
|
2043
|
+
const z = M[0], b = M[M.length - 1], p = (z == null ? void 0 : z.positionTime) < (b == null ? void 0 : b.positionTime) ? u.unix(z == null ? void 0 : z.positionTime) : u.unix(b == null ? void 0 : b.positionTime), c = (z == null ? void 0 : z.positionTime) > (b == null ? void 0 : b.positionTime) ? u.unix(z == null ? void 0 : z.positionTime) : u.unix(b == null ? void 0 : b.positionTime), O = Math.round(c.diff(p, "hours", !0) * 100) / 100, A = this.generateRouteAccordingToWaypoints(M, !0, !0), W = this.calculateRouteDistance(A), q = O ? Math.round(W / O * 100) / 100 : 0;
|
|
2044
2044
|
return {
|
|
2045
2045
|
begin: p.utc().format(),
|
|
2046
2046
|
end: c.utc().format(),
|
|
@@ -2067,24 +2067,23 @@ class S {
|
|
|
2067
2067
|
* }
|
|
2068
2068
|
*/
|
|
2069
2069
|
static pickUTCSampleFromSpeed(M, z) {
|
|
2070
|
-
var Y, d,
|
|
2070
|
+
var Y, d, R;
|
|
2071
2071
|
if (!((d = (Y = z == null ? void 0 : z.sample) == null ? void 0 : Y.hours) != null && d.length))
|
|
2072
2072
|
return { routes: [], hour: void 0 };
|
|
2073
|
-
const b = z.sample.hours.at(0), p =
|
|
2073
|
+
const b = z.sample.hours.at(0), p = u.utc(M), c = u.utc(z.eta), O = p.isAfter(c) ? c : p;
|
|
2074
2074
|
let A = z.sample.hours.find((T) => T.eta === O.format());
|
|
2075
2075
|
if (!A) {
|
|
2076
|
-
const T = z.sample.hours.filter((h) =>
|
|
2077
|
-
A = (
|
|
2078
|
-
const { bearing: i, cFactor:
|
|
2076
|
+
const T = z.sample.hours.filter((h) => u.utc(h.eta).isBefore(O)).at(-1), f = this.calculateSubRoute(T, z.route);
|
|
2077
|
+
A = (R = this.calculateNextCoordinateAlongRoute(T, T.speed * O.diff(u(T.etd), "hours", !0), f)) == null ? void 0 : R.coordinate;
|
|
2078
|
+
const { bearing: i, cFactor: S, cog: s, wxFactor: Z, meteo: P } = T, r = Math.round(A.distanceFromPrevious * 1e4) / 1e4, G = Math.round((r + T.distanceFromStart) * 1e4) / 1e4;
|
|
2079
2079
|
A = {
|
|
2080
2080
|
...A,
|
|
2081
|
-
|
|
2082
|
-
cFactor: r,
|
|
2081
|
+
cFactor: S,
|
|
2083
2082
|
cog: s,
|
|
2084
2083
|
speed: T.speed,
|
|
2085
2084
|
wxFactor: Z,
|
|
2086
2085
|
distanceFromStart: G,
|
|
2087
|
-
distanceFromPrevious:
|
|
2086
|
+
distanceFromPrevious: r,
|
|
2088
2087
|
meteo: P,
|
|
2089
2088
|
eta: O.format(),
|
|
2090
2089
|
etd: O.format()
|
|
@@ -2097,6 +2096,18 @@ class S {
|
|
|
2097
2096
|
hour: A
|
|
2098
2097
|
};
|
|
2099
2098
|
}
|
|
2099
|
+
static pickUTCSampleFromRoute(M, z, b) {
|
|
2100
|
+
var T;
|
|
2101
|
+
const p = this.calculateSubRoute(z, b), c = this.calculateRouteDistance(p), O = c / z.speed, A = u.utc(M), W = u(z.etd), q = (T = this.calculateNextCoordinateAlongRoute(z, z.speed * A.diff(u(z.etd), "hours", !0), p)) == null ? void 0 : T.coordinate;
|
|
2102
|
+
q.speed = z.speed;
|
|
2103
|
+
const Y = W.clone().add(q.hourFromPrevious, "hour");
|
|
2104
|
+
q.eta = Math.abs(Y.diff(A, "second")) < 2 ? A.format() : Y.format(), q.etd = q.eta, q.distanceFromStart = Math.round(q.distanceFromPrevious * 100) / 100, q.distanceToGo = Math.round((c - q.distanceFromStart) * 100) / 100, q.timeToGo = Math.round(W.clone().add(O, "hour").diff(u(q.etd), "hour") * 100) / 100;
|
|
2105
|
+
const d = this.calculateRangeWaypoints(z, q, b);
|
|
2106
|
+
return {
|
|
2107
|
+
routes: this.generateRouteAccordingToWaypoints(d),
|
|
2108
|
+
hour: q
|
|
2109
|
+
};
|
|
2110
|
+
}
|
|
2100
2111
|
}
|
|
2101
2112
|
let I;
|
|
2102
2113
|
try {
|
|
@@ -2118,20 +2129,20 @@ class t0 {
|
|
|
2118
2129
|
A && A.wind && (A.wind.kts = A.kts);
|
|
2119
2130
|
for (const W of O.forecasts) {
|
|
2120
2131
|
let q;
|
|
2121
|
-
const Y = [], d = [],
|
|
2132
|
+
const Y = [], d = [], R = u(W.date).utc(), T = `${O.name}-${W.model}`;
|
|
2122
2133
|
for (const i in W == null ? void 0 : W.hours) {
|
|
2123
|
-
const
|
|
2124
|
-
q = q ||
|
|
2125
|
-
const s =
|
|
2134
|
+
const S = W.hours[i];
|
|
2135
|
+
q = q || S;
|
|
2136
|
+
const s = R.clone().add(Number(i), "hour"), Z = N.point([S.lng, S.lat], {
|
|
2126
2137
|
model: W.model,
|
|
2127
2138
|
name: O.name,
|
|
2128
2139
|
date: s.format(),
|
|
2129
2140
|
hour: Number(i),
|
|
2130
2141
|
format: s.format("MMM-DD/HHmm[Z]"),
|
|
2131
|
-
pressure:
|
|
2132
|
-
gusts:
|
|
2133
|
-
wind:
|
|
2134
|
-
movement:
|
|
2142
|
+
pressure: S.pressure > 1e4 ? n.roundPrecision(S.pressure / 100, 0) : n.roundPrecision(S.pressure, 0),
|
|
2143
|
+
gusts: S.gusts,
|
|
2144
|
+
wind: S.wind || {},
|
|
2145
|
+
movement: S.movement,
|
|
2135
2146
|
category: T,
|
|
2136
2147
|
type: "forecast"
|
|
2137
2148
|
});
|
|
@@ -2142,12 +2153,12 @@ class t0 {
|
|
|
2142
2153
|
deg: void 0
|
|
2143
2154
|
};
|
|
2144
2155
|
if (A) {
|
|
2145
|
-
const i =
|
|
2156
|
+
const i = u(A.updated).utc();
|
|
2146
2157
|
if (q) {
|
|
2147
|
-
const s =
|
|
2148
|
-
f.kts = Math.round(s / Z * 100) / 100, f.deg =
|
|
2158
|
+
const s = B.calculateDistance(A, q), Z = u(q.utc || q.updated).diff(i, "h", !0);
|
|
2159
|
+
f.kts = Math.round(s / Z * 100) / 100, f.deg = B.calculateBearing(A, q, !0, 0);
|
|
2149
2160
|
}
|
|
2150
|
-
const
|
|
2161
|
+
const S = N.point([A.lng, A.lat], {
|
|
2151
2162
|
model: W.model,
|
|
2152
2163
|
name: O.name,
|
|
2153
2164
|
date: i.format(),
|
|
@@ -2161,11 +2172,11 @@ class t0 {
|
|
|
2161
2172
|
important: !0
|
|
2162
2173
|
// 第一个预报点为重要点
|
|
2163
2174
|
});
|
|
2164
|
-
d.unshift(
|
|
2175
|
+
d.unshift(S), Y.unshift(S.geometry.coordinates);
|
|
2165
2176
|
}
|
|
2166
2177
|
if (z.features.push(...d), (Y == null ? void 0 : Y.length) > 1) {
|
|
2167
2178
|
const i = N.lineString(n.convertToMonotonicLng2(Y), {
|
|
2168
|
-
date: (A == null ? void 0 : A.updated) || (
|
|
2179
|
+
date: (A == null ? void 0 : A.updated) || (R == null ? void 0 : R.format()),
|
|
2169
2180
|
id: O.id || O.name,
|
|
2170
2181
|
model: W.model,
|
|
2171
2182
|
name: O.name,
|
|
@@ -2177,28 +2188,28 @@ class t0 {
|
|
|
2177
2188
|
}
|
|
2178
2189
|
}
|
|
2179
2190
|
}
|
|
2180
|
-
if (z.features.sort((W, q) => W.properties.type === "forecast" && q.properties.type === "forecast" && W.geometry.type === "Point" && q.geometry.type === "Point" ?
|
|
2181
|
-
const W = [], q =
|
|
2182
|
-
for (const
|
|
2183
|
-
const T =
|
|
2191
|
+
if (z.features.sort((W, q) => W.properties.type === "forecast" && q.properties.type === "forecast" && W.geometry.type === "Point" && q.geometry.type === "Point" ? u(W.properties.date).valueOf() - u(q.properties.date).valueOf() : 0), (p = O.history) != null && p.length) {
|
|
2192
|
+
const W = [], q = u(A == null ? void 0 : A.updated).utc(), Y = u((c = O.history) == null ? void 0 : c.at(-1).updated).utc(), d = q.diff(Y, "h") % 24 > 2 ? 24 : 12;
|
|
2193
|
+
for (const R of O.history) {
|
|
2194
|
+
const T = u(R.updated).utc(), f = T.isSameOrBefore(q) || T.isSame(Y);
|
|
2184
2195
|
f && q.add(-d, "h");
|
|
2185
|
-
const i = N.point([
|
|
2196
|
+
const i = N.point([R.lng, R.lat], {
|
|
2186
2197
|
name: O.name,
|
|
2187
2198
|
date: T.format(),
|
|
2188
2199
|
format: T.format("MMM-DD/HHmm[Z]"),
|
|
2189
|
-
pressure:
|
|
2190
|
-
kts:
|
|
2191
|
-
level:
|
|
2200
|
+
pressure: R.pressure > 1e4 ? n.roundPrecision(R.pressure / 100, 0) : n.roundPrecision(R.pressure, 0),
|
|
2201
|
+
kts: R.kts,
|
|
2202
|
+
level: R.type,
|
|
2192
2203
|
type: "history",
|
|
2193
2204
|
category: `${O.name}-history`,
|
|
2194
|
-
wind:
|
|
2195
|
-
movement:
|
|
2205
|
+
wind: R.wind,
|
|
2206
|
+
movement: R.movement,
|
|
2196
2207
|
important: f
|
|
2197
2208
|
});
|
|
2198
2209
|
z.features.push(i), W.push(i.geometry.coordinates);
|
|
2199
2210
|
}
|
|
2200
2211
|
if (W.length === 1 && W.push(W[0]), W.length > 1) {
|
|
2201
|
-
const
|
|
2212
|
+
const R = N.lineString(n.convertToMonotonicLng2(W), {
|
|
2202
2213
|
name: O.name,
|
|
2203
2214
|
type: "history",
|
|
2204
2215
|
updated: A == null ? void 0 : A.updated,
|
|
@@ -2206,7 +2217,7 @@ class t0 {
|
|
|
2206
2217
|
kts: A == null ? void 0 : A.kts,
|
|
2207
2218
|
level: A == null ? void 0 : A.type
|
|
2208
2219
|
});
|
|
2209
|
-
z.features.push(
|
|
2220
|
+
z.features.push(R);
|
|
2210
2221
|
}
|
|
2211
2222
|
}
|
|
2212
2223
|
}
|
|
@@ -2221,28 +2232,28 @@ class t0 {
|
|
|
2221
2232
|
var c, O, A, W;
|
|
2222
2233
|
const b = (c = M == null ? void 0 : M.data) == null ? void 0 : c.features.filter((q) => q.geometry.type === "LineString" && q.properties.type === "forecast"), p = [];
|
|
2223
2234
|
for (const q of b) {
|
|
2224
|
-
const Y = q.properties.name, d = q.properties.model,
|
|
2235
|
+
const Y = q.properties.name, d = q.properties.model, R = q.properties.showCircle, T = q.properties.disabled, f = u(q.properties.date).utc();
|
|
2225
2236
|
let i = z * 60;
|
|
2226
|
-
const
|
|
2237
|
+
const S = (O = M == null ? void 0 : M.data) == null ? void 0 : O.features.filter(
|
|
2227
2238
|
(P) => P.geometry.type === "Point" && P.properties.type === "forecast" && P.properties.category === `${Y}-${d}`
|
|
2228
2239
|
);
|
|
2229
2240
|
let s, Z = f.clone().add(i, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2230
|
-
for (; s = this.pickIndex(
|
|
2241
|
+
for (; s = this.pickIndex(S, Z), s <= S.length - 1; ) {
|
|
2231
2242
|
if (s > 0) {
|
|
2232
|
-
const P =
|
|
2243
|
+
const P = S[s], r = s === 0 ? void 0 : S[s - 1], G = (i / 60 - ((A = r == null ? void 0 : r.properties) == null ? void 0 : A.hour)) / (P.properties.hour - ((W = r == null ? void 0 : r.properties) == null ? void 0 : W.hour)), h = this.computeNumber(r == null ? void 0 : r.geometry.coordinates[0], P.geometry.coordinates[0], G), Q = this.computeNumber(r == null ? void 0 : r.geometry.coordinates[1], P.geometry.coordinates[1], G), F = N.point([h, Q], {
|
|
2233
2244
|
name: Y,
|
|
2234
2245
|
model: d,
|
|
2235
2246
|
category: P == null ? void 0 : P.properties.category,
|
|
2236
2247
|
date: Z.format(),
|
|
2237
2248
|
format: Z.format("MMM-DD/HHmm[Z]"),
|
|
2238
|
-
gusts: this.computeNumber(
|
|
2239
|
-
hour: this.computeNumber(
|
|
2240
|
-
movement: this.computeNumber(
|
|
2241
|
-
pressure: this.computeNumber(
|
|
2242
|
-
wind: this.computeNumber(
|
|
2249
|
+
gusts: this.computeNumber(r == null ? void 0 : r.properties.gusts, P.properties.gusts, G),
|
|
2250
|
+
hour: this.computeNumber(r == null ? void 0 : r.properties.hour, P.properties.hour, G),
|
|
2251
|
+
movement: this.computeNumber(r == null ? void 0 : r.properties.movement, P.properties.movement, G),
|
|
2252
|
+
pressure: this.computeNumber(r == null ? void 0 : r.properties.pressure, P.properties.pressure, G),
|
|
2253
|
+
wind: this.computeNumber(r == null ? void 0 : r.properties.wind, P.properties.wind, G),
|
|
2243
2254
|
type: "forecast",
|
|
2244
2255
|
disabled: T,
|
|
2245
|
-
showCircle:
|
|
2256
|
+
showCircle: R
|
|
2246
2257
|
});
|
|
2247
2258
|
p.push(F);
|
|
2248
2259
|
}
|
|
@@ -2276,7 +2287,7 @@ class t0 {
|
|
|
2276
2287
|
const { t1: c, t2: O, hr: A, hours: W } = this.tropicalCenterTwin(z, 24, p);
|
|
2277
2288
|
if (c && O) {
|
|
2278
2289
|
if (!p.debug) {
|
|
2279
|
-
const f =
|
|
2290
|
+
const f = B.calculateDistance(M, c), i = B.calculateDistance(M, O);
|
|
2280
2291
|
if (f > 2 * b && i > 2 * b)
|
|
2281
2292
|
return I == null || I.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", p.requestId, f, i, {
|
|
2282
2293
|
from: M,
|
|
@@ -2285,10 +2296,10 @@ class t0 {
|
|
|
2285
2296
|
hr: A
|
|
2286
2297
|
}), {};
|
|
2287
2298
|
}
|
|
2288
|
-
const q =
|
|
2289
|
-
let
|
|
2290
|
-
d < 180 ?
|
|
2291
|
-
const T =
|
|
2299
|
+
const q = B.calculateBearing(M, c), Y = B.calculateBearing(c, O), d = Math.abs(q - Y);
|
|
2300
|
+
let R = 0;
|
|
2301
|
+
d < 180 ? R = d + 90 : d >= 180 && (R = d - 90);
|
|
2302
|
+
const T = B.calculateCoordinate(c, R, b);
|
|
2292
2303
|
return I == null || I.info("[%s] the right tangent position: %j", p.requestId, {
|
|
2293
2304
|
from: M,
|
|
2294
2305
|
t1: c,
|
|
@@ -2315,7 +2326,7 @@ class t0 {
|
|
|
2315
2326
|
const { t1: c, t2: O, hr: A, hours: W } = this.tropicalCenterTwin(z, 24, p);
|
|
2316
2327
|
if (c && O) {
|
|
2317
2328
|
if (!p.debug) {
|
|
2318
|
-
const T =
|
|
2329
|
+
const T = B.calculateDistance(M, c), f = B.calculateDistance(M, O);
|
|
2319
2330
|
if (T > 2 * b && f > 2 * b)
|
|
2320
2331
|
return I == null || I.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", p.requestId, T, f, {
|
|
2321
2332
|
from: M,
|
|
@@ -2324,8 +2335,8 @@ class t0 {
|
|
|
2324
2335
|
hr: A
|
|
2325
2336
|
}), {};
|
|
2326
2337
|
}
|
|
2327
|
-
const q =
|
|
2328
|
-
return { at:
|
|
2338
|
+
const q = B.calculateBearing(M, c), Y = B.calculateBearing(c, O), d = B.calculateDistance(M, c);
|
|
2339
|
+
return { at: B.calculateCoordinate(c, q - Y + 180, b < d ? b : d), t1: c, t2: O, hr: Number(A), hours: W };
|
|
2329
2340
|
} else
|
|
2330
2341
|
return I == null || I.info("[%s] no need drift: %j", p.requestId, { from: M, t1: c, t2: O, hr: A }), {};
|
|
2331
2342
|
}
|
|
@@ -2338,12 +2349,12 @@ class t0 {
|
|
|
2338
2349
|
* @private
|
|
2339
2350
|
*/
|
|
2340
2351
|
static tropicalCenterTwin(M, z = 24, b = {}) {
|
|
2341
|
-
var Y, d,
|
|
2352
|
+
var Y, d, R, T, f;
|
|
2342
2353
|
let p = {};
|
|
2343
2354
|
(Y = M.forecasts) == null || Y.forEach((i) => {
|
|
2344
2355
|
p = { ...i.hours, ...p };
|
|
2345
2356
|
});
|
|
2346
|
-
const c = ((d = M == null ? void 0 : M.history) == null ? void 0 : d[0]) || (p == null ? void 0 : p[(
|
|
2357
|
+
const c = ((d = M == null ? void 0 : M.history) == null ? void 0 : d[0]) || (p == null ? void 0 : p[(R = Object.keys(p)) == null ? void 0 : R[0]]);
|
|
2347
2358
|
I == null || I.info("[%s] the first tropical center: %j", b.requestId, c);
|
|
2348
2359
|
let O = (T = Object.keys(p || {}).filter((i) => Number(i) <= (z < 0 ? 24 : z))) == null ? void 0 : T.at(-1);
|
|
2349
2360
|
O || (O = (f = Object.keys(p || {}).filter((i) => Number(i) <= (z < 0 ? 24 : 2 * z))) == null ? void 0 : f.at(-1));
|
|
@@ -2357,7 +2368,7 @@ class t0 {
|
|
|
2357
2368
|
static pickIndex(M, z) {
|
|
2358
2369
|
let b = 0;
|
|
2359
2370
|
for (const p of M) {
|
|
2360
|
-
if (
|
|
2371
|
+
if (u(p.properties.date).isAfter(z))
|
|
2361
2372
|
return b === 0 ? -1 : b;
|
|
2362
2373
|
b++;
|
|
2363
2374
|
}
|
|
@@ -2385,7 +2396,7 @@ class V0 {
|
|
|
2385
2396
|
return `${M.lat}|${M.lng}|${M.positionTime}|${M.sog}|${M.cog}|${M.hdg}|${M.draught}|${z}|${JSON.stringify(M.meteo || {})}|${M.vendor}|${M.deleted}`;
|
|
2386
2397
|
}
|
|
2387
2398
|
static str2Json(M) {
|
|
2388
|
-
const [z, b, p, c, O, A, W, q, Y, d,
|
|
2399
|
+
const [z, b, p, c, O, A, W, q, Y, d, R] = M.split("|");
|
|
2389
2400
|
return {
|
|
2390
2401
|
lat: Number(z),
|
|
2391
2402
|
lng: Number(b),
|
|
@@ -2399,7 +2410,7 @@ class V0 {
|
|
|
2399
2410
|
important: q !== "A",
|
|
2400
2411
|
meteo: Y ? JSON.parse(Y) : void 0,
|
|
2401
2412
|
vendor: d,
|
|
2402
|
-
deleted:
|
|
2413
|
+
deleted: R === "true"
|
|
2403
2414
|
};
|
|
2404
2415
|
}
|
|
2405
2416
|
static inspectStoppages(M, z = 1, b = !0) {
|
|
@@ -2411,12 +2422,12 @@ class V0 {
|
|
|
2411
2422
|
const q = M[W];
|
|
2412
2423
|
if (!(b && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))) {
|
|
2413
2424
|
for (let Y = W + 1; Y < M.length; Y++) {
|
|
2414
|
-
const d = M[Y - 1],
|
|
2425
|
+
const d = M[Y - 1], R = M[Y];
|
|
2415
2426
|
if (b && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))
|
|
2416
2427
|
continue;
|
|
2417
|
-
const T =
|
|
2418
|
-
if (
|
|
2419
|
-
O || (O = q), Y === M.length - 1 && (A =
|
|
2428
|
+
const T = R.positionTime - d.positionTime;
|
|
2429
|
+
if (B.calculateDistance(R, d, !0, 4) / (T / 3600) < z)
|
|
2430
|
+
O || (O = q), Y === M.length - 1 && (A = R, W = Y);
|
|
2420
2431
|
else {
|
|
2421
2432
|
O && (A = M[Y - 1], W = Y);
|
|
2422
2433
|
break;
|
|
@@ -2429,18 +2440,18 @@ class V0 {
|
|
|
2429
2440
|
lng: O.lng,
|
|
2430
2441
|
sog: O.sog,
|
|
2431
2442
|
positionTime: O.positionTime,
|
|
2432
|
-
utc:
|
|
2443
|
+
utc: u.unix(O.positionTime).utc().format()
|
|
2433
2444
|
},
|
|
2434
2445
|
end: {
|
|
2435
2446
|
lat: A.lat,
|
|
2436
2447
|
lng: A.lng,
|
|
2437
2448
|
sog: A.sog,
|
|
2438
2449
|
positionTime: A.positionTime,
|
|
2439
|
-
utc:
|
|
2450
|
+
utc: u.unix(A.positionTime).utc().format()
|
|
2440
2451
|
},
|
|
2441
2452
|
duration: A.positionTime - O.positionTime
|
|
2442
|
-
}, d = M.filter((T) => T.positionTime >= Y.start.positionTime && T.positionTime <= Y.end.positionTime),
|
|
2443
|
-
Y.distance =
|
|
2453
|
+
}, d = M.filter((T) => T.positionTime >= Y.start.positionTime && T.positionTime <= Y.end.positionTime), R = B.divideAccordingToLng(d);
|
|
2454
|
+
Y.distance = B.calculateRouteDistance(R), Y.hours = Math.round(Y.duration / 3600 * 10) / 10, Y.avgSog = Math.round(Y.distance / Y.hours * 10) / 10, c.push(Y);
|
|
2444
2455
|
}
|
|
2445
2456
|
O = void 0, A = void 0;
|
|
2446
2457
|
}
|
|
@@ -2450,7 +2461,7 @@ class V0 {
|
|
|
2450
2461
|
}
|
|
2451
2462
|
export {
|
|
2452
2463
|
V0 as AisHelper,
|
|
2453
|
-
|
|
2464
|
+
B as LaneHelper,
|
|
2454
2465
|
n as LngLatHelper,
|
|
2455
2466
|
t0 as TropicalHelper
|
|
2456
2467
|
};
|