@idm-plugin/geo 1.4.4 → 1.4.6

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 CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as g from "@turf/turf";
2
- import R from "moment";
2
+ import y from "moment";
3
3
  import "moment-timezone";
4
4
  import A from "tz-lookup";
5
5
  function E(C) {
6
6
  return C && C.__esModule && Object.prototype.hasOwnProperty.call(C, "default") ? C.default : C;
7
7
  }
8
- class y {
8
+ class R {
9
9
  log() {
10
10
  }
11
11
  isLevelEnabled() {
@@ -19,18 +19,18 @@ class y {
19
19
  }
20
20
  }
21
21
  ["Trace", "Debug", "Info", "Warn", "Error", "Fatal", "Mark"].forEach((C) => {
22
- y.prototype[C.toLowerCase()] = () => {
23
- }, y.prototype[`is${C}Enabled`] = () => !1;
22
+ R.prototype[C.toLowerCase()] = () => {
23
+ }, R.prototype[`is${C}Enabled`] = () => !1;
24
24
  });
25
- const F = () => {
25
+ const k = () => {
26
26
  try {
27
27
  return require("log4js");
28
28
  } catch {
29
29
  return null;
30
30
  }
31
- }, x = F(), k = x ? x.getLogger : () => new y();
31
+ }, x = k(), F = x ? x.getLogger : () => new R();
32
32
  var B = {
33
- getLogger: k
33
+ getLogger: F
34
34
  };
35
35
  const O = /* @__PURE__ */ E(B);
36
36
  class l {
@@ -40,7 +40,7 @@ class l {
40
40
  * @param lat
41
41
  */
42
42
  static guessTimeZoneOffset(t, e) {
43
- const n = A(e, t), s = R().tz(n).utcOffset();
43
+ const i = A(e, t), s = y().tz(i).utcOffset();
44
44
  return this.roundPrecision(s / 60, 1);
45
45
  }
46
46
  /**
@@ -49,21 +49,21 @@ class l {
49
49
  * @return timezone => +08:30
50
50
  */
51
51
  static prettyTimeZoneOffset(t) {
52
- let e = Math.floor(Math.abs(t)), n = Math.round((Math.abs(t) - e) * 60);
53
- return n = n > 9 ? n : `0${n}`, e = e > 9 ? e : `0${e}`, t > 0 ? `+${e}:${n}` : `-${e}:${n}`;
52
+ let e = Math.floor(Math.abs(t)), i = Math.round((Math.abs(t) - e) * 60);
53
+ return i = i > 9 ? i : `0${i}`, e = e > 9 ? e : `0${e}`, t > 0 ? `+${e}:${i}` : `-${e}:${i}`;
54
54
  }
55
- static lng2pretty(t, e = 6, n = "H°M′") {
55
+ static lng2pretty(t, e = 6, i = "H°M′") {
56
56
  t = l.convertToStdLng(t, e);
57
57
  let s = "E";
58
- t < 0 && (s = "W"), t = Math.abs(t), n = n.toUpperCase();
59
- let o = t * 3600, i, r, c, a, d, u;
60
- i = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - i, r = l.padNumber(i, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = l.roundPrecision(c, e).toString().padStart(2, "0") : a = l.padNumber(c, 2, 2), o = o - c * 60), d = o / 3600, n.indexOf("M") !== -1 ? u = l.roundPrecision(d, e).toString().padStart(3, "0") : u = l.padNumber(d, 3, 2);
61
- const f = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
58
+ t < 0 && (s = "W"), t = Math.abs(t), i = i.toUpperCase();
59
+ let o = t * 3600, n, r, c, a, d, u;
60
+ n = o % 3600 % 60, i.indexOf("S") !== -1 && (o = o - n, r = l.padNumber(n, 2, 2)), c = o / 60 % 60, i.indexOf("M") !== -1 && (i.indexOf("S") !== -1 ? a = l.roundPrecision(c, e).toString().padStart(2, "0") : a = l.padNumber(c, 2, 2), o = o - c * 60), d = o / 3600, i.indexOf("M") !== -1 ? u = l.roundPrecision(d, e).toString().padStart(3, "0") : u = l.padNumber(d, 3, 2);
61
+ const f = `${i.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
62
62
  return {
63
63
  direction: s,
64
64
  degree: l.roundPrecision(d, e),
65
65
  minute: l.roundPrecision(c, e),
66
- second: l.roundPrecision(i, e),
66
+ second: l.roundPrecision(n, e),
67
67
  pretty: f
68
68
  };
69
69
  }
@@ -73,57 +73,57 @@ class l {
73
73
  * @param precision 精确度
74
74
  * @param format 格式化
75
75
  */
76
- static lat2pretty(t, e = 6, n = "H°M′") {
76
+ static lat2pretty(t, e = 6, i = "H°M′") {
77
77
  t = t % 180;
78
78
  let s = "N";
79
- t < 0 && (s = "S"), t = Math.abs(t), n = n.toUpperCase();
80
- let o = t * 3600, i, r, c, a, d, u;
81
- i = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - i, r = l.padNumber(i, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = l.roundPrecision(c, e).toString().padStart(2, "0") : a = l.padNumber(c, 2, 2), o = o - c * 60), d = o / 3600, n.indexOf("M") !== -1 ? u = l.roundPrecision(d, e).toString().padStart(2, "0") : u = l.padNumber(d, 2, 2);
82
- const f = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
79
+ t < 0 && (s = "S"), t = Math.abs(t), i = i.toUpperCase();
80
+ let o = t * 3600, n, r, c, a, d, u;
81
+ n = o % 3600 % 60, i.indexOf("S") !== -1 && (o = o - n, r = l.padNumber(n, 2, 2)), c = o / 60 % 60, i.indexOf("M") !== -1 && (i.indexOf("S") !== -1 ? a = l.roundPrecision(c, e).toString().padStart(2, "0") : a = l.padNumber(c, 2, 2), o = o - c * 60), d = o / 3600, i.indexOf("M") !== -1 ? u = l.roundPrecision(d, e).toString().padStart(2, "0") : u = l.padNumber(d, 2, 2);
82
+ const f = `${i.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
83
83
  return {
84
84
  direction: s,
85
85
  degree: l.roundPrecision(d, e),
86
86
  minute: l.roundPrecision(c, e),
87
- second: l.roundPrecision(i, e),
87
+ second: l.roundPrecision(n, e),
88
88
  pretty: f
89
89
  };
90
90
  }
91
91
  static str2Lng(t, e = 6) {
92
- let n;
92
+ let i;
93
93
  if (isNaN(t)) {
94
94
  t = l.strReplace(t, "LNG");
95
95
  const s = t[t.length - 1].toUpperCase();
96
96
  t = t.substring(0, t.length - 1).trim();
97
97
  const o = t.split(" ").filter((c) => c !== "").map((c) => Number(c));
98
- let [i, r] = o;
99
- if (r = r > 60 ? r / Math.pow(10, String(r).length - 2) : r, i > 360 && !r) {
100
- const c = this.roundPrecision(i / 100, 0);
101
- r = i - c * 100, i = c;
98
+ let [n, r] = o;
99
+ if (r = r > 60 ? r / Math.pow(10, String(r).length - 2) : r, n > 360 && !r) {
100
+ const c = this.roundPrecision(n / 100, 0);
101
+ r = n - c * 100, n = c;
102
102
  }
103
- n = i + (r ?? 0) / 60, s === "W" && (n = n * -1);
103
+ i = n + (r ?? 0) / 60, s === "W" && (i = i * -1);
104
104
  } else
105
- n = Number(t);
106
- return l.convertToStdLng(n, e);
105
+ i = Number(t);
106
+ return l.convertToStdLng(i, e);
107
107
  }
108
108
  static str2Lat(t, e = 6) {
109
- let n;
109
+ let i;
110
110
  if (isNaN(t)) {
111
111
  t = l.strReplace(t, "LAT");
112
112
  const s = t[t.length - 1].toUpperCase();
113
113
  t = t.substring(0, t.length - 1).trim();
114
114
  const o = t.split(" ").filter((c) => c !== "").map((c) => Number(c));
115
- let [i, r] = o;
116
- if (r = r > 60 ? r / Math.pow(10, String(r).length - 2) : r, i > 90 && !r) {
117
- const c = this.roundPrecision(i / 100, 0);
118
- r = i - c * 100, i = c;
115
+ let [n, r] = o;
116
+ if (r = r > 60 ? r / Math.pow(10, String(r).length - 2) : r, n > 90 && !r) {
117
+ const c = this.roundPrecision(n / 100, 0);
118
+ r = n - c * 100, n = c;
119
119
  }
120
- n = i + (r ?? 0) / 60, s === "S" && (n = n * -1);
120
+ i = n + (r ?? 0) / 60, s === "S" && (i = i * -1);
121
121
  } else
122
- n = Number(t);
123
- return l.roundPrecision(n, e);
122
+ i = Number(t);
123
+ return l.roundPrecision(i, e);
124
124
  }
125
- static str2LngOrLat(t, e = 6, n = "LAT") {
126
- t = l.strReplace(t, n);
125
+ static str2LngOrLat(t, e = 6, i = "LAT") {
126
+ t = l.strReplace(t, i);
127
127
  const s = t[t.length - 1].toUpperCase();
128
128
  return ["N", "S"].includes(s) ? {
129
129
  lat: l.str2Lat(t, e)
@@ -136,8 +136,8 @@ class l {
136
136
  }
137
137
  static roundPrecision(t, e = 4) {
138
138
  if (typeof t == "number") {
139
- const n = Number("1".padEnd(e + 1, "0"));
140
- return Math.round(t * n) / n;
139
+ const i = Number("1".padEnd(e + 1, "0"));
140
+ return Math.round(t * i) / i;
141
141
  }
142
142
  return t;
143
143
  }
@@ -161,8 +161,8 @@ class l {
161
161
  }
162
162
  static strReplace(t, e = "LAT") {
163
163
  t = t.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g, "$1 $2").replace(/-/g, " ").replace(/°/, " ").replace(/'/g, " ").replace(/′/g, " ").replace(/"/g, " ").replace(/∼/g, " ").replace(/°/g, " ").replace(/,/g, ".").replace(/^ /g, "").replace(/ $/g, "").trim();
164
- const n = t[t.length - 1].toUpperCase();
165
- if (!["N", "S", "E", "W"].includes(n)) {
164
+ const i = t[t.length - 1].toUpperCase();
165
+ if (!["N", "S", "E", "W"].includes(i)) {
166
166
  const s = t, o = Number(s.split(" ")[0]);
167
167
  if (isNaN(o))
168
168
  throw new Error(`invalid Lat/Lng: ${t}`);
@@ -177,8 +177,8 @@ class l {
177
177
  * @param intPrecision 整数位数
178
178
  * @param dcmPrecision 小数位数
179
179
  */
180
- static padNumber(t, e = 2, n = 2) {
181
- const s = Math.trunc(t).toString().padStart(e, "0"), o = Math.trunc(l.roundPrecision(t - Math.trunc(t), n) * Math.pow(10, n)).toString().padStart(n, "0");
180
+ static padNumber(t, e = 2, i = 2) {
181
+ const s = Math.trunc(t).toString().padStart(e, "0"), o = Math.trunc(l.roundPrecision(t - Math.trunc(t), i) * Math.pow(10, i)).toString().padStart(i, "0");
182
182
  return `${s}.${o}`;
183
183
  }
184
184
  }
@@ -191,13 +191,13 @@ class b {
191
191
  * @param precision
192
192
  * @returns {number} 单位度
193
193
  */
194
- static calculateBearing(t, e, n = !0, s = 4) {
194
+ static calculateBearing(t, e, i = !0, s = 4) {
195
195
  const o = g.points([
196
196
  [t.lng, t.lat],
197
197
  [e.lng, e.lat]
198
198
  ]);
199
- let i;
200
- return n ? i = g.rhumbBearing(o.features[0], o.features[1]) : i = g.bearing(o.features[0], o.features[1]), i < 0 && (i += 360), l.roundPrecision(i, s);
199
+ let n;
200
+ return i ? n = g.rhumbBearing(o.features[0], o.features[1]) : n = g.bearing(o.features[0], o.features[1]), n < 0 && (n += 360), l.roundPrecision(n, s);
201
201
  }
202
202
  /**
203
203
  * 计算两点间距离
@@ -208,14 +208,14 @@ class b {
208
208
  * @param units 单位,默认 nm(海里)
209
209
  * @returns {number}
210
210
  */
211
- static calculateDistance(t, e, n = !0, s = 4, o = "nauticalmiles") {
211
+ static calculateDistance(t, e, i = !0, s = 4, o = "nauticalmiles") {
212
212
  t = { ...t }, e = { ...e }, t.lng = l.convertToStdLng(t.lng, s), e.lng = l.convertToStdLng(e.lng, s);
213
- const i = g.points([
213
+ const n = g.points([
214
214
  [t.lng, t.lat],
215
215
  [e.lng, e.lat]
216
216
  ]);
217
217
  let r;
218
- return n ? r = g.rhumbDistance(i.features[0], i.features[1], { units: o }) : r = g.distance(i.features[0], i.features[1], { units: o }), l.roundPrecision(r, s);
218
+ return i ? r = g.rhumbDistance(n.features[0], n.features[1], { units: o }) : r = g.distance(n.features[0], n.features[1], { units: o }), l.roundPrecision(r, s);
219
219
  }
220
220
  /**
221
221
  * 计算航线距离
@@ -223,14 +223,14 @@ class b {
223
223
  * @param precision
224
224
  * @param units
225
225
  */
226
- static calculateRouteDistance(t, e = 4, n = "nauticalmiles") {
226
+ static calculateRouteDistance(t, e = 4, i = "nauticalmiles") {
227
227
  let s = 0, o;
228
- for (const i of t)
229
- for (let r = 0; r < i.length - 1; r++) {
230
- const c = { lng: i[r][0], lat: i[r][1] };
231
- r === 0 && o && (s += this.calculateDistance(o, c, !0, e, n));
232
- const a = { lng: i[r + 1][0], lat: i[r + 1][1] };
233
- s += this.calculateDistance(c, a, !0, e, n), o = a;
228
+ for (const n of t)
229
+ for (let r = 0; r < n.length - 1; r++) {
230
+ const c = { lng: n[r][0], lat: n[r][1] };
231
+ r === 0 && o && (s += this.calculateDistance(o, c, !0, e, i));
232
+ const a = { lng: n[r + 1][0], lat: n[r + 1][1] };
233
+ s += this.calculateDistance(c, a, !0, e, i), o = a;
234
234
  }
235
235
  return l.roundPrecision(s, e);
236
236
  }
@@ -242,10 +242,10 @@ class b {
242
242
  * @param units 单位,默认 nm(海里)
243
243
  * @param rhumb
244
244
  */
245
- static calculateCoordinate(t, e, n, s = "nauticalmiles", o = !0) {
246
- const i = g.point([t.lng, t.lat]);
245
+ static calculateCoordinate(t, e, i, s = "nauticalmiles", o = !0) {
246
+ const n = g.point([t.lng, t.lat]);
247
247
  let r;
248
- o ? r = g.rhumbDestination(i, n, e, { units: s }) : r = g.destination(i, n, e, { units: s });
248
+ o ? r = g.rhumbDestination(n, i, e, { units: s }) : r = g.destination(n, i, e, { units: s });
249
249
  const c = r.geometry.coordinates;
250
250
  return { lng: l.convertToStdLng(c[0], 8), lat: l.roundPrecision(c[1], 8) };
251
251
  }
@@ -258,12 +258,12 @@ class b {
258
258
  * @param includeTail true 包含终点 to
259
259
  * @param units 单位,默认 nm(海里)
260
260
  */
261
- static interpolateCoordinates(t, e, n, s = !0, o = !0, i = "nauticalmiles") {
262
- const r = [], c = this.calculateBearing(t, e, !1), a = this.calculateDistance(t, e, !1, 8, i);
261
+ static interpolateCoordinates(t, e, i, s = !0, o = !0, n = "nauticalmiles") {
262
+ const r = [], c = this.calculateBearing(t, e, !1), a = this.calculateDistance(t, e, !1, 8, n);
263
263
  s && r.push({ lng: t.lng, lat: t.lat });
264
264
  let d = 0;
265
265
  for (; d < a; )
266
- d += n, d < a && r.push(this.calculateCoordinate(t, c, d, i, !1));
266
+ d += i, d < a && r.push(this.calculateCoordinate(t, c, d, n, !1));
267
267
  return o && r.push({ lng: e.lng, lat: e.lat }), r;
268
268
  }
269
269
  /**
@@ -281,16 +281,16 @@ class b {
281
281
  if ((t == null ? void 0 : t.length) < 2)
282
282
  return [];
283
283
  t = this.deduplicateCoordinates(t);
284
- let n = [];
284
+ let i = [];
285
285
  const s = [];
286
- let o, i;
286
+ let o, n;
287
287
  for (let r = 0; r < t.length - 1; r++) {
288
- o = l.convertToStdLng(t[r].lng, 8), i = l.convertToStdLng(t[r + 1].lng, 8), t[r].lat = l.roundPrecision(t[r].lat, 8), t[r + 1].lat = l.roundPrecision(t[r + 1].lat, 8), n.push([o, t[r].lat]);
289
- const c = o - i;
288
+ o = l.convertToStdLng(t[r].lng, 8), n = l.convertToStdLng(t[r + 1].lng, 8), t[r].lat = l.roundPrecision(t[r].lat, 8), t[r + 1].lat = l.roundPrecision(t[r + 1].lat, 8), i.push([o, t[r].lat]);
289
+ const c = o - n;
290
290
  if (Math.abs(c) > 180) {
291
291
  const a = l.convertToMonotonicLng2([
292
292
  [o, t[r].lat],
293
- [i, t[r + 1].lat]
293
+ [n, t[r + 1].lat]
294
294
  ]);
295
295
  let d, u;
296
296
  e ? (d = g.lineString(a), u = g.lineString([
@@ -300,15 +300,15 @@ class b {
300
300
  const f = g.lineIntersect(d, u);
301
301
  let h;
302
302
  if (f.features.length) {
303
- const P = g.getCoord(f.features[0]);
304
- h = l.roundPrecision(P[1], 8);
303
+ const T = g.getCoord(f.features[0]);
304
+ h = l.roundPrecision(T[1], 8);
305
305
  } else
306
306
  h = t[r].lat;
307
- c > 0 ? (n.push([180 - 1e-6, h]), s.push([...n]), n = [], n.push([-(180 - 1e-6), h])) : (n.push([-(180 - 1e-6), h]), s.push([...n]), n = [], n.push([180 - 1e-6, h]));
307
+ c > 0 ? (i.push([180 - 1e-6, h]), s.push([...i]), i = [], i.push([-(180 - 1e-6), h])) : (i.push([-(180 - 1e-6), h]), s.push([...i]), i = [], i.push([180 - 1e-6, h]));
308
308
  }
309
- r === t.length - 2 && n.push([i, t[r + 1].lat]);
309
+ r === t.length - 2 && i.push([n, t[r + 1].lat]);
310
310
  }
311
- return s.push(n), s;
311
+ return s.push(i), s;
312
312
  }
313
313
  /**
314
314
  * 去除重复坐标
@@ -316,8 +316,8 @@ class b {
316
316
  */
317
317
  static deduplicateRoute(t) {
318
318
  const e = [];
319
- for (const n of t) {
320
- const s = n.reduce((o, i) => (o.findIndex((r) => r[0] === i[0] && r[1] === i[1]) === -1 && o.push(i), o), []);
319
+ for (const i of t) {
320
+ const s = i.reduce((o, n) => (o.findIndex((r) => r[0] === n[0] && r[1] === n[1]) === -1 && o.push(n), o), []);
321
321
  e.push(s);
322
322
  }
323
323
  return e;
@@ -327,7 +327,7 @@ class b {
327
327
  * @param coordinates
328
328
  */
329
329
  static deduplicateCoordinates(t) {
330
- return t.reduce((e, n) => (e.findIndex((s) => s.lat === n.lat && s.lng === n.lng) === -1 && e.push(n), e), []);
330
+ return t.reduce((e, i) => (e.findIndex((s) => s.lat === i.lat && s.lng === i.lng) === -1 && e.push(i), e), []);
331
331
  }
332
332
  /**
333
333
  * 移出坐标
@@ -336,9 +336,9 @@ class b {
336
336
  */
337
337
  static removeCoordinateFromRoute(t, e) {
338
338
  t.lng = l.convertToStdLng(t.lng, 8);
339
- for (const n of e)
340
- for (let s = n.length - 1; s >= 0; s--)
341
- l.roundPrecision(n[s][0], 8) === t.lng && l.roundPrecision(n[s][1], 8) === l.roundPrecision(t.lat, 8) && n.splice(s, 1);
339
+ for (const i of e)
340
+ for (let s = i.length - 1; s >= 0; s--)
341
+ l.roundPrecision(i[s][0], 8) === t.lng && l.roundPrecision(i[s][1], 8) === l.roundPrecision(t.lat, 8) && i.splice(s, 1);
342
342
  return e;
343
343
  }
344
344
  /**
@@ -348,8 +348,8 @@ class b {
348
348
  */
349
349
  static removeCoordinateFromWaypoints(t, e) {
350
350
  t.lng = l.convertToStdLng(t.lng, 8);
351
- for (let n = e.length - 1; n >= 0; n--)
352
- l.roundPrecision(e[n].lng, 8) === t.lng && l.roundPrecision(e[n].lat, 8) === l.roundPrecision(t.lat, 8) && e.splice(n, 1);
351
+ for (let i = e.length - 1; i >= 0; i--)
352
+ l.roundPrecision(e[i].lng, 8) === t.lng && l.roundPrecision(e[i].lat, 8) === l.roundPrecision(t.lat, 8) && e.splice(i, 1);
353
353
  return e;
354
354
  }
355
355
  /**
@@ -365,13 +365,13 @@ class b {
365
365
  */
366
366
  static mergeCoordinateToRoute(t, e) {
367
367
  t.lng = l.convertToStdLng(t.lng, 8);
368
- let n = Number.MAX_VALUE, s = 0, o = 0, i, r;
368
+ let i = Number.MAX_VALUE, s = 0, o = 0, n, r;
369
369
  return e.forEach((c, a) => {
370
370
  for (let d = 0; d < c.length - 1; d++) {
371
371
  const u = { lng: c[d][0], lat: c[d][1] }, f = { lng: c[d + 1][0], lat: c[d + 1][1] }, h = this.calculatePointToLineDistance(t, u, f);
372
- n > h && (n = h, o = d, s = a, i = this.calculateDistance(u, t), r = this.calculateDistance(f, t));
372
+ i > h && (i = h, o = d, s = a, n = this.calculateDistance(u, t), r = this.calculateDistance(f, t));
373
373
  }
374
- }), i !== 0 && r !== 0 ? e[s].splice(o + 1, 0, [t.lng, t.lat]) : i === 0 ? e[s].splice(o, 1, [t.lng, t.lat]) : r === 0 && e[s].splice(o + 1, 1, [t.lng, t.lat]), e;
374
+ }), n !== 0 && r !== 0 ? e[s].splice(o + 1, 0, [t.lng, t.lat]) : n === 0 ? e[s].splice(o, 1, [t.lng, t.lat]) : r === 0 && e[s].splice(o + 1, 1, [t.lng, t.lat]), e;
375
375
  }
376
376
  /**
377
377
  * 向Route尾加1个坐标
@@ -380,8 +380,8 @@ class b {
380
380
  */
381
381
  static appendCoordinateToRoute(t, e) {
382
382
  t.lng = l.convertToStdLng(t.lng, 8);
383
- const n = b.convertRouteToCoordinates(e);
384
- return n.push(t), b.divideAccordingToLng(n);
383
+ const i = b.convertRouteToCoordinates(e);
384
+ return i.push(t), b.divideAccordingToLng(i);
385
385
  }
386
386
  /**
387
387
  * 向route头加1个坐标
@@ -389,8 +389,8 @@ class b {
389
389
  * @param route
390
390
  */
391
391
  static unshiftCoordinateToRoute(t, e) {
392
- const n = b.convertRouteToCoordinates(e);
393
- return n.unshift(t), b.divideAccordingToLng(n);
392
+ const i = b.convertRouteToCoordinates(e);
393
+ return i.unshift(t), b.divideAccordingToLng(i);
394
394
  }
395
395
  /**
396
396
  * 合并多个waypoints进航线
@@ -398,8 +398,8 @@ class b {
398
398
  * @param route 航线 [[[lng, lat],[lng, lat]]]
399
399
  */
400
400
  static mergeWaypointsToRoute(t, e) {
401
- for (const n of t)
402
- e = this.mergeCoordinateToRoute(n, e);
401
+ for (const i of t)
402
+ e = this.mergeCoordinateToRoute(i, e);
403
403
  return e;
404
404
  }
405
405
  /**
@@ -409,15 +409,15 @@ class b {
409
409
  * @param route [[[lng, lat]]]
410
410
  * @return [[[lng, lat]]]
411
411
  */
412
- static calculateRangeRoute(t, e, n) {
413
- n = this.mergeWaypointsToRoute([t, e], n);
412
+ static calculateRangeRoute(t, e, i) {
413
+ i = this.mergeWaypointsToRoute([t, e], i);
414
414
  const s = [];
415
415
  let o = 0;
416
- return n.forEach((i) => {
416
+ return i.forEach((n) => {
417
417
  if (o === 2)
418
418
  return;
419
419
  const r = [];
420
- for (const c of i) {
420
+ for (const c of n) {
421
421
  if (l.roundPrecision(e.lng, 8) === l.roundPrecision(c[0], 8) && l.roundPrecision(e.lat, 8) === l.roundPrecision(c[1], 8)) {
422
422
  r.push(c), o === 0 && r.push([t.lng, t.lat]), o = 2;
423
423
  break;
@@ -435,13 +435,13 @@ class b {
435
435
  * @param waypoints
436
436
  * @return [{lng, lat}]
437
437
  */
438
- static calculateRangeWaypoints(t, e, n, s = []) {
439
- const o = this.convertRouteToCoordinates(n, 0), i = this.mergeCoordinatesToWaypoints([t, e, ...s], o), r = i.findIndex(
438
+ static calculateRangeWaypoints(t, e, i, s = []) {
439
+ const o = this.convertRouteToCoordinates(i, 0), n = this.mergeCoordinatesToWaypoints([t, e, ...s], o), r = n.findIndex(
440
440
  (d) => l.roundPrecision(t.lng, 8) === l.roundPrecision(d.lng, 8) && l.roundPrecision(t.lat, 8) === l.roundPrecision(d.lat, 8)
441
- ), c = i.findIndex(
441
+ ), c = n.findIndex(
442
442
  (d) => l.roundPrecision(e.lng, 8) === l.roundPrecision(d.lng, 8) && l.roundPrecision(e.lat, 8) === l.roundPrecision(d.lat, 8)
443
443
  );
444
- return i.filter((d, u) => u >= r && u <= c);
444
+ return n.filter((d, u) => u >= r && u <= c);
445
445
  }
446
446
  /**
447
447
  * 计算坐标到航路上的最短距离
@@ -449,13 +449,13 @@ class b {
449
449
  * @param route
450
450
  */
451
451
  static calculateMinDistanceToRoute(t, e) {
452
- let n = Number.MAX_VALUE, s = 0, o = 0;
453
- return e.forEach((i, r) => {
454
- for (let c = 0; c < i.length - 1; c++) {
455
- const a = { lng: i[c][0], lat: i[c][1] }, d = { lng: i[c + 1][0], lat: i[c + 1][1] }, u = this.calculatePointToLineDistance(t, a, d);
456
- n > u && (n = u, s = c, o = r);
452
+ let i = Number.MAX_VALUE, s = 0, o = 0;
453
+ return e.forEach((n, r) => {
454
+ for (let c = 0; c < n.length - 1; c++) {
455
+ const a = { lng: n[c][0], lat: n[c][1] }, d = { lng: n[c + 1][0], lat: n[c + 1][1] }, u = this.calculatePointToLineDistance(t, a, d);
456
+ i > u && (i = u, s = c, o = r);
457
457
  }
458
- }), { minDist: n, segIndex: o, minIndex: s };
458
+ }), { minDist: i, segIndex: o, minIndex: s };
459
459
  }
460
460
  /**
461
461
  * 计算子航线
@@ -464,11 +464,11 @@ class b {
464
464
  * @return [[[lng, lat]]]
465
465
  */
466
466
  static calculateSubRoute(t, e) {
467
- const n = b.convertRouteToCoordinates(e);
468
- b.mergeCoordinateToWaypoints(t, n, !0), e = b.divideAccordingToLng(n);
467
+ const i = b.convertRouteToCoordinates(e);
468
+ b.mergeCoordinateToWaypoints(t, i, !0), e = b.divideAccordingToLng(i);
469
469
  const { segIndex: s, minIndex: o } = this.calculateMinDistanceToRoute({ ...t }, e);
470
470
  t.lng = l.convertToStdLng(t.lng);
471
- const i = [];
471
+ const n = [];
472
472
  let r = !0;
473
473
  for (let c = s; c < e.length; c++)
474
474
  if (r) {
@@ -476,10 +476,10 @@ class b {
476
476
  a.push([t.lng, t.lat]);
477
477
  for (let d = o + 1; d < e[c].length; d++)
478
478
  t.lng === e[c][d][0] && t.lat === e[c][d][1] || a.push(e[c][d]);
479
- i.push(a), r = !1;
479
+ n.push(a), r = !1;
480
480
  } else
481
- i.push([...e[c]]);
482
- return i;
481
+ n.push([...e[c]]);
482
+ return n;
483
483
  }
484
484
  /**
485
485
  * 计算子途经点
@@ -488,20 +488,20 @@ class b {
488
488
  * @return [{lng, lat}]
489
489
  */
490
490
  static calculateSubWaypoints(t, e) {
491
- let n = Number.MAX_VALUE, s = 0;
492
- for (let i = 0; i < e.length - 1; i++) {
493
- const r = e[i], c = e[i + 1];
491
+ let i = Number.MAX_VALUE, s = 0;
492
+ for (let n = 0; n < e.length - 1; n++) {
493
+ const r = e[n], c = e[n + 1];
494
494
  if (this.calculateDistance(t, r) === 0)
495
495
  return e;
496
496
  if (this.calculateDistance(t, c) === 0)
497
497
  return e.filter((d, u) => u > 0);
498
498
  const a = this.calculatePointToLineDistance(t, r, c);
499
- n > a && (n = a, s = i);
499
+ i > a && (i = a, s = n);
500
500
  }
501
501
  t.lng = l.convertToStdLng(t.lng);
502
502
  const o = [t];
503
- for (let i = s + 1; i < e.length; i++)
504
- o.push(e[i]);
503
+ for (let n = s + 1; n < e.length; n++)
504
+ o.push(e[n]);
505
505
  return o;
506
506
  }
507
507
  /**
@@ -511,14 +511,14 @@ class b {
511
511
  * @param to { lng, lat }
512
512
  * @param options
513
513
  */
514
- static calculatePointToLineDistance(t, e, n, s = { units: "nauticalmiles", method: "geodesic" }) {
515
- t.lng = l.convertToStdLng(t.lng, 8), e = { ...e }, n = { ...n }, e.lng = l.convertToStdLng(e.lng, 8), n.lng = l.convertToStdLng(n.lng, 8);
516
- const o = l.convertToMonotonicLng([e, n]);
517
- e = o[0], n = o[1];
518
- const i = g.lineString([
514
+ static calculatePointToLineDistance(t, e, i, s = { units: "nauticalmiles", method: "geodesic" }) {
515
+ t.lng = l.convertToStdLng(t.lng, 8), e = { ...e }, i = { ...i }, e.lng = l.convertToStdLng(e.lng, 8), i.lng = l.convertToStdLng(i.lng, 8);
516
+ const o = l.convertToMonotonicLng([e, i]);
517
+ e = o[0], i = o[1];
518
+ const n = g.lineString([
519
519
  [e.lng, e.lat],
520
- [n.lng, n.lat]
521
- ]), r = g.pointToLineDistance(g.point([t.lng, t.lat]), i, s), c = g.pointToLineDistance(g.point([t.lng > 0 ? t.lng - 360 : t.lng + 360, t.lat]), i, s);
520
+ [i.lng, i.lat]
521
+ ]), r = g.pointToLineDistance(g.point([t.lng, t.lat]), n, s), c = g.pointToLineDistance(g.point([t.lng > 0 ? t.lng - 360 : t.lng + 360, t.lat]), n, s);
522
522
  return l.roundPrecision(Math.min(r, c), 6);
523
523
  }
524
524
  /**
@@ -528,9 +528,9 @@ class b {
528
528
  */
529
529
  static calculateWaypointsPropInRoute(t, e) {
530
530
  e = this.mergeWaypointsToRoute(t, e);
531
- for (let n = 0; n < t.length - 1; n++) {
532
- const s = t[n], o = t[n + 1], i = this.calculateRangeRoute(s, o, e);
533
- n === 0 && (s.distanceFromPrevious = 0, s.distanceFromStart = 0), o.distanceFromPrevious = this.calculateRouteDistance(i), o.distanceFromStart = l.roundPrecision((s.distanceFromStart || 0) + o.distanceFromPrevious);
531
+ for (let i = 0; i < t.length - 1; i++) {
532
+ const s = t[i], o = t[i + 1], n = this.calculateRangeRoute(s, o, e);
533
+ i === 0 && (s.distanceFromPrevious = 0, s.distanceFromStart = 0), o.distanceFromPrevious = this.calculateRouteDistance(n), o.distanceFromStart = l.roundPrecision((s.distanceFromStart || 0) + o.distanceFromPrevious);
534
534
  }
535
535
  return t;
536
536
  }
@@ -539,9 +539,9 @@ class b {
539
539
  * @param waypoints [{lng, lat}]
540
540
  * @param replace true replace the same waypoint with coordinate
541
541
  */
542
- static mergeCoordinatesToWaypoints(t, e, n = !0) {
542
+ static mergeCoordinatesToWaypoints(t, e, i = !0) {
543
543
  for (const s of t)
544
- this.mergeCoordinateToWaypoints(s, e, n);
544
+ this.mergeCoordinateToWaypoints(s, e, i);
545
545
  return e;
546
546
  }
547
547
  /**
@@ -556,14 +556,14 @@ class b {
556
556
  * @return
557
557
  * [{ lng: 160, lat: 30}, { lng: 170, lat: 40}, {lng: 179, lat: 50}, {lng: -170, lat: 40}, {lng: -160, lat: 30}]
558
558
  */
559
- static mergeCoordinateToWaypoints(t, e, n = !0) {
559
+ static mergeCoordinateToWaypoints(t, e, i = !0) {
560
560
  t.lng = l.convertToStdLng(t.lng, 8);
561
- let s = Number.MAX_VALUE, o = 0, i = 0, r = 0;
561
+ let s = Number.MAX_VALUE, o = 0, n = 0, r = 0;
562
562
  for (let c = 0; c < e.length - 1; c++) {
563
563
  const a = { lng: e[c].lng, lat: e[c].lat }, d = { lng: e[c + 1].lng, lat: e[c + 1].lat }, u = this.calculatePointToLineDistance(t, a, d);
564
- s >= u && (s = u, o = c, i = this.calculateDistance(a, t, !1, 6), r = this.calculateDistance(d, t, !1, 6));
564
+ s >= u && (s = u, o = c, n = this.calculateDistance(a, t, !1, 6), r = this.calculateDistance(d, t, !1, 6));
565
565
  }
566
- return i !== 0 && r !== 0 ? i < s || i === s && o === 0 ? e.unshift(t) : r < s || r === s && o === e.length - 2 ? e.push(t) : e.splice(o + 1, 0, t) : i === 0 ? n && e.splice(o, 1, t) : r === 0 && n && e.splice(o + 1, 1, t), e.map((c) => (c.lng = l.convertToStdLng(c.lng), c));
566
+ return n !== 0 && r !== 0 ? n < s || n === s && o === 0 ? e.unshift(t) : r < s || r === s && o === e.length - 2 ? e.push(t) : e.splice(o + 1, 0, t) : n === 0 ? i && e.splice(o, 1, t) : r === 0 && i && e.splice(o + 1, 1, t), e.map((c) => (c.lng = l.convertToStdLng(c.lng), c));
567
567
  }
568
568
  /**
569
569
  * 生成航线(基于途经点生成大圆/横向航线,并根据是否跨180度分组)
@@ -572,11 +572,11 @@ class b {
572
572
  */
573
573
  static generateRouteAccordingToWaypoints(t) {
574
574
  const e = [];
575
- for (let n = 1; n < t.length; n++) {
576
- const s = t[n - 1], o = t[n];
577
- if (n === 1 && e.push(s), o.gcToPrevious) {
578
- const i = this.interpolateCoordinates(s, o, 200, !1, !0, "nauticalmiles");
579
- e.push(...i);
575
+ for (let i = 1; i < t.length; i++) {
576
+ const s = t[i - 1], o = t[i];
577
+ if (i === 1 && e.push(s), o.gcToPrevious) {
578
+ const n = this.interpolateCoordinates(s, o, 200, !1, !0, "nauticalmiles");
579
+ e.push(...n);
580
580
  } else
581
581
  e.push(o);
582
582
  }
@@ -588,7 +588,7 @@ class b {
588
588
  * @param route [[[lng, lat]]]
589
589
  */
590
590
  static nearestCoordinateInRoute(t, e) {
591
- const n = g.point([t.lng, t.lat]), o = this.convertRouteToCoordinates(e).map((a) => [a.lng, a.lat]), i = g.lineString(o), r = g.nearestPointOnLine(i, n), c = g.getCoord(r);
591
+ const i = g.point([t.lng, t.lat]), o = this.convertRouteToCoordinates(e).map((a) => [a.lng, a.lat]), n = g.lineString(o), r = g.nearestPointOnLine(n, i), c = g.getCoord(r);
592
592
  return { lng: l.roundPrecision(c[0], 8), lat: l.roundPrecision(c[1], 8) };
593
593
  }
594
594
  /**
@@ -597,20 +597,20 @@ class b {
597
597
  * @param waypoints
598
598
  */
599
599
  static calculatePrevWaypoint(t, e) {
600
- let n = 0;
600
+ let i = 0;
601
601
  this.mergeCoordinateToWaypoints(t, e);
602
602
  for (let s = 0; s < e.length - 1; s++) {
603
- const o = e[s], i = e[s + 1];
603
+ const o = e[s], n = e[s + 1];
604
604
  if (this.calculateDistance(t, o) === 0) {
605
- n = s;
605
+ i = s;
606
606
  break;
607
607
  }
608
- if (this.calculateDistance(t, i) === 0) {
609
- n = s + 1;
608
+ if (this.calculateDistance(t, n) === 0) {
609
+ i = s + 1;
610
610
  break;
611
611
  }
612
612
  }
613
- return e[n === 0 ? 0 : n - 1];
613
+ return e[i === 0 ? 0 : i - 1];
614
614
  }
615
615
  /**
616
616
  * 计算下一个距离单位的坐标及其子航线
@@ -620,11 +620,11 @@ class b {
620
620
  * @param units
621
621
  * @return { coordinate: {lng, lat}, route: [[[lng, lat]]]}
622
622
  */
623
- static calculateNextCoordinateAlongRoute(t, e, n, s = "nauticalmiles") {
623
+ static calculateNextCoordinateAlongRoute(t, e, i, s = "nauticalmiles") {
624
624
  var f;
625
- const o = t.speed || 12, i = [];
625
+ const o = t.speed || 12, n = [];
626
626
  let r = [], c = !1, a = 0, d = 0, u;
627
- if (e && n.length ? (i.push(t), n.forEach((h, P) => {
627
+ if (e && i.length ? (n.push(t), i.forEach((h, T) => {
628
628
  if (c)
629
629
  r.push(h);
630
630
  else {
@@ -637,7 +637,7 @@ class b {
637
637
  S = { lng: h[M][0], lat: h[M][1] };
638
638
  const D = this.calculateDistance(t, S, !0, 8, s);
639
639
  if (a += D, a < e)
640
- d += D, i.push(S), t = S;
640
+ d += D, n.push(S), t = S;
641
641
  else {
642
642
  if (d = e, a === e)
643
643
  u = S, m.push([u.lng, u.lat]);
@@ -648,15 +648,15 @@ class b {
648
648
  c = !0;
649
649
  }
650
650
  }
651
- m.length && r.push(m), P === n.length - 1 && !u && (u = S);
651
+ m.length && r.push(m), T === i.length - 1 && !u && (u = S);
652
652
  }
653
- })) : (r = n, u = { ...t }), u)
654
- if (i.push(u), u.distanceFromPrevious = d, u.hourFromPrevious = Math.round(d / o * 1e4) / 1e4, ((f = r[0]) == null ? void 0 : f.length) > 1) {
653
+ })) : (r = i, u = { ...t }), u)
654
+ if (n.push(u), u.distanceFromPrevious = d, u.hourFromPrevious = Math.round(d / o * 1e4) / 1e4, ((f = r[0]) == null ? void 0 : f.length) > 1) {
655
655
  const h = { lng: r[0][1][0], lat: r[0][1][1] };
656
656
  u.bearing = this.calculateBearing(u, h);
657
657
  } else
658
658
  u.bearing = 0;
659
- return { coordinate: u, nextRoute: r, prevRoute: i };
659
+ return { coordinate: u, nextRoute: r, prevRoute: n };
660
660
  }
661
661
  /**
662
662
  * 返回最近点及其是否为垂足(最近点不是起点或终点)
@@ -664,12 +664,12 @@ class b {
664
664
  * @param from {lng, lat}
665
665
  * @param to {lng, lat}
666
666
  */
667
- static nearestCoordinateInLine(t, e, n) {
668
- const s = l.convertToStdLng(t.lng, 6), o = g.point([s, t.lat]), i = l.convertToStdLng(e.lng, 6), r = l.convertToStdLng(n.lng, 6), c = g.lineString([
669
- [i, e.lat],
670
- [r, n.lat]
667
+ static nearestCoordinateInLine(t, e, i) {
668
+ const s = l.convertToStdLng(t.lng, 6), o = g.point([s, t.lat]), n = l.convertToStdLng(e.lng, 6), r = l.convertToStdLng(i.lng, 6), c = g.lineString([
669
+ [n, e.lat],
670
+ [r, i.lat]
671
671
  ]), a = g.nearestPointOnLine(c, o), d = g.getCoord(a), u = l.roundPrecision(d[0], 6), f = l.roundPrecision(d[1], 6);
672
- return { lng: u, lat: f, inline: !(u === i && f === e.lat) && !(u === r && f === n.lat) };
672
+ return { lng: u, lat: f, inline: !(u === n && f === e.lat) && !(u === r && f === i.lat) };
673
673
  }
674
674
  /**
675
675
  * 将route转coordinate
@@ -677,22 +677,22 @@ class b {
677
677
  * @param distance 临近点过虑
678
678
  */
679
679
  static convertRouteToCoordinates(t, e = 0) {
680
- const n = [];
680
+ const i = [];
681
681
  let s, o;
682
- return t.forEach((i) => {
683
- i.forEach((r) => {
682
+ return t.forEach((n) => {
683
+ n.forEach((r) => {
684
684
  const c = { lng: l.roundPrecision(r[0], 8), lat: l.roundPrecision(r[1], 8) };
685
685
  if (!o)
686
- n.push(c), o = c;
686
+ i.push(c), o = c;
687
687
  else if (o.bearing === void 0)
688
688
  o.bearing = this.calculateBearing(o, c, !0);
689
689
  else {
690
690
  const a = this.calculateDistance(s, c, !0);
691
- a && a >= e && (s.bearing = this.calculateBearing(s, c, !0), n.push(s), o = s);
691
+ a && a >= e && (s.bearing = this.calculateBearing(s, c, !0), i.push(s), o = s);
692
692
  }
693
693
  s = c;
694
694
  });
695
- }), s && n.push(s), n;
695
+ }), s && i.push(s), i;
696
696
  }
697
697
  /**
698
698
  * 抽稀(基于转向点)
@@ -700,8 +700,8 @@ class b {
700
700
  * @param waypoints [{ lng, lat, gcToPrevious }]
701
701
  * @param distance
702
702
  */
703
- static simplifyRouteToCoordinates(t, e, n = 1) {
704
- let s = this.convertRouteToCoordinates(t, n);
703
+ static simplifyRouteToCoordinates(t, e, i = 1) {
704
+ let s = this.convertRouteToCoordinates(t, i);
705
705
  return s = this.simplifyGCCoordinates(s, e), s;
706
706
  }
707
707
  /**
@@ -714,17 +714,17 @@ class b {
714
714
  this.mergeCoordinateToWaypoints(s, t, !0);
715
715
  });
716
716
  for (let s = 1; s < e.length; s++) {
717
- const o = e[s - 1], i = e[s];
718
- if (i.gcToPrevious) {
719
- const r = t.findIndex((a) => a.lng === o.lng && a.lat === o.lat), c = t.findIndex((a) => a.lng === i.lng && a.lat === i.lat);
717
+ const o = e[s - 1], n = e[s];
718
+ if (n.gcToPrevious) {
719
+ const r = t.findIndex((a) => a.lng === o.lng && a.lat === o.lat), c = t.findIndex((a) => a.lng === n.lng && a.lat === n.lat);
720
720
  for (let a = c - 1; a > r; a--)
721
721
  t.splice(a, 1);
722
722
  }
723
723
  }
724
- let n = 0;
724
+ let i = 0;
725
725
  for (let s = 1; s < t.length; s++) {
726
- const o = t[s - 1], i = t[s];
727
- i.gcToPrevious ? (o.bearing = this.calculateBearing(o, i, !1), i.distanceFromPrevious = this.calculateDistance(o, i, !1)) : (o.bearing = this.calculateBearing(o, i, !0), i.distanceFromPrevious = this.calculateDistance(o, i, !0)), n = l.roundPrecision(n + i.distanceFromPrevious), i.distanceFromStart = n;
726
+ const o = t[s - 1], n = t[s];
727
+ n.gcToPrevious ? (o.bearing = this.calculateBearing(o, n, !1), n.distanceFromPrevious = this.calculateDistance(o, n, !1)) : (o.bearing = this.calculateBearing(o, n, !0), n.distanceFromPrevious = this.calculateDistance(o, n, !0)), i = l.roundPrecision(i + n.distanceFromPrevious), n.distanceFromStart = i;
728
728
  }
729
729
  return t.map((s) => (s.lng = l.convertToStdLng(s.lng), s));
730
730
  }
@@ -737,11 +737,11 @@ class b {
737
737
  for (const r of t)
738
738
  for (const c of r)
739
739
  e.push(c);
740
- const n = g.featureCollection([]), s = l.convertToMonotonicLng2(e);
740
+ const i = g.featureCollection([]), s = l.convertToMonotonicLng2(e);
741
741
  for (const r of s)
742
- n.features.push(g.point(r));
743
- const i = g.center(n).geometry.coordinates;
744
- return { lng: l.convertToStdLng(i[0], 8), lat: l.roundPrecision(i[1], 8) };
742
+ i.features.push(g.point(r));
743
+ const n = g.center(i).geometry.coordinates;
744
+ return { lng: l.convertToStdLng(n[0], 8), lat: l.roundPrecision(n[1], 8) };
745
745
  }
746
746
  /**
747
747
  * 计算中心点
@@ -758,9 +758,9 @@ class b {
758
758
  static calculateBBox(t) {
759
759
  const e = [];
760
760
  for (const o of t)
761
- for (const i of o)
762
- e.push(i);
763
- const n = l.convertToMonotonicLng2(e), s = g.lineString(n);
761
+ for (const n of o)
762
+ e.push(n);
763
+ const i = l.convertToMonotonicLng2(e), s = g.lineString(i);
764
764
  return g.bbox(s);
765
765
  }
766
766
  /**
@@ -777,14 +777,14 @@ class b {
777
777
  * @param distance 三点最小距离, 小于此距离时,B点将被忽略(三点太近)
778
778
  * @param angle 三点夹角, 大于此角度时,B点将被忽略(近似走RL)
779
779
  */
780
- static simplifyCoordinates(t, e = 10, n = 160) {
780
+ static simplifyCoordinates(t, e = 10, i = 160) {
781
781
  const s = [];
782
782
  for (let o = 1; o < t.length; o++) {
783
- const i = t[o - 1], r = t[o], c = t[o + 1];
783
+ const n = t[o - 1], r = t[o], c = t[o + 1];
784
784
  let a = !1, d = !1;
785
- if ((i.velocity || i.suspend || i.important || i.pilot || o === 1) && (a = !0, s.push(i)), r.gcToPrevious && (a || (a = !0, s.push(i)), d = !0, s.push(r), o++), c) {
786
- const u = b.calculateDistance(i, r, !0), f = b.calculateDistance(r, c, !0), h = b.calculateDistance(i, c, !0), P = (Math.pow(u, 2) + Math.pow(f, 2) - Math.pow(h, 2)) / (2 * u * f);
787
- Math.round(Math.acos(P) * 180 / Math.PI) < n && h > e && !d && (s.push(r), o++);
785
+ if ((n.velocity || n.suspend || n.important || n.pilot || o === 1) && (a = !0, s.push(n)), r.gcToPrevious && (a || (a = !0, s.push(n)), d = !0, s.push(r), o++), c) {
786
+ const u = b.calculateDistance(n, r, !0), f = b.calculateDistance(r, c, !0), h = b.calculateDistance(n, c, !0), T = (Math.pow(u, 2) + Math.pow(f, 2) - Math.pow(h, 2)) / (2 * u * f);
787
+ Math.round(Math.acos(T) * 180 / Math.PI) < i && h > e && !d && (s.push(r), o++);
788
788
  }
789
789
  if (o >= t.length - 1) {
790
790
  const u = t.at(-1);
@@ -793,10 +793,22 @@ class b {
793
793
  }
794
794
  return s;
795
795
  }
796
+ /**
797
+ * 在时间轨迹上寻找ts最近的点
798
+ * @param ts ts最近的点(向后取), 单位秒
799
+ * @param step 时间步长, 前后n小时
800
+ * @param waypoints 带时间的轨迹, 单位秒
801
+ */
802
+ static nearestTSPointInWaypoints(t, e, i) {
803
+ const s = y.unix(t), o = i.filter(
804
+ (n) => s.clone().subtract(e, "hour").unix() <= (n.positionTime || 0) && s.clone().add(e, "h").unix() >= (n.positionTime || 0)
805
+ );
806
+ return o.sort((n, r) => (n.positionTime || 0) - (r.positionTime || 0)), o.at(-1);
807
+ }
796
808
  }
797
- let T;
809
+ let P;
798
810
  try {
799
- T = O.getLogger("vessel");
811
+ P = O.getLogger("vessel");
800
812
  } catch {
801
813
  } finally {
802
814
  }
@@ -806,16 +818,17 @@ class q {
806
818
  * @param raw
807
819
  */
808
820
  static convert2Geojson(t) {
809
- var n;
821
+ var i;
810
822
  const e = g.featureCollection([]);
811
823
  for (const s of t) {
812
824
  if (s.forecasts) {
813
- const o = (n = s.history) == null ? void 0 : n[0];
814
- for (const i of s.forecasts) {
815
- const r = [], c = R(i.date).utc(), a = `${s.name}-${i.model}`;
825
+ const o = (i = s.history) == null ? void 0 : i[0];
826
+ o && o.wind && (o.wind.spd = o.spd, o.wind.kts = o.kts);
827
+ for (const n of s.forecasts) {
828
+ const r = [], c = y(n.date).utc(), a = `${s.name}-${n.model}`;
816
829
  if (o) {
817
- const d = R(o.updated).utc(), u = g.point([o.lng, o.lat], {
818
- model: i.model,
830
+ const d = y(o.updated).utc(), u = g.point([o.lng, o.lat], {
831
+ model: n.model,
819
832
  name: s.name,
820
833
  date: d.format(),
821
834
  hour: 0,
@@ -827,11 +840,11 @@ class q {
827
840
  });
828
841
  e.features.push(u), r.push(u.geometry.coordinates);
829
842
  }
830
- for (const d in i == null ? void 0 : i.hours) {
831
- const u = i.hours[d];
843
+ for (const d in n == null ? void 0 : n.hours) {
844
+ const u = n.hours[d];
832
845
  u.wind.spd = u.wind.spd || u.wind.speed;
833
846
  const f = c.clone().add(Number(d), "hour"), h = g.point([u.lng, u.lat], {
834
- model: i.model,
847
+ model: n.model,
835
848
  name: s.name,
836
849
  date: f.format(),
837
850
  hour: Number(d),
@@ -847,9 +860,9 @@ class q {
847
860
  }
848
861
  if ((r == null ? void 0 : r.length) > 1) {
849
862
  const d = g.lineString(l.convertToMonotonicLng2(r), {
850
- date: i.date,
863
+ date: n.date,
851
864
  id: s.id || s.name,
852
- model: i.model,
865
+ model: n.model,
853
866
  name: s.name,
854
867
  category: a,
855
868
  type: "forecast"
@@ -861,7 +874,7 @@ class q {
861
874
  if (s.history) {
862
875
  const o = [];
863
876
  for (const r of s.history) {
864
- const c = R(r.updated).utc(), a = g.point([r.lng, r.lat], {
877
+ const c = y(r.updated).utc(), a = g.point([r.lng, r.lat], {
865
878
  name: s.name,
866
879
  date: c.format(),
867
880
  format: c.format("MMM-DD/HHmm[Z]"),
@@ -876,17 +889,17 @@ class q {
876
889
  });
877
890
  e.features.push(a), o.push(a.geometry.coordinates);
878
891
  }
879
- const i = s.history[0];
892
+ const n = s.history[0];
880
893
  if (o.length === 1 && o.push(o[0]), o.length > 1) {
881
894
  const r = g.lineString(l.convertToMonotonicLng2(o), {
882
895
  name: s.name,
883
896
  type: "history",
884
- updated: i == null ? void 0 : i.updated,
885
- pressure: (i == null ? void 0 : i.pressure) > 1e4 ? l.roundPrecision((i == null ? void 0 : i.pressure) / 100, 0) : l.roundPrecision(i == null ? void 0 : i.pressure, 0),
886
- spd: (i == null ? void 0 : i.speed) || (i == null ? void 0 : i.spd),
887
- kts: i == null ? void 0 : i.kts,
888
- source: i == null ? void 0 : i.source,
889
- level: i == null ? void 0 : i.type
897
+ updated: n == null ? void 0 : n.updated,
898
+ pressure: (n == null ? void 0 : n.pressure) > 1e4 ? l.roundPrecision((n == null ? void 0 : n.pressure) / 100, 0) : l.roundPrecision(n == null ? void 0 : n.pressure, 0),
899
+ spd: (n == null ? void 0 : n.speed) || (n == null ? void 0 : n.spd),
900
+ kts: n == null ? void 0 : n.kts,
901
+ source: n == null ? void 0 : n.source,
902
+ level: n == null ? void 0 : n.type
890
903
  });
891
904
  e.features.push(r);
892
905
  }
@@ -900,15 +913,15 @@ class q {
900
913
  * @param step
901
914
  */
902
915
  static interpolate(t, e = 3) {
903
- var o, i, r, c;
904
- const n = (o = t == null ? void 0 : t.data) == null ? void 0 : o.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), s = [];
905
- for (const a of n) {
906
- const d = a.properties.name, u = a.properties.model, f = a.properties.showCircle, h = a.properties.disabled, P = R(a.properties.date).utc();
907
- let m = e * 60 - (P.get("hour") * 60 + P.get("minute")) % (e * 60);
908
- const S = (i = t == null ? void 0 : t.data) == null ? void 0 : i.features.filter(
916
+ var o, n, r, c;
917
+ const i = (o = t == null ? void 0 : t.data) == null ? void 0 : o.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), s = [];
918
+ for (const a of i) {
919
+ const d = a.properties.name, u = a.properties.model, f = a.properties.showCircle, h = a.properties.disabled, T = y(a.properties.date).utc();
920
+ let m = e * 60 - (T.get("hour") * 60 + T.get("minute")) % (e * 60);
921
+ const S = (n = t == null ? void 0 : t.data) == null ? void 0 : n.features.filter(
909
922
  (v) => v.geometry.type === "Point" && v.properties.type === "forecast" && v.properties.category === `${d}-${u}`
910
923
  );
911
- let M, D = P.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
924
+ let M, D = T.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
912
925
  for (; M = this.pickIndex(S, D), M <= S.length - 1; ) {
913
926
  if (M > 0) {
914
927
  const v = S[M], p = M === 0 ? void 0 : S[M - 1], N = (m / 60 - ((r = p == null ? void 0 : p.properties) == null ? void 0 : r.hour)) / (v.properties.hour - ((c = p == null ? void 0 : p.properties) == null ? void 0 : c.hour)), I = this.computeNumber(p == null ? void 0 : p.geometry.coordinates[0], v.geometry.coordinates[0], N), $ = this.computeNumber(p == null ? void 0 : p.geometry.coordinates[1], v.geometry.coordinates[1], N), W = g.point([I, $], {
@@ -928,7 +941,7 @@ class q {
928
941
  });
929
942
  s.push(W);
930
943
  }
931
- m += e * 60, D = P.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
944
+ m += e * 60, D = T.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
932
945
  }
933
946
  }
934
947
  return s;
@@ -940,8 +953,8 @@ class q {
940
953
  * @param options
941
954
  */
942
955
  static accelPassageAt(t, e) {
943
- const { t1: n, t2: s, hr: o, hours: i } = this.tropicalCenterTwin(t, 24, e);
944
- return { t1: n, t2: s, hr: o, hours: i };
956
+ const { t1: i, t2: s, hr: o, hours: n } = this.tropicalCenterTwin(t, 24, e);
957
+ return { t1: i, t2: s, hr: o, hours: n };
945
958
  }
946
959
  /**
947
960
  * 计算最佳绕航点
@@ -954,32 +967,32 @@ class q {
954
967
  * @param speed 前进速度
955
968
  * @param options
956
969
  */
957
- static diversionPassageAt(t, e, n, s = {}) {
958
- const { t1: o, t2: i, hr: r, hours: c } = this.tropicalCenterTwin(e, 24, s);
959
- if (o && i) {
970
+ static diversionPassageAt(t, e, i, s = {}) {
971
+ const { t1: o, t2: n, hr: r, hours: c } = this.tropicalCenterTwin(e, 24, s);
972
+ if (o && n) {
960
973
  if (!s.debug) {
961
- const P = b.calculateDistance(t, o), m = b.calculateDistance(t, i);
962
- if (P > 2 * n && m > 2 * n)
963
- return T == null || T.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, P, m, {
974
+ const T = b.calculateDistance(t, o), m = b.calculateDistance(t, n);
975
+ if (T > 2 * i && m > 2 * i)
976
+ return P == null || P.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, T, m, {
964
977
  from: t,
965
978
  t1: o,
966
- t2: i,
979
+ t2: n,
967
980
  hr: r
968
981
  }), {};
969
982
  }
970
- const a = b.calculateBearing(t, o), d = b.calculateBearing(o, i), u = Math.abs(a - d);
983
+ const a = b.calculateBearing(t, o), d = b.calculateBearing(o, n), u = Math.abs(a - d);
971
984
  let f = 0;
972
985
  u < 180 ? f = u + 90 : u >= 180 && (f = u - 90);
973
- const h = b.calculateCoordinate(o, f, n);
974
- return T == null || T.info("[%s] the right tangent position: %j", s.requestId, {
986
+ const h = b.calculateCoordinate(o, f, i);
987
+ return P == null || P.info("[%s] the right tangent position: %j", s.requestId, {
975
988
  from: t,
976
989
  t1: o,
977
- t2: i,
978
- radius: n,
990
+ t2: n,
991
+ radius: i,
979
992
  bearing1: a,
980
993
  bearing2: d,
981
994
  right: h
982
- }), { at: h, t1: o, t2: i, hr: Number(r), hours: c };
995
+ }), { at: h, t1: o, t2: n, hr: Number(r), hours: c };
983
996
  }
984
997
  return {};
985
998
  }
@@ -993,23 +1006,23 @@ class q {
993
1006
  * @param radius 与台风中心的距离
994
1007
  * @param options
995
1008
  */
996
- static driftPassageAt(t, e, n, s = {}) {
997
- const { t1: o, t2: i, hr: r, hours: c } = this.tropicalCenterTwin(e, 24, s);
998
- if (o && i) {
1009
+ static driftPassageAt(t, e, i, s = {}) {
1010
+ const { t1: o, t2: n, hr: r, hours: c } = this.tropicalCenterTwin(e, 24, s);
1011
+ if (o && n) {
999
1012
  if (!s.debug) {
1000
- const h = b.calculateDistance(t, o), P = b.calculateDistance(t, i);
1001
- if (h > 2 * n && P > 2 * n)
1002
- return T == null || T.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, h, P, {
1013
+ const h = b.calculateDistance(t, o), T = b.calculateDistance(t, n);
1014
+ if (h > 2 * i && T > 2 * i)
1015
+ return P == null || P.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, h, T, {
1003
1016
  from: t,
1004
1017
  t1: o,
1005
- t2: i,
1018
+ t2: n,
1006
1019
  hr: r
1007
1020
  }), {};
1008
1021
  }
1009
- const a = b.calculateBearing(t, o), d = b.calculateBearing(o, i), u = b.calculateDistance(t, o);
1010
- return { at: b.calculateCoordinate(o, a - d + 180, n < u ? n : u), t1: o, t2: i, hr: Number(r), hours: c };
1022
+ const a = b.calculateBearing(t, o), d = b.calculateBearing(o, n), u = b.calculateDistance(t, o);
1023
+ return { at: b.calculateCoordinate(o, a - d + 180, i < u ? i : u), t1: o, t2: n, hr: Number(r), hours: c };
1011
1024
  } else
1012
- return T == null || T.info("[%s] no need drift: %j", s.requestId, { from: t, t1: o, t2: i, hr: r }), {};
1025
+ return P == null || P.info("[%s] no need drift: %j", s.requestId, { from: t, t1: o, t2: n, hr: r }), {};
1013
1026
  }
1014
1027
  /**
1015
1028
  * 获取台风中心点对
@@ -1019,42 +1032,42 @@ class q {
1019
1032
  * @returns { t1: 当前台风中心点, t2: 未来hr小时台风中心点, hr: 未来台风中心点与当前台风中心点之间的时间差, hours: 未来24小时内所有台风中心点 }
1020
1033
  * @private
1021
1034
  */
1022
- static tropicalCenterTwin(t, e = 24, n = {}) {
1023
- var d, u, f, h, P;
1035
+ static tropicalCenterTwin(t, e = 24, i = {}) {
1036
+ var d, u, f, h, T;
1024
1037
  let s = {};
1025
1038
  (d = t.forecasts) == null || d.forEach((m) => {
1026
1039
  s = { ...m.hours, ...s };
1027
1040
  });
1028
1041
  const o = ((u = t == null ? void 0 : t.history) == null ? void 0 : u[0]) || (s == null ? void 0 : s[(f = Object.keys(s)) == null ? void 0 : f[0]]);
1029
- T == null || T.info("[%s] the first tropical center: %j", n.requestId, o);
1030
- let i = (h = Object.keys(s || {}).filter((m) => Number(m) <= (e < 0 ? 24 : e))) == null ? void 0 : h.at(-1);
1031
- i || (i = (P = Object.keys(s || {}).filter((m) => Number(m) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : P.at(-1));
1032
- const r = s == null ? void 0 : s[i || -1];
1033
- T == null || T.info("[%s] the second tropical center: %j in %d hrs", n.requestId, r, i);
1034
- const c = Object.keys(s || {}).filter((m) => Number(m) <= Number(i)), a = { 0: o };
1042
+ P == null || P.info("[%s] the first tropical center: %j", i.requestId, o);
1043
+ let n = (h = Object.keys(s || {}).filter((m) => Number(m) <= (e < 0 ? 24 : e))) == null ? void 0 : h.at(-1);
1044
+ n || (n = (T = Object.keys(s || {}).filter((m) => Number(m) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : T.at(-1));
1045
+ const r = s == null ? void 0 : s[n || -1];
1046
+ P == null || P.info("[%s] the second tropical center: %j in %d hrs", i.requestId, r, n);
1047
+ const c = Object.keys(s || {}).filter((m) => Number(m) <= Number(n)), a = { 0: o };
1035
1048
  for (const m of c)
1036
1049
  a[m] = s[m];
1037
- return { t1: o, t2: r, hr: Number(i), hours: a };
1050
+ return { t1: o, t2: r, hr: Number(n), hours: a };
1038
1051
  }
1039
1052
  static pickIndex(t, e) {
1040
- let n = 0;
1053
+ let i = 0;
1041
1054
  for (const s of t) {
1042
- if (R(s.properties.date).isAfter(e))
1043
- return n === 0 ? -1 : n;
1044
- n++;
1055
+ if (y(s.properties.date).isAfter(e))
1056
+ return i === 0 ? -1 : i;
1057
+ i++;
1045
1058
  }
1046
- return n;
1059
+ return i;
1047
1060
  }
1048
- static computeNumber(t, e, n) {
1061
+ static computeNumber(t, e, i) {
1049
1062
  if (t)
1050
1063
  if (e) {
1051
1064
  if (isNaN(t) && isNaN(e) && typeof t != "string" && typeof e != "string") {
1052
1065
  const s = {};
1053
1066
  for (const o in t)
1054
- s[o] = this.computeNumber(t[o], e[o], n);
1067
+ s[o] = this.computeNumber(t[o], e[o], i);
1055
1068
  return s;
1056
1069
  }
1057
- return Math.round((t + (e - t) * n) * 100) / 100;
1070
+ return Math.round((t + (e - t) * i) * 100) / 100;
1058
1071
  } else
1059
1072
  return t;
1060
1073
  else