@idm-plugin/geo 2.3.5 → 2.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -33,16 +33,16 @@ class h {
33
33
  t = h.convertToStdLng(t, 6);
34
34
  let s = "E";
35
35
  t < 0 && (s = "W"), t = Math.abs(t), n = n.toUpperCase();
36
- let o = t * 3600, r, i, c, a, l, u;
37
- r = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - r, i = h.padNumber(r, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = h.roundPrecision(c, e).toString().padStart(2, "0") : a = h.padNumber(c, 2, 3), o = o - c * 60), l = o / 3600, n.indexOf("M") !== -1 ? u = h.roundPrecision(l, e).toString().padStart(3, "0") : u = h.padNumber(l, 3, 6), Number(i) >= 60 && (a = Number(a) + 1, i = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
38
- const g = `${n.replace(/S+/gi, i).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
36
+ let c = t * 3600, i, r, o, a, l, u;
37
+ i = c % 3600 % 60, n.indexOf("S") !== -1 && (c = c - i, r = h.padNumber(i, 2, 2)), o = c / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = h.roundPrecision(o, e).toString().padStart(2, "0") : a = h.padNumber(o, 2, 3), c = c - o * 60), l = c / 3600, n.indexOf("M") !== -1 ? u = h.roundPrecision(l, e).toString().padStart(3, "0") : u = h.padNumber(l, 3, 6), Number(r) >= 60 && (a = Number(a) + 1, r = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
38
+ const g = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
39
39
  return {
40
40
  direction: s,
41
41
  degree: h.roundPrecision(l, e),
42
- minute: h.roundPrecision(c, e),
43
- second: h.roundPrecision(r, e),
42
+ minute: h.roundPrecision(o, e),
43
+ second: h.roundPrecision(i, e),
44
44
  pretty: g,
45
- S: i,
45
+ S: r,
46
46
  M: a,
47
47
  H: u
48
48
  };
@@ -57,16 +57,16 @@ class h {
57
57
  t = t % 180;
58
58
  let s = "N";
59
59
  t < 0 && (s = "S"), t = Math.abs(t), n = n.toUpperCase();
60
- let o = t * 3600, r, i, c, a, l, u;
61
- r = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - r, i = h.padNumber(r, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = h.roundPrecision(c, e).toString().padStart(2, "0") : a = h.padNumber(c, 2, 3), o = o - c * 60), l = o / 3600, n.indexOf("M") !== -1 ? u = h.roundPrecision(l, e).toString().padStart(2, "0") : u = h.padNumber(l, 2, 6), Number(i) >= 60 && (a = Number(a) + 1, i = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
62
- const g = `${n.replace(/S+/gi, i).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
60
+ let c = t * 3600, i, r, o, a, l, u;
61
+ i = c % 3600 % 60, n.indexOf("S") !== -1 && (c = c - i, r = h.padNumber(i, 2, 2)), o = c / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = h.roundPrecision(o, e).toString().padStart(2, "0") : a = h.padNumber(o, 2, 3), c = c - o * 60), l = c / 3600, n.indexOf("M") !== -1 ? u = h.roundPrecision(l, e).toString().padStart(2, "0") : u = h.padNumber(l, 2, 6), Number(r) >= 60 && (a = Number(a) + 1, r = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
62
+ const g = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
63
63
  return {
64
64
  direction: s,
65
65
  degree: h.roundPrecision(l, e),
66
- minute: h.roundPrecision(c, e),
67
- second: h.roundPrecision(r, e),
66
+ minute: h.roundPrecision(o, e),
67
+ second: h.roundPrecision(i, e),
68
68
  pretty: g,
69
- S: i,
69
+ S: r,
70
70
  M: a,
71
71
  H: u
72
72
  };
@@ -77,13 +77,13 @@ class h {
77
77
  t = h.strReplace(t, "LNG");
78
78
  const s = t[t.length - 1].toUpperCase();
79
79
  t = t.substring(0, t.length - 1).trim();
80
- const o = t.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
81
- let [r, i, c] = o;
82
- if (i = i || 0, i = i > 60 ? i / Math.pow(10, String(i).length - 2) : i, c = c || 0, c = c > 60 ? c / Math.pow(10, String(c).length - 2) : c, r > 360 && !i) {
83
- const a = this.roundPrecision(r / 100, 0);
84
- i = r - a * 100, r = a;
80
+ const c = t.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
81
+ let [i, r, o] = c;
82
+ 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) {
83
+ const a = this.roundPrecision(i / 100, 0);
84
+ r = i - a * 100, i = a;
85
85
  }
86
- n = r + i / 60 + c / 3600, s === "W" && (n = n * -1);
86
+ n = i + r / 60 + o / 3600, s === "W" && (n = n * -1);
87
87
  } else
88
88
  n = Number(t);
89
89
  return h.convertToStdLng(n, e);
@@ -94,13 +94,13 @@ class h {
94
94
  t = h.strReplace(t, "LAT");
95
95
  const s = t[t.length - 1].toUpperCase();
96
96
  t = t.substring(0, t.length - 1).trim();
97
- const o = t.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
98
- let [r, i, c] = o;
99
- if (c = c || 0, i = i || 0, i = i > 60 ? i / Math.pow(10, String(i).length - 2) : i, c = c > 60 ? c / Math.pow(10, String(c).length - 2) : c, r > 90 && !i) {
100
- const a = this.roundPrecision(r / 100, 0);
101
- i = r - a * 100, r = a;
97
+ const c = t.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
98
+ let [i, r, o] = c;
99
+ 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) {
100
+ const a = this.roundPrecision(i / 100, 0);
101
+ r = i - a * 100, i = a;
102
102
  }
103
- if (n = r + i / 60 + c / 3600, n > 90)
103
+ if (n = i + r / 60 + o / 3600, n > 90)
104
104
  throw new Error(`latitude out of range: ${t}${s}`);
105
105
  s === "S" && (n = n * -1);
106
106
  } else
@@ -145,10 +145,10 @@ class h {
145
145
  t = t.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g, "$1 $2").replace(/([0-9]+)-([0-9]+\.[0-9]+)/g, "$1 $2").replace(/°/, " ").replace(/(\d+)-(\d?)/g, "$1 $2").replace(/'/g, " ").replace(/′/g, " ").replace(/"/g, " ").replace(/∼/g, " ").replace(/°/g, " ").replace(/,/g, ".").replace(/^ /g, "").replace(/ $/g, "").trim();
146
146
  const n = t[t.length - 1].toUpperCase();
147
147
  if (!["N", "S", "E", "W"].includes(n)) {
148
- const s = t, o = Number(s.split(" ")[0]);
149
- if (isNaN(o))
148
+ const s = t, c = Number(s.split(" ")[0]);
149
+ if (isNaN(c))
150
150
  throw new Error(`invalid Lat/Lng: ${t}`);
151
- o >= 90 ? t = `${s}E` : o <= -90 ? t = `${s}W` : ["LAN", "LNG"].includes(e == null ? void 0 : e.toUpperCase()) ? t = `${s}${o > 0 ? "E" : "W"}` : t = `${s}${o > 0 ? "N" : "S"}`;
151
+ c >= 90 ? t = `${s}E` : c <= -90 ? t = `${s}W` : ["LAN", "LNG"].includes(e == null ? void 0 : e.toUpperCase()) ? t = `${s}${c > 0 ? "E" : "W"}` : t = `${s}${c > 0 ? "N" : "S"}`;
152
152
  }
153
153
  return t;
154
154
  }
@@ -160,8 +160,8 @@ class h {
160
160
  * @param dcmPrecision 小数位数
161
161
  */
162
162
  static padNumber(t, e = 2, n = 2) {
163
- const s = h.roundPrecision(t - Math.trunc(t), n), o = s >= 1 ? Math.trunc(t + 1).toString().padStart(e, "0") : Math.trunc(t).toString().padStart(e, "0");
164
- return s >= 1 ? o : n > 0 ? `${o}.${Math.trunc(s * Math.pow(10, n)).toString().padStart(n, "0")}` : o;
163
+ const s = h.roundPrecision(t - Math.trunc(t), n), c = s >= 1 ? Math.trunc(t + 1).toString().padStart(e, "0") : Math.trunc(t).toString().padStart(e, "0");
164
+ return s >= 1 ? c : n > 0 ? `${c}.${Math.trunc(s * Math.pow(10, n)).toString().padStart(n, "0")}` : c;
165
165
  }
166
166
  }
167
167
  class K {
@@ -170,16 +170,16 @@ class K {
170
170
  return `${t.lat}|${t.lng}|${t.positionTime}|${t.sog}|${t.cog}|${t.hdg}|${t.draught}|${e}|${JSON.stringify(t.meteo || {})}|${t.vendor}|${t.deleted}`;
171
171
  }
172
172
  static str2Json(t) {
173
- const [e, n, s, o, r, i, c, a, l, u, g] = t.split("|");
173
+ const [e, n, s, c, i, r, o, a, l, u, g] = t.split("|");
174
174
  return {
175
175
  lat: Number(e),
176
176
  lng: Number(n),
177
177
  positionTime: Number(s),
178
- sog: Number(o),
179
- cog: Number(r),
180
- hdg: Number(i),
178
+ sog: Number(c),
179
+ cog: Number(i),
180
+ hdg: Number(r),
181
181
  //@ts-ignore
182
- draught: isNaN(c) ? null : Number(c),
182
+ draught: isNaN(o) ? null : Number(o),
183
183
  type: a,
184
184
  important: a !== "A",
185
185
  meteo: l ? JSON.parse(l) : void 0,
@@ -191,48 +191,48 @@ class K {
191
191
  if (t.length < 2)
192
192
  return t;
193
193
  const s = t.at(0).positionTime < t.at(-1).positionTime;
194
- s || t.sort((c, a) => c.positionTime - a.positionTime);
195
- const o = [];
196
- let r, i;
197
- for (let c = 0; c < t.length - 1; c++) {
198
- const a = t[c];
194
+ s || t.sort((o, a) => o.positionTime - a.positionTime);
195
+ const c = [];
196
+ let i, r;
197
+ for (let o = 0; o < t.length - 1; o++) {
198
+ const a = t[o];
199
199
  if (!(n && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(a.type))) {
200
- for (let l = c + 1; l < t.length; l++) {
200
+ for (let l = o + 1; l < t.length; l++) {
201
201
  const u = t[l - 1], g = t[l];
202
202
  if (n && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(a.type))
203
203
  continue;
204
204
  const d = g.positionTime - u.positionTime;
205
205
  if (b.calculateDistance(g, u, !0, 4) / (d / 3600) < e)
206
- r || (r = a), l === t.length - 1 && (i = g, c = l);
206
+ i || (i = a), l === t.length - 1 && (r = g, o = l);
207
207
  else {
208
- r && (i = t[l - 1], c = l);
208
+ i && (r = t[l - 1], o = l);
209
209
  break;
210
210
  }
211
211
  }
212
- if ((i == null ? void 0 : i.positionTime) > (r == null ? void 0 : r.positionTime) && r) {
212
+ if ((r == null ? void 0 : r.positionTime) > (i == null ? void 0 : i.positionTime) && i) {
213
213
  const l = {
214
214
  start: {
215
- lat: r.lat,
216
- lng: r.lng,
217
- sog: r.sog,
218
- positionTime: r.positionTime,
219
- utc: x.unix(r.positionTime).utc().format()
220
- },
221
- end: {
222
215
  lat: i.lat,
223
216
  lng: i.lng,
224
217
  sog: i.sog,
225
218
  positionTime: i.positionTime,
226
219
  utc: x.unix(i.positionTime).utc().format()
227
220
  },
228
- duration: i.positionTime - r.positionTime
221
+ end: {
222
+ lat: r.lat,
223
+ lng: r.lng,
224
+ sog: r.sog,
225
+ positionTime: r.positionTime,
226
+ utc: x.unix(r.positionTime).utc().format()
227
+ },
228
+ duration: r.positionTime - i.positionTime
229
229
  }, u = t.filter((d) => d.positionTime >= l.start.positionTime && d.positionTime <= l.end.positionTime), g = b.divideAccordingToLng(u);
230
- l.distance = b.calculateRouteDistance(g), l.hours = Math.round(l.duration / 3600 * 10) / 10, l.hours && (l.avgSog = Math.round(l.distance / l.hours * 10) / 10, o.push(l));
230
+ l.distance = b.calculateRouteDistance(g), l.hours = Math.round(l.duration / 3600 * 10) / 10, l.hours && (l.avgSog = Math.round(l.distance / l.hours * 10) / 10, c.push(l));
231
231
  }
232
- r = void 0, i = void 0;
232
+ i = void 0, r = void 0;
233
233
  }
234
234
  }
235
- return s || t.sort((c, a) => a.positionTime - c.positionTime), o;
235
+ return s || t.sort((o, a) => a.positionTime - o.positionTime), c;
236
236
  }
237
237
  /**
238
238
  * 计算轨迹摘要
@@ -241,21 +241,21 @@ class K {
241
241
  * @param etm
242
242
  */
243
243
  static inspectSummary(t, e, n) {
244
- const s = x(e), o = x(n), r = t.filter((l) => l.positionTime >= s.unix() && l.positionTime <= o.unix());
245
- let i = 0, c = 0;
246
- if (r.length > 1)
247
- for (let l = 0; l < r.length - 1; l++) {
248
- const u = r[l], g = r[l + 1];
249
- i += b.calculateDistance(u, g, !0, 4), c += Math.abs(g.positionTime - u.positionTime);
244
+ const s = x(e), c = x(n), i = t.filter((l) => l.positionTime >= s.unix() && l.positionTime <= c.unix());
245
+ let r = 0, o = 0;
246
+ if (i.length > 1)
247
+ for (let l = 0; l < i.length - 1; l++) {
248
+ const u = i[l], g = i[l + 1];
249
+ r += b.calculateDistance(u, g, !0, 4), o += Math.abs(g.positionTime - u.positionTime);
250
250
  }
251
- i = Math.round(i * 100) / 100, c = Math.round(c / 3600 * 100) / 100;
252
- const a = c ? Math.round(i / c * 100) / 100 : 0;
253
- return { distance: i, interval: c, avgSpd: a };
251
+ r = Math.round(r * 100) / 100, o = Math.round(o / 3600 * 100) / 100;
252
+ const a = o ? Math.round(r / o * 100) / 100 : 0;
253
+ return { distance: r, interval: o, avgSpd: a };
254
254
  }
255
255
  }
256
- let Z;
256
+ let X;
257
257
  try {
258
- Z = z.getLogger("meteo");
258
+ X = z.getLogger("meteo");
259
259
  } catch {
260
260
  } finally {
261
261
  }
@@ -282,21 +282,21 @@ function _(C) {
282
282
  const p = t.encode(d.name), f = Q(d.data), m = new Uint8Array(30 + p.length), S = new DataView(m.buffer);
283
283
  S.setUint32(0, 67324752, !0), S.setUint16(4, 20, !0), S.setUint16(8, 0, !0), S.setUint32(14, f, !0), S.setUint32(18, d.data.length, !0), S.setUint32(22, d.data.length, !0), S.setUint16(26, p.length, !0), m.set(p, 30), e.push({ nameBytes: p, data: d.data, crc: f, offset: s }), s += m.length + d.data.length, n.push(m, d.data);
284
284
  }
285
- const o = s, r = [];
286
- let i = 0;
285
+ const c = s, i = [];
286
+ let r = 0;
287
287
  for (const d of e) {
288
288
  const p = new Uint8Array(46 + d.nameBytes.length), f = new DataView(p.buffer);
289
- f.setUint32(0, 33639248, !0), f.setUint16(4, 20, !0), f.setUint16(6, 20, !0), f.setUint16(10, 0, !0), f.setUint32(16, d.crc, !0), f.setUint32(20, d.data.length, !0), f.setUint32(24, d.data.length, !0), f.setUint16(28, d.nameBytes.length, !0), f.setUint32(42, d.offset, !0), p.set(d.nameBytes, 46), i += p.length, r.push(p);
289
+ f.setUint32(0, 33639248, !0), f.setUint16(4, 20, !0), f.setUint16(6, 20, !0), f.setUint16(10, 0, !0), f.setUint32(16, d.crc, !0), f.setUint32(20, d.data.length, !0), f.setUint32(24, d.data.length, !0), f.setUint16(28, d.nameBytes.length, !0), f.setUint32(42, d.offset, !0), p.set(d.nameBytes, 46), r += p.length, i.push(p);
290
290
  }
291
- const c = new Uint8Array(22), a = new DataView(c.buffer);
292
- a.setUint32(0, 101010256, !0), a.setUint16(8, e.length, !0), a.setUint16(10, e.length, !0), a.setUint32(12, i, !0), a.setUint32(16, o, !0);
293
- const l = n.reduce((d, p) => d + p.length, 0) + i + 22, u = new Uint8Array(l);
291
+ const o = new Uint8Array(22), a = new DataView(o.buffer);
292
+ a.setUint32(0, 101010256, !0), a.setUint16(8, e.length, !0), a.setUint16(10, e.length, !0), a.setUint32(12, r, !0), a.setUint32(16, c, !0);
293
+ const l = n.reduce((d, p) => d + p.length, 0) + r + 22, u = new Uint8Array(l);
294
294
  let g = 0;
295
295
  for (const d of n)
296
296
  u.set(d, g), g += d.length;
297
- for (const d of r)
297
+ for (const d of i)
298
298
  u.set(d, g), g += d.length;
299
- return u.set(c, g), u;
299
+ return u.set(o, g), u;
300
300
  }
301
301
  function G(C) {
302
302
  let t = "", e = C;
@@ -314,12 +314,12 @@ class b {
314
314
  * @returns {number} 单位度
315
315
  */
316
316
  static calculateBearing(t, e, n = !0, s = 4) {
317
- const o = T.points([
317
+ const c = T.points([
318
318
  [t.lng, t.lat],
319
319
  [e.lng, e.lat]
320
320
  ]);
321
- let r;
322
- return n ? r = T.rhumbBearing(o.features[0], o.features[1]) : r = T.bearing(o.features[0], o.features[1]), r < 0 && (r += 360), h.roundPrecision(r, s);
321
+ let i;
322
+ return n ? i = T.rhumbBearing(c.features[0], c.features[1]) : i = T.bearing(c.features[0], c.features[1]), i < 0 && (i += 360), h.roundPrecision(i, s);
323
323
  }
324
324
  /**
325
325
  * 计算两点间距离
@@ -330,14 +330,14 @@ class b {
330
330
  * @param units 单位,默认 nm(海里)
331
331
  * @returns {number}
332
332
  */
333
- static calculateDistance(t, e, n = !0, s = 4, o = "nauticalmiles") {
333
+ static calculateDistance(t, e, n = !0, s = 4, c = "nauticalmiles") {
334
334
  t = { ...t }, e = { ...e }, t.lng = h.convertToStdLng(t.lng, s), e.lng = h.convertToStdLng(e.lng, s);
335
- const r = T.points([
335
+ const i = T.points([
336
336
  [t.lng, t.lat],
337
337
  [e.lng, e.lat]
338
338
  ]);
339
- let i;
340
- return n ? i = T.rhumbDistance(r.features[0], r.features[1], { units: o }) : i = T.distance(r.features[0], r.features[1], { units: o }), h.roundPrecision(i, s);
339
+ let r;
340
+ return n ? r = T.rhumbDistance(i.features[0], i.features[1], { units: c }) : r = T.distance(i.features[0], i.features[1], { units: c }), h.roundPrecision(r, s);
341
341
  }
342
342
  /**
343
343
  * 计算航线距离
@@ -346,13 +346,13 @@ class b {
346
346
  * @param units
347
347
  */
348
348
  static calculateRouteDistance(t, e = 4, n = "nauticalmiles") {
349
- let s = 0, o;
350
- for (const r of t)
351
- for (let i = 0; i < r.length - 1; i++) {
352
- const c = { lng: r[i][0], lat: r[i][1] };
353
- i === 0 && o && (s += this.calculateDistance(o, c, !0, e, n));
354
- const a = { lng: r[i + 1][0], lat: r[i + 1][1] };
355
- s += this.calculateDistance(c, a, !0, e, n), o = a;
349
+ let s = 0, c;
350
+ for (const i of t)
351
+ for (let r = 0; r < i.length - 1; r++) {
352
+ const o = { lng: i[r][0], lat: i[r][1] };
353
+ r === 0 && c && (s += this.calculateDistance(c, o, !0, e, n));
354
+ const a = { lng: i[r + 1][0], lat: i[r + 1][1] };
355
+ s += this.calculateDistance(o, a, !0, e, n), c = a;
356
356
  }
357
357
  return h.roundPrecision(s, e);
358
358
  }
@@ -364,12 +364,12 @@ class b {
364
364
  * @param units 单位,默认 nm(海里)
365
365
  * @param rhumb
366
366
  */
367
- static calculateCoordinate(t, e, n, s = "nauticalmiles", o = !0) {
368
- const r = T.point([t.lng, t.lat]);
369
- let i;
370
- o ? i = T.rhumbDestination(r, n, e, { units: s }) : i = T.destination(r, n, e, { units: s });
371
- const c = i.geometry.coordinates;
372
- return { lng: h.convertToStdLng(c[0], 8), lat: h.roundPrecision(c[1], 8) };
367
+ static calculateCoordinate(t, e, n, s = "nauticalmiles", c = !0) {
368
+ const i = T.point([t.lng, t.lat]);
369
+ let r;
370
+ c ? r = T.rhumbDestination(i, n, e, { units: s }) : r = T.destination(i, n, e, { units: s });
371
+ const o = r.geometry.coordinates;
372
+ return { lng: h.convertToStdLng(o[0], 8), lat: h.roundPrecision(o[1], 8) };
373
373
  }
374
374
  /**
375
375
  * 插值大圆坐标(基于两点方位角和间距)
@@ -380,13 +380,13 @@ class b {
380
380
  * @param includeTail true 包含终点 to
381
381
  * @param units 单位,默认 nm(海里)
382
382
  */
383
- static interpolateCoordinates(t, e, n, s = !0, o = !0, r = "nauticalmiles") {
384
- const i = [], c = this.calculateBearing(t, e, !1), a = this.calculateDistance(t, e, !1, 8, r);
385
- s && i.push({ lng: t.lng, lat: t.lat });
383
+ static interpolateCoordinates(t, e, n, s = !0, c = !0, i = "nauticalmiles") {
384
+ const r = [], o = this.calculateBearing(t, e, !1), a = this.calculateDistance(t, e, !1, 8, i);
385
+ s && r.push({ lng: t.lng, lat: t.lat });
386
386
  let l = 0;
387
387
  for (; l < a; )
388
- l += n, l < a && i.push(this.calculateCoordinate(t, c, l, r, !1));
389
- return o && i.push({ lng: e.lng, lat: e.lat }), i;
388
+ l += n, l < a && r.push(this.calculateCoordinate(t, o, l, i, !1));
389
+ return c && r.push({ lng: e.lng, lat: e.lat }), r;
390
390
  }
391
391
  /**
392
392
  * 分组坐标(如相邻两个坐标经度差超180度,需以180为界将坐标分为两组)
@@ -405,15 +405,15 @@ class b {
405
405
  return [];
406
406
  t = n ? this.deduplicateCoordinates(t) : t;
407
407
  let s = [];
408
- const o = [];
409
- let r, i;
410
- for (let c = 0; c < t.length - 1; c++) {
411
- r = h.convertToStdLng(t[c].lng, 8), i = h.convertToStdLng(t[c + 1].lng, 8), t[c].lat = h.roundPrecision(t[c].lat, 8), t[c + 1].lat = h.roundPrecision(t[c + 1].lat, 8), s.push([r, t[c].lat]);
412
- const a = r - i;
408
+ const c = [];
409
+ let i, r;
410
+ for (let o = 0; o < t.length - 1; o++) {
411
+ i = h.convertToStdLng(t[o].lng, 8), r = h.convertToStdLng(t[o + 1].lng, 8), t[o].lat = h.roundPrecision(t[o].lat, 8), t[o + 1].lat = h.roundPrecision(t[o + 1].lat, 8), s.push([i, t[o].lat]);
412
+ const a = i - r;
413
413
  if (Math.abs(a) > 180) {
414
414
  const l = h.convertToMonotonicLng2([
415
- [r, t[c].lat],
416
- [i, t[c + 1].lat]
415
+ [i, t[o].lat],
416
+ [r, t[o + 1].lat]
417
417
  ]);
418
418
  let u, g;
419
419
  e ? (u = T.lineString(l), g = T.lineString([
@@ -426,12 +426,12 @@ class b {
426
426
  const f = T.getCoord(d.features[0]);
427
427
  p = h.roundPrecision(f[1], 8);
428
428
  } else
429
- p = t[c].lat;
430
- a > 0 ? (s.push([180 - 1e-6, p]), o.push([...s]), s = [], s.push([-(180 - 1e-6), p])) : (s.push([-(180 - 1e-6), p]), o.push([...s]), s = [], s.push([180 - 1e-6, p]));
429
+ p = t[o].lat;
430
+ a > 0 ? (s.push([180 - 1e-6, p]), c.push([...s]), s = [], s.push([-(180 - 1e-6), p])) : (s.push([-(180 - 1e-6), p]), c.push([...s]), s = [], s.push([180 - 1e-6, p]));
431
431
  }
432
- c === t.length - 2 && s.push([i, t[c + 1].lat]);
432
+ o === t.length - 2 && s.push([r, t[o + 1].lat]);
433
433
  }
434
- return o.push(s), o;
434
+ return c.push(s), c;
435
435
  }
436
436
  /**
437
437
  * 去除重复坐标
@@ -440,7 +440,7 @@ class b {
440
440
  static deduplicateRoute(t) {
441
441
  const e = [];
442
442
  for (const n of t) {
443
- const s = n.reduce((o, r) => (o.findIndex((i) => i[0] === r[0] && i[1] === r[1]) === -1 && o.push(r), o), []);
443
+ const s = n.reduce((c, i) => (c.findIndex((r) => r[0] === i[0] && r[1] === i[1]) === -1 && c.push(i), c), []);
444
444
  e.push(s);
445
445
  }
446
446
  return e;
@@ -488,13 +488,13 @@ class b {
488
488
  */
489
489
  static mergeCoordinateToRoute(t, e) {
490
490
  t.lng = h.convertToStdLng(t.lng, 8);
491
- let n = Number.MAX_VALUE, s = 0, o = 0, r, i;
492
- return e.forEach((c, a) => {
493
- for (let l = 0; l < c.length - 1; l++) {
494
- const u = { lng: c[l][0], lat: c[l][1] }, g = { lng: c[l + 1][0], lat: c[l + 1][1] }, d = this.calculatePointToLineDistance(t, u, g);
495
- n > d && (n = d, o = l, s = a, r = this.calculateDistance(u, t), i = this.calculateDistance(g, t));
491
+ let n = Number.MAX_VALUE, s = 0, c = 0, i, r;
492
+ return e.forEach((o, a) => {
493
+ for (let l = 0; l < o.length - 1; l++) {
494
+ const u = { lng: o[l][0], lat: o[l][1] }, g = { lng: o[l + 1][0], lat: o[l + 1][1] }, d = this.calculatePointToLineDistance(t, u, g);
495
+ n > d && (n = d, c = l, s = a, i = this.calculateDistance(u, t), r = this.calculateDistance(g, t));
496
496
  }
497
- }), r !== 0 && i !== 0 ? e[s].splice(o + 1, 0, [t.lng, t.lat]) : r === 0 ? e[s].splice(o, 1, [t.lng, t.lat]) : i === 0 && e[s].splice(o + 1, 1, [t.lng, t.lat]), e;
497
+ }), 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;
498
498
  }
499
499
  /**
500
500
  * 向Route尾加1个坐标
@@ -535,19 +535,19 @@ class b {
535
535
  static calculateRangeRoute(t, e, n) {
536
536
  n = this.mergeWaypointsToRoute([t, e], n);
537
537
  const s = [];
538
- let o = 0;
539
- return n.forEach((r) => {
540
- if (o === 2)
538
+ let c = 0;
539
+ return n.forEach((i) => {
540
+ if (c === 2)
541
541
  return;
542
- const i = [];
543
- for (const c of r) {
544
- if (h.roundPrecision(e.lng, 8) === h.roundPrecision(c[0], 8) && h.roundPrecision(e.lat, 8) === h.roundPrecision(c[1], 8)) {
545
- i.push(c), o === 0 && i.push([t.lng, t.lat]), o = 2;
542
+ const r = [];
543
+ for (const o of i) {
544
+ if (h.roundPrecision(e.lng, 8) === h.roundPrecision(o[0], 8) && h.roundPrecision(e.lat, 8) === h.roundPrecision(o[1], 8)) {
545
+ r.push(o), c === 0 && r.push([t.lng, t.lat]), c = 2;
546
546
  break;
547
547
  }
548
- o === 1 ? i.push(c) : h.roundPrecision(t.lng, 8) === h.roundPrecision(c[0], 8) && h.roundPrecision(t.lat, 8) === h.roundPrecision(c[1], 8) && (o = 1, i.push(c));
548
+ c === 1 ? r.push(o) : h.roundPrecision(t.lng, 8) === h.roundPrecision(o[0], 8) && h.roundPrecision(t.lat, 8) === h.roundPrecision(o[1], 8) && (c = 1, r.push(o));
549
549
  }
550
- i.length && s.push(i);
550
+ r.length && s.push(r);
551
551
  }), s;
552
552
  }
553
553
  /**
@@ -559,12 +559,12 @@ class b {
559
559
  * @return [{lng, lat}]
560
560
  */
561
561
  static calculateRangeWaypoints(t, e, n, s = []) {
562
- const o = this.convertRouteToCoordinates(n, 0), r = this.mergeCoordinatesToWaypoints([t, e], o.length ? o : s), i = r.findIndex(
562
+ const c = this.convertRouteToCoordinates(n, 0), i = this.mergeCoordinatesToWaypoints([t, e], c.length ? c : s), r = i.findIndex(
563
563
  (l) => h.roundPrecision(t.lng, 8) === h.roundPrecision(l.lng, 8) && h.roundPrecision(t.lat, 8) === h.roundPrecision(l.lat, 8)
564
- ), c = r.findIndex(
564
+ ), o = i.findIndex(
565
565
  (l) => h.roundPrecision(e.lng, 8) === h.roundPrecision(l.lng, 8) && h.roundPrecision(e.lat, 8) === h.roundPrecision(l.lat, 8)
566
566
  );
567
- return r.filter((l, u) => u >= i && u <= c);
567
+ return i.filter((l, u) => u >= r && u <= o);
568
568
  }
569
569
  /**
570
570
  * 计算坐标到航路上的最短距离
@@ -572,13 +572,13 @@ class b {
572
572
  * @param route
573
573
  */
574
574
  static calculateMinDistanceToRoute(t, e) {
575
- let n = Number.MAX_VALUE, s = 0, o = 0;
576
- return e.forEach((r, i) => {
577
- for (let c = 0; c < r.length - 1; c++) {
578
- const a = { lng: r[c][0], lat: r[c][1] }, l = { lng: r[c + 1][0], lat: r[c + 1][1] }, u = this.calculatePointToLineDistance(t, a, l);
579
- n > u && (n = u, s = c, o = i);
575
+ let n = Number.MAX_VALUE, s = 0, c = 0;
576
+ return e.forEach((i, r) => {
577
+ for (let o = 0; o < i.length - 1; o++) {
578
+ const a = { lng: i[o][0], lat: i[o][1] }, l = { lng: i[o + 1][0], lat: i[o + 1][1] }, u = this.calculatePointToLineDistance(t, a, l);
579
+ n > u && (n = u, s = o, c = r);
580
580
  }
581
- }), { minDist: n, segIndex: o, minIndex: s };
581
+ }), { minDist: n, segIndex: c, minIndex: s };
582
582
  }
583
583
  /**
584
584
  * 计算子航线
@@ -589,20 +589,20 @@ class b {
589
589
  static calculateSubRoute(t, e) {
590
590
  const n = b.convertRouteToCoordinates(e);
591
591
  b.mergeCoordinateToWaypoints(t, n, !0), e = b.divideAccordingToLng(n);
592
- const { segIndex: s, minIndex: o } = this.calculateMinDistanceToRoute({ ...t }, e);
592
+ const { segIndex: s, minIndex: c } = this.calculateMinDistanceToRoute({ ...t }, e);
593
593
  t.lng = h.convertToStdLng(t.lng);
594
- const r = [];
595
- let i = !0;
596
- for (let c = s; c < e.length; c++)
597
- if (i) {
594
+ const i = [];
595
+ let r = !0;
596
+ for (let o = s; o < e.length; o++)
597
+ if (r) {
598
598
  const a = [];
599
599
  a.push([t.lng, t.lat]);
600
- for (let l = o + 1; l < e[c].length; l++)
601
- t.lng === e[c][l][0] && t.lat === e[c][l][1] || a.push(e[c][l]);
602
- r.push(a), i = !1;
600
+ for (let l = c + 1; l < e[o].length; l++)
601
+ t.lng === e[o][l][0] && t.lat === e[o][l][1] || a.push(e[o][l]);
602
+ i.push(a), r = !1;
603
603
  } else
604
- r.push([...e[c]]);
605
- return r;
604
+ i.push([...e[o]]);
605
+ return i;
606
606
  }
607
607
  /**
608
608
  * 计算子途经点
@@ -612,20 +612,20 @@ class b {
612
612
  */
613
613
  static calculateSubWaypoints(t, e) {
614
614
  let n = Number.MAX_VALUE, s = 0;
615
- for (let r = 0; r < e.length - 1; r++) {
616
- const i = e[r], c = e[r + 1];
617
- if (this.calculateDistance(t, i) === 0)
615
+ for (let i = 0; i < e.length - 1; i++) {
616
+ const r = e[i], o = e[i + 1];
617
+ if (this.calculateDistance(t, r) === 0)
618
618
  return e;
619
- if (this.calculateDistance(t, c) === 0)
619
+ if (this.calculateDistance(t, o) === 0)
620
620
  return e.filter((l, u) => u > 0);
621
- const a = this.calculatePointToLineDistance(t, i, c);
622
- n > a && (n = a, s = r);
621
+ const a = this.calculatePointToLineDistance(t, r, o);
622
+ n > a && (n = a, s = i);
623
623
  }
624
624
  t.lng = h.convertToStdLng(t.lng);
625
- const o = [t];
626
- for (let r = s + 1; r < e.length; r++)
627
- o.push(e[r]);
628
- return o;
625
+ const c = [t];
626
+ for (let i = s + 1; i < e.length; i++)
627
+ c.push(e[i]);
628
+ return c;
629
629
  }
630
630
  /**
631
631
  * 计算坐标到以(from, to)横向线上的距离
@@ -636,13 +636,13 @@ class b {
636
636
  */
637
637
  static calculatePointToLineDistance(t, e, n, s = { units: "nauticalmiles", method: "geodesic" }) {
638
638
  t.lng = h.convertToStdLng(t.lng, 8), e = { ...e }, n = { ...n }, e.lng = h.convertToStdLng(e.lng, 8), n.lng = h.convertToStdLng(n.lng, 8);
639
- const o = h.convertToMonotonicLng([e, n]);
640
- e = o[0], n = o[1];
641
- const r = T.lineString([
639
+ const c = h.convertToMonotonicLng([e, n]);
640
+ e = c[0], n = c[1];
641
+ const i = T.lineString([
642
642
  [e.lng, e.lat],
643
643
  [n.lng, n.lat]
644
- ]), i = T.pointToLineDistance(T.point([t.lng, t.lat]), r, s), c = T.pointToLineDistance(T.point([t.lng > 0 ? t.lng - 360 : t.lng + 360, t.lat]), r, s);
645
- return h.roundPrecision(Math.min(i, c), 6);
644
+ ]), r = T.pointToLineDistance(T.point([t.lng, t.lat]), i, s), o = T.pointToLineDistance(T.point([t.lng > 0 ? t.lng - 360 : t.lng + 360, t.lat]), i, s);
645
+ return h.roundPrecision(Math.min(r, o), 6);
646
646
  }
647
647
  /**
648
648
  * 计算途经点的COG, Distance等属性
@@ -652,8 +652,8 @@ class b {
652
652
  static calculateWaypointsPropInRoute(t, e) {
653
653
  e = this.mergeWaypointsToRoute(t, e);
654
654
  for (let n = 0; n < t.length - 1; n++) {
655
- const s = t[n], o = t[n + 1], r = this.calculateRangeRoute(s, o, e);
656
- n === 0 && (s.distanceFromPrevious = 0, s.distanceFromStart = 0), o.distanceFromPrevious = this.calculateRouteDistance(r), o.distanceFromStart = h.roundPrecision((s.distanceFromStart || 0) + o.distanceFromPrevious);
655
+ const s = t[n], c = t[n + 1], i = this.calculateRangeRoute(s, c, e);
656
+ n === 0 && (s.distanceFromPrevious = 0, s.distanceFromStart = 0), c.distanceFromPrevious = this.calculateRouteDistance(i), c.distanceFromStart = h.roundPrecision((s.distanceFromStart || 0) + c.distanceFromPrevious);
657
657
  }
658
658
  return t;
659
659
  }
@@ -681,24 +681,24 @@ class b {
681
681
  */
682
682
  static mergeCoordinateToWaypoints(t, e, n = !0) {
683
683
  t.lng = h.convertToStdLng(t.lng, 8);
684
- let s = Number.MAX_VALUE, o = 0, r = 0, i = 0;
684
+ let s = Number.MAX_VALUE, c = 0, i = 0, r = 0;
685
685
  if (e.length < 2)
686
686
  e.push(t);
687
687
  else {
688
- for (let c = 0; c < e.length - 1; c++) {
689
- const a = { lng: e[c].lng, lat: e[c].lat }, l = { lng: e[c + 1].lng, lat: e[c + 1].lat }, u = this.calculatePointToLineDistance(t, a, l);
690
- s >= u && (s = u, o = c, r = this.calculateDistance(a, t, !1, 6), i = this.calculateDistance(l, t, !1, 6));
688
+ for (let o = 0; o < e.length - 1; o++) {
689
+ 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);
690
+ s >= u && (s = u, c = o, i = this.calculateDistance(a, t, !1, 6), r = this.calculateDistance(l, t, !1, 6));
691
691
  }
692
- r !== 0 && i !== 0 ? r <= s && o === 0 ? e.unshift(t) : i <= s && o === e.length - 2 ? e.push(t) : e.splice(o + 1, 0, t) : r === 0 ? n ? e.splice(o, 1, t) : e.splice(o + 1, 0, t) : i === 0 && (n ? e.splice(o + 1, 1, t) : e.splice(o + 1, 0, t));
692
+ i !== 0 && r !== 0 ? i <= s && c === 0 ? e.unshift(t) : r <= s && c === e.length - 2 ? e.push(t) : e.splice(c + 1, 0, t) : i === 0 ? n ? e.splice(c, 1, t) : e.splice(c + 1, 0, t) : r === 0 && (n ? e.splice(c + 1, 1, t) : e.splice(c + 1, 0, t));
693
693
  }
694
- return e.map((c, a) => {
695
- c.lng = h.convertToStdLng(c.lng);
694
+ return e.map((o, a) => {
695
+ o.lng = h.convertToStdLng(o.lng);
696
696
  const l = e[a + 1];
697
- if (l && ((c.bearing === null || c.bearing === void 0) && ((c.positionTime || 0) > (l.positionTime || 0) ? c.bearing = this.calculateBearing(l, c, !0) : c.bearing = this.calculateBearing(c, l, !0)), c.cog = c.cog || c.bearing, !c.sog && c.positionTime && l.positionTime)) {
698
- const u = this.calculateDistance(c, l, !0), g = Math.abs(l.positionTime - c.positionTime) / 3600;
699
- c.sog = h.roundPrecision(u / g, 2);
697
+ if (l && ((o.bearing === null || o.bearing === void 0) && ((o.positionTime || 0) > (l.positionTime || 0) ? o.bearing = this.calculateBearing(l, o, !0) : o.bearing = this.calculateBearing(o, l, !0)), o.cog = o.cog || o.bearing, !o.sog && o.positionTime && l.positionTime)) {
698
+ const u = this.calculateDistance(o, l, !0), g = Math.abs(l.positionTime - o.positionTime) / 3600;
699
+ o.sog = h.roundPrecision(u / g, 2);
700
700
  }
701
- return c;
701
+ return o;
702
702
  });
703
703
  }
704
704
  /**
@@ -710,13 +710,13 @@ class b {
710
710
  */
711
711
  static generateRouteAccordingToWaypoints(t, e = !0, n = !0) {
712
712
  const s = [];
713
- for (let o = 1; o < t.length; o++) {
714
- const r = t[o - 1], i = t[o];
715
- if (o === 1 && s.push(r), i.gcToPrevious) {
716
- const c = this.interpolateCoordinates(r, i, 200, !1, !0, "nauticalmiles");
717
- s.push(...c);
713
+ for (let c = 1; c < t.length; c++) {
714
+ const i = t[c - 1], r = t[c];
715
+ if (c === 1 && s.push(i), r.gcToPrevious) {
716
+ const o = this.interpolateCoordinates(i, r, 200, !1, !0, "nauticalmiles");
717
+ s.push(...o);
718
718
  } else
719
- s.push(i);
719
+ s.push(r);
720
720
  }
721
721
  return this.divideAccordingToLng(s, e, n);
722
722
  }
@@ -726,8 +726,8 @@ class b {
726
726
  * @param route [[[lng, lat]]]
727
727
  */
728
728
  static nearestCoordinateInRoute(t, e) {
729
- const n = T.point([t.lng, t.lat]), o = this.convertRouteToCoordinates(e).map((a) => [a.lng, a.lat]), r = T.lineString(o), i = T.nearestPointOnLine(r, n), c = T.getCoord(i);
730
- return { lng: h.roundPrecision(c[0], 8), lat: h.roundPrecision(c[1], 8) };
729
+ const n = T.point([t.lng, t.lat]), c = this.convertRouteToCoordinates(e).map((a) => [a.lng, a.lat]), i = T.lineString(c), r = T.nearestPointOnLine(i, n), o = T.getCoord(r);
730
+ return { lng: h.roundPrecision(o[0], 8), lat: h.roundPrecision(o[1], 8) };
731
731
  }
732
732
  /**
733
733
  * 计算经过方向上的最后一个waypoint
@@ -738,12 +738,12 @@ class b {
738
738
  let n = 0;
739
739
  this.mergeCoordinateToWaypoints(t, e);
740
740
  for (let s = 0; s < e.length - 1; s++) {
741
- const o = e[s], r = e[s + 1];
742
- if (this.calculateDistance(t, o) === 0) {
741
+ const c = e[s], i = e[s + 1];
742
+ if (this.calculateDistance(t, c) === 0) {
743
743
  n = s;
744
744
  break;
745
745
  }
746
- if (this.calculateDistance(t, r) === 0) {
746
+ if (this.calculateDistance(t, i) === 0) {
747
747
  n = s + 1;
748
748
  break;
749
749
  }
@@ -760,11 +760,11 @@ class b {
760
760
  */
761
761
  static calculateNextCoordinateAlongRoute(t, e, n, s = "nauticalmiles") {
762
762
  var g;
763
- const o = t.speed || 12, r = [];
764
- let i = [], c = !1, a = 0, l = 0, u;
765
- if (e && n.length ? (r.push(t), n.forEach((d, p) => {
766
- if (c)
767
- i.push(d);
763
+ const c = t.speed || 12, i = [];
764
+ let r = [], o = !1, a = 0, l = 0, u;
765
+ if (e && n.length ? (i.push(t), n.forEach((d, p) => {
766
+ if (o)
767
+ r.push(d);
768
768
  else {
769
769
  const f = [];
770
770
  let m;
@@ -775,7 +775,7 @@ class b {
775
775
  m = { lng: d[S][0], lat: d[S][1] };
776
776
  const v = this.calculateDistance(t, m, !0, 8, s);
777
777
  if (a += v, a < e)
778
- l += v, v && r.push(m), t = m;
778
+ l += v, v && i.push(m), t = m;
779
779
  else {
780
780
  if (l = e, a === e)
781
781
  u = m, f.push([u.lng, u.lat]);
@@ -783,18 +783,18 @@ class b {
783
783
  const P = a - e, y = this.calculateBearing(m, t);
784
784
  u = this.calculateCoordinate(m, y, P, s), f.push([u.lng, u.lat]), f.push([m.lng, m.lat]);
785
785
  }
786
- c = !0;
786
+ o = !0;
787
787
  }
788
788
  }
789
- f.length && i.push(f), p === n.length - 1 && !u && (u = m);
789
+ f.length && r.push(f), p === n.length - 1 && !u && (u = m);
790
790
  }
791
- })) : (i = n, u = { ...t }), u)
792
- if (r.push(u), u.distanceFromPrevious = Math.round(l * 1e4) / 1e4, u.hourFromPrevious = Math.round(l / o * 1e4) / 1e4, ((g = i[0]) == null ? void 0 : g.length) > 1) {
793
- const d = { lng: i[0][1][0], lat: i[0][1][1] };
791
+ })) : (r = n, u = { ...t }), u)
792
+ if (i.push(u), u.distanceFromPrevious = Math.round(l * 1e4) / 1e4, u.hourFromPrevious = Math.round(l / c * 1e4) / 1e4, ((g = r[0]) == null ? void 0 : g.length) > 1) {
793
+ const d = { lng: r[0][1][0], lat: r[0][1][1] };
794
794
  u.bearing = this.calculateBearing(u, d);
795
795
  } else
796
796
  u.bearing = 0;
797
- return { coordinate: u, nextRoute: i, prevRoute: r };
797
+ return { coordinate: u, nextRoute: r, prevRoute: i };
798
798
  }
799
799
  /**
800
800
  * 返回最近点及其是否为垂足(最近点不是起点或终点)
@@ -803,11 +803,11 @@ class b {
803
803
  * @param to {lng, lat}
804
804
  */
805
805
  static nearestCoordinateInLine(t, e, n) {
806
- const s = h.convertToStdLng(t.lng, 6), o = T.point([s, t.lat]), r = h.convertToStdLng(e.lng, 6), i = h.convertToStdLng(n.lng, 6), c = T.lineString([
807
- [r, e.lat],
808
- [i, n.lat]
809
- ]), a = T.nearestPointOnLine(c, o), l = T.getCoord(a), u = h.roundPrecision(l[0], 6), g = h.roundPrecision(l[1], 6);
810
- return { lng: u, lat: g, inline: !(u === r && g === e.lat) && !(u === i && g === n.lat) };
806
+ const s = h.convertToStdLng(t.lng, 6), c = T.point([s, t.lat]), i = h.convertToStdLng(e.lng, 6), r = h.convertToStdLng(n.lng, 6), o = T.lineString([
807
+ [i, e.lat],
808
+ [r, n.lat]
809
+ ]), a = T.nearestPointOnLine(o, c), l = T.getCoord(a), u = h.roundPrecision(l[0], 6), g = h.roundPrecision(l[1], 6);
810
+ return { lng: u, lat: g, inline: !(u === i && g === e.lat) && !(u === r && g === n.lat) };
811
811
  }
812
812
  /**
813
813
  * 将route转coordinate
@@ -816,19 +816,19 @@ class b {
816
816
  */
817
817
  static convertRouteToCoordinates(t, e = 0) {
818
818
  const n = [];
819
- let s, o;
820
- return t.forEach((r) => {
821
- r.forEach((i) => {
822
- const c = { lng: h.roundPrecision(i[0], 8), lat: h.roundPrecision(i[1], 8) };
823
- if (!o)
824
- n.push(c), o = c;
825
- else if (o.bearing === void 0 || o.bearing === null)
826
- o.bearing = this.calculateBearing(o, c, !0);
819
+ let s, c;
820
+ return t.forEach((i) => {
821
+ i.forEach((r) => {
822
+ const o = { lng: h.roundPrecision(r[0], 8), lat: h.roundPrecision(r[1], 8) };
823
+ if (!c)
824
+ n.push(o), c = o;
825
+ else if (c.bearing === void 0 || c.bearing === null)
826
+ c.bearing = this.calculateBearing(c, o, !0);
827
827
  else {
828
- const a = this.calculateDistance(s, c, !0);
829
- a && a >= e && (s.bearing = this.calculateBearing(s, c, !0), n.push(s), o = s);
828
+ const a = this.calculateDistance(s, o, !0);
829
+ a && a >= e && (s.bearing = this.calculateBearing(s, o, !0), n.push(s), c = s);
830
830
  }
831
- s = c;
831
+ s = o;
832
832
  });
833
833
  }), s && n.push(s), n;
834
834
  }
@@ -852,17 +852,17 @@ class b {
852
852
  this.mergeCoordinateToWaypoints(s, t, !0);
853
853
  });
854
854
  for (let s = 1; s < e.length; s++) {
855
- const o = e[s - 1], r = e[s];
856
- if (r.gcToPrevious) {
857
- const i = t.findIndex((a) => a.lng === o.lng && a.lat === o.lat), c = t.findIndex((a) => a.lng === r.lng && a.lat === r.lat);
858
- for (let a = c - 1; a > i; a--)
855
+ const c = e[s - 1], i = e[s];
856
+ if (i.gcToPrevious) {
857
+ 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);
858
+ for (let a = o - 1; a > r; a--)
859
859
  t.splice(a, 1);
860
860
  }
861
861
  }
862
862
  let n = 0;
863
863
  for (let s = 1; s < t.length; s++) {
864
- const o = t[s - 1], r = t[s];
865
- r.gcToPrevious ? (o.bearing = this.calculateBearing(o, r, !1), r.distanceFromPrevious = this.calculateDistance(o, r, !1)) : (o.bearing = this.calculateBearing(o, r, !0), r.distanceFromPrevious = this.calculateDistance(o, r, !0)), n = h.roundPrecision(n + r.distanceFromPrevious), r.distanceFromStart = n;
864
+ const c = t[s - 1], i = t[s];
865
+ i.gcToPrevious ? (c.bearing = this.calculateBearing(c, i, !1), i.distanceFromPrevious = this.calculateDistance(c, i, !1)) : (c.bearing = this.calculateBearing(c, i, !0), i.distanceFromPrevious = this.calculateDistance(c, i, !0)), n = h.roundPrecision(n + i.distanceFromPrevious), i.distanceFromStart = n;
866
866
  }
867
867
  return t.map((s) => (s.lng = h.convertToStdLng(s.lng), s));
868
868
  }
@@ -872,14 +872,14 @@ class b {
872
872
  */
873
873
  static calculateCenter(t) {
874
874
  const e = [];
875
- for (const i of t)
876
- for (const c of i)
877
- e.push(c);
875
+ for (const r of t)
876
+ for (const o of r)
877
+ e.push(o);
878
878
  const n = T.featureCollection([]), s = h.convertToMonotonicLng2(e);
879
- for (const i of s)
880
- n.features.push(T.point(i));
881
- const r = T.center(n).geometry.coordinates;
882
- return { lng: h.convertToStdLng(r[0], 8), lat: h.roundPrecision(r[1], 8) };
879
+ for (const r of s)
880
+ n.features.push(T.point(r));
881
+ const i = T.center(n).geometry.coordinates;
882
+ return { lng: h.convertToStdLng(i[0], 8), lat: h.roundPrecision(i[1], 8) };
883
883
  }
884
884
  /**
885
885
  * 计算中心点
@@ -895,9 +895,9 @@ class b {
895
895
  */
896
896
  static calculateBBox(t) {
897
897
  const e = [];
898
- for (const o of t)
899
- for (const r of o)
900
- e.push(r);
898
+ for (const c of t)
899
+ for (const i of c)
900
+ e.push(i);
901
901
  const n = h.convertToMonotonicLng2(e), s = T.lineString(n);
902
902
  return T.bbox(s);
903
903
  }
@@ -910,26 +910,35 @@ class b {
910
910
  return this.calculateBBox(e);
911
911
  }
912
912
  /**
913
- * 抽稀 三点抽稀, 对比A,B,C; 基于三点距离及夹角抽稀
914
- * @param coordinates
915
- * @param distance 三点最小距离, 小于此距离时,B点将被忽略(三点太近)
916
- * @param angle 三点夹角, 大于此角度时,B点将被忽略(近似走RL)
913
+ * 抽稀:基于三点夹角及距离移除冗余点
914
+ * - 保留首尾点、重要标记点(important/pilot/suspend/velocity/gcToPrevious)
915
+ * - 当三点夹角 >= minAngle 且相邻距离 <= minDistance 时,移除中间点
916
+ * @param coordinates 原始坐标序列
917
+ * @param minDistance 最小保留距离阈值(nm),默认 0.1
918
+ * @param minAngle 最小保留角度阈值(度),默认 175;>= 此值视为近似直线可抽稀
917
919
  */
918
920
  static simplifyCoordinates(t, e = 1, n = 180) {
919
- const s = [];
920
- for (let o = 1; o < t.length; o++) {
921
- const r = t[o - 1], i = t[o], c = t[o + 1];
922
- let a = !1, l = !1;
923
- if ((r.velocity || r.suspend || r.important || r.pilot || o === 1) && (a = !0, s.push(r)), i.gcToPrevious && (a || (a = !0, s.push(r)), l = !0, s.push(i), o++), c) {
924
- const u = b.calculateDistance(r, i, !0), g = b.calculateDistance(i, c, !0), d = b.calculateDistance(r, c, !0), p = (Math.pow(u, 2) + Math.pow(g, 2) - Math.pow(d, 2)) / (2 * u * g);
925
- Math.round(Math.acos(p) * 180 / Math.PI) < n && d > e && !l && (s.push(i), o++);
921
+ if (t.length <= 2)
922
+ return [...t];
923
+ const s = [t[0]];
924
+ let c = 0;
925
+ for (let i = 1; i < t.length - 1; i++) {
926
+ const r = t[i], o = t[i + 1], a = t[c];
927
+ if (r.important || r.pilot || r.suspend || r.velocity || r.gcToPrevious) {
928
+ s.push(r), c = i;
929
+ continue;
926
930
  }
927
- if (o >= t.length - 1) {
928
- const u = t.at(-1);
929
- u && s.push(u);
931
+ const l = b.calculateDistance(a, r, !0), u = b.calculateDistance(r, o, !0), g = b.calculateDistance(a, o, !0);
932
+ let d = (l * l + u * u - g * g) / (2 * l * u);
933
+ d = Math.max(-1, Math.min(1, d));
934
+ const p = Math.acos(d) * (180 / Math.PI);
935
+ if (p >= 180 || p >= n && g <= e) {
936
+ X.warn("simplify: skip point %d (angle=%d°, dist=%d): %j", i, p, g, r);
937
+ continue;
930
938
  }
939
+ s.push(r), c = i;
931
940
  }
932
- return s;
941
+ return s.push(t[t.length - 1]), s;
933
942
  }
934
943
  /**
935
944
  * 在时间轨迹上寻找ts最近的点
@@ -938,10 +947,10 @@ class b {
938
947
  * @param waypoints 带时间的轨迹, 单位秒
939
948
  */
940
949
  static nearestTSPointInWaypoints(t, e, n) {
941
- const s = x.unix(t), o = n.filter(
942
- (r) => s.clone().subtract(e, "hour").unix() <= (r.positionTime || 0) && s.clone().add(e, "h").unix() >= (r.positionTime || 0)
950
+ const s = x.unix(t), c = n.filter(
951
+ (i) => s.clone().subtract(e, "hour").unix() <= (i.positionTime || 0) && s.clone().add(e, "h").unix() >= (i.positionTime || 0)
943
952
  );
944
- return o.sort((r, i) => (r.positionTime || 0) - (i.positionTime || 0)), o.at(-1);
953
+ return c.sort((i, r) => (i.positionTime || 0) - (r.positionTime || 0)), c.at(-1);
945
954
  }
946
955
  /**
947
956
  * 推测船位
@@ -949,12 +958,12 @@ class b {
949
958
  * @param positions 带时间(positionTime)的轨迹
950
959
  */
951
960
  static deadReckoning(t, e) {
952
- var o, r, i, c;
961
+ var c, i, r, o;
953
962
  t > 1e12 && (t = Math.round(t / 1e3));
954
963
  const n = x.unix(t);
955
964
  let s = e.find((a) => a.positionTime === n.unix());
956
965
  if (!s) {
957
- const a = (r = (o = e.filter((u) => (u == null ? void 0 : u.positionTime) < n.unix())) == null ? void 0 : o.sort((u, g) => (u.positionTime || 0) - (g.positionTime || 0))) == null ? void 0 : r.at(-1), l = (c = (i = e.filter((u) => (u == null ? void 0 : u.positionTime) > n.unix())) == null ? void 0 : i.sort((u, g) => (u.positionTime || 0) - (g.positionTime || 0))) == null ? void 0 : c.at(0);
966
+ const a = (i = (c = e.filter((u) => (u == null ? void 0 : u.positionTime) < n.unix())) == null ? void 0 : c.sort((u, g) => (u.positionTime || 0) - (g.positionTime || 0))) == null ? void 0 : i.at(-1), l = (o = (r = e.filter((u) => (u == null ? void 0 : u.positionTime) > n.unix())) == null ? void 0 : r.sort((u, g) => (u.positionTime || 0) - (g.positionTime || 0))) == null ? void 0 : o.at(0);
958
967
  if (a && l) {
959
968
  const u = b.calculateBearing(a, l, !0), g = b.calculateDistance(a, l), d = (n.unix() - a.positionTime) / (l.positionTime - a.positionTime);
960
969
  s = b.calculateCoordinate(a, u, g * d), s.positionTime = n.unix(), s.utc = n.utc().format(), s.cog = u, s.sog = Math.round(g / ((l.positionTime - a.positionTime) / 3600) * 100) / 100;
@@ -975,14 +984,14 @@ class b {
975
984
  const l = e[a], u = e[a + 1], g = b.calculatePointToLineDistance(t, l, u);
976
985
  g < n && (n = g, s = a);
977
986
  }
978
- const o = e[s], r = e[s + 1], i = b.calculateDistance(o, t), c = b.calculateDistance(r, t);
979
- if (i === 0)
980
- t = o;
981
- else if (c === 0)
982
- t = r;
987
+ const c = e[s], i = e[s + 1], r = b.calculateDistance(c, t), o = b.calculateDistance(i, t);
988
+ if (r === 0)
989
+ t = c;
990
+ else if (o === 0)
991
+ t = i;
983
992
  else {
984
- const a = o.positionTime || 0, l = r.positionTime || 0, u = b.calculateDistance(o, r);
985
- t.positionTime = Math.round(a + (l - a) * (i / u));
993
+ const a = c.positionTime || 0, l = i.positionTime || 0, u = b.calculateDistance(c, i);
994
+ t.positionTime = Math.round(a + (l - a) * (r / u));
986
995
  }
987
996
  return t.utc = t.positionTime ? x.unix(t.positionTime).utc().format() : void 0, t.positionTime ? t : void 0;
988
997
  }
@@ -1031,30 +1040,30 @@ class b {
1031
1040
  * @see https://cirm.org/rtz-xml-schemas
1032
1041
  */
1033
1042
  static waypoints2RTZ10(t, e, n = !0) {
1034
- const o = [];
1035
- return o.push('<?xml version="1.0" encoding="UTF-8"?>'), o.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'), o.push(` <routeInfo routeName="${b.xmlEscape(t)}"></routeInfo>`), o.push(...b.toRTZWaypoints(e, 6, n)), o.push("</route>"), o.join(`
1043
+ const c = [];
1044
+ return c.push('<?xml version="1.0" encoding="UTF-8"?>'), c.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'), c.push(` <routeInfo routeName="${b.xmlEscape(t)}"></routeInfo>`), c.push(...b.toRTZWaypoints(e, 6, n)), c.push("</route>"), c.join(`
1036
1045
  `) + `
1037
1046
  `;
1038
1047
  }
1039
1048
  static toRTZWaypoints(t, e = 6, n = !0) {
1040
1049
  const s = [];
1041
1050
  s.push(" <waypoints>");
1042
- for (let o = 0; o < t.length; o++) {
1043
- const r = t[o], i = o + 1, c = (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"'];
1044
- if (r.name && l.push(`name="${b.xmlEscape(r.name)}"`), s.push(` <waypoint ${l.join(" ")}>`), s.push(` <position lat="${b.xmlEscape(c)}" lon="${b.xmlEscape(a)}" />`), o > 0) {
1045
- const u = r.gcToPrevious ? "Orthodrome" : "Loxodrome";
1051
+ for (let c = 0; c < t.length; c++) {
1052
+ const i = t[c], r = c + 1, o = (i.lat ?? "").toFixed ? i.lat.toFixed(e).padEnd(e + 2, "0") : i.lat, a = (i.lng ?? "").toFixed ? i.lng.toFixed(e).padEnd(e + 2, "0") : i.lng, l = [`id="${r}"`, 'revision="0"'];
1053
+ if (i.name && l.push(`name="${b.xmlEscape(i.name)}"`), s.push(` <waypoint ${l.join(" ")}>`), s.push(` <position lat="${b.xmlEscape(o)}" lon="${b.xmlEscape(a)}" />`), c > 0) {
1054
+ const u = i.gcToPrevious ? "Orthodrome" : "Loxodrome";
1046
1055
  s.push(` <leg geometryType="${u}" />`);
1047
1056
  }
1048
1057
  if (n) {
1049
1058
  const u = [];
1050
- if (r.description && u.push(` <description>${b.xmlEscape(r.description)}</description>`), r.utc)
1051
- u.push(` <time>${b.xmlEscape(r.utc)}</time>`);
1052
- else if (r.positionTime)
1059
+ if (i.description && u.push(` <description>${b.xmlEscape(i.description)}</description>`), i.utc)
1060
+ u.push(` <time>${b.xmlEscape(i.utc)}</time>`);
1061
+ else if (i.positionTime)
1053
1062
  try {
1054
- u.push(` <time>${b.xmlEscape(x.unix(r.positionTime).utc().format())}</time>`);
1063
+ u.push(` <time>${b.xmlEscape(x.unix(i.positionTime).utc().format())}</time>`);
1055
1064
  } catch {
1056
1065
  }
1057
- r.cog !== void 0 && u.push(` <cog>${b.xmlEscape(r.cog)}</cog>`), r.sog !== void 0 && u.push(` <sog>${b.xmlEscape(r.sog)}</sog>`), u.length && (s.push(" <extensions>"), s.push(...u), s.push(" </extensions>"));
1066
+ i.cog !== void 0 && u.push(` <cog>${b.xmlEscape(i.cog)}</cog>`), i.sog !== void 0 && u.push(` <sog>${b.xmlEscape(i.sog)}</sog>`), u.length && (s.push(" <extensions>"), s.push(...u), s.push(" </extensions>"));
1058
1067
  }
1059
1068
  s.push(" </waypoint>");
1060
1069
  }
@@ -1068,14 +1077,14 @@ class b {
1068
1077
  * @param options.precision 经纬度小数位数,默认6
1069
1078
  */
1070
1079
  static waypoints2CSV(t, e, n) {
1071
- Z.debug("keep name for waypoints2CSV for legacy compatibility only", t);
1072
- const s = (n == null ? void 0 : n.precision) ?? 6, o = e.some((m) => m.name), r = e.some((m) => m.description), i = e.some((m) => m.port != null), c = e.some((m) => m.stbd != null), a = e.some((m) => m.arrRad != null), l = e.some((m) => m.speed != null), u = e.some((m, S) => S > 0 && m.gcToPrevious != null), g = e.some((m) => m.bearing != null), d = e.some((m) => m.distanceFromPrevious != null), p = ["WPT No.", "Latitude", "Longitude"];
1073
- o && p.push("Name"), r && p.push("Description"), u && p.push("Leg"), g && p.push("Bearing[deg]"), d && p.push("Distance[NM]"), l && p.push("Speed[kn]"), i && p.push("PORT XTD[NM]"), c && p.push("STBD XTD[NM]"), a && p.push("Arr.Rad[NM]");
1080
+ X.debug("keep name for waypoints2CSV for legacy compatibility only", t);
1081
+ const s = (n == null ? void 0 : n.precision) ?? 6, c = e.some((m) => m.name), i = e.some((m) => m.description), r = e.some((m) => m.port != null), o = e.some((m) => m.stbd != null), a = e.some((m) => m.arrRad != null), l = e.some((m) => m.speed != null), u = e.some((m, S) => S > 0 && m.gcToPrevious != null), g = e.some((m) => m.bearing != null), d = e.some((m) => m.distanceFromPrevious != null), p = ["WPT No.", "Latitude", "Longitude"];
1082
+ c && p.push("Name"), i && p.push("Description"), u && p.push("Leg"), g && p.push("Bearing[deg]"), d && p.push("Distance[NM]"), l && p.push("Speed[kn]"), r && p.push("PORT XTD[NM]"), o && p.push("STBD XTD[NM]"), a && p.push("Arr.Rad[NM]");
1074
1083
  const f = [];
1075
1084
  f.push(p.map((m) => b.csvEscapeField(m)).join(","));
1076
1085
  for (let m = 0; m < e.length; m++) {
1077
1086
  const S = e[m], v = [];
1078
- v.push((m + 1).toString()), v.push(S.lat.toFixed(s)), v.push(S.lng.toFixed(s)), o && v.push(S.name ?? ""), r && v.push(S.description ?? ""), u && v.push(m === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), g && v.push(S.bearing != null ? String(S.bearing) : ""), d && v.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), l && v.push(S.speed != null ? String(S.speed) : ""), i && v.push(S.port != null ? String(S.port) : ""), c && v.push(S.stbd != null ? String(S.stbd) : ""), a && v.push(S.arrRad != null ? String(S.arrRad) : ""), f.push(v.map((P) => b.csvEscapeField(P)).join(","));
1087
+ v.push((m + 1).toString()), v.push(S.lat.toFixed(s)), v.push(S.lng.toFixed(s)), c && v.push(S.name ?? ""), i && v.push(S.description ?? ""), u && v.push(m === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), g && v.push(S.bearing != null ? String(S.bearing) : ""), d && v.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), l && v.push(S.speed != null ? String(S.speed) : ""), r && v.push(S.port != null ? String(S.port) : ""), o && v.push(S.stbd != null ? String(S.stbd) : ""), a && v.push(S.arrRad != null ? String(S.arrRad) : ""), f.push(v.map((P) => b.csvEscapeField(P)).join(","));
1079
1088
  }
1080
1089
  return f.join(`
1081
1090
  `);
@@ -1088,13 +1097,13 @@ class b {
1088
1097
  * @param options.precision 经纬度分钟小数位数,默认3
1089
1098
  */
1090
1099
  static waypoints2JRCCSV(t, e, n) {
1091
- const s = (n == null ? void 0 : n.precision) ?? 3, o = e.some((f) => f.name), r = e.some((f) => f.port != null), i = e.some((f) => f.stbd != null), c = e.some((f) => f.arrRad != null), a = e.some((f) => f.speed != null), l = e.some((f, m) => m > 0 && f.gcToPrevious != null), u = e.some((f) => f.rot != null), g = e.some((f) => f.turnRad != null), d = ["// WPT No.", "LAT", "", "", "LON", "", ""];
1092
- r && d.push("PORT[NM]"), i && d.push("STBD[NM]"), c && d.push("Arr. Rad[NM]"), a && d.push("Speed[kn]"), l && d.push("Sail(RL/GC)"), u && d.push("ROT[deg/min]"), g && d.push("Turn Rad[NM]"), o && d.push("Name");
1100
+ const s = (n == null ? void 0 : n.precision) ?? 3, c = e.some((f) => f.name), i = e.some((f) => f.port != null), r = e.some((f) => f.stbd != null), o = e.some((f) => f.arrRad != null), a = e.some((f) => f.speed != null), l = e.some((f, m) => m > 0 && f.gcToPrevious != null), u = e.some((f) => f.rot != null), g = e.some((f) => f.turnRad != null), d = ["// WPT No.", "LAT", "", "", "LON", "", ""];
1101
+ i && d.push("PORT[NM]"), r && d.push("STBD[NM]"), o && d.push("Arr. Rad[NM]"), a && d.push("Speed[kn]"), l && d.push("Sail(RL/GC)"), u && d.push("ROT[deg/min]"), g && d.push("Turn Rad[NM]"), c && d.push("Name");
1093
1102
  const p = [];
1094
1103
  p.push("// ROUTE SHEET exported by JRC ECDIS."), p.push("// <<NOTE>>This strings // indicate comment column/cells. You can edit freely."), p.push(`// ${b.xmlEscape(t)}`), p.push(d.join(","));
1095
1104
  for (let f = 0; f < e.length; f++) {
1096
- const m = e[f], S = String(f).padStart(3, "0"), v = h.lat2pretty(m.lat, 6), P = h.lng2pretty(m.lng, 6), y = v.degree, N = Number(v.minute).toFixed(s), $ = v.direction, E = P.degree, F = Number(P.minute).toFixed(s), R = P.direction, D = [S, String(y), N, $, String(E), F, R];
1097
- r && D.push(f === 0 ? "***" : m.port != null ? String(m.port) : "***"), i && D.push(f === 0 ? "***" : m.stbd != null ? String(m.stbd) : "***"), c && D.push(f === 0 ? "***" : m.arrRad != null ? String(m.arrRad) : "***"), a && D.push(f === 0 ? "***" : m.speed != null ? Number(m.speed).toFixed(1).padStart(5, "0") : "***"), l && D.push(f === 0 ? "***" : m.gcToPrevious ? "GC" : "RL"), u && D.push(f === 0 ? "***" : m.rot != null ? String(m.rot) : "***"), g && D.push(f === 0 ? "***" : m.turnRad != null ? String(m.turnRad) : "***"), o && D.push(m.name ?? ""), p.push(D.join(","));
1105
+ const m = e[f], S = String(f).padStart(3, "0"), v = h.lat2pretty(m.lat, 6), P = h.lng2pretty(m.lng, 6), y = v.degree, M = Number(v.minute).toFixed(s), $ = v.direction, E = P.degree, F = Number(P.minute).toFixed(s), R = P.direction, D = [S, String(y), M, $, String(E), F, R];
1106
+ i && D.push(f === 0 ? "***" : m.port != null ? String(m.port) : "***"), r && D.push(f === 0 ? "***" : m.stbd != null ? String(m.stbd) : "***"), o && D.push(f === 0 ? "***" : m.arrRad != null ? String(m.arrRad) : "***"), a && D.push(f === 0 ? "***" : m.speed != null ? Number(m.speed).toFixed(1).padStart(5, "0") : "***"), l && D.push(f === 0 ? "***" : m.gcToPrevious ? "GC" : "RL"), u && D.push(f === 0 ? "***" : m.rot != null ? String(m.rot) : "***"), g && D.push(f === 0 ? "***" : m.turnRad != null ? String(m.turnRad) : "***"), c && D.push(m.name ?? ""), p.push(D.join(","));
1098
1107
  }
1099
1108
  return p.join(`
1100
1109
  `);
@@ -1111,21 +1120,21 @@ class b {
1111
1120
  * @returns Uint8Array 二进制数据,可直接用于 new Blob([result], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
1112
1121
  */
1113
1122
  static waypoints2XLSX(t, e, n) {
1114
- const s = (n == null ? void 0 : n.precision) ?? 6, o = t || "Route", r = e.some((M) => M.name), i = e.some((M) => M.description), c = 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), g = e.some((M, A) => A > 0 && M.gcToPrevious != null), d = e.some((M) => M.bearing != null), p = e.some((M) => M.distanceFromPrevious != null), f = ["WPT No.", "Latitude", "Longitude"];
1115
- r && f.push("Name"), i && f.push("Description"), g && f.push("Leg"), d && f.push("Bearing[deg]"), p && f.push("Distance[NM]"), u && f.push("Speed[kn]"), c && f.push("PORT XTD[NM]"), a && f.push("STBD XTD[NM]"), l && f.push("Arr.Rad[NM]");
1116
- const m = (M) => M == null ? "" : String(M).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1117
- let v = `<row r="1">${f.map((M, A) => `<c r="${G(A)}1" s="1" t="inlineStr"><is><t>${m(M)}</t></is></c>`).join("")}</row>`;
1118
- for (let M = 0; M < e.length; M++) {
1119
- const A = e[M], j = M + 2, U = [], X = (L, q) => U.push(`<c r="${G(L)}${j}"><v>${q}</v></c>`), B = (L, q) => U.push(`<c r="${G(L)}${j}" t="inlineStr"><is><t>${m(q)}</t></is></c>`), w = (L, q) => {
1120
- q != null ? X(L, q) : B(L, "");
1123
+ const s = (n == null ? void 0 : n.precision) ?? 6, c = t || "Route", i = e.some((N) => N.name), r = e.some((N) => N.description), o = e.some((N) => N.port != null), a = e.some((N) => N.stbd != null), l = e.some((N) => N.arrRad != null), u = e.some((N) => N.speed != null), g = e.some((N, k) => k > 0 && N.gcToPrevious != null), d = e.some((N) => N.bearing != null), p = e.some((N) => N.distanceFromPrevious != null), f = ["WPT No.", "Latitude", "Longitude"];
1124
+ i && f.push("Name"), r && f.push("Description"), g && f.push("Leg"), d && f.push("Bearing[deg]"), p && f.push("Distance[NM]"), u && f.push("Speed[kn]"), o && f.push("PORT XTD[NM]"), a && f.push("STBD XTD[NM]"), l && f.push("Arr.Rad[NM]");
1125
+ const m = (N) => N == null ? "" : String(N).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1126
+ let v = `<row r="1">${f.map((N, k) => `<c r="${G(k)}1" s="1" t="inlineStr"><is><t>${m(N)}</t></is></c>`).join("")}</row>`;
1127
+ for (let N = 0; N < e.length; N++) {
1128
+ const k = e[N], j = N + 2, U = [], Z = (L, q) => U.push(`<c r="${G(L)}${j}"><v>${q}</v></c>`), B = (L, q) => U.push(`<c r="${G(L)}${j}" t="inlineStr"><is><t>${m(q)}</t></is></c>`), w = (L, q) => {
1129
+ q != null ? Z(L, q) : B(L, "");
1121
1130
  };
1122
- X(0, M + 1), B(1, h.lat2pretty(A.lat, s).pretty), B(2, h.lng2pretty(A.lng, s).pretty);
1131
+ Z(0, N + 1), B(1, h.lat2pretty(k.lat, s).pretty), B(2, h.lng2pretty(k.lng, s).pretty);
1123
1132
  let I = 3;
1124
- r && (B(I, A.name ?? ""), I++), i && (B(I, A.description ?? ""), I++), g && (B(I, M === 0 ? "" : A.gcToPrevious ? "GC" : "RL"), I++), d && (w(I, A.bearing), I++), p && (w(I, A.distanceFromPrevious), I++), u && (w(I, A.speed), I++), c && (w(I, A.port), I++), a && (w(I, A.stbd), I++), l && (w(I, A.arrRad), I++), v += `<row r="${j}">${U.join("")}</row>`;
1133
+ i && (B(I, k.name ?? ""), I++), r && (B(I, k.description ?? ""), I++), g && (B(I, N === 0 ? "" : k.gcToPrevious ? "GC" : "RL"), I++), d && (w(I, k.bearing), I++), p && (w(I, k.distanceFromPrevious), I++), u && (w(I, k.speed), I++), o && (w(I, k.port), I++), a && (w(I, k.stbd), I++), l && (w(I, k.arrRad), I++), v += `<row r="${j}">${U.join("")}</row>`;
1125
1134
  }
1126
- const P = "0." + "0".repeat(s), y = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>' + v + "</sheetData></worksheet>", N = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>', $ = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>', E = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="' + m(o) + '" sheetId="1" r:id="rId1"/></sheets></workbook>', F = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>', R = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><numFmts count="1"><numFmt numFmtId="164" formatCode="' + P + '"/></numFmts><fonts count="2"><font><sz val="11"/><name val="Arial"/></font><font><b/><sz val="11"/><name val="Arial"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="2"><border><left/><right/><top/><bottom/><diagonal/></border><border><bottom style="thin"><color auto="1"/></bottom></border></borders><cellStyleXfs count="1"><xf/></cellStyleXfs><cellXfs count="3"><xf/><xf fontId="1" fillId="0" borderId="1" applyFont="1" applyBorder="1"/><xf numFmtId="164" fontId="0" applyNumberFormat="1"/></cellXfs></styleSheet>', D = new TextEncoder();
1135
+ const P = "0." + "0".repeat(s), y = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>' + v + "</sheetData></worksheet>", M = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>', $ = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>', E = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="' + m(c) + '" sheetId="1" r:id="rId1"/></sheets></workbook>', F = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>', R = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><numFmts count="1"><numFmt numFmtId="164" formatCode="' + P + '"/></numFmts><fonts count="2"><font><sz val="11"/><name val="Arial"/></font><font><b/><sz val="11"/><name val="Arial"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="2"><border><left/><right/><top/><bottom/><diagonal/></border><border><bottom style="thin"><color auto="1"/></bottom></border></borders><cellStyleXfs count="1"><xf/></cellStyleXfs><cellXfs count="3"><xf/><xf fontId="1" fillId="0" borderId="1" applyFont="1" applyBorder="1"/><xf numFmtId="164" fontId="0" applyNumberFormat="1"/></cellXfs></styleSheet>', D = new TextEncoder();
1127
1136
  return _([
1128
- { name: "[Content_Types].xml", data: D.encode(N) },
1137
+ { name: "[Content_Types].xml", data: D.encode(M) },
1129
1138
  { name: "_rels/.rels", data: D.encode($) },
1130
1139
  { name: "xl/workbook.xml", data: D.encode(E) },
1131
1140
  { name: "xl/_rels/workbook.xml.rels", data: D.encode(F) },
@@ -1149,8 +1158,8 @@ class b {
1149
1158
  * @param isLat true为纬度,false为经度
1150
1159
  */
1151
1160
  static decimalToNmeaDm(t, e) {
1152
- const n = Math.abs(t), s = Math.floor(n), o = (n - s) * 60, r = e ? `${s.toString().padStart(2, "0")}${o.toFixed(2).padStart(5, "0")}` : `${s.toString().padStart(3, "0")}${o.toFixed(2).padStart(5, "0")}`, i = e ? t >= 0 ? "N" : "S" : t >= 0 ? "E" : "W";
1153
- return { dm: r, dir: i };
1161
+ 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";
1162
+ return { dm: i, dir: r };
1154
1163
  }
1155
1164
  /**
1156
1165
  * 计算NMEA 0183校验和 ($与*之间所有字符的异或,两字符十六进制大写)
@@ -1170,8 +1179,8 @@ class b {
1170
1179
  static waypoints2NMEA(t) {
1171
1180
  const e = [];
1172
1181
  for (let n = 0; n < t.length; n++) {
1173
- const s = t[n], o = b.decimalToNmeaDm(s.lat, !0), r = b.decimalToNmeaDm(s.lng, !1), i = s.name ? String(s.name).slice(0, 6) : `WPT${(n + 1).toString().padStart(3, "0")}`, c = `GPWPL,${o.dm},${o.dir},${r.dm},${r.dir},${i}`, a = b.nmeaChecksum(c);
1174
- e.push(`$${c}*${a}`);
1182
+ const s = t[n], c = b.decimalToNmeaDm(s.lat, !0), i = b.decimalToNmeaDm(s.lng, !1), r = s.name ? String(s.name).slice(0, 6) : `WPT${(n + 1).toString().padStart(3, "0")}`, o = `GPWPL,${c.dm},${c.dir},${i.dm},${i.dir},${r}`, a = b.nmeaChecksum(o);
1183
+ e.push(`$${o}*${a}`);
1175
1184
  }
1176
1185
  return e.join(`\r
1177
1186
  `);
@@ -1190,17 +1199,17 @@ class b {
1190
1199
  */
1191
1200
  static coordinatesSummary(t, e = 3) {
1192
1201
  if (t.length > 1) {
1193
- const n = t[0], s = t[t.length - 1], o = (n == null ? void 0 : n.positionTime) < (s == null ? void 0 : s.positionTime) ? x.unix(n == null ? void 0 : n.positionTime) : x.unix(s == null ? void 0 : s.positionTime), r = (n == null ? void 0 : n.positionTime) > (s == null ? void 0 : s.positionTime) ? x.unix(n == null ? void 0 : n.positionTime) : x.unix(s == null ? void 0 : s.positionTime), i = Math.round(r.diff(o, "hours", !0) * 100) / 100, c = this.generateRouteAccordingToWaypoints(t, !0, !0), a = this.calculateRouteDistance(c), u = K.inspectStoppages(t, e).reduce(
1202
+ const n = t[0], s = t[t.length - 1], c = (n == null ? void 0 : n.positionTime) < (s == null ? void 0 : s.positionTime) ? x.unix(n == null ? void 0 : n.positionTime) : x.unix(s == null ? void 0 : s.positionTime), i = (n == null ? void 0 : n.positionTime) > (s == null ? void 0 : s.positionTime) ? x.unix(n == null ? void 0 : n.positionTime) : x.unix(s == null ? void 0 : s.positionTime), r = Math.round(i.diff(c, "hours", !0) * 100) / 100, o = this.generateRouteAccordingToWaypoints(t, !0, !0), a = this.calculateRouteDistance(o), u = K.inspectStoppages(t, e).reduce(
1194
1203
  (d, p) => (d.duration += p.duration, d.distance += p.distance, d),
1195
1204
  { hours: 0, distance: 0, spd: 0, duration: 0 }
1196
1205
  );
1197
1206
  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;
1198
- const g = i ? Math.round((a - u.distance) / (i - u.hours) * 100) / 100 : 0;
1207
+ const g = r ? Math.round((a - u.distance) / (r - u.hours) * 100) / 100 : 0;
1199
1208
  return {
1200
- begin: o.utc().format(),
1201
- end: r.utc().format(),
1209
+ begin: c.utc().format(),
1210
+ end: i.utc().format(),
1202
1211
  distance: Math.round((a - u.distance) * 100) / 100,
1203
- hours: Math.round((i - u.hours) * 100) / 100,
1212
+ hours: Math.round((r - u.hours) * 100) / 100,
1204
1213
  avgSpeed: g,
1205
1214
  stoppage: u
1206
1215
  };
@@ -1226,14 +1235,14 @@ class b {
1226
1235
  var l, u, g;
1227
1236
  if (!((u = (l = e == null ? void 0 : e.sample) == null ? void 0 : l.hours) != null && u.length))
1228
1237
  return { routes: [], hour: void 0 };
1229
- const n = e.sample.hours.at(0), s = x.utc(t), o = x.utc(e.eta), r = s.isAfter(o) ? o : s;
1230
- let i = e.sample.all.find((d) => d.eta === r.format());
1231
- if (!i) {
1232
- const d = e.sample.all.filter((N) => x.utc(N.eta).isBefore(r)).at(-1), p = this.calculateSubRoute(d, e.route);
1233
- i = (g = this.calculateNextCoordinateAlongRoute(d, d.speed * r.diff(x(d.etd), "hours", !0), p)) == null ? void 0 : g.coordinate;
1234
- const { cFactor: f, cog: m, wxFactor: S, meteo: v } = d, P = Math.round(i.distanceFromPrevious * 1e4) / 1e4, y = Math.round((P + d.distanceFromStart) * 1e4) / 1e4;
1235
- i = {
1236
- ...i,
1238
+ const n = e.sample.hours.at(0), s = x.utc(t), c = x.utc(e.eta), i = s.isAfter(c) ? c : s;
1239
+ let r = e.sample.all.find((d) => d.eta === i.format());
1240
+ if (!r) {
1241
+ const d = e.sample.all.filter((M) => x.utc(M.eta).isBefore(i)).at(-1), p = this.calculateSubRoute(d, e.route);
1242
+ r = (g = this.calculateNextCoordinateAlongRoute(d, d.speed * i.diff(x(d.etd), "hours", !0), p)) == null ? void 0 : g.coordinate;
1243
+ const { cFactor: f, cog: m, wxFactor: S, meteo: v } = d, P = Math.round(r.distanceFromPrevious * 1e4) / 1e4, y = Math.round((P + d.distanceFromStart) * 1e4) / 1e4;
1244
+ r = {
1245
+ ...r,
1237
1246
  cFactor: f,
1238
1247
  cog: m,
1239
1248
  speed: d.speed,
@@ -1241,15 +1250,15 @@ class b {
1241
1250
  distanceFromStart: y,
1242
1251
  distanceFromPrevious: P,
1243
1252
  meteo: v,
1244
- eta: r.format(),
1245
- etd: r.format()
1253
+ eta: i.format(),
1254
+ etd: i.format()
1246
1255
  };
1247
1256
  }
1248
- i.distanceToGo = Math.round((e.distance - i.distanceFromStart) * 100) / 100, i.timeToGo = Math.round(o.diff(i.etd, "hours", !0) * 100) / 100;
1249
- const c = this.calculateRangeWaypoints(n, i, e.route);
1257
+ r.distanceToGo = Math.round((e.distance - r.distanceFromStart) * 100) / 100, r.timeToGo = Math.round(c.diff(r.etd, "hours", !0) * 100) / 100;
1258
+ const o = this.calculateRangeWaypoints(n, r, e.route);
1250
1259
  return {
1251
- routes: this.generateRouteAccordingToWaypoints(c),
1252
- hour: i
1260
+ routes: this.generateRouteAccordingToWaypoints(o),
1261
+ hour: r
1253
1262
  };
1254
1263
  }
1255
1264
  /**
@@ -1264,10 +1273,10 @@ class b {
1264
1273
  */
1265
1274
  static pickUTCSampleFromRoute(t, e, n) {
1266
1275
  var d;
1267
- const s = this.calculateSubRoute(e, n), o = this.calculateRouteDistance(s), r = o / e.speed, i = x.utc(t), c = x(e.etd), a = (d = this.calculateNextCoordinateAlongRoute(e, e.speed * i.diff(x(e.etd), "hours", !0), s)) == null ? void 0 : d.coordinate;
1276
+ const s = this.calculateSubRoute(e, n), c = this.calculateRouteDistance(s), i = c / e.speed, r = x.utc(t), o = x(e.etd), a = (d = this.calculateNextCoordinateAlongRoute(e, e.speed * r.diff(x(e.etd), "hours", !0), s)) == null ? void 0 : d.coordinate;
1268
1277
  a.speed = e.speed;
1269
- const l = c.clone().add(a.hourFromPrevious, "hour");
1270
- a.eta = Math.abs(l.diff(i, "second")) < 2 ? i.format() : l.format(), a.etd = a.eta, a.distanceFromStart = Math.round(a.distanceFromPrevious * 100) / 100, a.distanceToGo = Math.round((o - a.distanceFromStart) * 100) / 100, a.timeToGo = Math.round(c.clone().add(r, "hour").diff(x(a.etd), "hour") * 100) / 100;
1278
+ const l = o.clone().add(a.hourFromPrevious, "hour");
1279
+ a.eta = Math.abs(l.diff(r, "second")) < 2 ? r.format() : l.format(), a.etd = a.eta, a.distanceFromStart = Math.round(a.distanceFromPrevious * 100) / 100, a.distanceToGo = Math.round((c - a.distanceFromStart) * 100) / 100, a.timeToGo = Math.round(o.clone().add(i, "hour").diff(x(a.etd), "hour") * 100) / 100;
1271
1280
  const u = this.calculateRangeWaypoints(e, a, n);
1272
1281
  return {
1273
1282
  routes: this.generateRouteAccordingToWaypoints(u),
@@ -1280,7 +1289,7 @@ class b {
1280
1289
  * @param degree 要素角度,如 swell.degree
1281
1290
  */
1282
1291
  static includedAngle(t, e) {
1283
- Z == null || Z.debug("calculate bearing via: %j", { bearing: t, degree: e });
1292
+ X == null || X.debug("calculate bearing via: %j", { bearing: t, degree: e });
1284
1293
  let n = Math.abs(t % 360 - (e % 360 || 0));
1285
1294
  return n = n > 180 ? 360 - n : n, n;
1286
1295
  }
@@ -1300,28 +1309,28 @@ class b {
1300
1309
  * 如果没有相交区域,返回空数组。
1301
1310
  */
1302
1311
  static async intersectInECA(t, e) {
1303
- var o, r;
1304
- const s = (e instanceof Array ? e : e.features).filter((i) => {
1305
- var c, a;
1306
- return ((c = i.geometry) == null ? void 0 : c.type) === "Polygon" && !((a = i.properties) != null && a.disabled);
1312
+ var c, i;
1313
+ const s = (e instanceof Array ? e : e.features).filter((r) => {
1314
+ var o, a;
1315
+ return ((o = r.geometry) == null ? void 0 : o.type) === "Polygon" && !((a = r.properties) != null && a.disabled);
1307
1316
  });
1308
1317
  if (t != null && t.length) {
1309
- let i = t;
1310
- t.some((u) => u instanceof Array) ? t = this.convertRouteToCoordinates(t) : i = this.divideAccordingToLng(t);
1311
- const c = i.map((u) => T.lineString(u)), a = [], l = s.map((u) => ({
1318
+ let r = t;
1319
+ t.some((u) => u instanceof Array) ? t = this.convertRouteToCoordinates(t) : r = this.divideAccordingToLng(t);
1320
+ const o = r.map((u) => T.lineString(u)), a = [], l = s.map((u) => ({
1312
1321
  polygon: u,
1313
1322
  bbox: T.bbox(u)
1314
1323
  // [minX, minY, maxX, maxY]
1315
1324
  }));
1316
- for (const u of c) {
1325
+ for (const u of o) {
1317
1326
  const g = u.geometry.coordinates, d = this.convertRouteToCoordinates([g]), p = T.bbox(u);
1318
1327
  for (const { polygon: f, bbox: m } of l) {
1319
1328
  if (p[0] > m[2] || p[2] < m[0] || p[1] > m[3] || p[3] < m[1])
1320
1329
  continue;
1321
1330
  let S = [];
1322
1331
  const v = T.lineIntersect(u, f);
1323
- (o = v == null ? void 0 : v.features) != null && o.length && (S = T.getCoords(v.features).map((N) => {
1324
- const $ = T.getCoord(N);
1332
+ (c = v == null ? void 0 : v.features) != null && c.length && (S = T.getCoords(v.features).map((M) => {
1333
+ const $ = T.getCoord(M);
1325
1334
  return { lng: $[0], lat: $[1] };
1326
1335
  }));
1327
1336
  const P = [...d];
@@ -1329,7 +1338,7 @@ class b {
1329
1338
  for (const y of S)
1330
1339
  this.mergeCoordinateToWaypoints(y, P, !0);
1331
1340
  for (let y = 0; y < P.length - 1; y++) {
1332
- const N = P[y], $ = P[y + 1], E = this.calculateRangeWaypoints(N, $, [], P), F = this.divideAccordingToLng(E);
1341
+ const M = P[y], $ = P[y + 1], E = this.calculateRangeWaypoints(M, $, [], P), F = this.divideAccordingToLng(E);
1333
1342
  for (const R of F) {
1334
1343
  const D = [
1335
1344
  Math.min(R[0][0], R[R.length - 1][0]),
@@ -1339,13 +1348,13 @@ class b {
1339
1348
  ];
1340
1349
  if (D[0] > m[2] || D[2] < m[0] || D[1] > m[3] || D[3] < m[1])
1341
1350
  continue;
1342
- const M = T.lineString(R);
1343
- if (T.booleanContains(f, M)) {
1344
- const A = R.map((U) => ({ lng: U[0], lat: U[1] })), j = this.calculateRouteDistance([R]);
1351
+ const N = T.lineString(R);
1352
+ if (T.booleanContains(f, N)) {
1353
+ const k = R.map((U) => ({ lng: U[0], lat: U[1] })), j = this.calculateRouteDistance([R]);
1345
1354
  a.push({
1346
1355
  distance: j,
1347
- waypoints: A,
1348
- eca: (r = f == null ? void 0 : f.properties) == null ? void 0 : r.name
1356
+ waypoints: k,
1357
+ eca: (i = f == null ? void 0 : f.properties) == null ? void 0 : i.name
1349
1358
  });
1350
1359
  }
1351
1360
  }
@@ -1357,34 +1366,34 @@ class b {
1357
1366
  return [];
1358
1367
  }
1359
1368
  }
1360
- let k;
1369
+ let A;
1361
1370
  try {
1362
- k = z.getLogger("vessel");
1371
+ A = z.getLogger("vessel");
1363
1372
  } catch {
1364
1373
  } finally {
1365
1374
  }
1366
- class it {
1375
+ class rt {
1367
1376
  /**
1368
1377
  * 将原始数据转换为geojson
1369
1378
  * @param raw
1370
1379
  */
1371
1380
  static convert2Geojson(t) {
1372
- var n, s, o;
1381
+ var n, s, c;
1373
1382
  const e = T.featureCollection([]);
1374
- for (const r of t) {
1375
- const i = (n = r.history) == null ? void 0 : n[0];
1376
- if (r.forecasts) {
1377
- i && i.wind && (i.wind.kts = i.kts);
1378
- for (const c of r.forecasts) {
1383
+ for (const i of t) {
1384
+ const r = (n = i.history) == null ? void 0 : n[0];
1385
+ if (i.forecasts) {
1386
+ r && r.wind && (r.wind.kts = r.kts);
1387
+ for (const o of i.forecasts) {
1379
1388
  let a;
1380
- const l = [], u = [], g = x(c.date).utc(), d = `${r.name}-${c.model}`;
1381
- for (const f in c == null ? void 0 : c.hours) {
1382
- const m = c.hours[f];
1389
+ const l = [], u = [], g = x(o.date).utc(), d = `${i.name}-${o.model}`;
1390
+ for (const f in o == null ? void 0 : o.hours) {
1391
+ const m = o.hours[f];
1383
1392
  a = a || m;
1384
1393
  const S = g.clone().add(Number(f), "hour"), v = T.point([m.lng, m.lat], {
1385
- model: c.model,
1386
- name: r.name,
1387
- nameCn: r.nameCn,
1394
+ model: o.model,
1395
+ name: i.name,
1396
+ nameCn: i.nameCn,
1388
1397
  date: S.format(),
1389
1398
  hour: Number(f),
1390
1399
  format: S.format("MMM-DD/HHmm[Z]"),
@@ -1401,21 +1410,21 @@ class it {
1401
1410
  kts: void 0,
1402
1411
  deg: void 0
1403
1412
  };
1404
- if (i) {
1405
- const f = x(i.updated).utc();
1413
+ if (r) {
1414
+ const f = x(r.updated).utc();
1406
1415
  if (a) {
1407
- const S = b.calculateDistance(i, a), v = x(a.utc || a.updated).diff(f, "h", !0);
1408
- p.kts = Math.round(S / v * 100) / 100, p.deg = b.calculateBearing(i, a, !0, 0);
1416
+ const S = b.calculateDistance(r, a), v = x(a.utc || a.updated).diff(f, "h", !0);
1417
+ p.kts = Math.round(S / v * 100) / 100, p.deg = b.calculateBearing(r, a, !0, 0);
1409
1418
  }
1410
- const m = T.point([i.lng, i.lat], {
1411
- model: c.model,
1412
- name: r.name,
1413
- nameCn: r.nameCn,
1419
+ const m = T.point([r.lng, r.lat], {
1420
+ model: o.model,
1421
+ name: i.name,
1422
+ nameCn: i.nameCn,
1414
1423
  date: f.format(),
1415
1424
  hour: 0,
1416
1425
  format: f.format("MMM-DD/HHmm[Z]"),
1417
- pressure: i.pressure > 1e4 ? h.roundPrecision((i == null ? void 0 : i.pressure) / 100, 0) : h.roundPrecision(i.pressure, 0),
1418
- wind: i.wind,
1426
+ pressure: r.pressure > 1e4 ? h.roundPrecision((r == null ? void 0 : r.pressure) / 100, 0) : h.roundPrecision(r.pressure, 0),
1427
+ wind: r.wind,
1419
1428
  movement: p,
1420
1429
  category: d,
1421
1430
  type: "forecast",
@@ -1426,10 +1435,10 @@ class it {
1426
1435
  }
1427
1436
  if (e.features.push(...u), (l == null ? void 0 : l.length) > 1) {
1428
1437
  const f = T.lineString(h.convertToMonotonicLng2(l), {
1429
- date: (i == null ? void 0 : i.updated) || (g == null ? void 0 : g.format()),
1430
- id: r.id || r.name,
1431
- model: c.model,
1432
- name: r.name,
1438
+ date: (r == null ? void 0 : r.updated) || (g == null ? void 0 : g.format()),
1439
+ id: i.id || i.name,
1440
+ model: o.model,
1441
+ name: i.name,
1433
1442
  category: d,
1434
1443
  type: "forecast",
1435
1444
  movement: p
@@ -1438,35 +1447,35 @@ class it {
1438
1447
  }
1439
1448
  }
1440
1449
  }
1441
- if (e.features.sort((c, a) => c.properties.type === "forecast" && a.properties.type === "forecast" && c.geometry.type === "Point" && a.geometry.type === "Point" ? x(c.properties.date).valueOf() - x(a.properties.date).valueOf() : 0), (s = r.history) != null && s.length) {
1442
- const c = [], a = x(i == null ? void 0 : i.updated).utc(), l = x((o = r.history) == null ? void 0 : o.at(-1).updated).utc(), u = a.diff(l, "h") % 24 > 2 ? 24 : 12;
1443
- for (const g of r.history) {
1450
+ if (e.features.sort((o, a) => o.properties.type === "forecast" && a.properties.type === "forecast" && o.geometry.type === "Point" && a.geometry.type === "Point" ? x(o.properties.date).valueOf() - x(a.properties.date).valueOf() : 0), (s = i.history) != null && s.length) {
1451
+ const o = [], a = x(r == null ? void 0 : r.updated).utc(), l = x((c = i.history) == null ? void 0 : c.at(-1).updated).utc(), u = a.diff(l, "h") % 24 > 2 ? 24 : 12;
1452
+ for (const g of i.history) {
1444
1453
  const d = x(g.updated).utc(), p = d.isSameOrBefore(a) || d.isSame(l);
1445
1454
  p && a.add(-u, "h");
1446
1455
  const f = T.point([g.lng, g.lat], {
1447
- name: r.name,
1448
- nameCn: r.nameCn,
1456
+ name: i.name,
1457
+ nameCn: i.nameCn,
1449
1458
  date: d.format(),
1450
1459
  format: d.format("MMM-DD/HHmm[Z]"),
1451
1460
  pressure: g.pressure > 1e4 ? h.roundPrecision(g.pressure / 100, 0) : h.roundPrecision(g.pressure, 0),
1452
1461
  kts: g.kts,
1453
1462
  level: g.type,
1454
1463
  type: "history",
1455
- category: `${r.name}-history`,
1464
+ category: `${i.name}-history`,
1456
1465
  wind: g.wind,
1457
1466
  movement: g.movement,
1458
1467
  important: p
1459
1468
  });
1460
- e.features.push(f), c.push(f.geometry.coordinates);
1469
+ e.features.push(f), o.push(f.geometry.coordinates);
1461
1470
  }
1462
- if (c.length === 1 && c.push(c[0]), c.length > 1) {
1463
- const g = T.lineString(h.convertToMonotonicLng2(c), {
1464
- name: r.name,
1471
+ if (o.length === 1 && o.push(o[0]), o.length > 1) {
1472
+ const g = T.lineString(h.convertToMonotonicLng2(o), {
1473
+ name: i.name,
1465
1474
  type: "history",
1466
- updated: i == null ? void 0 : i.updated,
1467
- 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),
1468
- kts: i == null ? void 0 : i.kts,
1469
- level: i == null ? void 0 : i.type
1475
+ updated: r == null ? void 0 : r.updated,
1476
+ pressure: (r == null ? void 0 : r.pressure) > 1e4 ? h.roundPrecision((r == null ? void 0 : r.pressure) / 100, 0) : h.roundPrecision(r == null ? void 0 : r.pressure, 0),
1477
+ kts: r == null ? void 0 : r.kts,
1478
+ level: r == null ? void 0 : r.type
1470
1479
  });
1471
1480
  e.features.push(g);
1472
1481
  }
@@ -1480,28 +1489,28 @@ class it {
1480
1489
  * @param step
1481
1490
  */
1482
1491
  static interpolate(t, e = 3) {
1483
- var o, r, i, c;
1484
- const n = (o = t == null ? void 0 : t.data) == null ? void 0 : o.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), s = [];
1492
+ var c, i, r, o;
1493
+ 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 = [];
1485
1494
  for (const a of n) {
1486
1495
  const l = a.properties.name, u = a.properties.model, g = a.properties.showCircle, d = a.properties.disabled, p = x(a.properties.date).utc();
1487
1496
  let f = e * 60;
1488
- const m = (r = t == null ? void 0 : t.data) == null ? void 0 : r.features.filter(
1497
+ const m = (i = t == null ? void 0 : t.data) == null ? void 0 : i.features.filter(
1489
1498
  (P) => P.geometry.type === "Point" && P.properties.type === "forecast" && P.properties.category === `${l}-${u}`
1490
1499
  );
1491
1500
  let S, v = p.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1492
1501
  for (; S = this.pickIndex(m, v), S <= m.length - 1; ) {
1493
1502
  if (S > 0) {
1494
- const P = m[S], y = S === 0 ? void 0 : m[S - 1], N = (f / 60 - ((i = y == null ? void 0 : y.properties) == null ? void 0 : i.hour)) / (P.properties.hour - ((c = y == null ? void 0 : y.properties) == null ? void 0 : c.hour)), $ = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[0], P.geometry.coordinates[0], N), E = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[1], P.geometry.coordinates[1], N), F = T.point([$, E], {
1503
+ const P = m[S], y = S === 0 ? void 0 : m[S - 1], M = (f / 60 - ((r = y == null ? void 0 : y.properties) == null ? void 0 : r.hour)) / (P.properties.hour - ((o = y == null ? void 0 : y.properties) == null ? void 0 : o.hour)), $ = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[0], P.geometry.coordinates[0], M), E = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[1], P.geometry.coordinates[1], M), F = T.point([$, E], {
1495
1504
  name: l,
1496
1505
  model: u,
1497
1506
  category: P == null ? void 0 : P.properties.category,
1498
1507
  date: v.format(),
1499
1508
  format: v.format("MMM-DD/HHmm[Z]"),
1500
- gusts: this.computeNumber(y == null ? void 0 : y.properties.gusts, P.properties.gusts, N),
1501
- hour: this.computeNumber(y == null ? void 0 : y.properties.hour, P.properties.hour, N),
1502
- movement: this.computeNumber(y == null ? void 0 : y.properties.movement, P.properties.movement, N),
1503
- pressure: this.computeNumber(y == null ? void 0 : y.properties.pressure, P.properties.pressure, N),
1504
- wind: this.computeNumber(y == null ? void 0 : y.properties.wind, P.properties.wind, N),
1509
+ gusts: this.computeNumber(y == null ? void 0 : y.properties.gusts, P.properties.gusts, M),
1510
+ hour: this.computeNumber(y == null ? void 0 : y.properties.hour, P.properties.hour, M),
1511
+ movement: this.computeNumber(y == null ? void 0 : y.properties.movement, P.properties.movement, M),
1512
+ pressure: this.computeNumber(y == null ? void 0 : y.properties.pressure, P.properties.pressure, M),
1513
+ wind: this.computeNumber(y == null ? void 0 : y.properties.wind, P.properties.wind, M),
1505
1514
  type: "forecast",
1506
1515
  disabled: d,
1507
1516
  showCircle: g
@@ -1520,8 +1529,8 @@ class it {
1520
1529
  * @param options
1521
1530
  */
1522
1531
  static accelPassageAt(t, e) {
1523
- const { t1: n, t2: s, hr: o, hours: r } = this.tropicalCenterTwin(t, 24, e);
1524
- return { t1: n, t2: s, hr: o, hours: r };
1532
+ const { t1: n, t2: s, hr: c, hours: i } = this.tropicalCenterTwin(t, 24, e);
1533
+ return { t1: n, t2: s, hr: c, hours: i };
1525
1534
  }
1526
1535
  /**
1527
1536
  * 计算最佳绕航点
@@ -1535,31 +1544,31 @@ class it {
1535
1544
  * @param options
1536
1545
  */
1537
1546
  static diversionPassageAt(t, e, n, s = {}) {
1538
- const { t1: o, t2: r, hr: i, hours: c } = this.tropicalCenterTwin(e, 24, s);
1539
- if (o && r) {
1547
+ const { t1: c, t2: i, hr: r, hours: o } = this.tropicalCenterTwin(e, 24, s);
1548
+ if (c && i) {
1540
1549
  if (!s.debug) {
1541
- const p = b.calculateDistance(t, o), f = b.calculateDistance(t, r);
1550
+ const p = b.calculateDistance(t, c), f = b.calculateDistance(t, i);
1542
1551
  if (p > 2 * n && f > 2 * n)
1543
- return k == null || k.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, p, f, {
1552
+ return A == null || A.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, p, f, {
1544
1553
  from: t,
1545
- t1: o,
1546
- t2: r,
1547
- hr: i
1554
+ t1: c,
1555
+ t2: i,
1556
+ hr: r
1548
1557
  }), {};
1549
1558
  }
1550
- const a = b.calculateBearing(t, o), l = b.calculateBearing(o, r), u = Math.abs(a - l);
1559
+ const a = b.calculateBearing(t, c), l = b.calculateBearing(c, i), u = Math.abs(a - l);
1551
1560
  let g = 0;
1552
1561
  u < 180 ? g = u + 90 : u >= 180 && (g = u - 90);
1553
- const d = b.calculateCoordinate(o, g, n);
1554
- return k == null || k.info("[%s] the right tangent position: %j", s.requestId, {
1562
+ const d = b.calculateCoordinate(c, g, n);
1563
+ return A == null || A.info("[%s] the right tangent position: %j", s.requestId, {
1555
1564
  from: t,
1556
- t1: o,
1557
- t2: r,
1565
+ t1: c,
1566
+ t2: i,
1558
1567
  radius: n,
1559
1568
  bearing1: a,
1560
1569
  bearing2: l,
1561
1570
  right: d
1562
- }), { at: d, t1: o, t2: r, hr: Number(i), hours: c };
1571
+ }), { at: d, t1: c, t2: i, hr: Number(r), hours: o };
1563
1572
  }
1564
1573
  return {};
1565
1574
  }
@@ -1574,22 +1583,22 @@ class it {
1574
1583
  * @param options
1575
1584
  */
1576
1585
  static driftPassageAt(t, e, n, s = {}) {
1577
- const { t1: o, t2: r, hr: i, hours: c } = this.tropicalCenterTwin(e, 24, s);
1578
- if (o && r) {
1586
+ const { t1: c, t2: i, hr: r, hours: o } = this.tropicalCenterTwin(e, 24, s);
1587
+ if (c && i) {
1579
1588
  if (!s.debug) {
1580
- const d = b.calculateDistance(t, o), p = b.calculateDistance(t, r);
1589
+ const d = b.calculateDistance(t, c), p = b.calculateDistance(t, i);
1581
1590
  if (d > 2 * n && p > 2 * n)
1582
- return k == null || k.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, d, p, {
1591
+ 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, {
1583
1592
  from: t,
1584
- t1: o,
1585
- t2: r,
1586
- hr: i
1593
+ t1: c,
1594
+ t2: i,
1595
+ hr: r
1587
1596
  }), {};
1588
1597
  }
1589
- const a = b.calculateBearing(t, o), l = b.calculateBearing(o, r), u = b.calculateDistance(t, o);
1590
- return { at: b.calculateCoordinate(o, a - l + 180, n < u ? n : u), t1: o, t2: r, hr: Number(i), hours: c };
1598
+ const a = b.calculateBearing(t, c), l = b.calculateBearing(c, i), u = b.calculateDistance(t, c);
1599
+ return { at: b.calculateCoordinate(c, a - l + 180, n < u ? n : u), t1: c, t2: i, hr: Number(r), hours: o };
1591
1600
  } else
1592
- return k == null || k.info("[%s] no need drift: %j", s.requestId, { from: t, t1: o, t2: r, hr: i }), {};
1601
+ return A == null || A.info("[%s] no need drift: %j", s.requestId, { from: t, t1: c, t2: i, hr: r }), {};
1593
1602
  }
1594
1603
  /**
1595
1604
  * 获取台风中心点对
@@ -1605,16 +1614,16 @@ class it {
1605
1614
  (l = t.forecasts) == null || l.forEach((f) => {
1606
1615
  s = { ...f.hours, ...s };
1607
1616
  });
1608
- const o = ((u = t == null ? void 0 : t.history) == null ? void 0 : u[0]) || (s == null ? void 0 : s[(g = Object.keys(s)) == null ? void 0 : g[0]]);
1609
- k == null || k.info("[%s] the first tropical center: %j", n.requestId, o);
1610
- let r = (d = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : e))) == null ? void 0 : d.at(-1);
1611
- r || (r = (p = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : p.at(-1));
1612
- const i = s == null ? void 0 : s[r || -1];
1613
- k == null || k.info("[%s] the second tropical center: %j in %d hrs", n.requestId, i, r);
1614
- const c = Object.keys(s || {}).filter((f) => Number(f) <= Number(r)), a = { 0: o };
1615
- for (const f of c)
1617
+ const c = ((u = t == null ? void 0 : t.history) == null ? void 0 : u[0]) || (s == null ? void 0 : s[(g = Object.keys(s)) == null ? void 0 : g[0]]);
1618
+ A == null || A.info("[%s] the first tropical center: %j", n.requestId, c);
1619
+ let i = (d = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : e))) == null ? void 0 : d.at(-1);
1620
+ i || (i = (p = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : p.at(-1));
1621
+ const r = s == null ? void 0 : s[i || -1];
1622
+ A == null || A.info("[%s] the second tropical center: %j in %d hrs", n.requestId, r, i);
1623
+ const o = Object.keys(s || {}).filter((f) => Number(f) <= Number(i)), a = { 0: c };
1624
+ for (const f of o)
1616
1625
  a[f] = s[f];
1617
- return { t1: o, t2: i, hr: Number(r), hours: a };
1626
+ return { t1: c, t2: r, hr: Number(i), hours: a };
1618
1627
  }
1619
1628
  static pickIndex(t, e) {
1620
1629
  let n = 0;
@@ -1630,8 +1639,8 @@ class it {
1630
1639
  if (e) {
1631
1640
  if (isNaN(t) && isNaN(e) && typeof t != "string" && typeof e != "string") {
1632
1641
  const s = {};
1633
- for (const o in t)
1634
- s[o] = this.computeNumber(t[o], e[o], n);
1642
+ for (const c in t)
1643
+ s[c] = this.computeNumber(t[c], e[c], n);
1635
1644
  return s;
1636
1645
  }
1637
1646
  return Math.round((t + (e - t) * n) * 100) / 100;
@@ -1686,10 +1695,10 @@ class W {
1686
1695
  * @param options 步数、单位等选项
1687
1696
  */
1688
1697
  static drawCircle(t, e, n, s = {}) {
1689
- const o = (s == null ? void 0 : s.steps) ?? 64, r = (s == null ? void 0 : s.units) ?? "nauticalmiles", i = (s == null ? void 0 : s.properties) ?? {}, c = T.point([t, e]), a = T.destination(c, n, 90, { units: r }), l = x.utc();
1690
- i.id = (s == null ? void 0 : s.id) || l.valueOf().toString();
1698
+ const c = (s == null ? void 0 : s.steps) ?? 64, i = (s == null ? void 0 : s.units) ?? "nauticalmiles", r = (s == null ? void 0 : s.properties) ?? {}, o = T.point([t, e]), a = T.destination(o, n, 90, { units: i }), l = x.utc();
1699
+ r.id = (s == null ? void 0 : s.id) || l.valueOf().toString();
1691
1700
  const u = "circle";
1692
- 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((g) => h.roundPrecision(g, 9)), i.units = r, i.steps = o, i.shape = "circle", O.info("[%s] draw circle with %j", s == null ? void 0 : s.requestId, i), T.circle(c, n, { steps: o, units: r, properties: i });
1701
+ return r.name = (s == null ? void 0 : s.name) || `${u}_${l.format()}`, r.radius = n, r.center = [t, e], r.end = a.geometry.coordinates.map((g) => h.roundPrecision(g, 9)), r.units = i, r.steps = c, r.shape = "circle", O.info("[%s] draw circle with %j", s == null ? void 0 : s.requestId, r), T.circle(o, n, { steps: c, units: i, properties: r });
1693
1702
  }
1694
1703
  /**
1695
1704
  * 基于turf画矩形,返回GeoJSON Feature<Polygon>
@@ -1698,11 +1707,11 @@ class W {
1698
1707
  * @param options 选项
1699
1708
  */
1700
1709
  static drawRect(t, e, n = {}) {
1701
- const s = (n == null ? void 0 : n.properties) ?? {}, o = x.utc();
1702
- s.id = (n == null ? void 0 : n.id) || o.valueOf().toString();
1703
- const r = "rect";
1704
- s.name = (n == null ? void 0 : n.name) || `${r}_${o.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);
1705
- const [i, c] = h.convertToMonotonicLng2([t, e]), a = [Math.min(i[0], c[0]), Math.min(i[1], c[1]), Math.max(i[0], c[0]), Math.max(i[1], c[1])];
1710
+ const s = (n == null ? void 0 : n.properties) ?? {}, c = x.utc();
1711
+ s.id = (n == null ? void 0 : n.id) || c.valueOf().toString();
1712
+ const i = "rect";
1713
+ s.name = (n == null ? void 0 : n.name) || `${i}_${c.format()}`, s.start = t.map((l) => h.roundPrecision(l, 9)), s.end = e.map((l) => h.roundPrecision(l, 9)), s.shape = "rect", O.info("[%s] draw rect with %j", n == null ? void 0 : n.requestId, s);
1714
+ const [r, o] = h.convertToMonotonicLng2([t, e]), a = [Math.min(r[0], o[0]), Math.min(r[1], o[1]), Math.max(r[0], o[0]), Math.max(r[1], o[1])];
1706
1715
  return T.bboxPolygon(a, { properties: s });
1707
1716
  }
1708
1717
  /**
@@ -1715,10 +1724,10 @@ class W {
1715
1724
  static drawLine(t, e = {}) {
1716
1725
  const n = (e == null ? void 0 : e.properties) ?? {}, s = x.utc();
1717
1726
  n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1718
- const o = "line";
1719
- n.name = (e == null ? void 0 : e.name) || `${o}_${s.format()}`, n.shape = "line", O.info("[%s] draw line with %j", e == null ? void 0 : e.requestId, n);
1720
- const r = h.convertToMonotonicLng2(t);
1721
- return T.lineString(r, n);
1727
+ const c = "line";
1728
+ n.name = (e == null ? void 0 : e.name) || `${c}_${s.format()}`, n.shape = "line", O.info("[%s] draw line with %j", e == null ? void 0 : e.requestId, n);
1729
+ const i = h.convertToMonotonicLng2(t);
1730
+ return T.lineString(i, n);
1722
1731
  }
1723
1732
  /**
1724
1733
  * 基于turf画多边形,返回GeoJSON Feature<Polygon>
@@ -1729,10 +1738,10 @@ class W {
1729
1738
  static drawPolygon(t, e = {}) {
1730
1739
  const n = (e == null ? void 0 : e.properties) ?? {}, s = x.utc();
1731
1740
  n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1732
- const o = "polygon";
1733
- n.name = (e == null ? void 0 : e.name) || `${o}_${s.format()}`, n.coordinates = t.map((i) => i.map((c) => h.roundPrecision(c, 9))), n.shape = "polygon", O.info("[%s] draw polygon with %j", e == null ? void 0 : e.requestId, n);
1734
- const r = h.convertToMonotonicLng2(t);
1735
- return T.polygon([r], n);
1741
+ const c = "polygon";
1742
+ n.name = (e == null ? void 0 : e.name) || `${c}_${s.format()}`, n.coordinates = t.map((r) => r.map((o) => h.roundPrecision(o, 9))), n.shape = "polygon", O.info("[%s] draw polygon with %j", e == null ? void 0 : e.requestId, n);
1743
+ const i = h.convertToMonotonicLng2(t);
1744
+ return T.polygon([i], n);
1736
1745
  }
1737
1746
  /**
1738
1747
  * 基于turf画点,返回GeoJSON Feature<Point>
@@ -1742,10 +1751,10 @@ class W {
1742
1751
  * @returns
1743
1752
  */
1744
1753
  static drawPoint(t, e, n = {}) {
1745
- const s = (n == null ? void 0 : n.properties) ?? {}, o = x.utc();
1746
- s.id = (n == null ? void 0 : n.id) || o.valueOf().toString();
1747
- const r = "point";
1748
- return s.name = (n == null ? void 0 : n.name) || `${r}_${o.format()}`, s.shape = "point", O.info("[%s] draw point with %j", n == null ? void 0 : n.requestId, s), T.point([e, t], s);
1754
+ const s = (n == null ? void 0 : n.properties) ?? {}, c = x.utc();
1755
+ s.id = (n == null ? void 0 : n.id) || c.valueOf().toString();
1756
+ const i = "point";
1757
+ return s.name = (n == null ? void 0 : n.name) || `${i}_${c.format()}`, s.shape = "point", O.info("[%s] draw point with %j", n == null ? void 0 : n.requestId, s), T.point([e, t], s);
1749
1758
  }
1750
1759
  /**
1751
1760
  * 解析ORM GeoJSON Feature (圆), 返回FeatureCollection
@@ -1755,26 +1764,26 @@ class W {
1755
1764
  * 如果feature是圆,则返回圆的中心、端点、半径线 和 边线四个Feature
1756
1765
  */
1757
1766
  static parseCircle(t, e = {}) {
1758
- var s, o;
1767
+ var s, c;
1759
1768
  O.info("[%s] parse circle with %j", e == null ? void 0 : e.requestId, t.properties);
1760
1769
  const n = t.properties || {};
1761
1770
  if (n.shape == "circle") {
1762
- const r = x.utc();
1763
- n.id = (n == null ? void 0 : n.id) || r.valueOf().toString();
1764
- const i = n == null ? void 0 : n.id, c = ((s = n == null ? void 0 : n.center) == null ? void 0 : s.length) == 2 ? T.point(n.center) : T.centroid(t);
1771
+ const i = x.utc();
1772
+ n.id = (n == null ? void 0 : n.id) || i.valueOf().toString();
1773
+ 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);
1765
1774
  let a = "center";
1766
- c.properties = { id: `${a}_${i}`, parentId: i, name: a };
1775
+ o.properties = { id: `${a}_${r}`, parentId: r, name: a };
1767
1776
  const l = (n == null ? void 0 : n.units) || "nauticalmiles";
1768
1777
  let u = n == null ? void 0 : n.radius;
1769
1778
  if (!u) {
1770
1779
  const p = T.polygonToLine(t);
1771
- u = T.pointToLineDistance(c, p, { units: l });
1780
+ u = T.pointToLineDistance(o, p, { units: l });
1772
1781
  }
1773
1782
  a = "end";
1774
- const g = ((o = n == null ? void 0 : n.end) == null ? void 0 : o.length) == 2 ? T.point(n.end) : T.destination(c, u, 90, { units: l });
1775
- g.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l };
1776
- const d = T.lineString([c.geometry.coordinates, g.geometry.coordinates]);
1777
- return a = "edge", d.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l }, T.featureCollection([c, g, d, t]);
1783
+ const g = ((c = n == null ? void 0 : n.end) == null ? void 0 : c.length) == 2 ? T.point(n.end) : T.destination(o, u, 90, { units: l });
1784
+ g.properties = { id: `${a}_${r}`, parentId: r, name: a, radius: u, units: l };
1785
+ const d = T.lineString([o.geometry.coordinates, g.geometry.coordinates]);
1786
+ return a = "edge", d.properties = { id: `${a}_${r}`, parentId: r, name: a, radius: u, units: l }, T.featureCollection([o, g, d, t]);
1778
1787
  } else
1779
1788
  return O.warn("[%s] not a orm-std circle, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1780
1789
  }
@@ -1791,11 +1800,11 @@ class W {
1791
1800
  if (n.shape == "rect") {
1792
1801
  const s = x.utc();
1793
1802
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1794
- const o = n == null ? void 0 : n.id, r = t.geometry.coordinates[0], c = ["sw", "nw", "ne", "se"].map((a, l) => {
1795
- const u = T.point(r[l]);
1796
- return u.properties = { id: `${a}_${o}`, parentId: o, name: a }, u;
1803
+ const c = n == null ? void 0 : n.id, i = t.geometry.coordinates[0], o = ["sw", "nw", "ne", "se"].map((a, l) => {
1804
+ const u = T.point(i[l]);
1805
+ return u.properties = { id: `${a}_${c}`, parentId: c, name: a }, u;
1797
1806
  });
1798
- return T.featureCollection([...c, t]);
1807
+ return T.featureCollection([...o, t]);
1799
1808
  } else
1800
1809
  return O.warn("[%s] not a orm-std rect, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1801
1810
  }
@@ -1812,11 +1821,11 @@ class W {
1812
1821
  if (n.shape == "line") {
1813
1822
  const s = x.utc();
1814
1823
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1815
- const o = n == null ? void 0 : n.id, i = t.geometry.coordinates.map((c, a) => {
1816
- const l = `point_${a}`, u = T.point(c);
1817
- return u.properties = { id: `${l}_${o}`, parentId: o, name: l, index: a }, u;
1824
+ const c = n == null ? void 0 : n.id, r = t.geometry.coordinates.map((o, a) => {
1825
+ const l = `point_${a}`, u = T.point(o);
1826
+ return u.properties = { id: `${l}_${c}`, parentId: c, name: l, index: a }, u;
1818
1827
  });
1819
- return T.featureCollection([...i, t]);
1828
+ return T.featureCollection([...r, t]);
1820
1829
  } else
1821
1830
  return O.warn("[%s] not a orm-std line, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1822
1831
  }
@@ -1833,11 +1842,11 @@ class W {
1833
1842
  if (n.shape == "polygon") {
1834
1843
  const s = x.utc();
1835
1844
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1836
- const o = n == null ? void 0 : n.id, i = t.geometry.coordinates[0].map((c, a) => {
1837
- const l = T.point(c), u = `corner_${a}`;
1838
- return l.properties = { id: `${u}_${o}`, parentId: o, name: u, index: a }, l;
1845
+ const c = n == null ? void 0 : n.id, r = t.geometry.coordinates[0].map((o, a) => {
1846
+ const l = T.point(o), u = `corner_${a}`;
1847
+ return l.properties = { id: `${u}_${c}`, parentId: c, name: u, index: a }, l;
1839
1848
  });
1840
- return T.featureCollection([...i, t]);
1849
+ return T.featureCollection([...r, t]);
1841
1850
  } else
1842
1851
  return O.warn("[%s] not a orm-std polygon, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1843
1852
  }
@@ -1862,51 +1871,51 @@ class W {
1862
1871
  */
1863
1872
  static async _parseZipEntries(t) {
1864
1873
  var g;
1865
- const e = new Uint8Array(t), n = e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), s = new DataView(n), o = new Uint8Array(n), r = /* @__PURE__ */ new Map();
1866
- let i = -1;
1874
+ 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();
1875
+ let r = -1;
1867
1876
  for (let d = n.byteLength - 22; d >= 0; d--)
1868
1877
  if (s.getUint32(d, !0) === 101010256) {
1869
- i = d;
1878
+ r = d;
1870
1879
  break;
1871
1880
  }
1872
- if (i < 0)
1881
+ if (r < 0)
1873
1882
  throw new Error("Invalid ZIP file: EOCD not found");
1874
- s.getUint16(i + 8, !0);
1875
- const c = s.getUint32(i + 12, !0), a = s.getUint32(i + 16, !0);
1883
+ s.getUint16(r + 8, !0);
1884
+ const o = s.getUint32(r + 12, !0), a = s.getUint32(r + 16, !0);
1876
1885
  let l = a;
1877
- const u = a + c;
1886
+ const u = a + o;
1878
1887
  for (; l < u; ) {
1879
1888
  if (s.getUint32(l, !0) !== 33639248)
1880
1889
  throw new Error(`Invalid ZIP file: Central Directory signature mismatch at offset ${l}`);
1881
- const p = s.getUint16(l + 10, !0), f = s.getUint32(l + 20, !0), m = s.getUint16(l + 28, !0), S = s.getUint16(l + 30, !0), v = s.getUint16(l + 32, !0), P = s.getUint32(l + 42, !0), y = o.slice(l + 46, l + 46 + m), N = new TextDecoder().decode(y), $ = s.getUint16(P + 26, !0), E = s.getUint16(P + 28, !0), F = P + 30 + $ + E, R = o.slice(F, F + f);
1890
+ const p = s.getUint16(l + 10, !0), f = s.getUint32(l + 20, !0), m = s.getUint16(l + 28, !0), S = s.getUint16(l + 30, !0), v = s.getUint16(l + 32, !0), P = s.getUint32(l + 42, !0), y = c.slice(l + 46, l + 46 + m), M = new TextDecoder().decode(y), $ = s.getUint16(P + 26, !0), E = s.getUint16(P + 28, !0), F = P + 30 + $ + E, R = c.slice(F, F + f);
1882
1891
  if (p === 0)
1883
- r.set(N, R);
1892
+ i.set(M, R);
1884
1893
  else if (p === 8) {
1885
1894
  if (typeof DecompressionStream < "u") {
1886
- const D = new DecompressionStream("deflate-raw"), M = D.writable.getWriter(), A = D.readable.getReader();
1887
- M.write(R), M.close();
1895
+ const D = new DecompressionStream("deflate-raw"), N = D.writable.getWriter(), k = D.readable.getReader();
1896
+ N.write(R), N.close();
1888
1897
  const j = [];
1889
1898
  let U = 0;
1890
1899
  for (; ; ) {
1891
- const { done: w, value: I } = await A.read();
1900
+ const { done: w, value: I } = await k.read();
1892
1901
  if (w)
1893
1902
  break;
1894
1903
  j.push(I), U += I.length;
1895
1904
  }
1896
- const X = new Uint8Array(U);
1905
+ const Z = new Uint8Array(U);
1897
1906
  let B = 0;
1898
1907
  for (const w of j)
1899
- X.set(w, B), B += w.length;
1900
- r.set(N, X);
1908
+ Z.set(w, B), B += w.length;
1909
+ i.set(M, Z);
1901
1910
  } else if (typeof process < "u" && ((g = process.versions) != null && g.node))
1902
1911
  try {
1903
- r.set(N, W._inflateRawSync(R));
1912
+ i.set(M, W._inflateRawSync(R));
1904
1913
  } catch {
1905
1914
  }
1906
1915
  }
1907
1916
  l += 46 + m + S + v;
1908
1917
  }
1909
- return r;
1918
+ return i;
1910
1919
  }
1911
1920
  // ---------------------------------------------------------------------------
1912
1921
  // KMZ / ZIP → GeoJSON
@@ -1918,24 +1927,24 @@ class W {
1918
1927
  * @returns
1919
1928
  */
1920
1929
  static async convertKML2GeoJSON(t, e = {}) {
1921
- var i, c;
1930
+ var r, o;
1922
1931
  O.info("[%s] convert kml to geojson", e == null ? void 0 : e.requestId);
1923
- const s = H().parseFromString(t, "application/xml"), o = Array.from(s.querySelectorAll("Placemark")), r = [];
1924
- for (const a of o) {
1932
+ const s = H().parseFromString(t, "application/xml"), c = Array.from(s.querySelectorAll("Placemark")), i = [];
1933
+ for (const a of c) {
1925
1934
  const l = {}, u = Array.from(a.querySelectorAll("ExtendedData > Data"));
1926
1935
  for (const y of u) {
1927
- const N = y.getAttribute("name"), $ = (c = (i = y.querySelector("value")) == null ? void 0 : i.textContent) == null ? void 0 : c.trim();
1928
- N && $ !== void 0 && $ !== null && (l[N] = $);
1936
+ const M = y.getAttribute("name"), $ = (o = (r = y.querySelector("value")) == null ? void 0 : r.textContent) == null ? void 0 : o.trim();
1937
+ M && $ !== void 0 && $ !== null && (l[M] = $);
1929
1938
  }
1930
- const g = x.utc(), d = Object.keys(l).find((y) => y.toLowerCase().indexOf("name") !== -1), p = d ? l[d] : void 0, f = `${g.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, m = (y) => y.trim().split(/[\s\n]+/).filter((N) => N.length > 0).map((N) => {
1931
- const $ = N.split(",").map(Number);
1939
+ const g = x.utc(), d = Object.keys(l).find((y) => y.toLowerCase().indexOf("name") !== -1), p = d ? l[d] : void 0, f = `${g.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, m = (y) => y.trim().split(/[\s\n]+/).filter((M) => M.length > 0).map((M) => {
1940
+ const $ = M.split(",").map(Number);
1932
1941
  return [$[0], $[1]];
1933
1942
  }), S = a.querySelector("LineString > coordinates");
1934
1943
  if (S) {
1935
1944
  const y = m(S.textContent || "");
1936
1945
  if (y.length >= 2) {
1937
- const N = T.lineString(y, { ...l, shape: "line", id: f, name: p });
1938
- r.push(N);
1946
+ const M = T.lineString(y, { ...l, shape: "line", id: f, name: p });
1947
+ i.push(M);
1939
1948
  }
1940
1949
  continue;
1941
1950
  }
@@ -1943,8 +1952,8 @@ class W {
1943
1952
  if (v) {
1944
1953
  const y = m(v.textContent || "");
1945
1954
  if (y.length >= 4) {
1946
- const N = y[0][0] === y[y.length - 1][0] && y[0][1] === y[y.length - 1][1] ? y : [...y, y[0]], $ = T.polygon([N], { ...l, shape: "polygon", id: f, name: p });
1947
- r.push($);
1955
+ const M = y[0][0] === y[y.length - 1][0] && y[0][1] === y[y.length - 1][1] ? y : [...y, y[0]], $ = T.polygon([M], { ...l, shape: "polygon", id: f, name: p });
1956
+ i.push($);
1948
1957
  }
1949
1958
  continue;
1950
1959
  }
@@ -1952,13 +1961,13 @@ class W {
1952
1961
  if (P) {
1953
1962
  const y = m(P.textContent || "");
1954
1963
  if (y.length >= 1) {
1955
- const N = T.point(y[0], { ...l, shape: "point", id: f, name: p });
1956
- r.push(N);
1964
+ const M = T.point(y[0], { ...l, shape: "point", id: f, name: p });
1965
+ i.push(M);
1957
1966
  }
1958
1967
  continue;
1959
1968
  }
1960
1969
  }
1961
- return T.featureCollection(r);
1970
+ return T.featureCollection(i);
1962
1971
  }
1963
1972
  /**
1964
1973
  * 将 KMZ(ZIP 内含 doc.kml 或首个 .kml 文件)异步转换为 GeoJSON。
@@ -1970,13 +1979,13 @@ class W {
1970
1979
  * @param options
1971
1980
  */
1972
1981
  static async convertKMZ2GeoJSON(t, e = {}) {
1973
- var r;
1982
+ var i;
1974
1983
  O.info("[%s] convert kmz to geojson (async)", e == null ? void 0 : e.requestId), typeof Buffer < "u" && Buffer.isBuffer(t) && (t = W.toArrayBuffer(t));
1975
- 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]);
1984
+ 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]);
1976
1985
  if (!s)
1977
1986
  return O.warn("[%s] no .kml file found in kmz", e == null ? void 0 : e.requestId), T.featureCollection([]);
1978
- const o = new TextDecoder().decode(s);
1979
- return W.convertKML2GeoJSON(o, e);
1987
+ const c = new TextDecoder().decode(s);
1988
+ return W.convertKML2GeoJSON(c, e);
1980
1989
  }
1981
1990
  /**
1982
1991
  * 将 ZIP 文件中所有 .kml 文件合并转换为一个 GeoJSON FeatureCollection(异步)。
@@ -1990,11 +1999,11 @@ class W {
1990
1999
  static async convertZIP2GeoJSON(t, e = {}) {
1991
2000
  O.info("[%s] convert zip to geojson (async)", e == null ? void 0 : e.requestId), typeof Buffer < "u" && Buffer.isBuffer(t) && (t = W.toArrayBuffer(t));
1992
2001
  const n = await W._parseZipEntries(t), s = [];
1993
- for (const [o, r] of n) {
1994
- if (!o.toLowerCase().endsWith(".kml"))
2002
+ for (const [c, i] of n) {
2003
+ if (!c.toLowerCase().endsWith(".kml"))
1995
2004
  continue;
1996
- const i = new TextDecoder().decode(r), c = await W.convertKML2GeoJSON(i, e);
1997
- s.push(...c.features);
2005
+ const r = new TextDecoder().decode(i), o = await W.convertKML2GeoJSON(r, e);
2006
+ s.push(...o.features);
1998
2007
  }
1999
2008
  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);
2000
2009
  }
@@ -2012,7 +2021,7 @@ class W {
2012
2021
  typeof Buffer < "u" && Buffer.isBuffer(t) && (t = W.toArrayBuffer(t));
2013
2022
  const n = await J(t);
2014
2023
  if (Array.isArray(n)) {
2015
- const s = n.flatMap((c) => c.features || []), o = x.utc(), r = (e == null ? void 0 : e.id) || o.valueOf().toString(), i = {
2024
+ const s = n.flatMap((o) => o.features || []), c = x.utc(), i = (e == null ? void 0 : e.id) || c.valueOf().toString(), r = {
2016
2025
  Point: "point",
2017
2026
  MultiPoint: "point",
2018
2027
  LineString: "line",
@@ -2020,12 +2029,12 @@ class W {
2020
2029
  Polygon: "polygon",
2021
2030
  MultiPolygon: "polygon"
2022
2031
  };
2023
- return s.forEach((c, a) => {
2032
+ return s.forEach((o, a) => {
2024
2033
  var p;
2025
- const l = ((p = c.geometry) == null ? void 0 : p.type) || "", u = i[l] || l.toLowerCase();
2026
- c.properties = c.properties || {}, c.properties.shape = u, c.properties.parentId = r, c.properties.id = `${r}_${a}`;
2027
- const g = Object.keys(c.properties).find((f) => f.toLowerCase().indexOf("name") !== -1), d = g ? c.properties[g] : void 0;
2028
- c.properties.name = d || `${u}_${o.format()}_${a}`;
2034
+ const l = ((p = o.geometry) == null ? void 0 : p.type) || "", u = r[l] || l.toLowerCase();
2035
+ o.properties = o.properties || {}, o.properties.shape = u, o.properties.parentId = i, o.properties.id = `${i}_${a}`;
2036
+ const g = Object.keys(o.properties).find((f) => f.toLowerCase().indexOf("name") !== -1), d = g ? o.properties[g] : void 0;
2037
+ o.properties.name = d || `${u}_${c.format()}_${a}`;
2029
2038
  }), T.featureCollection(s);
2030
2039
  }
2031
2040
  return n;
@@ -2039,5 +2048,5 @@ export {
2039
2048
  W as GeoJsonHelper,
2040
2049
  b as LaneHelper,
2041
2050
  h as LngLatHelper,
2042
- it as TropicalHelper
2051
+ rt as TropicalHelper
2043
2052
  };