@idm-plugin/geo 2.3.7 → 2.3.9

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,19 +1,19 @@
1
1
  import * as T from "@turf/turf";
2
- import x from "moment";
3
- import z from "@log4js-node/log4js-api";
2
+ import P from "moment";
3
+ import G from "@log4js-node/log4js-api";
4
4
  import "moment-timezone";
5
5
  import V from "tz-lookup";
6
6
  import J from "shpjs";
7
- class h {
7
+ class f {
8
8
  /**
9
9
  * 基于输入的经度,计算出时区
10
10
  * @param lng
11
11
  * @param lat
12
12
  */
13
13
  static guessTimeZoneOffset(t, e) {
14
- t = h.convertToStdLng(t);
15
- const n = V(e, t), s = x().tz(n).utcOffset();
16
- return h.roundPrecision(s / 60, 1);
14
+ t = f.convertToStdLng(t);
15
+ const n = V(e, t), s = P().tz(n).utcOffset();
16
+ return f.roundPrecision(s / 60, 1);
17
17
  }
18
18
  /**
19
19
  * 将时间offset转换为时区,例如:8.5 => +08:30
@@ -30,17 +30,17 @@ class h {
30
30
  * @param format
31
31
  */
32
32
  static lng2pretty(t, e = 6, n = "H°M′") {
33
- t = h.convertToStdLng(t, 6);
33
+ t = f.convertToStdLng(t, 6);
34
34
  let s = "E";
35
35
  t < 0 && (s = "W"), t = Math.abs(t), n = n.toUpperCase();
36
36
  let c = t * 3600, i, r, o, a, l, u;
37
- i = c % 3600 % 60, n.indexOf("S") !== -1 && (c = c - i, r = h.padNumber(i, 2, 2)), o = c / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = h.roundPrecision(o, e).toString().padStart(2, "0") : a = h.padNumber(o, 2, 3), c = c - o * 60), l = c / 3600, n.indexOf("M") !== -1 ? u = h.roundPrecision(l, e).toString().padStart(3, "0") : u = h.padNumber(l, 3, 6), Number(r) >= 60 && (a = Number(a) + 1, r = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
37
+ i = c % 3600 % 60, n.indexOf("S") !== -1 && (c = c - i, r = f.padNumber(i, 2, 2)), o = c / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = f.roundPrecision(o, e).toString().padStart(2, "0") : a = f.padNumber(o, 2, 3), c = c - o * 60), l = c / 3600, n.indexOf("M") !== -1 ? u = f.roundPrecision(l, e).toString().padStart(3, "0") : u = f.padNumber(l, 3, 6), Number(r) >= 60 && (a = Number(a) + 1, r = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
38
38
  const g = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
39
39
  return {
40
40
  direction: s,
41
- degree: h.roundPrecision(l, e),
42
- minute: h.roundPrecision(o, e),
43
- second: h.roundPrecision(i, e),
41
+ degree: f.roundPrecision(l, e),
42
+ minute: f.roundPrecision(o, e),
43
+ second: f.roundPrecision(i, e),
44
44
  pretty: g,
45
45
  S: r,
46
46
  M: a,
@@ -58,13 +58,13 @@ class h {
58
58
  let s = "N";
59
59
  t < 0 && (s = "S"), t = Math.abs(t), n = n.toUpperCase();
60
60
  let c = t * 3600, i, r, o, a, l, u;
61
- i = c % 3600 % 60, n.indexOf("S") !== -1 && (c = c - i, r = h.padNumber(i, 2, 2)), o = c / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = h.roundPrecision(o, e).toString().padStart(2, "0") : a = h.padNumber(o, 2, 3), c = c - o * 60), l = c / 3600, n.indexOf("M") !== -1 ? u = h.roundPrecision(l, e).toString().padStart(2, "0") : u = h.padNumber(l, 2, 6), Number(r) >= 60 && (a = Number(a) + 1, r = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
61
+ i = c % 3600 % 60, n.indexOf("S") !== -1 && (c = c - i, r = f.padNumber(i, 2, 2)), o = c / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = f.roundPrecision(o, e).toString().padStart(2, "0") : a = f.padNumber(o, 2, 3), c = c - o * 60), l = c / 3600, n.indexOf("M") !== -1 ? u = f.roundPrecision(l, e).toString().padStart(2, "0") : u = f.padNumber(l, 2, 6), Number(r) >= 60 && (a = Number(a) + 1, r = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
62
62
  const g = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
63
63
  return {
64
64
  direction: s,
65
- degree: h.roundPrecision(l, e),
66
- minute: h.roundPrecision(o, e),
67
- second: h.roundPrecision(i, e),
65
+ degree: f.roundPrecision(l, e),
66
+ minute: f.roundPrecision(o, e),
67
+ second: f.roundPrecision(i, e),
68
68
  pretty: g,
69
69
  S: r,
70
70
  M: a,
@@ -74,7 +74,7 @@ class h {
74
74
  static str2Lng(t, e = 6) {
75
75
  let n;
76
76
  if (isNaN(t)) {
77
- t = h.strReplace(t, "LNG");
77
+ t = f.strReplace(t, "LNG");
78
78
  const s = t[t.length - 1].toUpperCase();
79
79
  t = t.substring(0, t.length - 1).trim();
80
80
  const c = t.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
@@ -86,12 +86,12 @@ class h {
86
86
  n = i + r / 60 + o / 3600, s === "W" && (n = n * -1);
87
87
  } else
88
88
  n = Number(t);
89
- return h.convertToStdLng(n, e);
89
+ return f.convertToStdLng(n, e);
90
90
  }
91
91
  static str2Lat(t, e = 6) {
92
92
  let n;
93
93
  if (isNaN(t)) {
94
- t = h.strReplace(t, "LAT");
94
+ t = f.strReplace(t, "LAT");
95
95
  const s = t[t.length - 1].toUpperCase();
96
96
  t = t.substring(0, t.length - 1).trim();
97
97
  const c = t.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
@@ -105,19 +105,19 @@ class h {
105
105
  s === "S" && (n = n * -1);
106
106
  } else
107
107
  n = Number(t);
108
- return h.roundPrecision(n, e);
108
+ return f.roundPrecision(n, e);
109
109
  }
110
110
  static str2LngOrLat(t, e = 6, n = "LAT") {
111
- t = h.strReplace(t, n);
111
+ t = f.strReplace(t, n);
112
112
  const s = t[t.length - 1].toUpperCase();
113
113
  return ["N", "S"].includes(s) ? {
114
- lat: h.str2Lat(t, e)
114
+ lat: f.str2Lat(t, e)
115
115
  } : {
116
- lng: h.str2Lng(t, e)
116
+ lng: f.str2Lng(t, e)
117
117
  };
118
118
  }
119
119
  static convertToStdLng(t, e = 6) {
120
- return t > 180 ? (t = t % 360, t = t > 180 ? t - 360 : t) : t < -180 && (t = t % 360, t = t < -180 ? t + 360 : t), h.roundPrecision(t, e);
120
+ return t > 180 ? (t = t % 360, t = t > 180 ? t - 360 : t) : t < -180 && (t = t % 360, t = t < -180 ? t + 360 : t), f.roundPrecision(t, e);
121
121
  }
122
122
  static roundPrecision(t, e = 6) {
123
123
  const n = Number("1".padEnd(e + 1, "0"));
@@ -160,7 +160,7 @@ class h {
160
160
  * @param dcmPrecision 小数位数
161
161
  */
162
162
  static padNumber(t, e = 2, n = 2) {
163
- const s = h.roundPrecision(t - Math.trunc(t), n), c = s >= 1 ? Math.trunc(t + 1).toString().padStart(e, "0") : Math.trunc(t).toString().padStart(e, "0");
163
+ const s = f.roundPrecision(t - Math.trunc(t), n), c = s >= 1 ? Math.trunc(t + 1).toString().padStart(e, "0") : Math.trunc(t).toString().padStart(e, "0");
164
164
  return s >= 1 ? c : n > 0 ? `${c}.${Math.trunc(s * Math.pow(10, n)).toString().padStart(n, "0")}` : c;
165
165
  }
166
166
  }
@@ -202,7 +202,7 @@ class K {
202
202
  if (n && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(a.type))
203
203
  continue;
204
204
  const d = g.positionTime - u.positionTime;
205
- if (b.calculateDistance(g, u, !0, 4) / (d / 3600) < e)
205
+ if (v.calculateDistance(g, u, !0, 4) / (d / 3600) < e)
206
206
  i || (i = a), l === t.length - 1 && (r = g, o = l);
207
207
  else {
208
208
  i && (r = t[l - 1], o = l);
@@ -216,18 +216,18 @@ class K {
216
216
  lng: i.lng,
217
217
  sog: i.sog,
218
218
  positionTime: i.positionTime,
219
- utc: x.unix(i.positionTime).utc().format()
219
+ utc: P.unix(i.positionTime).utc().format()
220
220
  },
221
221
  end: {
222
222
  lat: r.lat,
223
223
  lng: r.lng,
224
224
  sog: r.sog,
225
225
  positionTime: r.positionTime,
226
- utc: x.unix(r.positionTime).utc().format()
226
+ utc: P.unix(r.positionTime).utc().format()
227
227
  },
228
228
  duration: r.positionTime - i.positionTime
229
- }, u = t.filter((d) => d.positionTime >= l.start.positionTime && d.positionTime <= l.end.positionTime), g = b.divideAccordingToLng(u);
230
- l.distance = b.calculateRouteDistance(g), l.hours = Math.round(l.duration / 3600 * 10) / 10, l.hours && (l.avgSog = Math.round(l.distance / l.hours * 10) / 10, c.push(l));
229
+ }, u = t.filter((d) => d.positionTime >= l.start.positionTime && d.positionTime <= l.end.positionTime), g = v.divideAccordingToLng(u);
230
+ l.distance = v.calculateRouteDistance(g), l.hours = Math.round(l.duration / 3600 * 10) / 10, l.hours && (l.avgSog = Math.round(l.distance / l.hours * 10) / 10, c.push(l));
231
231
  }
232
232
  i = void 0, r = void 0;
233
233
  }
@@ -241,12 +241,12 @@ class K {
241
241
  * @param etm
242
242
  */
243
243
  static inspectSummary(t, e, n) {
244
- const s = x(e), c = x(n), i = t.filter((l) => l.positionTime >= s.unix() && l.positionTime <= c.unix());
244
+ const s = P(e), c = P(n), i = t.filter((l) => l.positionTime >= s.unix() && l.positionTime <= c.unix());
245
245
  let r = 0, o = 0;
246
246
  if (i.length > 1)
247
247
  for (let l = 0; l < i.length - 1; l++) {
248
248
  const u = i[l], g = i[l + 1];
249
- r += b.calculateDistance(u, g, !0, 4), o += Math.abs(g.positionTime - u.positionTime);
249
+ r += v.calculateDistance(u, g, !0, 4), o += Math.abs(g.positionTime - u.positionTime);
250
250
  }
251
251
  r = Math.round(r * 100) / 100, o = Math.round(o / 3600 * 100) / 100;
252
252
  const a = o ? Math.round(r / o * 100) / 100 : 0;
@@ -255,7 +255,7 @@ class K {
255
255
  }
256
256
  let X;
257
257
  try {
258
- X = z.getLogger("meteo");
258
+ X = G.getLogger("meteo");
259
259
  } catch {
260
260
  } finally {
261
261
  }
@@ -279,14 +279,14 @@ function _(C) {
279
279
  const t = new TextEncoder(), e = [], n = [];
280
280
  let s = 0;
281
281
  for (const d of C) {
282
- const p = t.encode(d.name), f = Q(d.data), m = new Uint8Array(30 + p.length), S = new DataView(m.buffer);
283
- S.setUint32(0, 67324752, !0), S.setUint16(4, 20, !0), S.setUint16(8, 0, !0), S.setUint32(14, f, !0), S.setUint32(18, d.data.length, !0), S.setUint32(22, d.data.length, !0), S.setUint16(26, p.length, !0), m.set(p, 30), e.push({ nameBytes: p, data: d.data, crc: f, offset: s }), s += m.length + d.data.length, n.push(m, d.data);
282
+ const p = t.encode(d.name), h = Q(d.data), m = new Uint8Array(30 + p.length), S = new DataView(m.buffer);
283
+ S.setUint32(0, 67324752, !0), S.setUint16(4, 20, !0), S.setUint16(8, 0, !0), S.setUint32(14, h, !0), S.setUint32(18, d.data.length, !0), S.setUint32(22, d.data.length, !0), S.setUint16(26, p.length, !0), m.set(p, 30), e.push({ nameBytes: p, data: d.data, crc: h, offset: s }), s += m.length + d.data.length, n.push(m, d.data);
284
284
  }
285
285
  const c = s, i = [];
286
286
  let r = 0;
287
287
  for (const d of e) {
288
- const p = new Uint8Array(46 + d.nameBytes.length), f = new DataView(p.buffer);
289
- f.setUint32(0, 33639248, !0), f.setUint16(4, 20, !0), f.setUint16(6, 20, !0), f.setUint16(10, 0, !0), f.setUint32(16, d.crc, !0), f.setUint32(20, d.data.length, !0), f.setUint32(24, d.data.length, !0), f.setUint16(28, d.nameBytes.length, !0), f.setUint32(42, d.offset, !0), p.set(d.nameBytes, 46), r += p.length, i.push(p);
288
+ const p = new Uint8Array(46 + d.nameBytes.length), h = new DataView(p.buffer);
289
+ h.setUint32(0, 33639248, !0), h.setUint16(4, 20, !0), h.setUint16(6, 20, !0), h.setUint16(10, 0, !0), h.setUint32(16, d.crc, !0), h.setUint32(20, d.data.length, !0), h.setUint32(24, d.data.length, !0), h.setUint16(28, d.nameBytes.length, !0), h.setUint32(42, d.offset, !0), p.set(d.nameBytes, 46), r += p.length, i.push(p);
290
290
  }
291
291
  const o = new Uint8Array(22), a = new DataView(o.buffer);
292
292
  a.setUint32(0, 101010256, !0), a.setUint16(8, e.length, !0), a.setUint16(10, e.length, !0), a.setUint32(12, r, !0), a.setUint32(16, c, !0);
@@ -298,13 +298,13 @@ function _(C) {
298
298
  u.set(d, g), g += d.length;
299
299
  return u.set(o, g), u;
300
300
  }
301
- function G(C) {
301
+ function z(C) {
302
302
  let t = "", e = C;
303
303
  for (; e >= 0; )
304
304
  t = String.fromCharCode(65 + e % 26) + t, e = Math.floor(e / 26) - 1;
305
305
  return t;
306
306
  }
307
- class b {
307
+ class v {
308
308
  /**
309
309
  * 计算方位角
310
310
  * @param from 坐标 {lng, lat}
@@ -319,7 +319,7 @@ class b {
319
319
  [e.lng, e.lat]
320
320
  ]);
321
321
  let i;
322
- return n ? i = T.rhumbBearing(c.features[0], c.features[1]) : i = T.bearing(c.features[0], c.features[1]), i < 0 && (i += 360), h.roundPrecision(i, s);
322
+ return n ? i = T.rhumbBearing(c.features[0], c.features[1]) : i = T.bearing(c.features[0], c.features[1]), i < 0 && (i += 360), f.roundPrecision(i, s);
323
323
  }
324
324
  /**
325
325
  * 计算两点间距离
@@ -331,13 +331,13 @@ class b {
331
331
  * @returns {number}
332
332
  */
333
333
  static calculateDistance(t, e, n = !0, s = 4, c = "nauticalmiles") {
334
- t = { ...t }, e = { ...e }, t.lng = h.convertToStdLng(t.lng, s), e.lng = h.convertToStdLng(e.lng, s);
334
+ t = { ...t }, e = { ...e }, t.lng = f.convertToStdLng(t.lng, s), e.lng = f.convertToStdLng(e.lng, s);
335
335
  const i = T.points([
336
336
  [t.lng, t.lat],
337
337
  [e.lng, e.lat]
338
338
  ]);
339
339
  let r;
340
- return n ? r = T.rhumbDistance(i.features[0], i.features[1], { units: c }) : r = T.distance(i.features[0], i.features[1], { units: c }), h.roundPrecision(r, s);
340
+ return n ? r = T.rhumbDistance(i.features[0], i.features[1], { units: c }) : r = T.distance(i.features[0], i.features[1], { units: c }), f.roundPrecision(r, s);
341
341
  }
342
342
  /**
343
343
  * 计算航线距离
@@ -354,7 +354,7 @@ class b {
354
354
  const a = { lng: i[r + 1][0], lat: i[r + 1][1] };
355
355
  s += this.calculateDistance(o, a, !0, e, n), c = a;
356
356
  }
357
- return h.roundPrecision(s, e);
357
+ return f.roundPrecision(s, e);
358
358
  }
359
359
  /**
360
360
  * 计算坐标(基于方位角和距离)
@@ -369,7 +369,7 @@ class b {
369
369
  let r;
370
370
  c ? r = T.rhumbDestination(i, n, e, { units: s }) : r = T.destination(i, n, e, { units: s });
371
371
  const o = r.geometry.coordinates;
372
- return { lng: h.convertToStdLng(o[0], 8), lat: h.roundPrecision(o[1], 8) };
372
+ return { lng: f.convertToStdLng(o[0], 8), lat: f.roundPrecision(o[1], 8) };
373
373
  }
374
374
  /**
375
375
  * 插值大圆坐标(基于两点方位角和间距)
@@ -408,10 +408,10 @@ class b {
408
408
  const c = [];
409
409
  let i, r;
410
410
  for (let o = 0; o < t.length - 1; o++) {
411
- i = h.convertToStdLng(t[o].lng, 8), r = h.convertToStdLng(t[o + 1].lng, 8), t[o].lat = h.roundPrecision(t[o].lat, 8), t[o + 1].lat = h.roundPrecision(t[o + 1].lat, 8), s.push([i, t[o].lat]);
411
+ i = f.convertToStdLng(t[o].lng, 8), r = f.convertToStdLng(t[o + 1].lng, 8), t[o].lat = f.roundPrecision(t[o].lat, 8), t[o + 1].lat = f.roundPrecision(t[o + 1].lat, 8), s.push([i, t[o].lat]);
412
412
  const a = i - r;
413
413
  if (Math.abs(a) > 180) {
414
- const l = h.convertToMonotonicLng2([
414
+ const l = f.convertToMonotonicLng2([
415
415
  [i, t[o].lat],
416
416
  [r, t[o + 1].lat]
417
417
  ]);
@@ -423,8 +423,8 @@ class b {
423
423
  const d = T.lineIntersect(u, g);
424
424
  let p;
425
425
  if (d.features.length) {
426
- const f = T.getCoord(d.features[0]);
427
- p = h.roundPrecision(f[1], 8);
426
+ const h = T.getCoord(d.features[0]);
427
+ p = f.roundPrecision(h[1], 8);
428
428
  } else
429
429
  p = t[o].lat;
430
430
  a > 0 ? (s.push([180 - 1e-6, p]), c.push([...s]), s = [], s.push([-(180 - 1e-6), p])) : (s.push([-(180 - 1e-6), p]), c.push([...s]), s = [], s.push([180 - 1e-6, p]));
@@ -458,10 +458,10 @@ class b {
458
458
  * @param route 航线[[[lng, lat],[lng, lat]]]
459
459
  */
460
460
  static removeCoordinateFromRoute(t, e) {
461
- t.lng = h.convertToStdLng(t.lng, 8);
461
+ t.lng = f.convertToStdLng(t.lng, 8);
462
462
  for (const n of e)
463
463
  for (let s = n.length - 1; s >= 0; s--)
464
- h.roundPrecision(n[s][0], 8) === t.lng && h.roundPrecision(n[s][1], 8) === h.roundPrecision(t.lat, 8) && n.splice(s, 1);
464
+ f.roundPrecision(n[s][0], 8) === t.lng && f.roundPrecision(n[s][1], 8) === f.roundPrecision(t.lat, 8) && n.splice(s, 1);
465
465
  return e;
466
466
  }
467
467
  /**
@@ -470,9 +470,9 @@ class b {
470
470
  * @param waypoints [{lat, lng}, {lat, lng}]
471
471
  */
472
472
  static removeCoordinateFromWaypoints(t, e) {
473
- t.lng = h.convertToStdLng(t.lng, 8);
473
+ t.lng = f.convertToStdLng(t.lng, 8);
474
474
  for (let n = e.length - 1; n >= 0; n--)
475
- h.roundPrecision(e[n].lng, 8) === t.lng && h.roundPrecision(e[n].lat, 8) === h.roundPrecision(t.lat, 8) && e.splice(n, 1);
475
+ f.roundPrecision(e[n].lng, 8) === t.lng && f.roundPrecision(e[n].lat, 8) === f.roundPrecision(t.lat, 8) && e.splice(n, 1);
476
476
  return e;
477
477
  }
478
478
  /**
@@ -487,7 +487,7 @@ class b {
487
487
  * [[[120, 30], [120, 35], [125,40], [130, 37]], [[-150, 40], [-130, 30]]]
488
488
  */
489
489
  static mergeCoordinateToRoute(t, e) {
490
- t.lng = h.convertToStdLng(t.lng, 8);
490
+ t.lng = f.convertToStdLng(t.lng, 8);
491
491
  let n = Number.MAX_VALUE, s = 0, c = 0, i, r;
492
492
  return e.forEach((o, a) => {
493
493
  for (let l = 0; l < o.length - 1; l++) {
@@ -502,9 +502,9 @@ class b {
502
502
  * @param route
503
503
  */
504
504
  static appendCoordinateToRoute(t, e) {
505
- t.lng = h.convertToStdLng(t.lng, 8);
506
- const n = b.convertRouteToCoordinates(e);
507
- return n.push(t), b.divideAccordingToLng(n);
505
+ t.lng = f.convertToStdLng(t.lng, 8);
506
+ const n = v.convertRouteToCoordinates(e);
507
+ return n.push(t), v.divideAccordingToLng(n);
508
508
  }
509
509
  /**
510
510
  * 向route头加1个坐标
@@ -512,8 +512,8 @@ class b {
512
512
  * @param route
513
513
  */
514
514
  static unshiftCoordinateToRoute(t, e) {
515
- const n = b.convertRouteToCoordinates(e);
516
- return n.unshift(t), b.divideAccordingToLng(n);
515
+ const n = v.convertRouteToCoordinates(e);
516
+ return n.unshift(t), v.divideAccordingToLng(n);
517
517
  }
518
518
  /**
519
519
  * 合并多个waypoints进航线
@@ -541,11 +541,11 @@ class b {
541
541
  return;
542
542
  const r = [];
543
543
  for (const o of i) {
544
- if (h.roundPrecision(e.lng, 8) === h.roundPrecision(o[0], 8) && h.roundPrecision(e.lat, 8) === h.roundPrecision(o[1], 8)) {
544
+ if (f.roundPrecision(e.lng, 8) === f.roundPrecision(o[0], 8) && f.roundPrecision(e.lat, 8) === f.roundPrecision(o[1], 8)) {
545
545
  r.push(o), c === 0 && r.push([t.lng, t.lat]), c = 2;
546
546
  break;
547
547
  }
548
- c === 1 ? r.push(o) : h.roundPrecision(t.lng, 8) === h.roundPrecision(o[0], 8) && h.roundPrecision(t.lat, 8) === h.roundPrecision(o[1], 8) && (c = 1, r.push(o));
548
+ c === 1 ? r.push(o) : f.roundPrecision(t.lng, 8) === f.roundPrecision(o[0], 8) && f.roundPrecision(t.lat, 8) === f.roundPrecision(o[1], 8) && (c = 1, r.push(o));
549
549
  }
550
550
  r.length && s.push(r);
551
551
  }), s;
@@ -560,9 +560,9 @@ class b {
560
560
  */
561
561
  static calculateRangeWaypoints(t, e, n, s = []) {
562
562
  const c = this.convertRouteToCoordinates(n, 0), i = this.mergeCoordinatesToWaypoints([t, e], c.length ? c : s), r = i.findIndex(
563
- (l) => h.roundPrecision(t.lng, 8) === h.roundPrecision(l.lng, 8) && h.roundPrecision(t.lat, 8) === h.roundPrecision(l.lat, 8)
563
+ (l) => f.roundPrecision(t.lng, 8) === f.roundPrecision(l.lng, 8) && f.roundPrecision(t.lat, 8) === f.roundPrecision(l.lat, 8)
564
564
  ), o = i.findIndex(
565
- (l) => h.roundPrecision(e.lng, 8) === h.roundPrecision(l.lng, 8) && h.roundPrecision(e.lat, 8) === h.roundPrecision(l.lat, 8)
565
+ (l) => f.roundPrecision(e.lng, 8) === f.roundPrecision(l.lng, 8) && f.roundPrecision(e.lat, 8) === f.roundPrecision(l.lat, 8)
566
566
  );
567
567
  return i.filter((l, u) => u >= r && u <= o);
568
568
  }
@@ -587,10 +587,10 @@ class b {
587
587
  * @return [[[lng, lat]]]
588
588
  */
589
589
  static calculateSubRoute(t, e) {
590
- const n = b.convertRouteToCoordinates(e);
591
- b.mergeCoordinateToWaypoints(t, n, !0), e = b.divideAccordingToLng(n);
590
+ const n = v.convertRouteToCoordinates(e);
591
+ v.mergeCoordinateToWaypoints(t, n, !0), e = v.divideAccordingToLng(n);
592
592
  const { segIndex: s, minIndex: c } = this.calculateMinDistanceToRoute({ ...t }, e);
593
- t.lng = h.convertToStdLng(t.lng);
593
+ t.lng = f.convertToStdLng(t.lng);
594
594
  const i = [];
595
595
  let r = !0;
596
596
  for (let o = s; o < e.length; o++)
@@ -621,7 +621,7 @@ class b {
621
621
  const a = this.calculatePointToLineDistance(t, r, o);
622
622
  n > a && (n = a, s = i);
623
623
  }
624
- t.lng = h.convertToStdLng(t.lng);
624
+ t.lng = f.convertToStdLng(t.lng);
625
625
  const c = [t];
626
626
  for (let i = s + 1; i < e.length; i++)
627
627
  c.push(e[i]);
@@ -635,14 +635,14 @@ class b {
635
635
  * @param options
636
636
  */
637
637
  static calculatePointToLineDistance(t, e, n, s = { units: "nauticalmiles", method: "geodesic" }) {
638
- t.lng = h.convertToStdLng(t.lng, 8), e = { ...e }, n = { ...n }, e.lng = h.convertToStdLng(e.lng, 8), n.lng = h.convertToStdLng(n.lng, 8);
639
- const c = h.convertToMonotonicLng([e, n]);
638
+ t.lng = f.convertToStdLng(t.lng, 8), e = { ...e }, n = { ...n }, e.lng = f.convertToStdLng(e.lng, 8), n.lng = f.convertToStdLng(n.lng, 8);
639
+ const c = f.convertToMonotonicLng([e, n]);
640
640
  e = c[0], n = c[1];
641
641
  const i = T.lineString([
642
642
  [e.lng, e.lat],
643
643
  [n.lng, n.lat]
644
644
  ]), r = T.pointToLineDistance(T.point([t.lng, t.lat]), i, s), o = T.pointToLineDistance(T.point([t.lng > 0 ? t.lng - 360 : t.lng + 360, t.lat]), i, s);
645
- return h.roundPrecision(Math.min(r, o), 6);
645
+ return f.roundPrecision(Math.min(r, o), 6);
646
646
  }
647
647
  /**
648
648
  * 计算途经点的COG, Distance等属性
@@ -653,7 +653,7 @@ class b {
653
653
  e = this.mergeWaypointsToRoute(t, e);
654
654
  for (let n = 0; n < t.length - 1; n++) {
655
655
  const s = t[n], c = t[n + 1], i = this.calculateRangeRoute(s, c, e);
656
- n === 0 && (s.distanceFromPrevious = 0, s.distanceFromStart = 0), c.distanceFromPrevious = this.calculateRouteDistance(i), c.distanceFromStart = h.roundPrecision((s.distanceFromStart || 0) + c.distanceFromPrevious);
656
+ n === 0 && (s.distanceFromPrevious = 0, s.distanceFromStart = 0), c.distanceFromPrevious = this.calculateRouteDistance(i), c.distanceFromStart = f.roundPrecision((s.distanceFromStart || 0) + c.distanceFromPrevious);
657
657
  }
658
658
  return t;
659
659
  }
@@ -680,7 +680,7 @@ class b {
680
680
  * [{ lng: 160, lat: 30}, { lng: 170, lat: 40}, {lng: 179, lat: 50}, {lng: -170, lat: 40}, {lng: -160, lat: 30}]
681
681
  */
682
682
  static mergeCoordinateToWaypoints(t, e, n = !0) {
683
- t.lng = h.convertToStdLng(t.lng, 8);
683
+ t.lng = f.convertToStdLng(t.lng, 8);
684
684
  let s = Number.MAX_VALUE, c = 0, i = 0, r = 0;
685
685
  if (e.length < 2)
686
686
  e.push(t);
@@ -692,11 +692,11 @@ class b {
692
692
  i !== 0 && r !== 0 ? i <= s && c === 0 ? e.unshift(t) : r <= s && c === e.length - 2 ? e.push(t) : e.splice(c + 1, 0, t) : i === 0 ? n ? e.splice(c, 1, t) : e.splice(c + 1, 0, t) : r === 0 && (n ? e.splice(c + 1, 1, t) : e.splice(c + 1, 0, t));
693
693
  }
694
694
  return e.map((o, a) => {
695
- o.lng = h.convertToStdLng(o.lng);
695
+ o.lng = f.convertToStdLng(o.lng);
696
696
  const l = e[a + 1];
697
697
  if (l && ((o.bearing === null || o.bearing === void 0) && ((o.positionTime || 0) > (l.positionTime || 0) ? o.bearing = this.calculateBearing(l, o, !0) : o.bearing = this.calculateBearing(o, l, !0)), o.cog = o.cog || o.bearing, !o.sog && o.positionTime && l.positionTime)) {
698
698
  const u = this.calculateDistance(o, l, !0), g = Math.abs(l.positionTime - o.positionTime) / 3600;
699
- o.sog = h.roundPrecision(u / g, 2);
699
+ o.sog = f.roundPrecision(u / g, 2);
700
700
  }
701
701
  return o;
702
702
  });
@@ -727,7 +727,7 @@ class b {
727
727
  */
728
728
  static nearestCoordinateInRoute(t, e) {
729
729
  const n = T.point([t.lng, t.lat]), c = this.convertRouteToCoordinates(e).map((a) => [a.lng, a.lat]), i = T.lineString(c), r = T.nearestPointOnLine(i, n), o = T.getCoord(r);
730
- return { lng: h.roundPrecision(o[0], 8), lat: h.roundPrecision(o[1], 8) };
730
+ return { lng: f.roundPrecision(o[0], 8), lat: f.roundPrecision(o[1], 8) };
731
731
  }
732
732
  /**
733
733
  * 计算经过方向上的最后一个waypoint
@@ -766,27 +766,27 @@ class b {
766
766
  if (o)
767
767
  r.push(d);
768
768
  else {
769
- const f = [];
769
+ const h = [];
770
770
  let m;
771
771
  for (let S = 0; S < d.length; S++)
772
772
  if (u)
773
- f.push(d[S]);
773
+ h.push(d[S]);
774
774
  else {
775
775
  m = { lng: d[S][0], lat: d[S][1] };
776
- const v = this.calculateDistance(t, m, !0, 8, s);
777
- if (a += v, a < e)
778
- l += v, v && i.push(m), t = m;
776
+ const b = this.calculateDistance(t, m, !0, 8, s);
777
+ if (a += b, a < e)
778
+ l += b, b && i.push(m), t = m;
779
779
  else {
780
780
  if (l = e, a === e)
781
- u = m, f.push([u.lng, u.lat]);
781
+ u = m, h.push([u.lng, u.lat]);
782
782
  else {
783
- const P = a - e, y = this.calculateBearing(m, t);
784
- u = this.calculateCoordinate(m, y, P, s), f.push([u.lng, u.lat]), f.push([m.lng, m.lat]);
783
+ const x = a - e, y = this.calculateBearing(m, t);
784
+ u = this.calculateCoordinate(m, y, x, s), h.push([u.lng, u.lat]), h.push([m.lng, m.lat]);
785
785
  }
786
786
  o = !0;
787
787
  }
788
788
  }
789
- f.length && r.push(f), p === n.length - 1 && !u && (u = m);
789
+ h.length && r.push(h), p === n.length - 1 && !u && (u = m);
790
790
  }
791
791
  })) : (r = n, u = { ...t }), u)
792
792
  if (i.push(u), u.distanceFromPrevious = Math.round(l * 1e4) / 1e4, u.hourFromPrevious = Math.round(l / c * 1e4) / 1e4, ((g = r[0]) == null ? void 0 : g.length) > 1) {
@@ -803,10 +803,10 @@ class b {
803
803
  * @param to {lng, lat}
804
804
  */
805
805
  static nearestCoordinateInLine(t, e, n) {
806
- const s = h.convertToStdLng(t.lng, 6), c = T.point([s, t.lat]), i = h.convertToStdLng(e.lng, 6), r = h.convertToStdLng(n.lng, 6), o = T.lineString([
806
+ const s = f.convertToStdLng(t.lng, 6), c = T.point([s, t.lat]), i = f.convertToStdLng(e.lng, 6), r = f.convertToStdLng(n.lng, 6), o = T.lineString([
807
807
  [i, e.lat],
808
808
  [r, n.lat]
809
- ]), a = T.nearestPointOnLine(o, c), l = T.getCoord(a), u = h.roundPrecision(l[0], 6), g = h.roundPrecision(l[1], 6);
809
+ ]), a = T.nearestPointOnLine(o, c), l = T.getCoord(a), u = f.roundPrecision(l[0], 6), g = f.roundPrecision(l[1], 6);
810
810
  return { lng: u, lat: g, inline: !(u === i && g === e.lat) && !(u === r && g === n.lat) };
811
811
  }
812
812
  /**
@@ -819,7 +819,7 @@ class b {
819
819
  let s, c;
820
820
  return t.forEach((i) => {
821
821
  i.forEach((r) => {
822
- const o = { lng: h.roundPrecision(r[0], 8), lat: h.roundPrecision(r[1], 8) };
822
+ const o = { lng: f.roundPrecision(r[0], 8), lat: f.roundPrecision(r[1], 8) };
823
823
  if (!c)
824
824
  n.push(o), c = o;
825
825
  else if (c.bearing === void 0 || c.bearing === null)
@@ -843,9 +843,9 @@ class b {
843
843
  return s = this.simplifyGCCoordinates(s, e), s;
844
844
  }
845
845
  /**
846
- * 基于大圆标识抽稀
847
- * @param coordinates
848
- * @param waypoints
846
+ * 基于大圆标识抽稀, 将 waypoints 中的 gcToPrevious 标记的点作为关键点,移除这些点之间的冗余点
847
+ * @param coordinates 航路点
848
+ * @param waypoints 关键航路点
849
849
  */
850
850
  static simplifyGCCoordinates(t, e) {
851
851
  e.forEach((s) => {
@@ -862,9 +862,9 @@ class b {
862
862
  let n = 0;
863
863
  for (let s = 1; s < t.length; s++) {
864
864
  const c = t[s - 1], i = t[s];
865
- i.gcToPrevious ? (c.bearing = this.calculateBearing(c, i, !1), i.distanceFromPrevious = this.calculateDistance(c, i, !1)) : (c.bearing = this.calculateBearing(c, i, !0), i.distanceFromPrevious = this.calculateDistance(c, i, !0)), n = h.roundPrecision(n + i.distanceFromPrevious), i.distanceFromStart = n;
865
+ i.gcToPrevious ? (c.bearing = this.calculateBearing(c, i, !1), i.distanceFromPrevious = this.calculateDistance(c, i, !1)) : (c.bearing = this.calculateBearing(c, i, !0), i.distanceFromPrevious = this.calculateDistance(c, i, !0)), n = f.roundPrecision(n + i.distanceFromPrevious), i.distanceFromStart = n;
866
866
  }
867
- return t.map((s) => (s.lng = h.convertToStdLng(s.lng), s));
867
+ return t.map((s) => (s.lng = f.convertToStdLng(s.lng), s));
868
868
  }
869
869
  /**
870
870
  * 计算轨迹中心点
@@ -875,11 +875,11 @@ class b {
875
875
  for (const r of t)
876
876
  for (const o of r)
877
877
  e.push(o);
878
- const n = T.featureCollection([]), s = h.convertToMonotonicLng2(e);
878
+ const n = T.featureCollection([]), s = f.convertToMonotonicLng2(e);
879
879
  for (const r of s)
880
880
  n.features.push(T.point(r));
881
881
  const i = T.center(n).geometry.coordinates;
882
- return { lng: h.convertToStdLng(i[0], 8), lat: h.roundPrecision(i[1], 8) };
882
+ return { lng: f.convertToStdLng(i[0], 8), lat: f.roundPrecision(i[1], 8) };
883
883
  }
884
884
  /**
885
885
  * 计算中心点
@@ -898,7 +898,7 @@ class b {
898
898
  for (const c of t)
899
899
  for (const i of c)
900
900
  e.push(i);
901
- const n = h.convertToMonotonicLng2(e), s = T.lineString(n);
901
+ const n = f.convertToMonotonicLng2(e), s = T.lineString(n);
902
902
  return T.bbox(s);
903
903
  }
904
904
  /**
@@ -910,35 +910,108 @@ class b {
910
910
  return this.calculateBBox(e);
911
911
  }
912
912
  /**
913
- * 抽稀:基于三点夹角及距离移除冗余点
914
- * - 保留首尾点、重要标记点(important/pilot/suspend/velocity/gcToPrevious)
915
- * - 当三点夹角 >= minAngle 且相邻距离 <= minDistance 时,移除中间点
913
+ * 抽稀:基于 Ramer-Douglas-Peucker(RDP)横向偏差移除冗余点
914
+ * - 保留首尾点、重要标记点(important/pilot/suspend/velocity/gcToPrevious),并以其为分段锚点
915
+ * - 每个锚点段内,点相对首尾弦的横向偏差超过 epsilon 才保留,否则整段内部点一次性剔除
916
+ * - 抽稀后若指定 maxLeg,对超过 maxLeg 的腿在原始轨迹上均匀补点,保证航路点密度
916
917
  * @param coordinates 原始坐标序列
917
- * @param minDistance 最小保留距离阈值(nm),默认 0.1
918
- * @param minAngle 最小保留角度阈值(度),默认 175;>= 此值视为近似直线可抽稀
918
+ * @param epsilon 最大允许横向偏差阈值(nm),默认 1
919
+ * @param maxLeg 最大允许腿长(nm),默认 0 不限制
919
920
  */
920
- static simplifyCoordinates(t, e = 1, n = 180) {
921
+ static simplifyCoordinates(t, e = 1, n = 0) {
921
922
  if (t.length <= 2)
922
923
  return [...t];
923
- const s = [t[0]];
924
- let c = 0;
925
- for (let i = 1; i < t.length - 1; i++) {
926
- const r = t[i], o = t[i + 1], a = t[c];
927
- if (r.important || r.pilot || r.suspend || r.velocity || r.gcToPrevious) {
928
- s.push(r), c = i;
929
- continue;
924
+ const s = v.rdpSimplify(t, e), i = (n > 0 ? v.splitLongLegs(t, s, n) : s).map((r) => t[r]);
925
+ return X.info("simplify: %d -> %d points (epsilon=%dnm, maxLeg=%dnm)", t.length, i.length, e, n), i;
926
+ }
927
+ /**
928
+ * RDP 主循环:首尾点与强制标记点作为锚点分段,段内迭代栈求最大横向偏差
929
+ * @param coordinates 原始坐标序列
930
+ * @param epsilon 最大允许横向偏差阈值(nm)
931
+ * @returns 升序保留点索引数组
932
+ */
933
+ static rdpSimplify(t, e) {
934
+ const n = new Array(t.length).fill(!1);
935
+ n[0] = !0, n[t.length - 1] = !0;
936
+ const s = [0];
937
+ for (let o = 1; o < t.length - 1; o++) {
938
+ const a = t[o];
939
+ (a.important || a.pilot || a.suspend || a.velocity || a.gcToPrevious) && (n[o] = !0, s.push(o));
940
+ }
941
+ s.push(t.length - 1);
942
+ const c = t.map((o) => v.toUnitVector(o)), i = T.convertLength(1, "radians", "nauticalmiles");
943
+ for (let o = 0; o < s.length - 1; o++) {
944
+ const a = [[s[o], s[o + 1]]];
945
+ for (; a.length; ) {
946
+ const [l, u] = a.pop(), g = c[l], d = c[u];
947
+ let p = g[1] * d[2] - g[2] * d[1], h = g[2] * d[0] - g[0] * d[2], m = g[0] * d[1] - g[1] * d[0];
948
+ const S = Math.sqrt(p * p + h * h + m * m), b = S < 1e-12;
949
+ b || (p /= S, h /= S, m /= S);
950
+ let x = 0, y = -1;
951
+ for (let M = l + 1; M < u; M++) {
952
+ const D = b ? v.calculateDistance(t[M], t[l]) : Math.asin(Math.min(1, Math.abs(c[M][0] * p + c[M][1] * h + c[M][2] * m))) * i;
953
+ D > x && (x = D, y = M);
954
+ }
955
+ x > e && (n[y] = !0, a.push([l, y], [y, u]));
930
956
  }
931
- const l = b.calculateDistance(a, r, !0), u = b.calculateDistance(r, o, !0), g = b.calculateDistance(a, o, !0);
932
- let d = (l * l + u * u - g * g) / (2 * l * u);
933
- d = Math.max(-1, Math.min(1, d));
934
- const p = Math.acos(d) * (180 / Math.PI);
935
- if (p >= 180 || p >= n && g <= e) {
936
- X.warn("simplify: skip point %d (angle=%d°, dist=%d): %j", i, p, g, r);
937
- continue;
957
+ }
958
+ const r = [];
959
+ for (let o = 0; o < n.length; o++)
960
+ n[o] && r.push(o);
961
+ return r;
962
+ }
963
+ /**
964
+ * 最大腿长后处理:超过 maxLeg 的腿按腿内原始点累计里程均分为 ceil(leg/maxLeg) 段取点
965
+ * @param coordinates 原始坐标序列
966
+ * @param keptIndices RDP 保留点索引(升序)
967
+ * @param maxLeg 最大允许腿长(nm)
968
+ * @returns 补点后的升序索引数组
969
+ */
970
+ static splitLongLegs(t, e, n) {
971
+ const s = [e[0]];
972
+ for (let c = 1; c < e.length; c++) {
973
+ const i = s[s.length - 1], r = e[c], o = v.calculateDistance(t[i], t[r]);
974
+ if (o > n && r - i >= 2) {
975
+ const a = Math.ceil(o / n), l = [0];
976
+ for (let u = i + 1; u <= r; u++)
977
+ l.push(l[l.length - 1] + v.calculateDistance(t[u - 1], t[u]));
978
+ for (let u = 1; u < a; u++) {
979
+ const g = o / a * u;
980
+ let d = i + 1;
981
+ for (; d < r - 1 && l[d - i] < g; )
982
+ d++;
983
+ d > i && d < r && s[s.length - 1] !== d && s.push(d);
984
+ }
938
985
  }
939
- s.push(r), c = i;
986
+ s.push(r);
940
987
  }
941
- return s.push(t[t.length - 1]), s;
988
+ return s;
989
+ }
990
+ /**
991
+ * 经纬度转三维单位向量
992
+ * @param c 坐标 {lng, lat}
993
+ * @returns [x, y, z] 单位向量
994
+ */
995
+ static toUnitVector(t) {
996
+ const e = t.lat * Math.PI / 180, n = t.lng * Math.PI / 180;
997
+ return [Math.cos(e) * Math.cos(n), Math.cos(e) * Math.sin(n), Math.sin(e)];
998
+ }
999
+ /**
1000
+ * 计算点 p 相对弦 start->end 的横向偏差(真实球面大圆偏差,天然兼容跨180°经线)
1001
+ * @param p 待测点
1002
+ * @param start 弦起点
1003
+ * @param end 弦终点
1004
+ * @returns {number} 单位 nm
1005
+ */
1006
+ static perpendicularDeviation(t, e, n) {
1007
+ const s = v.toUnitVector(e), c = v.toUnitVector(n), i = v.toUnitVector(t);
1008
+ let r = s[1] * c[2] - s[2] * c[1], o = s[2] * c[0] - s[0] * c[2], a = s[0] * c[1] - s[1] * c[0];
1009
+ const l = Math.sqrt(r * r + o * o + a * a);
1010
+ if (l < 1e-12)
1011
+ return v.calculateDistance(t, e);
1012
+ r /= l, o /= l, a /= l;
1013
+ const u = T.convertLength(1, "radians", "nauticalmiles");
1014
+ return Math.asin(Math.min(1, Math.abs(i[0] * r + i[1] * o + i[2] * a))) * u;
942
1015
  }
943
1016
  /**
944
1017
  * 在时间轨迹上寻找ts最近的点
@@ -947,7 +1020,7 @@ class b {
947
1020
  * @param waypoints 带时间的轨迹, 单位秒
948
1021
  */
949
1022
  static nearestTSPointInWaypoints(t, e, n) {
950
- const s = x.unix(t), c = n.filter(
1023
+ const s = P.unix(t), c = n.filter(
951
1024
  (i) => s.clone().subtract(e, "hour").unix() <= (i.positionTime || 0) && s.clone().add(e, "h").unix() >= (i.positionTime || 0)
952
1025
  );
953
1026
  return c.sort((i, r) => (i.positionTime || 0) - (r.positionTime || 0)), c.at(-1);
@@ -960,15 +1033,15 @@ class b {
960
1033
  static deadReckoning(t, e) {
961
1034
  var c, i, r, o;
962
1035
  t > 1e12 && (t = Math.round(t / 1e3));
963
- const n = x.unix(t);
1036
+ const n = P.unix(t);
964
1037
  let s = e.find((a) => a.positionTime === n.unix());
965
1038
  if (!s) {
966
1039
  const a = (i = (c = e.filter((u) => (u == null ? void 0 : u.positionTime) < n.unix())) == null ? void 0 : c.sort((u, g) => (u.positionTime || 0) - (g.positionTime || 0))) == null ? void 0 : i.at(-1), l = (o = (r = e.filter((u) => (u == null ? void 0 : u.positionTime) > n.unix())) == null ? void 0 : r.sort((u, g) => (u.positionTime || 0) - (g.positionTime || 0))) == null ? void 0 : o.at(0);
967
1040
  if (a && l) {
968
- const u = b.calculateBearing(a, l, !0), g = b.calculateDistance(a, l), d = (n.unix() - a.positionTime) / (l.positionTime - a.positionTime);
969
- s = b.calculateCoordinate(a, u, g * d), s.positionTime = n.unix(), s.utc = n.utc().format(), s.cog = u, s.sog = Math.round(g / ((l.positionTime - a.positionTime) / 3600) * 100) / 100;
1041
+ const u = v.calculateBearing(a, l, !0), g = v.calculateDistance(a, l), d = (n.unix() - a.positionTime) / (l.positionTime - a.positionTime);
1042
+ s = v.calculateCoordinate(a, u, g * d), s.positionTime = n.unix(), s.utc = n.utc().format(), s.cog = u, s.sog = Math.round(g / ((l.positionTime - a.positionTime) / 3600) * 100) / 100;
970
1043
  } else
971
- s = a || l, s && (s.utc = x.unix(s == null ? void 0 : s.positionTime).utc().format());
1044
+ s = a || l, s && (s.utc = P.unix(s == null ? void 0 : s.positionTime).utc().format());
972
1045
  }
973
1046
  return s;
974
1047
  }
@@ -981,19 +1054,19 @@ class b {
981
1054
  e = JSON.parse(JSON.stringify(e)), e.sort((a, l) => (a.positionTime || 0) - (l.positionTime || 0));
982
1055
  let n = Number.MAX_SAFE_INTEGER, s = Number.MAX_SAFE_INTEGER;
983
1056
  for (let a = 0; a < e.length - 1; a++) {
984
- const l = e[a], u = e[a + 1], g = b.calculatePointToLineDistance(t, l, u);
1057
+ const l = e[a], u = e[a + 1], g = v.calculatePointToLineDistance(t, l, u);
985
1058
  g < n && (n = g, s = a);
986
1059
  }
987
- const c = e[s], i = e[s + 1], r = b.calculateDistance(c, t), o = b.calculateDistance(i, t);
1060
+ const c = e[s], i = e[s + 1], r = v.calculateDistance(c, t), o = v.calculateDistance(i, t);
988
1061
  if (r === 0)
989
1062
  t = c;
990
1063
  else if (o === 0)
991
1064
  t = i;
992
1065
  else {
993
- const a = c.positionTime || 0, l = i.positionTime || 0, u = b.calculateDistance(c, i);
1066
+ const a = c.positionTime || 0, l = i.positionTime || 0, u = v.calculateDistance(c, i);
994
1067
  t.positionTime = Math.round(a + (l - a) * (r / u));
995
1068
  }
996
- return t.utc = t.positionTime ? x.unix(t.positionTime).utc().format() : void 0, t.positionTime ? t : void 0;
1069
+ return t.utc = t.positionTime ? P.unix(t.positionTime).utc().format() : void 0, t.positionTime ? t : void 0;
997
1070
  }
998
1071
  /**
999
1072
  * 翻转轨迹
@@ -1029,7 +1102,7 @@ class b {
1029
1102
  */
1030
1103
  static waypoints2RTZ(t, e) {
1031
1104
  const s = [];
1032
- return s.push('<?xml version="1.0" encoding="UTF-8"?>'), s.push('<route xmlns="http://www.cirm.org/RTZ/1/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2">'), s.push(` <routeInfo routeName="${b.xmlEscape(t)}"></routeInfo>`), s.push(...b.toRTZWaypoints(e, 6)), s.push("</route>"), s.join(`
1105
+ return s.push('<?xml version="1.0" encoding="UTF-8"?>'), s.push('<route xmlns="http://www.cirm.org/RTZ/1/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2">'), s.push(` <routeInfo routeName="${v.xmlEscape(t)}"></routeInfo>`), s.push(...v.toRTZWaypoints(e, 6)), s.push("</route>"), s.join(`
1033
1106
  `) + `
1034
1107
  `;
1035
1108
  }
@@ -1041,7 +1114,7 @@ class b {
1041
1114
  */
1042
1115
  static waypoints2RTZ10(t, e, n = !0) {
1043
1116
  const c = [];
1044
- return c.push('<?xml version="1.0" encoding="UTF-8"?>'), c.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'), c.push(` <routeInfo routeName="${b.xmlEscape(t)}"></routeInfo>`), c.push(...b.toRTZWaypoints(e, 6, n)), c.push("</route>"), c.join(`
1117
+ return c.push('<?xml version="1.0" encoding="UTF-8"?>'), c.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'), c.push(` <routeInfo routeName="${v.xmlEscape(t)}"></routeInfo>`), c.push(...v.toRTZWaypoints(e, 6, n)), c.push("</route>"), c.join(`
1045
1118
  `) + `
1046
1119
  `;
1047
1120
  }
@@ -1050,20 +1123,20 @@ class b {
1050
1123
  s.push(" <waypoints>");
1051
1124
  for (let c = 0; c < t.length; c++) {
1052
1125
  const i = t[c], r = c + 1, o = (i.lat ?? "").toFixed ? i.lat.toFixed(e).padEnd(e + 2, "0") : i.lat, a = (i.lng ?? "").toFixed ? i.lng.toFixed(e).padEnd(e + 2, "0") : i.lng, l = [`id="${r}"`, 'revision="0"'];
1053
- if (i.name && l.push(`name="${b.xmlEscape(i.name)}"`), s.push(` <waypoint ${l.join(" ")}>`), s.push(` <position lat="${b.xmlEscape(o)}" lon="${b.xmlEscape(a)}" />`), c > 0) {
1126
+ if (i.name && l.push(`name="${v.xmlEscape(i.name)}"`), s.push(` <waypoint ${l.join(" ")}>`), s.push(` <position lat="${v.xmlEscape(o)}" lon="${v.xmlEscape(a)}" />`), c > 0) {
1054
1127
  const u = i.gcToPrevious ? "Orthodrome" : "Loxodrome";
1055
1128
  s.push(` <leg geometryType="${u}" />`);
1056
1129
  }
1057
1130
  if (n) {
1058
1131
  const u = [];
1059
- if (i.description && u.push(` <description>${b.xmlEscape(i.description)}</description>`), i.utc)
1060
- u.push(` <time>${b.xmlEscape(i.utc)}</time>`);
1132
+ if (i.description && u.push(` <description>${v.xmlEscape(i.description)}</description>`), i.utc)
1133
+ u.push(` <time>${v.xmlEscape(i.utc)}</time>`);
1061
1134
  else if (i.positionTime)
1062
1135
  try {
1063
- u.push(` <time>${b.xmlEscape(x.unix(i.positionTime).utc().format())}</time>`);
1136
+ u.push(` <time>${v.xmlEscape(P.unix(i.positionTime).utc().format())}</time>`);
1064
1137
  } catch {
1065
1138
  }
1066
- i.cog !== void 0 && u.push(` <cog>${b.xmlEscape(i.cog)}</cog>`), i.sog !== void 0 && u.push(` <sog>${b.xmlEscape(i.sog)}</sog>`), u.length && (s.push(" <extensions>"), s.push(...u), s.push(" </extensions>"));
1139
+ i.cog !== void 0 && u.push(` <cog>${v.xmlEscape(i.cog)}</cog>`), i.sog !== void 0 && u.push(` <sog>${v.xmlEscape(i.sog)}</sog>`), u.length && (s.push(" <extensions>"), s.push(...u), s.push(" </extensions>"));
1067
1140
  }
1068
1141
  s.push(" </waypoint>");
1069
1142
  }
@@ -1080,13 +1153,13 @@ class b {
1080
1153
  X.debug("keep name for waypoints2CSV for legacy compatibility only", t);
1081
1154
  const s = (n == null ? void 0 : n.precision) ?? 6, c = e.some((m) => m.name), i = e.some((m) => m.description), r = e.some((m) => m.port != null), o = e.some((m) => m.stbd != null), a = e.some((m) => m.arrRad != null), l = e.some((m) => m.speed != null), u = e.some((m, S) => S > 0 && m.gcToPrevious != null), g = e.some((m) => m.bearing != null), d = e.some((m) => m.distanceFromPrevious != null), p = ["WPT No.", "Latitude", "Longitude"];
1082
1155
  c && p.push("Name"), i && p.push("Description"), u && p.push("Leg"), g && p.push("Bearing[deg]"), d && p.push("Distance[NM]"), l && p.push("Speed[kn]"), r && p.push("PORT XTD[NM]"), o && p.push("STBD XTD[NM]"), a && p.push("Arr.Rad[NM]");
1083
- const f = [];
1084
- f.push(p.map((m) => b.csvEscapeField(m)).join(","));
1156
+ const h = [];
1157
+ h.push(p.map((m) => v.csvEscapeField(m)).join(","));
1085
1158
  for (let m = 0; m < e.length; m++) {
1086
- const S = e[m], v = [];
1087
- v.push((m + 1).toString()), v.push(S.lat.toFixed(s)), v.push(S.lng.toFixed(s)), c && v.push(S.name ?? ""), i && v.push(S.description ?? ""), u && v.push(m === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), g && v.push(S.bearing != null ? String(S.bearing) : ""), d && v.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), l && v.push(S.speed != null ? String(S.speed) : ""), r && v.push(S.port != null ? String(S.port) : ""), o && v.push(S.stbd != null ? String(S.stbd) : ""), a && v.push(S.arrRad != null ? String(S.arrRad) : ""), f.push(v.map((P) => b.csvEscapeField(P)).join(","));
1159
+ const S = e[m], b = [];
1160
+ b.push((m + 1).toString()), b.push(S.lat.toFixed(s)), b.push(S.lng.toFixed(s)), c && b.push(S.name ?? ""), i && b.push(S.description ?? ""), u && b.push(m === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), g && b.push(S.bearing != null ? String(S.bearing) : ""), d && b.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), l && b.push(S.speed != null ? String(S.speed) : ""), r && b.push(S.port != null ? String(S.port) : ""), o && b.push(S.stbd != null ? String(S.stbd) : ""), a && b.push(S.arrRad != null ? String(S.arrRad) : ""), h.push(b.map((x) => v.csvEscapeField(x)).join(","));
1088
1161
  }
1089
- return f.join(`
1162
+ return h.join(`
1090
1163
  `);
1091
1164
  }
1092
1165
  /**
@@ -1097,13 +1170,13 @@ class b {
1097
1170
  * @param options.precision 经纬度分钟小数位数,默认3
1098
1171
  */
1099
1172
  static waypoints2JRCCSV(t, e, n) {
1100
- const s = (n == null ? void 0 : n.precision) ?? 3, c = e.some((f) => f.name), i = e.some((f) => f.port != null), r = e.some((f) => f.stbd != null), o = e.some((f) => f.arrRad != null), a = e.some((f) => f.speed != null), l = e.some((f, m) => m > 0 && f.gcToPrevious != null), u = e.some((f) => f.rot != null), g = e.some((f) => f.turnRad != null), d = ["// WPT No.", "LAT", "", "", "LON", "", ""];
1173
+ const s = (n == null ? void 0 : n.precision) ?? 3, c = e.some((h) => h.name), i = e.some((h) => h.port != null), r = e.some((h) => h.stbd != null), o = e.some((h) => h.arrRad != null), a = e.some((h) => h.speed != null), l = e.some((h, m) => m > 0 && h.gcToPrevious != null), u = e.some((h) => h.rot != null), g = e.some((h) => h.turnRad != null), d = ["// WPT No.", "LAT", "", "", "LON", "", ""];
1101
1174
  i && d.push("PORT[NM]"), r && d.push("STBD[NM]"), o && d.push("Arr. Rad[NM]"), a && d.push("Speed[kn]"), l && d.push("Sail(RL/GC)"), u && d.push("ROT[deg/min]"), g && d.push("Turn Rad[NM]"), c && d.push("Name");
1102
1175
  const p = [];
1103
- p.push("// ROUTE SHEET exported by JRC ECDIS."), p.push("// <<NOTE>>This strings // indicate comment column/cells. You can edit freely."), p.push(`// ${b.xmlEscape(t)}`), p.push(d.join(","));
1104
- for (let f = 0; f < e.length; f++) {
1105
- const m = e[f], S = String(f).padStart(3, "0"), v = h.lat2pretty(m.lat, 6), P = h.lng2pretty(m.lng, 6), y = v.degree, M = Number(v.minute).toFixed(s), $ = v.direction, E = P.degree, F = Number(P.minute).toFixed(s), R = P.direction, D = [S, String(y), M, $, String(E), F, R];
1106
- i && D.push(f === 0 ? "***" : m.port != null ? String(m.port) : "***"), r && D.push(f === 0 ? "***" : m.stbd != null ? String(m.stbd) : "***"), o && D.push(f === 0 ? "***" : m.arrRad != null ? String(m.arrRad) : "***"), a && D.push(f === 0 ? "***" : m.speed != null ? Number(m.speed).toFixed(1).padStart(5, "0") : "***"), l && D.push(f === 0 ? "***" : m.gcToPrevious ? "GC" : "RL"), u && D.push(f === 0 ? "***" : m.rot != null ? String(m.rot) : "***"), g && D.push(f === 0 ? "***" : m.turnRad != null ? String(m.turnRad) : "***"), c && D.push(m.name ?? ""), p.push(D.join(","));
1176
+ p.push("// ROUTE SHEET exported by JRC ECDIS."), p.push("// <<NOTE>>This strings // indicate comment column/cells. You can edit freely."), p.push(`// ${v.xmlEscape(t)}`), p.push(d.join(","));
1177
+ for (let h = 0; h < e.length; h++) {
1178
+ const m = e[h], S = String(h).padStart(3, "0"), b = f.lat2pretty(m.lat, 6), x = f.lng2pretty(m.lng, 6), y = b.degree, M = Number(b.minute).toFixed(s), D = b.direction, E = x.degree, F = Number(x.minute).toFixed(s), $ = x.direction, R = [S, String(y), M, D, String(E), F, $];
1179
+ i && R.push(h === 0 ? "***" : m.port != null ? String(m.port) : "***"), r && R.push(h === 0 ? "***" : m.stbd != null ? String(m.stbd) : "***"), o && R.push(h === 0 ? "***" : m.arrRad != null ? String(m.arrRad) : "***"), a && R.push(h === 0 ? "***" : m.speed != null ? Number(m.speed).toFixed(1).padStart(5, "0") : "***"), l && R.push(h === 0 ? "***" : m.gcToPrevious ? "GC" : "RL"), u && R.push(h === 0 ? "***" : m.rot != null ? String(m.rot) : "***"), g && R.push(h === 0 ? "***" : m.turnRad != null ? String(m.turnRad) : "***"), c && R.push(m.name ?? ""), p.push(R.join(","));
1107
1180
  }
1108
1181
  return p.join(`
1109
1182
  `);
@@ -1120,26 +1193,26 @@ class b {
1120
1193
  * @returns Uint8Array 二进制数据,可直接用于 new Blob([result], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
1121
1194
  */
1122
1195
  static waypoints2XLSX(t, e, n) {
1123
- const s = (n == null ? void 0 : n.precision) ?? 6, c = t || "Route", i = e.some((N) => N.name), r = e.some((N) => N.description), o = e.some((N) => N.port != null), a = e.some((N) => N.stbd != null), l = e.some((N) => N.arrRad != null), u = e.some((N) => N.speed != null), g = e.some((N, k) => k > 0 && N.gcToPrevious != null), d = e.some((N) => N.bearing != null), p = e.some((N) => N.distanceFromPrevious != null), f = ["WPT No.", "Latitude", "Longitude"];
1124
- i && f.push("Name"), r && f.push("Description"), g && f.push("Leg"), d && f.push("Bearing[deg]"), p && f.push("Distance[NM]"), u && f.push("Speed[kn]"), o && f.push("PORT XTD[NM]"), a && f.push("STBD XTD[NM]"), l && f.push("Arr.Rad[NM]");
1196
+ const s = (n == null ? void 0 : n.precision) ?? 6, c = t || "Route", i = e.some((N) => N.name), r = e.some((N) => N.description), o = e.some((N) => N.port != null), a = e.some((N) => N.stbd != null), l = e.some((N) => N.arrRad != null), u = e.some((N) => N.speed != null), g = e.some((N, k) => k > 0 && N.gcToPrevious != null), d = e.some((N) => N.bearing != null), p = e.some((N) => N.distanceFromPrevious != null), h = ["WPT No.", "Latitude", "Longitude"];
1197
+ i && h.push("Name"), r && h.push("Description"), g && h.push("Leg"), d && h.push("Bearing[deg]"), p && h.push("Distance[NM]"), u && h.push("Speed[kn]"), o && h.push("PORT XTD[NM]"), a && h.push("STBD XTD[NM]"), l && h.push("Arr.Rad[NM]");
1125
1198
  const m = (N) => N == null ? "" : String(N).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1126
- let v = `<row r="1">${f.map((N, k) => `<c r="${G(k)}1" s="1" t="inlineStr"><is><t>${m(N)}</t></is></c>`).join("")}</row>`;
1199
+ let b = `<row r="1">${h.map((N, k) => `<c r="${z(k)}1" s="1" t="inlineStr"><is><t>${m(N)}</t></is></c>`).join("")}</row>`;
1127
1200
  for (let N = 0; N < e.length; N++) {
1128
- const k = e[N], j = N + 2, U = [], Z = (L, q) => U.push(`<c r="${G(L)}${j}"><v>${q}</v></c>`), B = (L, q) => U.push(`<c r="${G(L)}${j}" t="inlineStr"><is><t>${m(q)}</t></is></c>`), w = (L, q) => {
1129
- q != null ? Z(L, q) : B(L, "");
1201
+ const k = e[N], j = N + 2, U = [], Z = (q, L) => U.push(`<c r="${z(q)}${j}"><v>${L}</v></c>`), B = (q, L) => U.push(`<c r="${z(q)}${j}" t="inlineStr"><is><t>${m(L)}</t></is></c>`), w = (q, L) => {
1202
+ L != null ? Z(q, L) : B(q, "");
1130
1203
  };
1131
- Z(0, N + 1), B(1, h.lat2pretty(k.lat, s).pretty), B(2, h.lng2pretty(k.lng, s).pretty);
1204
+ Z(0, N + 1), B(1, f.lat2pretty(k.lat, s).pretty), B(2, f.lng2pretty(k.lng, s).pretty);
1132
1205
  let I = 3;
1133
- i && (B(I, k.name ?? ""), I++), r && (B(I, k.description ?? ""), I++), g && (B(I, N === 0 ? "" : k.gcToPrevious ? "GC" : "RL"), I++), d && (w(I, k.bearing), I++), p && (w(I, k.distanceFromPrevious), I++), u && (w(I, k.speed), I++), o && (w(I, k.port), I++), a && (w(I, k.stbd), I++), l && (w(I, k.arrRad), I++), v += `<row r="${j}">${U.join("")}</row>`;
1206
+ i && (B(I, k.name ?? ""), I++), r && (B(I, k.description ?? ""), I++), g && (B(I, N === 0 ? "" : k.gcToPrevious ? "GC" : "RL"), I++), d && (w(I, k.bearing), I++), p && (w(I, k.distanceFromPrevious), I++), u && (w(I, k.speed), I++), o && (w(I, k.port), I++), a && (w(I, k.stbd), I++), l && (w(I, k.arrRad), I++), b += `<row r="${j}">${U.join("")}</row>`;
1134
1207
  }
1135
- const P = "0." + "0".repeat(s), y = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>' + v + "</sheetData></worksheet>", M = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>', $ = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>', E = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="' + m(c) + '" sheetId="1" r:id="rId1"/></sheets></workbook>', F = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>', R = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><numFmts count="1"><numFmt numFmtId="164" formatCode="' + P + '"/></numFmts><fonts count="2"><font><sz val="11"/><name val="Arial"/></font><font><b/><sz val="11"/><name val="Arial"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="2"><border><left/><right/><top/><bottom/><diagonal/></border><border><bottom style="thin"><color auto="1"/></bottom></border></borders><cellStyleXfs count="1"><xf/></cellStyleXfs><cellXfs count="3"><xf/><xf fontId="1" fillId="0" borderId="1" applyFont="1" applyBorder="1"/><xf numFmtId="164" fontId="0" applyNumberFormat="1"/></cellXfs></styleSheet>', D = new TextEncoder();
1208
+ const x = "0." + "0".repeat(s), y = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>' + b + "</sheetData></worksheet>", M = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>', D = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>', E = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="' + m(c) + '" sheetId="1" r:id="rId1"/></sheets></workbook>', F = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>', $ = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><numFmts count="1"><numFmt numFmtId="164" formatCode="' + x + '"/></numFmts><fonts count="2"><font><sz val="11"/><name val="Arial"/></font><font><b/><sz val="11"/><name val="Arial"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="2"><border><left/><right/><top/><bottom/><diagonal/></border><border><bottom style="thin"><color auto="1"/></bottom></border></borders><cellStyleXfs count="1"><xf/></cellStyleXfs><cellXfs count="3"><xf/><xf fontId="1" fillId="0" borderId="1" applyFont="1" applyBorder="1"/><xf numFmtId="164" fontId="0" applyNumberFormat="1"/></cellXfs></styleSheet>', R = new TextEncoder();
1136
1209
  return _([
1137
- { name: "[Content_Types].xml", data: D.encode(M) },
1138
- { name: "_rels/.rels", data: D.encode($) },
1139
- { name: "xl/workbook.xml", data: D.encode(E) },
1140
- { name: "xl/_rels/workbook.xml.rels", data: D.encode(F) },
1141
- { name: "xl/worksheets/sheet1.xml", data: D.encode(y) },
1142
- { name: "xl/styles.xml", data: D.encode(R) }
1210
+ { name: "[Content_Types].xml", data: R.encode(M) },
1211
+ { name: "_rels/.rels", data: R.encode(D) },
1212
+ { name: "xl/workbook.xml", data: R.encode(E) },
1213
+ { name: "xl/_rels/workbook.xml.rels", data: R.encode(F) },
1214
+ { name: "xl/worksheets/sheet1.xml", data: R.encode(y) },
1215
+ { name: "xl/styles.xml", data: R.encode($) }
1143
1216
  ]);
1144
1217
  }
1145
1218
  /**
@@ -1179,7 +1252,7 @@ class b {
1179
1252
  static waypoints2NMEA(t) {
1180
1253
  const e = [];
1181
1254
  for (let n = 0; n < t.length; n++) {
1182
- const s = t[n], c = b.decimalToNmeaDm(s.lat, !0), i = b.decimalToNmeaDm(s.lng, !1), r = s.name ? String(s.name).slice(0, 6) : `WPT${(n + 1).toString().padStart(3, "0")}`, o = `GPWPL,${c.dm},${c.dir},${i.dm},${i.dir},${r}`, a = b.nmeaChecksum(o);
1255
+ const s = t[n], c = v.decimalToNmeaDm(s.lat, !0), i = v.decimalToNmeaDm(s.lng, !1), r = s.name ? String(s.name).slice(0, 6) : `WPT${(n + 1).toString().padStart(3, "0")}`, o = `GPWPL,${c.dm},${c.dir},${i.dm},${i.dir},${r}`, a = v.nmeaChecksum(o);
1183
1256
  e.push(`$${o}*${a}`);
1184
1257
  }
1185
1258
  return e.join(`\r
@@ -1199,7 +1272,7 @@ class b {
1199
1272
  */
1200
1273
  static coordinatesSummary(t, e = 3) {
1201
1274
  if (t.length > 1) {
1202
- const n = t[0], s = t[t.length - 1], c = (n == null ? void 0 : n.positionTime) < (s == null ? void 0 : s.positionTime) ? x.unix(n == null ? void 0 : n.positionTime) : x.unix(s == null ? void 0 : s.positionTime), i = (n == null ? void 0 : n.positionTime) > (s == null ? void 0 : s.positionTime) ? x.unix(n == null ? void 0 : n.positionTime) : x.unix(s == null ? void 0 : s.positionTime), r = Math.round(i.diff(c, "hours", !0) * 100) / 100, o = this.generateRouteAccordingToWaypoints(t, !0, !0), a = this.calculateRouteDistance(o), u = K.inspectStoppages(t, e).reduce(
1275
+ const n = t[0], s = t[t.length - 1], c = (n == null ? void 0 : n.positionTime) < (s == null ? void 0 : s.positionTime) ? P.unix(n == null ? void 0 : n.positionTime) : P.unix(s == null ? void 0 : s.positionTime), i = (n == null ? void 0 : n.positionTime) > (s == null ? void 0 : s.positionTime) ? P.unix(n == null ? void 0 : n.positionTime) : P.unix(s == null ? void 0 : s.positionTime), r = Math.round(i.diff(c, "hours", !0) * 100) / 100, o = this.generateRouteAccordingToWaypoints(t, !0, !0), a = this.calculateRouteDistance(o), u = K.inspectStoppages(t, e).reduce(
1203
1276
  (d, p) => (d.duration += p.duration, d.distance += p.distance, d),
1204
1277
  { hours: 0, distance: 0, spd: 0, duration: 0 }
1205
1278
  );
@@ -1235,21 +1308,25 @@ class b {
1235
1308
  var l, u, g;
1236
1309
  if (!((u = (l = e == null ? void 0 : e.sample) == null ? void 0 : l.hours) != null && u.length))
1237
1310
  return { routes: [], hour: void 0 };
1238
- const n = e.sample.hours.at(0), s = x.utc(t), c = x.utc(e.eta), i = s.isAfter(c) ? c : s;
1311
+ const n = e.sample.hours.at(0), s = P.utc(t), c = P.utc(e.eta), i = s.isAfter(c) ? c : s;
1239
1312
  let r = e.sample.all.find((d) => d.eta === i.format());
1240
1313
  if (!r) {
1241
- const d = e.sample.all.filter((M) => x.utc(M.eta).isBefore(i)).at(-1), p = this.calculateSubRoute(d, e.route);
1242
- r = (g = this.calculateNextCoordinateAlongRoute(d, d.speed * i.diff(x(d.etd), "hours", !0), p)) == null ? void 0 : g.coordinate;
1243
- const { cFactor: f, cog: m, wxFactor: S, meteo: v } = d, P = Math.round(r.distanceFromPrevious * 1e4) / 1e4, y = Math.round((P + d.distanceFromStart) * 1e4) / 1e4;
1314
+ let d = e.sample.all.filter((y) => P.utc(y.eta).isBefore(i)).at(-1);
1315
+ if (d) {
1316
+ const y = this.calculateSubRoute(d, e.route);
1317
+ r = (g = this.calculateNextCoordinateAlongRoute(d, d.speed * i.diff(P(d.etd), "hours", !0), y)) == null ? void 0 : g.coordinate;
1318
+ } else
1319
+ d = e.sample.all.at(0), r = d;
1320
+ const { cFactor: p, cog: h, wxFactor: m, meteo: S } = d, b = Math.round(r.distanceFromPrevious * 1e4) / 1e4, x = Math.round((b + d.distanceFromStart) * 1e4) / 1e4;
1244
1321
  r = {
1245
1322
  ...r,
1246
- cFactor: f,
1247
- cog: m,
1323
+ cFactor: p,
1324
+ cog: h,
1248
1325
  speed: d.speed,
1249
- wxFactor: S,
1250
- distanceFromStart: y,
1251
- distanceFromPrevious: P,
1252
- meteo: v,
1326
+ wxFactor: m,
1327
+ distanceFromStart: x,
1328
+ distanceFromPrevious: b,
1329
+ meteo: S,
1253
1330
  eta: i.format(),
1254
1331
  etd: i.format()
1255
1332
  };
@@ -1273,10 +1350,10 @@ class b {
1273
1350
  */
1274
1351
  static pickUTCSampleFromRoute(t, e, n) {
1275
1352
  var d;
1276
- const s = this.calculateSubRoute(e, n), c = this.calculateRouteDistance(s), i = c / e.speed, r = x.utc(t), o = x(e.etd), a = (d = this.calculateNextCoordinateAlongRoute(e, e.speed * r.diff(x(e.etd), "hours", !0), s)) == null ? void 0 : d.coordinate;
1353
+ const s = this.calculateSubRoute(e, n), c = this.calculateRouteDistance(s), i = c / e.speed, r = P.utc(t), o = P(e.etd), a = (d = this.calculateNextCoordinateAlongRoute(e, e.speed * r.diff(P(e.etd), "hours", !0), s)) == null ? void 0 : d.coordinate;
1277
1354
  a.speed = e.speed;
1278
1355
  const l = o.clone().add(a.hourFromPrevious, "hour");
1279
- a.eta = Math.abs(l.diff(r, "second")) < 2 ? r.format() : l.format(), a.etd = a.eta, a.distanceFromStart = Math.round(a.distanceFromPrevious * 100) / 100, a.distanceToGo = Math.round((c - a.distanceFromStart) * 100) / 100, a.timeToGo = Math.round(o.clone().add(i, "hour").diff(x(a.etd), "hour") * 100) / 100;
1356
+ a.eta = Math.abs(l.diff(r, "second")) < 2 ? r.format() : l.format(), a.etd = a.eta, a.distanceFromStart = Math.round(a.distanceFromPrevious * 100) / 100, a.distanceToGo = Math.round((c - a.distanceFromStart) * 100) / 100, a.timeToGo = Math.round(o.clone().add(i, "hour").diff(P(a.etd), "hour") * 100) / 100;
1280
1357
  const u = this.calculateRangeWaypoints(e, a, n);
1281
1358
  return {
1282
1359
  routes: this.generateRouteAccordingToWaypoints(u),
@@ -1324,37 +1401,37 @@ class b {
1324
1401
  }));
1325
1402
  for (const u of o) {
1326
1403
  const g = u.geometry.coordinates, d = this.convertRouteToCoordinates([g]), p = T.bbox(u);
1327
- for (const { polygon: f, bbox: m } of l) {
1404
+ for (const { polygon: h, bbox: m } of l) {
1328
1405
  if (p[0] > m[2] || p[2] < m[0] || p[1] > m[3] || p[3] < m[1])
1329
1406
  continue;
1330
1407
  let S = [];
1331
- const v = T.lineIntersect(u, f);
1332
- (c = v == null ? void 0 : v.features) != null && c.length && (S = T.getCoords(v.features).map((M) => {
1333
- const $ = T.getCoord(M);
1334
- return { lng: $[0], lat: $[1] };
1408
+ const b = T.lineIntersect(u, h);
1409
+ (c = b == null ? void 0 : b.features) != null && c.length && (S = T.getCoords(b.features).map((M) => {
1410
+ const D = T.getCoord(M);
1411
+ return { lng: D[0], lat: D[1] };
1335
1412
  }));
1336
- const P = [...d];
1413
+ const x = [...d];
1337
1414
  if (S.length > 0)
1338
1415
  for (const y of S)
1339
- this.mergeCoordinateToWaypoints(y, P, !0);
1340
- for (let y = 0; y < P.length - 1; y++) {
1341
- const M = P[y], $ = P[y + 1], E = this.calculateRangeWaypoints(M, $, [], P), F = this.divideAccordingToLng(E);
1342
- for (const R of F) {
1343
- const D = [
1344
- Math.min(R[0][0], R[R.length - 1][0]),
1345
- Math.min(R[0][1], R[R.length - 1][1]),
1346
- Math.max(R[0][0], R[R.length - 1][0]),
1347
- Math.max(R[0][1], R[R.length - 1][1])
1416
+ this.mergeCoordinateToWaypoints(y, x, !0);
1417
+ for (let y = 0; y < x.length - 1; y++) {
1418
+ const M = x[y], D = x[y + 1], E = this.calculateRangeWaypoints(M, D, [], x), F = this.divideAccordingToLng(E);
1419
+ for (const $ of F) {
1420
+ const R = [
1421
+ Math.min($[0][0], $[$.length - 1][0]),
1422
+ Math.min($[0][1], $[$.length - 1][1]),
1423
+ Math.max($[0][0], $[$.length - 1][0]),
1424
+ Math.max($[0][1], $[$.length - 1][1])
1348
1425
  ];
1349
- if (D[0] > m[2] || D[2] < m[0] || D[1] > m[3] || D[3] < m[1])
1426
+ if (R[0] > m[2] || R[2] < m[0] || R[1] > m[3] || R[3] < m[1])
1350
1427
  continue;
1351
- const N = T.lineString(R);
1352
- if (T.booleanContains(f, N)) {
1353
- const k = R.map((U) => ({ lng: U[0], lat: U[1] })), j = this.calculateRouteDistance([R]);
1428
+ const N = T.lineString($);
1429
+ if (T.booleanContains(h, N)) {
1430
+ const k = $.map((U) => ({ lng: U[0], lat: U[1] })), j = this.calculateRouteDistance([$]);
1354
1431
  a.push({
1355
1432
  distance: j,
1356
1433
  waypoints: k,
1357
- eca: (i = f == null ? void 0 : f.properties) == null ? void 0 : i.name
1434
+ eca: (i = h == null ? void 0 : h.properties) == null ? void 0 : i.name
1358
1435
  });
1359
1436
  }
1360
1437
  }
@@ -1368,7 +1445,7 @@ class b {
1368
1445
  }
1369
1446
  let A;
1370
1447
  try {
1371
- A = z.getLogger("vessel");
1448
+ A = G.getLogger("vessel");
1372
1449
  } catch {
1373
1450
  } finally {
1374
1451
  }
@@ -1386,44 +1463,44 @@ class rt {
1386
1463
  r && r.wind && (r.wind.kts = r.kts);
1387
1464
  for (const o of i.forecasts) {
1388
1465
  let a;
1389
- const l = [], u = [], g = x(o.date).utc(), d = `${i.name}-${o.model}`;
1390
- for (const f in o == null ? void 0 : o.hours) {
1391
- const m = o.hours[f];
1466
+ const l = [], u = [], g = P(o.date).utc(), d = `${i.name}-${o.model}`;
1467
+ for (const h in o == null ? void 0 : o.hours) {
1468
+ const m = o.hours[h];
1392
1469
  a = a || m;
1393
- const S = g.clone().add(Number(f), "hour"), v = T.point([m.lng, m.lat], {
1470
+ const S = g.clone().add(Number(h), "hour"), b = T.point([m.lng, m.lat], {
1394
1471
  model: o.model,
1395
1472
  name: i.name,
1396
1473
  nameCn: i.nameCn,
1397
1474
  date: S.format(),
1398
- hour: Number(f),
1475
+ hour: Number(h),
1399
1476
  format: S.format("MMM-DD/HHmm[Z]"),
1400
- pressure: m.pressure > 1e4 ? h.roundPrecision(m.pressure / 100, 0) : h.roundPrecision(m.pressure, 0),
1477
+ pressure: m.pressure > 1e4 ? f.roundPrecision(m.pressure / 100, 0) : f.roundPrecision(m.pressure, 0),
1401
1478
  gusts: m.gusts,
1402
1479
  wind: m.wind || {},
1403
1480
  movement: m.movement,
1404
1481
  category: d,
1405
1482
  type: "forecast"
1406
1483
  });
1407
- u.push(v), l.push(v.geometry.coordinates);
1484
+ u.push(b), l.push(b.geometry.coordinates);
1408
1485
  }
1409
1486
  const p = {
1410
1487
  kts: void 0,
1411
1488
  deg: void 0
1412
1489
  };
1413
1490
  if (r) {
1414
- const f = x(r.updated).utc();
1491
+ const h = P(r.updated).utc();
1415
1492
  if (a) {
1416
- const S = b.calculateDistance(r, a), v = x(a.utc || a.updated).diff(f, "h", !0);
1417
- p.kts = Math.round(S / v * 100) / 100, p.deg = b.calculateBearing(r, a, !0, 0);
1493
+ const S = v.calculateDistance(r, a), b = P(a.utc || a.updated).diff(h, "h", !0);
1494
+ p.kts = Math.round(S / b * 100) / 100, p.deg = v.calculateBearing(r, a, !0, 0);
1418
1495
  }
1419
1496
  const m = T.point([r.lng, r.lat], {
1420
1497
  model: o.model,
1421
1498
  name: i.name,
1422
1499
  nameCn: i.nameCn,
1423
- date: f.format(),
1500
+ date: h.format(),
1424
1501
  hour: 0,
1425
- format: f.format("MMM-DD/HHmm[Z]"),
1426
- pressure: r.pressure > 1e4 ? h.roundPrecision((r == null ? void 0 : r.pressure) / 100, 0) : h.roundPrecision(r.pressure, 0),
1502
+ format: h.format("MMM-DD/HHmm[Z]"),
1503
+ pressure: r.pressure > 1e4 ? f.roundPrecision((r == null ? void 0 : r.pressure) / 100, 0) : f.roundPrecision(r.pressure, 0),
1427
1504
  wind: r.wind,
1428
1505
  movement: p,
1429
1506
  category: d,
@@ -1434,7 +1511,7 @@ class rt {
1434
1511
  u.unshift(m), l.unshift(m.geometry.coordinates);
1435
1512
  }
1436
1513
  if (e.features.push(...u), (l == null ? void 0 : l.length) > 1) {
1437
- const f = T.lineString(h.convertToMonotonicLng2(l), {
1514
+ const h = T.lineString(f.convertToMonotonicLng2(l), {
1438
1515
  date: (r == null ? void 0 : r.updated) || (g == null ? void 0 : g.format()),
1439
1516
  id: i.id || i.name,
1440
1517
  model: o.model,
@@ -1443,21 +1520,21 @@ class rt {
1443
1520
  type: "forecast",
1444
1521
  movement: p
1445
1522
  });
1446
- e.features.push(f);
1523
+ e.features.push(h);
1447
1524
  }
1448
1525
  }
1449
1526
  }
1450
- if (e.features.sort((o, a) => o.properties.type === "forecast" && a.properties.type === "forecast" && o.geometry.type === "Point" && a.geometry.type === "Point" ? x(o.properties.date).valueOf() - x(a.properties.date).valueOf() : 0), (s = i.history) != null && s.length) {
1451
- const o = [], a = x(r == null ? void 0 : r.updated).utc(), l = x((c = i.history) == null ? void 0 : c.at(-1).updated).utc(), u = a.diff(l, "h") % 24 > 2 ? 24 : 12;
1527
+ if (e.features.sort((o, a) => o.properties.type === "forecast" && a.properties.type === "forecast" && o.geometry.type === "Point" && a.geometry.type === "Point" ? P(o.properties.date).valueOf() - P(a.properties.date).valueOf() : 0), (s = i.history) != null && s.length) {
1528
+ const o = [], a = P(r == null ? void 0 : r.updated).utc(), l = P((c = i.history) == null ? void 0 : c.at(-1).updated).utc(), u = a.diff(l, "h") % 24 > 2 ? 24 : 12;
1452
1529
  for (const g of i.history) {
1453
- const d = x(g.updated).utc(), p = d.isSameOrBefore(a) || d.isSame(l);
1530
+ const d = P(g.updated).utc(), p = d.isSameOrBefore(a) || d.isSame(l);
1454
1531
  p && a.add(-u, "h");
1455
- const f = T.point([g.lng, g.lat], {
1532
+ const h = T.point([g.lng, g.lat], {
1456
1533
  name: i.name,
1457
1534
  nameCn: i.nameCn,
1458
1535
  date: d.format(),
1459
1536
  format: d.format("MMM-DD/HHmm[Z]"),
1460
- pressure: g.pressure > 1e4 ? h.roundPrecision(g.pressure / 100, 0) : h.roundPrecision(g.pressure, 0),
1537
+ pressure: g.pressure > 1e4 ? f.roundPrecision(g.pressure / 100, 0) : f.roundPrecision(g.pressure, 0),
1461
1538
  kts: g.kts,
1462
1539
  level: g.type,
1463
1540
  type: "history",
@@ -1466,14 +1543,14 @@ class rt {
1466
1543
  movement: g.movement,
1467
1544
  important: p
1468
1545
  });
1469
- e.features.push(f), o.push(f.geometry.coordinates);
1546
+ e.features.push(h), o.push(h.geometry.coordinates);
1470
1547
  }
1471
1548
  if (o.length === 1 && o.push(o[0]), o.length > 1) {
1472
- const g = T.lineString(h.convertToMonotonicLng2(o), {
1549
+ const g = T.lineString(f.convertToMonotonicLng2(o), {
1473
1550
  name: i.name,
1474
1551
  type: "history",
1475
1552
  updated: r == null ? void 0 : r.updated,
1476
- pressure: (r == null ? void 0 : r.pressure) > 1e4 ? h.roundPrecision((r == null ? void 0 : r.pressure) / 100, 0) : h.roundPrecision(r == null ? void 0 : r.pressure, 0),
1553
+ pressure: (r == null ? void 0 : r.pressure) > 1e4 ? f.roundPrecision((r == null ? void 0 : r.pressure) / 100, 0) : f.roundPrecision(r == null ? void 0 : r.pressure, 0),
1477
1554
  kts: r == null ? void 0 : r.kts,
1478
1555
  level: r == null ? void 0 : r.type
1479
1556
  });
@@ -1492,32 +1569,32 @@ class rt {
1492
1569
  var c, i, r, o;
1493
1570
  const n = (c = t == null ? void 0 : t.data) == null ? void 0 : c.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), s = [];
1494
1571
  for (const a of n) {
1495
- const l = a.properties.name, u = a.properties.model, g = a.properties.showCircle, d = a.properties.disabled, p = x(a.properties.date).utc();
1496
- let f = e * 60;
1572
+ const l = a.properties.name, u = a.properties.model, g = a.properties.showCircle, d = a.properties.disabled, p = P(a.properties.date).utc();
1573
+ let h = e * 60;
1497
1574
  const m = (i = t == null ? void 0 : t.data) == null ? void 0 : i.features.filter(
1498
- (P) => P.geometry.type === "Point" && P.properties.type === "forecast" && P.properties.category === `${l}-${u}`
1575
+ (x) => x.geometry.type === "Point" && x.properties.type === "forecast" && x.properties.category === `${l}-${u}`
1499
1576
  );
1500
- let S, v = p.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1501
- for (; S = this.pickIndex(m, v), S <= m.length - 1; ) {
1577
+ let S, b = p.clone().add(h, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1578
+ for (; S = this.pickIndex(m, b), S <= m.length - 1; ) {
1502
1579
  if (S > 0) {
1503
- const P = m[S], y = S === 0 ? void 0 : m[S - 1], M = (f / 60 - ((r = y == null ? void 0 : y.properties) == null ? void 0 : r.hour)) / (P.properties.hour - ((o = y == null ? void 0 : y.properties) == null ? void 0 : o.hour)), $ = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[0], P.geometry.coordinates[0], M), E = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[1], P.geometry.coordinates[1], M), F = T.point([$, E], {
1580
+ const x = m[S], y = S === 0 ? void 0 : m[S - 1], M = (h / 60 - ((r = y == null ? void 0 : y.properties) == null ? void 0 : r.hour)) / (x.properties.hour - ((o = y == null ? void 0 : y.properties) == null ? void 0 : o.hour)), D = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[0], x.geometry.coordinates[0], M), E = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[1], x.geometry.coordinates[1], M), F = T.point([D, E], {
1504
1581
  name: l,
1505
1582
  model: u,
1506
- category: P == null ? void 0 : P.properties.category,
1507
- date: v.format(),
1508
- format: v.format("MMM-DD/HHmm[Z]"),
1509
- gusts: this.computeNumber(y == null ? void 0 : y.properties.gusts, P.properties.gusts, M),
1510
- hour: this.computeNumber(y == null ? void 0 : y.properties.hour, P.properties.hour, M),
1511
- movement: this.computeNumber(y == null ? void 0 : y.properties.movement, P.properties.movement, M),
1512
- pressure: this.computeNumber(y == null ? void 0 : y.properties.pressure, P.properties.pressure, M),
1513
- wind: this.computeNumber(y == null ? void 0 : y.properties.wind, P.properties.wind, M),
1583
+ category: x == null ? void 0 : x.properties.category,
1584
+ date: b.format(),
1585
+ format: b.format("MMM-DD/HHmm[Z]"),
1586
+ gusts: this.computeNumber(y == null ? void 0 : y.properties.gusts, x.properties.gusts, M),
1587
+ hour: this.computeNumber(y == null ? void 0 : y.properties.hour, x.properties.hour, M),
1588
+ movement: this.computeNumber(y == null ? void 0 : y.properties.movement, x.properties.movement, M),
1589
+ pressure: this.computeNumber(y == null ? void 0 : y.properties.pressure, x.properties.pressure, M),
1590
+ wind: this.computeNumber(y == null ? void 0 : y.properties.wind, x.properties.wind, M),
1514
1591
  type: "forecast",
1515
1592
  disabled: d,
1516
1593
  showCircle: g
1517
1594
  });
1518
1595
  s.push(F);
1519
1596
  }
1520
- f += e * 60, v = p.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1597
+ h += e * 60, b = p.clone().add(h, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1521
1598
  }
1522
1599
  }
1523
1600
  return s;
@@ -1547,19 +1624,19 @@ class rt {
1547
1624
  const { t1: c, t2: i, hr: r, hours: o } = this.tropicalCenterTwin(e, 24, s);
1548
1625
  if (c && i) {
1549
1626
  if (!s.debug) {
1550
- const p = b.calculateDistance(t, c), f = b.calculateDistance(t, i);
1551
- if (p > 2 * n && f > 2 * n)
1552
- return A == null || A.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, p, f, {
1627
+ const p = v.calculateDistance(t, c), h = v.calculateDistance(t, i);
1628
+ if (p > 2 * n && h > 2 * n)
1629
+ return A == null || A.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, p, h, {
1553
1630
  from: t,
1554
1631
  t1: c,
1555
1632
  t2: i,
1556
1633
  hr: r
1557
1634
  }), {};
1558
1635
  }
1559
- const a = b.calculateBearing(t, c), l = b.calculateBearing(c, i), u = Math.abs(a - l);
1636
+ const a = v.calculateBearing(t, c), l = v.calculateBearing(c, i), u = Math.abs(a - l);
1560
1637
  let g = 0;
1561
1638
  u < 180 ? g = u + 90 : u >= 180 && (g = u - 90);
1562
- const d = b.calculateCoordinate(c, g, n);
1639
+ const d = v.calculateCoordinate(c, g, n);
1563
1640
  return A == null || A.info("[%s] the right tangent position: %j", s.requestId, {
1564
1641
  from: t,
1565
1642
  t1: c,
@@ -1586,7 +1663,7 @@ class rt {
1586
1663
  const { t1: c, t2: i, hr: r, hours: o } = this.tropicalCenterTwin(e, 24, s);
1587
1664
  if (c && i) {
1588
1665
  if (!s.debug) {
1589
- const d = b.calculateDistance(t, c), p = b.calculateDistance(t, i);
1666
+ const d = v.calculateDistance(t, c), p = v.calculateDistance(t, i);
1590
1667
  if (d > 2 * n && p > 2 * n)
1591
1668
  return A == null || A.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, d, p, {
1592
1669
  from: t,
@@ -1595,8 +1672,8 @@ class rt {
1595
1672
  hr: r
1596
1673
  }), {};
1597
1674
  }
1598
- const a = b.calculateBearing(t, c), l = b.calculateBearing(c, i), u = b.calculateDistance(t, c);
1599
- return { at: b.calculateCoordinate(c, a - l + 180, n < u ? n : u), t1: c, t2: i, hr: Number(r), hours: o };
1675
+ const a = v.calculateBearing(t, c), l = v.calculateBearing(c, i), u = v.calculateDistance(t, c);
1676
+ return { at: v.calculateCoordinate(c, a - l + 180, n < u ? n : u), t1: c, t2: i, hr: Number(r), hours: o };
1600
1677
  } else
1601
1678
  return A == null || A.info("[%s] no need drift: %j", s.requestId, { from: t, t1: c, t2: i, hr: r }), {};
1602
1679
  }
@@ -1611,24 +1688,24 @@ class rt {
1611
1688
  static tropicalCenterTwin(t, e = 24, n = {}) {
1612
1689
  var l, u, g, d, p;
1613
1690
  let s = {};
1614
- (l = t.forecasts) == null || l.forEach((f) => {
1615
- s = { ...f.hours, ...s };
1691
+ (l = t.forecasts) == null || l.forEach((h) => {
1692
+ s = { ...h.hours, ...s };
1616
1693
  });
1617
1694
  const c = ((u = t == null ? void 0 : t.history) == null ? void 0 : u[0]) || (s == null ? void 0 : s[(g = Object.keys(s)) == null ? void 0 : g[0]]);
1618
1695
  A == null || A.info("[%s] the first tropical center: %j", n.requestId, c);
1619
- let i = (d = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : e))) == null ? void 0 : d.at(-1);
1620
- i || (i = (p = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : p.at(-1));
1696
+ let i = (d = Object.keys(s || {}).filter((h) => Number(h) <= (e < 0 ? 24 : e))) == null ? void 0 : d.at(-1);
1697
+ i || (i = (p = Object.keys(s || {}).filter((h) => Number(h) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : p.at(-1));
1621
1698
  const r = s == null ? void 0 : s[i || -1];
1622
1699
  A == null || A.info("[%s] the second tropical center: %j in %d hrs", n.requestId, r, i);
1623
- const o = Object.keys(s || {}).filter((f) => Number(f) <= Number(i)), a = { 0: c };
1624
- for (const f of o)
1625
- a[f] = s[f];
1700
+ const o = Object.keys(s || {}).filter((h) => Number(h) <= Number(i)), a = { 0: c };
1701
+ for (const h of o)
1702
+ a[h] = s[h];
1626
1703
  return { t1: c, t2: r, hr: Number(i), hours: a };
1627
1704
  }
1628
1705
  static pickIndex(t, e) {
1629
1706
  let n = 0;
1630
1707
  for (const s of t) {
1631
- if (x(s.properties.date).isAfter(e))
1708
+ if (P(s.properties.date).isAfter(e))
1632
1709
  return n === 0 ? -1 : n;
1633
1710
  n++;
1634
1711
  }
@@ -1666,7 +1743,7 @@ typeof globalThis < "u" && typeof globalThis.Buffer > "u" && (globalThis.Buffer
1666
1743
  });
1667
1744
  let O;
1668
1745
  try {
1669
- O = z.getLogger("meteo");
1746
+ O = G.getLogger("meteo");
1670
1747
  } catch {
1671
1748
  } finally {
1672
1749
  }
@@ -1695,10 +1772,10 @@ class W {
1695
1772
  * @param options 步数、单位等选项
1696
1773
  */
1697
1774
  static drawCircle(t, e, n, s = {}) {
1698
- const c = (s == null ? void 0 : s.steps) ?? 64, i = (s == null ? void 0 : s.units) ?? "nauticalmiles", r = (s == null ? void 0 : s.properties) ?? {}, o = T.point([t, e]), a = T.destination(o, n, 90, { units: i }), l = x.utc();
1775
+ const c = (s == null ? void 0 : s.steps) ?? 64, i = (s == null ? void 0 : s.units) ?? "nauticalmiles", r = (s == null ? void 0 : s.properties) ?? {}, o = T.point([t, e]), a = T.destination(o, n, 90, { units: i }), l = P.utc();
1699
1776
  r.id = (s == null ? void 0 : s.id) || l.valueOf().toString();
1700
1777
  const u = "circle";
1701
- return r.name = (s == null ? void 0 : s.name) || `${u}_${l.format()}`, r.radius = n, r.center = [t, e], r.end = a.geometry.coordinates.map((g) => h.roundPrecision(g, 9)), r.units = i, r.steps = c, r.shape = "circle", O.info("[%s] draw circle with %j", s == null ? void 0 : s.requestId, r), T.circle(o, n, { steps: c, units: i, properties: r });
1778
+ return r.name = (s == null ? void 0 : s.name) || `${u}_${l.format()}`, r.radius = n, r.center = [t, e], r.end = a.geometry.coordinates.map((g) => f.roundPrecision(g, 9)), r.units = i, r.steps = c, r.shape = "circle", O.info("[%s] draw circle with %j", s == null ? void 0 : s.requestId, r), T.circle(o, n, { steps: c, units: i, properties: r });
1702
1779
  }
1703
1780
  /**
1704
1781
  * 基于turf画矩形,返回GeoJSON Feature<Polygon>
@@ -1707,11 +1784,11 @@ class W {
1707
1784
  * @param options 选项
1708
1785
  */
1709
1786
  static drawRect(t, e, n = {}) {
1710
- const s = (n == null ? void 0 : n.properties) ?? {}, c = x.utc();
1787
+ const s = (n == null ? void 0 : n.properties) ?? {}, c = P.utc();
1711
1788
  s.id = (n == null ? void 0 : n.id) || c.valueOf().toString();
1712
1789
  const i = "rect";
1713
- s.name = (n == null ? void 0 : n.name) || `${i}_${c.format()}`, s.start = t.map((l) => h.roundPrecision(l, 9)), s.end = e.map((l) => h.roundPrecision(l, 9)), s.shape = "rect", O.info("[%s] draw rect with %j", n == null ? void 0 : n.requestId, s);
1714
- const [r, o] = h.convertToMonotonicLng2([t, e]), a = [Math.min(r[0], o[0]), Math.min(r[1], o[1]), Math.max(r[0], o[0]), Math.max(r[1], o[1])];
1790
+ s.name = (n == null ? void 0 : n.name) || `${i}_${c.format()}`, s.start = t.map((l) => f.roundPrecision(l, 9)), s.end = e.map((l) => f.roundPrecision(l, 9)), s.shape = "rect", O.info("[%s] draw rect with %j", n == null ? void 0 : n.requestId, s);
1791
+ const [r, o] = f.convertToMonotonicLng2([t, e]), a = [Math.min(r[0], o[0]), Math.min(r[1], o[1]), Math.max(r[0], o[0]), Math.max(r[1], o[1])];
1715
1792
  return T.bboxPolygon(a, { properties: s });
1716
1793
  }
1717
1794
  /**
@@ -1722,11 +1799,11 @@ class W {
1722
1799
  * @returns
1723
1800
  */
1724
1801
  static drawLine(t, e = {}) {
1725
- const n = (e == null ? void 0 : e.properties) ?? {}, s = x.utc();
1802
+ const n = (e == null ? void 0 : e.properties) ?? {}, s = P.utc();
1726
1803
  n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1727
1804
  const c = "line";
1728
1805
  n.name = (e == null ? void 0 : e.name) || `${c}_${s.format()}`, n.shape = "line", O.info("[%s] draw line with %j", e == null ? void 0 : e.requestId, n);
1729
- const i = h.convertToMonotonicLng2(t);
1806
+ const i = f.convertToMonotonicLng2(t);
1730
1807
  return T.lineString(i, n);
1731
1808
  }
1732
1809
  /**
@@ -1736,11 +1813,11 @@ class W {
1736
1813
  * @returns
1737
1814
  */
1738
1815
  static drawPolygon(t, e = {}) {
1739
- const n = (e == null ? void 0 : e.properties) ?? {}, s = x.utc();
1816
+ const n = (e == null ? void 0 : e.properties) ?? {}, s = P.utc();
1740
1817
  n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1741
1818
  const c = "polygon";
1742
- n.name = (e == null ? void 0 : e.name) || `${c}_${s.format()}`, n.coordinates = t.map((r) => r.map((o) => h.roundPrecision(o, 9))), n.shape = "polygon", O.info("[%s] draw polygon with %j", e == null ? void 0 : e.requestId, n);
1743
- const i = h.convertToMonotonicLng2(t);
1819
+ n.name = (e == null ? void 0 : e.name) || `${c}_${s.format()}`, n.coordinates = t.map((r) => r.map((o) => f.roundPrecision(o, 9))), n.shape = "polygon", O.info("[%s] draw polygon with %j", e == null ? void 0 : e.requestId, n);
1820
+ const i = f.convertToMonotonicLng2(t);
1744
1821
  return T.polygon([i], n);
1745
1822
  }
1746
1823
  /**
@@ -1751,7 +1828,7 @@ class W {
1751
1828
  * @returns
1752
1829
  */
1753
1830
  static drawPoint(t, e, n = {}) {
1754
- const s = (n == null ? void 0 : n.properties) ?? {}, c = x.utc();
1831
+ const s = (n == null ? void 0 : n.properties) ?? {}, c = P.utc();
1755
1832
  s.id = (n == null ? void 0 : n.id) || c.valueOf().toString();
1756
1833
  const i = "point";
1757
1834
  return s.name = (n == null ? void 0 : n.name) || `${i}_${c.format()}`, s.shape = "point", O.info("[%s] draw point with %j", n == null ? void 0 : n.requestId, s), T.point([e, t], s);
@@ -1768,7 +1845,7 @@ class W {
1768
1845
  O.info("[%s] parse circle with %j", e == null ? void 0 : e.requestId, t.properties);
1769
1846
  const n = t.properties || {};
1770
1847
  if (n.shape == "circle") {
1771
- const i = x.utc();
1848
+ const i = P.utc();
1772
1849
  n.id = (n == null ? void 0 : n.id) || i.valueOf().toString();
1773
1850
  const r = n == null ? void 0 : n.id, o = ((s = n == null ? void 0 : n.center) == null ? void 0 : s.length) == 2 ? T.point(n.center) : T.centroid(t);
1774
1851
  let a = "center";
@@ -1798,7 +1875,7 @@ class W {
1798
1875
  O.info("[%s] parse rect with %j", e == null ? void 0 : e.requestId, t.properties);
1799
1876
  const n = t.properties || {};
1800
1877
  if (n.shape == "rect") {
1801
- const s = x.utc();
1878
+ const s = P.utc();
1802
1879
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1803
1880
  const c = n == null ? void 0 : n.id, i = t.geometry.coordinates[0], o = ["sw", "nw", "ne", "se"].map((a, l) => {
1804
1881
  const u = T.point(i[l]);
@@ -1819,7 +1896,7 @@ class W {
1819
1896
  O.info("[%s] parse line with %j", e == null ? void 0 : e.requestId, t.properties);
1820
1897
  const n = t.properties || {};
1821
1898
  if (n.shape == "line") {
1822
- const s = x.utc();
1899
+ const s = P.utc();
1823
1900
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1824
1901
  const c = n == null ? void 0 : n.id, r = t.geometry.coordinates.map((o, a) => {
1825
1902
  const l = `point_${a}`, u = T.point(o);
@@ -1840,7 +1917,7 @@ class W {
1840
1917
  O.info("[%s] parse polygon with %j", e == null ? void 0 : e.requestId, t.properties);
1841
1918
  const n = t.properties || {};
1842
1919
  if (n.shape == "polygon") {
1843
- const s = x.utc();
1920
+ const s = P.utc();
1844
1921
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1845
1922
  const c = n == null ? void 0 : n.id, r = t.geometry.coordinates[0].map((o, a) => {
1846
1923
  const l = T.point(o), u = `corner_${a}`;
@@ -1887,13 +1964,13 @@ class W {
1887
1964
  for (; l < u; ) {
1888
1965
  if (s.getUint32(l, !0) !== 33639248)
1889
1966
  throw new Error(`Invalid ZIP file: Central Directory signature mismatch at offset ${l}`);
1890
- const p = s.getUint16(l + 10, !0), f = s.getUint32(l + 20, !0), m = s.getUint16(l + 28, !0), S = s.getUint16(l + 30, !0), v = s.getUint16(l + 32, !0), P = s.getUint32(l + 42, !0), y = c.slice(l + 46, l + 46 + m), M = new TextDecoder().decode(y), $ = s.getUint16(P + 26, !0), E = s.getUint16(P + 28, !0), F = P + 30 + $ + E, R = c.slice(F, F + f);
1967
+ const p = s.getUint16(l + 10, !0), h = s.getUint32(l + 20, !0), m = s.getUint16(l + 28, !0), S = s.getUint16(l + 30, !0), b = s.getUint16(l + 32, !0), x = s.getUint32(l + 42, !0), y = c.slice(l + 46, l + 46 + m), M = new TextDecoder().decode(y), D = s.getUint16(x + 26, !0), E = s.getUint16(x + 28, !0), F = x + 30 + D + E, $ = c.slice(F, F + h);
1891
1968
  if (p === 0)
1892
- i.set(M, R);
1969
+ i.set(M, $);
1893
1970
  else if (p === 8) {
1894
1971
  if (typeof DecompressionStream < "u") {
1895
- const D = new DecompressionStream("deflate-raw"), N = D.writable.getWriter(), k = D.readable.getReader();
1896
- N.write(R), N.close();
1972
+ const R = new DecompressionStream("deflate-raw"), N = R.writable.getWriter(), k = R.readable.getReader();
1973
+ N.write($), N.close();
1897
1974
  const j = [];
1898
1975
  let U = 0;
1899
1976
  for (; ; ) {
@@ -1909,11 +1986,11 @@ class W {
1909
1986
  i.set(M, Z);
1910
1987
  } else if (typeof process < "u" && ((g = process.versions) != null && g.node))
1911
1988
  try {
1912
- i.set(M, W._inflateRawSync(R));
1989
+ i.set(M, W._inflateRawSync($));
1913
1990
  } catch {
1914
1991
  }
1915
1992
  }
1916
- l += 46 + m + S + v;
1993
+ l += 46 + m + S + b;
1917
1994
  }
1918
1995
  return i;
1919
1996
  }
@@ -1933,35 +2010,35 @@ class W {
1933
2010
  for (const a of c) {
1934
2011
  const l = {}, u = Array.from(a.querySelectorAll("ExtendedData > Data"));
1935
2012
  for (const y of u) {
1936
- const M = y.getAttribute("name"), $ = (o = (r = y.querySelector("value")) == null ? void 0 : r.textContent) == null ? void 0 : o.trim();
1937
- M && $ !== void 0 && $ !== null && (l[M] = $);
2013
+ const M = y.getAttribute("name"), D = (o = (r = y.querySelector("value")) == null ? void 0 : r.textContent) == null ? void 0 : o.trim();
2014
+ M && D !== void 0 && D !== null && (l[M] = D);
1938
2015
  }
1939
- const g = x.utc(), d = Object.keys(l).find((y) => y.toLowerCase().indexOf("name") !== -1), p = d ? l[d] : void 0, f = `${g.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, m = (y) => y.trim().split(/[\s\n]+/).filter((M) => M.length > 0).map((M) => {
1940
- const $ = M.split(",").map(Number);
1941
- return [$[0], $[1]];
2016
+ const g = P.utc(), d = Object.keys(l).find((y) => y.toLowerCase().indexOf("name") !== -1), p = d ? l[d] : void 0, h = `${g.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, m = (y) => y.trim().split(/[\s\n]+/).filter((M) => M.length > 0).map((M) => {
2017
+ const D = M.split(",").map(Number);
2018
+ return [D[0], D[1]];
1942
2019
  }), S = a.querySelector("LineString > coordinates");
1943
2020
  if (S) {
1944
2021
  const y = m(S.textContent || "");
1945
2022
  if (y.length >= 2) {
1946
- const M = T.lineString(y, { ...l, shape: "line", id: f, name: p });
2023
+ const M = T.lineString(y, { ...l, shape: "line", id: h, name: p });
1947
2024
  i.push(M);
1948
2025
  }
1949
2026
  continue;
1950
2027
  }
1951
- const v = a.querySelector("Polygon outerBoundaryIs LinearRing > coordinates");
1952
- if (v) {
1953
- const y = m(v.textContent || "");
2028
+ const b = a.querySelector("Polygon outerBoundaryIs LinearRing > coordinates");
2029
+ if (b) {
2030
+ const y = m(b.textContent || "");
1954
2031
  if (y.length >= 4) {
1955
- const M = y[0][0] === y[y.length - 1][0] && y[0][1] === y[y.length - 1][1] ? y : [...y, y[0]], $ = T.polygon([M], { ...l, shape: "polygon", id: f, name: p });
1956
- i.push($);
2032
+ const M = y[0][0] === y[y.length - 1][0] && y[0][1] === y[y.length - 1][1] ? y : [...y, y[0]], D = T.polygon([M], { ...l, shape: "polygon", id: h, name: p });
2033
+ i.push(D);
1957
2034
  }
1958
2035
  continue;
1959
2036
  }
1960
- const P = a.querySelector("Point > coordinates");
1961
- if (P) {
1962
- const y = m(P.textContent || "");
2037
+ const x = a.querySelector("Point > coordinates");
2038
+ if (x) {
2039
+ const y = m(x.textContent || "");
1963
2040
  if (y.length >= 1) {
1964
- const M = T.point(y[0], { ...l, shape: "point", id: f, name: p });
2041
+ const M = T.point(y[0], { ...l, shape: "point", id: h, name: p });
1965
2042
  i.push(M);
1966
2043
  }
1967
2044
  continue;
@@ -2021,7 +2098,7 @@ class W {
2021
2098
  typeof Buffer < "u" && Buffer.isBuffer(t) && (t = W.toArrayBuffer(t));
2022
2099
  const n = await J(t);
2023
2100
  if (Array.isArray(n)) {
2024
- const s = n.flatMap((o) => o.features || []), c = x.utc(), i = (e == null ? void 0 : e.id) || c.valueOf().toString(), r = {
2101
+ const s = n.flatMap((o) => o.features || []), c = P.utc(), i = (e == null ? void 0 : e.id) || c.valueOf().toString(), r = {
2025
2102
  Point: "point",
2026
2103
  MultiPoint: "point",
2027
2104
  LineString: "line",
@@ -2033,7 +2110,7 @@ class W {
2033
2110
  var p;
2034
2111
  const l = ((p = o.geometry) == null ? void 0 : p.type) || "", u = r[l] || l.toLowerCase();
2035
2112
  o.properties = o.properties || {}, o.properties.shape = u, o.properties.parentId = i, o.properties.id = `${i}_${a}`;
2036
- const g = Object.keys(o.properties).find((f) => f.toLowerCase().indexOf("name") !== -1), d = g ? o.properties[g] : void 0;
2113
+ const g = Object.keys(o.properties).find((h) => h.toLowerCase().indexOf("name") !== -1), d = g ? o.properties[g] : void 0;
2037
2114
  o.properties.name = d || `${u}_${c.format()}_${a}`;
2038
2115
  }), T.featureCollection(s);
2039
2116
  }
@@ -2046,7 +2123,7 @@ class W {
2046
2123
  export {
2047
2124
  K as AisHelper,
2048
2125
  W as GeoJsonHelper,
2049
- b as LaneHelper,
2050
- h as LngLatHelper,
2126
+ v as LaneHelper,
2127
+ f as LngLatHelper,
2051
2128
  rt as TropicalHelper
2052
2129
  };