@idm-plugin/geo 1.9.3 → 1.9.5
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 +194 -172
- package/dist/index.umd.cjs +3 -3
- package/dist/lane/src/index.d.ts +16 -0
- package/dist/tropicals/src/index.d.ts +1 -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,28 @@ class S {
|
|
|
2097
2096
|
hour: A
|
|
2098
2097
|
};
|
|
2099
2098
|
}
|
|
2099
|
+
/**
|
|
2100
|
+
* 查询特定时间的船位及航行区间
|
|
2101
|
+
* @param utc 目标时间, UTC格式
|
|
2102
|
+
* @param from 起点, 包含speed, etd, lat, lng
|
|
2103
|
+
* @param route
|
|
2104
|
+
* @return {
|
|
2105
|
+
* routes: [],
|
|
2106
|
+
* hour: Coordinate
|
|
2107
|
+
* }
|
|
2108
|
+
*/
|
|
2109
|
+
static pickUTCSampleFromRoute(M, z, b) {
|
|
2110
|
+
var T;
|
|
2111
|
+
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;
|
|
2112
|
+
q.speed = z.speed;
|
|
2113
|
+
const Y = W.clone().add(q.hourFromPrevious, "hour");
|
|
2114
|
+
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;
|
|
2115
|
+
const d = this.calculateRangeWaypoints(z, q, b);
|
|
2116
|
+
return {
|
|
2117
|
+
routes: this.generateRouteAccordingToWaypoints(d),
|
|
2118
|
+
hour: q
|
|
2119
|
+
};
|
|
2120
|
+
}
|
|
2100
2121
|
}
|
|
2101
2122
|
let I;
|
|
2102
2123
|
try {
|
|
@@ -2118,20 +2139,21 @@ class t0 {
|
|
|
2118
2139
|
A && A.wind && (A.wind.kts = A.kts);
|
|
2119
2140
|
for (const W of O.forecasts) {
|
|
2120
2141
|
let q;
|
|
2121
|
-
const Y = [], d = [],
|
|
2142
|
+
const Y = [], d = [], R = u(W.date).utc(), T = `${O.name}-${W.model}`;
|
|
2122
2143
|
for (const i in W == null ? void 0 : W.hours) {
|
|
2123
|
-
const
|
|
2124
|
-
q = q ||
|
|
2125
|
-
const s =
|
|
2144
|
+
const S = W.hours[i];
|
|
2145
|
+
q = q || S;
|
|
2146
|
+
const s = R.clone().add(Number(i), "hour"), Z = N.point([S.lng, S.lat], {
|
|
2126
2147
|
model: W.model,
|
|
2127
2148
|
name: O.name,
|
|
2149
|
+
nameCn: O.nameCn,
|
|
2128
2150
|
date: s.format(),
|
|
2129
2151
|
hour: Number(i),
|
|
2130
2152
|
format: s.format("MMM-DD/HHmm[Z]"),
|
|
2131
|
-
pressure:
|
|
2132
|
-
gusts:
|
|
2133
|
-
wind:
|
|
2134
|
-
movement:
|
|
2153
|
+
pressure: S.pressure > 1e4 ? n.roundPrecision(S.pressure / 100, 0) : n.roundPrecision(S.pressure, 0),
|
|
2154
|
+
gusts: S.gusts,
|
|
2155
|
+
wind: S.wind || {},
|
|
2156
|
+
movement: S.movement,
|
|
2135
2157
|
category: T,
|
|
2136
2158
|
type: "forecast"
|
|
2137
2159
|
});
|
|
@@ -2142,12 +2164,12 @@ class t0 {
|
|
|
2142
2164
|
deg: void 0
|
|
2143
2165
|
};
|
|
2144
2166
|
if (A) {
|
|
2145
|
-
const i =
|
|
2167
|
+
const i = u(A.updated).utc();
|
|
2146
2168
|
if (q) {
|
|
2147
|
-
const s =
|
|
2148
|
-
f.kts = Math.round(s / Z * 100) / 100, f.deg =
|
|
2169
|
+
const s = B.calculateDistance(A, q), Z = u(q.utc || q.updated).diff(i, "h", !0);
|
|
2170
|
+
f.kts = Math.round(s / Z * 100) / 100, f.deg = B.calculateBearing(A, q, !0, 0);
|
|
2149
2171
|
}
|
|
2150
|
-
const
|
|
2172
|
+
const S = N.point([A.lng, A.lat], {
|
|
2151
2173
|
model: W.model,
|
|
2152
2174
|
name: O.name,
|
|
2153
2175
|
date: i.format(),
|
|
@@ -2161,11 +2183,11 @@ class t0 {
|
|
|
2161
2183
|
important: !0
|
|
2162
2184
|
// 第一个预报点为重要点
|
|
2163
2185
|
});
|
|
2164
|
-
d.unshift(
|
|
2186
|
+
d.unshift(S), Y.unshift(S.geometry.coordinates);
|
|
2165
2187
|
}
|
|
2166
2188
|
if (z.features.push(...d), (Y == null ? void 0 : Y.length) > 1) {
|
|
2167
2189
|
const i = N.lineString(n.convertToMonotonicLng2(Y), {
|
|
2168
|
-
date: (A == null ? void 0 : A.updated) || (
|
|
2190
|
+
date: (A == null ? void 0 : A.updated) || (R == null ? void 0 : R.format()),
|
|
2169
2191
|
id: O.id || O.name,
|
|
2170
2192
|
model: W.model,
|
|
2171
2193
|
name: O.name,
|
|
@@ -2177,28 +2199,28 @@ class t0 {
|
|
|
2177
2199
|
}
|
|
2178
2200
|
}
|
|
2179
2201
|
}
|
|
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 =
|
|
2202
|
+
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) {
|
|
2203
|
+
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;
|
|
2204
|
+
for (const R of O.history) {
|
|
2205
|
+
const T = u(R.updated).utc(), f = T.isSameOrBefore(q) || T.isSame(Y);
|
|
2184
2206
|
f && q.add(-d, "h");
|
|
2185
|
-
const i = N.point([
|
|
2207
|
+
const i = N.point([R.lng, R.lat], {
|
|
2186
2208
|
name: O.name,
|
|
2187
2209
|
date: T.format(),
|
|
2188
2210
|
format: T.format("MMM-DD/HHmm[Z]"),
|
|
2189
|
-
pressure:
|
|
2190
|
-
kts:
|
|
2191
|
-
level:
|
|
2211
|
+
pressure: R.pressure > 1e4 ? n.roundPrecision(R.pressure / 100, 0) : n.roundPrecision(R.pressure, 0),
|
|
2212
|
+
kts: R.kts,
|
|
2213
|
+
level: R.type,
|
|
2192
2214
|
type: "history",
|
|
2193
2215
|
category: `${O.name}-history`,
|
|
2194
|
-
wind:
|
|
2195
|
-
movement:
|
|
2216
|
+
wind: R.wind,
|
|
2217
|
+
movement: R.movement,
|
|
2196
2218
|
important: f
|
|
2197
2219
|
});
|
|
2198
2220
|
z.features.push(i), W.push(i.geometry.coordinates);
|
|
2199
2221
|
}
|
|
2200
2222
|
if (W.length === 1 && W.push(W[0]), W.length > 1) {
|
|
2201
|
-
const
|
|
2223
|
+
const R = N.lineString(n.convertToMonotonicLng2(W), {
|
|
2202
2224
|
name: O.name,
|
|
2203
2225
|
type: "history",
|
|
2204
2226
|
updated: A == null ? void 0 : A.updated,
|
|
@@ -2206,7 +2228,7 @@ class t0 {
|
|
|
2206
2228
|
kts: A == null ? void 0 : A.kts,
|
|
2207
2229
|
level: A == null ? void 0 : A.type
|
|
2208
2230
|
});
|
|
2209
|
-
z.features.push(
|
|
2231
|
+
z.features.push(R);
|
|
2210
2232
|
}
|
|
2211
2233
|
}
|
|
2212
2234
|
}
|
|
@@ -2221,28 +2243,28 @@ class t0 {
|
|
|
2221
2243
|
var c, O, A, W;
|
|
2222
2244
|
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
2245
|
for (const q of b) {
|
|
2224
|
-
const Y = q.properties.name, d = q.properties.model,
|
|
2246
|
+
const Y = q.properties.name, d = q.properties.model, R = q.properties.showCircle, T = q.properties.disabled, f = u(q.properties.date).utc();
|
|
2225
2247
|
let i = z * 60;
|
|
2226
|
-
const
|
|
2248
|
+
const S = (O = M == null ? void 0 : M.data) == null ? void 0 : O.features.filter(
|
|
2227
2249
|
(P) => P.geometry.type === "Point" && P.properties.type === "forecast" && P.properties.category === `${Y}-${d}`
|
|
2228
2250
|
);
|
|
2229
2251
|
let s, Z = f.clone().add(i, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2230
|
-
for (; s = this.pickIndex(
|
|
2252
|
+
for (; s = this.pickIndex(S, Z), s <= S.length - 1; ) {
|
|
2231
2253
|
if (s > 0) {
|
|
2232
|
-
const P =
|
|
2254
|
+
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
2255
|
name: Y,
|
|
2234
2256
|
model: d,
|
|
2235
2257
|
category: P == null ? void 0 : P.properties.category,
|
|
2236
2258
|
date: Z.format(),
|
|
2237
2259
|
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(
|
|
2260
|
+
gusts: this.computeNumber(r == null ? void 0 : r.properties.gusts, P.properties.gusts, G),
|
|
2261
|
+
hour: this.computeNumber(r == null ? void 0 : r.properties.hour, P.properties.hour, G),
|
|
2262
|
+
movement: this.computeNumber(r == null ? void 0 : r.properties.movement, P.properties.movement, G),
|
|
2263
|
+
pressure: this.computeNumber(r == null ? void 0 : r.properties.pressure, P.properties.pressure, G),
|
|
2264
|
+
wind: this.computeNumber(r == null ? void 0 : r.properties.wind, P.properties.wind, G),
|
|
2243
2265
|
type: "forecast",
|
|
2244
2266
|
disabled: T,
|
|
2245
|
-
showCircle:
|
|
2267
|
+
showCircle: R
|
|
2246
2268
|
});
|
|
2247
2269
|
p.push(F);
|
|
2248
2270
|
}
|
|
@@ -2276,7 +2298,7 @@ class t0 {
|
|
|
2276
2298
|
const { t1: c, t2: O, hr: A, hours: W } = this.tropicalCenterTwin(z, 24, p);
|
|
2277
2299
|
if (c && O) {
|
|
2278
2300
|
if (!p.debug) {
|
|
2279
|
-
const f =
|
|
2301
|
+
const f = B.calculateDistance(M, c), i = B.calculateDistance(M, O);
|
|
2280
2302
|
if (f > 2 * b && i > 2 * b)
|
|
2281
2303
|
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
2304
|
from: M,
|
|
@@ -2285,10 +2307,10 @@ class t0 {
|
|
|
2285
2307
|
hr: A
|
|
2286
2308
|
}), {};
|
|
2287
2309
|
}
|
|
2288
|
-
const q =
|
|
2289
|
-
let
|
|
2290
|
-
d < 180 ?
|
|
2291
|
-
const T =
|
|
2310
|
+
const q = B.calculateBearing(M, c), Y = B.calculateBearing(c, O), d = Math.abs(q - Y);
|
|
2311
|
+
let R = 0;
|
|
2312
|
+
d < 180 ? R = d + 90 : d >= 180 && (R = d - 90);
|
|
2313
|
+
const T = B.calculateCoordinate(c, R, b);
|
|
2292
2314
|
return I == null || I.info("[%s] the right tangent position: %j", p.requestId, {
|
|
2293
2315
|
from: M,
|
|
2294
2316
|
t1: c,
|
|
@@ -2315,7 +2337,7 @@ class t0 {
|
|
|
2315
2337
|
const { t1: c, t2: O, hr: A, hours: W } = this.tropicalCenterTwin(z, 24, p);
|
|
2316
2338
|
if (c && O) {
|
|
2317
2339
|
if (!p.debug) {
|
|
2318
|
-
const T =
|
|
2340
|
+
const T = B.calculateDistance(M, c), f = B.calculateDistance(M, O);
|
|
2319
2341
|
if (T > 2 * b && f > 2 * b)
|
|
2320
2342
|
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
2343
|
from: M,
|
|
@@ -2324,8 +2346,8 @@ class t0 {
|
|
|
2324
2346
|
hr: A
|
|
2325
2347
|
}), {};
|
|
2326
2348
|
}
|
|
2327
|
-
const q =
|
|
2328
|
-
return { at:
|
|
2349
|
+
const q = B.calculateBearing(M, c), Y = B.calculateBearing(c, O), d = B.calculateDistance(M, c);
|
|
2350
|
+
return { at: B.calculateCoordinate(c, q - Y + 180, b < d ? b : d), t1: c, t2: O, hr: Number(A), hours: W };
|
|
2329
2351
|
} else
|
|
2330
2352
|
return I == null || I.info("[%s] no need drift: %j", p.requestId, { from: M, t1: c, t2: O, hr: A }), {};
|
|
2331
2353
|
}
|
|
@@ -2338,12 +2360,12 @@ class t0 {
|
|
|
2338
2360
|
* @private
|
|
2339
2361
|
*/
|
|
2340
2362
|
static tropicalCenterTwin(M, z = 24, b = {}) {
|
|
2341
|
-
var Y, d,
|
|
2363
|
+
var Y, d, R, T, f;
|
|
2342
2364
|
let p = {};
|
|
2343
2365
|
(Y = M.forecasts) == null || Y.forEach((i) => {
|
|
2344
2366
|
p = { ...i.hours, ...p };
|
|
2345
2367
|
});
|
|
2346
|
-
const c = ((d = M == null ? void 0 : M.history) == null ? void 0 : d[0]) || (p == null ? void 0 : p[(
|
|
2368
|
+
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
2369
|
I == null || I.info("[%s] the first tropical center: %j", b.requestId, c);
|
|
2348
2370
|
let O = (T = Object.keys(p || {}).filter((i) => Number(i) <= (z < 0 ? 24 : z))) == null ? void 0 : T.at(-1);
|
|
2349
2371
|
O || (O = (f = Object.keys(p || {}).filter((i) => Number(i) <= (z < 0 ? 24 : 2 * z))) == null ? void 0 : f.at(-1));
|
|
@@ -2357,7 +2379,7 @@ class t0 {
|
|
|
2357
2379
|
static pickIndex(M, z) {
|
|
2358
2380
|
let b = 0;
|
|
2359
2381
|
for (const p of M) {
|
|
2360
|
-
if (
|
|
2382
|
+
if (u(p.properties.date).isAfter(z))
|
|
2361
2383
|
return b === 0 ? -1 : b;
|
|
2362
2384
|
b++;
|
|
2363
2385
|
}
|
|
@@ -2385,7 +2407,7 @@ class V0 {
|
|
|
2385
2407
|
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
2408
|
}
|
|
2387
2409
|
static str2Json(M) {
|
|
2388
|
-
const [z, b, p, c, O, A, W, q, Y, d,
|
|
2410
|
+
const [z, b, p, c, O, A, W, q, Y, d, R] = M.split("|");
|
|
2389
2411
|
return {
|
|
2390
2412
|
lat: Number(z),
|
|
2391
2413
|
lng: Number(b),
|
|
@@ -2399,7 +2421,7 @@ class V0 {
|
|
|
2399
2421
|
important: q !== "A",
|
|
2400
2422
|
meteo: Y ? JSON.parse(Y) : void 0,
|
|
2401
2423
|
vendor: d,
|
|
2402
|
-
deleted:
|
|
2424
|
+
deleted: R === "true"
|
|
2403
2425
|
};
|
|
2404
2426
|
}
|
|
2405
2427
|
static inspectStoppages(M, z = 1, b = !0) {
|
|
@@ -2411,12 +2433,12 @@ class V0 {
|
|
|
2411
2433
|
const q = M[W];
|
|
2412
2434
|
if (!(b && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))) {
|
|
2413
2435
|
for (let Y = W + 1; Y < M.length; Y++) {
|
|
2414
|
-
const d = M[Y - 1],
|
|
2436
|
+
const d = M[Y - 1], R = M[Y];
|
|
2415
2437
|
if (b && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))
|
|
2416
2438
|
continue;
|
|
2417
|
-
const T =
|
|
2418
|
-
if (
|
|
2419
|
-
O || (O = q), Y === M.length - 1 && (A =
|
|
2439
|
+
const T = R.positionTime - d.positionTime;
|
|
2440
|
+
if (B.calculateDistance(R, d, !0, 4) / (T / 3600) < z)
|
|
2441
|
+
O || (O = q), Y === M.length - 1 && (A = R, W = Y);
|
|
2420
2442
|
else {
|
|
2421
2443
|
O && (A = M[Y - 1], W = Y);
|
|
2422
2444
|
break;
|
|
@@ -2429,18 +2451,18 @@ class V0 {
|
|
|
2429
2451
|
lng: O.lng,
|
|
2430
2452
|
sog: O.sog,
|
|
2431
2453
|
positionTime: O.positionTime,
|
|
2432
|
-
utc:
|
|
2454
|
+
utc: u.unix(O.positionTime).utc().format()
|
|
2433
2455
|
},
|
|
2434
2456
|
end: {
|
|
2435
2457
|
lat: A.lat,
|
|
2436
2458
|
lng: A.lng,
|
|
2437
2459
|
sog: A.sog,
|
|
2438
2460
|
positionTime: A.positionTime,
|
|
2439
|
-
utc:
|
|
2461
|
+
utc: u.unix(A.positionTime).utc().format()
|
|
2440
2462
|
},
|
|
2441
2463
|
duration: A.positionTime - O.positionTime
|
|
2442
|
-
}, d = M.filter((T) => T.positionTime >= Y.start.positionTime && T.positionTime <= Y.end.positionTime),
|
|
2443
|
-
Y.distance =
|
|
2464
|
+
}, d = M.filter((T) => T.positionTime >= Y.start.positionTime && T.positionTime <= Y.end.positionTime), R = B.divideAccordingToLng(d);
|
|
2465
|
+
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
2466
|
}
|
|
2445
2467
|
O = void 0, A = void 0;
|
|
2446
2468
|
}
|
|
@@ -2450,7 +2472,7 @@ class V0 {
|
|
|
2450
2472
|
}
|
|
2451
2473
|
export {
|
|
2452
2474
|
V0 as AisHelper,
|
|
2453
|
-
|
|
2475
|
+
B as LaneHelper,
|
|
2454
2476
|
n as LngLatHelper,
|
|
2455
2477
|
t0 as TropicalHelper
|
|
2456
2478
|
};
|