@idm-plugin/geo 2.3.8 → 2.4.0

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