@idm-plugin/geo 2.4.0 → 2.4.2

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,9 +1,12 @@
1
+ var Y = Object.defineProperty;
2
+ var Q = (C, t, e) => t in C ? Y(C, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : C[t] = e;
3
+ var K = (C, t, e) => (Q(C, typeof t != "symbol" ? t + "" : t, e), e);
1
4
  import * as T from "@turf/turf";
2
5
  import N from "moment";
3
- import G from "@log4js-node/log4js-api";
6
+ import J from "@log4js-node/log4js-api";
4
7
  import "moment-timezone";
5
- import V from "tz-lookup";
6
- import J from "shpjs";
8
+ import _ from "tz-lookup";
9
+ import H from "shpjs";
7
10
  class h {
8
11
  /**
9
12
  * 基于输入的经度,计算出时区
@@ -12,7 +15,7 @@ class h {
12
15
  */
13
16
  static guessTimeZoneOffset(t, e) {
14
17
  t = h.convertToStdLng(t);
15
- const n = V(e, t), s = N().tz(n).utcOffset();
18
+ const n = _(e, t), s = N().tz(n).utcOffset();
16
19
  return h.roundPrecision(s / 60, 1);
17
20
  }
18
21
  /**
@@ -30,25 +33,25 @@ class h {
30
33
  * @param format
31
34
  */
32
35
  static lng2pretty(t, e = 6, n = "H°M′") {
33
- t = h.convertToStdLng(t, 6);
36
+ t = h.convertToStdLng(t, e);
34
37
  let s = "E";
35
38
  t < 0 && (s = "W"), t = Math.abs(t), n = n.toUpperCase();
36
- let c = t * 3600, r = "", i = "", o = "";
39
+ let c = t * 3600, i = "", r = "", o = "";
37
40
  const a = c % 3600 % 60;
38
- n.indexOf("S") !== -1 && (c = c - a, r = h.padNumber(a, 2, 1));
39
- const l = c / 60 % 60;
40
- n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? i = h.roundPrecision(l, 2).toString().padStart(2, "0") : i = h.padNumber(l, 2, 2), c = c - l * 60);
41
- const u = c / 3600;
42
- n.indexOf("M") !== -1 ? o = h.roundPrecision(u, e).toString().padStart(3, "0") : o = h.padNumber(u, 3, 6), Number(r) >= 60 && (i = Number(i) + 1, r = 0), Number(i) >= 60 && (o = Number(o) + 1, i = 0), o = o.toString(), i = h.padNumber(Number(i), 2, Number.isInteger(Number(i)) ? 0 : 2), r = h.padNumber(Number(r), 2, Number.isInteger(Number(r)) ? 0 : 1);
43
- const m = `${n.replace(/S+/gi, r).replace(/M+/gi, i).replace(/H+/gi, o)}${s}`;
41
+ n.indexOf("S") !== -1 && (c = c - a, i = h.padNumber(a, 2, 1));
42
+ const u = c / 60 % 60;
43
+ n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? r = h.roundPrecision(u, 2).toString().padStart(2, "0") : r = h.padNumber(u, 2, 2), c = c - u * 60);
44
+ const l = c / 3600;
45
+ n.indexOf("M") !== -1 ? o = h.roundPrecision(l, e).toString().padStart(3, "0") : o = h.padNumber(l, 3, 6), Number(i) >= 60 && (r = Number(r) + 1, i = 0), Number(r) >= 60 && (o = Number(o) + 1, r = 0), o = o.toString(), r = h.padNumber(Number(r), 2, Number.isInteger(Number(r)) ? 0 : 2), i = h.padNumber(Number(i), 2, Number.isInteger(Number(i)) ? 0 : 1);
46
+ const m = `${n.replace(/S+/gi, i).replace(/M+/gi, r).replace(/H+/gi, o)}${s}`;
44
47
  return {
45
48
  direction: s,
46
- degree: h.roundPrecision(u, e),
47
- minute: h.roundPrecision(l, e),
49
+ degree: h.roundPrecision(l, e),
50
+ minute: h.roundPrecision(u, e),
48
51
  second: h.roundPrecision(a, e),
49
52
  pretty: m,
50
- S: r,
51
- M: i,
53
+ S: i,
54
+ M: r,
52
55
  H: o
53
56
  };
54
57
  }
@@ -62,22 +65,22 @@ class h {
62
65
  t = t % 180;
63
66
  let s = "N";
64
67
  t < 0 && (s = "S"), t = Math.abs(t), n = n.toUpperCase();
65
- let c = t * 3600, r = "", i = "", o = "";
68
+ let c = t * 3600, i = "", r = "", o = "";
66
69
  const a = c % 3600 % 60;
67
- n.indexOf("S") !== -1 && (c = c - a, r = h.padNumber(a, 2, 1));
68
- const l = c / 60 % 60;
69
- n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? i = h.roundPrecision(l, 2).toString().padStart(2, "0") : i = h.padNumber(l, 2, 2), c = c - l * 60);
70
- const u = c / 3600;
71
- n.indexOf("M") !== -1 ? o = h.roundPrecision(u, e).toString().padStart(2, "0") : o = h.padNumber(u, 2, 6), Number(r) >= 60 && (i = Number(i) + 1, r = 0), Number(i) >= 60 && (o = Number(o) + 1, i = 0), o = o.toString(), i = h.padNumber(Number(i), 2, Number.isInteger(Number(i)) ? 0 : 2), r = h.padNumber(Number(r), 2, Number.isInteger(Number(r)) ? 0 : 1);
72
- const m = `${n.replace(/S+/gi, r).replace(/M+/gi, i).replace(/H+/gi, o)}${s}`;
70
+ n.indexOf("S") !== -1 && (c = c - a, i = h.padNumber(a, 2, 1));
71
+ const u = c / 60 % 60;
72
+ n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? r = h.roundPrecision(u, 2).toString().padStart(2, "0") : r = h.padNumber(u, 2, 2), c = c - u * 60);
73
+ const l = c / 3600;
74
+ n.indexOf("M") !== -1 ? o = h.roundPrecision(l, e).toString().padStart(2, "0") : o = h.padNumber(l, 2, 6), Number(i) >= 60 && (r = Number(r) + 1, i = 0), Number(r) >= 60 && (o = Number(o) + 1, r = 0), o = o.toString(), r = h.padNumber(Number(r), 2, Number.isInteger(Number(r)) ? 0 : 2), i = h.padNumber(Number(i), 2, Number.isInteger(Number(i)) ? 0 : 1);
75
+ const m = `${n.replace(/S+/gi, i).replace(/M+/gi, r).replace(/H+/gi, o)}${s}`;
73
76
  return {
74
77
  direction: s,
75
- degree: h.roundPrecision(u, e),
76
- minute: h.roundPrecision(l, e),
78
+ degree: h.roundPrecision(l, e),
79
+ minute: h.roundPrecision(u, e),
77
80
  second: h.roundPrecision(a, e),
78
81
  pretty: m,
79
- S: r,
80
- M: i,
82
+ S: i,
83
+ M: r,
81
84
  H: o
82
85
  };
83
86
  }
