@idm-plugin/geo 2.2.4 → 2.2.5

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
@@ -10,9 +10,9 @@ class d {
10
10
  * @param lng
11
11
  * @param lat
12
12
  */
13
- static guessTimeZoneOffset(e, t) {
14
- e = d.convertToStdLng(e);
15
- const n = V(t, e), s = b().tz(n).utcOffset();
13
+ static guessTimeZoneOffset(t, e) {
14
+ t = d.convertToStdLng(t);
15
+ const n = V(e, t), s = b().tz(n).utcOffset();
16
16
  return d.roundPrecision(s / 60, 1);
17
17
  }
18
18
  /**
@@ -20,29 +20,29 @@ class d {
20
20
  * @param offset => 8.5
21
21
  * @return timezone => +08:30
22
22
  */
23
- static prettyTimeZoneOffset(e) {
24
- let t = Math.floor(Math.abs(e)), n = Math.round((Math.abs(e) - t) * 60);
25
- return n = n > 9 ? n : `0${n}`, t = t > 9 ? t : `0${t}`, e > 0 ? `+${t}:${n}` : `-${t}:${n}`;
23
+ static prettyTimeZoneOffset(t) {
24
+ let e = Math.floor(Math.abs(t)), n = Math.round((Math.abs(t) - e) * 60);
25
+ return n = n > 9 ? n : `0${n}`, e = e > 9 ? e : `0${e}`, t > 0 ? `+${e}:${n}` : `-${e}:${n}`;
26
26
  }
27
27
  /**
28
28
  * @param lng
29
29
  * @param precision 3位小数在百米级,4位小数在十米级, 5位小数在米级
30
30
  * @param format
31
31
  */
32
- static lng2pretty(e, t = 6, n = "H°M′") {
33
- e = d.convertToStdLng(e, t);
32
+ static lng2pretty(t, e = 6, n = "H°M′") {
33
+ t = d.convertToStdLng(t, e);
34
34
  let s = "E";
35
- e < 0 && (s = "W"), e = Math.abs(e), n = n.toUpperCase();
36
- let o = e * 3600, i, r, c, a, l, u;
37
- i = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - i, r = d.padNumber(i, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = d.roundPrecision(c, t).toString().padStart(2, "0") : a = d.padNumber(c, 2, 3), o = o - c * 60), l = o / 3600, n.indexOf("M") !== -1 ? u = d.roundPrecision(l, t).toString().padStart(3, "0") : u = d.padNumber(l, 3, 6), Number(r) >= 60 && (a = Number(a) + 1, r = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
38
- const f = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
35
+ t < 0 && (s = "W"), t = Math.abs(t), n = n.toUpperCase();
36
+ let o = t * 3600, r, i, c, a, l, u;
37
+ r = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - r, i = d.padNumber(r, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = d.roundPrecision(c, e).toString().padStart(2, "0") : a = d.padNumber(c, 2, 3), o = o - c * 60), l = o / 3600, n.indexOf("M") !== -1 ? u = d.roundPrecision(l, e).toString().padStart(3, "0") : u = d.padNumber(l, 3, 6), Number(i) >= 60 && (a = Number(a) + 1, i = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
38
+ const f = `${n.replace(/S+/gi, i).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
39
39
  return {
40
40
  direction: s,
41
- degree: d.roundPrecision(l, t),
42
- minute: d.roundPrecision(c, t),
43
- second: d.roundPrecision(i, t),
41
+ degree: d.roundPrecision(l, e),
42
+ minute: d.roundPrecision(c, e),
43
+ second: d.roundPrecision(r, e),
44
44
  pretty: f,
45
- S: r,
45
+ S: i,
46
46
  M: a,
47
47
  H: u
48
48
  };
@@ -53,104 +53,104 @@ class d {
53
53
  * @param precision 精确度
54
54
  * @param format 格式化
55
55
  */
56
- static lat2pretty(e, t = 6, n = "H°M′") {
57
- e = e % 180;
56
+ static lat2pretty(t, e = 6, n = "H°M′") {
57
+ t = t % 180;
58
58
  let s = "N";
59
- e < 0 && (s = "S"), e = Math.abs(e), n = n.toUpperCase();
60
- let o = e * 3600, i, r, c, a, l, u;
61
- i = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - i, r = d.padNumber(i, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = d.roundPrecision(c, t).toString().padStart(2, "0") : a = d.padNumber(c, 2, 3), o = o - c * 60), l = o / 3600, n.indexOf("M") !== -1 ? u = d.roundPrecision(l, t).toString().padStart(2, "0") : u = d.padNumber(l, 2, 6), Number(r) >= 60 && (a = Number(a) + 1, r = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
62
- const f = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
59
+ t < 0 && (s = "S"), t = Math.abs(t), n = n.toUpperCase();
60
+ let o = t * 3600, r, i, c, a, l, u;
61
+ r = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - r, i = d.padNumber(r, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = d.roundPrecision(c, e).toString().padStart(2, "0") : a = d.padNumber(c, 2, 3), o = o - c * 60), l = o / 3600, n.indexOf("M") !== -1 ? u = d.roundPrecision(l, e).toString().padStart(2, "0") : u = d.padNumber(l, 2, 6), Number(i) >= 60 && (a = Number(a) + 1, i = 0), Number(a) >= 60 && (u = Number(u) + 1, a = 0);
62
+ const f = `${n.replace(/S+/gi, i).replace(/M+/gi, a).replace(/H+/gi, u)}${s}`;
63
63
  return {
64
64
  direction: s,
65
- degree: d.roundPrecision(l, t),
66
- minute: d.roundPrecision(c, t),
67
- second: d.roundPrecision(i, t),
65
+ degree: d.roundPrecision(l, e),
66
+ minute: d.roundPrecision(c, e),
67
+ second: d.roundPrecision(r, e),
68
68
  pretty: f,
69
- S: r,
69
+ S: i,
70
70
  M: a,
71
71
  H: u
72
72
  };
73
73
  }
74
- static str2Lng(e, t = 6) {
74
+ static str2Lng(t, e = 6) {
75
75
  let n;
76
- if (isNaN(e)) {
77
- e = d.strReplace(e, "LNG");
78
- const s = e[e.length - 1].toUpperCase();
79
- e = e.substring(0, e.length - 1).trim();
80
- const o = e.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
81
- let [i, r, c] = o;
82
- if (r = r || 0, r = r > 60 ? r / Math.pow(10, String(r).length - 2) : r, c = c || 0, c = c > 60 ? c / Math.pow(10, String(c).length - 2) : c, i > 360 && !r) {
83
- const a = this.roundPrecision(i / 100, 0);
84
- r = i - a * 100, i = a;
76
+ if (isNaN(t)) {
77
+ t = d.strReplace(t, "LNG");
78
+ const s = t[t.length - 1].toUpperCase();
79
+ t = t.substring(0, t.length - 1).trim();
80
+ const o = t.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
81
+ let [r, i, c] = o;
82
+ if (i = i || 0, i = i > 60 ? i / Math.pow(10, String(i).length - 2) : i, c = c || 0, c = c > 60 ? c / Math.pow(10, String(c).length - 2) : c, r > 360 && !i) {
83
+ const a = this.roundPrecision(r / 100, 0);
84
+ i = r - a * 100, r = a;
85
85
  }
86
- n = i + r / 60 + c / 3600, s === "W" && (n = n * -1);
86
+ n = r + i / 60 + c / 3600, s === "W" && (n = n * -1);
87
87
  } else
88
- n = Number(e);
89
- return d.convertToStdLng(n, t);
88
+ n = Number(t);
89
+ return d.convertToStdLng(n, e);
90
90
  }
91
- static str2Lat(e, t = 6) {
91
+ static str2Lat(t, e = 6) {
92
92
  let n;
93
- if (isNaN(e)) {
94
- e = d.strReplace(e, "LAT");
95
- const s = e[e.length - 1].toUpperCase();
96
- e = e.substring(0, e.length - 1).trim();
97
- const o = e.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
98
- let [i, r, c] = o;
99
- if (c = c || 0, r = r || 0, r = r > 60 ? r / Math.pow(10, String(r).length - 2) : r, c = c > 60 ? c / Math.pow(10, String(c).length - 2) : c, i > 90 && !r) {
100
- const a = this.roundPrecision(i / 100, 0);
101
- r = i - a * 100, i = a;
93
+ if (isNaN(t)) {
94
+ t = d.strReplace(t, "LAT");
95
+ const s = t[t.length - 1].toUpperCase();
96
+ t = t.substring(0, t.length - 1).trim();
97
+ const o = t.split(" ").filter((a) => a !== "").map((a) => Math.abs(Number(a)));
98
+ let [r, i, c] = o;
99
+ if (c = c || 0, i = i || 0, i = i > 60 ? i / Math.pow(10, String(i).length - 2) : i, c = c > 60 ? c / Math.pow(10, String(c).length - 2) : c, r > 90 && !i) {
100
+ const a = this.roundPrecision(r / 100, 0);
101
+ i = r - a * 100, r = a;
102
102
  }
103
- if (n = i + r / 60 + c / 3600, n > 90)
104
- throw new Error(`latitude out of range: ${e}${s}`);
103
+ if (n = r + i / 60 + c / 3600, n > 90)
104
+ throw new Error(`latitude out of range: ${t}${s}`);
105
105
  s === "S" && (n = n * -1);
106
106
  } else
107
- n = Number(e);
108
- return d.roundPrecision(n, t);
107
+ n = Number(t);
108
+ return d.roundPrecision(n, e);
109
109
  }
110
- static str2LngOrLat(e, t = 6, n = "LAT") {
111
- e = d.strReplace(e, n);
112
- const s = e[e.length - 1].toUpperCase();
110
+ static str2LngOrLat(t, e = 6, n = "LAT") {
111
+ t = d.strReplace(t, n);
112
+ const s = t[t.length - 1].toUpperCase();
113
113
  return ["N", "S"].includes(s) ? {
114
- lat: d.str2Lat(e, t)
114
+ lat: d.str2Lat(t, e)
115
115
  } : {
116
- lng: d.str2Lng(e, t)
116
+ lng: d.str2Lng(t, e)
117
117
  };
118
118
  }
119
- static convertToStdLng(e, t = 6) {
120
- return e > 180 ? (e = e % 360, e = e > 180 ? e - 360 : e) : e < -180 && (e = e % 360, e = e < -180 ? e + 360 : e), d.roundPrecision(e, t);
119
+ static convertToStdLng(t, e = 6) {
120
+ return t > 180 ? (t = t % 360, t = t > 180 ? t - 360 : t) : t < -180 && (t = t % 360, t = t < -180 ? t + 360 : t), d.roundPrecision(t, e);
121
121
  }
122
- static roundPrecision(e, t = 6) {
123
- const n = Number("1".padEnd(t + 1, "0"));
124
- return Math.round(e * n) / n;
122
+ static roundPrecision(t, e = 6) {
123
+ const n = Number("1".padEnd(e + 1, "0"));
124
+ return Math.round(t * n) / n;
125
125
  }
126
126
  /**
127
127
  * 转换为按经度单调增/减的坐标数组
128
128
  * @param coordinates
129
129
  */
130
- static convertToMonotonicLng2(e) {
131
- for (let t = 1; t < e.length; t++)
132
- e[t][0] += Math.round((e[t - 1][0] - e[t][0]) / 360) * 360;
133
- return e;
130
+ static convertToMonotonicLng2(t) {
131
+ for (let e = 1; e < t.length; e++)
132
+ t[e][0] += Math.round((t[e - 1][0] - t[e][0]) / 360) * 360;
133
+ return t;
134
134
  }
135
135
  /**
136
136
  * 转移为按经度单调增/减的坐标数组
137
137
  * @param coordinates
138
138
  */
139
- static convertToMonotonicLng(e) {
140
- for (let t = 1; t < e.length; t++)
141
- e[t].lng += Math.round((e[t - 1].lng - e[t].lng) / 360) * 360;
142
- return e;
139
+ static convertToMonotonicLng(t) {
140
+ for (let e = 1; e < t.length; e++)
141
+ t[e].lng += Math.round((t[e - 1].lng - t[e].lng) / 360) * 360;
142
+ return t;
143
143
  }
144
- static strReplace(e, t = "LAT") {
145
- e = e.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g, "$1 $2").replace(/([0-9]+)-([0-9]+\.[0-9]+)/g, "$1 $2").replace(/°/, " ").replace(/(\d+)-(\d?)/g, "$1 $2").replace(/'/g, " ").replace(/′/g, " ").replace(/"/g, " ").replace(/∼/g, " ").replace(/°/g, " ").replace(/,/g, ".").replace(/^ /g, "").replace(/ $/g, "").trim();
146
- const n = e[e.length - 1].toUpperCase();
144
+ static strReplace(t, e = "LAT") {
145
+ t = t.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g, "$1 $2").replace(/([0-9]+)-([0-9]+\.[0-9]+)/g, "$1 $2").replace(/°/, " ").replace(/(\d+)-(\d?)/g, "$1 $2").replace(/'/g, " ").replace(/′/g, " ").replace(/"/g, " ").replace(/∼/g, " ").replace(/°/g, " ").replace(/,/g, ".").replace(/^ /g, "").replace(/ $/g, "").trim();
146
+ const n = t[t.length - 1].toUpperCase();
147
147
  if (!["N", "S", "E", "W"].includes(n)) {
148
- const s = e, o = Number(s.split(" ")[0]);
148
+ const s = t, o = Number(s.split(" ")[0]);
149
149
  if (isNaN(o))
150
- throw new Error(`invalid Lat/Lng: ${e}`);
151
- o >= 90 ? e = `${s}E` : o <= -90 ? e = `${s}W` : ["LAN", "LNG"].includes(t == null ? void 0 : t.toUpperCase()) ? e = `${s}${o > 0 ? "E" : "W"}` : e = `${s}${o > 0 ? "N" : "S"}`;
150
+ throw new Error(`invalid Lat/Lng: ${t}`);
151
+ o >= 90 ? t = `${s}E` : o <= -90 ? t = `${s}W` : ["LAN", "LNG"].includes(e == null ? void 0 : e.toUpperCase()) ? t = `${s}${o > 0 ? "E" : "W"}` : t = `${s}${o > 0 ? "N" : "S"}`;
152
152
  }
153
- return e;
153
+ return t;
154
154
  }
155
155
  /**
156
156
  * 数据格式
@@ -159,25 +159,25 @@ class d {
159
159
  * @param intPrecision 整数位数
160
160
  * @param dcmPrecision 小数位数
161
161
  */
162
- static padNumber(e, t = 2, n = 2) {
163
- const s = d.roundPrecision(e - Math.trunc(e), n), o = s >= 1 ? Math.trunc(e + 1).toString().padStart(t, "0") : Math.trunc(e).toString().padStart(t, "0");
162
+ static padNumber(t, e = 2, n = 2) {
163
+ const s = d.roundPrecision(t - Math.trunc(t), n), o = s >= 1 ? Math.trunc(t + 1).toString().padStart(e, "0") : Math.trunc(t).toString().padStart(e, "0");
164
164
  return s >= 1 ? o : n > 0 ? `${o}.${Math.trunc(s * Math.pow(10, n)).toString().padStart(n, "0")}` : o;
165
165
  }
166
166
  }
167
167
  class K {
168
- static json2Str(e) {
169
- const t = e.type ? e.type[0].toUpperCase() : "A";
170
- return `${e.lat}|${e.lng}|${e.positionTime}|${e.sog}|${e.cog}|${e.hdg}|${e.draught}|${t}|${JSON.stringify(e.meteo || {})}|${e.vendor}|${e.deleted}`;
168
+ static json2Str(t) {
169
+ const e = t.type ? t.type[0].toUpperCase() : "A";
170
+ return `${t.lat}|${t.lng}|${t.positionTime}|${t.sog}|${t.cog}|${t.hdg}|${t.draught}|${e}|${JSON.stringify(t.meteo || {})}|${t.vendor}|${t.deleted}`;
171
171
  }
172
- static str2Json(e) {
173
- const [t, n, s, o, i, r, c, a, l, u, f] = e.split("|");
172
+ static str2Json(t) {
173
+ const [e, n, s, o, r, i, c, a, l, u, f] = t.split("|");
174
174
  return {
175
- lat: Number(t),
175
+ lat: Number(e),
176
176
  lng: Number(n),
177
177
  positionTime: Number(s),
178
178
  sog: Number(o),
179
- cog: Number(i),
180
- hdg: Number(r),
179
+ cog: Number(r),
180
+ hdg: Number(i),
181
181
  //@ts-ignore
182
182
  draught: isNaN(c) ? null : Number(c),
183
183
  type: a,
@@ -187,50 +187,50 @@ class K {
187
187
  deleted: f === "true"
188
188
  };
189
189
  }
190
- static inspectStoppages(e, t = 1, n = !0) {
191
- const s = e.at(0).positionTime < e.at(-1).positionTime;
192
- s || e.sort((c, a) => c.positionTime - a.positionTime);
190
+ static inspectStoppages(t, e = 1, n = !0) {
191
+ const s = t.at(0).positionTime < t.at(-1).positionTime;
192
+ s || t.sort((c, a) => c.positionTime - a.positionTime);
193
193
  const o = [];
194
- let i, r;
195
- for (let c = 0; c < e.length - 1; c++) {
196
- const a = e[c];
194
+ let r, i;
195
+ for (let c = 0; c < t.length - 1; c++) {
196
+ const a = t[c];
197
197
  if (!(n && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(a.type))) {
198
- for (let l = c + 1; l < e.length; l++) {
199
- const u = e[l - 1], f = e[l];
198
+ for (let l = c + 1; l < t.length; l++) {
199
+ const u = t[l - 1], f = t[l];
200
200
  if (n && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(a.type))
201
201
  continue;
202
202
  const h = f.positionTime - u.positionTime;
203
- if (v.calculateDistance(f, u, !0, 4) / (h / 3600) < t)
204
- i || (i = a), l === e.length - 1 && (r = f, c = l);
203
+ if (v.calculateDistance(f, u, !0, 4) / (h / 3600) < e)
204
+ r || (r = a), l === t.length - 1 && (i = f, c = l);
205
205
  else {
206
- i && (r = e[l - 1], c = l);
206
+ r && (i = t[l - 1], c = l);
207
207
  break;
208
208
  }
209
209
  }
210
- if ((r == null ? void 0 : r.positionTime) > (i == null ? void 0 : i.positionTime) && i) {
210
+ if ((i == null ? void 0 : i.positionTime) > (r == null ? void 0 : r.positionTime) && r) {
211
211
  const l = {
212
212
  start: {
213
- lat: i.lat,
214
- lng: i.lng,
215
- sog: i.sog,
216
- positionTime: i.positionTime,
217
- utc: b.unix(i.positionTime).utc().format()
218
- },
219
- end: {
220
213
  lat: r.lat,
221
214
  lng: r.lng,
222
215
  sog: r.sog,
223
216
  positionTime: r.positionTime,
224
217
  utc: b.unix(r.positionTime).utc().format()
225
218
  },
226
- duration: r.positionTime - i.positionTime
227
- }, u = e.filter((h) => h.positionTime >= l.start.positionTime && h.positionTime <= l.end.positionTime), f = v.divideAccordingToLng(u);
219
+ end: {
220
+ lat: i.lat,
221
+ lng: i.lng,
222
+ sog: i.sog,
223
+ positionTime: i.positionTime,
224
+ utc: b.unix(i.positionTime).utc().format()
225
+ },
226
+ duration: i.positionTime - r.positionTime
227
+ }, u = t.filter((h) => h.positionTime >= l.start.positionTime && h.positionTime <= l.end.positionTime), f = v.divideAccordingToLng(u);
228
228
  l.distance = v.calculateRouteDistance(f), l.hours = Math.round(l.duration / 3600 * 10) / 10, l.avgSog = Math.round(l.distance / l.hours * 10) / 10, o.push(l);
229
229
  }
230
- i = void 0, r = void 0;
230
+ r = void 0, i = void 0;
231
231
  }
232
232
  }
233
- return s || e.sort((c, a) => a.positionTime - c.positionTime), o;
233
+ return s || t.sort((c, a) => a.positionTime - c.positionTime), o;
234
234
  }
235
235
  /**
236
236
  * 计算轨迹摘要
@@ -238,17 +238,17 @@ class K {
238
238
  * @param stm
239
239
  * @param etm
240
240
  */
241
- static inspectSummary(e, t, n) {
242
- const s = b(t), o = b(n), i = e.filter((l) => l.positionTime >= s.unix() && l.positionTime <= o.unix());
243
- let r = 0, c = 0;
244
- if (i.length > 1)
245
- for (let l = 0; l < i.length - 1; l++) {
246
- const u = i[l], f = i[l + 1];
247
- r += v.calculateDistance(u, f, !0, 4), c += Math.abs(f.positionTime - u.positionTime);
241
+ static inspectSummary(t, e, n) {
242
+ const s = b(e), o = b(n), r = t.filter((l) => l.positionTime >= s.unix() && l.positionTime <= o.unix());
243
+ let i = 0, c = 0;
244
+ if (r.length > 1)
245
+ for (let l = 0; l < r.length - 1; l++) {
246
+ const u = r[l], f = r[l + 1];
247
+ i += v.calculateDistance(u, f, !0, 4), c += Math.abs(f.positionTime - u.positionTime);
248
248
  }
249
- r = Math.round(r * 100) / 100, c = Math.round(c / 3600 * 100) / 100;
250
- const a = c ? Math.round(r / c * 100) / 100 : 0;
251
- return { distance: r, interval: c, avgSpd: a };
249
+ i = Math.round(i * 100) / 100, c = Math.round(c / 3600 * 100) / 100;
250
+ const a = c ? Math.round(i / c * 100) / 100 : 0;
251
+ return { distance: i, interval: c, avgSpd: a };
252
252
  }
253
253
  }
254
254
  let X;
@@ -259,48 +259,48 @@ try {
259
259
  }
260
260
  const Q = (() => {
261
261
  const C = new Uint32Array(256);
262
- for (let e = 0; e < 256; e++) {
263
- let t = e;
262
+ for (let t = 0; t < 256; t++) {
263
+ let e = t;
264
264
  for (let n = 0; n < 8; n++)
265
- t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
266
- C[e] = t;
265
+ e = e & 1 ? 3988292384 ^ e >>> 1 : e >>> 1;
266
+ C[t] = e;
267
267
  }
268
268
  return C;
269
269
  })();
270
270
  function Y(C) {
271
- let e = 4294967295;
272
- for (let t = 0; t < C.length; t++)
273
- e = Q[(e ^ C[t]) & 255] ^ e >>> 8;
274
- return (e ^ 4294967295) >>> 0;
271
+ let t = 4294967295;
272
+ for (let e = 0; e < C.length; e++)
273
+ t = Q[(t ^ C[e]) & 255] ^ t >>> 8;
274
+ return (t ^ 4294967295) >>> 0;
275
275
  }
276
276
  function _(C) {
277
- const e = new TextEncoder(), t = [], n = [];
277
+ const t = new TextEncoder(), e = [], n = [];
278
278
  let s = 0;
279
279
  for (const h of C) {
280
- const g = e.encode(h.name), m = Y(h.data), p = new Uint8Array(30 + g.length), S = new DataView(p.buffer);
281
- S.setUint32(0, 67324752, !0), S.setUint16(4, 20, !0), S.setUint16(8, 0, !0), S.setUint32(14, m, !0), S.setUint32(18, h.data.length, !0), S.setUint32(22, h.data.length, !0), S.setUint16(26, g.length, !0), p.set(g, 30), t.push({ nameBytes: g, data: h.data, crc: m, offset: s }), s += p.length + h.data.length, n.push(p, h.data);
280
+ const g = t.encode(h.name), m = Y(h.data), p = new Uint8Array(30 + g.length), S = new DataView(p.buffer);
281
+ S.setUint32(0, 67324752, !0), S.setUint16(4, 20, !0), S.setUint16(8, 0, !0), S.setUint32(14, m, !0), S.setUint32(18, h.data.length, !0), S.setUint32(22, h.data.length, !0), S.setUint16(26, g.length, !0), p.set(g, 30), e.push({ nameBytes: g, data: h.data, crc: m, offset: s }), s += p.length + h.data.length, n.push(p, h.data);
282
282
  }
283
- const o = s, i = [];
284
- let r = 0;
285
- for (const h of t) {
283
+ const o = s, r = [];
284
+ let i = 0;
285
+ for (const h of e) {
286
286
  const g = new Uint8Array(46 + h.nameBytes.length), m = new DataView(g.buffer);
287
- m.setUint32(0, 33639248, !0), m.setUint16(4, 20, !0), m.setUint16(6, 20, !0), m.setUint16(10, 0, !0), m.setUint32(16, h.crc, !0), m.setUint32(20, h.data.length, !0), m.setUint32(24, h.data.length, !0), m.setUint16(28, h.nameBytes.length, !0), m.setUint32(42, h.offset, !0), g.set(h.nameBytes, 46), r += g.length, i.push(g);
287
+ m.setUint32(0, 33639248, !0), m.setUint16(4, 20, !0), m.setUint16(6, 20, !0), m.setUint16(10, 0, !0), m.setUint32(16, h.crc, !0), m.setUint32(20, h.data.length, !0), m.setUint32(24, h.data.length, !0), m.setUint16(28, h.nameBytes.length, !0), m.setUint32(42, h.offset, !0), g.set(h.nameBytes, 46), i += g.length, r.push(g);
288
288
  }
289
289
  const c = new Uint8Array(22), a = new DataView(c.buffer);
290
- a.setUint32(0, 101010256, !0), a.setUint16(8, t.length, !0), a.setUint16(10, t.length, !0), a.setUint32(12, r, !0), a.setUint32(16, o, !0);
291
- const l = n.reduce((h, g) => h + g.length, 0) + r + 22, u = new Uint8Array(l);
290
+ a.setUint32(0, 101010256, !0), a.setUint16(8, e.length, !0), a.setUint16(10, e.length, !0), a.setUint32(12, i, !0), a.setUint32(16, o, !0);
291
+ const l = n.reduce((h, g) => h + g.length, 0) + i + 22, u = new Uint8Array(l);
292
292
  let f = 0;
293
293
  for (const h of n)
294
294
  u.set(h, f), f += h.length;
295
- for (const h of i)
295
+ for (const h of r)
296
296
  u.set(h, f), f += h.length;
297
297
  return u.set(c, f), u;
298
298
  }
299
299
  function z(C) {
300
- let e = "", t = C;
301
- for (; t >= 0; )
302
- e = String.fromCharCode(65 + t % 26) + e, t = Math.floor(t / 26) - 1;
303
- return e;
300
+ let t = "", e = C;
301
+ for (; e >= 0; )
302
+ t = String.fromCharCode(65 + e % 26) + t, e = Math.floor(e / 26) - 1;
303
+ return t;
304
304
  }
305
305
  class v {
306
306
  /**
@@ -311,13 +311,13 @@ class v {
311
311
  * @param precision
312
312
  * @returns {number} 单位度
313
313
  */
314
- static calculateBearing(e, t, n = !0, s = 4) {
314
+ static calculateBearing(t, e, n = !0, s = 4) {
315
315
  const o = T.points([
316
- [e.lng, e.lat],
317
- [t.lng, t.lat]
316
+ [t.lng, t.lat],
317
+ [e.lng, e.lat]
318
318
  ]);
319
- let i;
320
- return n ? i = T.rhumbBearing(o.features[0], o.features[1]) : i = T.bearing(o.features[0], o.features[1]), i < 0 && (i += 360), d.roundPrecision(i, s);
319
+ let r;
320
+ return n ? r = T.rhumbBearing(o.features[0], o.features[1]) : r = T.bearing(o.features[0], o.features[1]), r < 0 && (r += 360), d.roundPrecision(r, s);
321
321
  }
322
322
  /**
323
323
  * 计算两点间距离
@@ -328,14 +328,14 @@ class v {
328
328
  * @param units 单位,默认 nm(海里)
329
329
  * @returns {number}
330
330
  */
331
- static calculateDistance(e, t, n = !0, s = 4, o = "nauticalmiles") {
332
- e = { ...e }, t = { ...t }, e.lng = d.convertToStdLng(e.lng, s), t.lng = d.convertToStdLng(t.lng, s);
333
- const i = T.points([
334
- [e.lng, e.lat],
335
- [t.lng, t.lat]
331
+ static calculateDistance(t, e, n = !0, s = 4, o = "nauticalmiles") {
332
+ t = { ...t }, e = { ...e }, t.lng = d.convertToStdLng(t.lng, s), e.lng = d.convertToStdLng(e.lng, s);
333
+ const r = T.points([
334
+ [t.lng, t.lat],
335
+ [e.lng, e.lat]
336
336
  ]);
337
- let r;
338
- return n ? r = T.rhumbDistance(i.features[0], i.features[1], { units: o }) : r = T.distance(i.features[0], i.features[1], { units: o }), d.roundPrecision(r, s);
337
+ let i;
338
+ return n ? i = T.rhumbDistance(r.features[0], r.features[1], { units: o }) : i = T.distance(r.features[0], r.features[1], { units: o }), d.roundPrecision(i, s);
339
339
  }
340
340
  /**
341
341
  * 计算航线距离
@@ -343,16 +343,16 @@ class v {
343
343
  * @param precision
344
344
  * @param units
345
345
  */
346
- static calculateRouteDistance(e, t = 4, n = "nauticalmiles") {
346
+ static calculateRouteDistance(t, e = 4, n = "nauticalmiles") {
347
347
  let s = 0, o;
348
- for (const i of e)
349
- for (let r = 0; r < i.length - 1; r++) {
350
- const c = { lng: i[r][0], lat: i[r][1] };
351
- r === 0 && o && (s += this.calculateDistance(o, c, !0, t, n));
352
- const a = { lng: i[r + 1][0], lat: i[r + 1][1] };
353
- s += this.calculateDistance(c, a, !0, t, n), o = a;
348
+ for (const r of t)
349
+ for (let i = 0; i < r.length - 1; i++) {
350
+ const c = { lng: r[i][0], lat: r[i][1] };
351
+ i === 0 && o && (s += this.calculateDistance(o, c, !0, e, n));
352
+ const a = { lng: r[i + 1][0], lat: r[i + 1][1] };
353
+ s += this.calculateDistance(c, a, !0, e, n), o = a;
354
354
  }
355
- return d.roundPrecision(s, t);
355
+ return d.roundPrecision(s, e);
356
356
  }
357
357
  /**
358
358
  * 计算坐标(基于方位角和距离)
@@ -362,11 +362,11 @@ class v {
362
362
  * @param units 单位,默认 nm(海里)
363
363
  * @param rhumb
364
364
  */
365
- static calculateCoordinate(e, t, n, s = "nauticalmiles", o = !0) {
366
- const i = T.point([e.lng, e.lat]);
367
- let r;
368
- o ? r = T.rhumbDestination(i, n, t, { units: s }) : r = T.destination(i, n, t, { units: s });
369
- const c = r.geometry.coordinates;
365
+ static calculateCoordinate(t, e, n, s = "nauticalmiles", o = !0) {
366
+ const r = T.point([t.lng, t.lat]);
367
+ let i;
368
+ o ? i = T.rhumbDestination(r, n, e, { units: s }) : i = T.destination(r, n, e, { units: s });
369
+ const c = i.geometry.coordinates;
370
370
  return { lng: d.convertToStdLng(c[0], 8), lat: d.roundPrecision(c[1], 8) };
371
371
  }
372
372
  /**
@@ -378,13 +378,13 @@ class v {
378
378
  * @param includeTail true 包含终点 to
379
379
  * @param units 单位,默认 nm(海里)
380
380
  */
381
- static interpolateCoordinates(e, t, n, s = !0, o = !0, i = "nauticalmiles") {
382
- const r = [], c = this.calculateBearing(e, t, !1), a = this.calculateDistance(e, t, !1, 8, i);
383
- s && r.push({ lng: e.lng, lat: e.lat });
381
+ static interpolateCoordinates(t, e, n, s = !0, o = !0, r = "nauticalmiles") {
382
+ const i = [], c = this.calculateBearing(t, e, !1), a = this.calculateDistance(t, e, !1, 8, r);
383
+ s && i.push({ lng: t.lng, lat: t.lat });
384
384
  let l = 0;
385
385
  for (; l < a; )
386
- l += n, l < a && r.push(this.calculateCoordinate(e, c, l, i, !1));
387
- return o && r.push({ lng: t.lng, lat: t.lat }), r;
386
+ l += n, l < a && i.push(this.calculateCoordinate(t, c, l, r, !1));
387
+ return o && i.push({ lng: e.lng, lat: e.lat }), i;
388
388
  }
389
389
  /**
390
390
  * 分组坐标(如相邻两个坐标经度差超180度,需以180为界将坐标分为两组)
@@ -398,23 +398,23 @@ class v {
398
398
  * [[-170,40],[-160,30]]
399
399
  * ]
400
400
  */
401
- static divideAccordingToLng(e, t = !1, n = !0) {
402
- if ((e == null ? void 0 : e.length) < 2)
401
+ static divideAccordingToLng(t, e = !1, n = !0) {
402
+ if ((t == null ? void 0 : t.length) < 2)
403
403
  return [];
404
- e = n ? this.deduplicateCoordinates(e) : e;
404
+ t = n ? this.deduplicateCoordinates(t) : t;
405
405
  let s = [];
406
406
  const o = [];
407
- let i, r;
408
- for (let c = 0; c < e.length - 1; c++) {
409
- i = d.convertToStdLng(e[c].lng, 8), r = d.convertToStdLng(e[c + 1].lng, 8), e[c].lat = d.roundPrecision(e[c].lat, 8), e[c + 1].lat = d.roundPrecision(e[c + 1].lat, 8), s.push([i, e[c].lat]);
410
- const a = i - r;
407
+ let r, i;
408
+ for (let c = 0; c < t.length - 1; c++) {
409
+ r = d.convertToStdLng(t[c].lng, 8), i = d.convertToStdLng(t[c + 1].lng, 8), t[c].lat = d.roundPrecision(t[c].lat, 8), t[c + 1].lat = d.roundPrecision(t[c + 1].lat, 8), s.push([r, t[c].lat]);
410
+ const a = r - i;
411
411
  if (Math.abs(a) > 180) {
412
412
  const l = d.convertToMonotonicLng2([
413
- [i, e[c].lat],
414
- [r, e[c + 1].lat]
413
+ [r, t[c].lat],
414
+ [i, t[c + 1].lat]
415
415
  ]);
416
416
  let u, f;
417
- t ? (u = T.lineString(l), f = T.lineString([
417
+ e ? (u = T.lineString(l), f = T.lineString([
418
418
  [a > 0 ? 180 : -180, 89],
419
419
  [a > 0 ? 180 : -180, -89]
420
420
  ])) : (u = T.greatCircle(l[0], l[1]), f = T.greatCircle([a > 0 ? 180 : -180, 89], [a > 0 ? 180 : -180, -89]));
@@ -424,10 +424,10 @@ class v {
424
424
  const m = T.getCoord(h.features[0]);
425
425
  g = d.roundPrecision(m[1], 8);
426
426
  } else
427
- g = e[c].lat;
427
+ g = t[c].lat;
428
428
  a > 0 ? (s.push([180 - 1e-6, g]), o.push([...s]), s = [], s.push([-(180 - 1e-6), g])) : (s.push([-(180 - 1e-6), g]), o.push([...s]), s = [], s.push([180 - 1e-6, g]));
429
429
  }
430
- c === e.length - 2 && s.push([r, e[c + 1].lat]);
430
+ c === t.length - 2 && s.push([i, t[c + 1].lat]);
431
431
  }
432
432
  return o.push(s), o;
433
433
  }
@@ -435,43 +435,43 @@ class v {
435
435
  * 去除重复坐标
436
436
  * @param route
437
437
  */
438
- static deduplicateRoute(e) {
439
- const t = [];
440
- for (const n of e) {
441
- const s = n.reduce((o, i) => (o.findIndex((r) => r[0] === i[0] && r[1] === i[1]) === -1 && o.push(i), o), []);
442
- t.push(s);
438
+ static deduplicateRoute(t) {
439
+ const e = [];
440
+ for (const n of t) {
441
+ const s = n.reduce((o, r) => (o.findIndex((i) => i[0] === r[0] && i[1] === r[1]) === -1 && o.push(r), o), []);
442
+ e.push(s);
443
443
  }
444
- return t;
444
+ return e;
445
445
  }
446
446
  /**
447
447
  * 去除重新坐标
448
448
  * @param coordinates
449
449
  */
450
- static deduplicateCoordinates(e) {
451
- return e.reduce((t, n) => (t.findIndex((s) => s.lat === n.lat && s.lng === n.lng) === -1 && t.push(n), t), []);
450
+ static deduplicateCoordinates(t) {
451
+ return t.reduce((e, n) => (e.findIndex((s) => s.lat === n.lat && s.lng === n.lng) === -1 && e.push(n), e), []);
452
452
  }
453
453
  /**
454
454
  * 移出坐标
455
455
  * @param coordinate {lng, lat}
456
456
  * @param route 航线[[[lng, lat],[lng, lat]]]
457
457
  */
458
- static removeCoordinateFromRoute(e, t) {
459
- e.lng = d.convertToStdLng(e.lng, 8);
460
- for (const n of t)
458
+ static removeCoordinateFromRoute(t, e) {
459
+ t.lng = d.convertToStdLng(t.lng, 8);
460
+ for (const n of e)
461
461
  for (let s = n.length - 1; s >= 0; s--)
462
- d.roundPrecision(n[s][0], 8) === e.lng && d.roundPrecision(n[s][1], 8) === d.roundPrecision(e.lat, 8) && n.splice(s, 1);
463
- return t;
462
+ d.roundPrecision(n[s][0], 8) === t.lng && d.roundPrecision(n[s][1], 8) === d.roundPrecision(t.lat, 8) && n.splice(s, 1);
463
+ return e;
464
464
  }
465
465
  /**
466
466
  * 移出坐标
467
467
  * @param coordinate {lng, lat}
468
468
  * @param waypoints [{lat, lng}, {lat, lng}]
469
469
  */
470
- static removeCoordinateFromWaypoints(e, t) {
471
- e.lng = d.convertToStdLng(e.lng, 8);
472
- for (let n = t.length - 1; n >= 0; n--)
473
- d.roundPrecision(t[n].lng, 8) === e.lng && d.roundPrecision(t[n].lat, 8) === d.roundPrecision(e.lat, 8) && t.splice(n, 1);
474
- return t;
470
+ static removeCoordinateFromWaypoints(t, e) {
471
+ t.lng = d.convertToStdLng(t.lng, 8);
472
+ for (let n = e.length - 1; n >= 0; n--)
473
+ d.roundPrecision(e[n].lng, 8) === t.lng && d.roundPrecision(e[n].lat, 8) === d.roundPrecision(t.lat, 8) && e.splice(n, 1);
474
+ return e;
475
475
  }
476
476
  /**
477
477
  * 合并坐标进航线(基于坐标到线段最短距离边合并)
@@ -484,44 +484,44 @@ class v {
484
484
  * @return
485
485
  * [[[120, 30], [120, 35], [125,40], [130, 37]], [[-150, 40], [-130, 30]]]
486
486
  */
487
- static mergeCoordinateToRoute(e, t) {
488
- e.lng = d.convertToStdLng(e.lng, 8);
489
- let n = Number.MAX_VALUE, s = 0, o = 0, i, r;
490
- return t.forEach((c, a) => {
487
+ static mergeCoordinateToRoute(t, e) {
488
+ t.lng = d.convertToStdLng(t.lng, 8);
489
+ let n = Number.MAX_VALUE, s = 0, o = 0, r, i;
490
+ return e.forEach((c, a) => {
491
491
  for (let l = 0; l < c.length - 1; l++) {
492
- const u = { lng: c[l][0], lat: c[l][1] }, f = { lng: c[l + 1][0], lat: c[l + 1][1] }, h = this.calculatePointToLineDistance(e, u, f);
493
- n > h && (n = h, o = l, s = a, i = this.calculateDistance(u, e), r = this.calculateDistance(f, e));
492
+ const u = { lng: c[l][0], lat: c[l][1] }, f = { lng: c[l + 1][0], lat: c[l + 1][1] }, h = this.calculatePointToLineDistance(t, u, f);
493
+ n > h && (n = h, o = l, s = a, r = this.calculateDistance(u, t), i = this.calculateDistance(f, t));
494
494
  }
495
- }), i !== 0 && r !== 0 ? t[s].splice(o + 1, 0, [e.lng, e.lat]) : i === 0 ? t[s].splice(o, 1, [e.lng, e.lat]) : r === 0 && t[s].splice(o + 1, 1, [e.lng, e.lat]), t;
495
+ }), r !== 0 && i !== 0 ? e[s].splice(o + 1, 0, [t.lng, t.lat]) : r === 0 ? e[s].splice(o, 1, [t.lng, t.lat]) : i === 0 && e[s].splice(o + 1, 1, [t.lng, t.lat]), e;
496
496
  }
497
497
  /**
498
498
  * 向Route尾加1个坐标
499
499
  * @param coordinate
500
500
  * @param route
501
501
  */
502
- static appendCoordinateToRoute(e, t) {
503
- e.lng = d.convertToStdLng(e.lng, 8);
504
- const n = v.convertRouteToCoordinates(t);
505
- return n.push(e), v.divideAccordingToLng(n);
502
+ static appendCoordinateToRoute(t, e) {
503
+ t.lng = d.convertToStdLng(t.lng, 8);
504
+ const n = v.convertRouteToCoordinates(e);
505
+ return n.push(t), v.divideAccordingToLng(n);
506
506
  }
507
507
  /**
508
508
  * 向route头加1个坐标
509
509
  * @param coordinate
510
510
  * @param route
511
511
  */
512
- static unshiftCoordinateToRoute(e, t) {
513
- const n = v.convertRouteToCoordinates(t);
514
- return n.unshift(e), v.divideAccordingToLng(n);
512
+ static unshiftCoordinateToRoute(t, e) {
513
+ const n = v.convertRouteToCoordinates(e);
514
+ return n.unshift(t), v.divideAccordingToLng(n);
515
515
  }
516
516
  /**
517
517
  * 合并多个waypoints进航线
518
518
  * @param waypoints [{lat, lng}, {lat, lng}]
519
519
  * @param route 航线 [[[lng, lat],[lng, lat]]]
520
520
  */
521
- static mergeWaypointsToRoute(e, t) {
522
- for (const n of e)
523
- t = this.mergeCoordinateToRoute(n, t);
524
- return t;
521
+ static mergeWaypointsToRoute(t, e) {
522
+ for (const n of t)
523
+ e = this.mergeCoordinateToRoute(n, e);
524
+ return e;
525
525
  }
526
526
  /**
527
527
  * 计算区间航线
@@ -530,22 +530,22 @@ class v {
530
530
  * @param route [[[lng, lat]]]
531
531
  * @return [[[lng, lat]]]
532
532
  */
533
- static calculateRangeRoute(e, t, n) {
534
- n = this.mergeWaypointsToRoute([e, t], n);
533
+ static calculateRangeRoute(t, e, n) {
534
+ n = this.mergeWaypointsToRoute([t, e], n);
535
535
  const s = [];
536
536
  let o = 0;
537
- return n.forEach((i) => {
537
+ return n.forEach((r) => {
538
538
  if (o === 2)
539
539
  return;
540
- const r = [];
541
- for (const c of i) {
542
- if (d.roundPrecision(t.lng, 8) === d.roundPrecision(c[0], 8) && d.roundPrecision(t.lat, 8) === d.roundPrecision(c[1], 8)) {
543
- r.push(c), o === 0 && r.push([e.lng, e.lat]), o = 2;
540
+ const i = [];
541
+ for (const c of r) {
542
+ if (d.roundPrecision(e.lng, 8) === d.roundPrecision(c[0], 8) && d.roundPrecision(e.lat, 8) === d.roundPrecision(c[1], 8)) {
543
+ i.push(c), o === 0 && i.push([t.lng, t.lat]), o = 2;
544
544
  break;
545
545
  }
546
- o === 1 ? r.push(c) : d.roundPrecision(e.lng, 8) === d.roundPrecision(c[0], 8) && d.roundPrecision(e.lat, 8) === d.roundPrecision(c[1], 8) && (o = 1, r.push(c));
546
+ o === 1 ? i.push(c) : d.roundPrecision(t.lng, 8) === d.roundPrecision(c[0], 8) && d.roundPrecision(t.lat, 8) === d.roundPrecision(c[1], 8) && (o = 1, i.push(c));
547
547
  }
548
- r.length && s.push(r);
548
+ i.length && s.push(i);
549
549
  }), s;
550
550
  }
551
551
  /**
@@ -556,25 +556,25 @@ class v {
556
556
  * @param waypoints
557
557
  * @return [{lng, lat}]
558
558
  */
559
- static calculateRangeWaypoints(e, t, n, s = []) {
560
- const o = this.convertRouteToCoordinates(n, 0), i = this.mergeCoordinatesToWaypoints([e, t], o.length ? o : s), r = i.findIndex(
561
- (l) => d.roundPrecision(e.lng, 8) === d.roundPrecision(l.lng, 8) && d.roundPrecision(e.lat, 8) === d.roundPrecision(l.lat, 8)
562
- ), c = i.findIndex(
559
+ static calculateRangeWaypoints(t, e, n, s = []) {
560
+ const o = this.convertRouteToCoordinates(n, 0), r = this.mergeCoordinatesToWaypoints([t, e], o.length ? o : s), i = r.findIndex(
563
561
  (l) => d.roundPrecision(t.lng, 8) === d.roundPrecision(l.lng, 8) && d.roundPrecision(t.lat, 8) === d.roundPrecision(l.lat, 8)
562
+ ), c = r.findIndex(
563
+ (l) => d.roundPrecision(e.lng, 8) === d.roundPrecision(l.lng, 8) && d.roundPrecision(e.lat, 8) === d.roundPrecision(l.lat, 8)
564
564
  );
565
- return i.filter((l, u) => u >= r && u <= c);
565
+ return r.filter((l, u) => u >= i && u <= c);
566
566
  }
567
567
  /**
568
568
  * 计算坐标到航路上的最短距离
569
569
  * @param from
570
570
  * @param route
571
571
  */
572
- static calculateMinDistanceToRoute(e, t) {
572
+ static calculateMinDistanceToRoute(t, e) {
573
573
  let n = Number.MAX_VALUE, s = 0, o = 0;
574
- return t.forEach((i, r) => {
575
- for (let c = 0; c < i.length - 1; c++) {
576
- const a = { lng: i[c][0], lat: i[c][1] }, l = { lng: i[c + 1][0], lat: i[c + 1][1] }, u = this.calculatePointToLineDistance(e, a, l);
577
- n > u && (n = u, s = c, o = r);
574
+ return e.forEach((r, i) => {
575
+ for (let c = 0; c < r.length - 1; c++) {
576
+ const a = { lng: r[c][0], lat: r[c][1] }, l = { lng: r[c + 1][0], lat: r[c + 1][1] }, u = this.calculatePointToLineDistance(t, a, l);
577
+ n > u && (n = u, s = c, o = i);
578
578
  }
579
579
  }), { minDist: n, segIndex: o, minIndex: s };
580
580
  }
@@ -584,23 +584,23 @@ class v {
584
584
  * @param route [[[lng, lat]]] 剩余航线
585
585
  * @return [[[lng, lat]]]
586
586
  */
587
- static calculateSubRoute(e, t) {
588
- const n = v.convertRouteToCoordinates(t);
589
- v.mergeCoordinateToWaypoints(e, n, !0), t = v.divideAccordingToLng(n);
590
- const { segIndex: s, minIndex: o } = this.calculateMinDistanceToRoute({ ...e }, t);
591
- e.lng = d.convertToStdLng(e.lng);
592
- const i = [];
593
- let r = !0;
594
- for (let c = s; c < t.length; c++)
595
- if (r) {
587
+ static calculateSubRoute(t, e) {
588
+ const n = v.convertRouteToCoordinates(e);
589
+ v.mergeCoordinateToWaypoints(t, n, !0), e = v.divideAccordingToLng(n);
590
+ const { segIndex: s, minIndex: o } = this.calculateMinDistanceToRoute({ ...t }, e);
591
+ t.lng = d.convertToStdLng(t.lng);
592
+ const r = [];
593
+ let i = !0;
594
+ for (let c = s; c < e.length; c++)
595
+ if (i) {
596
596
  const a = [];
597
- a.push([e.lng, e.lat]);
598
- for (let l = o + 1; l < t[c].length; l++)
599
- e.lng === t[c][l][0] && e.lat === t[c][l][1] || a.push(t[c][l]);
600
- i.push(a), r = !1;
597
+ a.push([t.lng, t.lat]);
598
+ for (let l = o + 1; l < e[c].length; l++)
599
+ t.lng === e[c][l][0] && t.lat === e[c][l][1] || a.push(e[c][l]);
600
+ r.push(a), i = !1;
601
601
  } else
602
- i.push([...t[c]]);
603
- return i;
602
+ r.push([...e[c]]);
603
+ return r;
604
604
  }
605
605
  /**
606
606
  * 计算子途经点
@@ -608,21 +608,21 @@ class v {
608
608
  * @param waypoints [{lng, lat}]
609
609
  * @return [{lng, lat}]
610
610
  */
611
- static calculateSubWaypoints(e, t) {
611
+ static calculateSubWaypoints(t, e) {
612
612
  let n = Number.MAX_VALUE, s = 0;
613
- for (let i = 0; i < t.length - 1; i++) {
614
- const r = t[i], c = t[i + 1];
615
- if (this.calculateDistance(e, r) === 0)
616
- return t;
617
- if (this.calculateDistance(e, c) === 0)
618
- return t.filter((l, u) => u > 0);
619
- const a = this.calculatePointToLineDistance(e, r, c);
620
- n > a && (n = a, s = i);
613
+ for (let r = 0; r < e.length - 1; r++) {
614
+ const i = e[r], c = e[r + 1];
615
+ if (this.calculateDistance(t, i) === 0)
616
+ return e;
617
+ if (this.calculateDistance(t, c) === 0)
618
+ return e.filter((l, u) => u > 0);
619
+ const a = this.calculatePointToLineDistance(t, i, c);
620
+ n > a && (n = a, s = r);
621
621
  }
622
- e.lng = d.convertToStdLng(e.lng);
623
- const o = [e];
624
- for (let i = s + 1; i < t.length; i++)
625
- o.push(t[i]);
622
+ t.lng = d.convertToStdLng(t.lng);
623
+ const o = [t];
624
+ for (let r = s + 1; r < e.length; r++)
625
+ o.push(e[r]);
626
626
  return o;
627
627
  }
628
628
  /**
@@ -632,38 +632,38 @@ class v {
632
632
  * @param to { lng, lat }
633
633
  * @param options
634
634
  */
635
- static calculatePointToLineDistance(e, t, n, s = { units: "nauticalmiles", method: "geodesic" }) {
636
- e.lng = d.convertToStdLng(e.lng, 8), t = { ...t }, n = { ...n }, t.lng = d.convertToStdLng(t.lng, 8), n.lng = d.convertToStdLng(n.lng, 8);
637
- const o = d.convertToMonotonicLng([t, n]);
638
- t = o[0], n = o[1];
639
- const i = T.lineString([
640
- [t.lng, t.lat],
635
+ static calculatePointToLineDistance(t, e, n, s = { units: "nauticalmiles", method: "geodesic" }) {
636
+ t.lng = d.convertToStdLng(t.lng, 8), e = { ...e }, n = { ...n }, e.lng = d.convertToStdLng(e.lng, 8), n.lng = d.convertToStdLng(n.lng, 8);
637
+ const o = d.convertToMonotonicLng([e, n]);
638
+ e = o[0], n = o[1];
639
+ const r = T.lineString([
640
+ [e.lng, e.lat],
641
641
  [n.lng, n.lat]
642
- ]), r = T.pointToLineDistance(T.point([e.lng, e.lat]), i, s), c = T.pointToLineDistance(T.point([e.lng > 0 ? e.lng - 360 : e.lng + 360, e.lat]), i, s);
643
- return d.roundPrecision(Math.min(r, c), 6);
642
+ ]), i = T.pointToLineDistance(T.point([t.lng, t.lat]), r, s), c = T.pointToLineDistance(T.point([t.lng > 0 ? t.lng - 360 : t.lng + 360, t.lat]), r, s);
643
+ return d.roundPrecision(Math.min(i, c), 6);
644
644
  }
645
645
  /**
646
646
  * 计算途经点的COG, Distance等属性
647
647
  * @param waypoints
648
648
  * @param route
649
649
  */
650
- static calculateWaypointsPropInRoute(e, t) {
651
- t = this.mergeWaypointsToRoute(e, t);
652
- for (let n = 0; n < e.length - 1; n++) {
653
- const s = e[n], o = e[n + 1], i = this.calculateRangeRoute(s, o, t);
654
- n === 0 && (s.distanceFromPrevious = 0, s.distanceFromStart = 0), o.distanceFromPrevious = this.calculateRouteDistance(i), o.distanceFromStart = d.roundPrecision((s.distanceFromStart || 0) + o.distanceFromPrevious);
650
+ static calculateWaypointsPropInRoute(t, e) {
651
+ e = this.mergeWaypointsToRoute(t, e);
652
+ for (let n = 0; n < t.length - 1; n++) {
653
+ const s = t[n], o = t[n + 1], r = this.calculateRangeRoute(s, o, e);
654
+ n === 0 && (s.distanceFromPrevious = 0, s.distanceFromStart = 0), o.distanceFromPrevious = this.calculateRouteDistance(r), o.distanceFromStart = d.roundPrecision((s.distanceFromStart || 0) + o.distanceFromPrevious);
655
655
  }
656
- return e;
656
+ return t;
657
657
  }
658
658
  /**
659
659
  * @param coordinates [{lng, lat}]
660
660
  * @param waypoints [{lng, lat}]
661
661
  * @param replace true replace the same waypoint with coordinate
662
662
  */
663
- static mergeCoordinatesToWaypoints(e, t, n = !0) {
664
- for (const s of e)
665
- this.mergeCoordinateToWaypoints(s, t, n);
666
- return t;
663
+ static mergeCoordinatesToWaypoints(t, e, n = !0) {
664
+ for (const s of t)
665
+ this.mergeCoordinateToWaypoints(s, e, n);
666
+ return e;
667
667
  }
668
668
  /**
669
669
  * 合并坐标进航路途经点
@@ -677,21 +677,21 @@ class v {
677
677
  * @return
678
678
  * [{ lng: 160, lat: 30}, { lng: 170, lat: 40}, {lng: 179, lat: 50}, {lng: -170, lat: 40}, {lng: -160, lat: 30}]
679
679
  */
680
- static mergeCoordinateToWaypoints(e, t, n = !0) {
681
- e.lng = d.convertToStdLng(e.lng, 8);
682
- let s = Number.MAX_VALUE, o = 0, i = 0, r = 0;
683
- if (t.length < 2)
684
- t.push(e);
680
+ static mergeCoordinateToWaypoints(t, e, n = !0) {
681
+ t.lng = d.convertToStdLng(t.lng, 8);
682
+ let s = Number.MAX_VALUE, o = 0, r = 0, i = 0;
683
+ if (e.length < 2)
684
+ e.push(t);
685
685
  else {
686
- for (let c = 0; c < t.length - 1; c++) {
687
- const a = { lng: t[c].lng, lat: t[c].lat }, l = { lng: t[c + 1].lng, lat: t[c + 1].lat }, u = this.calculatePointToLineDistance(e, a, l);
688
- s >= u && (s = u, o = c, i = this.calculateDistance(a, e, !1, 6), r = this.calculateDistance(l, e, !1, 6));
686
+ for (let c = 0; c < e.length - 1; c++) {
687
+ const a = { lng: e[c].lng, lat: e[c].lat }, l = { lng: e[c + 1].lng, lat: e[c + 1].lat }, u = this.calculatePointToLineDistance(t, a, l);
688
+ s >= u && (s = u, o = c, r = this.calculateDistance(a, t, !1, 6), i = this.calculateDistance(l, t, !1, 6));
689
689
  }
690
- i !== 0 && r !== 0 ? i <= s && o === 0 ? t.unshift(e) : r <= s && o === t.length - 2 ? t.push(e) : t.splice(o + 1, 0, e) : i === 0 ? n ? t.splice(o, 1, e) : t.splice(o + 1, 0, e) : r === 0 && (n ? t.splice(o + 1, 1, e) : t.splice(o + 1, 0, e));
690
+ r !== 0 && i !== 0 ? r <= s && o === 0 ? e.unshift(t) : i <= s && o === e.length - 2 ? e.push(t) : e.splice(o + 1, 0, t) : r === 0 ? n ? e.splice(o, 1, t) : e.splice(o + 1, 0, t) : i === 0 && (n ? e.splice(o + 1, 1, t) : e.splice(o + 1, 0, t));
691
691
  }
692
- return t.map((c, a) => {
692
+ return e.map((c, a) => {
693
693
  c.lng = d.convertToStdLng(c.lng);
694
- const l = t[a + 1];
694
+ const l = e[a + 1];
695
695
  if (l && ((c.bearing === null || c.bearing === void 0) && ((c.positionTime || 0) > (l.positionTime || 0) ? c.bearing = this.calculateBearing(l, c, !0) : c.bearing = this.calculateBearing(c, l, !0)), c.cog = c.cog || c.bearing, !c.sog && c.positionTime && l.positionTime)) {
696
696
  const u = this.calculateDistance(c, l, !0), f = Math.abs(l.positionTime - c.positionTime) / 3600;
697
697
  c.sog = d.roundPrecision(u / f, 2);
@@ -706,25 +706,25 @@ class v {
706
706
  * @param rhumb
707
707
  * @param deduplicate
708
708
  */
709
- static generateRouteAccordingToWaypoints(e, t = !0, n = !0) {
709
+ static generateRouteAccordingToWaypoints(t, e = !0, n = !0) {
710
710
  const s = [];
711
- for (let o = 1; o < e.length; o++) {
712
- const i = e[o - 1], r = e[o];
713
- if (o === 1 && s.push(i), r.gcToPrevious) {
714
- const c = this.interpolateCoordinates(i, r, 200, !1, !0, "nauticalmiles");
711
+ for (let o = 1; o < t.length; o++) {
712
+ const r = t[o - 1], i = t[o];
713
+ if (o === 1 && s.push(r), i.gcToPrevious) {
714
+ const c = this.interpolateCoordinates(r, i, 200, !1, !0, "nauticalmiles");
715
715
  s.push(...c);
716
716
  } else
717
- s.push(r);
717
+ s.push(i);
718
718
  }
719
- return this.divideAccordingToLng(s, t, n);
719
+ return this.divideAccordingToLng(s, e, n);
720
720
  }
721
721
  /**
722
722
  * 最近点(从route中找出距离目标点最近的点)
723
723
  * @param coordinate 目标点 {lng, lat}
724
724
  * @param route [[[lng, lat]]]
725
725
  */
726
- static nearestCoordinateInRoute(e, t) {
727
- const n = T.point([e.lng, e.lat]), o = this.convertRouteToCoordinates(t).map((a) => [a.lng, a.lat]), i = T.lineString(o), r = T.nearestPointOnLine(i, n), c = T.getCoord(r);
726
+ static nearestCoordinateInRoute(t, e) {
727
+ const n = T.point([t.lng, t.lat]), o = this.convertRouteToCoordinates(e).map((a) => [a.lng, a.lat]), r = T.lineString(o), i = T.nearestPointOnLine(r, n), c = T.getCoord(i);
728
728
  return { lng: d.roundPrecision(c[0], 8), lat: d.roundPrecision(c[1], 8) };
729
729
  }
730
730
  /**
@@ -732,21 +732,21 @@ class v {
732
732
  * @param from
733
733
  * @param waypoints
734
734
  */
735
- static calculatePrevWaypoint(e, t) {
735
+ static calculatePrevWaypoint(t, e) {
736
736
  let n = 0;
737
- this.mergeCoordinateToWaypoints(e, t);
738
- for (let s = 0; s < t.length - 1; s++) {
739
- const o = t[s], i = t[s + 1];
740
- if (this.calculateDistance(e, o) === 0) {
737
+ this.mergeCoordinateToWaypoints(t, e);
738
+ for (let s = 0; s < e.length - 1; s++) {
739
+ const o = e[s], r = e[s + 1];
740
+ if (this.calculateDistance(t, o) === 0) {
741
741
  n = s;
742
742
  break;
743
743
  }
744
- if (this.calculateDistance(e, i) === 0) {
744
+ if (this.calculateDistance(t, r) === 0) {
745
745
  n = s + 1;
746
746
  break;
747
747
  }
748
748
  }
749
- return t[n === 0 ? 0 : n - 1];
749
+ return e[n === 0 ? 0 : n - 1];
750
750
  }
751
751
  /**
752
752
  * 计算下一个距离单位的坐标及其子航线
@@ -756,13 +756,13 @@ class v {
756
756
  * @param units
757
757
  * @return { coordinate: {lng, lat}, route: [[[lng, lat]]]}
758
758
  */
759
- static calculateNextCoordinateAlongRoute(e, t, n, s = "nauticalmiles") {
759
+ static calculateNextCoordinateAlongRoute(t, e, n, s = "nauticalmiles") {
760
760
  var f;
761
- const o = e.speed || 12, i = [];
762
- let r = [], c = !1, a = 0, l = 0, u;
763
- if (t && n.length ? (i.push(e), n.forEach((h, g) => {
761
+ const o = t.speed || 12, r = [];
762
+ let i = [], c = !1, a = 0, l = 0, u;
763
+ if (e && n.length ? (r.push(t), n.forEach((h, g) => {
764
764
  if (c)
765
- r.push(h);
765
+ i.push(h);
766
766
  else {
767
767
  const m = [];
768
768
  let p;
@@ -771,28 +771,28 @@ class v {
771
771
  m.push(h[S]);
772
772
  else {
773
773
  p = { lng: h[S][0], lat: h[S][1] };
774
- const x = this.calculateDistance(e, p, !0, 8, s);
775
- if (a += x, a < t)
776
- l += x, x && i.push(p), e = p;
774
+ const x = this.calculateDistance(t, p, !0, 8, s);
775
+ if (a += x, a < e)
776
+ l += x, x && r.push(p), t = p;
777
777
  else {
778
- if (l = t, a === t)
778
+ if (l = e, a === e)
779
779
  u = p, m.push([u.lng, u.lat]);
780
780
  else {
781
- const M = a - t, y = this.calculateBearing(p, e);
781
+ const M = a - e, y = this.calculateBearing(p, t);
782
782
  u = this.calculateCoordinate(p, y, M, s), m.push([u.lng, u.lat]), m.push([p.lng, p.lat]);
783
783
  }
784
784
  c = !0;
785
785
  }
786
786
  }
787
- m.length && r.push(m), g === n.length - 1 && !u && (u = p);
787
+ m.length && i.push(m), g === n.length - 1 && !u && (u = p);
788
788
  }
789
- })) : (r = n, u = { ...e }), u)
790
- if (i.push(u), u.distanceFromPrevious = Math.round(l * 1e4) / 1e4, u.hourFromPrevious = Math.round(l / o * 1e4) / 1e4, ((f = r[0]) == null ? void 0 : f.length) > 1) {
791
- const h = { lng: r[0][1][0], lat: r[0][1][1] };
789
+ })) : (i = n, u = { ...t }), u)
790
+ if (r.push(u), u.distanceFromPrevious = Math.round(l * 1e4) / 1e4, u.hourFromPrevious = Math.round(l / o * 1e4) / 1e4, ((f = i[0]) == null ? void 0 : f.length) > 1) {
791
+ const h = { lng: i[0][1][0], lat: i[0][1][1] };
792
792
  u.bearing = this.calculateBearing(u, h);
793
793
  } else
794
794
  u.bearing = 0;
795
- return { coordinate: u, nextRoute: r, prevRoute: i };
795
+ return { coordinate: u, nextRoute: i, prevRoute: r };
796
796
  }
797
797
  /**
798
798
  * 返回最近点及其是否为垂足(最近点不是起点或终点)
@@ -800,31 +800,31 @@ class v {
800
800
  * @param from {lng, lat}
801
801
  * @param to {lng, lat}
802
802
  */
803
- static nearestCoordinateInLine(e, t, n) {
804
- const s = d.convertToStdLng(e.lng, 6), o = T.point([s, e.lat]), i = d.convertToStdLng(t.lng, 6), r = d.convertToStdLng(n.lng, 6), c = T.lineString([
805
- [i, t.lat],
806
- [r, n.lat]
803
+ static nearestCoordinateInLine(t, e, n) {
804
+ const s = d.convertToStdLng(t.lng, 6), o = T.point([s, t.lat]), r = d.convertToStdLng(e.lng, 6), i = d.convertToStdLng(n.lng, 6), c = T.lineString([
805
+ [r, e.lat],
806
+ [i, n.lat]
807
807
  ]), a = T.nearestPointOnLine(c, o), l = T.getCoord(a), u = d.roundPrecision(l[0], 6), f = d.roundPrecision(l[1], 6);
808
- return { lng: u, lat: f, inline: !(u === i && f === t.lat) && !(u === r && f === n.lat) };
808
+ return { lng: u, lat: f, inline: !(u === r && f === e.lat) && !(u === i && f === n.lat) };
809
809
  }
810
810
  /**
811
811
  * 将route转coordinate
812
812
  * @param route
813
813
  * @param distance 临近点过虑
814
814
  */
815
- static convertRouteToCoordinates(e, t = 0) {
815
+ static convertRouteToCoordinates(t, e = 0) {
816
816
  const n = [];
817
817
  let s, o;
818
- return e.forEach((i) => {
819
- i.forEach((r) => {
820
- const c = { lng: d.roundPrecision(r[0], 8), lat: d.roundPrecision(r[1], 8) };
818
+ return t.forEach((r) => {
819
+ r.forEach((i) => {
820
+ const c = { lng: d.roundPrecision(i[0], 8), lat: d.roundPrecision(i[1], 8) };
821
821
  if (!o)
822
822
  n.push(c), o = c;
823
823
  else if (o.bearing === void 0 || o.bearing === null)
824
824
  o.bearing = this.calculateBearing(o, c, !0);
825
825
  else {
826
826
  const a = this.calculateDistance(s, c, !0);
827
- a && a >= t && (s.bearing = this.calculateBearing(s, c, !0), n.push(s), o = s);
827
+ a && a >= e && (s.bearing = this.calculateBearing(s, c, !0), n.push(s), o = s);
828
828
  }
829
829
  s = c;
830
830
  });
@@ -836,76 +836,76 @@ class v {
836
836
  * @param waypoints [{ lng, lat, gcToPrevious }]
837
837
  * @param distance
838
838
  */
839
- static simplifyRouteToCoordinates(e, t, n = 1) {
840
- let s = this.convertRouteToCoordinates(e, n);
841
- return s = this.simplifyGCCoordinates(s, t), s;
839
+ static simplifyRouteToCoordinates(t, e, n = 1) {
840
+ let s = this.convertRouteToCoordinates(t, n);
841
+ return s = this.simplifyGCCoordinates(s, e), s;
842
842
  }
843
843
  /**
844
844
  * 基于大圆标识抽稀
845
845
  * @param coordinates
846
846
  * @param waypoints
847
847
  */
848
- static simplifyGCCoordinates(e, t) {
849
- t.forEach((s) => {
850
- this.mergeCoordinateToWaypoints(s, e, !0);
848
+ static simplifyGCCoordinates(t, e) {
849
+ e.forEach((s) => {
850
+ this.mergeCoordinateToWaypoints(s, t, !0);
851
851
  });
852
- for (let s = 1; s < t.length; s++) {
853
- const o = t[s - 1], i = t[s];
854
- if (i.gcToPrevious) {
855
- const r = e.findIndex((a) => a.lng === o.lng && a.lat === o.lat), c = e.findIndex((a) => a.lng === i.lng && a.lat === i.lat);
856
- for (let a = c - 1; a > r; a--)
857
- e.splice(a, 1);
852
+ for (let s = 1; s < e.length; s++) {
853
+ const o = e[s - 1], r = e[s];
854
+ if (r.gcToPrevious) {
855
+ const i = t.findIndex((a) => a.lng === o.lng && a.lat === o.lat), c = t.findIndex((a) => a.lng === r.lng && a.lat === r.lat);
856
+ for (let a = c - 1; a > i; a--)
857
+ t.splice(a, 1);
858
858
  }
859
859
  }
860
860
  let n = 0;
861
- for (let s = 1; s < e.length; s++) {
862
- const o = e[s - 1], i = e[s];
863
- i.gcToPrevious ? (o.bearing = this.calculateBearing(o, i, !1), i.distanceFromPrevious = this.calculateDistance(o, i, !1)) : (o.bearing = this.calculateBearing(o, i, !0), i.distanceFromPrevious = this.calculateDistance(o, i, !0)), n = d.roundPrecision(n + i.distanceFromPrevious), i.distanceFromStart = n;
861
+ for (let s = 1; s < t.length; s++) {
862
+ const o = t[s - 1], r = t[s];
863
+ r.gcToPrevious ? (o.bearing = this.calculateBearing(o, r, !1), r.distanceFromPrevious = this.calculateDistance(o, r, !1)) : (o.bearing = this.calculateBearing(o, r, !0), r.distanceFromPrevious = this.calculateDistance(o, r, !0)), n = d.roundPrecision(n + r.distanceFromPrevious), r.distanceFromStart = n;
864
864
  }
865
- return e.map((s) => (s.lng = d.convertToStdLng(s.lng), s));
865
+ return t.map((s) => (s.lng = d.convertToStdLng(s.lng), s));
866
866
  }
867
867
  /**
868
868
  * 计算轨迹中心点
869
869
  * @param route
870
870
  */
871
- static calculateCenter(e) {
872
- const t = [];
873
- for (const r of e)
874
- for (const c of r)
875
- t.push(c);
876
- const n = T.featureCollection([]), s = d.convertToMonotonicLng2(t);
877
- for (const r of s)
878
- n.features.push(T.point(r));
879
- const i = T.center(n).geometry.coordinates;
880
- return { lng: d.convertToStdLng(i[0], 8), lat: d.roundPrecision(i[1], 8) };
871
+ static calculateCenter(t) {
872
+ const e = [];
873
+ for (const i of t)
874
+ for (const c of i)
875
+ e.push(c);
876
+ const n = T.featureCollection([]), s = d.convertToMonotonicLng2(e);
877
+ for (const i of s)
878
+ n.features.push(T.point(i));
879
+ const r = T.center(n).geometry.coordinates;
880
+ return { lng: d.convertToStdLng(r[0], 8), lat: d.roundPrecision(r[1], 8) };
881
881
  }
882
882
  /**
883
883
  * 计算中心点
884
884
  * @param coords
885
885
  */
886
- static calculateCenter2(e) {
887
- const t = this.generateRouteAccordingToWaypoints(e);
888
- return this.calculateCenter(t);
886
+ static calculateCenter2(t) {
887
+ const e = this.generateRouteAccordingToWaypoints(t);
888
+ return this.calculateCenter(e);
889
889
  }
890
890
  /**
891
891
  * 计算BBox
892
892
  * @param route
893
893
  */
894
- static calculateBBox(e) {
895
- const t = [];
896
- for (const o of e)
897
- for (const i of o)
898
- t.push(i);
899
- const n = d.convertToMonotonicLng2(t), s = T.lineString(n);
894
+ static calculateBBox(t) {
895
+ const e = [];
896
+ for (const o of t)
897
+ for (const r of o)
898
+ e.push(r);
899
+ const n = d.convertToMonotonicLng2(e), s = T.lineString(n);
900
900
  return T.bbox(s);
901
901
  }
902
902
  /**
903
903
  * 计算BBox
904
904
  * @param coords
905
905
  */
906
- static calculateBBox2(e) {
907
- const t = this.generateRouteAccordingToWaypoints(e);
908
- return this.calculateBBox(t);
906
+ static calculateBBox2(t) {
907
+ const e = this.generateRouteAccordingToWaypoints(t);
908
+ return this.calculateBBox(e);
909
909
  }
910
910
  /**
911
911
  * 抽稀 三点抽稀, 对比A,B,C; 基于三点距离及夹角抽稀
@@ -913,17 +913,17 @@ class v {
913
913
  * @param distance 三点最小距离, 小于此距离时,B点将被忽略(三点太近)
914
914
  * @param angle 三点夹角, 大于此角度时,B点将被忽略(近似走RL)
915
915
  */
916
- static simplifyCoordinates(e, t = 1, n = 180) {
916
+ static simplifyCoordinates(t, e = 1, n = 180) {
917
917
  const s = [];
918
- for (let o = 1; o < e.length; o++) {
919
- const i = e[o - 1], r = e[o], c = e[o + 1];
918
+ for (let o = 1; o < t.length; o++) {
919
+ const r = t[o - 1], i = t[o], c = t[o + 1];
920
920
  let a = !1, l = !1;
921
- if ((i.velocity || i.suspend || i.important || i.pilot || o === 1) && (a = !0, s.push(i)), r.gcToPrevious && (a || (a = !0, s.push(i)), l = !0, s.push(r), o++), c) {
922
- const u = v.calculateDistance(i, r, !0), f = v.calculateDistance(r, c, !0), h = v.calculateDistance(i, c, !0), g = (Math.pow(u, 2) + Math.pow(f, 2) - Math.pow(h, 2)) / (2 * u * f);
923
- Math.round(Math.acos(g) * 180 / Math.PI) < n && h > t && !l && (s.push(r), o++);
921
+ if ((r.velocity || r.suspend || r.important || r.pilot || o === 1) && (a = !0, s.push(r)), i.gcToPrevious && (a || (a = !0, s.push(r)), l = !0, s.push(i), o++), c) {
922
+ const u = v.calculateDistance(r, i, !0), f = v.calculateDistance(i, c, !0), h = v.calculateDistance(r, c, !0), g = (Math.pow(u, 2) + Math.pow(f, 2) - Math.pow(h, 2)) / (2 * u * f);
923
+ Math.round(Math.acos(g) * 180 / Math.PI) < n && h > e && !l && (s.push(i), o++);
924
924
  }
925
- if (o >= e.length - 1) {
926
- const u = e.at(-1);
925
+ if (o >= t.length - 1) {
926
+ const u = t.at(-1);
927
927
  u && s.push(u);
928
928
  }
929
929
  }
@@ -935,24 +935,24 @@ class v {
935
935
  * @param step 时间步长, 前后n小时
936
936
  * @param waypoints 带时间的轨迹, 单位秒
937
937
  */
938
- static nearestTSPointInWaypoints(e, t, n) {
939
- const s = b.unix(e), o = n.filter(
940
- (i) => s.clone().subtract(t, "hour").unix() <= (i.positionTime || 0) && s.clone().add(t, "h").unix() >= (i.positionTime || 0)
938
+ static nearestTSPointInWaypoints(t, e, n) {
939
+ const s = b.unix(t), o = n.filter(
940
+ (r) => s.clone().subtract(e, "hour").unix() <= (r.positionTime || 0) && s.clone().add(e, "h").unix() >= (r.positionTime || 0)
941
941
  );
942
- return o.sort((i, r) => (i.positionTime || 0) - (r.positionTime || 0)), o.at(-1);
942
+ return o.sort((r, i) => (r.positionTime || 0) - (i.positionTime || 0)), o.at(-1);
943
943
  }
944
944
  /**
945
945
  * 推测船位
946
946
  * @param ts 目标时间的船位,单位 s
947
947
  * @param positions 带时间(positionTime)的轨迹
948
948
  */
949
- static deadReckoning(e, t) {
950
- var o, i, r, c;
951
- e > 1e12 && (e = Math.round(e / 1e3));
952
- const n = b.unix(e);
953
- let s = t.find((a) => a.positionTime === n.unix());
949
+ static deadReckoning(t, e) {
950
+ var o, r, i, c;
951
+ t > 1e12 && (t = Math.round(t / 1e3));
952
+ const n = b.unix(t);
953
+ let s = e.find((a) => a.positionTime === n.unix());
954
954
  if (!s) {
955
- const a = (i = (o = t.filter((u) => (u == null ? void 0 : u.positionTime) < n.unix())) == null ? void 0 : o.sort((u, f) => (u.positionTime || 0) - (f.positionTime || 0))) == null ? void 0 : i.at(-1), l = (c = (r = t.filter((u) => (u == null ? void 0 : u.positionTime) > n.unix())) == null ? void 0 : r.sort((u, f) => (u.positionTime || 0) - (f.positionTime || 0))) == null ? void 0 : c.at(0);
955
+ const a = (r = (o = e.filter((u) => (u == null ? void 0 : u.positionTime) < n.unix())) == null ? void 0 : o.sort((u, f) => (u.positionTime || 0) - (f.positionTime || 0))) == null ? void 0 : r.at(-1), l = (c = (i = e.filter((u) => (u == null ? void 0 : u.positionTime) > n.unix())) == null ? void 0 : i.sort((u, f) => (u.positionTime || 0) - (f.positionTime || 0))) == null ? void 0 : c.at(0);
956
956
  if (a && l) {
957
957
  const u = v.calculateBearing(a, l, !0), f = v.calculateDistance(a, l), h = (n.unix() - a.positionTime) / (l.positionTime - a.positionTime);
958
958
  s = v.calculateCoordinate(a, u, f * h), s.positionTime = n.unix(), s.utc = n.utc().format(), s.cog = u, s.sog = Math.round(f / ((l.positionTime - a.positionTime) / 3600) * 100) / 100;
@@ -966,47 +966,47 @@ class v {
966
966
  * @param coordinate
967
967
  * @param positions
968
968
  */
969
- static deadReckoningTime(e, t) {
970
- t = JSON.parse(JSON.stringify(t)), t.sort((a, l) => (a.positionTime || 0) - (l.positionTime || 0));
969
+ static deadReckoningTime(t, e) {
970
+ e = JSON.parse(JSON.stringify(e)), e.sort((a, l) => (a.positionTime || 0) - (l.positionTime || 0));
971
971
  let n = Number.MAX_SAFE_INTEGER, s = Number.MAX_SAFE_INTEGER;
972
- for (let a = 0; a < t.length - 1; a++) {
973
- const l = t[a], u = t[a + 1], f = v.calculatePointToLineDistance(e, l, u);
972
+ for (let a = 0; a < e.length - 1; a++) {
973
+ const l = e[a], u = e[a + 1], f = v.calculatePointToLineDistance(t, l, u);
974
974
  f < n && (n = f, s = a);
975
975
  }
976
- const o = t[s], i = t[s + 1], r = v.calculateDistance(o, e), c = v.calculateDistance(i, e);
977
- if (r === 0)
978
- e = o;
976
+ const o = e[s], r = e[s + 1], i = v.calculateDistance(o, t), c = v.calculateDistance(r, t);
977
+ if (i === 0)
978
+ t = o;
979
979
  else if (c === 0)
980
- e = i;
980
+ t = r;
981
981
  else {
982
- const a = o.positionTime || 0, l = i.positionTime || 0, u = v.calculateDistance(o, i);
983
- e.positionTime = Math.round(a + (l - a) * (r / u));
982
+ const a = o.positionTime || 0, l = r.positionTime || 0, u = v.calculateDistance(o, r);
983
+ t.positionTime = Math.round(a + (l - a) * (i / u));
984
984
  }
985
- return e.utc = e.positionTime ? b.unix(e.positionTime).utc().format() : void 0, e.positionTime ? e : void 0;
985
+ return t.utc = t.positionTime ? b.unix(t.positionTime).utc().format() : void 0, t.positionTime ? t : void 0;
986
986
  }
987
987
  /**
988
988
  * 翻转轨迹
989
989
  * @param route
990
990
  */
991
- static reverseRoute(e) {
992
- const t = [];
993
- for (const n of e)
994
- t.push(n.reverse());
995
- return t;
991
+ static reverseRoute(t) {
992
+ const e = [];
993
+ for (const n of t)
994
+ e.push(n.reverse());
995
+ return e;
996
996
  }
997
997
  /**
998
998
  * 翻转坐标
999
999
  * @param coordinates
1000
1000
  */
1001
- static reverseCoordinates(e) {
1002
- return e.reverse();
1001
+ static reverseCoordinates(t) {
1002
+ return t.reverse();
1003
1003
  }
1004
1004
  /**
1005
1005
  * XML转义
1006
1006
  * @param s
1007
1007
  */
1008
- static xmlEscape(e) {
1009
- return e == null ? "" : String(e).trim().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
1008
+ static xmlEscape(t) {
1009
+ return t == null ? "" : String(t).trim().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
1010
1010
  }
1011
1011
  /**
1012
1012
  * 路径转RTZ 1.2
@@ -1016,9 +1016,9 @@ class v {
1016
1016
  * @see https://cirm.org/api/documents/download/64?documents/October2022/bWjrTyyfNGseK9ch3TKf.xsd
1017
1017
  *
1018
1018
  */
1019
- static waypoints2RTZ(e, t) {
1019
+ static waypoints2RTZ(t, e) {
1020
1020
  const s = [];
1021
- 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(e)}"></routeInfo>`), s.push(...v.toRTZWaypoints(t, 6)), s.push("</route>"), s.join(`
1021
+ 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(`
1022
1022
  `);
1023
1023
  }
1024
1024
  /**
@@ -1027,30 +1027,30 @@ class v {
1027
1027
  * @param waypoints 途径点
1028
1028
  * @see https://cirm.org/rtz-xml-schemas
1029
1029
  */
1030
- static waypoints2RTZ10(e, t, n = !0) {
1030
+ static waypoints2RTZ10(t, e, n = !0) {
1031
1031
  const o = [];
1032
- return o.push('<?xml version="1.0" encoding="UTF-8"?>'), o.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'), o.push(` <routeInfo routeName="${v.xmlEscape(e)}"></routeInfo>`), o.push(...v.toRTZWaypoints(t, 6, n)), o.push("</route>"), o.join(`
1032
+ return o.push('<?xml version="1.0" encoding="UTF-8"?>'), o.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'), o.push(` <routeInfo routeName="${v.xmlEscape(t)}"></routeInfo>`), o.push(...v.toRTZWaypoints(e, 6, n)), o.push("</route>"), o.join(`
1033
1033
  `);
1034
1034
  }
1035
- static toRTZWaypoints(e, t = 6, n = !0) {
1035
+ static toRTZWaypoints(t, e = 6, n = !0) {
1036
1036
  const s = [];
1037
1037
  s.push(" <waypoints>");
1038
- for (let o = 0; o < e.length; o++) {
1039
- const i = e[o], r = o + 1, c = (i.lat ?? "").toFixed ? i.lat.toFixed(t).padEnd(t + 2, "0") : i.lat, a = (i.lng ?? "").toFixed ? i.lng.toFixed(t).padEnd(t + 2, "0") : i.lng, l = [`id="${r}"`, 'revision="0"'];
1040
- if (i.name && l.push(`name="${v.xmlEscape(i.name)}"`), s.push(` <waypoint ${l.join(" ")}>`), s.push(` <position lat="${v.xmlEscape(c)}" lon="${v.xmlEscape(a)}" />`), o > 0) {
1041
- const u = i.gcToPrevious ? "Orthodrome" : "Loxodrome";
1038
+ for (let o = 0; o < t.length; o++) {
1039
+ const r = t[o], i = o + 1, c = (r.lat ?? "").toFixed ? r.lat.toFixed(e).padEnd(e + 2, "0") : r.lat, a = (r.lng ?? "").toFixed ? r.lng.toFixed(e).padEnd(e + 2, "0") : r.lng, l = [`id="${i}"`, 'revision="0"'];
1040
+ if (r.name && l.push(`name="${v.xmlEscape(r.name)}"`), s.push(` <waypoint ${l.join(" ")}>`), s.push(` <position lat="${v.xmlEscape(c)}" lon="${v.xmlEscape(a)}" />`), o > 0) {
1041
+ const u = r.gcToPrevious ? "Orthodrome" : "Loxodrome";
1042
1042
  s.push(` <leg geometryType="${u}" />`);
1043
1043
  }
1044
1044
  if (n) {
1045
1045
  const u = [];
1046
- if (i.description && u.push(` <description>${v.xmlEscape(i.description)}</description>`), i.utc)
1047
- u.push(` <time>${v.xmlEscape(i.utc)}</time>`);
1048
- else if (i.positionTime)
1046
+ if (r.description && u.push(` <description>${v.xmlEscape(r.description)}</description>`), r.utc)
1047
+ u.push(` <time>${v.xmlEscape(r.utc)}</time>`);
1048
+ else if (r.positionTime)
1049
1049
  try {
1050
- u.push(` <time>${v.xmlEscape(b.unix(i.positionTime).utc().format())}</time>`);
1050
+ u.push(` <time>${v.xmlEscape(b.unix(r.positionTime).utc().format())}</time>`);
1051
1051
  } catch {
1052
1052
  }
1053
- 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>"));
1053
+ r.cog !== void 0 && u.push(` <cog>${v.xmlEscape(r.cog)}</cog>`), r.sog !== void 0 && u.push(` <sog>${v.xmlEscape(r.sog)}</sog>`), u.length && (s.push(" <extensions>"), s.push(...u), s.push(" </extensions>"));
1054
1054
  }
1055
1055
  s.push(" </waypoint>");
1056
1056
  }
@@ -1063,15 +1063,15 @@ class v {
1063
1063
  * @param waypoints 途径点
1064
1064
  * @param options.precision 经纬度小数位数,默认6
1065
1065
  */
1066
- static waypoints2CSV(e, t, n) {
1067
- X.debug("keep name for waypoints2CSV for legacy compatibility only", e);
1068
- const s = (n == null ? void 0 : n.precision) ?? 6, o = t.some((p) => p.name), i = t.some((p) => p.description), r = t.some((p) => p.port != null), c = t.some((p) => p.stbd != null), a = t.some((p) => p.arrRad != null), l = t.some((p) => p.speed != null), u = t.some((p, S) => S > 0 && p.gcToPrevious != null), f = t.some((p) => p.bearing != null), h = t.some((p) => p.distanceFromPrevious != null), g = ["WPT No.", "Latitude", "Longitude"];
1069
- o && g.push("Name"), i && g.push("Description"), u && g.push("Leg"), f && g.push("Bearing[deg]"), h && g.push("Distance[NM]"), l && g.push("Speed[kn]"), r && g.push("PORT XTD[NM]"), c && g.push("STBD XTD[NM]"), a && g.push("Arr.Rad[NM]");
1066
+ static waypoints2CSV(t, e, n) {
1067
+ X.debug("keep name for waypoints2CSV for legacy compatibility only", t);
1068
+ const s = (n == null ? void 0 : n.precision) ?? 6, o = e.some((p) => p.name), r = e.some((p) => p.description), i = e.some((p) => p.port != null), c = e.some((p) => p.stbd != null), a = e.some((p) => p.arrRad != null), l = e.some((p) => p.speed != null), u = e.some((p, S) => S > 0 && p.gcToPrevious != null), f = e.some((p) => p.bearing != null), h = e.some((p) => p.distanceFromPrevious != null), g = ["WPT No.", "Latitude", "Longitude"];
1069
+ o && g.push("Name"), r && g.push("Description"), u && g.push("Leg"), f && g.push("Bearing[deg]"), h && g.push("Distance[NM]"), l && g.push("Speed[kn]"), i && g.push("PORT XTD[NM]"), c && g.push("STBD XTD[NM]"), a && g.push("Arr.Rad[NM]");
1070
1070
  const m = [];
1071
1071
  m.push(g.map((p) => v.csvEscapeField(p)).join(","));
1072
- for (let p = 0; p < t.length; p++) {
1073
- const S = t[p], x = [];
1074
- x.push((p + 1).toString()), x.push(S.lat.toFixed(s)), x.push(S.lng.toFixed(s)), o && x.push(S.name ?? ""), i && x.push(S.description ?? ""), u && x.push(p === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), f && x.push(S.bearing != null ? String(S.bearing) : ""), h && x.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), l && x.push(S.speed != null ? String(S.speed) : ""), r && x.push(S.port != null ? String(S.port) : ""), c && x.push(S.stbd != null ? String(S.stbd) : ""), a && x.push(S.arrRad != null ? String(S.arrRad) : ""), m.push(x.map((M) => v.csvEscapeField(M)).join(","));
1072
+ for (let p = 0; p < e.length; p++) {
1073
+ const S = e[p], x = [];
1074
+ x.push((p + 1).toString()), x.push(S.lat.toFixed(s)), x.push(S.lng.toFixed(s)), o && x.push(S.name ?? ""), r && x.push(S.description ?? ""), u && x.push(p === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), f && x.push(S.bearing != null ? String(S.bearing) : ""), h && x.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), l && x.push(S.speed != null ? String(S.speed) : ""), i && x.push(S.port != null ? String(S.port) : ""), c && x.push(S.stbd != null ? String(S.stbd) : ""), a && x.push(S.arrRad != null ? String(S.arrRad) : ""), m.push(x.map((M) => v.csvEscapeField(M)).join(","));
1075
1075
  }
1076
1076
  return m.join(`
1077
1077
  `);
@@ -1087,20 +1087,20 @@ class v {
1087
1087
  * @param options.precision 经纬度小数位数,默认6
1088
1088
  * @returns Uint8Array 二进制数据,可直接用于 new Blob([result], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
1089
1089
  */
1090
- static waypoints2XLSX(e, t, n) {
1091
- const s = (n == null ? void 0 : n.precision) ?? 6, o = e || "Route", i = t.some((P) => P.name), r = t.some((P) => P.description), c = t.some((P) => P.port != null), a = t.some((P) => P.stbd != null), l = t.some((P) => P.arrRad != null), u = t.some((P) => P.speed != null), f = t.some((P, I) => I > 0 && P.gcToPrevious != null), h = t.some((P) => P.bearing != null), g = t.some((P) => P.distanceFromPrevious != null), m = ["WPT No.", "Latitude", "Longitude"];
1092
- i && m.push("Name"), r && m.push("Description"), f && m.push("Leg"), h && m.push("Bearing[deg]"), g && m.push("Distance[NM]"), u && m.push("Speed[kn]"), c && m.push("PORT XTD[NM]"), a && m.push("STBD XTD[NM]"), l && m.push("Arr.Rad[NM]");
1090
+ static waypoints2XLSX(t, e, n) {
1091
+ const s = (n == null ? void 0 : n.precision) ?? 6, o = t || "Route", r = e.some((P) => P.name), i = e.some((P) => P.description), c = e.some((P) => P.port != null), a = e.some((P) => P.stbd != null), l = e.some((P) => P.arrRad != null), u = e.some((P) => P.speed != null), f = e.some((P, I) => I > 0 && P.gcToPrevious != null), h = e.some((P) => P.bearing != null), g = e.some((P) => P.distanceFromPrevious != null), m = ["WPT No.", "Latitude", "Longitude"];
1092
+ r && m.push("Name"), i && m.push("Description"), f && m.push("Leg"), h && m.push("Bearing[deg]"), g && m.push("Distance[NM]"), u && m.push("Speed[kn]"), c && m.push("PORT XTD[NM]"), a && m.push("STBD XTD[NM]"), l && m.push("Arr.Rad[NM]");
1093
1093
  const p = (P) => P == null ? "" : String(P).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1094
1094
  let x = `<row r="1">${m.map((P, I) => `<c r="${z(I)}1" s="1" t="inlineStr"><is><t>${p(P)}</t></is></c>`).join("")}</row>`;
1095
- for (let P = 0; P < t.length; P++) {
1096
- const I = t[P], E = P + 2, B = [], Z = (W, j) => B.push(`<c r="${z(W)}${E}"><v>${j}</v></c>`), A = (W, j) => B.push(`<c r="${z(W)}${E}" t="inlineStr"><is><t>${p(j)}</t></is></c>`), k = (W, j) => {
1095
+ for (let P = 0; P < e.length; P++) {
1096
+ const I = e[P], E = P + 2, B = [], Z = (W, j) => B.push(`<c r="${z(W)}${E}"><v>${j}</v></c>`), A = (W, j) => B.push(`<c r="${z(W)}${E}" t="inlineStr"><is><t>${p(j)}</t></is></c>`), k = (W, j) => {
1097
1097
  j != null ? Z(W, j) : A(W, "");
1098
1098
  };
1099
1099
  Z(0, P + 1), A(1, d.lat2pretty(I.lat, s).pretty), A(2, d.lng2pretty(I.lng, s).pretty);
1100
1100
  let D = 3;
1101
- i && (A(D, I.name ?? ""), D++), r && (A(D, I.description ?? ""), D++), f && (A(D, P === 0 ? "" : I.gcToPrevious ? "GC" : "RL"), D++), h && (k(D, I.bearing), D++), g && (k(D, I.distanceFromPrevious), D++), u && (k(D, I.speed), D++), c && (k(D, I.port), D++), a && (k(D, I.stbd), D++), l && (k(D, I.arrRad), D++), x += `<row r="${E}">${B.join("")}</row>`;
1101
+ r && (A(D, I.name ?? ""), D++), i && (A(D, I.description ?? ""), D++), f && (A(D, P === 0 ? "" : I.gcToPrevious ? "GC" : "RL"), D++), h && (k(D, I.bearing), D++), g && (k(D, I.distanceFromPrevious), D++), u && (k(D, I.speed), D++), c && (k(D, I.port), D++), a && (k(D, I.stbd), D++), l && (k(D, I.arrRad), D++), x += `<row r="${E}">${B.join("")}</row>`;
1102
1102
  }
1103
- const M = "0." + "0".repeat(s), y = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>' + x + "</sheetData></worksheet>", N = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>', w = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>', q = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="' + p(o) + '" sheetId="1" r:id="rId1"/></sheets></workbook>', U = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>', L = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><numFmts count="1"><numFmt numFmtId="164" formatCode="' + M + '"/></numFmts><fonts count="2"><font><sz val="11"/><name val="Arial"/></font><font><b/><sz val="11"/><name val="Arial"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="none"/></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="1" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/><xf numFmtId="164" fontId="0" applyNumberFormat="1"/></cellXfs></styleSheet>', O = new TextEncoder();
1103
+ const M = "0." + "0".repeat(s), y = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>' + x + "</sheetData></worksheet>", N = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>', w = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>', q = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="' + p(o) + '" sheetId="1" r:id="rId1"/></sheets></workbook>', U = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>', L = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><numFmts count="1"><numFmt numFmtId="164" formatCode="' + M + '"/></numFmts><fonts count="2"><font><sz val="11"/><name val="Arial"/></font><font><b/><sz val="11"/><name val="Arial"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="2"><border><left/><right/><top/><bottom/><diagonal/></border><border><bottom style="thin"><color auto="1"/></bottom></border></borders><cellStyleXfs count="1"><xf/></cellStyleXfs><cellXfs count="3"><xf/><xf fontId="1" fillId="0" borderId="1" applyFont="1" applyBorder="1"/><xf numFmtId="164" fontId="0" applyNumberFormat="1"/></cellXfs></styleSheet>', O = new TextEncoder();
1104
1104
  return _([
1105
1105
  { name: "[Content_Types].xml", data: O.encode(N) },
1106
1106
  { name: "_rels/.rels", data: O.encode(w) },
@@ -1113,44 +1113,44 @@ class v {
1113
1113
  /**
1114
1114
  * RFC 4180 CSV字段转义:含逗号、双引号、换行时用双引号包裹,内部双引号翻倍
1115
1115
  */
1116
- static csvEscapeField(e) {
1117
- if (e == null)
1116
+ static csvEscapeField(t) {
1117
+ if (t == null)
1118
1118
  return "";
1119
- const t = String(e);
1120
- return t.includes(",") || t.includes('"') || t.includes(`
1121
- `) || t.includes("\r") ? `"${t.replace(/"/g, '""')}"` : t;
1119
+ const e = String(t);
1120
+ return e.includes(",") || e.includes('"') || e.includes(`
1121
+ `) || e.includes("\r") ? `"${e.replace(/"/g, '""')}"` : e;
1122
1122
  }
1123
1123
  /**
1124
1124
  * 十进制度数转NMEA度分格式 (DDMM.MM / DDDMM.MM)
1125
1125
  * @param value 十进制度数
1126
1126
  * @param isLat true为纬度,false为经度
1127
1127
  */
1128
- static decimalToNmeaDm(e, t) {
1129
- const n = Math.abs(e), s = Math.floor(n), o = (n - s) * 60, i = t ? `${s.toString().padStart(2, "0")}${o.toFixed(2).padStart(5, "0")}` : `${s.toString().padStart(3, "0")}${o.toFixed(2).padStart(5, "0")}`, r = t ? e >= 0 ? "N" : "S" : e >= 0 ? "E" : "W";
1130
- return { dm: i, dir: r };
1128
+ static decimalToNmeaDm(t, e) {
1129
+ const n = Math.abs(t), s = Math.floor(n), o = (n - s) * 60, r = e ? `${s.toString().padStart(2, "0")}${o.toFixed(2).padStart(5, "0")}` : `${s.toString().padStart(3, "0")}${o.toFixed(2).padStart(5, "0")}`, i = e ? t >= 0 ? "N" : "S" : t >= 0 ? "E" : "W";
1130
+ return { dm: r, dir: i };
1131
1131
  }
1132
1132
  /**
1133
1133
  * 计算NMEA 0183校验和 ($与*之间所有字符的异或,两字符十六进制大写)
1134
1134
  * @param sentence $与*之间的字符串
1135
1135
  */
1136
- static nmeaChecksum(e) {
1137
- let t = 0;
1138
- for (let n = 0; n < e.length; n++)
1139
- t ^= e.charCodeAt(n);
1140
- return t.toString(16).toUpperCase().padStart(2, "0");
1136
+ static nmeaChecksum(t) {
1137
+ let e = 0;
1138
+ for (let n = 0; n < t.length; n++)
1139
+ e ^= t.charCodeAt(n);
1140
+ return e.toString(16).toUpperCase().padStart(2, "0");
1141
1141
  }
1142
1142
  /**
1143
1143
  * 路径转NMEA 0183 WPL航点语句
1144
1144
  * @param waypoints 途径点
1145
1145
  * @returns 多条$GPWPL语句,以\r\n分隔
1146
1146
  */
1147
- static waypoints2NMEA(e) {
1148
- const t = [];
1149
- for (let n = 0; n < e.length; n++) {
1150
- const s = e[n], o = 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")}`, c = `GPWPL,${o.dm},${o.dir},${i.dm},${i.dir},${r}`, a = v.nmeaChecksum(c);
1151
- t.push(`$${c}*${a}`);
1147
+ static waypoints2NMEA(t) {
1148
+ const e = [];
1149
+ for (let n = 0; n < t.length; n++) {
1150
+ const s = t[n], o = v.decimalToNmeaDm(s.lat, !0), r = v.decimalToNmeaDm(s.lng, !1), i = s.name ? String(s.name).slice(0, 6) : `WPT${(n + 1).toString().padStart(3, "0")}`, c = `GPWPL,${o.dm},${o.dir},${r.dm},${r.dir},${i}`, a = v.nmeaChecksum(c);
1151
+ e.push(`$${c}*${a}`);
1152
1152
  }
1153
- return t.join(`\r
1153
+ return e.join(`\r
1154
1154
  `);
1155
1155
  }
1156
1156
  /**
@@ -1165,19 +1165,19 @@ class v {
1165
1165
  * avgSpeed: number // 平均航速,单位节
1166
1166
  * }
1167
1167
  */
1168
- static coordinatesSummary(e, t = 3) {
1169
- if (e.length > 1) {
1170
- const n = e[0], s = e[e.length - 1], o = (n == null ? void 0 : n.positionTime) < (s == null ? void 0 : s.positionTime) ? b.unix(n == null ? void 0 : n.positionTime) : b.unix(s == null ? void 0 : s.positionTime), i = (n == null ? void 0 : n.positionTime) > (s == null ? void 0 : s.positionTime) ? b.unix(n == null ? void 0 : n.positionTime) : b.unix(s == null ? void 0 : s.positionTime), r = Math.round(i.diff(o, "hours", !0) * 100) / 100, c = this.generateRouteAccordingToWaypoints(e, !0, !0), a = this.calculateRouteDistance(c), u = K.inspectStoppages(e, t).reduce(
1168
+ static coordinatesSummary(t, e = 3) {
1169
+ if (t.length > 1) {
1170
+ const n = t[0], s = t[t.length - 1], o = (n == null ? void 0 : n.positionTime) < (s == null ? void 0 : s.positionTime) ? b.unix(n == null ? void 0 : n.positionTime) : b.unix(s == null ? void 0 : s.positionTime), r = (n == null ? void 0 : n.positionTime) > (s == null ? void 0 : s.positionTime) ? b.unix(n == null ? void 0 : n.positionTime) : b.unix(s == null ? void 0 : s.positionTime), i = Math.round(r.diff(o, "hours", !0) * 100) / 100, c = this.generateRouteAccordingToWaypoints(t, !0, !0), a = this.calculateRouteDistance(c), u = K.inspectStoppages(t, e).reduce(
1171
1171
  (h, g) => (h.duration += g.duration, h.distance += g.distance, h),
1172
1172
  { hours: 0, distance: 0, spd: 0, duration: 0 }
1173
1173
  );
1174
1174
  u.hours = Math.round(u.duration / 3600 * 100) / 100, u.distance = Math.round(u.distance * 100) / 100, u.spd = u.hours ? Math.round(u.distance / u.hours * 100) / 100 : 0;
1175
- const f = r ? Math.round((a - u.distance) / (r - u.hours) * 100) / 100 : 0;
1175
+ const f = i ? Math.round((a - u.distance) / (i - u.hours) * 100) / 100 : 0;
1176
1176
  return {
1177
1177
  begin: o.utc().format(),
1178
- end: i.utc().format(),
1178
+ end: r.utc().format(),
1179
1179
  distance: Math.round((a - u.distance) * 100) / 100,
1180
- hours: Math.round((r - u.hours) * 100) / 100,
1180
+ hours: Math.round((i - u.hours) * 100) / 100,
1181
1181
  avgSpeed: f,
1182
1182
  stoppage: u
1183
1183
  };
@@ -1199,18 +1199,18 @@ class v {
1199
1199
  * hour: Coordinate
1200
1200
  * }
1201
1201
  */
1202
- static pickUTCSampleFromSpeed(e, t) {
1202
+ static pickUTCSampleFromSpeed(t, e) {
1203
1203
  var l, u, f;
1204
- if (!((u = (l = t == null ? void 0 : t.sample) == null ? void 0 : l.hours) != null && u.length))
1204
+ if (!((u = (l = e == null ? void 0 : e.sample) == null ? void 0 : l.hours) != null && u.length))
1205
1205
  return { routes: [], hour: void 0 };
1206
- const n = t.sample.hours.at(0), s = b.utc(e), o = b.utc(t.eta), i = s.isAfter(o) ? o : s;
1207
- let r = t.sample.all.find((h) => h.eta === i.format());
1208
- if (!r) {
1209
- const h = t.sample.all.filter((N) => b.utc(N.eta).isBefore(i)).at(-1), g = this.calculateSubRoute(h, t.route);
1210
- r = (f = this.calculateNextCoordinateAlongRoute(h, h.speed * i.diff(b(h.etd), "hours", !0), g)) == null ? void 0 : f.coordinate;
1211
- const { cFactor: m, cog: p, wxFactor: S, meteo: x } = h, M = Math.round(r.distanceFromPrevious * 1e4) / 1e4, y = Math.round((M + h.distanceFromStart) * 1e4) / 1e4;
1212
- r = {
1213
- ...r,
1206
+ const n = e.sample.hours.at(0), s = b.utc(t), o = b.utc(e.eta), r = s.isAfter(o) ? o : s;
1207
+ let i = e.sample.all.find((h) => h.eta === r.format());
1208
+ if (!i) {
1209
+ const h = e.sample.all.filter((N) => b.utc(N.eta).isBefore(r)).at(-1), g = this.calculateSubRoute(h, e.route);
1210
+ i = (f = this.calculateNextCoordinateAlongRoute(h, h.speed * r.diff(b(h.etd), "hours", !0), g)) == null ? void 0 : f.coordinate;
1211
+ const { cFactor: m, cog: p, wxFactor: S, meteo: x } = h, M = Math.round(i.distanceFromPrevious * 1e4) / 1e4, y = Math.round((M + h.distanceFromStart) * 1e4) / 1e4;
1212
+ i = {
1213
+ ...i,
1214
1214
  cFactor: m,
1215
1215
  cog: p,
1216
1216
  speed: h.speed,
@@ -1218,15 +1218,15 @@ class v {
1218
1218
  distanceFromStart: y,
1219
1219
  distanceFromPrevious: M,
1220
1220
  meteo: x,
1221
- eta: i.format(),
1222
- etd: i.format()
1221
+ eta: r.format(),
1222
+ etd: r.format()
1223
1223
  };
1224
1224
  }
1225
- r.distanceToGo = Math.round((t.distance - r.distanceFromStart) * 100) / 100, r.timeToGo = Math.round(o.diff(r.etd, "hours", !0) * 100) / 100;
1226
- const c = this.calculateRangeWaypoints(n, r, t.route);
1225
+ i.distanceToGo = Math.round((e.distance - i.distanceFromStart) * 100) / 100, i.timeToGo = Math.round(o.diff(i.etd, "hours", !0) * 100) / 100;
1226
+ const c = this.calculateRangeWaypoints(n, i, e.route);
1227
1227
  return {
1228
1228
  routes: this.generateRouteAccordingToWaypoints(c),
1229
- hour: r
1229
+ hour: i
1230
1230
  };
1231
1231
  }
1232
1232
  /**
@@ -1239,13 +1239,13 @@ class v {
1239
1239
  * hour: Coordinate
1240
1240
  * }
1241
1241
  */
1242
- static pickUTCSampleFromRoute(e, t, n) {
1242
+ static pickUTCSampleFromRoute(t, e, n) {
1243
1243
  var h;
1244
- const s = this.calculateSubRoute(t, n), o = this.calculateRouteDistance(s), i = o / t.speed, r = b.utc(e), c = b(t.etd), a = (h = this.calculateNextCoordinateAlongRoute(t, t.speed * r.diff(b(t.etd), "hours", !0), s)) == null ? void 0 : h.coordinate;
1245
- a.speed = t.speed;
1244
+ const s = this.calculateSubRoute(e, n), o = this.calculateRouteDistance(s), r = o / e.speed, i = b.utc(t), c = b(e.etd), a = (h = this.calculateNextCoordinateAlongRoute(e, e.speed * i.diff(b(e.etd), "hours", !0), s)) == null ? void 0 : h.coordinate;
1245
+ a.speed = e.speed;
1246
1246
  const l = c.clone().add(a.hourFromPrevious, "hour");
1247
- 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((o - a.distanceFromStart) * 100) / 100, a.timeToGo = Math.round(c.clone().add(i, "hour").diff(b(a.etd), "hour") * 100) / 100;
1248
- const u = this.calculateRangeWaypoints(t, a, n);
1247
+ a.eta = Math.abs(l.diff(i, "second")) < 2 ? i.format() : l.format(), a.etd = a.eta, a.distanceFromStart = Math.round(a.distanceFromPrevious * 100) / 100, a.distanceToGo = Math.round((o - a.distanceFromStart) * 100) / 100, a.timeToGo = Math.round(c.clone().add(r, "hour").diff(b(a.etd), "hour") * 100) / 100;
1248
+ const u = this.calculateRangeWaypoints(e, a, n);
1249
1249
  return {
1250
1250
  routes: this.generateRouteAccordingToWaypoints(u),
1251
1251
  hour: a
@@ -1256,9 +1256,9 @@ class v {
1256
1256
  * @param bearing 航首向
1257
1257
  * @param degree 要素角度,如 swell.degree
1258
1258
  */
1259
- static includedAngle(e, t) {
1260
- X == null || X.debug("calculate bearing via: %j", { bearing: e, degree: t });
1261
- let n = Math.abs(e % 360 - (t % 360 || 0));
1259
+ static includedAngle(t, e) {
1260
+ X == null || X.debug("calculate bearing via: %j", { bearing: t, degree: e });
1261
+ let n = Math.abs(t % 360 - (e % 360 || 0));
1262
1262
  return n = n > 180 ? 360 - n : n, n;
1263
1263
  }
1264
1264
  }
@@ -1268,28 +1268,28 @@ try {
1268
1268
  } catch {
1269
1269
  } finally {
1270
1270
  }
1271
- class re {
1271
+ class it {
1272
1272
  /**
1273
1273
  * 将原始数据转换为geojson
1274
1274
  * @param raw
1275
1275
  */
1276
- static convert2Geojson(e) {
1276
+ static convert2Geojson(t) {
1277
1277
  var n, s, o;
1278
- const t = T.featureCollection([]);
1279
- for (const i of e) {
1280
- const r = (n = i.history) == null ? void 0 : n[0];
1281
- if (i.forecasts) {
1282
- r && r.wind && (r.wind.kts = r.kts);
1283
- for (const c of i.forecasts) {
1278
+ const e = T.featureCollection([]);
1279
+ for (const r of t) {
1280
+ const i = (n = r.history) == null ? void 0 : n[0];
1281
+ if (r.forecasts) {
1282
+ i && i.wind && (i.wind.kts = i.kts);
1283
+ for (const c of r.forecasts) {
1284
1284
  let a;
1285
- const l = [], u = [], f = b(c.date).utc(), h = `${i.name}-${c.model}`;
1285
+ const l = [], u = [], f = b(c.date).utc(), h = `${r.name}-${c.model}`;
1286
1286
  for (const m in c == null ? void 0 : c.hours) {
1287
1287
  const p = c.hours[m];
1288
1288
  a = a || p;
1289
1289
  const S = f.clone().add(Number(m), "hour"), x = T.point([p.lng, p.lat], {
1290
1290
  model: c.model,
1291
- name: i.name,
1292
- nameCn: i.nameCn,
1291
+ name: r.name,
1292
+ nameCn: r.nameCn,
1293
1293
  date: S.format(),
1294
1294
  hour: Number(m),
1295
1295
  format: S.format("MMM-DD/HHmm[Z]"),
@@ -1306,21 +1306,21 @@ class re {
1306
1306
  kts: void 0,
1307
1307
  deg: void 0
1308
1308
  };
1309
- if (r) {
1310
- const m = b(r.updated).utc();
1309
+ if (i) {
1310
+ const m = b(i.updated).utc();
1311
1311
  if (a) {
1312
- const S = v.calculateDistance(r, a), x = b(a.utc || a.updated).diff(m, "h", !0);
1313
- g.kts = Math.round(S / x * 100) / 100, g.deg = v.calculateBearing(r, a, !0, 0);
1312
+ const S = v.calculateDistance(i, a), x = b(a.utc || a.updated).diff(m, "h", !0);
1313
+ g.kts = Math.round(S / x * 100) / 100, g.deg = v.calculateBearing(i, a, !0, 0);
1314
1314
  }
1315
- const p = T.point([r.lng, r.lat], {
1315
+ const p = T.point([i.lng, i.lat], {
1316
1316
  model: c.model,
1317
- name: i.name,
1318
- nameCn: i.nameCn,
1317
+ name: r.name,
1318
+ nameCn: r.nameCn,
1319
1319
  date: m.format(),
1320
1320
  hour: 0,
1321
1321
  format: m.format("MMM-DD/HHmm[Z]"),
1322
- pressure: r.pressure > 1e4 ? d.roundPrecision((r == null ? void 0 : r.pressure) / 100, 0) : d.roundPrecision(r.pressure, 0),
1323
- wind: r.wind,
1322
+ pressure: i.pressure > 1e4 ? d.roundPrecision((i == null ? void 0 : i.pressure) / 100, 0) : d.roundPrecision(i.pressure, 0),
1323
+ wind: i.wind,
1324
1324
  movement: g,
1325
1325
  category: h,
1326
1326
  type: "forecast",
@@ -1329,74 +1329,74 @@ class re {
1329
1329
  });
1330
1330
  u.unshift(p), l.unshift(p.geometry.coordinates);
1331
1331
  }
1332
- if (t.features.push(...u), (l == null ? void 0 : l.length) > 1) {
1332
+ if (e.features.push(...u), (l == null ? void 0 : l.length) > 1) {
1333
1333
  const m = T.lineString(d.convertToMonotonicLng2(l), {
1334
- date: (r == null ? void 0 : r.updated) || (f == null ? void 0 : f.format()),
1335
- id: i.id || i.name,
1334
+ date: (i == null ? void 0 : i.updated) || (f == null ? void 0 : f.format()),
1335
+ id: r.id || r.name,
1336
1336
  model: c.model,
1337
- name: i.name,
1337
+ name: r.name,
1338
1338
  category: h,
1339
1339
  type: "forecast",
1340
1340
  movement: g
1341
1341
  });
1342
- t.features.push(m);
1342
+ e.features.push(m);
1343
1343
  }
1344
1344
  }
1345
1345
  }
1346
- if (t.features.sort((c, a) => c.properties.type === "forecast" && a.properties.type === "forecast" && c.geometry.type === "Point" && a.geometry.type === "Point" ? b(c.properties.date).valueOf() - b(a.properties.date).valueOf() : 0), (s = i.history) != null && s.length) {
1347
- const c = [], a = b(r == null ? void 0 : r.updated).utc(), l = b((o = i.history) == null ? void 0 : o.at(-1).updated).utc(), u = a.diff(l, "h") % 24 > 2 ? 24 : 12;
1348
- for (const f of i.history) {
1346
+ if (e.features.sort((c, a) => c.properties.type === "forecast" && a.properties.type === "forecast" && c.geometry.type === "Point" && a.geometry.type === "Point" ? b(c.properties.date).valueOf() - b(a.properties.date).valueOf() : 0), (s = r.history) != null && s.length) {
1347
+ const c = [], a = b(i == null ? void 0 : i.updated).utc(), l = b((o = r.history) == null ? void 0 : o.at(-1).updated).utc(), u = a.diff(l, "h") % 24 > 2 ? 24 : 12;
1348
+ for (const f of r.history) {
1349
1349
  const h = b(f.updated).utc(), g = h.isSameOrBefore(a) || h.isSame(l);
1350
1350
  g && a.add(-u, "h");
1351
1351
  const m = T.point([f.lng, f.lat], {
1352
- name: i.name,
1353
- nameCn: i.nameCn,
1352
+ name: r.name,
1353
+ nameCn: r.nameCn,
1354
1354
  date: h.format(),
1355
1355
  format: h.format("MMM-DD/HHmm[Z]"),
1356
1356
  pressure: f.pressure > 1e4 ? d.roundPrecision(f.pressure / 100, 0) : d.roundPrecision(f.pressure, 0),
1357
1357
  kts: f.kts,
1358
1358
  level: f.type,
1359
1359
  type: "history",
1360
- category: `${i.name}-history`,
1360
+ category: `${r.name}-history`,
1361
1361
  wind: f.wind,
1362
1362
  movement: f.movement,
1363
1363
  important: g
1364
1364
  });
1365
- t.features.push(m), c.push(m.geometry.coordinates);
1365
+ e.features.push(m), c.push(m.geometry.coordinates);
1366
1366
  }
1367
1367
  if (c.length === 1 && c.push(c[0]), c.length > 1) {
1368
1368
  const f = T.lineString(d.convertToMonotonicLng2(c), {
1369
- name: i.name,
1369
+ name: r.name,
1370
1370
  type: "history",
1371
- updated: r == null ? void 0 : r.updated,
1372
- pressure: (r == null ? void 0 : r.pressure) > 1e4 ? d.roundPrecision((r == null ? void 0 : r.pressure) / 100, 0) : d.roundPrecision(r == null ? void 0 : r.pressure, 0),
1373
- kts: r == null ? void 0 : r.kts,
1374
- level: r == null ? void 0 : r.type
1371
+ updated: i == null ? void 0 : i.updated,
1372
+ pressure: (i == null ? void 0 : i.pressure) > 1e4 ? d.roundPrecision((i == null ? void 0 : i.pressure) / 100, 0) : d.roundPrecision(i == null ? void 0 : i.pressure, 0),
1373
+ kts: i == null ? void 0 : i.kts,
1374
+ level: i == null ? void 0 : i.type
1375
1375
  });
1376
- t.features.push(f);
1376
+ e.features.push(f);
1377
1377
  }
1378
1378
  }
1379
1379
  }
1380
- return t;
1380
+ return e;
1381
1381
  }
1382
1382
  /**
1383
1383
  * 插值台风预报轨迹
1384
1384
  * @param tropicals
1385
1385
  * @param step
1386
1386
  */
1387
- static interpolate(e, t = 3) {
1388
- var o, i, r, c;
1389
- const n = (o = e == null ? void 0 : e.data) == null ? void 0 : o.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), s = [];
1387
+ static interpolate(t, e = 3) {
1388
+ var o, r, i, c;
1389
+ const n = (o = t == null ? void 0 : t.data) == null ? void 0 : o.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), s = [];
1390
1390
  for (const a of n) {
1391
1391
  const l = a.properties.name, u = a.properties.model, f = a.properties.showCircle, h = a.properties.disabled, g = b(a.properties.date).utc();
1392
- let m = t * 60;
1393
- const p = (i = e == null ? void 0 : e.data) == null ? void 0 : i.features.filter(
1392
+ let m = e * 60;
1393
+ const p = (r = t == null ? void 0 : t.data) == null ? void 0 : r.features.filter(
1394
1394
  (M) => M.geometry.type === "Point" && M.properties.type === "forecast" && M.properties.category === `${l}-${u}`
1395
1395
  );
1396
1396
  let S, x = g.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1397
1397
  for (; S = this.pickIndex(p, x), S <= p.length - 1; ) {
1398
1398
  if (S > 0) {
1399
- const M = p[S], y = S === 0 ? void 0 : p[S - 1], N = (m / 60 - ((r = y == null ? void 0 : y.properties) == null ? void 0 : r.hour)) / (M.properties.hour - ((c = y == null ? void 0 : y.properties) == null ? void 0 : c.hour)), w = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[0], M.geometry.coordinates[0], N), q = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[1], M.geometry.coordinates[1], N), U = T.point([w, q], {
1399
+ const M = p[S], y = S === 0 ? void 0 : p[S - 1], N = (m / 60 - ((i = y == null ? void 0 : y.properties) == null ? void 0 : i.hour)) / (M.properties.hour - ((c = y == null ? void 0 : y.properties) == null ? void 0 : c.hour)), w = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[0], M.geometry.coordinates[0], N), q = this.computeNumber(y == null ? void 0 : y.geometry.coordinates[1], M.geometry.coordinates[1], N), U = T.point([w, q], {
1400
1400
  name: l,
1401
1401
  model: u,
1402
1402
  category: M == null ? void 0 : M.properties.category,
@@ -1413,7 +1413,7 @@ class re {
1413
1413
  });
1414
1414
  s.push(U);
1415
1415
  }
1416
- m += t * 60, x = g.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1416
+ m += e * 60, x = g.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1417
1417
  }
1418
1418
  }
1419
1419
  return s;
@@ -1424,9 +1424,9 @@ class re {
1424
1424
  * @param tropical 台风数据 { history: any[], forecasts: any[] }
1425
1425
  * @param options
1426
1426
  */
1427
- static accelPassageAt(e, t) {
1428
- const { t1: n, t2: s, hr: o, hours: i } = this.tropicalCenterTwin(e, 24, t);
1429
- return { t1: n, t2: s, hr: o, hours: i };
1427
+ static accelPassageAt(t, e) {
1428
+ const { t1: n, t2: s, hr: o, hours: r } = this.tropicalCenterTwin(t, 24, e);
1429
+ return { t1: n, t2: s, hr: o, hours: r };
1430
1430
  }
1431
1431
  /**
1432
1432
  * 计算最佳绕航点
@@ -1439,32 +1439,32 @@ class re {
1439
1439
  * @param speed 前进速度
1440
1440
  * @param options
1441
1441
  */
1442
- static diversionPassageAt(e, t, n, s = {}) {
1443
- const { t1: o, t2: i, hr: r, hours: c } = this.tropicalCenterTwin(t, 24, s);
1444
- if (o && i) {
1442
+ static diversionPassageAt(t, e, n, s = {}) {
1443
+ const { t1: o, t2: r, hr: i, hours: c } = this.tropicalCenterTwin(e, 24, s);
1444
+ if (o && r) {
1445
1445
  if (!s.debug) {
1446
- const g = v.calculateDistance(e, o), m = v.calculateDistance(e, i);
1446
+ const g = v.calculateDistance(t, o), m = v.calculateDistance(t, r);
1447
1447
  if (g > 2 * n && m > 2 * n)
1448
1448
  return $ == null || $.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, g, m, {
1449
- from: e,
1449
+ from: t,
1450
1450
  t1: o,
1451
- t2: i,
1452
- hr: r
1451
+ t2: r,
1452
+ hr: i
1453
1453
  }), {};
1454
1454
  }
1455
- const a = v.calculateBearing(e, o), l = v.calculateBearing(o, i), u = Math.abs(a - l);
1455
+ const a = v.calculateBearing(t, o), l = v.calculateBearing(o, r), u = Math.abs(a - l);
1456
1456
  let f = 0;
1457
1457
  u < 180 ? f = u + 90 : u >= 180 && (f = u - 90);
1458
1458
  const h = v.calculateCoordinate(o, f, n);
1459
1459
  return $ == null || $.info("[%s] the right tangent position: %j", s.requestId, {
1460
- from: e,
1460
+ from: t,
1461
1461
  t1: o,
1462
- t2: i,
1462
+ t2: r,
1463
1463
  radius: n,
1464
1464
  bearing1: a,
1465
1465
  bearing2: l,
1466
1466
  right: h
1467
- }), { at: h, t1: o, t2: i, hr: Number(r), hours: c };
1467
+ }), { at: h, t1: o, t2: r, hr: Number(i), hours: c };
1468
1468
  }
1469
1469
  return {};
1470
1470
  }
@@ -1478,23 +1478,23 @@ class re {
1478
1478
  * @param radius 与台风中心的距离
1479
1479
  * @param options
1480
1480
  */
1481
- static driftPassageAt(e, t, n, s = {}) {
1482
- const { t1: o, t2: i, hr: r, hours: c } = this.tropicalCenterTwin(t, 24, s);
1483
- if (o && i) {
1481
+ static driftPassageAt(t, e, n, s = {}) {
1482
+ const { t1: o, t2: r, hr: i, hours: c } = this.tropicalCenterTwin(e, 24, s);
1483
+ if (o && r) {
1484
1484
  if (!s.debug) {
1485
- const h = v.calculateDistance(e, o), g = v.calculateDistance(e, i);
1485
+ const h = v.calculateDistance(t, o), g = v.calculateDistance(t, r);
1486
1486
  if (h > 2 * n && g > 2 * n)
1487
1487
  return $ == null || $.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, h, g, {
1488
- from: e,
1488
+ from: t,
1489
1489
  t1: o,
1490
- t2: i,
1491
- hr: r
1490
+ t2: r,
1491
+ hr: i
1492
1492
  }), {};
1493
1493
  }
1494
- const a = v.calculateBearing(e, o), l = v.calculateBearing(o, i), u = v.calculateDistance(e, o);
1495
- return { at: v.calculateCoordinate(o, a - l + 180, n < u ? n : u), t1: o, t2: i, hr: Number(r), hours: c };
1494
+ const a = v.calculateBearing(t, o), l = v.calculateBearing(o, r), u = v.calculateDistance(t, o);
1495
+ return { at: v.calculateCoordinate(o, a - l + 180, n < u ? n : u), t1: o, t2: r, hr: Number(i), hours: c };
1496
1496
  } else
1497
- return $ == null || $.info("[%s] no need drift: %j", s.requestId, { from: e, t1: o, t2: i, hr: r }), {};
1497
+ return $ == null || $.info("[%s] no need drift: %j", s.requestId, { from: t, t1: o, t2: r, hr: i }), {};
1498
1498
  }
1499
1499
  /**
1500
1500
  * 获取台风中心点对
@@ -1504,53 +1504,53 @@ class re {
1504
1504
  * @returns { t1: 当前台风中心点, t2: 未来hr小时台风中心点, hr: 未来台风中心点与当前台风中心点之间的时间差, hours: 未来24小时内所有台风中心点 }
1505
1505
  * @private
1506
1506
  */
1507
- static tropicalCenterTwin(e, t = 24, n = {}) {
1507
+ static tropicalCenterTwin(t, e = 24, n = {}) {
1508
1508
  var l, u, f, h, g;
1509
1509
  let s = {};
1510
- (l = e.forecasts) == null || l.forEach((m) => {
1510
+ (l = t.forecasts) == null || l.forEach((m) => {
1511
1511
  s = { ...m.hours, ...s };
1512
1512
  });
1513
- const o = ((u = e == null ? void 0 : e.history) == null ? void 0 : u[0]) || (s == null ? void 0 : s[(f = Object.keys(s)) == null ? void 0 : f[0]]);
1513
+ const o = ((u = t == null ? void 0 : t.history) == null ? void 0 : u[0]) || (s == null ? void 0 : s[(f = Object.keys(s)) == null ? void 0 : f[0]]);
1514
1514
  $ == null || $.info("[%s] the first tropical center: %j", n.requestId, o);
1515
- let i = (h = Object.keys(s || {}).filter((m) => Number(m) <= (t < 0 ? 24 : t))) == null ? void 0 : h.at(-1);
1516
- i || (i = (g = Object.keys(s || {}).filter((m) => Number(m) <= (t < 0 ? 24 : 2 * t))) == null ? void 0 : g.at(-1));
1517
- const r = s == null ? void 0 : s[i || -1];
1518
- $ == null || $.info("[%s] the second tropical center: %j in %d hrs", n.requestId, r, i);
1519
- const c = Object.keys(s || {}).filter((m) => Number(m) <= Number(i)), a = { 0: o };
1515
+ let r = (h = Object.keys(s || {}).filter((m) => Number(m) <= (e < 0 ? 24 : e))) == null ? void 0 : h.at(-1);
1516
+ r || (r = (g = Object.keys(s || {}).filter((m) => Number(m) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : g.at(-1));
1517
+ const i = s == null ? void 0 : s[r || -1];
1518
+ $ == null || $.info("[%s] the second tropical center: %j in %d hrs", n.requestId, i, r);
1519
+ const c = Object.keys(s || {}).filter((m) => Number(m) <= Number(r)), a = { 0: o };
1520
1520
  for (const m of c)
1521
1521
  a[m] = s[m];
1522
- return { t1: o, t2: r, hr: Number(i), hours: a };
1522
+ return { t1: o, t2: i, hr: Number(r), hours: a };
1523
1523
  }
1524
- static pickIndex(e, t) {
1524
+ static pickIndex(t, e) {
1525
1525
  let n = 0;
1526
- for (const s of e) {
1527
- if (b(s.properties.date).isAfter(t))
1526
+ for (const s of t) {
1527
+ if (b(s.properties.date).isAfter(e))
1528
1528
  return n === 0 ? -1 : n;
1529
1529
  n++;
1530
1530
  }
1531
1531
  return n;
1532
1532
  }
1533
- static computeNumber(e, t, n) {
1534
- if (e)
1535
- if (t) {
1536
- if (isNaN(e) && isNaN(t) && typeof e != "string" && typeof t != "string") {
1533
+ static computeNumber(t, e, n) {
1534
+ if (t)
1535
+ if (e) {
1536
+ if (isNaN(t) && isNaN(e) && typeof t != "string" && typeof e != "string") {
1537
1537
  const s = {};
1538
- for (const o in e)
1539
- s[o] = this.computeNumber(e[o], t[o], n);
1538
+ for (const o in t)
1539
+ s[o] = this.computeNumber(t[o], e[o], n);
1540
1540
  return s;
1541
1541
  }
1542
- return Math.round((e + (t - e) * n) * 100) / 100;
1542
+ return Math.round((t + (e - t) * n) * 100) / 100;
1543
1543
  } else
1544
- return e;
1544
+ return t;
1545
1545
  else
1546
- return t;
1546
+ return e;
1547
1547
  }
1548
1548
  }
1549
1549
  typeof globalThis < "u" && typeof globalThis.Buffer > "u" && (globalThis.Buffer = {
1550
1550
  isBuffer(C) {
1551
1551
  return C instanceof Uint8Array;
1552
1552
  },
1553
- from(C, e) {
1553
+ from(C, t) {
1554
1554
  if (typeof C == "string")
1555
1555
  return new TextEncoder().encode(C);
1556
1556
  if (C instanceof ArrayBuffer)
@@ -1569,8 +1569,8 @@ try {
1569
1569
  function H() {
1570
1570
  if (typeof DOMParser < "u")
1571
1571
  return new DOMParser();
1572
- const { JSDOM: C } = require("jsdom"), { DOMParser: e } = new C("").window;
1573
- return new e();
1572
+ const { JSDOM: C } = require("jsdom"), { DOMParser: t } = new C("").window;
1573
+ return new t();
1574
1574
  }
1575
1575
  class F {
1576
1576
  /**
@@ -1580,8 +1580,8 @@ class F {
1580
1580
  * @param buf
1581
1581
  * @returns
1582
1582
  */
1583
- static toArrayBuffer(e) {
1584
- return e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
1583
+ static toArrayBuffer(t) {
1584
+ return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
1585
1585
  }
1586
1586
  /**
1587
1587
  * 基于turf画圆,返回GeoJSON Feature<Polygon>
@@ -1590,11 +1590,11 @@ class F {
1590
1590
  * @param radius 半径
1591
1591
  * @param options 步数、单位等选项
1592
1592
  */
1593
- static drawCircle(e, t, n, s = {}) {
1594
- const o = (s == null ? void 0 : s.steps) ?? 64, i = (s == null ? void 0 : s.units) ?? "nauticalmiles", r = (s == null ? void 0 : s.properties) ?? {}, c = T.point([e, t]), a = T.destination(c, n, 90, { units: i }), l = b.utc();
1595
- r.id = (s == null ? void 0 : s.id) || l.valueOf().toString();
1593
+ static drawCircle(t, e, n, s = {}) {
1594
+ const o = (s == null ? void 0 : s.steps) ?? 64, r = (s == null ? void 0 : s.units) ?? "nauticalmiles", i = (s == null ? void 0 : s.properties) ?? {}, c = T.point([t, e]), a = T.destination(c, n, 90, { units: r }), l = b.utc();
1595
+ i.id = (s == null ? void 0 : s.id) || l.valueOf().toString();
1596
1596
  const u = "circle";
1597
- return r.name = (s == null ? void 0 : s.name) || `${u}_${l.format()}`, r.radius = n, r.center = [e, t], r.end = a.geometry.coordinates.map((f) => d.roundPrecision(f, 9)), r.units = i, r.steps = o, r.shape = "circle", R.info("[%s] draw circle with %j", s == null ? void 0 : s.requestId, r), T.circle(c, n, { steps: o, units: i, properties: r });
1597
+ return i.name = (s == null ? void 0 : s.name) || `${u}_${l.format()}`, i.radius = n, i.center = [t, e], i.end = a.geometry.coordinates.map((f) => d.roundPrecision(f, 9)), i.units = r, i.steps = o, i.shape = "circle", R.info("[%s] draw circle with %j", s == null ? void 0 : s.requestId, i), T.circle(c, n, { steps: o, units: r, properties: i });
1598
1598
  }
1599
1599
  /**
1600
1600
  * 基于turf画矩形,返回GeoJSON Feature<Polygon>
@@ -1602,12 +1602,12 @@ class F {
1602
1602
  * @param end 对角线终点 [lng, lat]
1603
1603
  * @param options 选项
1604
1604
  */
1605
- static drawRect(e, t, n = {}) {
1605
+ static drawRect(t, e, n = {}) {
1606
1606
  const s = (n == null ? void 0 : n.properties) ?? {}, o = b.utc();
1607
1607
  s.id = (n == null ? void 0 : n.id) || o.valueOf().toString();
1608
- const i = "rect";
1609
- s.name = (n == null ? void 0 : n.name) || `${i}_${o.format()}`, s.start = e.map((l) => d.roundPrecision(l, 9)), s.end = t.map((l) => d.roundPrecision(l, 9)), s.shape = "rect", R.info("[%s] draw rect with %j", n == null ? void 0 : n.requestId, s);
1610
- const [r, c] = d.convertToMonotonicLng2([e, t]), a = [Math.min(r[0], c[0]), Math.min(r[1], c[1]), Math.max(r[0], c[0]), Math.max(r[1], c[1])];
1608
+ const r = "rect";
1609
+ s.name = (n == null ? void 0 : n.name) || `${r}_${o.format()}`, s.start = t.map((l) => d.roundPrecision(l, 9)), s.end = e.map((l) => d.roundPrecision(l, 9)), s.shape = "rect", R.info("[%s] draw rect with %j", n == null ? void 0 : n.requestId, s);
1610
+ const [i, c] = d.convertToMonotonicLng2([t, e]), a = [Math.min(i[0], c[0]), Math.min(i[1], c[1]), Math.max(i[0], c[0]), Math.max(i[1], c[1])];
1611
1611
  return T.bboxPolygon(a, { properties: s });
1612
1612
  }
1613
1613
  /**
@@ -1617,13 +1617,13 @@ class F {
1617
1617
  * @param options
1618
1618
  * @returns
1619
1619
  */
1620
- static drawLine(e, t = {}) {
1621
- const n = (t == null ? void 0 : t.properties) ?? {}, s = b.utc();
1622
- n.id = (t == null ? void 0 : t.id) || s.valueOf().toString();
1620
+ static drawLine(t, e = {}) {
1621
+ const n = (e == null ? void 0 : e.properties) ?? {}, s = b.utc();
1622
+ n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1623
1623
  const o = "line";
1624
- n.name = (t == null ? void 0 : t.name) || `${o}_${s.format()}`, n.shape = "line", R.info("[%s] draw line with %j", t == null ? void 0 : t.requestId, n);
1625
- const i = d.convertToMonotonicLng2(e);
1626
- return T.lineString(i, n);
1624
+ n.name = (e == null ? void 0 : e.name) || `${o}_${s.format()}`, n.shape = "line", R.info("[%s] draw line with %j", e == null ? void 0 : e.requestId, n);
1625
+ const r = d.convertToMonotonicLng2(t);
1626
+ return T.lineString(r, n);
1627
1627
  }
1628
1628
  /**
1629
1629
  * 基于turf画多边形,返回GeoJSON Feature<Polygon>
@@ -1631,13 +1631,13 @@ class F {
1631
1631
  * @param options
1632
1632
  * @returns
1633
1633
  */
1634
- static drawPolygon(e, t = {}) {
1635
- const n = (t == null ? void 0 : t.properties) ?? {}, s = b.utc();
1636
- n.id = (t == null ? void 0 : t.id) || s.valueOf().toString();
1634
+ static drawPolygon(t, e = {}) {
1635
+ const n = (e == null ? void 0 : e.properties) ?? {}, s = b.utc();
1636
+ n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1637
1637
  const o = "polygon";
1638
- n.name = (t == null ? void 0 : t.name) || `${o}_${s.format()}`, n.coordinates = e.map((r) => r.map((c) => d.roundPrecision(c, 9))), n.shape = "polygon", R.info("[%s] draw polygon with %j", t == null ? void 0 : t.requestId, n);
1639
- const i = d.convertToMonotonicLng2(e);
1640
- return T.polygon([i], n);
1638
+ n.name = (e == null ? void 0 : e.name) || `${o}_${s.format()}`, n.coordinates = t.map((i) => i.map((c) => d.roundPrecision(c, 9))), n.shape = "polygon", R.info("[%s] draw polygon with %j", e == null ? void 0 : e.requestId, n);
1639
+ const r = d.convertToMonotonicLng2(t);
1640
+ return T.polygon([r], n);
1641
1641
  }
1642
1642
  /**
1643
1643
  * 基于turf画点,返回GeoJSON Feature<Point>
@@ -1646,11 +1646,11 @@ class F {
1646
1646
  * @param options
1647
1647
  * @returns
1648
1648
  */
1649
- static drawPoint(e, t, n = {}) {
1649
+ static drawPoint(t, e, n = {}) {
1650
1650
  const s = (n == null ? void 0 : n.properties) ?? {}, o = b.utc();
1651
1651
  s.id = (n == null ? void 0 : n.id) || o.valueOf().toString();
1652
- const i = "point";
1653
- return s.name = (n == null ? void 0 : n.name) || `${i}_${o.format()}`, s.shape = "point", R.info("[%s] draw point with %j", n == null ? void 0 : n.requestId, s), T.point([t, e], s);
1652
+ const r = "point";
1653
+ return s.name = (n == null ? void 0 : n.name) || `${r}_${o.format()}`, s.shape = "point", R.info("[%s] draw point with %j", n == null ? void 0 : n.requestId, s), T.point([e, t], s);
1654
1654
  }
1655
1655
  /**
1656
1656
  * 解析ORM GeoJSON Feature (圆), 返回FeatureCollection
@@ -1659,29 +1659,29 @@ class F {
1659
1659
  * @returns
1660
1660
  * 如果feature是圆,则返回圆的中心、端点、半径线 和 边线四个Feature
1661
1661
  */
1662
- static parseCircle(e, t = {}) {
1662
+ static parseCircle(t, e = {}) {
1663
1663
  var s, o;
1664
- R.info("[%s] parse circle with %j", t == null ? void 0 : t.requestId, e.properties);
1665
- const n = e.properties || {};
1664
+ R.info("[%s] parse circle with %j", e == null ? void 0 : e.requestId, t.properties);
1665
+ const n = t.properties || {};
1666
1666
  if (n.shape == "circle") {
1667
- const i = b.utc();
1668
- n.id = (n == null ? void 0 : n.id) || i.valueOf().toString();
1669
- const r = n == null ? void 0 : n.id, c = ((s = n == null ? void 0 : n.center) == null ? void 0 : s.length) == 2 ? T.point(n.center) : T.centroid(e);
1667
+ const r = b.utc();
1668
+ n.id = (n == null ? void 0 : n.id) || r.valueOf().toString();
1669
+ const i = n == null ? void 0 : n.id, c = ((s = n == null ? void 0 : n.center) == null ? void 0 : s.length) == 2 ? T.point(n.center) : T.centroid(t);
1670
1670
  let a = "center";
1671
- c.properties = { id: `${a}_${r}`, parentId: r, name: a };
1671
+ c.properties = { id: `${a}_${i}`, parentId: i, name: a };
1672
1672
  const l = (n == null ? void 0 : n.units) || "nauticalmiles";
1673
1673
  let u = n == null ? void 0 : n.radius;
1674
1674
  if (!u) {
1675
- const g = T.polygonToLine(e);
1675
+ const g = T.polygonToLine(t);
1676
1676
  u = T.pointToLineDistance(c, g, { units: l });
1677
1677
  }
1678
1678
  a = "end";
1679
1679
  const f = ((o = n == null ? void 0 : n.end) == null ? void 0 : o.length) == 2 ? T.point(n.end) : T.destination(c, u, 90, { units: l });
1680
- f.properties = { id: `${a}_${r}`, parentId: r, name: a, radius: u, units: l };
1680
+ f.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l };
1681
1681
  const h = T.lineString([c.geometry.coordinates, f.geometry.coordinates]);
1682
- return a = "edge", h.properties = { id: `${a}_${r}`, parentId: r, name: a, radius: u, units: l }, T.featureCollection([c, f, h, e]);
1682
+ return a = "edge", h.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l }, T.featureCollection([c, f, h, t]);
1683
1683
  } else
1684
- return R.warn("[%s] not a orm-std circle, just return the original feature", t == null ? void 0 : t.requestId), T.featureCollection([e]);
1684
+ return R.warn("[%s] not a orm-std circle, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1685
1685
  }
1686
1686
  /**
1687
1687
  * 解析ORM GeoJSON Feature (矩形), 返回FeatureCollection
@@ -1690,19 +1690,19 @@ class F {
1690
1690
  * @returns
1691
1691
  * 如果feature是矩形,则返回矩形的四个顶点和矩形Feature
1692
1692
  */
1693
- static parseRect(e, t = {}) {
1694
- R.info("[%s] parse rect with %j", t == null ? void 0 : t.requestId, e.properties);
1695
- const n = e.properties || {};
1693
+ static parseRect(t, e = {}) {
1694
+ R.info("[%s] parse rect with %j", e == null ? void 0 : e.requestId, t.properties);
1695
+ const n = t.properties || {};
1696
1696
  if (n.shape == "rect") {
1697
1697
  const s = b.utc();
1698
1698
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1699
- const o = n == null ? void 0 : n.id, i = e.geometry.coordinates[0], c = ["sw", "nw", "ne", "se"].map((a, l) => {
1700
- const u = T.point(i[l]);
1699
+ const o = n == null ? void 0 : n.id, r = t.geometry.coordinates[0], c = ["sw", "nw", "ne", "se"].map((a, l) => {
1700
+ const u = T.point(r[l]);
1701
1701
  return u.properties = { id: `${a}_${o}`, parentId: o, name: a }, u;
1702
1702
  });
1703
- return T.featureCollection([...c, e]);
1703
+ return T.featureCollection([...c, t]);
1704
1704
  } else
1705
- return R.warn("[%s] not a orm-std rect, just return the original feature", t == null ? void 0 : t.requestId), T.featureCollection([e]);
1705
+ return R.warn("[%s] not a orm-std rect, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1706
1706
  }
1707
1707
  /**
1708
1708
  * 解析ORM GeoJSON Feature (线), 返回FeatureCollection
@@ -1711,19 +1711,19 @@ class F {
1711
1711
  * @returns
1712
1712
  * 如果feature是线,则返回所有坐标点(首为start、尾为end、中间为point_N)以及线Feature
1713
1713
  */
1714
- static parseLine(e, t = {}) {
1715
- R.info("[%s] parse line with %j", t == null ? void 0 : t.requestId, e.properties);
1716
- const n = e.properties || {};
1714
+ static parseLine(t, e = {}) {
1715
+ R.info("[%s] parse line with %j", e == null ? void 0 : e.requestId, t.properties);
1716
+ const n = t.properties || {};
1717
1717
  if (n.shape == "line") {
1718
1718
  const s = b.utc();
1719
1719
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1720
- const o = n == null ? void 0 : n.id, r = e.geometry.coordinates.map((c, a) => {
1720
+ const o = n == null ? void 0 : n.id, i = t.geometry.coordinates.map((c, a) => {
1721
1721
  const l = `point_${a}`, u = T.point(c);
1722
1722
  return u.properties = { id: `${l}_${o}`, parentId: o, name: l, index: a }, u;
1723
1723
  });
1724
- return T.featureCollection([...r, e]);
1724
+ return T.featureCollection([...i, t]);
1725
1725
  } else
1726
- return R.warn("[%s] not a orm-std line, just return the original feature", t == null ? void 0 : t.requestId), T.featureCollection([e]);
1726
+ return R.warn("[%s] not a orm-std line, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1727
1727
  }
1728
1728
  /**
1729
1729
  * 解析ORM GeoJSON Feature (多边形), 返回FeatureCollection
@@ -1732,19 +1732,19 @@ class F {
1732
1732
  * @returns
1733
1733
  * 如果feature是多边形,则返回多边形的顶点和多边形Feature
1734
1734
  */
1735
- static parsePolygon(e, t = {}) {
1736
- R.info("[%s] parse polygon with %j", t == null ? void 0 : t.requestId, e.properties);
1737
- const n = e.properties || {};
1735
+ static parsePolygon(t, e = {}) {
1736
+ R.info("[%s] parse polygon with %j", e == null ? void 0 : e.requestId, t.properties);
1737
+ const n = t.properties || {};
1738
1738
  if (n.shape == "polygon") {
1739
1739
  const s = b.utc();
1740
1740
  n.id = (n == null ? void 0 : n.id) || s.valueOf().toString();
1741
- const o = n == null ? void 0 : n.id, r = e.geometry.coordinates[0].map((c, a) => {
1741
+ const o = n == null ? void 0 : n.id, i = t.geometry.coordinates[0].map((c, a) => {
1742
1742
  const l = T.point(c), u = `corner_${a}`;
1743
1743
  return l.properties = { id: `${u}_${o}`, parentId: o, name: u, index: a }, l;
1744
1744
  });
1745
- return T.featureCollection([...r, e]);
1745
+ return T.featureCollection([...i, t]);
1746
1746
  } else
1747
- return R.warn("[%s] not a orm-std polygon, just return the original feature", t == null ? void 0 : t.requestId), T.featureCollection([e]);
1747
+ return R.warn("[%s] not a orm-std polygon, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1748
1748
  }
1749
1749
  // ---------------------------------------------------------------------------
1750
1750
  // ZIP / KMZ 内部工具
@@ -1753,11 +1753,11 @@ class F {
1753
1753
  * 解压 DEFLATE raw 数据(ZIP compressionMethod=8)。
1754
1754
  * Node.js 环境使用内置 zlib.inflateRawSync;浏览器环境抛出错误提示使用异步版本。
1755
1755
  */
1756
- static _inflateRawSync(e) {
1757
- var t;
1758
- if (typeof process < "u" && ((t = process.versions) != null && t.node)) {
1756
+ static _inflateRawSync(t) {
1757
+ var e;
1758
+ if (typeof process < "u" && ((e = process.versions) != null && e.node)) {
1759
1759
  const n = require("zlib");
1760
- return new Uint8Array(n.inflateRawSync(Buffer.from(e)));
1760
+ return new Uint8Array(n.inflateRawSync(Buffer.from(t)));
1761
1761
  }
1762
1762
  throw new Error("Sync inflate is not supported in browser; use the async convertKMZ2GeoJSONAsync / convertZIP2GeoJSONAsync instead");
1763
1763
  }
@@ -1765,19 +1765,19 @@ class F {
1765
1765
  * 从 ZIP ArrayBuffer 中异步解析所有文件条目(浏览器 DecompressionStream)。
1766
1766
  * 使用 Central Directory 解析,避免 Data Descriptor 导致的大小不准问题。
1767
1767
  */
1768
- static async _parseZipEntries(e) {
1768
+ static async _parseZipEntries(t) {
1769
1769
  var f;
1770
- const t = new Uint8Array(e), n = t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength), s = new DataView(n), o = new Uint8Array(n), i = /* @__PURE__ */ new Map();
1771
- let r = -1;
1770
+ const e = new Uint8Array(t), n = e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), s = new DataView(n), o = new Uint8Array(n), r = /* @__PURE__ */ new Map();
1771
+ let i = -1;
1772
1772
  for (let h = n.byteLength - 22; h >= 0; h--)
1773
1773
  if (s.getUint32(h, !0) === 101010256) {
1774
- r = h;
1774
+ i = h;
1775
1775
  break;
1776
1776
  }
1777
- if (r < 0)
1777
+ if (i < 0)
1778
1778
  throw new Error("Invalid ZIP file: EOCD not found");
1779
- s.getUint16(r + 8, !0);
1780
- const c = s.getUint32(r + 12, !0), a = s.getUint32(r + 16, !0);
1779
+ s.getUint16(i + 8, !0);
1780
+ const c = s.getUint32(i + 12, !0), a = s.getUint32(i + 16, !0);
1781
1781
  let l = a;
1782
1782
  const u = a + c;
1783
1783
  for (; l < u; ) {
@@ -1785,7 +1785,7 @@ class F {
1785
1785
  throw new Error(`Invalid ZIP file: Central Directory signature mismatch at offset ${l}`);
1786
1786
  const g = s.getUint16(l + 10, !0), m = s.getUint32(l + 20, !0), p = s.getUint16(l + 28, !0), S = s.getUint16(l + 30, !0), x = s.getUint16(l + 32, !0), M = s.getUint32(l + 42, !0), y = o.slice(l + 46, l + 46 + p), N = new TextDecoder().decode(y), w = s.getUint16(M + 26, !0), q = s.getUint16(M + 28, !0), U = M + 30 + w + q, L = o.slice(U, U + m);
1787
1787
  if (g === 0)
1788
- i.set(N, L);
1788
+ r.set(N, L);
1789
1789
  else if (g === 8) {
1790
1790
  if (typeof DecompressionStream < "u") {
1791
1791
  const O = new DecompressionStream("deflate-raw"), P = O.writable.getWriter(), I = O.readable.getReader();
@@ -1802,16 +1802,16 @@ class F {
1802
1802
  let A = 0;
1803
1803
  for (const k of E)
1804
1804
  Z.set(k, A), A += k.length;
1805
- i.set(N, Z);
1805
+ r.set(N, Z);
1806
1806
  } else if (typeof process < "u" && ((f = process.versions) != null && f.node))
1807
1807
  try {
1808
- i.set(N, F._inflateRawSync(L));
1808
+ r.set(N, F._inflateRawSync(L));
1809
1809
  } catch {
1810
1810
  }
1811
1811
  }
1812
1812
  l += 46 + p + S + x;
1813
1813
  }
1814
- return i;
1814
+ return r;
1815
1815
  }
1816
1816
  // ---------------------------------------------------------------------------
1817
1817
  // KMZ / ZIP → GeoJSON
@@ -1822,14 +1822,14 @@ class F {
1822
1822
  * @param options
1823
1823
  * @returns
1824
1824
  */
1825
- static async convertKML2GeoJSON(e, t = {}) {
1826
- var r, c;
1827
- R.info("[%s] convert kml to geojson", t == null ? void 0 : t.requestId);
1828
- const s = H().parseFromString(e, "application/xml"), o = Array.from(s.querySelectorAll("Placemark")), i = [];
1825
+ static async convertKML2GeoJSON(t, e = {}) {
1826
+ var i, c;
1827
+ R.info("[%s] convert kml to geojson", e == null ? void 0 : e.requestId);
1828
+ const s = H().parseFromString(t, "application/xml"), o = Array.from(s.querySelectorAll("Placemark")), r = [];
1829
1829
  for (const a of o) {
1830
1830
  const l = {}, u = Array.from(a.querySelectorAll("ExtendedData > Data"));
1831
1831
  for (const y of u) {
1832
- const N = y.getAttribute("name"), w = (c = (r = y.querySelector("value")) == null ? void 0 : r.textContent) == null ? void 0 : c.trim();
1832
+ const N = y.getAttribute("name"), w = (c = (i = y.querySelector("value")) == null ? void 0 : i.textContent) == null ? void 0 : c.trim();
1833
1833
  N && w !== void 0 && w !== null && (l[N] = w);
1834
1834
  }
1835
1835
  const f = b.utc(), h = Object.keys(l).find((y) => y.toLowerCase().indexOf("name") !== -1), g = h ? l[h] : void 0, m = `${f.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, p = (y) => y.trim().split(/[\s\n]+/).filter((N) => N.length > 0).map((N) => {
@@ -1840,7 +1840,7 @@ class F {
1840
1840
  const y = p(S.textContent || "");
1841
1841
  if (y.length >= 2) {
1842
1842
  const N = T.lineString(y, { ...l, shape: "line", id: m, name: g });
1843
- i.push(N);
1843
+ r.push(N);
1844
1844
  }
1845
1845
  continue;
1846
1846
  }
@@ -1849,7 +1849,7 @@ class F {
1849
1849
  const y = p(x.textContent || "");
1850
1850
  if (y.length >= 4) {
1851
1851
  const N = y[0][0] === y[y.length - 1][0] && y[0][1] === y[y.length - 1][1] ? y : [...y, y[0]], w = T.polygon([N], { ...l, shape: "polygon", id: m, name: g });
1852
- i.push(w);
1852
+ r.push(w);
1853
1853
  }
1854
1854
  continue;
1855
1855
  }
@@ -1858,12 +1858,12 @@ class F {
1858
1858
  const y = p(M.textContent || "");
1859
1859
  if (y.length >= 1) {
1860
1860
  const N = T.point(y[0], { ...l, shape: "point", id: m, name: g });
1861
- i.push(N);
1861
+ r.push(N);
1862
1862
  }
1863
1863
  continue;
1864
1864
  }
1865
1865
  }
1866
- return T.featureCollection(i);
1866
+ return T.featureCollection(r);
1867
1867
  }
1868
1868
  /**
1869
1869
  * 将 KMZ(ZIP 内含 doc.kml 或首个 .kml 文件)异步转换为 GeoJSON。
@@ -1874,14 +1874,14 @@ class F {
1874
1874
  * @param buffer KMZ 文件的 ArrayBuffer
1875
1875
  * @param options
1876
1876
  */
1877
- static async convertKMZ2GeoJSON(e, t = {}) {
1878
- var i;
1879
- R.info("[%s] convert kmz to geojson (async)", t == null ? void 0 : t.requestId), typeof Buffer < "u" && Buffer.isBuffer(e) && (e = F.toArrayBuffer(e));
1880
- const n = await F._parseZipEntries(e), s = n.get("doc.kml") ?? ((i = [...n.entries()].find(([r]) => r.toLowerCase().endsWith(".kml"))) == null ? void 0 : i[1]);
1877
+ static async convertKMZ2GeoJSON(t, e = {}) {
1878
+ var r;
1879
+ R.info("[%s] convert kmz to geojson (async)", e == null ? void 0 : e.requestId), typeof Buffer < "u" && Buffer.isBuffer(t) && (t = F.toArrayBuffer(t));
1880
+ const n = await F._parseZipEntries(t), s = n.get("doc.kml") ?? ((r = [...n.entries()].find(([i]) => i.toLowerCase().endsWith(".kml"))) == null ? void 0 : r[1]);
1881
1881
  if (!s)
1882
- return R.warn("[%s] no .kml file found in kmz", t == null ? void 0 : t.requestId), T.featureCollection([]);
1882
+ return R.warn("[%s] no .kml file found in kmz", e == null ? void 0 : e.requestId), T.featureCollection([]);
1883
1883
  const o = new TextDecoder().decode(s);
1884
- return F.convertKML2GeoJSON(o, t);
1884
+ return F.convertKML2GeoJSON(o, e);
1885
1885
  }
1886
1886
  /**
1887
1887
  * 将 ZIP 文件中所有 .kml 文件合并转换为一个 GeoJSON FeatureCollection(异步)。
@@ -1892,16 +1892,16 @@ class F {
1892
1892
  * @param buffer ZIP 文件的 ArrayBuffer
1893
1893
  * @param options
1894
1894
  */
1895
- static async convertZIP2GeoJSON(e, t = {}) {
1896
- R.info("[%s] convert zip to geojson (async)", t == null ? void 0 : t.requestId), typeof Buffer < "u" && Buffer.isBuffer(e) && (e = F.toArrayBuffer(e));
1897
- const n = await F._parseZipEntries(e), s = [];
1898
- for (const [o, i] of n) {
1895
+ static async convertZIP2GeoJSON(t, e = {}) {
1896
+ R.info("[%s] convert zip to geojson (async)", e == null ? void 0 : e.requestId), typeof Buffer < "u" && Buffer.isBuffer(t) && (t = F.toArrayBuffer(t));
1897
+ const n = await F._parseZipEntries(t), s = [];
1898
+ for (const [o, r] of n) {
1899
1899
  if (!o.toLowerCase().endsWith(".kml"))
1900
1900
  continue;
1901
- const r = new TextDecoder().decode(i), c = await F.convertKML2GeoJSON(r, t);
1901
+ const i = new TextDecoder().decode(r), c = await F.convertKML2GeoJSON(i, e);
1902
1902
  s.push(...c.features);
1903
1903
  }
1904
- return s.length === 0 ? (R.warn("[%s] no .kml files found in zip", t == null ? void 0 : t.requestId), this.convertSHP2GeoJSON(e, t)) : T.featureCollection(s);
1904
+ return s.length === 0 ? (R.warn("[%s] no .kml files found in zip", e == null ? void 0 : e.requestId), this.convertSHP2GeoJSON(t, e)) : T.featureCollection(s);
1905
1905
  }
1906
1906
  /**
1907
1907
  * 将 Shapefile ZIP(含 .shp/.shx/.dbf/.prj)转换为 GeoJSON FeatureCollection。
@@ -1911,13 +1911,13 @@ class F {
1911
1911
  * @param buffer ZIP 文件的 ArrayBuffer
1912
1912
  * @param options
1913
1913
  */
1914
- static async convertSHP2GeoJSON(e, t = {}) {
1915
- R.info("[%s] convert shp zip to geojson", t == null ? void 0 : t.requestId);
1914
+ static async convertSHP2GeoJSON(t, e = {}) {
1915
+ R.info("[%s] convert shp zip to geojson", e == null ? void 0 : e.requestId);
1916
1916
  try {
1917
- typeof Buffer < "u" && Buffer.isBuffer(e) && (e = F.toArrayBuffer(e));
1918
- const n = await J(e);
1917
+ typeof Buffer < "u" && Buffer.isBuffer(t) && (t = F.toArrayBuffer(t));
1918
+ const n = await J(t);
1919
1919
  if (Array.isArray(n)) {
1920
- const s = n.flatMap((c) => c.features || []), o = b.utc(), i = (t == null ? void 0 : t.id) || o.valueOf().toString(), r = {
1920
+ const s = n.flatMap((c) => c.features || []), o = b.utc(), r = (e == null ? void 0 : e.id) || o.valueOf().toString(), i = {
1921
1921
  Point: "point",
1922
1922
  MultiPoint: "point",
1923
1923
  LineString: "line",
@@ -1927,15 +1927,15 @@ class F {
1927
1927
  };
1928
1928
  return s.forEach((c, a) => {
1929
1929
  var g;
1930
- const l = ((g = c.geometry) == null ? void 0 : g.type) || "", u = r[l] || l.toLowerCase();
1931
- c.properties = c.properties || {}, c.properties.shape = u, c.properties.parentId = i, c.properties.id = `${i}_${a}`;
1930
+ const l = ((g = c.geometry) == null ? void 0 : g.type) || "", u = i[l] || l.toLowerCase();
1931
+ c.properties = c.properties || {}, c.properties.shape = u, c.properties.parentId = r, c.properties.id = `${r}_${a}`;
1932
1932
  const f = Object.keys(c.properties).find((m) => m.toLowerCase().indexOf("name") !== -1), h = f ? c.properties[f] : void 0;
1933
1933
  c.properties.name = h || `${u}_${o.format()}_${a}`;
1934
1934
  }), T.featureCollection(s);
1935
1935
  }
1936
1936
  return n;
1937
1937
  } catch (n) {
1938
- return R.warn("[%s] failed to convert shp zip: %s", t == null ? void 0 : t.requestId, n), T.featureCollection([]);
1938
+ return R.warn("[%s] failed to convert shp zip: %s", e == null ? void 0 : e.requestId, n), T.featureCollection([]);
1939
1939
  }
1940
1940
  }
1941
1941
  }
@@ -1944,5 +1944,5 @@ export {
1944
1944
  F as GeoJsonHelper,
1945
1945
  v as LaneHelper,
1946
1946
  d as LngLatHelper,
1947
- re as TropicalHelper
1947
+ it as TropicalHelper
1948
1948
  };