@idm-plugin/geo 2.2.5 → 2.2.7

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,6 +1,6 @@
1
1
  import * as T from "@turf/turf";
2
- import b from "moment";
3
- import G from "@log4js-node/log4js-api";
2
+ import x from "moment";
3
+ import z from "@log4js-node/log4js-api";
4
4
  import "moment-timezone";
5
5
  import V from "tz-lookup";
6
6
  import J from "shpjs";
@@ -12,7 +12,7 @@ class d {
12
12
  */
13
13
  static guessTimeZoneOffset(t, e) {
14
14
  t = d.convertToStdLng(t);
15
- const n = V(e, t), s = b().tz(n).utcOffset();
15
+ const n = V(e, t), s = x().tz(n).utcOffset();
16
16
  return d.roundPrecision(s / 60, 1);
17
17
  }
18
18
  /**
@@ -35,13 +35,13 @@ class d {
35
35
  t < 0 && (s = "W"), t = Math.abs(t), n = n.toUpperCase();
36
36
  let o = t * 3600, r, i, c, a, l, u;
37
37
  r = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - r, i = d.padNumber(r, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = d.roundPrecision(c, e).toString().padStart(2, "0") : a = d.padNumber(c, 2, 3), o = o - c * 60), l = o / 3600, n.indexOf("M") !== -1 ? u = d.roundPrecision(l, e).toString().padStart(3, "0") : u = d.padNumber(l, 3, 6), Number(i) >= 60 && (a = Number(a) + 1, i = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
38
- const f = `${n.replace(/S+/gi, i).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
38
+ const m = `${n.replace(/S+/gi, i).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
39
39
  return {
40
40
  direction: s,
41
41
  degree: d.roundPrecision(l, e),
42
42
  minute: d.roundPrecision(c, e),
43
43
  second: d.roundPrecision(r, e),
44
- pretty: f,
44
+ pretty: m,
45
45
  S: i,
46
46
  M: a,
47
47
  H: u
@@ -59,13 +59,13 @@ class d {
59
59
  t < 0 && (s = "S"), t = Math.abs(t), n = n.toUpperCase();
60
60
  let o = t * 3600, r, i, c, a, l, u;
61
61
  r = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - r, i = d.padNumber(r, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = d.roundPrecision(c, e).toString().padStart(2, "0") : a = d.padNumber(c, 2, 3), o = o - c * 60), l = o / 3600, n.indexOf("M") !== -1 ? u = d.roundPrecision(l, e).toString().padStart(2, "0") : u = d.padNumber(l, 2, 6), Number(i) >= 60 && (a = Number(a) + 1, i = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
62
- const f = `${n.replace(/S+/gi, i).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
62
+ const m = `${n.replace(/S+/gi, i).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
63
63
  return {
64
64
  direction: s,
65
65
  degree: d.roundPrecision(l, e),
66
66
  minute: d.roundPrecision(c, e),
67
67
  second: d.roundPrecision(r, e),
68
- pretty: f,
68
+ pretty: m,
69
69
  S: i,
70
70
  M: a,
71
71
  H: u
@@ -170,7 +170,7 @@ class K {
170
170
  return `${t.lat}|${t.lng}|${t.positionTime}|${t.sog}|${t.cog}|${t.hdg}|${t.draught}|${e}|${JSON.stringify(t.meteo || {})}|${t.vendor}|${t.deleted}`;
171
171
  }
172
172
  static str2Json(t) {
173
- const [e, n, s, o, r, i, c, a, l, u, f] = t.split("|");
173
+ const [e, n, s, o, r, i, c, a, l, u, m] = t.split("|");
174
174
  return {
175
175
  lat: Number(e),
176
176
  lng: Number(n),
@@ -184,7 +184,7 @@ class K {
184
184
  important: a !== "A",
185
185
  meteo: l ? JSON.parse(l) : void 0,
186
186
  vendor: u,
187
- deleted: f === "true"
187
+ deleted: m === "true"
188
188
  };
189
189
  }
190
190
  static inspectStoppages(t, e = 1, n = !0) {
@@ -196,12 +196,12 @@ class K {
196
196
  const a = t[c];
197
197
  if (!(n && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(a.type))) {
198
198
  for (let l = c + 1; l < t.length; l++) {
199
- const u = t[l - 1], f = t[l];
199
+ const u = t[l - 1], m = t[l];
200
200
  if (n && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(a.type))
201
201
  continue;
202
- const h = f.positionTime - u.positionTime;
203
- if (v.calculateDistance(f, u, !0, 4) / (h / 3600) < e)
204
- r || (r = a), l === t.length - 1 && (i = f, c = l);
202
+ const h = m.positionTime - u.positionTime;
203
+ if (v.calculateDistance(m, u, !0, 4) / (h / 3600) < e)
204
+ r || (r = a), l === t.length - 1 && (i = m, c = l);
205
205
  else {
206
206
  r && (i = t[l - 1], c = l);
207
207
  break;
@@ -214,18 +214,18 @@ class K {
214
214
  lng: r.lng,
215
215
  sog: r.sog,
216
216
  positionTime: r.positionTime,
217
- utc: b.unix(r.positionTime).utc().format()
217
+ utc: x.unix(r.positionTime).utc().format()
218
218
  },
219
219
  end: {
220
220
  lat: i.lat,
221
221
  lng: i.lng,
222
222
  sog: i.sog,
223
223
  positionTime: i.positionTime,
224
- utc: b.unix(i.positionTime).utc().format()
224
+ utc: x.unix(i.positionTime).utc().format()
225
225
  },
226
226
  duration: i.positionTime - r.positionTime
227
- }, u = t.filter((h) => h.positionTime >= l.start.positionTime && h.positionTime <= l.end.positionTime), f = v.divideAccordingToLng(u);
228
- l.distance = v.calculateRouteDistance(f), l.hours = Math.round(l.duration / 3600 * 10) / 10, l.avgSog = Math.round(l.distance / l.hours * 10) / 10, o.push(l);
227
+ }, u = t.filter((h) => h.positionTime >= l.start.positionTime && h.positionTime <= l.end.positionTime), m = v.divideAccordingToLng(u);
228
+ l.distance = v.calculateRouteDistance(m), l.hours = Math.round(l.duration / 3600 * 10) / 10, l.avgSog = Math.round(l.distance / l.hours * 10) / 10, o.push(l);
229
229
  }
230
230
  r = void 0, i = void 0;
231
231
  }
@@ -239,12 +239,12 @@ class K {
239
239
  * @param etm
240
240
  */
241
241
  static inspectSummary(t, e, n) {
242
- const s = b(e), o = b(n), r = t.filter((l) => l.positionTime >= s.unix() && l.positionTime <= o.unix());
242
+ const s = x(e), o = x(n), r = t.filter((l) => l.positionTime >= s.unix() && l.positionTime <= o.unix());
243
243
  let i = 0, c = 0;
244
244
  if (r.length > 1)
245
245
  for (let l = 0; l < r.length - 1; l++) {
246
- const u = r[l], f = r[l + 1];
247
- i += v.calculateDistance(u, f, !0, 4), c += Math.abs(f.positionTime - u.positionTime);
246
+ const u = r[l], m = r[l + 1];
247
+ i += v.calculateDistance(u, m, !0, 4), c += Math.abs(m.positionTime - u.positionTime);
248
248
  }
249
249
  i = Math.round(i * 100) / 100, c = Math.round(c / 3600 * 100) / 100;
250
250
  const a = c ? Math.round(i / c * 100) / 100 : 0;
@@ -253,11 +253,11 @@ class K {
253
253
  }
254
254
  let X;
255
255
  try {
256
- X = G.getLogger("meteo");
256
+ X = z.getLogger("meteo");
257
257
  } catch {
258
258
  } finally {
259
259
  }
260
- const Q = (() => {
260
+ const Y = (() => {
261
261
  const C = new Uint32Array(256);
262
262
  for (let t = 0; t < 256; t++) {
263
263
  let e = t;
@@ -267,36 +267,36 @@ const Q = (() => {
267
267
  }
268
268
  return C;
269
269
  })();
270
- function Y(C) {
270
+ function Q(C) {
271
271
  let t = 4294967295;
272
272
  for (let e = 0; e < C.length; e++)
273
- t = Q[(t ^ C[e]) & 255] ^ t >>> 8;
273
+ t = Y[(t ^ C[e]) & 255] ^ t >>> 8;
274
274
  return (t ^ 4294967295) >>> 0;
275
275
  }
276
276
  function _(C) {
277
277
  const t = new TextEncoder(), e = [], n = [];
278
278
  let s = 0;
279
279
  for (const h of C) {
280
- const g = t.encode(h.name), m = Y(h.data), p = new Uint8Array(30 + g.length), S = new DataView(p.buffer);
281
- S.setUint32(0, 67324752, !0), S.setUint16(4, 20, !0), S.setUint16(8, 0, !0), S.setUint32(14, m, !0), S.setUint32(18, h.data.length, !0), S.setUint32(22, h.data.length, !0), S.setUint16(26, g.length, !0), p.set(g, 30), e.push({ nameBytes: g, data: h.data, crc: m, offset: s }), s += p.length + h.data.length, n.push(p, h.data);
280
+ const p = t.encode(h.name), f = Q(h.data), g = new Uint8Array(30 + p.length), S = new DataView(g.buffer);
281
+ S.setUint32(0, 67324752, !0), S.setUint16(4, 20, !0), S.setUint16(8, 0, !0), S.setUint32(14, f, !0), S.setUint32(18, h.data.length, !0), S.setUint32(22, h.data.length, !0), S.setUint16(26, p.length, !0), g.set(p, 30), e.push({ nameBytes: p, data: h.data, crc: f, offset: s }), s += g.length + h.data.length, n.push(g, h.data);
282
282
  }
283
283
  const o = s, r = [];
284
284
  let i = 0;
285
285
  for (const h of e) {
286
- const g = new Uint8Array(46 + h.nameBytes.length), m = new DataView(g.buffer);
287
- m.setUint32(0, 33639248, !0), m.setUint16(4, 20, !0), m.setUint16(6, 20, !0), m.setUint16(10, 0, !0), m.setUint32(16, h.crc, !0), m.setUint32(20, h.data.length, !0), m.setUint32(24, h.data.length, !0), m.setUint16(28, h.nameBytes.length, !0), m.setUint32(42, h.offset, !0), g.set(h.nameBytes, 46), i += g.length, r.push(g);
286
+ const p = new Uint8Array(46 + h.nameBytes.length), f = new DataView(p.buffer);
287
+ f.setUint32(0, 33639248, !0), f.setUint16(4, 20, !0), f.setUint16(6, 20, !0), f.setUint16(10, 0, !0), f.setUint32(16, h.crc, !0), f.setUint32(20, h.data.length, !0), f.setUint32(24, h.data.length, !0), f.setUint16(28, h.nameBytes.length, !0), f.setUint32(42, h.offset, !0), p.set(h.nameBytes, 46), i += p.length, r.push(p);
288
288
  }
289
289
  const c = new Uint8Array(22), a = new DataView(c.buffer);
290
290
  a.setUint32(0, 101010256, !0), a.setUint16(8, e.length, !0), a.setUint16(10, e.length, !0), a.setUint32(12, i, !0), a.setUint32(16, o, !0);
291
- const l = n.reduce((h, g) => h + g.length, 0) + i + 22, u = new Uint8Array(l);
292
- let f = 0;
291
+ const l = n.reduce((h, p) => h + p.length, 0) + i + 22, u = new Uint8Array(l);
292
+ let m = 0;
293
293
  for (const h of n)
294
- u.set(h, f), f += h.length;
294
+ u.set(h, m), m += h.length;
295
295
  for (const h of r)
296
- u.set(h, f), f += h.length;
297
- return u.set(c, f), u;
296
+ u.set(h, m), m += h.length;
297
+ return u.set(c, m), u;
298
298
  }
299
- function z(C) {
299
+ function G(C) {
300
300
  let t = "", e = C;
301
301
  for (; e >= 0; )
302
302
  t = String.fromCharCode(65 + e % 26) + t, e = Math.floor(e / 26) - 1;
@@ -413,19 +413,19 @@ class v {
413
413
  [r, t[c].lat],
414
414
  [i, t[c + 1].lat]
415
415
  ]);
416
- let u, f;
417
- e ? (u = T.lineString(l), f = T.lineString([
416
+ let u, m;
417
+ e ? (u = T.lineString(l), m = T.lineString([
418
418
  [a > 0 ? 180 : -180, 89],
419
419
  [a > 0 ? 180 : -180, -89]
420
- ])) : (u = T.greatCircle(l[0], l[1]), f = T.greatCircle([a > 0 ? 180 : -180, 89], [a > 0 ? 180 : -180, -89]));
421
- const h = T.lineIntersect(u, f);
422
- let g;
420
+ ])) : (u = T.greatCircle(l[0], l[1]), m = T.greatCircle([a > 0 ? 180 : -180, 89], [a > 0 ? 180 : -180, -89]));
421
+ const h = T.lineIntersect(u, m);
422
+ let p;
423
423
  if (h.features.length) {
424
- const m = T.getCoord(h.features[0]);
425
- g = d.roundPrecision(m[1], 8);
424
+ const f = T.getCoord(h.features[0]);
425
+ p = d.roundPrecision(f[1], 8);
426
426
  } else
427
- g = t[c].lat;
428
- a > 0 ? (s.push([180 - 1e-6, g]), o.push([...s]), s = [], s.push([-(180 - 1e-6), g])) : (s.push([-(180 - 1e-6), g]), o.push([...s]), s = [], s.push([180 - 1e-6, g]));
427
+ p = t[c].lat;
428
+ a > 0 ? (s.push([180 - 1e-6, p]), o.push([...s]), s = [], s.push([-(180 - 1e-6), p])) : (s.push([-(180 - 1e-6), p]), o.push([...s]), s = [], s.push([180 - 1e-6, p]));
429
429
  }
430
430
  c === t.length - 2 && s.push([i, t[c + 1].lat]);
431
431
  }
@@ -489,8 +489,8 @@ class v {
489
489
  let n = Number.MAX_VALUE, s = 0, o = 0, r, i;
490
490
  return e.forEach((c, a) => {
491
491
  for (let l = 0; l < c.length - 1; l++) {
492
- const u = { lng: c[l][0], lat: c[l][1] }, f = { lng: c[l + 1][0], lat: c[l + 1][1] }, h = this.calculatePointToLineDistance(t, u, f);
493
- n > h && (n = h, o = l, s = a, r = this.calculateDistance(u, t), i = this.calculateDistance(f, t));
492
+ const u = { lng: c[l][0], lat: c[l][1] }, m = { lng: c[l + 1][0], lat: c[l + 1][1] }, h = this.calculatePointToLineDistance(t, u, m);
493
+ n > h && (n = h, o = l, s = a, r = this.calculateDistance(u, t), i = this.calculateDistance(m, t));
494
494
  }
495
495
  }), r !== 0 && i !== 0 ? e[s].splice(o + 1, 0, [t.lng, t.lat]) : r === 0 ? e[s].splice(o, 1, [t.lng, t.lat]) : i === 0 && e[s].splice(o + 1, 1, [t.lng, t.lat]), e;
496
496
  }
@@ -693,8 +693,8 @@ class v {
693
693
  c.lng = d.convertToStdLng(c.lng);
694
694
  const l = e[a + 1];
695
695
  if (l && ((c.bearing === null || c.bearing === void 0) && ((c.positionTime || 0) > (l.positionTime || 0) ? c.bearing = this.calculateBearing(l, c, !0) : c.bearing = this.calculateBearing(c, l, !0)), c.cog = c.cog || c.bearing, !c.sog && c.positionTime && l.positionTime)) {
696
- const u = this.calculateDistance(c, l, !0), f = Math.abs(l.positionTime - c.positionTime) / 3600;
697
- c.sog = d.roundPrecision(u / f, 2);
696
+ const u = this.calculateDistance(c, l, !0), m = Math.abs(l.positionTime - c.positionTime) / 3600;
697
+ c.sog = d.roundPrecision(u / m, 2);
698
698
  }
699
699
  return c;
700
700
  });
@@ -757,37 +757,37 @@ class v {
757
757
  * @return { coordinate: {lng, lat}, route: [[[lng, lat]]]}
758
758
  */
759
759
  static calculateNextCoordinateAlongRoute(t, e, n, s = "nauticalmiles") {
760
- var f;
760
+ var m;
761
761
  const o = t.speed || 12, r = [];
762
762
  let i = [], c = !1, a = 0, l = 0, u;
763
- if (e && n.length ? (r.push(t), n.forEach((h, g) => {
763
+ if (e && n.length ? (r.push(t), n.forEach((h, p) => {
764
764
  if (c)
765
765
  i.push(h);
766
766
  else {
767
- const m = [];
768
- let p;
767
+ const f = [];
768
+ let g;
769
769
  for (let S = 0; S < h.length; S++)
770
770
  if (u)
771
- m.push(h[S]);
771
+ f.push(h[S]);
772
772
  else {
773
- p = { lng: h[S][0], lat: h[S][1] };
774
- const x = this.calculateDistance(t, p, !0, 8, s);
775
- if (a += x, a < e)
776
- l += x, x && r.push(p), t = p;
773
+ g = { lng: h[S][0], lat: h[S][1] };
774
+ const P = this.calculateDistance(t, g, !0, 8, s);
775
+ if (a += P, a < e)
776
+ l += P, P && r.push(g), t = g;
777
777
  else {
778
778
  if (l = e, a === e)
779
- u = p, m.push([u.lng, u.lat]);
779
+ u = g, f.push([u.lng, u.lat]);
780
780
  else {
781
- const M = a - e, y = this.calculateBearing(p, t);
782
- u = this.calculateCoordinate(p, y, M, s), m.push([u.lng, u.lat]), m.push([p.lng, p.lat]);
781
+ const N = a - e, y = this.calculateBearing(g, t);
782
+ u = this.calculateCoordinate(g, y, N, s), f.push([u.lng, u.lat]), f.push([g.lng, g.lat]);
783
783
  }
784
784
  c = !0;
785
785
  }
786
786
  }
787
- m.length && i.push(m), g === n.length - 1 && !u && (u = p);
787
+ f.length && i.push(f), p === n.length - 1 && !u && (u = g);
788
788
  }
789
789
  })) : (i = n, u = { ...t }), u)
790
- if (r.push(u), u.distanceFromPrevious = Math.round(l * 1e4) / 1e4, u.hourFromPrevious = Math.round(l / o * 1e4) / 1e4, ((f = i[0]) == null ? void 0 : f.length) > 1) {
790
+ if (r.push(u), u.distanceFromPrevious = Math.round(l * 1e4) / 1e4, u.hourFromPrevious = Math.round(l / o * 1e4) / 1e4, ((m = i[0]) == null ? void 0 : m.length) > 1) {
791
791
  const h = { lng: i[0][1][0], lat: i[0][1][1] };
792
792
  u.bearing = this.calculateBearing(u, h);
793
793
  } else
@@ -804,8 +804,8 @@ class v {
804
804
  const s = d.convertToStdLng(t.lng, 6), o = T.point([s, t.lat]), r = d.convertToStdLng(e.lng, 6), i = d.convertToStdLng(n.lng, 6), c = T.lineString([
805
805
  [r, e.lat],
806
806
  [i, n.lat]
807
- ]), a = T.nearestPointOnLine(c, o), l = T.getCoord(a), u = d.roundPrecision(l[0], 6), f = d.roundPrecision(l[1], 6);
808
- return { lng: u, lat: f, inline: !(u === r && f === e.lat) && !(u === i && f === n.lat) };
807
+ ]), a = T.nearestPointOnLine(c, o), l = T.getCoord(a), u = d.roundPrecision(l[0], 6), m = d.roundPrecision(l[1], 6);
808
+ return { lng: u, lat: m, inline: !(u === r && m === e.lat) && !(u === i && m === n.lat) };
809
809
  }
810
810
  /**
811
811
  * 将route转coordinate
@@ -919,8 +919,8 @@ class v {
919
919
  const r = t[o - 1], i = t[o], c = t[o + 1];
920
920
  let a = !1, l = !1;
921
921
  if ((r.velocity || r.suspend || r.important || r.pilot || o === 1) && (a = !0, s.push(r)), i.gcToPrevious && (a || (a = !0, s.push(r)), l = !0, s.push(i), o++), c) {
922
- const u = v.calculateDistance(r, i, !0), f = v.calculateDistance(i, c, !0), h = v.calculateDistance(r, c, !0), g = (Math.pow(u, 2) + Math.pow(f, 2) - Math.pow(h, 2)) / (2 * u * f);
923
- Math.round(Math.acos(g) * 180 / Math.PI) < n && h > e && !l && (s.push(i), o++);
922
+ const u = v.calculateDistance(r, i, !0), m = v.calculateDistance(i, c, !0), h = v.calculateDistance(r, c, !0), p = (Math.pow(u, 2) + Math.pow(m, 2) - Math.pow(h, 2)) / (2 * u * m);
923
+ Math.round(Math.acos(p) * 180 / Math.PI) < n && h > e && !l && (s.push(i), o++);
924
924
  }
925
925
  if (o >= t.length - 1) {
926
926
  const u = t.at(-1);
@@ -936,7 +936,7 @@ class v {
936
936
  * @param waypoints 带时间的轨迹, 单位秒
937
937
  */
938
938
  static nearestTSPointInWaypoints(t, e, n) {
939
- const s = b.unix(t), o = n.filter(
939
+ const s = x.unix(t), o = n.filter(
940
940
  (r) => s.clone().subtract(e, "hour").unix() <= (r.positionTime || 0) && s.clone().add(e, "h").unix() >= (r.positionTime || 0)
941
941
  );
942
942
  return o.sort((r, i) => (r.positionTime || 0) - (i.positionTime || 0)), o.at(-1);
@@ -949,15 +949,15 @@ class v {
949
949
  static deadReckoning(t, e) {
950
950
  var o, r, i, c;
951
951
  t > 1e12 && (t = Math.round(t / 1e3));
952
- const n = b.unix(t);
952
+ const n = x.unix(t);
953
953
  let s = e.find((a) => a.positionTime === n.unix());
954
954
  if (!s) {
955
- const a = (r = (o = e.filter((u) => (u == null ? void 0 : u.positionTime) < n.unix())) == null ? void 0 : o.sort((u, f) => (u.positionTime || 0) - (f.positionTime || 0))) == null ? void 0 : r.at(-1), l = (c = (i = e.filter((u) => (u == null ? void 0 : u.positionTime) > n.unix())) == null ? void 0 : i.sort((u, f) => (u.positionTime || 0) - (f.positionTime || 0))) == null ? void 0 : c.at(0);
955
+ const a = (r = (o = e.filter((u) => (u == null ? void 0 : u.positionTime) < n.unix())) == null ? void 0 : o.sort((u, m) => (u.positionTime || 0) - (m.positionTime || 0))) == null ? void 0 : r.at(-1), l = (c = (i = e.filter((u) => (u == null ? void 0 : u.positionTime) > n.unix())) == null ? void 0 : i.sort((u, m) => (u.positionTime || 0) - (m.positionTime || 0))) == null ? void 0 : c.at(0);
956
956
  if (a && l) {
957
- const u = v.calculateBearing(a, l, !0), f = v.calculateDistance(a, l), h = (n.unix() - a.positionTime) / (l.positionTime - a.positionTime);
958
- s = v.calculateCoordinate(a, u, f * h), s.positionTime = n.unix(), s.utc = n.utc().format(), s.cog = u, s.sog = Math.round(f / ((l.positionTime - a.positionTime) / 3600) * 100) / 100;
957
+ const u = v.calculateBearing(a, l, !0), m = v.calculateDistance(a, l), h = (n.unix() - a.positionTime) / (l.positionTime - a.positionTime);
958
+ s = v.calculateCoordinate(a, u, m * h), s.positionTime = n.unix(), s.utc = n.utc().format(), s.cog = u, s.sog = Math.round(m / ((l.positionTime - a.positionTime) / 3600) * 100) / 100;
959
959
  } else
960
- s = a || l, s && (s.utc = b.unix(s == null ? void 0 : s.positionTime).utc().format());
960
+ s = a || l, s && (s.utc = x.unix(s == null ? void 0 : s.positionTime).utc().format());
961
961
  }
962
962
  return s;
963
963
  }
@@ -970,8 +970,8 @@ class v {
970
970
  e = JSON.parse(JSON.stringify(e)), e.sort((a, l) => (a.positionTime || 0) - (l.positionTime || 0));
971
971
  let n = Number.MAX_SAFE_INTEGER, s = Number.MAX_SAFE_INTEGER;
972
972
  for (let a = 0; a < e.length - 1; a++) {
973
- const l = e[a], u = e[a + 1], f = v.calculatePointToLineDistance(t, l, u);
974
- f < n && (n = f, s = a);
973
+ const l = e[a], u = e[a + 1], m = v.calculatePointToLineDistance(t, l, u);
974
+ m < n && (n = m, s = a);
975
975
  }
976
976
  const o = e[s], r = e[s + 1], i = v.calculateDistance(o, t), c = v.calculateDistance(r, t);
977
977
  if (i === 0)
@@ -982,7 +982,7 @@ class v {
982
982
  const a = o.positionTime || 0, l = r.positionTime || 0, u = v.calculateDistance(o, r);
983
983
  t.positionTime = Math.round(a + (l - a) * (i / u));
984
984
  }
985
- return t.utc = t.positionTime ? b.unix(t.positionTime).utc().format() : void 0, t.positionTime ? t : void 0;
985
+ return t.utc = t.positionTime ? x.unix(t.positionTime).utc().format() : void 0, t.positionTime ? t : void 0;
986
986
  }
987
987
  /**
988
988
  * 翻转轨迹
@@ -1047,7 +1047,7 @@ class v {
1047
1047
  u.push(` <time>${v.xmlEscape(r.utc)}</time>`);
1048
1048
  else if (r.positionTime)
1049
1049
  try {
1050
- u.push(` <time>${v.xmlEscape(b.unix(r.positionTime).utc().format())}</time>`);
1050
+ u.push(` <time>${v.xmlEscape(x.unix(r.positionTime).utc().format())}</time>`);
1051
1051
  } catch {
1052
1052
  }
1053
1053
  r.cog !== void 0 && u.push(` <cog>${v.xmlEscape(r.cog)}</cog>`), r.sog !== void 0 && u.push(` <sog>${v.xmlEscape(r.sog)}</sog>`), u.length && (s.push(" <extensions>"), s.push(...u), s.push(" </extensions>"));
@@ -1065,15 +1065,70 @@ class v {
1065
1065
  */
1066
1066
  static waypoints2CSV(t, e, n) {
1067
1067
  X.debug("keep name for waypoints2CSV for legacy compatibility only", t);
1068
- const s = (n == null ? void 0 : n.precision) ?? 6, o = e.some((p) => p.name), r = e.some((p) => p.description), i = e.some((p) => p.port != null), c = e.some((p) => p.stbd != null), a = e.some((p) => p.arrRad != null), l = e.some((p) => p.speed != null), u = e.some((p, S) => S > 0 && p.gcToPrevious != null), f = e.some((p) => p.bearing != null), h = e.some((p) => p.distanceFromPrevious != null), g = ["WPT No.", "Latitude", "Longitude"];
1069
- o && g.push("Name"), r && g.push("Description"), u && g.push("Leg"), f && g.push("Bearing[deg]"), h && g.push("Distance[NM]"), l && g.push("Speed[kn]"), i && g.push("PORT XTD[NM]"), c && g.push("STBD XTD[NM]"), a && g.push("Arr.Rad[NM]");
1070
- const m = [];
1071
- m.push(g.map((p) => v.csvEscapeField(p)).join(","));
1072
- for (let p = 0; p < e.length; p++) {
1073
- const S = e[p], x = [];
1074
- x.push((p + 1).toString()), x.push(S.lat.toFixed(s)), x.push(S.lng.toFixed(s)), o && x.push(S.name ?? ""), r && x.push(S.description ?? ""), u && x.push(p === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), f && x.push(S.bearing != null ? String(S.bearing) : ""), h && x.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), l && x.push(S.speed != null ? String(S.speed) : ""), i && x.push(S.port != null ? String(S.port) : ""), c && x.push(S.stbd != null ? String(S.stbd) : ""), a && x.push(S.arrRad != null ? String(S.arrRad) : ""), m.push(x.map((M) => v.csvEscapeField(M)).join(","));
1068
+ const s = (n == null ? void 0 : n.precision) ?? 6, o = e.some((g) => g.name), r = e.some((g) => g.description), i = e.some((g) => g.port != null), c = e.some((g) => g.stbd != null), a = e.some((g) => g.arrRad != null), l = e.some((g) => g.speed != null), u = e.some((g, S) => S > 0 && g.gcToPrevious != null), m = e.some((g) => g.bearing != null), h = e.some((g) => g.distanceFromPrevious != null), p = ["WPT No.", "Latitude", "Longitude"];
1069
+ o && p.push("Name"), r && p.push("Description"), u && p.push("Leg"), m && p.push("Bearing[deg]"), h && p.push("Distance[NM]"), l && p.push("Speed[kn]"), i && p.push("PORT XTD[NM]"), c && p.push("STBD XTD[NM]"), a && p.push("Arr.Rad[NM]");
1070
+ const f = [];
1071
+ f.push(p.map((g) => v.csvEscapeField(g)).join(","));
1072
+ for (let g = 0; g < e.length; g++) {
1073
+ const S = e[g], P = [];
1074
+ P.push((g + 1).toString()), P.push(S.lat.toFixed(s)), P.push(S.lng.toFixed(s)), o && P.push(S.name ?? ""), r && P.push(S.description ?? ""), u && P.push(g === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), m && P.push(S.bearing != null ? String(S.bearing) : ""), h && P.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), l && P.push(S.speed != null ? String(S.speed) : ""), i && P.push(S.port != null ? String(S.port) : ""), c && P.push(S.stbd != null ? String(S.stbd) : ""), a && P.push(S.arrRad != null ? String(S.arrRad) : ""), f.push(P.map((N) => v.csvEscapeField(N)).join(","));
1075
+ }
1076
+ return f.join(`
1077
+ `);
1078
+ }
1079
+ /**
1080
+ * 路径导出为 JRC ECDIS CSV 格式
1081
+ * 符合 JRC ECDIS 路由表导入/导出规范
1082
+ * @param name 航线名称
1083
+ * @param waypoints 途径点
1084
+ * @param options.precision 经纬度分钟小数位数,默认3
1085
+ */
1086
+ static waypoints2JRCCSV(t, e, n) {
1087
+ const s = (n == null ? void 0 : n.precision) ?? 3, o = e.some((f) => f.name), r = e.some((f) => f.port != null), i = e.some((f) => f.stbd != null), c = e.some((f) => f.arrRad != null), a = e.some((f) => f.speed != null), l = e.some((f, g) => g > 0 && f.gcToPrevious != null), u = e.some((f) => f.rot != null), m = e.some((f) => f.turnRad != null), h = ["// WPT No.", "LAT", "", "", "LON", "", ""];
1088
+ r && h.push("PORT[NM]"), i && h.push("STBD[NM]"), c && h.push("Arr. Rad[NM]"), a && h.push("Speed[kn]"), l && h.push("Sail(RL/GC)"), u && h.push("ROT[deg/min]"), m && h.push("Turn Rad[NM]"), o && h.push("Name");
1089
+ const p = [];
1090
+ 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(h.join(","));
1091
+ for (let f = 0; f < e.length; f++) {
1092
+ const g = [], S = e[f], P = String(f).padStart(3, "0");
1093
+ g.push(P);
1094
+ const N = d.lat2pretty(S.lat, 6), y = d.lng2pretty(S.lng, 6), M = N.H, O = Number(N.minute).toFixed(s), U = N.direction;
1095
+ g.push(M), g.push(O), g.push(U);
1096
+ const E = y.H, B = Number(y.minute).toFixed(s), k = y.direction;
1097
+ if (g.push(E), g.push(B), g.push(k), r) {
1098
+ const b = f === 0 ? "***" : S.port != null ? String(S.port) : "***";
1099
+ g.push(b);
1100
+ }
1101
+ if (i) {
1102
+ const b = f === 0 ? "***" : S.stbd != null ? String(S.stbd) : "***";
1103
+ g.push(b);
1104
+ }
1105
+ if (c) {
1106
+ const b = f === 0 ? "***" : S.arrRad != null ? String(S.arrRad) : "***";
1107
+ g.push(b);
1108
+ }
1109
+ if (a) {
1110
+ const b = f === 0 ? "***" : S.speed != null ? Number(S.speed).toFixed(1).padStart(5, "0") : "***";
1111
+ g.push(b);
1112
+ }
1113
+ if (l) {
1114
+ const b = f === 0 ? "***" : S.gcToPrevious ? "GC" : "RL";
1115
+ g.push(b);
1116
+ }
1117
+ if (u) {
1118
+ const b = f === 0 ? "***" : S.rot != null ? String(S.rot) : "***";
1119
+ g.push(b);
1120
+ }
1121
+ if (m) {
1122
+ const b = f === 0 ? "***" : S.turnRad != null ? String(S.turnRad) : "***";
1123
+ g.push(b);
1124
+ }
1125
+ if (o) {
1126
+ const b = f === 0 ? "***" : S.name ?? "";
1127
+ g.push(b);
1128
+ }
1129
+ p.push(g.join(","));
1075
1130
  }
1076
- return m.join(`
1131
+ return p.join(`
1077
1132
  `);
1078
1133
  }
1079
1134
  /**
@@ -1088,26 +1143,26 @@ class v {
1088
1143
  * @returns Uint8Array 二进制数据,可直接用于 new Blob([result], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
1089
1144
  */
1090
1145
  static waypoints2XLSX(t, e, n) {
1091
- const s = (n == null ? void 0 : n.precision) ?? 6, o = t || "Route", r = e.some((P) => P.name), i = e.some((P) => P.description), c = e.some((P) => P.port != null), a = e.some((P) => P.stbd != null), l = e.some((P) => P.arrRad != null), u = e.some((P) => P.speed != null), f = e.some((P, I) => I > 0 && P.gcToPrevious != null), h = e.some((P) => P.bearing != null), g = e.some((P) => P.distanceFromPrevious != null), m = ["WPT No.", "Latitude", "Longitude"];
1092
- r && m.push("Name"), i && m.push("Description"), f && m.push("Leg"), h && m.push("Bearing[deg]"), g && m.push("Distance[NM]"), u && m.push("Speed[kn]"), c && m.push("PORT XTD[NM]"), a && m.push("STBD XTD[NM]"), l && m.push("Arr.Rad[NM]");
1093
- const p = (P) => P == null ? "" : String(P).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1094
- let x = `<row r="1">${m.map((P, I) => `<c r="${z(I)}1" s="1" t="inlineStr"><is><t>${p(P)}</t></is></c>`).join("")}</row>`;
1095
- for (let P = 0; P < e.length; P++) {
1096
- const I = e[P], E = P + 2, B = [], Z = (W, j) => B.push(`<c r="${z(W)}${E}"><v>${j}</v></c>`), A = (W, j) => B.push(`<c r="${z(W)}${E}" t="inlineStr"><is><t>${p(j)}</t></is></c>`), k = (W, j) => {
1097
- j != null ? Z(W, j) : A(W, "");
1146
+ const s = (n == null ? void 0 : n.precision) ?? 6, o = t || "Route", r = e.some((b) => b.name), i = e.some((b) => b.description), c = e.some((b) => b.port != null), a = e.some((b) => b.stbd != null), l = e.some((b) => b.arrRad != null), u = e.some((b) => b.speed != null), m = e.some((b, I) => I > 0 && b.gcToPrevious != null), h = e.some((b) => b.bearing != null), p = e.some((b) => b.distanceFromPrevious != null), f = ["WPT No.", "Latitude", "Longitude"];
1147
+ r && f.push("Name"), i && f.push("Description"), m && f.push("Leg"), h && f.push("Bearing[deg]"), p && f.push("Distance[NM]"), u && f.push("Speed[kn]"), c && f.push("PORT XTD[NM]"), a && f.push("STBD XTD[NM]"), l && f.push("Arr.Rad[NM]");
1148
+ const g = (b) => b == null ? "" : String(b).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1149
+ let P = `<row r="1">${f.map((b, I) => `<c r="${G(I)}1" s="1" t="inlineStr"><is><t>${g(b)}</t></is></c>`).join("")}</row>`;
1150
+ for (let b = 0; b < e.length; b++) {
1151
+ const I = e[b], W = b + 2, j = [], Z = (q, L) => j.push(`<c r="${G(q)}${W}"><v>${L}</v></c>`), A = (q, L) => j.push(`<c r="${G(q)}${W}" t="inlineStr"><is><t>${g(L)}</t></is></c>`), w = (q, L) => {
1152
+ L != null ? Z(q, L) : A(q, "");
1098
1153
  };
1099
- Z(0, P + 1), A(1, d.lat2pretty(I.lat, s).pretty), A(2, d.lng2pretty(I.lng, s).pretty);
1154
+ Z(0, b + 1), A(1, d.lat2pretty(I.lat, s).pretty), A(2, d.lng2pretty(I.lng, s).pretty);
1100
1155
  let D = 3;
1101
- r && (A(D, I.name ?? ""), D++), i && (A(D, I.description ?? ""), D++), f && (A(D, P === 0 ? "" : I.gcToPrevious ? "GC" : "RL"), D++), h && (k(D, I.bearing), D++), g && (k(D, I.distanceFromPrevious), D++), u && (k(D, I.speed), D++), c && (k(D, I.port), D++), a && (k(D, I.stbd), D++), l && (k(D, I.arrRad), D++), x += `<row r="${E}">${B.join("")}</row>`;
1156
+ r && (A(D, I.name ?? ""), D++), i && (A(D, I.description ?? ""), D++), m && (A(D, b === 0 ? "" : I.gcToPrevious ? "GC" : "RL"), D++), h && (w(D, I.bearing), D++), p && (w(D, I.distanceFromPrevious), D++), u && (w(D, I.speed), D++), c && (w(D, I.port), D++), a && (w(D, I.stbd), D++), l && (w(D, I.arrRad), D++), P += `<row r="${W}">${j.join("")}</row>`;
1102
1157
  }
1103
- const M = "0." + "0".repeat(s), y = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>' + x + "</sheetData></worksheet>", N = '<?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>', w = '<?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>', q = '<?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="' + p(o) + '" sheetId="1" r:id="rId1"/></sheets></workbook>', U = '<?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>', L = '<?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="' + M + '"/></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>', O = new TextEncoder();
1158
+ const N = "0." + "0".repeat(s), y = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>' + P + "</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>', O = '<?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>', U = '<?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="' + g(o) + '" sheetId="1" r:id="rId1"/></sheets></workbook>', E = '<?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>', B = '<?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="' + N + '"/></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>', k = new TextEncoder();
1104
1159
  return _([
1105
- { name: "[Content_Types].xml", data: O.encode(N) },
1106
- { name: "_rels/.rels", data: O.encode(w) },
1107
- { name: "xl/workbook.xml", data: O.encode(q) },
1108
- { name: "xl/_rels/workbook.xml.rels", data: O.encode(U) },
1109
- { name: "xl/worksheets/sheet1.xml", data: O.encode(y) },
1110
- { name: "xl/styles.xml", data: O.encode(L) }
1160
+ { name: "[Content_Types].xml", data: k.encode(M) },
1161
+ { name: "_rels/.rels", data: k.encode(O) },
1162
+ { name: "xl/workbook.xml", data: k.encode(U) },
1163
+ { name: "xl/_rels/workbook.xml.rels", data: k.encode(E) },
1164
+ { name: "xl/worksheets/sheet1.xml", data: k.encode(y) },
1165
+ { name: "xl/styles.xml", data: k.encode(B) }
1111
1166
  ]);
1112
1167
  }
1113
1168
  /**
@@ -1167,18 +1222,18 @@ class v {
1167
1222
  */
1168
1223
  static coordinatesSummary(t, e = 3) {
1169
1224
  if (t.length > 1) {
1170
- const n = t[0], s = t[t.length - 1], o = (n == null ? void 0 : n.positionTime) < (s == null ? void 0 : s.positionTime) ? b.unix(n == null ? void 0 : n.positionTime) : b.unix(s == null ? void 0 : s.positionTime), r = (n == null ? void 0 : n.positionTime) > (s == null ? void 0 : s.positionTime) ? b.unix(n == null ? void 0 : n.positionTime) : b.unix(s == null ? void 0 : s.positionTime), i = Math.round(r.diff(o, "hours", !0) * 100) / 100, c = this.generateRouteAccordingToWaypoints(t, !0, !0), a = this.calculateRouteDistance(c), u = K.inspectStoppages(t, e).reduce(
1171
- (h, g) => (h.duration += g.duration, h.distance += g.distance, h),
1225
+ const n = t[0], s = t[t.length - 1], o = (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 = (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 = Math.round(r.diff(o, "hours", !0) * 100) / 100, c = this.generateRouteAccordingToWaypoints(t, !0, !0), a = this.calculateRouteDistance(c), u = K.inspectStoppages(t, e).reduce(
1226
+ (h, p) => (h.duration += p.duration, h.distance += p.distance, h),
1172
1227
  { hours: 0, distance: 0, spd: 0, duration: 0 }
1173
1228
  );
1174
1229
  u.hours = Math.round(u.duration / 3600 * 100) / 100, u.distance = Math.round(u.distance * 100) / 100, u.spd = u.hours ? Math.round(u.distance / u.hours * 100) / 100 : 0;
1175
- const f = i ? Math.round((a - u.distance) / (i - u.hours) * 100) / 100 : 0;
1230
+ const m = i ? Math.round((a - u.distance) / (i - u.hours) * 100) / 100 : 0;
1176
1231
  return {
1177
1232
  begin: o.utc().format(),
1178
1233
  end: r.utc().format(),
1179
1234
  distance: Math.round((a - u.distance) * 100) / 100,
1180
1235
  hours: Math.round((i - u.hours) * 100) / 100,
1181
- avgSpeed: f,
1236
+ avgSpeed: m,
1182
1237
  stoppage: u
1183
1238
  };
1184
1239
  }
@@ -1200,24 +1255,24 @@ class v {
1200
1255
  * }
1201
1256
  */
1202
1257
  static pickUTCSampleFromSpeed(t, e) {
1203
- var l, u, f;
1258
+ var l, u, m;
1204
1259
  if (!((u = (l = e == null ? void 0 : e.sample) == null ? void 0 : l.hours) != null && u.length))
1205
1260
  return { routes: [], hour: void 0 };
1206
- const n = e.sample.hours.at(0), s = b.utc(t), o = b.utc(e.eta), r = s.isAfter(o) ? o : s;
1261
+ const n = e.sample.hours.at(0), s = x.utc(t), o = x.utc(e.eta), r = s.isAfter(o) ? o : s;
1207
1262
  let i = e.sample.all.find((h) => h.eta === r.format());
1208
1263
  if (!i) {
1209
- const h = e.sample.all.filter((N) => b.utc(N.eta).isBefore(r)).at(-1), g = this.calculateSubRoute(h, e.route);
1210
- i = (f = this.calculateNextCoordinateAlongRoute(h, h.speed * r.diff(b(h.etd), "hours", !0), g)) == null ? void 0 : f.coordinate;
1211
- const { cFactor: m, cog: p, wxFactor: S, meteo: x } = h, M = Math.round(i.distanceFromPrevious * 1e4) / 1e4, y = Math.round((M + h.distanceFromStart) * 1e4) / 1e4;
1264
+ const h = e.sample.all.filter((M) => x.utc(M.eta).isBefore(r)).at(-1), p = this.calculateSubRoute(h, e.route);
1265
+ i = (m = this.calculateNextCoordinateAlongRoute(h, h.speed * r.diff(x(h.etd), "hours", !0), p)) == null ? void 0 : m.coordinate;
1266
+ const { cFactor: f, cog: g, wxFactor: S, meteo: P } = h, N = Math.round(i.distanceFromPrevious * 1e4) / 1e4, y = Math.round((N + h.distanceFromStart) * 1e4) / 1e4;
1212
1267
  i = {
1213
1268
  ...i,
1214
- cFactor: m,
1215
- cog: p,
1269
+ cFactor: f,
1270
+ cog: g,
1216
1271
  speed: h.speed,
1217
1272
  wxFactor: S,
1218
1273
  distanceFromStart: y,
1219
- distanceFromPrevious: M,
1220
- meteo: x,
1274
+ distanceFromPrevious: N,
1275
+ meteo: P,
1221
1276
  eta: r.format(),
1222
1277
  etd: r.format()
1223
1278
  };
@@ -1241,10 +1296,10 @@ class v {
1241
1296
  */
1242
1297
  static pickUTCSampleFromRoute(t, e, n) {
1243
1298
  var h;
1244
- const s = this.calculateSubRoute(e, n), o = this.calculateRouteDistance(s), r = o / e.speed, i = b.utc(t), c = b(e.etd), a = (h = this.calculateNextCoordinateAlongRoute(e, e.speed * i.diff(b(e.etd), "hours", !0), s)) == null ? void 0 : h.coordinate;
1299
+ const s = this.calculateSubRoute(e, n), o = this.calculateRouteDistance(s), r = o / e.speed, i = x.utc(t), c = x(e.etd), a = (h = this.calculateNextCoordinateAlongRoute(e, e.speed * i.diff(x(e.etd), "hours", !0), s)) == null ? void 0 : h.coordinate;
1245
1300
  a.speed = e.speed;
1246
1301
  const l = c.clone().add(a.hourFromPrevious, "hour");
1247
- a.eta = Math.abs(l.diff(i, "second")) < 2 ? i.format() : l.format(), a.etd = a.eta, a.distanceFromStart = Math.round(a.distanceFromPrevious * 100) / 100, a.distanceToGo = Math.round((o - a.distanceFromStart) * 100) / 100, a.timeToGo = Math.round(c.clone().add(r, "hour").diff(b(a.etd), "hour") * 100) / 100;
1302
+ a.eta = Math.abs(l.diff(i, "second")) < 2 ? i.format() : l.format(), a.etd = a.eta, a.distanceFromStart = Math.round(a.distanceFromPrevious * 100) / 100, a.distanceToGo = Math.round((o - a.distanceFromStart) * 100) / 100, a.timeToGo = Math.round(c.clone().add(r, "hour").diff(x(a.etd), "hour") * 100) / 100;
1248
1303
  const u = this.calculateRangeWaypoints(e, a, n);
1249
1304
  return {
1250
1305
  routes: this.generateRouteAccordingToWaypoints(u),
@@ -1264,7 +1319,7 @@ class v {
1264
1319
  }
1265
1320
  let $;
1266
1321
  try {
1267
- $ = G.getLogger("vessel");
1322
+ $ = z.getLogger("vessel");
1268
1323
  } catch {
1269
1324
  } finally {
1270
1325
  }
@@ -1282,90 +1337,90 @@ class it {
1282
1337
  i && i.wind && (i.wind.kts = i.kts);
1283
1338
  for (const c of r.forecasts) {
1284
1339
  let a;
1285
- const l = [], u = [], f = b(c.date).utc(), h = `${r.name}-${c.model}`;
1286
- for (const m in c == null ? void 0 : c.hours) {
1287
- const p = c.hours[m];
1288
- a = a || p;
1289
- const S = f.clone().add(Number(m), "hour"), x = T.point([p.lng, p.lat], {
1340
+ const l = [], u = [], m = x(c.date).utc(), h = `${r.name}-${c.model}`;
1341
+ for (const f in c == null ? void 0 : c.hours) {
1342
+ const g = c.hours[f];
1343
+ a = a || g;
1344
+ const S = m.clone().add(Number(f), "hour"), P = T.point([g.lng, g.lat], {
1290
1345
  model: c.model,
1291
1346
  name: r.name,
1292
1347
  nameCn: r.nameCn,
1293
1348
  date: S.format(),
1294
- hour: Number(m),
1349
+ hour: Number(f),
1295
1350
  format: S.format("MMM-DD/HHmm[Z]"),
1296
- pressure: p.pressure > 1e4 ? d.roundPrecision(p.pressure / 100, 0) : d.roundPrecision(p.pressure, 0),
1297
- gusts: p.gusts,
1298
- wind: p.wind || {},
1299
- movement: p.movement,
1351
+ pressure: g.pressure > 1e4 ? d.roundPrecision(g.pressure / 100, 0) : d.roundPrecision(g.pressure, 0),
1352
+ gusts: g.gusts,
1353
+ wind: g.wind || {},
1354
+ movement: g.movement,
1300
1355
  category: h,
1301
1356
  type: "forecast"
1302
1357
  });
1303
- u.push(x), l.push(x.geometry.coordinates);
1358
+ u.push(P), l.push(P.geometry.coordinates);
1304
1359
  }
1305
- const g = {
1360
+ const p = {
1306
1361
  kts: void 0,
1307
1362
  deg: void 0
1308
1363
  };
1309
1364
  if (i) {
1310
- const m = b(i.updated).utc();
1365
+ const f = x(i.updated).utc();
1311
1366
  if (a) {
1312
- const S = v.calculateDistance(i, a), x = b(a.utc || a.updated).diff(m, "h", !0);
1313
- g.kts = Math.round(S / x * 100) / 100, g.deg = v.calculateBearing(i, a, !0, 0);
1367
+ const S = v.calculateDistance(i, a), P = x(a.utc || a.updated).diff(f, "h", !0);
1368
+ p.kts = Math.round(S / P * 100) / 100, p.deg = v.calculateBearing(i, a, !0, 0);
1314
1369
  }
1315
- const p = T.point([i.lng, i.lat], {
1370
+ const g = T.point([i.lng, i.lat], {
1316
1371
  model: c.model,
1317
1372
  name: r.name,
1318
1373
  nameCn: r.nameCn,
1319
- date: m.format(),
1374
+ date: f.format(),
1320
1375
  hour: 0,
1321
- format: m.format("MMM-DD/HHmm[Z]"),
1376
+ format: f.format("MMM-DD/HHmm[Z]"),
1322
1377
  pressure: i.pressure > 1e4 ? d.roundPrecision((i == null ? void 0 : i.pressure) / 100, 0) : d.roundPrecision(i.pressure, 0),
1323
1378
  wind: i.wind,
1324
- movement: g,
1379
+ movement: p,
1325
1380
  category: h,
1326
1381
  type: "forecast",
1327
1382
  important: !0
1328
1383
  // 第一个预报点为重要点
1329
1384
  });
1330
- u.unshift(p), l.unshift(p.geometry.coordinates);
1385
+ u.unshift(g), l.unshift(g.geometry.coordinates);
1331
1386
  }
1332
1387
  if (e.features.push(...u), (l == null ? void 0 : l.length) > 1) {
1333
- const m = T.lineString(d.convertToMonotonicLng2(l), {
1334
- date: (i == null ? void 0 : i.updated) || (f == null ? void 0 : f.format()),
1388
+ const f = T.lineString(d.convertToMonotonicLng2(l), {
1389
+ date: (i == null ? void 0 : i.updated) || (m == null ? void 0 : m.format()),
1335
1390
  id: r.id || r.name,
1336
1391
  model: c.model,
1337
1392
  name: r.name,
1338
1393
  category: h,
1339
1394
  type: "forecast",
1340
- movement: g
1395
+ movement: p
1341
1396
  });
1342
- e.features.push(m);
1397
+ e.features.push(f);
1343
1398
  }
1344
1399
  }
1345
1400
  }
1346
- if (e.features.sort((c, a) => c.properties.type === "forecast" && a.properties.type === "forecast" && c.geometry.type === "Point" && a.geometry.type === "Point" ? b(c.properties.date).valueOf() - b(a.properties.date).valueOf() : 0), (s = r.history) != null && s.length) {
1347
- const c = [], a = b(i == null ? void 0 : i.updated).utc(), l = b((o = r.history) == null ? void 0 : o.at(-1).updated).utc(), u = a.diff(l, "h") % 24 > 2 ? 24 : 12;
1348
- for (const f of r.history) {
1349
- const h = b(f.updated).utc(), g = h.isSameOrBefore(a) || h.isSame(l);
1350
- g && a.add(-u, "h");
1351
- const m = T.point([f.lng, f.lat], {
1401
+ if (e.features.sort((c, a) => c.properties.type === "forecast" && a.properties.type === "forecast" && c.geometry.type === "Point" && a.geometry.type === "Point" ? x(c.properties.date).valueOf() - x(a.properties.date).valueOf() : 0), (s = r.history) != null && s.length) {
1402
+ const c = [], a = x(i == null ? void 0 : i.updated).utc(), l = x((o = r.history) == null ? void 0 : o.at(-1).updated).utc(), u = a.diff(l, "h") % 24 > 2 ? 24 : 12;
1403
+ for (const m of r.history) {
1404
+ const h = x(m.updated).utc(), p = h.isSameOrBefore(a) || h.isSame(l);
1405
+ p && a.add(-u, "h");
1406
+ const f = T.point([m.lng, m.lat], {
1352
1407
  name: r.name,
1353
1408
  nameCn: r.nameCn,
1354
1409
  date: h.format(),
1355
1410
  format: h.format("MMM-DD/HHmm[Z]"),
1356
- pressure: f.pressure > 1e4 ? d.roundPrecision(f.pressure / 100, 0) : d.roundPrecision(f.pressure, 0),
1357
- kts: f.kts,
1358
- level: f.type,
1411
+ pressure: m.pressure > 1e4 ? d.roundPrecision(m.pressure / 100, 0) : d.roundPrecision(m.pressure, 0),
1412
+ kts: m.kts,
1413
+ level: m.type,
1359
1414
  type: "history",
1360
1415
  category: `${r.name}-history`,
1361
- wind: f.wind,
1362
- movement: f.movement,
1363
- important: g
1416
+ wind: m.wind,
1417
+ movement: m.movement,
1418
+ important: p
1364
1419
  });
1365
- e.features.push(m), c.push(m.geometry.coordinates);
1420
+ e.features.push(f), c.push(f.geometry.coordinates);
1366
1421
  }
1367
1422
  if (c.length === 1 && c.push(c[0]), c.length > 1) {
1368
- const f = T.lineString(d.convertToMonotonicLng2(c), {
1423
+ const m = T.lineString(d.convertToMonotonicLng2(c), {
1369
1424
  name: r.name,
1370
1425
  type: "history",
1371
1426
  updated: i == null ? void 0 : i.updated,
@@ -1373,7 +1428,7 @@ class it {
1373
1428
  kts: i == null ? void 0 : i.kts,
1374
1429
  level: i == null ? void 0 : i.type
1375
1430
  });
1376
- e.features.push(f);
1431
+ e.features.push(m);
1377
1432
  }
1378
1433
  }
1379
1434
  }
@@ -1388,32 +1443,32 @@ class it {
1388
1443
  var o, r, i, c;
1389
1444
  const n = (o = t == null ? void 0 : t.data) == null ? void 0 : o.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), s = [];
1390
1445
  for (const a of n) {
1391
- const l = a.properties.name, u = a.properties.model, f = a.properties.showCircle, h = a.properties.disabled, g = b(a.properties.date).utc();
1392
- let m = e * 60;
1393
- const p = (r = t == null ? void 0 : t.data) == null ? void 0 : r.features.filter(
1394
- (M) => M.geometry.type === "Point" && M.properties.type === "forecast" && M.properties.category === `${l}-${u}`
1446
+ const l = a.properties.name, u = a.properties.model, m = a.properties.showCircle, h = a.properties.disabled, p = x(a.properties.date).utc();
1447
+ let f = e * 60;
1448
+ const g = (r = t == null ? void 0 : t.data) == null ? void 0 : r.features.filter(
1449
+ (N) => N.geometry.type === "Point" && N.properties.type === "forecast" && N.properties.category === `${l}-${u}`
1395
1450
  );
1396
- let S, x = g.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1397
- for (; S = this.pickIndex(p, x), S <= p.length - 1; ) {
1451
+ let S, P = p.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1452
+ for (; S = this.pickIndex(g, P), S <= g.length - 1; ) {
1398
1453
  if (S > 0) {
1399
- const M = p[S], y = S === 0 ? void 0 : p[S - 1], N = (m / 60 - ((i = y == null ? void 0 : y.properties) == null ? void 0 : i.hour)) / (M.properties.hour - ((c = y == null ? void 0 : y.properties) == null ? void 0 : c.hour)), w = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[0], M.geometry.coordinates[0], N), q = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[1], M.geometry.coordinates[1], N), U = T.point([w, q], {
1454
+ const N = g[S], y = S === 0 ? void 0 : g[S - 1], M = (f / 60 - ((i = y == null ? void 0 : y.properties) == null ? void 0 : i.hour)) / (N.properties.hour - ((c = y == null ? void 0 : y.properties) == null ? void 0 : c.hour)), O = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[0], N.geometry.coordinates[0], M), U = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[1], N.geometry.coordinates[1], M), E = T.point([O, U], {
1400
1455
  name: l,
1401
1456
  model: u,
1402
- category: M == null ? void 0 : M.properties.category,
1403
- date: x.format(),
1404
- format: x.format("MMM-DD/HHmm[Z]"),
1405
- gusts: this.computeNumber(y == null ? void 0 : y.properties.gusts, M.properties.gusts, N),
1406
- hour: this.computeNumber(y == null ? void 0 : y.properties.hour, M.properties.hour, N),
1407
- movement: this.computeNumber(y == null ? void 0 : y.properties.movement, M.properties.movement, N),
1408
- pressure: this.computeNumber(y == null ? void 0 : y.properties.pressure, M.properties.pressure, N),
1409
- wind: this.computeNumber(y == null ? void 0 : y.properties.wind, M.properties.wind, N),
1457
+ category: N == null ? void 0 : N.properties.category,
1458
+ date: P.format(),
1459
+ format: P.format("MMM-DD/HHmm[Z]"),
1460
+ gusts: this.computeNumber(y == null ? void 0 : y.properties.gusts, N.properties.gusts, M),
1461
+ hour: this.computeNumber(y == null ? void 0 : y.properties.hour, N.properties.hour, M),
1462
+ movement: this.computeNumber(y == null ? void 0 : y.properties.movement, N.properties.movement, M),
1463
+ pressure: this.computeNumber(y == null ? void 0 : y.properties.pressure, N.properties.pressure, M),
1464
+ wind: this.computeNumber(y == null ? void 0 : y.properties.wind, N.properties.wind, M),
1410
1465
  type: "forecast",
1411
1466
  disabled: h,
1412
- showCircle: f
1467
+ showCircle: m
1413
1468
  });
1414
- s.push(U);
1469
+ s.push(E);
1415
1470
  }
1416
- m += e * 60, x = g.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1471
+ f += e * 60, P = p.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1417
1472
  }
1418
1473
  }
1419
1474
  return s;
@@ -1443,9 +1498,9 @@ class it {
1443
1498
  const { t1: o, t2: r, hr: i, hours: c } = this.tropicalCenterTwin(e, 24, s);
1444
1499
  if (o && r) {
1445
1500
  if (!s.debug) {
1446
- const g = v.calculateDistance(t, o), m = v.calculateDistance(t, r);
1447
- if (g > 2 * n && m > 2 * n)
1448
- return $ == null || $.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, g, m, {
1501
+ const p = v.calculateDistance(t, o), f = v.calculateDistance(t, r);
1502
+ if (p > 2 * n && f > 2 * n)
1503
+ return $ == null || $.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, p, f, {
1449
1504
  from: t,
1450
1505
  t1: o,
1451
1506
  t2: r,
@@ -1453,9 +1508,9 @@ class it {
1453
1508
  }), {};
1454
1509
  }
1455
1510
  const a = v.calculateBearing(t, o), l = v.calculateBearing(o, r), u = Math.abs(a - l);
1456
- let f = 0;
1457
- u < 180 ? f = u + 90 : u >= 180 && (f = u - 90);
1458
- const h = v.calculateCoordinate(o, f, n);
1511
+ let m = 0;
1512
+ u < 180 ? m = u + 90 : u >= 180 && (m = u - 90);
1513
+ const h = v.calculateCoordinate(o, m, n);
1459
1514
  return $ == null || $.info("[%s] the right tangent position: %j", s.requestId, {
1460
1515
  from: t,
1461
1516
  t1: o,
@@ -1482,9 +1537,9 @@ class it {
1482
1537
  const { t1: o, t2: r, hr: i, hours: c } = this.tropicalCenterTwin(e, 24, s);
1483
1538
  if (o && r) {
1484
1539
  if (!s.debug) {
1485
- const h = v.calculateDistance(t, o), g = v.calculateDistance(t, r);
1486
- if (h > 2 * n && g > 2 * n)
1487
- return $ == null || $.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, h, g, {
1540
+ const h = v.calculateDistance(t, o), p = v.calculateDistance(t, r);
1541
+ if (h > 2 * n && p > 2 * n)
1542
+ return $ == null || $.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, h, p, {
1488
1543
  from: t,
1489
1544
  t1: o,
1490
1545
  t2: r,
@@ -1505,26 +1560,26 @@ class it {
1505
1560
  * @private
1506
1561
  */
1507
1562
  static tropicalCenterTwin(t, e = 24, n = {}) {
1508
- var l, u, f, h, g;
1563
+ var l, u, m, h, p;
1509
1564
  let s = {};
1510
- (l = t.forecasts) == null || l.forEach((m) => {
1511
- s = { ...m.hours, ...s };
1565
+ (l = t.forecasts) == null || l.forEach((f) => {
1566
+ s = { ...f.hours, ...s };
1512
1567
  });
1513
- const o = ((u = t == null ? void 0 : t.history) == null ? void 0 : u[0]) || (s == null ? void 0 : s[(f = Object.keys(s)) == null ? void 0 : f[0]]);
1568
+ const o = ((u = t == null ? void 0 : t.history) == null ? void 0 : u[0]) || (s == null ? void 0 : s[(m = Object.keys(s)) == null ? void 0 : m[0]]);
1514
1569
  $ == null || $.info("[%s] the first tropical center: %j", n.requestId, o);
1515
- let r = (h = Object.keys(s || {}).filter((m) => Number(m) <= (e < 0 ? 24 : e))) == null ? void 0 : h.at(-1);
1516
- r || (r = (g = Object.keys(s || {}).filter((m) => Number(m) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : g.at(-1));
1570
+ let r = (h = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : e))) == null ? void 0 : h.at(-1);
1571
+ r || (r = (p = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : p.at(-1));
1517
1572
  const i = s == null ? void 0 : s[r || -1];
1518
1573
  $ == null || $.info("[%s] the second tropical center: %j in %d hrs", n.requestId, i, r);
1519
- const c = Object.keys(s || {}).filter((m) => Number(m) <= Number(r)), a = { 0: o };
1520
- for (const m of c)
1521
- a[m] = s[m];
1574
+ const c = Object.keys(s || {}).filter((f) => Number(f) <= Number(r)), a = { 0: o };
1575
+ for (const f of c)
1576
+ a[f] = s[f];
1522
1577
  return { t1: o, t2: i, hr: Number(r), hours: a };
1523
1578
  }
1524
1579
  static pickIndex(t, e) {
1525
1580
  let n = 0;
1526
1581
  for (const s of t) {
1527
- if (b(s.properties.date).isAfter(e))
1582
+ if (x(s.properties.date).isAfter(e))
1528
1583
  return n === 0 ? -1 : n;
1529
1584
  n++;
1530
1585
  }
@@ -1562,7 +1617,7 @@ typeof globalThis < "u" && typeof globalThis.Buffer > "u" && (globalThis.Buffer
1562
1617
  });
1563
1618
  let R;
1564
1619
  try {
1565
- R = G.getLogger("meteo");
1620
+ R = z.getLogger("meteo");
1566
1621
  } catch {
1567
1622
  } finally {
1568
1623
  }
@@ -1591,10 +1646,10 @@ class F {
1591
1646
  * @param options 步数、单位等选项
1592
1647
  */
1593
1648
  static drawCircle(t, e, n, s = {}) {
1594
- const o = (s == null ? void 0 : s.steps) ?? 64, r = (s == null ? void 0 : s.units) ?? "nauticalmiles", i = (s == null ? void 0 : s.properties) ?? {}, c = T.point([t, e]), a = T.destination(c, n, 90, { units: r }), l = b.utc();
1649
+ const o = (s == null ? void 0 : s.steps) ?? 64, r = (s == null ? void 0 : s.units) ?? "nauticalmiles", i = (s == null ? void 0 : s.properties) ?? {}, c = T.point([t, e]), a = T.destination(c, n, 90, { units: r }), l = x.utc();
1595
1650
  i.id = (s == null ? void 0 : s.id) || l.valueOf().toString();
1596
1651
  const u = "circle";
1597
- return i.name = (s == null ? void 0 : s.name) || `${u}_${l.format()}`, i.radius = n, i.center = [t, e], i.end = a.geometry.coordinates.map((f) => d.roundPrecision(f, 9)), i.units = r, i.steps = o, i.shape = "circle", R.info("[%s] draw circle with %j", s == null ? void 0 : s.requestId, i), T.circle(c, n, { steps: o, units: r, properties: i });
1652
+ return i.name = (s == null ? void 0 : s.name) || `${u}_${l.format()}`, i.radius = n, i.center = [t, e], i.end = a.geometry.coordinates.map((m) => d.roundPrecision(m, 9)), i.units = r, i.steps = o, i.shape = "circle", R.info("[%s] draw circle with %j", s == null ? void 0 : s.requestId, i), T.circle(c, n, { steps: o, units: r, properties: i });
1598
1653
  }
1599
1654
  /**
1600
1655
  * 基于turf画矩形,返回GeoJSON Feature<Polygon>
@@ -1603,7 +1658,7 @@ class F {
1603
1658
  * @param options 选项
1604
1659
  */
1605
1660
  static drawRect(t, e, n = {}) {
1606
- const s = (n == null ? void 0 : n.properties) ?? {}, o = b.utc();
1661
+ const s = (n == null ? void 0 : n.properties) ?? {}, o = x.utc();
1607
1662
  s.id = (n == null ? void 0 : n.id) || o.valueOf().toString();
1608
1663
  const r = "rect";
1609
1664
  s.name = (n == null ? void 0 : n.name) || `${r}_${o.format()}`, s.start = t.map((l) => d.roundPrecision(l, 9)), s.end = e.map((l) => d.roundPrecision(l, 9)), s.shape = "rect", R.info("[%s] draw rect with %j", n == null ? void 0 : n.requestId, s);
@@ -1618,7 +1673,7 @@ class F {
1618
1673
  * @returns
1619
1674
  */
1620
1675
  static drawLine(t, e = {}) {
1621
- const n = (e == null ? void 0 : e.properties) ?? {}, s = b.utc();
1676
+ const n = (e == null ? void 0 : e.properties) ?? {}, s = x.utc();
1622
1677
  n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1623
1678
  const o = "line";
1624
1679
  n.name = (e == null ? void 0 : e.name) || `${o}_${s.format()}`, n.shape = "line", R.info("[%s] draw line with %j", e == null ? void 0 : e.requestId, n);
@@ -1632,7 +1687,7 @@ class F {
1632
1687
  * @returns
1633
1688
  */
1634
1689
  static drawPolygon(t, e = {}) {
1635
- const n = (e == null ? void 0 : e.properties) ?? {}, s = b.utc();
1690
+ const n = (e == null ? void 0 : e.properties) ?? {}, s = x.utc();
1636
1691
  n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1637
1692
  const o = "polygon";
1638
1693
  n.name = (e == null ? void 0 : e.name) || `${o}_${s.format()}`, n.coordinates = t.map((i) => i.map((c) => d.roundPrecision(c, 9))), n.shape = "polygon", R.info("[%s] draw polygon with %j", e == null ? void 0 : e.requestId, n);
@@ -1647,7 +1702,7 @@ class F {
1647
1702
  * @returns
1648
1703
  */
1649
1704
  static drawPoint(t, e, n = {}) {
1650
- const s = (n == null ? void 0 : n.properties) ?? {}, o = b.utc();
1705
+ const s = (n == null ? void 0 : n.properties) ?? {}, o = x.utc();
1651
1706
  s.id = (n == null ? void 0 : n.id) || o.valueOf().toString();
1652
1707
  const r = "point";
1653
1708
  return s.name = (n == null ? void 0 : n.name) || `${r}_${o.format()}`, s.shape = "point", R.info("[%s] draw point with %j", n == null ? void 0 : n.requestId, s), T.point([e, t], s);
@@ -1664,7 +1719,7 @@ class F {
1664
1719
  R.info("[%s] parse circle with %j", e == null ? void 0 : e.requestId, t.properties);
1665
1720
  const n = t.properties || {};
1666
1721
  if (n.shape == "circle") {
1667
- const r = b.utc();
1722
+ const r = x.utc();
1668
1723
  n.id = (n == null ? void 0 : n.id) || r.valueOf().toString();
1669
1724
  const i = n == null ? void 0 : n.id, c = ((s = n == null ? void 0 : n.center) == null ? void 0 : s.length) == 2 ? T.point(n.center) : T.centroid(t);
1670
1725
  let a = "center";
@@ -1672,14 +1727,14 @@ class F {
1672
1727
  const l = (n == null ? void 0 : n.units) || "nauticalmiles";
1673
1728
  let u = n == null ? void 0 : n.radius;
1674
1729
  if (!u) {
1675
- const g = T.polygonToLine(t);
1676
- u = T.pointToLineDistance(c, g, { units: l });
1730
+ const p = T.polygonToLine(t);
1731
+ u = T.pointToLineDistance(c, p, { units: l });
1677
1732
  }
1678
1733
  a = "end";
1679
- const f = ((o = n == null ? void 0 : n.end) == null ? void 0 : o.length) == 2 ? T.point(n.end) : T.destination(c, u, 90, { units: l });
1680
- f.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l };
1681
- const h = T.lineString([c.geometry.coordinates, f.geometry.coordinates]);
1682
- return a = "edge", h.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l }, T.featureCollection([c, f, h, t]);
1734
+ const m = ((o = n == null ? void 0 : n.end) == null ? void 0 : o.length) == 2 ? T.point(n.end) : T.destination(c, u, 90, { units: l });
1735
+ m.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l };
1736
+ const h = T.lineString([c.geometry.coordinates, m.geometry.coordinates]);
1737
+ return a = "edge", h.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l }, T.featureCollection([c, m, h, t]);
1683
1738
  } else
1684
1739
  return R.warn("[%s] not a orm-std circle, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1685
1740
  }
@@ -1694,7 +1749,7 @@ class F {
1694
1749
  R.info("[%s] parse rect with %j", e == null ? void 0 : e.requestId, t.properties);
1695
1750
  const n = t.properties || {};
1696
1751
  if (n.shape == "rect") {
1697
- const s = b.utc();
1752
+ const s = x.utc();
1698
1753
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1699
1754
  const o = n == null ? void 0 : n.id, r = t.geometry.coordinates[0], c = ["sw", "nw", "ne", "se"].map((a, l) => {
1700
1755
  const u = T.point(r[l]);
@@ -1715,7 +1770,7 @@ class F {
1715
1770
  R.info("[%s] parse line with %j", e == null ? void 0 : e.requestId, t.properties);
1716
1771
  const n = t.properties || {};
1717
1772
  if (n.shape == "line") {
1718
- const s = b.utc();
1773
+ const s = x.utc();
1719
1774
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1720
1775
  const o = n == null ? void 0 : n.id, i = t.geometry.coordinates.map((c, a) => {
1721
1776
  const l = `point_${a}`, u = T.point(c);
@@ -1736,7 +1791,7 @@ class F {
1736
1791
  R.info("[%s] parse polygon with %j", e == null ? void 0 : e.requestId, t.properties);
1737
1792
  const n = t.properties || {};
1738
1793
  if (n.shape == "polygon") {
1739
- const s = b.utc();
1794
+ const s = x.utc();
1740
1795
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1741
1796
  const o = n == null ? void 0 : n.id, i = t.geometry.coordinates[0].map((c, a) => {
1742
1797
  const l = T.point(c), u = `corner_${a}`;
@@ -1766,7 +1821,7 @@ class F {
1766
1821
  * 使用 Central Directory 解析,避免 Data Descriptor 导致的大小不准问题。
1767
1822
  */
1768
1823
  static async _parseZipEntries(t) {
1769
- var f;
1824
+ var m;
1770
1825
  const e = new Uint8Array(t), n = e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), s = new DataView(n), o = new Uint8Array(n), r = /* @__PURE__ */ new Map();
1771
1826
  let i = -1;
1772
1827
  for (let h = n.byteLength - 22; h >= 0; h--)
@@ -1783,33 +1838,33 @@ class F {
1783
1838
  for (; l < u; ) {
1784
1839
  if (s.getUint32(l, !0) !== 33639248)
1785
1840
  throw new Error(`Invalid ZIP file: Central Directory signature mismatch at offset ${l}`);
1786
- const g = s.getUint16(l + 10, !0), m = s.getUint32(l + 20, !0), p = s.getUint16(l + 28, !0), S = s.getUint16(l + 30, !0), x = s.getUint16(l + 32, !0), M = s.getUint32(l + 42, !0), y = o.slice(l + 46, l + 46 + p), N = new TextDecoder().decode(y), w = s.getUint16(M + 26, !0), q = s.getUint16(M + 28, !0), U = M + 30 + w + q, L = o.slice(U, U + m);
1787
- if (g === 0)
1788
- r.set(N, L);
1789
- else if (g === 8) {
1841
+ const p = s.getUint16(l + 10, !0), f = s.getUint32(l + 20, !0), g = s.getUint16(l + 28, !0), S = s.getUint16(l + 30, !0), P = s.getUint16(l + 32, !0), N = s.getUint32(l + 42, !0), y = o.slice(l + 46, l + 46 + g), M = new TextDecoder().decode(y), O = s.getUint16(N + 26, !0), U = s.getUint16(N + 28, !0), E = N + 30 + O + U, B = o.slice(E, E + f);
1842
+ if (p === 0)
1843
+ r.set(M, B);
1844
+ else if (p === 8) {
1790
1845
  if (typeof DecompressionStream < "u") {
1791
- const O = new DecompressionStream("deflate-raw"), P = O.writable.getWriter(), I = O.readable.getReader();
1792
- P.write(L), P.close();
1793
- const E = [];
1794
- let B = 0;
1846
+ const k = new DecompressionStream("deflate-raw"), b = k.writable.getWriter(), I = k.readable.getReader();
1847
+ b.write(B), b.close();
1848
+ const W = [];
1849
+ let j = 0;
1795
1850
  for (; ; ) {
1796
- const { done: k, value: D } = await I.read();
1797
- if (k)
1851
+ const { done: w, value: D } = await I.read();
1852
+ if (w)
1798
1853
  break;
1799
- E.push(D), B += D.length;
1854
+ W.push(D), j += D.length;
1800
1855
  }
1801
- const Z = new Uint8Array(B);
1856
+ const Z = new Uint8Array(j);
1802
1857
  let A = 0;
1803
- for (const k of E)
1804
- Z.set(k, A), A += k.length;
1805
- r.set(N, Z);
1806
- } else if (typeof process < "u" && ((f = process.versions) != null && f.node))
1858
+ for (const w of W)
1859
+ Z.set(w, A), A += w.length;
1860
+ r.set(M, Z);
1861
+ } else if (typeof process < "u" && ((m = process.versions) != null && m.node))
1807
1862
  try {
1808
- r.set(N, F._inflateRawSync(L));
1863
+ r.set(M, F._inflateRawSync(B));
1809
1864
  } catch {
1810
1865
  }
1811
1866
  }
1812
- l += 46 + p + S + x;
1867
+ l += 46 + g + S + P;
1813
1868
  }
1814
1869
  return r;
1815
1870
  }
@@ -1829,36 +1884,36 @@ class F {
1829
1884
  for (const a of o) {
1830
1885
  const l = {}, u = Array.from(a.querySelectorAll("ExtendedData > Data"));
1831
1886
  for (const y of u) {
1832
- const N = y.getAttribute("name"), w = (c = (i = y.querySelector("value")) == null ? void 0 : i.textContent) == null ? void 0 : c.trim();
1833
- N && w !== void 0 && w !== null && (l[N] = w);
1887
+ const M = y.getAttribute("name"), O = (c = (i = y.querySelector("value")) == null ? void 0 : i.textContent) == null ? void 0 : c.trim();
1888
+ M && O !== void 0 && O !== null && (l[M] = O);
1834
1889
  }
1835
- const f = b.utc(), h = Object.keys(l).find((y) => y.toLowerCase().indexOf("name") !== -1), g = h ? l[h] : void 0, m = `${f.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, p = (y) => y.trim().split(/[\s\n]+/).filter((N) => N.length > 0).map((N) => {
1836
- const w = N.split(",").map(Number);
1837
- return [w[0], w[1]];
1890
+ const m = x.utc(), h = Object.keys(l).find((y) => y.toLowerCase().indexOf("name") !== -1), p = h ? l[h] : void 0, f = `${m.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, g = (y) => y.trim().split(/[\s\n]+/).filter((M) => M.length > 0).map((M) => {
1891
+ const O = M.split(",").map(Number);
1892
+ return [O[0], O[1]];
1838
1893
  }), S = a.querySelector("LineString > coordinates");
1839
1894
  if (S) {
1840
- const y = p(S.textContent || "");
1895
+ const y = g(S.textContent || "");
1841
1896
  if (y.length >= 2) {
1842
- const N = T.lineString(y, { ...l, shape: "line", id: m, name: g });
1843
- r.push(N);
1897
+ const M = T.lineString(y, { ...l, shape: "line", id: f, name: p });
1898
+ r.push(M);
1844
1899
  }
1845
1900
  continue;
1846
1901
  }
1847
- const x = a.querySelector("Polygon outerBoundaryIs LinearRing > coordinates");
1848
- if (x) {
1849
- const y = p(x.textContent || "");
1902
+ const P = a.querySelector("Polygon outerBoundaryIs LinearRing > coordinates");
1903
+ if (P) {
1904
+ const y = g(P.textContent || "");
1850
1905
  if (y.length >= 4) {
1851
- const N = y[0][0] === y[y.length - 1][0] && y[0][1] === y[y.length - 1][1] ? y : [...y, y[0]], w = T.polygon([N], { ...l, shape: "polygon", id: m, name: g });
1852
- r.push(w);
1906
+ const M = y[0][0] === y[y.length - 1][0] && y[0][1] === y[y.length - 1][1] ? y : [...y, y[0]], O = T.polygon([M], { ...l, shape: "polygon", id: f, name: p });
1907
+ r.push(O);
1853
1908
  }
1854
1909
  continue;
1855
1910
  }
1856
- const M = a.querySelector("Point > coordinates");
1857
- if (M) {
1858
- const y = p(M.textContent || "");
1911
+ const N = a.querySelector("Point > coordinates");
1912
+ if (N) {
1913
+ const y = g(N.textContent || "");
1859
1914
  if (y.length >= 1) {
1860
- const N = T.point(y[0], { ...l, shape: "point", id: m, name: g });
1861
- r.push(N);
1915
+ const M = T.point(y[0], { ...l, shape: "point", id: f, name: p });
1916
+ r.push(M);
1862
1917
  }
1863
1918
  continue;
1864
1919
  }
@@ -1917,7 +1972,7 @@ class F {
1917
1972
  typeof Buffer < "u" && Buffer.isBuffer(t) && (t = F.toArrayBuffer(t));
1918
1973
  const n = await J(t);
1919
1974
  if (Array.isArray(n)) {
1920
- const s = n.flatMap((c) => c.features || []), o = b.utc(), r = (e == null ? void 0 : e.id) || o.valueOf().toString(), i = {
1975
+ const s = n.flatMap((c) => c.features || []), o = x.utc(), r = (e == null ? void 0 : e.id) || o.valueOf().toString(), i = {
1921
1976
  Point: "point",
1922
1977
  MultiPoint: "point",
1923
1978
  LineString: "line",
@@ -1926,10 +1981,10 @@ class F {
1926
1981
  MultiPolygon: "polygon"
1927
1982
  };
1928
1983
  return s.forEach((c, a) => {
1929
- var g;
1930
- const l = ((g = c.geometry) == null ? void 0 : g.type) || "", u = i[l] || l.toLowerCase();
1984
+ var p;
1985
+ const l = ((p = c.geometry) == null ? void 0 : p.type) || "", u = i[l] || l.toLowerCase();
1931
1986
  c.properties = c.properties || {}, c.properties.shape = u, c.properties.parentId = r, c.properties.id = `${r}_${a}`;
1932
- const f = Object.keys(c.properties).find((m) => m.toLowerCase().indexOf("name") !== -1), h = f ? c.properties[f] : void 0;
1987
+ const m = Object.keys(c.properties).find((f) => f.toLowerCase().indexOf("name") !== -1), h = m ? c.properties[m] : void 0;
1933
1988
  c.properties.name = h || `${u}_${o.format()}_${a}`;
1934
1989
  }), T.featureCollection(s);
1935
1990
  }