@@ -88,12 +91,12 @@ class h {
88
91
  const s = t[t.length - 1].toUpperCase();
89
92
  t = t.substring(0, t.length - 1).trim();
90
93
  const c = t.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
91
- let [r, i, o] = c;
92
- if (i = i || 0, i = i > 60 ? i / Math.pow(10, String(i).length - 2) : i, o = o || 0, o = o > 60 ? o / Math.pow(10, String(o).length - 2) : o, r > 360 && !i) {
93
- const a = this.roundPrecision(r / 100, 0);
94
- i = r - a * 100, r = a;
94
+ let [i, r, o] = c;
95
+ if (r = r || 0, r = r > 60 ? r / Math.pow(10, String(r).length - 2) : r, o = o || 0, o = o > 60 ? o / Math.pow(10, String(o).length - 2) : o, i > 360 && !r) {
96
+ const a = this.roundPrecision(i / 100, 0);
97
+ r = i - a * 100, i = a;
95
98
  }
96
- n = r + i / 60 + o / 3600, s === "W" && (n = n * -1);
99
+ n = i + r / 60 + o / 3600, s === "W" && (n = n * -1);
97
100
  } else
98
101
  n = Number(t);
99
102
  return h.convertToStdLng(n, e);
@@ -105,12 +108,12 @@ class h {
105
108
  const s = t[t.length - 1].toUpperCase();
106
109
  t = t.substring(0, t.length - 1).trim();
107
110
  const c = t.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
108
- let [r, i, o] = c;
109
- if (o = o || 0, i = i || 0, i = i > 60 ? i / Math.pow(10, String(i).length - 2) : i, o = o > 60 ? o / Math.pow(10, String(o).length - 2) : o, r > 90 && !i) {
110
- const a = this.roundPrecision(r / 100, 0);
111
- i = r - a * 100, r = a;
111
+ let [i, r, o] = c;
112
+ if (o = o || 0, r = r || 0, r = r > 60 ? r / Math.pow(10, String(r).length - 2) : r, o = o > 60 ? o / Math.pow(10, String(o).length - 2) : o, i > 90 && !r) {
113
+ const a = this.roundPrecision(i / 100, 0);
114
+ r = i - a * 100, i = a;
112
115
  }
113
- if (n = r + i / 60 + o / 3600, n > 90)
116
+ if (n = i + r / 60 + o / 3600, n > 90)
114
117
  throw new Error(`latitude out of range: ${t}${s}`);
115
118
  s === "S" && (n = n * -1);
116
119
  } else
@@ -175,26 +178,32 @@ class h {
175
178
  return s >= 1 ? c : n > 0 ? `${c}.${Math.trunc(s * Math.pow(10, n)).toString().padStart(n, "0")}` : c;
176
179
  }
177
180
  }
178
- class K {
181
+ const z = class z {
182
+ /**
183
+ * 是否船报点,type 大小写不敏感
184
+ */
185
+ static isShipReport(t) {
186
+ return z.shipReportTypes.includes(String((t == null ? void 0 : t.type) ?? "").toUpperCase());
187
+ }
179
188
  static json2Str(t) {
180
189
  const e = t.type ? t.type[0].toUpperCase() : "A";
181
190
  return `${t.lat}|${t.lng}|${t.positionTime}|${t.sog}|${t.cog}|${t.hdg}|${t.draught}|${e}|${JSON.stringify(t.meteo || {})}|${t.vendor}|${t.deleted}`;
182
191
  }
183
192
  static str2Json(t) {
184
- const [e, n, s, c, r, i, o, a, l, u, m] = t.split("|");
193
+ const [e, n, s, c, i, r, o, a, u, l, m] = t.split("|");
185
194
  return {
186
195
  lat: Number(e),
187
196
  lng: Number(n),
188
197
  positionTime: Number(s),
189
198
  sog: Number(c),
190
- cog: Number(r),
191
- hdg: Number(i),
199
+ cog: Number(i),
200
+ hdg: Number(r),
192
201
  //@ts-ignore
193
202
  draught: isNaN(o) ? null : Number(o),
194
203
  type: a,
195
204
  important: a !== "A",
196
- meteo: l ? JSON.parse(l) : void 0,
197
- vendor: u,
205
+ meteo: u ? JSON.parse(u) : void 0,
206
+ vendor: l,
198
207
  deleted: m === "true"
199
208
  };
200
209
  }
@@ -202,48 +211,45 @@ class K {
202
211
  if (t.length < 2)
203
212
  return t;
204
213
  const s = t.at(0).positionTime < t.at(-1).positionTime;
205
- s || t.sort((o, a) => o.positionTime - a.positionTime);
206
- const c = [];
207
- let r, i;
208
- for (let o = 0; o < t.length - 1; o++) {
209
- const a = t[o];
210
- if (!(n && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(a.type))) {
211
- for (let l = o + 1; l < t.length; l++) {
212
- const u = t[l - 1], m = t[l];
213
- if (n && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(a.type))
214
- continue;
215
- const d = m.positionTime - u.positionTime;
216
- if (S.calculateDistance(m, u, !0, 4) / (d / 3600) < e)
217
- r || (r = a), l === t.length - 1 && (i = m, o = l);
218
- else {
219
- r && (i = t[l - 1], o = l);
220
- break;
221
- }
222
- }
223
- if ((i == null ? void 0 : i.positionTime) > (r == null ? void 0 : r.positionTime) && r) {
224
- const l = {
225
- start: {
226
- lat: r.lat,
227
- lng: r.lng,
228
- sog: r.sog,
229
- positionTime: r.positionTime,
230
- utc: N.unix(r.positionTime).utc().format()
231
- },
232
- end: {
233
- lat: i.lat,
234
- lng: i.lng,
235
- sog: i.sog,
236
- positionTime: i.positionTime,
237
- utc: N.unix(i.positionTime).utc().format()
238
- },
239
- duration: i.positionTime - r.positionTime
240
- }, u = t.filter((d) => d.positionTime >= l.start.positionTime && d.positionTime <= l.end.positionTime), m = S.divideAccordingToLng(u);
241
- l.distance = S.calculateRouteDistance(m), l.hours = Math.round(l.duration / 3600 * 10) / 10, l.hours && (l.avgSog = Math.round(l.distance / l.hours * 10) / 10, c.push(l));
214
+ s || t.sort((a, u) => a.positionTime - u.positionTime);
215
+ const c = [], i = n ? t.filter((a) => !z.isShipReport(a)) : t;
216
+ if (i.length < 2)
217
+ return c;
218
+ let r, o;
219
+ for (let a = 0; a < i.length - 1; a++) {
220
+ const u = i[a];
221
+ for (let l = a + 1; l < i.length; l++) {
222
+ const m = i[l - 1], d = i[l], p = d.positionTime - m.positionTime;
223
+ if (b.calculateDistance(d, m, !0, 4) / (p / 3600) < e)
224
+ r || (r = u), l === i.length - 1 && (o = d, a = l);
225
+ else {
226
+ r && (o = i[l - 1], a = l);
227
+ break;
242
228
  }
243
- r = void 0, i = void 0;
244
229
  }
230
+ if ((o == null ? void 0 : o.positionTime) > (r == null ? void 0 : r.positionTime) && r) {
231
+ const l = {
232
+ start: {
233
+ lat: r.lat,
234
+ lng: r.lng,
235
+ sog: r.sog,
236
+ positionTime: r.positionTime,
237
+ utc: N.unix(r.positionTime).utc().format()
238
+ },
239
+ end: {
240
+ lat: o.lat,
241
+ lng: o.lng,
242
+ sog: o.sog,
243
+ positionTime: o.positionTime,
244
+ utc: N.unix(o.positionTime).utc().format()
245
+ },
246
+ duration: o.positionTime - r.positionTime
247
+ }, m = i.filter((p) => p.positionTime >= l.start.positionTime && p.positionTime <= l.end.positionTime), d = b.divideAccordingToLng(m);
248
+ l.distance = b.calculateRouteDistance(d), l.hours = Math.round(l.duration / 3600 * 10) / 10, l.hours && (l.avgSog = Math.round(l.distance / l.hours * 10) / 10, c.push(l));
249
+ }
250
+ r = void 0, o = void 0;
245
251
  }
246
- return s || t.sort((o, a) => a.positionTime - o.positionTime), c;
252
+ return s || t.sort((a, u) => u.positionTime - a.positionTime), c;
247
253
  }
248
254
  /**
249
255
  * 计算轨迹摘要
@@ -252,25 +258,29 @@ class K {
252
258
  * @param etm
253
259
  */
254
260
  static inspectSummary(t, e, n) {
255
- const s = N(e), c = N(n), r = t.filter((l) => l.positionTime >= s.unix() && l.positionTime <= c.unix());
256
- let i = 0, o = 0;
257
- if (r.length > 1)
258
- for (let l = 0; l < r.length - 1; l++) {
259
- const u = r[l], m = r[l + 1];
260
- i += S.calculateDistance(u, m, !0, 4), o += Math.abs(m.positionTime - u.positionTime);
261
+ const s = N(e), c = N(n), i = t.filter((u) => u.positionTime >= s.unix() && u.positionTime <= c.unix());
262
+ let r = 0, o = 0;
263
+ if (i.length > 1)
264
+ for (let u = 0; u < i.length - 1; u++) {
265
+ const l = i[u], m = i[u + 1];
266
+ r += b.calculateDistance(l, m, !0, 4), o += Math.abs(m.positionTime - l.positionTime);
261
267
  }
262
- i = Math.round(i * 100) / 100, o = Math.round(o / 3600 * 100) / 100;
263
- const a = o ? Math.round(i / o * 100) / 100 : 0;
264
- return { distance: i, interval: o, avgSpd: a };
268
+ r = Math.round(r * 100) / 100, o = Math.round(o / 3600 * 100) / 100;
269
+ const a = o ? Math.round(r / o * 100) / 100 : 0;
270
+ return { distance: r, interval: o, avgSpd: a };
265
271
  }
266
- }
267
- let X;
272
+ };
273
+ /**
274
+ * 船报点类型,其定位精度与 AIS 不一致,参与航速推算会干扰停泊判定
275
+ */
276
+ K(z, "shipReportTypes", ["N", "C", "B", "E", "NOON", "COSP", "BOSP", "EOSP"]);
277
+ let V = z, X;
268
278
  try {
269
- X = G.getLogger("meteo");
279
+ X = J.getLogger("meteo");
270
280
  } catch {
271
281
  } finally {
272
282
  }
273
- const Y = (() => {
283
+ const tt = (() => {
274
284
  const C = new Uint32Array(256);
275
285
  for (let t = 0; t < 256; t++) {
276
286
  let e = t;
@@ -280,42 +290,42 @@ const Y = (() => {
280
290
  }
281
291
  return C;
282
292
  })();
283
- function Q(C) {
293
+ function et(C) {
284
294
  let t = 4294967295;
285
295
  for (let e = 0; e < C.length; e++)
286
- t = Y[(t ^ C[e]) & 255] ^ t >>> 8;
296
+ t = tt[(t ^ C[e]) & 255] ^ t >>> 8;
287
297
  return (t ^ 4294967295) >>> 0;
288
298
  }
289
- function _(C) {
299
+ function nt(C) {
290
300
  const t = new TextEncoder(), e = [], n = [];
291
301
  let s = 0;
292
302
  for (const d of C) {
293
- const p = t.encode(d.name), f = Q(d.data), g = new Uint8Array(30 + p.length), b = new DataView(g.buffer);
294
- b.setUint32(0, 67324752, !0), b.setUint16(4, 20, !0), b.setUint16(8, 0, !0), b.setUint32(14, f, !0), b.setUint32(18, d.data.length, !0), b.setUint32(22, d.data.length, !0), b.setUint16(26, p.length, !0), g.set(p, 30), e.push({ nameBytes: p, data: d.data, crc: f, offset: s }), s += g.length + d.data.length, n.push(g, d.data);
303
+ const p = t.encode(d.name), f = et(d.data), g = new Uint8Array(30 + p.length), S = new DataView(g.buffer);
304
+ 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), g.set(p, 30), e.push({ nameBytes: p, data: d.data, crc: f, offset: s }), s += g.length + d.data.length, n.push(g, d.data);
295
305
  }
296
- const c = s, r = [];
297
- let i = 0;
306
+ const c = s, i = [];
307
+ let r = 0;
298
308
  for (const d of e) {
299
309
  const p = new Uint8Array(46 + d.nameBytes.length), f = new DataView(p.buffer);
300
- 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), i += p.length, r.push(p);
310
+ 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);
301
311
  }
302
312
  const o = new Uint8Array(22), a = new DataView(o.buffer);
303
- 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, c, !0);
304
- const l = n.reduce((d, p) => d + p.length, 0) + i + 22, u = new Uint8Array(l);
313
+ 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);
314
+ const u = n.reduce((d, p) => d + p.length, 0) + r + 22, l = new Uint8Array(u);
305
315
  let m = 0;
306
316
  for (const d of n)
307
- u.set(d, m), m += d.length;
308
- for (const d of r)
309
- u.set(d, m), m += d.length;
310
- return u.set(o, m), u;
317
+ l.set(d, m), m += d.length;
318
+ for (const d of i)
319
+ l.set(d, m), m += d.length;
320
+ return l.set(o, m), l;
311
321
  }
312
- function z(C) {
322
+ function G(C) {
313
323
  let t = "", e = C;
314
324
  for (; e >= 0; )
315
325
  t = String.fromCharCode(65 + e % 26) + t, e = Math.floor(e / 26) - 1;
316
326
  return t;
317
327
  }
318
- class S {
328
+ class b {
319
329
  /**
320
330
  * 计算方位角
321
331
  * @param from 坐标 {lng, lat}
@@ -329,8 +339,8 @@ class S {
329
339
  [t.lng, t.lat],
330
340
  [e.lng, e.lat]
331
341
  ]);
332
- let r;
333
- return n ? r = T.rhumbBearing(c.features[0], c.features[1]) : r = T.bearing(c.features[0], c.features[1]), r < 0 && (r += 360), h.roundPrecision(r, s);
342
+ let i;
343
+ 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);
334
344
  }
335
345
  /**
336
346
  * 计算两点间距离
@@ -343,12 +353,12 @@ class S {
343
353
  */
344
354
  static calculateDistance(t, e, n = !0, s = 4, c = "nauticalmiles") {
345
355
  t = { ...t }, e = { ...e }, t.lng = h.convertToStdLng(t.lng, s), e.lng = h.convertToStdLng(e.lng, s);
346
- const r = T.points([
356
+ const i = T.points([
347
357
  [t.lng, t.lat],
348
358
  [e.lng, e.lat]
349
359
  ]);
350
- let i;
351
- return n ? i = T.rhumbDistance(r.features[0], r.features[1], { units: c }) : i = T.distance(r.features[0], r.features[1], { units: c }), h.roundPrecision(i, s);
360
+ let r;
361
+ 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);
352
362
  }
353
363
  /**
354
364
  * 计算航线距离
@@ -358,11 +368,11 @@ class S {
358
368
  */
359
369
  static calculateRouteDistance(t, e = 4, n = "nauticalmiles") {
360
370
  let s = 0, c;
361
- for (const r of t)
362
- for (let i = 0; i < r.length - 1; i++) {
363
- const o = { lng: r[i][0], lat: r[i][1] };
364
- i === 0 && c && (s += this.calculateDistance(c, o, !0, e, n));
365
- const a = { lng: r[i + 1][0], lat: r[i + 1][1] };
371
+ for (const i of t)
372
+ for (let r = 0; r < i.length - 1; r++) {
373
+ const o = { lng: i[r][0], lat: i[r][1] };
374
+ r === 0 && c && (s += this.calculateDistance(c, o, !0, e, n));
375
+ const a = { lng: i[r + 1][0], lat: i[r + 1][1] };
366
376
  s += this.calculateDistance(o, a, !0, e, n), c = a;
367
377
  }
368
378
  return h.roundPrecision(s, e);
@@ -376,10 +386,10 @@ class S {
376
386
  * @param rhumb
377
387
  */
378
388
  static calculateCoordinate(t, e, n, s = "nauticalmiles", c = !0) {
379
- const r = T.point([t.lng, t.lat]);
380
- let i;
381
- c ? i = T.rhumbDestination(r, n, e, { units: s }) : i = T.destination(r, n, e, { units: s });
382
- const o = i.geometry.coordinates;
389
+ const i = T.point([t.lng, t.lat]);
390
+ let r;
391
+ c ? r = T.rhumbDestination(i, n, e, { units: s }) : r = T.destination(i, n, e, { units: s });
392
+ const o = r.geometry.coordinates;
383
393
  return { lng: h.convertToStdLng(o[0], 8), lat: h.roundPrecision(o[1], 8) };
384
394
  }
385
395
  /**
@@ -391,13 +401,13 @@ class S {
391
401
  * @param includeTail true 包含终点 to
392
402
  * @param units 单位,默认 nm(海里)
393
403
  */
394
- static interpolateCoordinates(t, e, n, s = !0, c = !0, r = "nauticalmiles") {
395
- const i = [], o = this.calculateBearing(t, e, !1), a = this.calculateDistance(t, e, !1, 8, r);
396
- s && i.push({ lng: t.lng, lat: t.lat });
397
- let l = 0;
398
- for (; l < a; )
399
- l += n, l < a && i.push(this.calculateCoordinate(t, o, l, r, !1));
400
- return c && i.push({ lng: e.lng, lat: e.lat }), i;
404
+ static interpolateCoordinates(t, e, n, s = !0, c = !0, i = "nauticalmiles") {
405
+ const r = [], o = this.calculateBearing(t, e, !1), a = this.calculateDistance(t, e, !1, 8, i);
406
+ s && r.push({ lng: t.lng, lat: t.lat });
407
+ let u = 0;
408
+ for (; u < a; )
409
+ u += n, u < a && r.push(this.calculateCoordinate(t, o, u, i, !1));
410
+ return c && r.push({ lng: e.lng, lat: e.lat }), r;
401
411
  }
402
412
  /**
403
413
  * 分组坐标(如相邻两个坐标经度差超180度,需以180为界将坐标分为两组)
@@ -417,21 +427,21 @@ class S {
417
427
  t = n ? this.deduplicateCoordinates(t) : t;
418
428
  let s = [];
419
429
  const c = [];
420
- let r, i;
430
+ let i, r;
421
431
  for (let o = 0; o < t.length - 1; o++) {
422
- r = h.convertToStdLng(t[o].lng, 8), i = 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([r, t[o].lat]);
423
- const a = r - i;
432
+ 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]);
433
+ const a = i - r;
424
434
  if (Math.abs(a) > 180) {
425
- const l = h.convertToMonotonicLng2([
426
- [r, t[o].lat],
427
- [i, t[o + 1].lat]
435
+ const u = h.convertToMonotonicLng2([
436
+ [i, t[o].lat],
437
+ [r, t[o + 1].lat]
428
438
  ]);
429
- let u, m;
430
- e ? (u = T.lineString(l), m = T.lineString([
439
+ let l, m;
440
+ e ? (l = T.lineString(u), m = T.lineString([
431
441
  [a > 0 ? 180 : -180, 89],
432
442
  [a > 0 ? 180 : -180, -89]
433
- ])) : (u = T.greatCircle(l[0], l[1]), m = T.greatCircle([a > 0 ? 180 : -180, 89], [a > 0 ? 180 : -180, -89]));
434
- const d = T.lineIntersect(u, m);
443
+ ])) : (l = T.greatCircle(u[0], u[1]), m = T.greatCircle([a > 0 ? 180 : -180, 89], [a > 0 ? 180 : -180, -89]));
444
+ const d = T.lineIntersect(l, m);
435
445
  let p;
436
446
  if (d.features.length) {
437
447
  const f = T.getCoord(d.features[0]);
@@ -440,7 +450,7 @@ class S {
440
450
  p = t[o].lat;
441
451
  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]));
442
452
  }
443
- o === t.length - 2 && s.push([i, t[o + 1].lat]);
453
+ o === t.length - 2 && s.push([r, t[o + 1].lat]);
444
454
  }
445
455
  return c.push(s), c;
446
456
  }
@@ -451,7 +461,7 @@ class S {
451
461
  static deduplicateRoute(t) {
452
462
  const e = [];
453
463
  for (const n of t) {
454
- const s = n.reduce((c, r) => (c.findIndex((i) => i[0] === r[0] && i[1] === r[1]) === -1 && c.push(r), c), []);
464
+ const s = n.reduce((c, i) => (c.findIndex((r) => r[0] === i[0] && r[1] === i[1]) === -1 && c.push(i), c), []);
455
465
  e.push(s);
456
466
  }
457
467
  return e;
@@ -499,13 +509,13 @@ class S {
499
509
  */
500
510
  static mergeCoordinateToRoute(t, e) {
501
511
  t.lng = h.convertToStdLng(t.lng, 8);
502
- let n = Number.MAX_VALUE, s = 0, c = 0, r, i;
512
+ let n = Number.MAX_VALUE, s = 0, c = 0, i, r;
503
513
  return e.forEach((o, a) => {
504
- for (let l = 0; l < o.length - 1; l++) {
505
- const u = { lng: o[l][0], lat: o[l][1] }, m = { lng: o[l + 1][0], lat: o[l + 1][1] }, d = this.calculatePointToLineDistance(t, u, m);
506
- n > d && (n = d, c = l, s = a, r = this.calculateDistance(u, t), i = this.calculateDistance(m, t));
514
+ for (let u = 0; u < o.length - 1; u++) {
515
+ const l = { lng: o[u][0], lat: o[u][1] }, m = { lng: o[u + 1][0], lat: o[u + 1][1] }, d = this.calculatePointToLineDistance(t, l, m);
516
+ n > d && (n = d, c = u, s = a, i = this.calculateDistance(l, t), r = this.calculateDistance(m, t));
507
517
  }
508
- }), r !== 0 && i !== 0 ? e[s].splice(c + 1, 0, [t.lng, t.lat]) : r === 0 ? e[s].splice(c, 1, [t.lng, t.lat]) : i === 0 && e[s].splice(c + 1, 1, [t.lng, t.lat]), e;
518
+ }), i !== 0 && r !== 0 ? e[s].splice(c + 1, 0, [t.lng, t.lat]) : i === 0 ? e[s].splice(c, 1, [t.lng, t.lat]) : r === 0 && e[s].splice(c + 1, 1, [t.lng, t.lat]), e;
509
519
  }
510
520
  /**
511
521
  * 向Route尾加1个坐标
@@ -514,8 +524,8 @@ class S {
514
524
  */
515
525
  static appendCoordinateToRoute(t, e) {
516
526
  t.lng = h.convertToStdLng(t.lng, 8);
517
- const n = S.convertRouteToCoordinates(e);
518
- return n.push(t), S.divideAccordingToLng(n);
527
+ const n = b.convertRouteToCoordinates(e);
528
+ return n.push(t), b.divideAccordingToLng(n);
519
529
  }
520
530
  /**
521
531
  * 向route头加1个坐标
@@ -523,8 +533,8 @@ class S {
523
533
  * @param route
524
534
  */
525
535
  static unshiftCoordinateToRoute(t, e) {
526
- const n = S.convertRouteToCoordinates(e);
527
- return n.unshift(t), S.divideAccordingToLng(n);
536
+ const n = b.convertRouteToCoordinates(e);
537
+ return n.unshift(t), b.divideAccordingToLng(n);
528
538
  }
529
539
  /**
530
540
  * 合并多个waypoints进航线
@@ -547,18 +557,18 @@ class S {
547
557
  n = this.mergeWaypointsToRoute([t, e], n);
548
558
  const s = [];
549
559
  let c = 0;
550
- return n.forEach((r) => {
560
+ return n.forEach((i) => {
551
561
  if (c === 2)
552
562
  return;
553
- const i = [];
554
- for (const o of r) {
563
+ const r = [];
564
+ for (const o of i) {
555
565
  if (h.roundPrecision(e.lng, 8) === h.roundPrecision(o[0], 8) && h.roundPrecision(e.lat, 8) === h.roundPrecision(o[1], 8)) {
556
- i.push(o), c === 0 && i.push([t.lng, t.lat]), c = 2;
566
+ r.push(o), c === 0 && r.push([t.lng, t.lat]), c = 2;
557
567
  break;
558
568
  }
559
- c === 1 ? i.push(o) : h.roundPrecision(t.lng, 8) === h.roundPrecision(o[0], 8) && h.roundPrecision(t.lat, 8) === h.roundPrecision(o[1], 8) && (c = 1, i.push(o));
569
+ 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));
560
570
  }
561
- i.length && s.push(i);
571
+ r.length && s.push(r);
562
572
  }), s;
563
573
  }
564
574
  /**
@@ -570,12 +580,12 @@ class S {
570
580
  * @return [{lng, lat}]
571
581
  */
572
582
  static calculateRangeWaypoints(t, e, n, s = []) {
573
- const c = this.convertRouteToCoordinates(n, 0), r = this.mergeCoordinatesToWaypoints([t, e], c.length ? c : s), i = r.findIndex(
574
- (l) => h.roundPrecision(t.lng, 8) === h.roundPrecision(l.lng, 8) && h.roundPrecision(t.lat, 8) === h.roundPrecision(l.lat, 8)
575
- ), o = r.findIndex(
576
- (l) => h.roundPrecision(e.lng, 8) === h.roundPrecision(l.lng, 8) && h.roundPrecision(e.lat, 8) === h.roundPrecision(l.lat, 8)
583
+ const c = this.convertRouteToCoordinates(n, 0), i = this.mergeCoordinatesToWaypoints([t, e], c.length ? c : s), r = i.findIndex(
584
+ (u) => h.roundPrecision(t.lng, 8) === h.roundPrecision(u.lng, 8) && h.roundPrecision(t.lat, 8) === h.roundPrecision(u.lat, 8)
585
+ ), o = i.findIndex(
586
+ (u) => h.roundPrecision(e.lng, 8) === h.roundPrecision(u.lng, 8) && h.roundPrecision(e.lat, 8) === h.roundPrecision(u.lat, 8)
577
587
  );
578
- return r.filter((l, u) => u >= i && u <= o);
588
+ return i.filter((u, l) => l >= r && l <= o);
579
589
  }
580
590
  /**
581
591
  * 计算坐标到航路上的最短距离
@@ -584,10 +594,10 @@ class S {
584
594
  */
585
595
  static calculateMinDistanceToRoute(t, e) {
586
596
  let n = Number.MAX_VALUE, s = 0, c = 0;
587
- return e.forEach((r, i) => {
588
- for (let o = 0; o < r.length - 1; o++) {
589
- const a = { lng: r[o][0], lat: r[o][1] }, l = { lng: r[o + 1][0], lat: r[o + 1][1] }, u = this.calculatePointToLineDistance(t, a, l);
590
- n > u && (n = u, s = o, c = i);
597
+ return e.forEach((i, r) => {
598
+ for (let o = 0; o < i.length - 1; o++) {
599
+ const a = { lng: i[o][0], lat: i[o][1] }, u = { lng: i[o + 1][0], lat: i[o + 1][1] }, l = this.calculatePointToLineDistance(t, a, u);
600
+ n > l && (n = l, s = o, c = r);
591
601
  }
592
602
  }), { minDist: n, segIndex: c, minIndex: s };
593
603
  }
@@ -598,22 +608,22 @@ class S {
598
608
  * @return [[[lng, lat]]]
599
609
  */
600
610
  static calculateSubRoute(t, e) {
601
- const n = S.convertRouteToCoordinates(e);
602
- S.mergeCoordinateToWaypoints(t, n, !0), e = S.divideAccordingToLng(n);
611
+ const n = b.convertRouteToCoordinates(e);
612
+ b.mergeCoordinateToWaypoints(t, n, !0), e = b.divideAccordingToLng(n);
603
613
  const { segIndex: s, minIndex: c } = this.calculateMinDistanceToRoute({ ...t }, e);
604
614
  t.lng = h.convertToStdLng(t.lng);
605
- const r = [];
606
- let i = !0;
615
+ const i = [];
616
+ let r = !0;
607
617
  for (let o = s; o < e.length; o++)
608
- if (i) {
618
+ if (r) {
609
619
  const a = [];
610
620
  a.push([t.lng, t.lat]);
611
- for (let l = c + 1; l < e[o].length; l++)
612
- t.lng === e[o][l][0] && t.lat === e[o][l][1] || a.push(e[o][l]);
613
- r.push(a), i = !1;
621
+ for (let u = c + 1; u < e[o].length; u++)
622
+ t.lng === e[o][u][0] && t.lat === e[o][u][1] || a.push(e[o][u]);
623
+ i.push(a), r = !1;
614
624
  } else
615
- r.push([...e[o]]);
616
- return r;
625
+ i.push([...e[o]]);
626
+ return i;
617
627
  }
618
628
  /**
619
629
  * 计算子途经点
@@ -623,19 +633,19 @@ class S {
623
633
  */
624
634
  static calculateSubWaypoints(t, e) {
625
635
  let n = Number.MAX_VALUE, s = 0;
626
- for (let r = 0; r < e.length - 1; r++) {
627
- const i = e[r], o = e[r + 1];
628
- if (this.calculateDistance(t, i) === 0)
636
+ for (let i = 0; i < e.length - 1; i++) {
637
+ const r = e[i], o = e[i + 1];
638
+ if (this.calculateDistance(t, r) === 0)
629
639
  return e;
630
640
  if (this.calculateDistance(t, o) === 0)
631
- return e.filter((l, u) => u > 0);
632
- const a = this.calculatePointToLineDistance(t, i, o);
633
- n > a && (n = a, s = r);
641
+ return e.filter((u, l) => l > 0);
642
+ const a = this.calculatePointToLineDistance(t, r, o);
643
+ n > a && (n = a, s = i);
634
644
  }
635
645
  t.lng = h.convertToStdLng(t.lng);
636
646
  const c = [t];
637
- for (let r = s + 1; r < e.length; r++)
638
- c.push(e[r]);
647
+ for (let i = s + 1; i < e.length; i++)
648
+ c.push(e[i]);
639
649
  return c;
640
650
  }
641
651
  /**
@@ -649,11 +659,11 @@ class S {
649
659
  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);
650
660
  const c = h.convertToMonotonicLng([e, n]);
651
661
  e = c[0], n = c[1];
652
- const r = T.lineString([
662
+ const i = T.lineString([
653
663
  [e.lng, e.lat],
654
664
  [n.lng, n.lat]
655
- ]), i = T.pointToLineDistance(T.point([t.lng, t.lat]), r, s), o = T.pointToLineDistance(T.point([t.lng > 0 ? t.lng - 360 : t.lng + 360, t.lat]), r, s);
656
- return h.roundPrecision(Math.min(i, o), 6);
665
+ ]), 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);
666
+ return h.roundPrecision(Math.min(r, o), 6);
657
667
  }
658
668
  /**
659
669
  * 计算途经点的COG, Distance等属性
@@ -663,8 +673,8 @@ class S {
663
673
  static calculateWaypointsPropInRoute(t, e) {
664
674
  e = this.mergeWaypointsToRoute(t, e);
665
675
  for (let n = 0; n < t.length - 1; n++) {
666
- const s = t[n], c = t[n + 1], r = this.calculateRangeRoute(s, c, e);
667
- n === 0 && (s.distanceFromPrevious = 0, s.distanceFromStart = 0), c.distanceFromPrevious = this.calculateRouteDistance(r), c.distanceFromStart = h.roundPrecision((s.distanceFromStart || 0) + c.distanceFromPrevious);
676
+ const s = t[n], c = t[n + 1], i = this.calculateRangeRoute(s, c, e);
677
+ n === 0 && (s.distanceFromPrevious = 0, s.distanceFromStart = 0), c.distanceFromPrevious = this.calculateRouteDistance(i), c.distanceFromStart = h.roundPrecision((s.distanceFromStart || 0) + c.distanceFromPrevious);
668
678
  }
669
679
  return t;
670
680
  }
@@ -692,22 +702,22 @@ class S {
692
702
  */
693
703
  static mergeCoordinateToWaypoints(t, e, n = !0) {
694
704
  t.lng = h.convertToStdLng(t.lng, 8);
695
- let s = Number.MAX_VALUE, c = 0, r = 0, i = 0;
705
+ let s = Number.MAX_VALUE, c = 0, i = 0, r = 0;
696
706
  if (e.length < 2)
697
707
  e.push(t);
698
708
  else {
699
709
  for (let o = 0; o < e.length - 1; o++) {
700
- const a = { lng: e[o].lng, lat: e[o].lat }, l = { lng: e[o + 1].lng, lat: e[o + 1].lat }, u = this.calculatePointToLineDistance(t, a, l);
701
- s >= u && (s = u, c = o, r = this.calculateDistance(a, t, !1, 6), i = this.calculateDistance(l, t, !1, 6));
710
+ const a = { lng: e[o].lng, lat: e[o].lat }, u = { lng: e[o + 1].lng, lat: e[o + 1].lat }, l = this.calculatePointToLineDistance(t, a, u);
711
+ s >= l && (s = l, c = o, i = this.calculateDistance(a, t, !1, 6), r = this.calculateDistance(u, t, !1, 6));
702
712
  }
703
- r !== 0 && i !== 0 ? r <= s && c === 0 ? e.unshift(t) : i <= s && c === e.length - 2 ? e.push(t) : e.splice(c + 1, 0, t) : r === 0 ? n ? e.splice(c, 1, t) : e.splice(c + 1, 0, t) : i === 0 && (n ? e.splice(c + 1, 1, t) : e.splice(c + 1, 0, t));
713
+ 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));
704
714
  }
705
715
  return e.map((o, a) => {
706
716
  o.lng = h.convertToStdLng(o.lng);
707
- const l = e[a + 1];
708
- 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)) {
709
- const u = this.calculateDistance(o, l, !0), m = Math.abs(l.positionTime - o.positionTime) / 3600;
710
- o.sog = h.roundPrecision(u / m, 2);
717
+ const u = e[a + 1];
718
+ if (u && ((o.bearing === null || o.bearing === void 0) && ((o.positionTime || 0) > (u.positionTime || 0) ? o.bearing = this.calculateBearing(u, o, !0) : o.bearing = this.calculateBearing(o, u, !0)), o.cog = o.cog || o.bearing, !o.sog && o.positionTime && u.positionTime)) {
719
+ const l = this.calculateDistance(o, u, !0), m = Math.abs(u.positionTime - o.positionTime) / 3600;
720
+ o.sog = h.roundPrecision(l / m, 2);
711
721
  }
712
722
  return o;
713
723
  });
@@ -722,12 +732,12 @@ class S {
722
732
  static generateRouteAccordingToWaypoints(t, e = !0, n = !0) {
723
733
  const s = [];
724
734
  for (let c = 1; c < t.length; c++) {
725
- const r = t[c - 1], i = t[c];
726
- if (c === 1 && s.push(r), i.gcToPrevious) {
727
- const o = this.interpolateCoordinates(r, i, 200, !1, !0, "nauticalmiles");
735
+ const i = t[c - 1], r = t[c];
736
+ if (c === 1 && s.push(i), r.gcToPrevious) {
737
+ const o = this.interpolateCoordinates(i, r, 200, !1, !0, "nauticalmiles");
728
738
  s.push(...o);
729
739
  } else
730
- s.push(i);
740
+ s.push(r);
731
741
  }
732
742
  return this.divideAccordingToLng(s, e, n);
733
743
  }
@@ -737,7 +747,7 @@ class S {
737
747
  * @param route [[[lng, lat]]]
738
748
  */
739
749
  static nearestCoordinateInRoute(t, e) {
740
- const n = T.point([t.lng, t.lat]), c = this.convertRouteToCoordinates(e).map((a) => [a.lng, a.lat]), r = T.lineString(c), i = T.nearestPointOnLine(r, n), o = T.getCoord(i);
750
+ 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);
741
751
  return { lng: h.roundPrecision(o[0], 8), lat: h.roundPrecision(o[1], 8) };
742
752
  }
743
753
  /**
@@ -749,12 +759,12 @@ class S {
749
759
  let n = 0;
750
760
  this.mergeCoordinateToWaypoints(t, e);
751
761
  for (let s = 0; s < e.length - 1; s++) {
752
- const c = e[s], r = e[s + 1];
762
+ const c = e[s], i = e[s + 1];
753
763
  if (this.calculateDistance(t, c) === 0) {
754
764
  n = s;
755
765
  break;
756
766
  }
757
- if (this.calculateDistance(t, r) === 0) {
767
+ if (this.calculateDistance(t, i) === 0) {
758
768
  n = s + 1;
759
769
  break;
760
770
  }
@@ -771,41 +781,41 @@ class S {
771
781
  */
772
782
  static calculateNextCoordinateAlongRoute(t, e, n, s = "nauticalmiles") {
773
783
  var m;
774
- const c = t.speed || 12, r = [];
775
- let i = [], o = !1, a = 0, l = 0, u;
776
- if (e && n.length ? (r.push(t), n.forEach((d, p) => {
784
+ const c = t.speed || 12, i = [];
785
+ let r = [], o = !1, a = 0, u = 0, l;
786
+ if (e && n.length ? (i.push(t), n.forEach((d, p) => {
777
787
  if (o)
778
- i.push(d);
788
+ r.push(d);
779
789
  else {
780
790
  const f = [];
781
791
  let g;
782
- for (let b = 0; b < d.length; b++)
783
- if (u)
784
- f.push(d[b]);
792
+ for (let S = 0; S < d.length; S++)
793
+ if (l)
794
+ f.push(d[S]);
785
795
  else {
786
- g = { lng: d[b][0], lat: d[b][1] };
796
+ g = { lng: d[S][0], lat: d[S][1] };
787
797
  const v = this.calculateDistance(t, g, !0, 8, s);
788
798
  if (a += v, a < e)
789
- l += v, v && r.push(g), t = g;
799
+ u += v, v && i.push(g), t = g;
790
800
  else {
791
- if (l = e, a === e)
792
- u = g, f.push([u.lng, u.lat]);
801
+ if (u = e, a === e)
802
+ l = g, f.push([l.lng, l.lat]);
793
803
  else {
794
804
  const x = a - e, y = this.calculateBearing(g, t);
795
- u = this.calculateCoordinate(g, y, x, s), f.push([u.lng, u.lat]), f.push([g.lng, g.lat]);
805
+ l = this.calculateCoordinate(g, y, x, s), f.push([l.lng, l.lat]), f.push([g.lng, g.lat]);
796
806
  }
797
807
  o = !0;
798
808
  }
799
809
  }
800
- f.length && i.push(f), p === n.length - 1 && !u && (u = g);
810
+ f.length && r.push(f), p === n.length - 1 && !l && (l = g);
801
811
  }
802
- })) : (i = n, u = { ...t }), u)
803
- if (r.push(u), u.distanceFromPrevious = Math.round(l * 1e4) / 1e4, u.hourFromPrevious = Math.round(l / c * 1e4) / 1e4, ((m = i[0]) == null ? void 0 : m.length) > 1) {
804
- const d = { lng: i[0][1][0], lat: i[0][1][1] };
805
- u.bearing = this.calculateBearing(u, d);
812
+ })) : (r = n, l = { ...t }), l)
813
+ if (i.push(l), l.distanceFromPrevious = Math.round(u * 1e4) / 1e4, l.hourFromPrevious = Math.round(u / c * 1e4) / 1e4, ((m = r[0]) == null ? void 0 : m.length) > 1) {
814
+ const d = { lng: r[0][1][0], lat: r[0][1][1] };
815
+ l.bearing = this.calculateBearing(l, d);
806
816
  } else
807
- u.bearing = 0;
808
- return { coordinate: u, nextRoute: i, prevRoute: r };
817
+ l.bearing = 0;
818
+ return { coordinate: l, nextRoute: r, prevRoute: i };
809
819
  }
810
820
  /**
811
821
  * 返回最近点及其是否为垂足(最近点不是起点或终点)
@@ -814,11 +824,11 @@ class S {
814
824
  * @param to {lng, lat}
815
825
  */
816
826
  static nearestCoordinateInLine(t, e, n) {
817
- const s = h.convertToStdLng(t.lng, 6), c = T.point([s, t.lat]), r = h.convertToStdLng(e.lng, 6), i = h.convertToStdLng(n.lng, 6), o = T.lineString([
818
- [r, e.lat],
819
- [i, n.lat]
820
- ]), a = T.nearestPointOnLine(o, c), l = T.getCoord(a), u = h.roundPrecision(l[0], 6), m = h.roundPrecision(l[1], 6);
821
- return { lng: u, lat: m, inline: !(u === r && m === e.lat) && !(u === i && m === n.lat) };
827
+ 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([
828
+ [i, e.lat],
829
+ [r, n.lat]
830
+ ]), a = T.nearestPointOnLine(o, c), u = T.getCoord(a), l = h.roundPrecision(u[0], 6), m = h.roundPrecision(u[1], 6);
831
+ return { lng: l, lat: m, inline: !(l === i && m === e.lat) && !(l === r && m === n.lat) };
822
832
  }
823
833
  /**
824
834
  * 将route转coordinate
@@ -828,9 +838,9 @@ class S {
828
838
  static convertRouteToCoordinates(t, e = 0) {
829
839
  const n = [];
830
840
  let s, c;
831
- return t.forEach((r) => {
832
- r.forEach((i) => {
833
- const o = { lng: h.roundPrecision(i[0], 8), lat: h.roundPrecision(i[1], 8) };
841
+ return t.forEach((i) => {
842
+ i.forEach((r) => {
843
+ const o = { lng: h.roundPrecision(r[0], 8), lat: h.roundPrecision(r[1], 8) };
834
844
  if (!c)
835
845
  n.push(o), c = o;
836
846
  else if (c.bearing === void 0 || c.bearing === null)
@@ -863,17 +873,17 @@ class S {
863
873
  this.mergeCoordinateToWaypoints(s, t, !0);
864
874
  });
865
875
  for (let s = 1; s < e.length; s++) {
866
- const c = e[s - 1], r = e[s];
867
- if (r.gcToPrevious) {
868
- const i = t.findIndex((a) => a.lng === c.lng && a.lat === c.lat), o = t.findIndex((a) => a.lng === r.lng && a.lat === r.lat);
869
- for (let a = o - 1; a > i; a--)
876
+ const c = e[s - 1], i = e[s];
877
+ if (i.gcToPrevious) {
878
+ const r = t.findIndex((a) => a.lng === c.lng && a.lat === c.lat), o = t.findIndex((a) => a.lng === i.lng && a.lat === i.lat);
879
+ for (let a = o - 1; a > r; a--)
870
880
  t.splice(a, 1);
871
881
  }
872
882
  }
873
883
  let n = 0;
874
884
  for (let s = 1; s < t.length; s++) {
875
- const c = t[s - 1], r = t[s];
876
- r.gcToPrevious ? (c.bearing = this.calculateBearing(c, r, !1), r.distanceFromPrevious = this.calculateDistance(c, r, !1)) : (c.bearing = this.calculateBearing(c, r, !0), r.distanceFromPrevious = this.calculateDistance(c, r, !0)), n = h.roundPrecision(n + r.distanceFromPrevious), r.distanceFromStart = n;
885
+ const c = t[s - 1], i = t[s];
886
+ 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;
877
887
  }
878
888
  return t.map((s) => (s.lng = h.convertToStdLng(s.lng), s));
879
889
  }
@@ -883,14 +893,14 @@ class S {
883
893
  */
884
894
  static calculateCenter(t) {
885
895
  const e = [];
886
- for (const i of t)
887
- for (const o of i)
896
+ for (const r of t)
897
+ for (const o of r)
888
898
  e.push(o);
889
899
  const n = T.featureCollection([]), s = h.convertToMonotonicLng2(e);
890
- for (const i of s)
891
- n.features.push(T.point(i));
892
- const r = T.center(n).geometry.coordinates;
893
- return { lng: h.convertToStdLng(r[0], 8), lat: h.roundPrecision(r[1], 8) };
900
+ for (const r of s)
901
+ n.features.push(T.point(r));
902
+ const i = T.center(n).geometry.coordinates;
903
+ return { lng: h.convertToStdLng(i[0], 8), lat: h.roundPrecision(i[1], 8) };
894
904
  }
895
905
  /**
896
906
  * 计算中心点
@@ -907,8 +917,8 @@ class S {
907
917
  static calculateBBox(t) {
908
918
  const e = [];
909
919
  for (const c of t)
910
- for (const r of c)
911
- e.push(r);
920
+ for (const i of c)
921
+ e.push(i);
912
922
  const n = h.convertToMonotonicLng2(e), s = T.lineString(n);
913
923
  return T.bbox(s);
914
924
  }
@@ -932,8 +942,8 @@ class S {
932
942
  static simplifyCoordinates(t, e = 1, n = 0) {
933
943
  if (t.length <= 2)
934
944
  return [...t];
935
- const s = S.rdpSimplify(t, e), r = (n > 0 ? S.splitLongLegs(t, s, n) : s).map((i) => t[i]);
936
- return X.info("simplify: %d -> %d points (epsilon=%dnm, maxLeg=%dnm)", t.length, r.length, e, n), r;
945
+ const s = b.rdpSimplify(t, e), i = (n > 0 ? b.splitLongLegs(t, s, n) : s).map((r) => t[r]);
946
+ return X.info("simplify: %d -> %d points (epsilon=%dnm, maxLeg=%dnm)", t.length, i.length, e, n), i;
937
947
  }
938
948
  /**
939
949
  * RDP 主循环:首尾点与强制标记点作为锚点分段,段内迭代栈求最大横向偏差
@@ -950,26 +960,26 @@ class S {
950
960
  (a.important || a.pilot || a.suspend || a.velocity || a.gcToPrevious) && (n[o] = !0, s.push(o));
951
961
  }
952
962
  s.push(t.length - 1);
953
- const c = t.map((o) => S.toUnitVector(o)), r = T.convertLength(1, "radians", "nauticalmiles");
963
+ const c = t.map((o) => b.toUnitVector(o)), i = T.convertLength(1, "radians", "nauticalmiles");
954
964
  for (let o = 0; o < s.length - 1; o++) {
955
965
  const a = [[s[o], s[o + 1]]];
956
966
  for (; a.length; ) {
957
- const [l, u] = a.pop(), m = c[l], d = c[u];
967
+ const [u, l] = a.pop(), m = c[u], d = c[l];
958
968
  let p = m[1] * d[2] - m[2] * d[1], f = m[2] * d[0] - m[0] * d[2], g = m[0] * d[1] - m[1] * d[0];
959
- const b = Math.sqrt(p * p + f * f + g * g), v = b < 1e-12;
960
- v || (p /= b, f /= b, g /= b);
969
+ const S = Math.sqrt(p * p + f * f + g * g), v = S < 1e-12;
970
+ v || (p /= S, f /= S, g /= S);
961
971
  let x = 0, y = -1;
962
- for (let P = l + 1; P < u; P++) {
963
- const D = v ? S.calculateDistance(t[P], t[l]) : Math.asin(Math.min(1, Math.abs(c[P][0] * p + c[P][1] * f + c[P][2] * g))) * r;
972
+ for (let P = u + 1; P < l; P++) {
973
+ const D = v ? b.calculateDistance(t[P], t[u]) : Math.asin(Math.min(1, Math.abs(c[P][0] * p + c[P][1] * f + c[P][2] * g))) * i;
964
974
  D > x && (x = D, y = P);
965
975
  }
966
- x > e && (n[y] = !0, a.push([l, y], [y, u]));
976
+ x > e && (n[y] = !0, a.push([u, y], [y, l]));
967
977
  }
968
978
  }
969
- const i = [];
979
+ const r = [];
970
980
  for (let o = 0; o < n.length; o++)
971
- n[o] && i.push(o);
972
- return i;
981
+ n[o] && r.push(o);
982
+ return r;
973
983
  }
974
984
  /**
975
985
  * 最大腿长后处理:超过 maxLeg 的腿按腿内原始点累计里程均分为 ceil(leg/maxLeg) 段取点
@@ -981,20 +991,20 @@ class S {
981
991
  static splitLongLegs(t, e, n) {
982
992
  const s = [e[0]];
983
993
  for (let c = 1; c < e.length; c++) {
984
- const r = s[s.length - 1], i = e[c], o = S.calculateDistance(t[r], t[i]);
985
- if (o > n && i - r >= 2) {
986
- const a = Math.ceil(o / n), l = [0];
987
- for (let u = r + 1; u <= i; u++)
988
- l.push(l[l.length - 1] + S.calculateDistance(t[u - 1], t[u]));
989
- for (let u = 1; u < a; u++) {
990
- const m = o / a * u;
991
- let d = r + 1;
992
- for (; d < i - 1 && l[d - r] < m; )
994
+ const i = s[s.length - 1], r = e[c], o = b.calculateDistance(t[i], t[r]);
995
+ if (o > n && r - i >= 2) {
996
+ const a = Math.ceil(o / n), u = [0];
997
+ for (let l = i + 1; l <= r; l++)
998
+ u.push(u[u.length - 1] + b.calculateDistance(t[l - 1], t[l]));
999
+ for (let l = 1; l < a; l++) {
1000
+ const m = o / a * l;
1001
+ let d = i + 1;
1002
+ for (; d < r - 1 && u[d - i] < m; )
993
1003
  d++;
994
- d > r && d < i && s[s.length - 1] !== d && s.push(d);
1004
+ d > i && d < r && s[s.length - 1] !== d && s.push(d);
995
1005
  }
996
1006
  }
997
- s.push(i);
1007
+ s.push(r);
998
1008
  }
999
1009
  return s;
1000
1010
  }
@@ -1015,14 +1025,14 @@ class S {
1015
1025
  * @returns {number} 单位 nm
1016
1026
  */
1017
1027
  static perpendicularDeviation(t, e, n) {
1018
- const s = S.toUnitVector(e), c = S.toUnitVector(n), r = S.toUnitVector(t);
1019
- let i = 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];
1020
- const l = Math.sqrt(i * i + o * o + a * a);
1021
- if (l < 1e-12)
1022
- return S.calculateDistance(t, e);
1023
- i /= l, o /= l, a /= l;
1024
- const u = T.convertLength(1, "radians", "nauticalmiles");
1025
- return Math.asin(Math.min(1, Math.abs(r[0] * i + r[1] * o + r[2] * a))) * u;
1028
+ const s = b.toUnitVector(e), c = b.toUnitVector(n), i = b.toUnitVector(t);
1029
+ 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];
1030
+ const u = Math.sqrt(r * r + o * o + a * a);
1031
+ if (u < 1e-12)
1032
+ return b.calculateDistance(t, e);
1033
+ r /= u, o /= u, a /= u;
1034
+ const l = T.convertLength(1, "radians", "nauticalmiles");
1035
+ return Math.asin(Math.min(1, Math.abs(i[0] * r + i[1] * o + i[2] * a))) * l;
1026
1036
  }
1027
1037
  /**
1028
1038
  * 在时间轨迹上寻找ts最近的点
@@ -1032,9 +1042,9 @@ class S {
1032
1042
  */
1033
1043
  static nearestTSPointInWaypoints(t, e, n) {
1034
1044
  const s = N.unix(t), c = n.filter(
1035
- (r) => s.clone().subtract(e, "hour").unix() <= (r.positionTime || 0) && s.clone().add(e, "h").unix() >= (r.positionTime || 0)
1045
+ (i) => s.clone().subtract(e, "hour").unix() <= (i.positionTime || 0) && s.clone().add(e, "h").unix() >= (i.positionTime || 0)
1036
1046
  );
1037
- return c.sort((r, i) => (r.positionTime || 0) - (i.positionTime || 0)), c.at(-1);
1047
+ return c.sort((i, r) => (i.positionTime || 0) - (r.positionTime || 0)), c.at(-1);
1038
1048
  }
1039
1049
  /**
1040
1050
  * 推测船位
@@ -1042,17 +1052,17 @@ class S {
1042
1052
  * @param positions 带时间(positionTime)的轨迹
1043
1053
  */
1044
1054
  static deadReckoning(t, e) {
1045
- var c, r, i, o;
1055
+ var c, i, r, o;
1046
1056
  t > 1e12 && (t = Math.round(t / 1e3));
1047
1057
  const n = N.unix(t);
1048
1058
  let s = e.find((a) => a.positionTime === n.unix());
1049
1059
  if (!s) {
1050
- const a = (r = (c = e.filter((u) => (u == null ? void 0 : u.positionTime) < n.unix())) == null ? void 0 : c.sort((u, m) => (u.positionTime || 0) - (m.positionTime || 0))) == null ? void 0 : r.at(-1), l = (o = (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 : o.at(0);
1051
- if (a && l) {
1052
- const u = S.calculateBearing(a, l, !0), m = S.calculateDistance(a, l), d = (n.unix() - a.positionTime) / (l.positionTime - a.positionTime);
1053
- s = S.calculateCoordinate(a, u, m * d), s.positionTime = n.unix(), s.utc = n.utc().format(), s.cog = u, s.sog = Math.round(m / ((l.positionTime - a.positionTime) / 3600) * 100) / 100;
1060
+ const a = (i = (c = e.filter((l) => (l == null ? void 0 : l.positionTime) < n.unix())) == null ? void 0 : c.sort((l, m) => (l.positionTime || 0) - (m.positionTime || 0))) == null ? void 0 : i.at(-1), u = (o = (r = e.filter((l) => (l == null ? void 0 : l.positionTime) > n.unix())) == null ? void 0 : r.sort((l, m) => (l.positionTime || 0) - (m.positionTime || 0))) == null ? void 0 : o.at(0);
1061
+ if (a && u) {
1062
+ const l = b.calculateBearing(a, u, !0), m = b.calculateDistance(a, u), d = (n.unix() - a.positionTime) / (u.positionTime - a.positionTime);
1063
+ s = b.calculateCoordinate(a, l, m * d), s.positionTime = n.unix(), s.utc = n.utc().format(), s.cog = l, s.sog = Math.round(m / ((u.positionTime - a.positionTime) / 3600) * 100) / 100;
1054
1064
  } else
1055
- s = a || l, s && (s.utc = N.unix(s == null ? void 0 : s.positionTime).utc().format());
1065
+ s = a || u, s && (s.utc = N.unix(s == null ? void 0 : s.positionTime).utc().format());
1056
1066
  }
1057
1067
  return s;
1058
1068
  }
@@ -1062,20 +1072,20 @@ class S {
1062
1072
  * @param positions
1063
1073
  */
1064
1074
  static deadReckoningTime(t, e) {
1065
- e = JSON.parse(JSON.stringify(e)), e.sort((a, l) => (a.positionTime || 0) - (l.positionTime || 0));
1075
+ e = JSON.parse(JSON.stringify(e)), e.sort((a, u) => (a.positionTime || 0) - (u.positionTime || 0));
1066
1076
  let n = Number.MAX_SAFE_INTEGER, s = Number.MAX_SAFE_INTEGER;
1067
1077
  for (let a = 0; a < e.length - 1; a++) {
1068
- const l = e[a], u = e[a + 1], m = S.calculatePointToLineDistance(t, l, u);
1078
+ const u = e[a], l = e[a + 1], m = b.calculatePointToLineDistance(t, u, l);
1069
1079
  m < n && (n = m, s = a);
1070
1080
  }
1071
- const c = e[s], r = e[s + 1], i = S.calculateDistance(c, t), o = S.calculateDistance(r, t);
1072
- if (i === 0)
1081
+ const c = e[s], i = e[s + 1], r = b.calculateDistance(c, t), o = b.calculateDistance(i, t);
1082
+ if (r === 0)
1073
1083
  t = c;
1074
1084
  else if (o === 0)
1075
- t = r;
1085
+ t = i;
1076
1086
  else {
1077
- const a = c.positionTime || 0, l = r.positionTime || 0, u = S.calculateDistance(c, r);
1078
- t.positionTime = Math.round(a + (l - a) * (i / u));
1087
+ const a = c.positionTime || 0, u = i.positionTime || 0, l = b.calculateDistance(c, i);
1088
+ t.positionTime = Math.round(a + (u - a) * (r / l));
1079
1089
  }
1080
1090
  return t.utc = t.positionTime ? N.unix(t.positionTime).utc().format() : void 0, t.positionTime ? t : void 0;
1081
1091
  }
@@ -1113,7 +1123,7 @@ class S {
1113
1123
  */
1114
1124
  static waypoints2RTZ(t, e) {
1115
1125
  const s = [];
1116
- 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="${S.xmlEscape(t)}"></routeInfo>`), s.push(...S.toRTZWaypoints(e, 6)), s.push("</route>"), s.join(`
1126
+ 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(`
1117
1127
  `) + `
1118
1128
  `;
1119
1129
  }
@@ -1125,7 +1135,7 @@ class S {
1125
1135
  */
1126
1136
  static waypoints2RTZ10(t, e, n = !0) {
1127
1137
  const c = [];
1128
- 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="${S.xmlEscape(t)}"></routeInfo>`), c.push(...S.toRTZWaypoints(e, 6, n)), c.push("</route>"), c.join(`
1138
+ 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(`
1129
1139
  `) + `
1130
1140
  `;
1131
1141
  }
@@ -1133,21 +1143,21 @@ class S {
1133
1143
  const s = [];
1134
1144
  s.push(" <waypoints>");
1135
1145
  for (let c = 0; c < t.length; c++) {
1136
- const r = t[c], i = c + 1, o = (r.lat ?? "").toFixed ? r.lat.toFixed(e).padEnd(e + 2, "0") : r.lat, a = (r.lng ?? "").toFixed ? r.lng.toFixed(e).padEnd(e + 2, "0") : r.lng, l = [`id="${i}"`, 'revision="0"'];
1137
- if (r.name && l.push(`name="${S.xmlEscape(r.name)}"`), s.push(` <waypoint ${l.join(" ")}>`), s.push(` <position lat="${S.xmlEscape(o)}" lon="${S.xmlEscape(a)}" />`), c > 0) {
1138
- const u = r.gcToPrevious ? "Orthodrome" : "Loxodrome";
1139
- s.push(` <leg geometryType="${u}" />`);
1146
+ 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, u = [`id="${r}"`, 'revision="0"'];
1147
+ if (i.name && u.push(`name="${b.xmlEscape(i.name)}"`), s.push(` <waypoint ${u.join(" ")}>`), s.push(` <position lat="${b.xmlEscape(o)}" lon="${b.xmlEscape(a)}" />`), c > 0) {
1148
+ const l = i.gcToPrevious ? "Orthodrome" : "Loxodrome";
1149
+ s.push(` <leg geometryType="${l}" />`);
1140
1150
  }
1141
1151
  if (n) {
1142
- const u = [];
1143
- if (r.description && u.push(` <description>${S.xmlEscape(r.description)}</description>`), r.utc)
1144
- u.push(` <time>${S.xmlEscape(r.utc)}</time>`);
1145
- else if (r.positionTime)
1152
+ const l = [];
1153
+ if (i.description && l.push(` <description>${b.xmlEscape(i.description)}</description>`), i.utc)
1154
+ l.push(` <time>${b.xmlEscape(i.utc)}</time>`);
1155
+ else if (i.positionTime)
1146
1156
  try {
1147
- u.push(` <time>${S.xmlEscape(N.unix(r.positionTime).utc().format())}</time>`);
1157
+ l.push(` <time>${b.xmlEscape(N.unix(i.positionTime).utc().format())}</time>`);
1148
1158
  } catch {
1149
1159
  }
1150
- r.cog !== void 0 && u.push(` <cog>${S.xmlEscape(r.cog)}</cog>`), r.sog !== void 0 && u.push(` <sog>${S.xmlEscape(r.sog)}</sog>`), u.length && (s.push(" <extensions>"), s.push(...u), s.push(" </extensions>"));
1160
+ i.cog !== void 0 && l.push(` <cog>${b.xmlEscape(i.cog)}</cog>`), i.sog !== void 0 && l.push(` <sog>${b.xmlEscape(i.sog)}</sog>`), l.length && (s.push(" <extensions>"), s.push(...l), s.push(" </extensions>"));
1151
1161
  }
1152
1162
  s.push(" </waypoint>");
1153
1163
  }
@@ -1162,13 +1172,13 @@ class S {
1162
1172
  */
1163
1173
  static waypoints2CSV(t, e, n) {
1164
1174
  X.debug("keep name for waypoints2CSV for legacy compatibility only", t);
1165
- const s = (n == null ? void 0 : n.precision) ?? 6, c = e.some((g) => g.name), r = e.some((g) => g.description), i = e.some((g) => g.port != null), o = e.some((g) => g.stbd != null), a = e.some((g) => g.arrRad != null), l = e.some((g) => g.speed != null), u = e.some((g, b) => b > 0 && g.gcToPrevious != null), m = e.some((g) => g.bearing != null), d = e.some((g) => g.distanceFromPrevious != null), p = ["WPT No.", "Latitude", "Longitude"];
1166
- c && p.push("Name"), r && p.push("Description"), u && p.push("Leg"), m && p.push("Bearing[deg]"), d && p.push("Distance[NM]"), l && p.push("Speed[kn]"), i && p.push("PORT XTD[NM]"), o && p.push("STBD XTD[NM]"), a && p.push("Arr.Rad[NM]");
1175
+ const s = (n == null ? void 0 : n.precision) ?? 6, c = e.some((g) => g.name), i = e.some((g) => g.description), r = e.some((g) => g.port != null), o = e.some((g) => g.stbd != null), a = e.some((g) => g.arrRad != null), u = e.some((g) => g.speed != null), l = e.some((g, S) => S > 0 && g.gcToPrevious != null), m = e.some((g) => g.bearing != null), d = e.some((g) => g.distanceFromPrevious != null), p = ["WPT No.", "Latitude", "Longitude"];
1176
+ c && p.push("Name"), i && p.push("Description"), l && p.push("Leg"), m && p.push("Bearing[deg]"), d && p.push("Distance[NM]"), u && p.push("Speed[kn]"), r && p.push("PORT XTD[NM]"), o && p.push("STBD XTD[NM]"), a && p.push("Arr.Rad[NM]");
1167
1177
  const f = [];
1168
- f.push(p.map((g) => S.csvEscapeField(g)).join(","));
1178
+ f.push(p.map((g) => b.csvEscapeField(g)).join(","));
1169
1179
  for (let g = 0; g < e.length; g++) {
1170
- const b = e[g], v = [];
1171
- v.push((g + 1).toString()), v.push(b.lat.toFixed(s)), v.push(b.lng.toFixed(s)), c && v.push(b.name ?? ""), r && v.push(b.description ?? ""), u && v.push(g === 0 ? "" : b.gcToPrevious ? "GC" : "RL"), m && v.push(b.bearing != null ? String(b.bearing) : ""), d && v.push(b.distanceFromPrevious != null ? String(b.distanceFromPrevious) : ""), l && v.push(b.speed != null ? String(b.speed) : ""), i && v.push(b.port != null ? String(b.port) : ""), o && v.push(b.stbd != null ? String(b.stbd) : ""), a && v.push(b.arrRad != null ? String(b.arrRad) : ""), f.push(v.map((x) => S.csvEscapeField(x)).join(","));
1180
+ const S = e[g], v = [];
1181
+ v.push((g + 1).toString()), v.push(S.lat.toFixed(s)), v.push(S.lng.toFixed(s)), c && v.push(S.name ?? ""), i && v.push(S.description ?? ""), l && v.push(g === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), m && v.push(S.bearing != null ? String(S.bearing) : ""), d && v.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), u && 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((x) => b.csvEscapeField(x)).join(","));
1172
1182
  }
1173
1183
  return f.join(`
1174
1184
  `);
@@ -1181,13 +1191,13 @@ class S {
1181
1191
  * @param options.precision 经纬度分钟小数位数,默认3
1182
1192
  */
1183
1193
  static waypoints2JRCCSV(t, e, n) {
1184
- const s = (n == null ? void 0 : n.precision) ?? 3, c = e.some((f) => f.name), r = e.some((f) => f.port != null), i = e.some((f) => f.stbd != null), o = 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), d = ["// WPT No.", "LAT", "", "", "LON", "", ""];
1185
- r && d.push("PORT[NM]"), i && 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]"), m && d.push("Turn Rad[NM]"), c && d.push("Name");
1194
+ 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), u = e.some((f, g) => g > 0 && f.gcToPrevious != null), l = e.some((f) => f.rot != null), m = e.some((f) => f.turnRad != null), d = ["// WPT No.", "LAT", "", "", "LON", "", ""];
1195
+ i && d.push("PORT[NM]"), r && d.push("STBD[NM]"), o && d.push("Arr. Rad[NM]"), a && d.push("Speed[kn]"), u && d.push("Sail(RL/GC)"), l && d.push("ROT[deg/min]"), m && d.push("Turn Rad[NM]"), c && d.push("Name");
1186
1196
  const p = [];
1187
- p.push("// ROUTE SHEET exported by JRC ECDIS."), p.push("// <<NOTE>>This strings // indicate comment column/cells. You can edit freely."), p.push(`// ${S.xmlEscape(t)}`), p.push(d.join(","));
1197
+ 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(","));
1188
1198
  for (let f = 0; f < e.length; f++) {
1189
- const g = e[f], b = String(f).padStart(3, "0"), v = h.lat2pretty(g.lat, 6), x = h.lng2pretty(g.lng, 6), y = v.degree, P = Number(v.minute).toFixed(s), D = v.direction, E = x.degree, F = Number(x.minute).toFixed(s), $ = x.direction, R = [b, String(y), P, D, String(E), F, $];
1190
- r && R.push(f === 0 ? "***" : g.port != null ? String(g.port) : "***"), i && R.push(f === 0 ? "***" : g.stbd != null ? String(g.stbd) : "***"), o && R.push(f === 0 ? "***" : g.arrRad != null ? String(g.arrRad) : "***"), a && R.push(f === 0 ? "***" : g.speed != null ? Number(g.speed).toFixed(1).padStart(5, "0") : "***"), l && R.push(f === 0 ? "***" : g.gcToPrevious ? "GC" : "RL"), u && R.push(f === 0 ? "***" : g.rot != null ? String(g.rot) : "***"), m && R.push(f === 0 ? "***" : g.turnRad != null ? String(g.turnRad) : "***"), c && R.push(g.name ?? ""), p.push(R.join(","));
1199
+ const g = e[f], S = String(f).padStart(3, "0"), v = h.lat2pretty(g.lat, 6), x = h.lng2pretty(g.lng, 6), y = v.degree, P = Number(v.minute).toFixed(s), D = v.direction, U = x.degree, F = Number(x.minute).toFixed(s), $ = x.direction, R = [S, String(y), P, D, String(U), F, $];
1200
+ i && R.push(f === 0 ? "***" : g.port != null ? String(g.port) : "***"), r && R.push(f === 0 ? "***" : g.stbd != null ? String(g.stbd) : "***"), o && R.push(f === 0 ? "***" : g.arrRad != null ? String(g.arrRad) : "***"), a && R.push(f === 0 ? "***" : g.speed != null ? Number(g.speed).toFixed(1).padStart(5, "0") : "***"), u && R.push(f === 0 ? "***" : g.gcToPrevious ? "GC" : "RL"), l && R.push(f === 0 ? "***" : g.rot != null ? String(g.rot) : "***"), m && R.push(f === 0 ? "***" : g.turnRad != null ? String(g.turnRad) : "***"), c && R.push(g.name ?? ""), p.push(R.join(","));
1191
1201
  }
1192
1202
  return p.join(`
1193
1203
  `);
@@ -1204,23 +1214,23 @@ class S {
1204
1214
  * @returns Uint8Array 二进制数据,可直接用于 new Blob([result], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
1205
1215
  */
1206
1216
  static waypoints2XLSX(t, e, n) {
1207
- const s = (n == null ? void 0 : n.precision) ?? 6, c = t || "Route", r = e.some((M) => M.name), i = e.some((M) => M.description), o = e.some((M) => M.port != null), a = e.some((M) => M.stbd != null), l = e.some((M) => M.arrRad != null), u = e.some((M) => M.speed != null), m = e.some((M, k) => k > 0 && M.gcToPrevious != null), d = e.some((M) => M.bearing != null), p = e.some((M) => M.distanceFromPrevious != null), f = ["WPT No.", "Latitude", "Longitude"];
1208
- r && f.push("Name"), i && f.push("Description"), m && 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]");
1217
+ const s = (n == null ? void 0 : n.precision) ?? 6, c = t || "Route", i = e.some((M) => M.name), r = e.some((M) => M.description), o = e.some((M) => M.port != null), a = e.some((M) => M.stbd != null), u = e.some((M) => M.arrRad != null), l = e.some((M) => M.speed != null), m = e.some((M, w) => w > 0 && M.gcToPrevious != null), d = e.some((M) => M.bearing != null), p = e.some((M) => M.distanceFromPrevious != null), f = ["WPT No.", "Latitude", "Longitude"];
1218
+ i && f.push("Name"), r && f.push("Description"), m && f.push("Leg"), d && f.push("Bearing[deg]"), p && f.push("Distance[NM]"), l && f.push("Speed[kn]"), o && f.push("PORT XTD[NM]"), a && f.push("STBD XTD[NM]"), u && f.push("Arr.Rad[NM]");
1209
1219
  const g = (M) => M == null ? "" : String(M).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1210
- let v = `<row r="1">${f.map((M, k) => `<c r="${z(k)}1" s="1" t="inlineStr"><is><t>${g(M)}</t></is></c>`).join("")}</row>`;
1220
+ let v = `<row r="1">${f.map((M, w) => `<c r="${G(w)}1" s="1" t="inlineStr"><is><t>${g(M)}</t></is></c>`).join("")}</row>`;
1211
1221
  for (let M = 0; M < e.length; M++) {
1212
- const k = e[M], j = M + 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>${g(L)}</t></is></c>`), w = (q, L) => {
1222
+ const w = e[M], j = M + 2, E = [], Z = (q, L) => E.push(`<c r="${G(q)}${j}"><v>${L}</v></c>`), B = (q, L) => E.push(`<c r="${G(q)}${j}" t="inlineStr"><is><t>${g(L)}</t></is></c>`), A = (q, L) => {
1213
1223
  L != null ? Z(q, L) : B(q, "");
1214
1224
  };
1215
- Z(0, M + 1), B(1, h.lat2pretty(k.lat, s).pretty), B(2, h.lng2pretty(k.lng, s).pretty);
1225
+ Z(0, M + 1), B(1, h.lat2pretty(w.lat, s).pretty), B(2, h.lng2pretty(w.lng, s).pretty);
1216
1226
  let I = 3;
1217
- r && (B(I, k.name ?? ""), I++), i && (B(I, k.description ?? ""), I++), m && (B(I, M === 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>`;
1227
+ i && (B(I, w.name ?? ""), I++), r && (B(I, w.description ?? ""), I++), m && (B(I, M === 0 ? "" : w.gcToPrevious ? "GC" : "RL"), I++), d && (A(I, w.bearing), I++), p && (A(I, w.distanceFromPrevious), I++), l && (A(I, w.speed), I++), o && (A(I, w.port), I++), a && (A(I, w.stbd), I++), u && (A(I, w.arrRad), I++), v += `<row r="${j}">${E.join("")}</row>`;
1218
1228
  }
1219
- 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>' + v + "</sheetData></worksheet>", P = '<?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="' + g(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();
1220
- return _([
1229
+ 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>' + v + "</sheetData></worksheet>", P = '<?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>', 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(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();
1230
+ return nt([
1221
1231
  { name: "[Content_Types].xml", data: R.encode(P) },
1222
1232
  { name: "_rels/.rels", data: R.encode(D) },
1223
- { name: "xl/workbook.xml", data: R.encode(E) },
1233
+ { name: "xl/workbook.xml", data: R.encode(U) },
1224
1234
  { name: "xl/_rels/workbook.xml.rels", data: R.encode(F) },
1225
1235
  { name: "xl/worksheets/sheet1.xml", data: R.encode(y) },
1226
1236
  { name: "xl/styles.xml", data: R.encode($) }
@@ -1242,8 +1252,8 @@ class S {
1242
1252
  * @param isLat true为纬度,false为经度
1243
1253
  */
1244
1254
  static decimalToNmeaDm(t, e) {
1245
- const n = Math.abs(t), s = Math.floor(n), c = (n - s) * 60, r = e ? `${s.toString().padStart(2, "0")}${c.toFixed(2).padStart(5, "0")}` : `${s.toString().padStart(3, "0")}${c.toFixed(2).padStart(5, "0")}`, i = e ? t >= 0 ? "N" : "S" : t >= 0 ? "E" : "W";
1246
- return { dm: r, dir: i };
1255
+ const n = Math.abs(t), s = Math.floor(n), c = (n - s) * 60, i = e ? `${s.toString().padStart(2, "0")}${c.toFixed(2).padStart(5, "0")}` : `${s.toString().padStart(3, "0")}${c.toFixed(2).padStart(5, "0")}`, r = e ? t >= 0 ? "N" : "S" : t >= 0 ? "E" : "W";
1256
+ return { dm: i, dir: r };
1247
1257
  }
1248
1258
  /**
1249
1259
  * 计算NMEA 0183校验和 ($与*之间所有字符的异或,两字符十六进制大写)
@@ -1263,7 +1273,7 @@ class S {
1263
1273
  static waypoints2NMEA(t) {
1264
1274
  const e = [];
1265
1275
  for (let n = 0; n < t.length; n++) {
1266
- const s = t[n], c = S.decimalToNmeaDm(s.lat, !0), r = S.decimalToNmeaDm(s.lng, !1), i = s.name ? String(s.name).slice(0, 6) : `WPT${(n + 1).toString().padStart(3, "0")}`, o = `GPWPL,${c.dm},${c.dir},${r.dm},${r.dir},${i}`, a = S.nmeaChecksum(o);
1276
+ 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);
1267
1277
  e.push(`$${o}*${a}`);
1268
1278
  }
1269
1279
  return e.join(`\r
@@ -1283,19 +1293,19 @@ class S {
1283
1293
  */
1284
1294
  static coordinatesSummary(t, e = 3) {
1285
1295
  if (t.length > 1) {
1286
- const n = t[0], s = t[t.length - 1], c = (n == null ? void 0 : n.positionTime) < (s == null ? void 0 : s.positionTime) ? N.unix(n == null ? void 0 : n.positionTime) : N.unix(s == null ? void 0 : s.positionTime), r = (n == null ? void 0 : n.positionTime) > (s == null ? void 0 : s.positionTime) ? N.unix(n == null ? void 0 : n.positionTime) : N.unix(s == null ? void 0 : s.positionTime), i = Math.round(r.diff(c, "hours", !0) * 100) / 100, o = this.generateRouteAccordingToWaypoints(t, !0, !0), a = this.calculateRouteDistance(o), u = K.inspectStoppages(t, e).reduce(
1296
+ const n = t[0], s = t[t.length - 1], c = (n == null ? void 0 : n.positionTime) < (s == null ? void 0 : s.positionTime) ? N.unix(n == null ? void 0 : n.positionTime) : N.unix(s == null ? void 0 : s.positionTime), i = (n == null ? void 0 : n.positionTime) > (s == null ? void 0 : s.positionTime) ? N.unix(n == null ? void 0 : n.positionTime) : N.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), l = V.inspectStoppages(t, e).reduce(
1287
1297
  (d, p) => (d.duration += p.duration, d.distance += p.distance, d),
1288
1298
  { hours: 0, distance: 0, spd: 0, duration: 0 }
1289
1299
  );
1290
- 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;
1291
- const m = i ? Math.round((a - u.distance) / (i - u.hours) * 100) / 100 : 0;
1300
+ l.hours = Math.round(l.duration / 3600 * 100) / 100, l.distance = Math.round(l.distance * 100) / 100, l.spd = l.hours ? Math.round(l.distance / l.hours * 100) / 100 : 0;
1301
+ const m = r ? Math.round((a - l.distance) / (r - l.hours) * 100) / 100 : 0;
1292
1302
  return {
1293
1303
  begin: c.utc().format(),
1294
- end: r.utc().format(),
1295
- distance: Math.round((a - u.distance) * 100) / 100,
1296
- hours: Math.round((i - u.hours) * 100) / 100,
1304
+ end: i.utc().format(),
1305
+ distance: Math.round((a - l.distance) * 100) / 100,
1306
+ hours: Math.round((r - l.hours) * 100) / 100,
1297
1307
  avgSpeed: m,
1298
- stoppage: u
1308
+ stoppage: l
1299
1309
  };
1300
1310
  }
1301
1311
  return {
@@ -1316,37 +1326,37 @@ class S {
1316
1326
  * }
1317
1327
  */
1318
1328
  static pickUTCSampleFromSpeed(t, e) {
1319
- var l, u, m;
1320
- if (!((u = (l = e == null ? void 0 : e.sample) == null ? void 0 : l.hours) != null && u.length))
1329
+ var u, l, m;
1330
+ if (!((l = (u = e == null ? void 0 : e.sample) == null ? void 0 : u.hours) != null && l.length))
1321
1331
  return { routes: [], hour: void 0 };
1322
- const n = e.sample.hours.at(0), s = N.utc(t), c = N.utc(e.eta), r = s.isAfter(c) ? c : s;
1323
- let i = e.sample.all.find((d) => d.eta === r.format());
1324
- if (!i) {
1325
- let d = e.sample.all.filter((y) => N.utc(y.eta).isBefore(r)).at(-1);
1332
+ const n = e.sample.hours.at(0), s = N.utc(t), c = N.utc(e.eta), i = s.isAfter(c) ? c : s;
1333
+ let r = e.sample.all.find((d) => d.eta === i.format());
1334
+ if (!r) {
1335
+ let d = e.sample.all.filter((y) => N.utc(y.eta).isBefore(i)).at(-1);
1326
1336
  if (d) {
1327
1337
  const y = this.calculateSubRoute(d, e.route);
1328
- i = (m = this.calculateNextCoordinateAlongRoute(d, d.speed * r.diff(N(d.etd), "hours", !0), y)) == null ? void 0 : m.coordinate;
1338
+ r = (m = this.calculateNextCoordinateAlongRoute(d, d.speed * i.diff(N(d.etd), "hours", !0), y)) == null ? void 0 : m.coordinate;
1329
1339
  } else
1330
- d = e.sample.all.at(0), i = d;
1331
- const { cFactor: p, cog: f, wxFactor: g, meteo: b } = d, v = Math.round(i.distanceFromPrevious * 1e4) / 1e4, x = Math.round((v + d.distanceFromStart) * 1e4) / 1e4;
1332
- i = {
1333
- ...i,
1340
+ d = e.sample.all.at(0), r = d;
1341
+ const { cFactor: p, cog: f, wxFactor: g, meteo: S } = d, v = Math.round(r.distanceFromPrevious * 1e4) / 1e4, x = Math.round((v + d.distanceFromStart) * 1e4) / 1e4;
1342
+ r = {
1343
+ ...r,
1334
1344
  cFactor: p,
1335
1345
  cog: f,
1336
1346
  speed: d.speed,
1337
1347
  wxFactor: g,
1338
1348
  distanceFromStart: x,
1339
1349
  distanceFromPrevious: v,
1340
- meteo: b,
1341
- eta: r.format(),
1342
- etd: r.format()
1350
+ meteo: S,
1351
+ eta: i.format(),
1352
+ etd: i.format()
1343
1353
  };
1344
1354
  }
1345
- i.distanceToGo = Math.round((e.distance - i.distanceFromStart) * 100) / 100, i.timeToGo = Math.round(c.diff(i.etd, "hours", !0) * 100) / 100;
1346
- const o = this.calculateRangeWaypoints(n, i, e.route);
1355
+ r.distanceToGo = Math.round((e.distance - r.distanceFromStart) * 100) / 100, r.timeToGo = Math.round(c.diff(r.etd, "hours", !0) * 100) / 100;
1356
+ const o = this.calculateRangeWaypoints(n, r, e.route);
1347
1357
  return {
1348
1358
  routes: this.generateRouteAccordingToWaypoints(o),
1349
- hour: i
1359
+ hour: r
1350
1360
  };
1351
1361
  }
1352
1362
  /**
@@ -1361,13 +1371,13 @@ class S {
1361
1371
  */
1362
1372
  static pickUTCSampleFromRoute(t, e, n) {
1363
1373
  var d;
1364
- const s = this.calculateSubRoute(e, n), c = this.calculateRouteDistance(s), r = c / e.speed, i = N.utc(t), o = N(e.etd), a = (d = this.calculateNextCoordinateAlongRoute(e, e.speed * i.diff(N(e.etd), "hours", !0), s)) == null ? void 0 : d.coordinate;
1374
+ const s = this.calculateSubRoute(e, n), c = this.calculateRouteDistance(s), i = c / e.speed, r = N.utc(t), o = N(e.etd), a = (d = this.calculateNextCoordinateAlongRoute(e, e.speed * r.diff(N(e.etd), "hours", !0), s)) == null ? void 0 : d.coordinate;
1365
1375
  a.speed = e.speed;
1366
- const l = o.clone().add(a.hourFromPrevious, "hour");
1367
- 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((c - a.distanceFromStart) * 100) / 100, a.timeToGo = Math.round(o.clone().add(r, "hour").diff(N(a.etd), "hour") * 100) / 100;
1368
- const u = this.calculateRangeWaypoints(e, a, n);
1376
+ const u = o.clone().add(a.hourFromPrevious, "hour");
1377
+ a.eta = Math.abs(u.diff(r, "second")) < 2 ? r.format() : u.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(N(a.etd), "hour") * 100) / 100;
1378
+ const l = this.calculateRangeWaypoints(e, a, n);
1369
1379
  return {
1370
- routes: this.generateRouteAccordingToWaypoints(u),
1380
+ routes: this.generateRouteAccordingToWaypoints(l),
1371
1381
  hour: a
1372
1382
  };
1373
1383
  }
@@ -1385,7 +1395,7 @@ class S {
1385
1395
  * 判断路径是否与ECA区域相交
1386
1396
  * @param path
1387
1397
  * @param ecaZones
1388
- * @see https://osshz.idmwx.com/layers/other/eca-zones.json
1398
+ * @see https://ossjson.ormwx.com/layers/other/eca-zones.json
1389
1399
  * @return 返回相交的区域
1390
1400
  * [
1391
1401
  * {
@@ -1397,36 +1407,36 @@ class S {
1397
1407
  * 如果没有相交区域,返回空数组。
1398
1408
  */
1399
1409
  static async intersectInECA(t, e) {
1400
- var c, r;
1401
- const s = (e instanceof Array ? e : e.features).filter((i) => {
1410
+ var c, i;
1411
+ const s = (e instanceof Array ? e : e.features).filter((r) => {
1402
1412
  var o, a;
1403
- return ((o = i.geometry) == null ? void 0 : o.type) === "Polygon" && !((a = i.properties) != null && a.disabled);
1413
+ return ((o = r.geometry) == null ? void 0 : o.type) === "Polygon" && !((a = r.properties) != null && a.disabled);
1404
1414
  });
1405
1415
  if (t != null && t.length) {
1406
- let i = t;
1407
- t.some((u) => u instanceof Array) ? t = this.convertRouteToCoordinates(t) : i = this.divideAccordingToLng(t);
1408
- const o = i.map((u) => T.lineString(u)), a = [], l = s.map((u) => ({
1409
- polygon: u,
1410
- bbox: T.bbox(u)
1416
+ let r = t;
1417
+ t.some((l) => l instanceof Array) ? t = this.convertRouteToCoordinates(t) : r = this.divideAccordingToLng(t);
1418
+ const o = r.map((l) => T.lineString(l)), a = [], u = s.map((l) => ({
1419
+ polygon: l,
1420
+ bbox: T.bbox(l)
1411
1421
  // [minX, minY, maxX, maxY]
1412
1422
  }));
1413
- for (const u of o) {
1414
- const m = u.geometry.coordinates, d = this.convertRouteToCoordinates([m]), p = T.bbox(u);
1415
- for (const { polygon: f, bbox: g } of l) {
1423
+ for (const l of o) {
1424
+ const m = l.geometry.coordinates, d = this.convertRouteToCoordinates([m]), p = T.bbox(l);
1425
+ for (const { polygon: f, bbox: g } of u) {
1416
1426
  if (p[0] > g[2] || p[2] < g[0] || p[1] > g[3] || p[3] < g[1])
1417
1427
  continue;
1418
- let b = [];
1419
- const v = T.lineIntersect(u, f);
1420
- (c = v == null ? void 0 : v.features) != null && c.length && (b = T.getCoords(v.features).map((P) => {
1428
+ let S = [];
1429
+ const v = T.lineIntersect(l, f);
1430
+ (c = v == null ? void 0 : v.features) != null && c.length && (S = T.getCoords(v.features).map((P) => {
1421
1431
  const D = T.getCoord(P);
1422
1432
  return { lng: D[0], lat: D[1] };
1423
1433
  }));
1424
1434
  const x = [...d];
1425
- if (b.length > 0)
1426
- for (const y of b)
1435
+ if (S.length > 0)
1436
+ for (const y of S)
1427
1437
  this.mergeCoordinateToWaypoints(y, x, !0);
1428
1438
  for (let y = 0; y < x.length - 1; y++) {
1429
- const P = x[y], D = x[y + 1], E = this.calculateRangeWaypoints(P, D, [], x), F = this.divideAccordingToLng(E);
1439
+ const P = x[y], D = x[y + 1], U = this.calculateRangeWaypoints(P, D, [], x), F = this.divideAccordingToLng(U);
1430
1440
  for (const $ of F) {
1431
1441
  const R = [
1432
1442
  Math.min($[0][0], $[$.length - 1][0]),
@@ -1438,11 +1448,11 @@ class S {
1438
1448
  continue;
1439
1449
  const M = T.lineString($);
1440
1450
  if (T.booleanContains(f, M)) {
1441
- const k = $.map((U) => ({ lng: U[0], lat: U[1] })), j = this.calculateRouteDistance([$]);
1451
+ const w = $.map((E) => ({ lng: E[0], lat: E[1] })), j = this.calculateRouteDistance([$]);
1442
1452
  a.push({
1443
1453
  distance: j,
1444
- waypoints: k,
1445
- eca: (r = f == null ? void 0 : f.properties) == null ? void 0 : r.name
1454
+ waypoints: w,
1455
+ eca: (i = f == null ? void 0 : f.properties) == null ? void 0 : i.name
1446
1456
  });
1447
1457
  }
1448
1458
  }
@@ -1454,13 +1464,13 @@ class S {
1454
1464
  return [];
1455
1465
  }
1456
1466
  }
1457
- let A;
1467
+ let O;
1458
1468
  try {
1459
- A = G.getLogger("vessel");
1469
+ O = J.getLogger("vessel");
1460
1470
  } catch {
1461
1471
  } finally {
1462
1472
  }
1463
- class it {
1473
+ class ut {
1464
1474
  /**
1465
1475
  * 将原始数据转换为geojson
1466
1476
  * @param raw
@@ -1468,23 +1478,23 @@ class it {
1468
1478
  static convert2Geojson(t) {
1469
1479
  var n, s, c;
1470
1480
  const e = T.featureCollection([]);
1471
- for (const r of t) {
1472
- const i = (n = r.history) == null ? void 0 : n[0];
1473
- if (r.forecasts) {
1474
- i && i.wind && (i.wind.kts = i.kts);
1475
- for (const o of r.forecasts) {
1481
+ for (const i of t) {
1482
+ const r = (n = i.history) == null ? void 0 : n[0];
1483
+ if (i.forecasts) {
1484
+ r && r.wind && (r.wind.kts = r.kts);
1485
+ for (const o of i.forecasts) {
1476
1486
  let a;
1477
- const l = [], u = [], m = N(o.date).utc(), d = `${r.name}-${o.model}`;
1487
+ const u = [], l = [], m = N(o.date).utc(), d = `${i.name}-${o.model}`;
1478
1488
  for (const f in o == null ? void 0 : o.hours) {
1479
1489
  const g = o.hours[f];
1480
1490
  a = a || g;
1481
- const b = m.clone().add(Number(f), "hour"), v = T.point([g.lng, g.lat], {
1491
+ const S = m.clone().add(Number(f), "hour"), v = T.point([g.lng, g.lat], {
1482
1492
  model: o.model,
1483
- name: r.name,
1484
- nameCn: r.nameCn,
1485
- date: b.format(),
1493
+ name: i.name,
1494
+ nameCn: i.nameCn,
1495
+ date: S.format(),
1486
1496
  hour: Number(f),
1487
- format: b.format("MMM-DD/HHmm[Z]"),
1497
+ format: S.format("MMM-DD/HHmm[Z]"),
1488
1498
  pressure: g.pressure > 1e4 ? h.roundPrecision(g.pressure / 100, 0) : h.roundPrecision(g.pressure, 0),
1489
1499
  gusts: g.gusts,
1490
1500
  wind: g.wind || {},
@@ -1492,41 +1502,41 @@ class it {
1492
1502
  category: d,
1493
1503
  type: "forecast"
1494
1504
  });
1495
- u.push(v), l.push(v.geometry.coordinates);
1505
+ l.push(v), u.push(v.geometry.coordinates);
1496
1506
  }
1497
1507
  const p = {
1498
1508
  kts: void 0,
1499
1509
  deg: void 0
1500
1510
  };
1501
- if (i) {
1502
- const f = N(i.updated).utc();
1511
+ if (r) {
1512
+ const f = N(r.updated).utc();
1503
1513
  if (a) {
1504
- const b = S.calculateDistance(i, a), v = N(a.utc || a.updated).diff(f, "h", !0);
1505
- p.kts = Math.round(b / v * 100) / 100, p.deg = S.calculateBearing(i, a, !0, 0);
1514
+ const S = b.calculateDistance(r, a), v = N(a.utc || a.updated).diff(f, "h", !0);
1515
+ p.kts = Math.round(S / v * 100) / 100, p.deg = b.calculateBearing(r, a, !0, 0);
1506
1516
  }
1507
- const g = T.point([i.lng, i.lat], {
1517
+ const g = T.point([r.lng, r.lat], {
1508
1518
  model: o.model,
1509
- name: r.name,
1510
- nameCn: r.nameCn,
1519
+ name: i.name,
1520
+ nameCn: i.nameCn,
1511
1521
  date: f.format(),
1512
1522
  hour: 0,
1513
1523
  format: f.format("MMM-DD/HHmm[Z]"),
1514
- pressure: i.pressure > 1e4 ? h.roundPrecision((i == null ? void 0 : i.pressure) / 100, 0) : h.roundPrecision(i.pressure, 0),
1515
- wind: i.wind,
1524
+ pressure: r.pressure > 1e4 ? h.roundPrecision((r == null ? void 0 : r.pressure) / 100, 0) : h.roundPrecision(r.pressure, 0),
1525
+ wind: r.wind,
1516
1526
  movement: p,
1517
1527
  category: d,
1518
1528
  type: "forecast",
1519
1529
  important: !0
1520
1530
  // 第一个预报点为重要点
1521
1531
  });
1522
- u.unshift(g), l.unshift(g.geometry.coordinates);
1532
+ l.unshift(g), u.unshift(g.geometry.coordinates);
1523
1533
  }
1524
- if (e.features.push(...u), (l == null ? void 0 : l.length) > 1) {
1525
- const f = T.lineString(h.convertToMonotonicLng2(l), {
1526
- date: (i == null ? void 0 : i.updated) || (m == null ? void 0 : m.format()),
1527
- id: r.id || r.name,
1534
+ if (e.features.push(...l), (u == null ? void 0 : u.length) > 1) {
1535
+ const f = T.lineString(h.convertToMonotonicLng2(u), {
1536
+ date: (r == null ? void 0 : r.updated) || (m == null ? void 0 : m.format()),
1537
+ id: i.id || i.name,
1528
1538
  model: o.model,
1529
- name: r.name,
1539
+ name: i.name,
1530
1540
  category: d,
1531
1541
  type: "forecast",
1532
1542
  movement: p
@@ -1535,21 +1545,21 @@ class it {
1535
1545
  }
1536
1546
  }
1537
1547
  }
1538
- if (e.features.sort((o, a) => o.properties.type === "forecast" && a.properties.type === "forecast" && o.geometry.type === "Point" && a.geometry.type === "Point" ? N(o.properties.date).valueOf() - N(a.properties.date).valueOf() : 0), (s = r.history) != null && s.length) {
1539
- const o = [], a = N(i == null ? void 0 : i.updated).utc(), l = N((c = r.history) == null ? void 0 : c.at(-1).updated).utc(), u = a.diff(l, "h") % 24 > 2 ? 24 : 12;
1540
- for (const m of r.history) {
1541
- const d = N(m.updated).utc(), p = d.isSameOrBefore(a) || d.isSame(l);
1542
- p && a.add(-u, "h");
1548
+ if (e.features.sort((o, a) => o.properties.type === "forecast" && a.properties.type === "forecast" && o.geometry.type === "Point" && a.geometry.type === "Point" ? N(o.properties.date).valueOf() - N(a.properties.date).valueOf() : 0), (s = i.history) != null && s.length) {
1549
+ const o = [], a = N(r == null ? void 0 : r.updated).utc(), u = N((c = i.history) == null ? void 0 : c.at(-1).updated).utc(), l = a.diff(u, "h") % 24 > 2 ? 24 : 12;
1550
+ for (const m of i.history) {
1551
+ const d = N(m.updated).utc(), p = d.isSameOrBefore(a) || d.isSame(u);
1552
+ p && a.add(-l, "h");
1543
1553
  const f = T.point([m.lng, m.lat], {
1544
- name: r.name,
1545
- nameCn: r.nameCn,
1554
+ name: i.name,
1555
+ nameCn: i.nameCn,
1546
1556
  date: d.format(),
1547
1557
  format: d.format("MMM-DD/HHmm[Z]"),
1548
1558
  pressure: m.pressure > 1e4 ? h.roundPrecision(m.pressure / 100, 0) : h.roundPrecision(m.pressure, 0),
1549
1559
  kts: m.kts,
1550
1560
  level: m.type,
1551
1561
  type: "history",
1552
- category: `${r.name}-history`,
1562
+ category: `${i.name}-history`,
1553
1563
  wind: m.wind,
1554
1564
  movement: m.movement,
1555
1565
  important: p
@@ -1558,12 +1568,12 @@ class it {
1558
1568
  }
1559
1569
  if (o.length === 1 && o.push(o[0]), o.length > 1) {
1560
1570
  const m = T.lineString(h.convertToMonotonicLng2(o), {
1561
- name: r.name,
1571
+ name: i.name,
1562
1572
  type: "history",
1563
- updated: i == null ? void 0 : i.updated,
1564
- pressure: (i == null ? void 0 : i.pressure) > 1e4 ? h.roundPrecision((i == null ? void 0 : i.pressure) / 100, 0) : h.roundPrecision(i == null ? void 0 : i.pressure, 0),
1565
- kts: i == null ? void 0 : i.kts,
1566
- level: i == null ? void 0 : i.type
1573
+ updated: r == null ? void 0 : r.updated,
1574
+ 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),
1575
+ kts: r == null ? void 0 : r.kts,
1576
+ level: r == null ? void 0 : r.type
1567
1577
  });
1568
1578
  e.features.push(m);
1569
1579
  }
@@ -1577,20 +1587,20 @@ class it {
1577
1587
  * @param step
1578
1588
  */
1579
1589
  static interpolate(t, e = 3) {
1580
- var c, r, i, o;
1590
+ var c, i, r, o;
1581
1591
  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 = [];
1582
1592
  for (const a of n) {
1583
- const l = a.properties.name, u = a.properties.model, m = a.properties.showCircle, d = a.properties.disabled, p = N(a.properties.date).utc();
1593
+ const u = a.properties.name, l = a.properties.model, m = a.properties.showCircle, d = a.properties.disabled, p = N(a.properties.date).utc();
1584
1594
  let f = e * 60;
1585
- const g = (r = t == null ? void 0 : t.data) == null ? void 0 : r.features.filter(
1586
- (x) => x.geometry.type === "Point" && x.properties.type === "forecast" && x.properties.category === `${l}-${u}`
1595
+ const g = (i = t == null ? void 0 : t.data) == null ? void 0 : i.features.filter(
1596
+ (x) => x.geometry.type === "Point" && x.properties.type === "forecast" && x.properties.category === `${u}-${l}`
1587
1597
  );
1588
- let b, v = p.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1589
- for (; b = this.pickIndex(g, v), b <= g.length - 1; ) {
1590
- if (b > 0) {
1591
- const x = g[b], y = b === 0 ? void 0 : g[b - 1], P = (f / 60 - ((i = y == null ? void 0 : y.properties) == null ? void 0 : i.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], P), E = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[1], x.geometry.coordinates[1], P), F = T.point([D, E], {
1592
- name: l,
1593
- model: u,
1598
+ let S, v = p.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1599
+ for (; S = this.pickIndex(g, v), S <= g.length - 1; ) {
1600
+ if (S > 0) {
1601
+ const x = g[S], y = S === 0 ? void 0 : g[S - 1], P = (f / 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], P), U = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[1], x.geometry.coordinates[1], P), F = T.point([D, U], {
1602
+ name: u,
1603
+ model: l,
1594
1604
  category: x == null ? void 0 : x.properties.category,
1595
1605
  date: v.format(),
1596
1606
  format: v.format("MMM-DD/HHmm[Z]"),
@@ -1617,8 +1627,8 @@ class it {
1617
1627
  * @param options
1618
1628
  */
1619
1629
  static accelPassageAt(t, e) {
1620
- const { t1: n, t2: s, hr: c, hours: r } = this.tropicalCenterTwin(t, 24, e);
1621
- return { t1: n, t2: s, hr: c, hours: r };
1630
+ const { t1: n, t2: s, hr: c, hours: i } = this.tropicalCenterTwin(t, 24, e);
1631
+ return { t1: n, t2: s, hr: c, hours: i };
1622
1632
  }
1623
1633
  /**
1624
1634
  * 计算最佳绕航点
@@ -1632,31 +1642,31 @@ class it {
1632
1642
  * @param options
1633
1643
  */
1634
1644
  static diversionPassageAt(t, e, n, s = {}) {
1635
- const { t1: c, t2: r, hr: i, hours: o } = this.tropicalCenterTwin(e, 24, s);
1636
- if (c && r) {
1645
+ const { t1: c, t2: i, hr: r, hours: o } = this.tropicalCenterTwin(e, 24, s);
1646
+ if (c && i) {
1637
1647
  if (!s.debug) {
1638
- const p = S.calculateDistance(t, c), f = S.calculateDistance(t, r);
1648
+ const p = b.calculateDistance(t, c), f = b.calculateDistance(t, i);
1639
1649
  if (p > 2 * n && f > 2 * n)
1640
- 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, {
1650
+ return O == null || O.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, p, f, {
1641
1651
  from: t,
1642
1652
  t1: c,
1643
- t2: r,
1644
- hr: i
1653
+ t2: i,
1654
+ hr: r
1645
1655
  }), {};
1646
1656
  }
1647
- const a = S.calculateBearing(t, c), l = S.calculateBearing(c, r), u = Math.abs(a - l);
1657
+ const a = b.calculateBearing(t, c), u = b.calculateBearing(c, i), l = Math.abs(a - u);
1648
1658
  let m = 0;
1649
- u < 180 ? m = u + 90 : u >= 180 && (m = u - 90);
1650
- const d = S.calculateCoordinate(c, m, n);
1651
- return A == null || A.info("[%s] the right tangent position: %j", s.requestId, {
1659
+ l < 180 ? m = l + 90 : l >= 180 && (m = l - 90);
1660
+ const d = b.calculateCoordinate(c, m, n);
1661
+ return O == null || O.info("[%s] the right tangent position: %j", s.requestId, {
1652
1662
  from: t,
1653
1663
  t1: c,
1654
- t2: r,
1664
+ t2: i,
1655
1665
  radius: n,
1656
1666
  bearing1: a,
1657
- bearing2: l,
1667
+ bearing2: u,
1658
1668
  right: d
1659
- }), { at: d, t1: c, t2: r, hr: Number(i), hours: o };
1669
+ }), { at: d, t1: c, t2: i, hr: Number(r), hours: o };
1660
1670
  }
1661
1671
  return {};
1662
1672
  }
@@ -1671,22 +1681,22 @@ class it {
1671
1681
  * @param options
1672
1682
  */
1673
1683
  static driftPassageAt(t, e, n, s = {}) {
1674
- const { t1: c, t2: r, hr: i, hours: o } = this.tropicalCenterTwin(e, 24, s);
1675
- if (c && r) {
1684
+ const { t1: c, t2: i, hr: r, hours: o } = this.tropicalCenterTwin(e, 24, s);
1685
+ if (c && i) {
1676
1686
  if (!s.debug) {
1677
- const d = S.calculateDistance(t, c), p = S.calculateDistance(t, r);
1687
+ const d = b.calculateDistance(t, c), p = b.calculateDistance(t, i);
1678
1688
  if (d > 2 * n && p > 2 * n)
1679
- 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, {
1689
+ return O == null || O.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, d, p, {
1680
1690
  from: t,
1681
1691
  t1: c,
1682
- t2: r,
1683
- hr: i
1692
+ t2: i,
1693
+ hr: r
1684
1694
  }), {};
1685
1695
  }
1686
- const a = S.calculateBearing(t, c), l = S.calculateBearing(c, r), u = S.calculateDistance(t, c);
1687
- return { at: S.calculateCoordinate(c, a - l + 180, n < u ? n : u), t1: c, t2: r, hr: Number(i), hours: o };
1696
+ const a = b.calculateBearing(t, c), u = b.calculateBearing(c, i), l = b.calculateDistance(t, c);
1697
+ return { at: b.calculateCoordinate(c, a - u + 180, n < l ? n : l), t1: c, t2: i, hr: Number(r), hours: o };
1688
1698
  } else
1689
- return A == null || A.info("[%s] no need drift: %j", s.requestId, { from: t, t1: c, t2: r, hr: i }), {};
1699
+ return O == null || O.info("[%s] no need drift: %j", s.requestId, { from: t, t1: c, t2: i, hr: r }), {};
1690
1700
  }
1691
1701
  /**
1692
1702
  * 获取台风中心点对
@@ -1697,21 +1707,21 @@ class it {
1697
1707
  * @private
1698
1708
  */
1699
1709
  static tropicalCenterTwin(t, e = 24, n = {}) {
1700
- var l, u, m, d, p;
1710
+ var u, l, m, d, p;
1701
1711
  let s = {};
1702
- (l = t.forecasts) == null || l.forEach((f) => {
1712
+ (u = t.forecasts) == null || u.forEach((f) => {
1703
1713
  s = { ...f.hours, ...s };
1704
1714
  });
1705
- const c = ((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]]);
1706
- A == null || A.info("[%s] the first tropical center: %j", n.requestId, c);
1707
- let r = (d = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : e))) == null ? void 0 : d.at(-1);
1708
- r || (r = (p = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : p.at(-1));
1709
- const i = s == null ? void 0 : s[r || -1];
1710
- A == null || A.info("[%s] the second tropical center: %j in %d hrs", n.requestId, i, r);
1711
- const o = Object.keys(s || {}).filter((f) => Number(f) <= Number(r)), a = { 0: c };
1715
+ const c = ((l = t == null ? void 0 : t.history) == null ? void 0 : l[0]) || (s == null ? void 0 : s[(m = Object.keys(s)) == null ? void 0 : m[0]]);
1716
+ O == null || O.info("[%s] the first tropical center: %j", n.requestId, c);
1717
+ let i = (d = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : e))) == null ? void 0 : d.at(-1);
1718
+ i || (i = (p = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : p.at(-1));
1719
+ const r = s == null ? void 0 : s[i || -1];
1720
+ O == null || O.info("[%s] the second tropical center: %j in %d hrs", n.requestId, r, i);
1721
+ const o = Object.keys(s || {}).filter((f) => Number(f) <= Number(i)), a = { 0: c };
1712
1722
  for (const f of o)
1713
1723
  a[f] = s[f];
1714
- return { t1: c, t2: i, hr: Number(r), hours: a };
1724
+ return { t1: c, t2: r, hr: Number(i), hours: a };
1715
1725
  }
1716
1726
  static pickIndex(t, e) {
1717
1727
  let n = 0;
@@ -1752,13 +1762,13 @@ typeof globalThis < "u" && typeof globalThis.Buffer > "u" && (globalThis.Buffer
1752
1762
  throw new TypeError("Buffer.from: unsupported source type");
1753
1763
  }
1754
1764
  });
1755
- let O;
1765
+ let k;
1756
1766
  try {
1757
- O = G.getLogger("meteo");
1767
+ k = J.getLogger("meteo");
1758
1768
  } catch {
1759
1769
  } finally {
1760
1770
  }
1761
- function H() {
1771
+ function st() {
1762
1772
  if (typeof DOMParser < "u")
1763
1773
  return new DOMParser();
1764
1774
  const { JSDOM: C } = require("jsdom"), { DOMParser: t } = new C("").window;
@@ -1783,10 +1793,10 @@ class W {
1783
1793
  * @param options 步数、单位等选项
1784
1794
  */
1785
1795
  static drawCircle(t, e, n, s = {}) {
1786
- const c = (s == null ? void 0 : s.steps) ?? 64, r = (s == null ? void 0 : s.units) ?? "nauticalmiles", i = (s == null ? void 0 : s.properties) ?? {}, o = T.point([t, e]), a = T.destination(o, n, 90, { units: r }), l = N.utc();
1787
- i.id = (s == null ? void 0 : s.id) || l.valueOf().toString();
1788
- const u = "circle";
1789
- 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) => h.roundPrecision(m, 9)), i.units = r, i.steps = c, i.shape = "circle", O.info("[%s] draw circle with %j", s == null ? void 0 : s.requestId, i), T.circle(o, n, { steps: c, units: r, properties: i });
1796
+ 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 }), u = N.utc();
1797
+ r.id = (s == null ? void 0 : s.id) || u.valueOf().toString();
1798
+ const l = "circle";
1799
+ return r.name = (s == null ? void 0 : s.name) || `${l}_${u.format()}`, r.radius = n, r.center = [t, e], r.end = a.geometry.coordinates.map((m) => h.roundPrecision(m, 9)), r.units = i, r.steps = c, r.shape = "circle", k.info("[%s] draw circle with %j", s == null ? void 0 : s.requestId, r), T.circle(o, n, { steps: c, units: i, properties: r });
1790
1800
  }
1791
1801
  /**
1792
1802
  * 基于turf画矩形,返回GeoJSON Feature<Polygon>
@@ -1797,9 +1807,9 @@ class W {
1797
1807
  static drawRect(t, e, n = {}) {
1798
1808
  const s = (n == null ? void 0 : n.properties) ?? {}, c = N.utc();
1799
1809
  s.id = (n == null ? void 0 : n.id) || c.valueOf().toString();
1800
- const r = "rect";
1801
- s.name = (n == null ? void 0 : n.name) || `${r}_${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);
1802
- const [i, o] = h.convertToMonotonicLng2([t, e]), a = [Math.min(i[0], o[0]), Math.min(i[1], o[1]), Math.max(i[0], o[0]), Math.max(i[1], o[1])];
1810
+ const i = "rect";
1811
+ s.name = (n == null ? void 0 : n.name) || `${i}_${c.format()}`, s.start = t.map((u) => h.roundPrecision(u, 9)), s.end = e.map((u) => h.roundPrecision(u, 9)), s.shape = "rect", k.info("[%s] draw rect with %j", n == null ? void 0 : n.requestId, s);
1812
+ 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])];
1803
1813
  return T.bboxPolygon(a, { properties: s });
1804
1814
  }
1805
1815
  /**
@@ -1813,9 +1823,9 @@ class W {
1813
1823
  const n = (e == null ? void 0 : e.properties) ?? {}, s = N.utc();
1814
1824
  n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1815
1825
  const c = "line";
1816
- 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);
1817
- const r = h.convertToMonotonicLng2(t);
1818
- return T.lineString(r, n);
1826
+ n.name = (e == null ? void 0 : e.name) || `${c}_${s.format()}`, n.shape = "line", k.info("[%s] draw line with %j", e == null ? void 0 : e.requestId, n);
1827
+ const i = h.convertToMonotonicLng2(t);
1828
+ return T.lineString(i, n);
1819
1829
  }
1820
1830
  /**
1821
1831
  * 基于turf画多边形,返回GeoJSON Feature<Polygon>
@@ -1827,9 +1837,9 @@ class W {
1827
1837
  const n = (e == null ? void 0 : e.properties) ?? {}, s = N.utc();
1828
1838
  n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1829
1839
  const c = "polygon";
1830
- n.name = (e == null ? void 0 : e.name) || `${c}_${s.format()}`, n.coordinates = t.map((i) => i.map((o) => h.roundPrecision(o, 9))), n.shape = "polygon", O.info("[%s] draw polygon with %j", e == null ? void 0 : e.requestId, n);
1831
- const r = h.convertToMonotonicLng2(t);
1832
- return T.polygon([r], n);
1840
+ 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", k.info("[%s] draw polygon with %j", e == null ? void 0 : e.requestId, n);
1841
+ const i = h.convertToMonotonicLng2(t);
1842
+ return T.polygon([i], n);
1833
1843
  }
1834
1844
  /**
1835
1845
  * 基于turf画点,返回GeoJSON Feature<Point>
@@ -1841,8 +1851,8 @@ class W {
1841
1851
  static drawPoint(t, e, n = {}) {
1842
1852
  const s = (n == null ? void 0 : n.properties) ?? {}, c = N.utc();
1843
1853
  s.id = (n == null ? void 0 : n.id) || c.valueOf().toString();
1844
- const r = "point";
1845
- return s.name = (n == null ? void 0 : n.name) || `${r}_${c.format()}`, s.shape = "point", O.info("[%s] draw point with %j", n == null ? void 0 : n.requestId, s), T.point([e, t], s);
1854
+ const i = "point";
1855
+ return s.name = (n == null ? void 0 : n.name) || `${i}_${c.format()}`, s.shape = "point", k.info("[%s] draw point with %j", n == null ? void 0 : n.requestId, s), T.point([e, t], s);
1846
1856
  }
1847
1857
  /**
1848
1858
  * 解析ORM GeoJSON Feature (圆), 返回FeatureCollection
@@ -1853,27 +1863,27 @@ class W {
1853
1863
  */
1854
1864
  static parseCircle(t, e = {}) {
1855
1865
  var s, c;
1856
- O.info("[%s] parse circle with %j", e == null ? void 0 : e.requestId, t.properties);
1866
+ k.info("[%s] parse circle with %j", e == null ? void 0 : e.requestId, t.properties);
1857
1867
  const n = t.properties || {};
1858
1868
  if (n.shape == "circle") {
1859
- const r = N.utc();
1860
- n.id = (n == null ? void 0 : n.id) || r.valueOf().toString();
1861
- const i = 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);
1869
+ const i = N.utc();
1870
+ n.id = (n == null ? void 0 : n.id) || i.valueOf().toString();
1871
+ 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);
1862
1872
  let a = "center";
1863
- o.properties = { id: `${a}_${i}`, parentId: i, name: a };
1864
- const l = (n == null ? void 0 : n.units) || "nauticalmiles";
1865
- let u = n == null ? void 0 : n.radius;
1866
- if (!u) {
1873
+ o.properties = { id: `${a}_${r}`, parentId: r, name: a };
1874
+ const u = (n == null ? void 0 : n.units) || "nauticalmiles";
1875
+ let l = n == null ? void 0 : n.radius;
1876
+ if (!l) {
1867
1877
  const p = T.polygonToLine(t);
1868
- u = T.pointToLineDistance(o, p, { units: l });
1878
+ l = T.pointToLineDistance(o, p, { units: u });
1869
1879
  }
1870
1880
  a = "end";
1871
- const m = ((c = n == null ? void 0 : n.end) == null ? void 0 : c.length) == 2 ? T.point(n.end) : T.destination(o, u, 90, { units: l });
1872
- m.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l };
1881
+ const m = ((c = n == null ? void 0 : n.end) == null ? void 0 : c.length) == 2 ? T.point(n.end) : T.destination(o, l, 90, { units: u });
1882
+ m.properties = { id: `${a}_${r}`, parentId: r, name: a, radius: l, units: u };
1873
1883
  const d = T.lineString([o.geometry.coordinates, m.geometry.coordinates]);
1874
- return a = "edge", d.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l }, T.featureCollection([o, m, d, t]);
1884
+ return a = "edge", d.properties = { id: `${a}_${r}`, parentId: r, name: a, radius: l, units: u }, T.featureCollection([o, m, d, t]);
1875
1885
  } else
1876
- return O.warn("[%s] not a orm-std circle, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1886
+ return k.warn("[%s] not a orm-std circle, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1877
1887
  }
1878
1888
  /**
1879
1889
  * 解析ORM GeoJSON Feature (矩形), 返回FeatureCollection
@@ -1883,18 +1893,18 @@ class W {
1883
1893
  * 如果feature是矩形,则返回矩形的四个顶点和矩形Feature
1884
1894
  */
1885
1895
  static parseRect(t, e = {}) {
1886
- O.info("[%s] parse rect with %j", e == null ? void 0 : e.requestId, t.properties);
1896
+ k.info("[%s] parse rect with %j", e == null ? void 0 : e.requestId, t.properties);
1887
1897
  const n = t.properties || {};
1888
1898
  if (n.shape == "rect") {
1889
1899
  const s = N.utc();
1890
1900
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1891
- const c = n == null ? void 0 : n.id, r = t.geometry.coordinates[0], o = ["sw", "nw", "ne", "se"].map((a, l) => {
1892
- const u = T.point(r[l]);
1893
- return u.properties = { id: `${a}_${c}`, parentId: c, name: a }, u;
1901
+ const c = n == null ? void 0 : n.id, i = t.geometry.coordinates[0], o = ["sw", "nw", "ne", "se"].map((a, u) => {
1902
+ const l = T.point(i[u]);
1903
+ return l.properties = { id: `${a}_${c}`, parentId: c, name: a }, l;
1894
1904
  });
1895
1905
  return T.featureCollection([...o, t]);
1896
1906
  } else
1897
- return O.warn("[%s] not a orm-std rect, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1907
+ return k.warn("[%s] not a orm-std rect, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1898
1908
  }
1899
1909
  /**
1900
1910
  * 解析ORM GeoJSON Feature (线), 返回FeatureCollection
@@ -1904,18 +1914,18 @@ class W {
1904
1914
  * 如果feature是线,则返回所有坐标点(首为start、尾为end、中间为point_N)以及线Feature
1905
1915
  */
1906
1916
  static parseLine(t, e = {}) {
1907
- O.info("[%s] parse line with %j", e == null ? void 0 : e.requestId, t.properties);
1917
+ k.info("[%s] parse line with %j", e == null ? void 0 : e.requestId, t.properties);
1908
1918
  const n = t.properties || {};
1909
1919
  if (n.shape == "line") {
1910
1920
  const s = N.utc();
1911
1921
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1912
- const c = n == null ? void 0 : n.id, i = t.geometry.coordinates.map((o, a) => {
1913
- const l = `point_${a}`, u = T.point(o);
1914
- return u.properties = { id: `${l}_${c}`, parentId: c, name: l, index: a }, u;
1922
+ const c = n == null ? void 0 : n.id, r = t.geometry.coordinates.map((o, a) => {
1923
+ const u = `point_${a}`, l = T.point(o);
1924
+ return l.properties = { id: `${u}_${c}`, parentId: c, name: u, index: a }, l;
1915
1925
  });
1916
- return T.featureCollection([...i, t]);
1926
+ return T.featureCollection([...r, t]);
1917
1927
  } else
1918
- return O.warn("[%s] not a orm-std line, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1928
+ return k.warn("[%s] not a orm-std line, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1919
1929
  }
1920
1930
  /**
1921
1931
  * 解析ORM GeoJSON Feature (多边形), 返回FeatureCollection
@@ -1925,18 +1935,18 @@ class W {
1925
1935
  * 如果feature是多边形,则返回多边形的顶点和多边形Feature
1926
1936
  */
1927
1937
  static parsePolygon(t, e = {}) {
1928
- O.info("[%s] parse polygon with %j", e == null ? void 0 : e.requestId, t.properties);
1938
+ k.info("[%s] parse polygon with %j", e == null ? void 0 : e.requestId, t.properties);
1929
1939
  const n = t.properties || {};
1930
1940
  if (n.shape == "polygon") {
1931
1941
  const s = N.utc();
1932
1942
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1933
- const c = n == null ? void 0 : n.id, i = t.geometry.coordinates[0].map((o, a) => {
1934
- const l = T.point(o), u = `corner_${a}`;
1935
- return l.properties = { id: `${u}_${c}`, parentId: c, name: u, index: a }, l;
1943
+ const c = n == null ? void 0 : n.id, r = t.geometry.coordinates[0].map((o, a) => {
1944
+ const u = T.point(o), l = `corner_${a}`;
1945
+ return u.properties = { id: `${l}_${c}`, parentId: c, name: l, index: a }, u;
1936
1946
  });
1937
- return T.featureCollection([...i, t]);
1947
+ return T.featureCollection([...r, t]);
1938
1948
  } else
1939
- return O.warn("[%s] not a orm-std polygon, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1949
+ return k.warn("[%s] not a orm-std polygon, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1940
1950
  }
1941
1951
  // ---------------------------------------------------------------------------
1942
1952
  // ZIP / KMZ 内部工具
@@ -1959,51 +1969,51 @@ class W {
1959
1969
  */
1960
1970
  static async _parseZipEntries(t) {
1961
1971
  var m;
1962
- const e = new Uint8Array(t), n = e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), s = new DataView(n), c = new Uint8Array(n), r = /* @__PURE__ */ new Map();
1963
- let i = -1;
1972
+ const e = new Uint8Array(t), n = e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), s = new DataView(n), c = new Uint8Array(n), i = /* @__PURE__ */ new Map();
1973
+ let r = -1;
1964
1974
  for (let d = n.byteLength - 22; d >= 0; d--)
1965
1975
  if (s.getUint32(d, !0) === 101010256) {
1966
- i = d;
1976
+ r = d;
1967
1977
  break;
1968
1978
  }
1969
- if (i < 0)
1979
+ if (r < 0)
1970
1980
  throw new Error("Invalid ZIP file: EOCD not found");
1971
- s.getUint16(i + 8, !0);
1972
- const o = s.getUint32(i + 12, !0), a = s.getUint32(i + 16, !0);
1973
- let l = a;
1974
- const u = a + o;
1975
- for (; l < u; ) {
1976
- if (s.getUint32(l, !0) !== 33639248)
1977
- throw new Error(`Invalid ZIP file: Central Directory signature mismatch at offset ${l}`);
1978
- const p = s.getUint16(l + 10, !0), f = s.getUint32(l + 20, !0), g = s.getUint16(l + 28, !0), b = s.getUint16(l + 30, !0), v = s.getUint16(l + 32, !0), x = s.getUint32(l + 42, !0), y = c.slice(l + 46, l + 46 + g), P = 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 + f);
1981
+ s.getUint16(r + 8, !0);
1982
+ const o = s.getUint32(r + 12, !0), a = s.getUint32(r + 16, !0);
1983
+ let u = a;
1984
+ const l = a + o;
1985
+ for (; u < l; ) {
1986
+ if (s.getUint32(u, !0) !== 33639248)
1987
+ throw new Error(`Invalid ZIP file: Central Directory signature mismatch at offset ${u}`);
1988
+ const p = s.getUint16(u + 10, !0), f = s.getUint32(u + 20, !0), g = s.getUint16(u + 28, !0), S = s.getUint16(u + 30, !0), v = s.getUint16(u + 32, !0), x = s.getUint32(u + 42, !0), y = c.slice(u + 46, u + 46 + g), P = new TextDecoder().decode(y), D = s.getUint16(x + 26, !0), U = s.getUint16(x + 28, !0), F = x + 30 + D + U, $ = c.slice(F, F + f);
1979
1989
  if (p === 0)
1980
- r.set(P, $);
1990
+ i.set(P, $);
1981
1991
  else if (p === 8) {
1982
1992
  if (typeof DecompressionStream < "u") {
1983
- const R = new DecompressionStream("deflate-raw"), M = R.writable.getWriter(), k = R.readable.getReader();
1993
+ const R = new DecompressionStream("deflate-raw"), M = R.writable.getWriter(), w = R.readable.getReader();
1984
1994
  M.write($), M.close();
1985
1995
  const j = [];
1986
- let U = 0;
1996
+ let E = 0;
1987
1997
  for (; ; ) {
1988
- const { done: w, value: I } = await k.read();
1989
- if (w)
1998
+ const { done: A, value: I } = await w.read();
1999
+ if (A)
1990
2000
  break;
1991
- j.push(I), U += I.length;
2001
+ j.push(I), E += I.length;
1992
2002
  }
1993
- const Z = new Uint8Array(U);
2003
+ const Z = new Uint8Array(E);
1994
2004
  let B = 0;
1995
- for (const w of j)
1996
- Z.set(w, B), B += w.length;
1997
- r.set(P, Z);
2005
+ for (const A of j)
2006
+ Z.set(A, B), B += A.length;
2007
+ i.set(P, Z);
1998
2008
  } else if (typeof process < "u" && ((m = process.versions) != null && m.node))
1999
2009
  try {
2000
- r.set(P, W._inflateRawSync($));
2010
+ i.set(P, W._inflateRawSync($));
2001
2011
  } catch {
2002
2012
  }
2003
2013
  }
2004
- l += 46 + g + b + v;
2014
+ u += 46 + g + S + v;
2005
2015
  }
2006
- return r;
2016
+ return i;
2007
2017
  }
2008
2018
  // ---------------------------------------------------------------------------
2009
2019
  // KMZ / ZIP → GeoJSON
@@ -2015,24 +2025,24 @@ class W {
2015
2025
  * @returns
2016
2026
  */
2017
2027
  static async convertKML2GeoJSON(t, e = {}) {
2018
- var i, o;
2019
- O.info("[%s] convert kml to geojson", e == null ? void 0 : e.requestId);
2020
- const s = H().parseFromString(t, "application/xml"), c = Array.from(s.querySelectorAll("Placemark")), r = [];
2028
+ var r, o;
2029
+ k.info("[%s] convert kml to geojson", e == null ? void 0 : e.requestId);
2030
+ const s = st().parseFromString(t, "application/xml"), c = Array.from(s.querySelectorAll("Placemark")), i = [];
2021
2031
  for (const a of c) {
2022
- const l = {}, u = Array.from(a.querySelectorAll("ExtendedData > Data"));
2023
- for (const y of u) {
2024
- const P = y.getAttribute("name"), D = (o = (i = y.querySelector("value")) == null ? void 0 : i.textContent) == null ? void 0 : o.trim();
2025
- P && D !== void 0 && D !== null && (l[P] = D);
2032
+ const u = {}, l = Array.from(a.querySelectorAll("ExtendedData > Data"));
2033
+ for (const y of l) {
2034
+ const P = y.getAttribute("name"), D = (o = (r = y.querySelector("value")) == null ? void 0 : r.textContent) == null ? void 0 : o.trim();
2035
+ P && D !== void 0 && D !== null && (u[P] = D);
2026
2036
  }
2027
- const m = N.utc(), d = Object.keys(l).find((y) => y.toLowerCase().indexOf("name") !== -1), p = d ? l[d] : void 0, f = `${m.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, g = (y) => y.trim().split(/[\s\n]+/).filter((P) => P.length > 0).map((P) => {
2037
+ const m = N.utc(), d = Object.keys(u).find((y) => y.toLowerCase().indexOf("name") !== -1), p = d ? u[d] : void 0, f = `${m.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, g = (y) => y.trim().split(/[\s\n]+/).filter((P) => P.length > 0).map((P) => {
2028
2038
  const D = P.split(",").map(Number);
2029
2039
  return [D[0], D[1]];
2030
- }), b = a.querySelector("LineString > coordinates");
2031
- if (b) {
2032
- const y = g(b.textContent || "");
2040
+ }), S = a.querySelector("LineString > coordinates");
2041
+ if (S) {
2042
+ const y = g(S.textContent || "");
2033
2043
  if (y.length >= 2) {
2034
- const P = T.lineString(y, { ...l, shape: "line", id: f, name: p });
2035
- r.push(P);
2044
+ const P = T.lineString(y, { ...u, shape: "line", id: f, name: p });
2045
+ i.push(P);
2036
2046
  }
2037
2047
  continue;
2038
2048
  }
@@ -2040,8 +2050,8 @@ class W {
2040
2050
  if (v) {
2041
2051
  const y = g(v.textContent || "");
2042
2052
  if (y.length >= 4) {
2043
- const P = y[0][0] === y[y.length - 1][0] && y[0][1] === y[y.length - 1][1] ? y : [...y, y[0]], D = T.polygon([P], { ...l, shape: "polygon", id: f, name: p });
2044
- r.push(D);
2053
+ const P = y[0][0] === y[y.length - 1][0] && y[0][1] === y[y.length - 1][1] ? y : [...y, y[0]], D = T.polygon([P], { ...u, shape: "polygon", id: f, name: p });
2054
+ i.push(D);
2045
2055
  }
2046
2056
  continue;
2047
2057
  }
@@ -2049,13 +2059,13 @@ class W {
2049
2059
  if (x) {
2050
2060
  const y = g(x.textContent || "");
2051
2061
  if (y.length >= 1) {
2052
- const P = T.point(y[0], { ...l, shape: "point", id: f, name: p });
2053
- r.push(P);
2062
+ const P = T.point(y[0], { ...u, shape: "point", id: f, name: p });
2063
+ i.push(P);
2054
2064
  }
2055
2065
  continue;
2056
2066
  }
2057
2067
  }
2058
- return T.featureCollection(r);
2068
+ return T.featureCollection(i);
2059
2069
  }
2060
2070
  /**
2061
2071
  * 将 KMZ(ZIP 内含 doc.kml 或首个 .kml 文件)异步转换为 GeoJSON。
@@ -2067,11 +2077,11 @@ class W {
2067
2077
  * @param options
2068
2078
  */
2069
2079
  static async convertKMZ2GeoJSON(t, e = {}) {
2070
- var r;
2071
- O.info("[%s] convert kmz to geojson (async)", e == null ? void 0 : e.requestId), typeof Buffer < "u" && Buffer.isBuffer(t) && (t = W.toArrayBuffer(t));
2072
- const n = await W._parseZipEntries(t), s = n.get("doc.kml") ?? ((r = [...n.entries()].find(([i]) => i.toLowerCase().endsWith(".kml"))) == null ? void 0 : r[1]);
2080
+ var i;
2081
+ k.info("[%s] convert kmz to geojson (async)", e == null ? void 0 : e.requestId), typeof Buffer < "u" && Buffer.isBuffer(t) && (t = W.toArrayBuffer(t));
2082
+ const n = await W._parseZipEntries(t), s = n.get("doc.kml") ?? ((i = [...n.entries()].find(([r]) => r.toLowerCase().endsWith(".kml"))) == null ? void 0 : i[1]);
2073
2083
  if (!s)
2074
- return O.warn("[%s] no .kml file found in kmz", e == null ? void 0 : e.requestId), T.featureCollection([]);
2084
+ return k.warn("[%s] no .kml file found in kmz", e == null ? void 0 : e.requestId), T.featureCollection([]);
2075
2085
  const c = new TextDecoder().decode(s);
2076
2086
  return W.convertKML2GeoJSON(c, e);
2077
2087
  }
@@ -2085,15 +2095,15 @@ class W {
2085
2095
  * @param options
2086
2096
  */
2087
2097
  static async convertZIP2GeoJSON(t, e = {}) {
2088
- O.info("[%s] convert zip to geojson (async)", e == null ? void 0 : e.requestId), typeof Buffer < "u" && Buffer.isBuffer(t) && (t = W.toArrayBuffer(t));
2098
+ k.info("[%s] convert zip to geojson (async)", e == null ? void 0 : e.requestId), typeof Buffer < "u" && Buffer.isBuffer(t) && (t = W.toArrayBuffer(t));
2089
2099
  const n = await W._parseZipEntries(t), s = [];
2090
- for (const [c, r] of n) {
2100
+ for (const [c, i] of n) {
2091
2101
  if (!c.toLowerCase().endsWith(".kml"))
2092
2102
  continue;
2093
- const i = new TextDecoder().decode(r), o = await W.convertKML2GeoJSON(i, e);
2103
+ const r = new TextDecoder().decode(i), o = await W.convertKML2GeoJSON(r, e);
2094
2104
  s.push(...o.features);
2095
2105
  }
2096
- return s.length === 0 ? (O.warn("[%s] no .kml files found in zip", e == null ? void 0 : e.requestId), this.convertSHP2GeoJSON(t, e)) : T.featureCollection(s);
2106
+ return s.length === 0 ? (k.warn("[%s] no .kml files found in zip", e == null ? void 0 : e.requestId), this.convertSHP2GeoJSON(t, e)) : T.featureCollection(s);
2097
2107
  }
2098
2108
  /**
2099
2109
  * 将 Shapefile ZIP(含 .shp/.shx/.dbf/.prj)转换为 GeoJSON FeatureCollection。
@@ -2104,12 +2114,12 @@ class W {
2104
2114
  * @param options
2105
2115
  */
2106
2116
  static async convertSHP2GeoJSON(t, e = {}) {
2107
- O.info("[%s] convert shp zip to geojson", e == null ? void 0 : e.requestId);
2117
+ k.info("[%s] convert shp zip to geojson", e == null ? void 0 : e.requestId);
2108
2118
  try {
2109
2119
  typeof Buffer < "u" && Buffer.isBuffer(t) && (t = W.toArrayBuffer(t));
2110
- const n = await J(t);
2120
+ const n = await H(t);
2111
2121
  if (Array.isArray(n)) {
2112
- const s = n.flatMap((o) => o.features || []), c = N.utc(), r = (e == null ? void 0 : e.id) || c.valueOf().toString(), i = {
2122
+ const s = n.flatMap((o) => o.features || []), c = N.utc(), i = (e == null ? void 0 : e.id) || c.valueOf().toString(), r = {
2113
2123
  Point: "point",
2114
2124
  MultiPoint: "point",
2115
2125
  LineString: "line",
@@ -2119,22 +2129,22 @@ class W {
2119
2129
  };
2120
2130
  return s.forEach((o, a) => {
2121
2131
  var p;
2122
- const l = ((p = o.geometry) == null ? void 0 : p.type) || "", u = i[l] || l.toLowerCase();
2123
- o.properties = o.properties || {}, o.properties.shape = u, o.properties.parentId = r, o.properties.id = `${r}_${a}`;
2132
+ const u = ((p = o.geometry) == null ? void 0 : p.type) || "", l = r[u] || u.toLowerCase();
2133
+ o.properties = o.properties || {}, o.properties.shape = l, o.properties.parentId = i, o.properties.id = `${i}_${a}`;
2124
2134
  const m = Object.keys(o.properties).find((f) => f.toLowerCase().indexOf("name") !== -1), d = m ? o.properties[m] : void 0;
2125
- o.properties.name = d || `${u}_${c.format()}_${a}`;
2135
+ o.properties.name = d || `${l}_${c.format()}_${a}`;
2126
2136
  }), T.featureCollection(s);
2127
2137
  }
2128
2138
  return n;
2129
2139
  } catch (n) {
2130
- return O.warn("[%s] failed to convert shp zip: %s", e == null ? void 0 : e.requestId, n), T.featureCollection([]);
2140
+ return k.warn("[%s] failed to convert shp zip: %s", e == null ? void 0 : e.requestId, n), T.featureCollection([]);
2131
2141
  }
2132
2142
  }
2133
2143
  }
2134
2144
  export {
2135
- K as AisHelper,
2145
+ V as AisHelper,
2136
2146
  W as GeoJsonHelper,
2137
- S as LaneHelper,
2147
+ b as LaneHelper,
2138
2148
  h as LngLatHelper,
2139
- it as TropicalHelper
2149
+ ut as TropicalHelper
2140
2150
  };