@idm-plugin/geo 2.2.4 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as T from "@turf/turf";
2
2
  import b from "moment";
3
- import G from "@log4js-node/log4js-api";
3
+ import z from "@log4js-node/log4js-api";
4
4
  import "moment-timezone";
5
5
  import V from "tz-lookup";
6
6
  import J from "shpjs";
@@ -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 m = `${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),
44
- pretty: f,
45
- S: r,
41
+ degree: d.roundPrecision(l, e),
42
+ minute: d.roundPrecision(c, e),
43
+ second: d.roundPrecision(r, e),
44
+ pretty: m,
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 m = `${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),
68
- pretty: f,
69
- S: r,
65
+ degree: d.roundPrecision(l, e),
66
+ minute: d.roundPrecision(c, e),
67
+ second: d.roundPrecision(r, e),
68
+ pretty: m,
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,78 +159,78 @@ 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, m] = 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,
184
184
  important: a !== "A",
185
185
  meteo: l ? JSON.parse(l) : void 0,
186
186
  vendor: u,
187
- deleted: f === "true"
187
+ deleted: m === "true"
188
188
  };
189
189
  }
190
- 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], m = t[l];
200
200
  if (n && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(a.type))
201
201
  continue;
202
- const h = f.positionTime - u.positionTime;
203
- if (v.calculateDistance(f, u, !0, 4) / (h / 3600) < t)
204
- i || (i = a), l === e.length - 1 && (r = f, c = l);
202
+ const h = m.positionTime - u.positionTime;
203
+ if (v.calculateDistance(m, u, !0, 4) / (h / 3600) < e)
204
+ r || (r = a), l === t.length - 1 && (i = m, c = l);
205
205
  else {
206
- 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);
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);
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), m = v.divideAccordingToLng(u);
228
+ l.distance = v.calculateRouteDistance(m), l.hours = Math.round(l.duration / 3600 * 10) / 10, l.avgSog = Math.round(l.distance / l.hours * 10) / 10, o.push(l);
229
229
  }
230
- 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,69 +238,69 @@ 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], m = r[l + 1];
247
+ i += v.calculateDistance(u, m, !0, 4), c += Math.abs(m.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;
255
255
  try {
256
- X = G.getLogger("meteo");
256
+ X = z.getLogger("meteo");
257
257
  } catch {
258
258
  } finally {
259
259
  }
260
- const Q = (() => {
260
+ const Y = (() => {
261
261
  const C = new Uint32Array(256);
262
- 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
- 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;
270
+ function Q(C) {
271
+ let t = 4294967295;
272
+ for (let e = 0; e < C.length; e++)
273
+ t = Y[(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 p = t.encode(h.name), f = Q(h.data), g = new Uint8Array(30 + p.length), y = new DataView(g.buffer);
281
+ y.setUint32(0, 67324752, !0), y.setUint16(4, 20, !0), y.setUint16(8, 0, !0), y.setUint32(14, f, !0), y.setUint32(18, h.data.length, !0), y.setUint32(22, h.data.length, !0), y.setUint16(26, p.length, !0), g.set(p, 30), e.push({ nameBytes: p, data: h.data, crc: f, offset: s }), s += g.length + h.data.length, n.push(g, h.data);
282
282
  }
283
- const o = s, i = [];
284
- let r = 0;
285
- for (const h of t) {
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);
283
+ const o = s, r = [];
284
+ let i = 0;
285
+ for (const h of e) {
286
+ const p = new Uint8Array(46 + h.nameBytes.length), f = new DataView(p.buffer);
287
+ f.setUint32(0, 33639248, !0), f.setUint16(4, 20, !0), f.setUint16(6, 20, !0), f.setUint16(10, 0, !0), f.setUint32(16, h.crc, !0), f.setUint32(20, h.data.length, !0), f.setUint32(24, h.data.length, !0), f.setUint16(28, h.nameBytes.length, !0), f.setUint32(42, h.offset, !0), p.set(h.nameBytes, 46), i += p.length, r.push(p);
288
288
  }
289
289
  const c = new Uint8Array(22), a = new DataView(c.buffer);
290
- 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);
292
- let f = 0;
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, p) => h + p.length, 0) + i + 22, u = new Uint8Array(l);
292
+ let m = 0;
293
293
  for (const h of n)
294
- u.set(h, f), f += h.length;
295
- for (const h of i)
296
- u.set(h, f), f += h.length;
297
- return u.set(c, f), u;
294
+ u.set(h, m), m += h.length;
295
+ for (const h of r)
296
+ u.set(h, m), m += h.length;
297
+ return u.set(c, m), u;
298
298
  }
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;
299
+ function G(C) {
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,36 +398,36 @@ 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
- let u, f;
417
- t ? (u = T.lineString(l), f = T.lineString([
416
+ let u, m;
417
+ e ? (u = T.lineString(l), m = T.lineString([
418
418
  [a > 0 ? 180 : -180, 89],
419
419
  [a > 0 ? 180 : -180, -89]
420
- ])) : (u = T.greatCircle(l[0], l[1]), f = T.greatCircle([a > 0 ? 180 : -180, 89], [a > 0 ? 180 : -180, -89]));
421
- const h = T.lineIntersect(u, f);
422
- let g;
420
+ ])) : (u = T.greatCircle(l[0], l[1]), m = T.greatCircle([a > 0 ? 180 : -180, 89], [a > 0 ? 180 : -180, -89]));
421
+ const h = T.lineIntersect(u, m);
422
+ let p;
423
423
  if (h.features.length) {
424
- const m = T.getCoord(h.features[0]);
425
- g = d.roundPrecision(m[1], 8);
424
+ const f = T.getCoord(h.features[0]);
425
+ p = d.roundPrecision(f[1], 8);
426
426
  } else
427
- g = e[c].lat;
428
- a > 0 ? (s.push([180 - 1e-6, g]), o.push([...s]), s = [], s.push([-(180 - 1e-6), g])) : (s.push([-(180 - 1e-6), g]), o.push([...s]), s = [], s.push([180 - 1e-6, g]));
427
+ p = t[c].lat;
428
+ a > 0 ? (s.push([180 - 1e-6, p]), o.push([...s]), s = [], s.push([-(180 - 1e-6), p])) : (s.push([-(180 - 1e-6), p]), o.push([...s]), s = [], s.push([180 - 1e-6, p]));
429
429
  }
430
- 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] }, m = { lng: c[l + 1][0], lat: c[l + 1][1] }, h = this.calculatePointToLineDistance(t, u, m);
493
+ n > h && (n = h, o = l, s = a, r = this.calculateDistance(u, t), i = this.calculateDistance(m, t));
494
494
  }
495
- }), 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,24 +677,24 @@ 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
- const u = this.calculateDistance(c, l, !0), f = Math.abs(l.positionTime - c.positionTime) / 3600;
697
- c.sog = d.roundPrecision(u / f, 2);
696
+ const u = this.calculateDistance(c, l, !0), m = Math.abs(l.positionTime - c.positionTime) / 3600;
697
+ c.sog = d.roundPrecision(u / m, 2);
698
698
  }
699
699
  return c;
700
700
  });
@@ -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,43 +756,43 @@ 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") {
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) => {
759
+ static calculateNextCoordinateAlongRoute(t, e, n, s = "nauticalmiles") {
760
+ var m;
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, p) => {
764
764
  if (c)
765
- r.push(h);
765
+ i.push(h);
766
766
  else {
767
- const m = [];
768
- let p;
769
- for (let S = 0; S < h.length; S++)
767
+ const f = [];
768
+ let g;
769
+ for (let y = 0; y < h.length; y++)
770
770
  if (u)
771
- m.push(h[S]);
771
+ f.push(h[y]);
772
772
  else {
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;
773
+ g = { lng: h[y][0], lat: h[y][1] };
774
+ const x = this.calculateDistance(t, g, !0, 8, s);
775
+ if (a += x, a < e)
776
+ l += x, x && r.push(g), t = g;
777
777
  else {
778
- if (l = t, a === t)
779
- u = p, m.push([u.lng, u.lat]);
778
+ if (l = e, a === e)
779
+ u = g, f.push([u.lng, u.lat]);
780
780
  else {
781
- const M = a - t, y = this.calculateBearing(p, e);
782
- u = this.calculateCoordinate(p, y, M, s), m.push([u.lng, u.lat]), m.push([p.lng, p.lat]);
781
+ const P = a - e, S = this.calculateBearing(g, t);
782
+ u = this.calculateCoordinate(g, S, P, s), f.push([u.lng, u.lat]), f.push([g.lng, g.lat]);
783
783
  }
784
784
  c = !0;
785
785
  }
786
786
  }
787
- m.length && r.push(m), g === n.length - 1 && !u && (u = p);
787
+ f.length && i.push(f), p === n.length - 1 && !u && (u = g);
788
788
  }
789
- })) : (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, ((m = i[0]) == null ? void 0 : m.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]
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) };
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
+ ]), a = T.nearestPointOnLine(c, o), l = T.getCoord(a), u = d.roundPrecision(l[0], 6), m = d.roundPrecision(l[1], 6);
808
+ return { lng: u, lat: m, inline: !(u === r && m === e.lat) && !(u === i && m === n.lat) };
809
809
  }
810
810
  /**
811
811
  * 将route转coordinate
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), m = v.calculateDistance(i, c, !0), h = v.calculateDistance(r, c, !0), p = (Math.pow(u, 2) + Math.pow(m, 2) - Math.pow(h, 2)) / (2 * u * m);
923
+ Math.round(Math.acos(p) * 180 / Math.PI) < n && h > e && !l && (s.push(i), o++);
924
924
  }
925
- 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,27 +935,27 @@ 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, m) => (u.positionTime || 0) - (m.positionTime || 0))) == null ? void 0 : r.at(-1), l = (c = (i = e.filter((u) => (u == null ? void 0 : u.positionTime) > n.unix())) == null ? void 0 : i.sort((u, m) => (u.positionTime || 0) - (m.positionTime || 0))) == null ? void 0 : c.at(0);
956
956
  if (a && l) {
957
- const u = v.calculateBearing(a, l, !0), f = v.calculateDistance(a, l), h = (n.unix() - a.positionTime) / (l.positionTime - a.positionTime);
958
- s = v.calculateCoordinate(a, u, f * h), s.positionTime = n.unix(), s.utc = n.utc().format(), s.cog = u, s.sog = Math.round(f / ((l.positionTime - a.positionTime) / 3600) * 100) / 100;
957
+ const u = v.calculateBearing(a, l, !0), m = v.calculateDistance(a, l), h = (n.unix() - a.positionTime) / (l.positionTime - a.positionTime);
958
+ s = v.calculateCoordinate(a, u, m * h), s.positionTime = n.unix(), s.utc = n.utc().format(), s.cog = u, s.sog = Math.round(m / ((l.positionTime - a.positionTime) / 3600) * 100) / 100;
959
959
  } else
960
960
  s = a || l, s && (s.utc = b.unix(s == null ? void 0 : s.positionTime).utc().format());
961
961
  }
@@ -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);
974
- f < n && (n = f, s = a);
972
+ for (let a = 0; a < e.length - 1; a++) {
973
+ const l = e[a], u = e[a + 1], m = v.calculatePointToLineDistance(t, l, u);
974
+ m < n && (n = m, s = a);
975
975
  }
976
- 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,17 +1063,36 @@ 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]");
1070
- const m = [];
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(","));
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((g) => g.name), r = e.some((g) => g.description), i = e.some((g) => g.port != null), c = e.some((g) => g.stbd != null), a = e.some((g) => g.arrRad != null), l = e.some((g) => g.speed != null), u = e.some((g, y) => y > 0 && g.gcToPrevious != null), m = e.some((g) => g.bearing != null), h = e.some((g) => g.distanceFromPrevious != null), p = ["WPT No.", "Latitude", "Longitude"];
1069
+ o && p.push("Name"), r && p.push("Description"), u && p.push("Leg"), m && p.push("Bearing[deg]"), h && p.push("Distance[NM]"), l && p.push("Speed[kn]"), i && p.push("PORT XTD[NM]"), c && p.push("STBD XTD[NM]"), a && p.push("Arr.Rad[NM]");
1070
+ const f = [];
1071
+ f.push(p.map((g) => v.csvEscapeField(g)).join(","));
1072
+ for (let g = 0; g < e.length; g++) {
1073
+ const y = e[g], x = [];
1074
+ x.push((g + 1).toString()), x.push(y.lat.toFixed(s)), x.push(y.lng.toFixed(s)), o && x.push(y.name ?? ""), r && x.push(y.description ?? ""), u && x.push(g === 0 ? "" : y.gcToPrevious ? "GC" : "RL"), m && x.push(y.bearing != null ? String(y.bearing) : ""), h && x.push(y.distanceFromPrevious != null ? String(y.distanceFromPrevious) : ""), l && x.push(y.speed != null ? String(y.speed) : ""), i && x.push(y.port != null ? String(y.port) : ""), c && x.push(y.stbd != null ? String(y.stbd) : ""), a && x.push(y.arrRad != null ? String(y.arrRad) : ""), f.push(x.map((P) => v.csvEscapeField(P)).join(","));
1075
1075
  }
1076
- return m.join(`
1076
+ return f.join(`
1077
+ `);
1078
+ }
1079
+ /**
1080
+ * 路径导出为 JRC ECDIS CSV 格式
1081
+ * 符合 JRC ECDIS 路由表导入/导出规范
1082
+ * @param name 航线名称
1083
+ * @param waypoints 途径点
1084
+ * @param options.precision 经纬度分钟小数位数,默认3
1085
+ */
1086
+ static waypoints2JRCCSV(t, e, n) {
1087
+ const s = (n == null ? void 0 : n.precision) ?? 3, o = e.some((f) => f.name), r = e.some((f) => f.port != null), i = e.some((f) => f.stbd != null), c = e.some((f) => f.arrRad != null), a = e.some((f) => f.speed != null), l = e.some((f, g) => g > 0 && f.gcToPrevious != null), u = e.some((f) => f.rot != null), m = e.some((f) => f.turnRad != null), h = ["// WPT No.", "LAT", "", "", "LON", "", ""];
1088
+ r && h.push("PORT[NM]"), i && h.push("STBD[NM]"), c && h.push("Arr. Rad[NM]"), a && h.push("Speed[kn]"), l && h.push("Sail(RL/GC)"), u && h.push("ROT[deg/min]"), m && h.push("Turn Rad[NM]"), o && h.push("Name");
1089
+ const p = [];
1090
+ p.push("// ROUTE SHEET exported by JRC ECDIS."), p.push("// <<NOTE>>This strings // indicate comment column/cells. You can edit freely."), p.push(`// ${v.xmlEscape(t)}`), p.push(h.join(","));
1091
+ for (let f = 0; f < e.length; f++) {
1092
+ const g = e[f], y = String(f).padStart(3, "0"), x = d.lat2pretty(g.lat, 6), P = d.lng2pretty(g.lng, 6), S = x.H, M = Number(x.minute).toFixed(s), O = x.direction, W = P.H, E = Number(P.minute).toFixed(s), j = P.direction, w = f === 0 ? "***" : g.port != null ? String(g.port) : "***", N = f === 0 ? "***" : g.stbd != null ? String(g.stbd) : "***", $ = f === 0 ? "***" : g.arrRad != null ? String(g.arrRad) : "***", U = f === 0 ? "***" : g.speed != null ? Number(g.speed).toFixed(1).padStart(5, "0") : "***", B = f === 0 ? "***" : g.gcToPrevious ? "GC" : "RL", q = f === 0 ? "***" : g.rot != null ? String(g.rot) : "***", A = f === 0 ? "***" : g.turnRad != null ? String(g.turnRad) : "***", k = g.name ?? "";
1093
+ p.push(`${y},${S},${M},${O},${W},${E},${j},${w},${N},${$},${U},${B},${q},${A},${k}`);
1094
+ }
1095
+ return p.join(`
1077
1096
  `);
1078
1097
  }
1079
1098
  /**
@@ -1087,70 +1106,70 @@ class v {
1087
1106
  * @param options.precision 经纬度小数位数,默认6
1088
1107
  * @returns Uint8Array 二进制数据,可直接用于 new Blob([result], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
1089
1108
  */
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]");
1093
- const p = (P) => P == null ? "" : String(P).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1094
- let x = `<row r="1">${m.map((P, I) => `<c r="${z(I)}1" s="1" t="inlineStr"><is><t>${p(P)}</t></is></c>`).join("")}</row>`;
1095
- for (let P = 0; P < 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) => {
1097
- j != null ? Z(W, j) : A(W, "");
1109
+ static waypoints2XLSX(t, e, n) {
1110
+ const s = (n == null ? void 0 : n.precision) ?? 6, o = t || "Route", r = e.some((N) => N.name), i = e.some((N) => N.description), c = e.some((N) => N.port != null), a = e.some((N) => N.stbd != null), l = e.some((N) => N.arrRad != null), u = e.some((N) => N.speed != null), m = e.some((N, $) => $ > 0 && N.gcToPrevious != null), h = e.some((N) => N.bearing != null), p = e.some((N) => N.distanceFromPrevious != null), f = ["WPT No.", "Latitude", "Longitude"];
1111
+ r && f.push("Name"), i && f.push("Description"), m && f.push("Leg"), h && f.push("Bearing[deg]"), p && f.push("Distance[NM]"), u && f.push("Speed[kn]"), c && f.push("PORT XTD[NM]"), a && f.push("STBD XTD[NM]"), l && f.push("Arr.Rad[NM]");
1112
+ const g = (N) => N == null ? "" : String(N).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1113
+ let x = `<row r="1">${f.map((N, $) => `<c r="${G($)}1" s="1" t="inlineStr"><is><t>${g(N)}</t></is></c>`).join("")}</row>`;
1114
+ for (let N = 0; N < e.length; N++) {
1115
+ const $ = e[N], U = N + 2, B = [], q = (L, Z) => B.push(`<c r="${G(L)}${U}"><v>${Z}</v></c>`), A = (L, Z) => B.push(`<c r="${G(L)}${U}" t="inlineStr"><is><t>${g(Z)}</t></is></c>`), k = (L, Z) => {
1116
+ Z != null ? q(L, Z) : A(L, "");
1098
1117
  };
1099
- Z(0, P + 1), A(1, d.lat2pretty(I.lat, s).pretty), A(2, d.lng2pretty(I.lng, s).pretty);
1118
+ q(0, N + 1), A(1, d.lat2pretty($.lat, s).pretty), A(2, d.lng2pretty($.lng, s).pretty);
1100
1119
  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>`;
1120
+ r && (A(D, $.name ?? ""), D++), i && (A(D, $.description ?? ""), D++), m && (A(D, N === 0 ? "" : $.gcToPrevious ? "GC" : "RL"), D++), h && (k(D, $.bearing), D++), p && (k(D, $.distanceFromPrevious), D++), u && (k(D, $.speed), D++), c && (k(D, $.port), D++), a && (k(D, $.stbd), D++), l && (k(D, $.arrRad), D++), x += `<row r="${U}">${B.join("")}</row>`;
1102
1121
  }
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();
1122
+ const P = "0." + "0".repeat(s), S = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>' + x + "</sheetData></worksheet>", M = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>', O = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>', W = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="' + g(o) + '" sheetId="1" r:id="rId1"/></sheets></workbook>', E = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>', j = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><numFmts count="1"><numFmt numFmtId="164" formatCode="' + P + '"/></numFmts><fonts count="2"><font><sz val="11"/><name val="Arial"/></font><font><b/><sz val="11"/><name val="Arial"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="2"><border><left/><right/><top/><bottom/><diagonal/></border><border><bottom style="thin"><color auto="1"/></bottom></border></borders><cellStyleXfs count="1"><xf/></cellStyleXfs><cellXfs count="3"><xf/><xf fontId="1" fillId="0" borderId="1" applyFont="1" applyBorder="1"/><xf numFmtId="164" fontId="0" applyNumberFormat="1"/></cellXfs></styleSheet>', w = new TextEncoder();
1104
1123
  return _([
1105
- { name: "[Content_Types].xml", data: O.encode(N) },
1106
- { name: "_rels/.rels", data: O.encode(w) },
1107
- { name: "xl/workbook.xml", data: O.encode(q) },
1108
- { name: "xl/_rels/workbook.xml.rels", data: O.encode(U) },
1109
- { name: "xl/worksheets/sheet1.xml", data: O.encode(y) },
1110
- { name: "xl/styles.xml", data: O.encode(L) }
1124
+ { name: "[Content_Types].xml", data: w.encode(M) },
1125
+ { name: "_rels/.rels", data: w.encode(O) },
1126
+ { name: "xl/workbook.xml", data: w.encode(W) },
1127
+ { name: "xl/_rels/workbook.xml.rels", data: w.encode(E) },
1128
+ { name: "xl/worksheets/sheet1.xml", data: w.encode(S) },
1129
+ { name: "xl/styles.xml", data: w.encode(j) }
1111
1130
  ]);
1112
1131
  }
1113
1132
  /**
1114
1133
  * RFC 4180 CSV字段转义:含逗号、双引号、换行时用双引号包裹,内部双引号翻倍
1115
1134
  */
1116
- static csvEscapeField(e) {
1117
- if (e == null)
1135
+ static csvEscapeField(t) {
1136
+ if (t == null)
1118
1137
  return "";
1119
- const t = String(e);
1120
- return t.includes(",") || t.includes('"') || t.includes(`
1121
- `) || t.includes("\r") ? `"${t.replace(/"/g, '""')}"` : t;
1138
+ const e = String(t);
1139
+ return e.includes(",") || e.includes('"') || e.includes(`
1140
+ `) || e.includes("\r") ? `"${e.replace(/"/g, '""')}"` : e;
1122
1141
  }
1123
1142
  /**
1124
1143
  * 十进制度数转NMEA度分格式 (DDMM.MM / DDDMM.MM)
1125
1144
  * @param value 十进制度数
1126
1145
  * @param isLat true为纬度,false为经度
1127
1146
  */
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 };
1147
+ static decimalToNmeaDm(t, e) {
1148
+ 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";
1149
+ return { dm: r, dir: i };
1131
1150
  }
1132
1151
  /**
1133
1152
  * 计算NMEA 0183校验和 ($与*之间所有字符的异或,两字符十六进制大写)
1134
1153
  * @param sentence $与*之间的字符串
1135
1154
  */
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");
1155
+ static nmeaChecksum(t) {
1156
+ let e = 0;
1157
+ for (let n = 0; n < t.length; n++)
1158
+ e ^= t.charCodeAt(n);
1159
+ return e.toString(16).toUpperCase().padStart(2, "0");
1141
1160
  }
1142
1161
  /**
1143
1162
  * 路径转NMEA 0183 WPL航点语句
1144
1163
  * @param waypoints 途径点
1145
1164
  * @returns 多条$GPWPL语句,以\r\n分隔
1146
1165
  */
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}`);
1166
+ static waypoints2NMEA(t) {
1167
+ const e = [];
1168
+ for (let n = 0; n < t.length; n++) {
1169
+ 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);
1170
+ e.push(`$${c}*${a}`);
1152
1171
  }
1153
- return t.join(`\r
1172
+ return e.join(`\r
1154
1173
  `);
1155
1174
  }
1156
1175
  /**
@@ -1165,20 +1184,20 @@ class v {
1165
1184
  * avgSpeed: number // 平均航速,单位节
1166
1185
  * }
1167
1186
  */
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(
1171
- (h, g) => (h.duration += g.duration, h.distance += g.distance, h),
1187
+ static coordinatesSummary(t, e = 3) {
1188
+ if (t.length > 1) {
1189
+ 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(
1190
+ (h, p) => (h.duration += p.duration, h.distance += p.distance, h),
1172
1191
  { hours: 0, distance: 0, spd: 0, duration: 0 }
1173
1192
  );
1174
1193
  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;
1194
+ const m = i ? Math.round((a - u.distance) / (i - u.hours) * 100) / 100 : 0;
1176
1195
  return {
1177
1196
  begin: o.utc().format(),
1178
- end: i.utc().format(),
1197
+ end: r.utc().format(),
1179
1198
  distance: Math.round((a - u.distance) * 100) / 100,
1180
- hours: Math.round((r - u.hours) * 100) / 100,
1181
- avgSpeed: f,
1199
+ hours: Math.round((i - u.hours) * 100) / 100,
1200
+ avgSpeed: m,
1182
1201
  stoppage: u
1183
1202
  };
1184
1203
  }
@@ -1199,34 +1218,34 @@ class v {
1199
1218
  * hour: Coordinate
1200
1219
  * }
1201
1220
  */
1202
- static pickUTCSampleFromSpeed(e, t) {
1203
- var l, u, f;
1204
- if (!((u = (l = t == null ? void 0 : t.sample) == null ? void 0 : l.hours) != null && u.length))
1221
+ static pickUTCSampleFromSpeed(t, e) {
1222
+ var l, u, m;
1223
+ if (!((u = (l = e == null ? void 0 : e.sample) == null ? void 0 : l.hours) != null && u.length))
1205
1224
  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,
1214
- cFactor: m,
1215
- cog: p,
1225
+ const n = e.sample.hours.at(0), s = b.utc(t), o = b.utc(e.eta), r = s.isAfter(o) ? o : s;
1226
+ let i = e.sample.all.find((h) => h.eta === r.format());
1227
+ if (!i) {
1228
+ const h = e.sample.all.filter((M) => b.utc(M.eta).isBefore(r)).at(-1), p = this.calculateSubRoute(h, e.route);
1229
+ i = (m = this.calculateNextCoordinateAlongRoute(h, h.speed * r.diff(b(h.etd), "hours", !0), p)) == null ? void 0 : m.coordinate;
1230
+ const { cFactor: f, cog: g, wxFactor: y, meteo: x } = h, P = Math.round(i.distanceFromPrevious * 1e4) / 1e4, S = Math.round((P + h.distanceFromStart) * 1e4) / 1e4;
1231
+ i = {
1232
+ ...i,
1233
+ cFactor: f,
1234
+ cog: g,
1216
1235
  speed: h.speed,
1217
- wxFactor: S,
1218
- distanceFromStart: y,
1219
- distanceFromPrevious: M,
1236
+ wxFactor: y,
1237
+ distanceFromStart: S,
1238
+ distanceFromPrevious: P,
1220
1239
  meteo: x,
1221
- eta: i.format(),
1222
- etd: i.format()
1240
+ eta: r.format(),
1241
+ etd: r.format()
1223
1242
  };
1224
1243
  }
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);
1244
+ i.distanceToGo = Math.round((e.distance - i.distanceFromStart) * 100) / 100, i.timeToGo = Math.round(o.diff(i.etd, "hours", !0) * 100) / 100;
1245
+ const c = this.calculateRangeWaypoints(n, i, e.route);
1227
1246
  return {
1228
1247
  routes: this.generateRouteAccordingToWaypoints(c),
1229
- hour: r
1248
+ hour: i
1230
1249
  };
1231
1250
  }
1232
1251
  /**
@@ -1239,13 +1258,13 @@ class v {
1239
1258
  * hour: Coordinate
1240
1259
  * }
1241
1260
  */
1242
- static pickUTCSampleFromRoute(e, t, n) {
1261
+ static pickUTCSampleFromRoute(t, e, n) {
1243
1262
  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;
1263
+ 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;
1264
+ a.speed = e.speed;
1246
1265
  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);
1266
+ 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;
1267
+ const u = this.calculateRangeWaypoints(e, a, n);
1249
1268
  return {
1250
1269
  routes: this.generateRouteAccordingToWaypoints(u),
1251
1270
  hour: a
@@ -1256,164 +1275,164 @@ class v {
1256
1275
  * @param bearing 航首向
1257
1276
  * @param degree 要素角度,如 swell.degree
1258
1277
  */
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));
1278
+ static includedAngle(t, e) {
1279
+ X == null || X.debug("calculate bearing via: %j", { bearing: t, degree: e });
1280
+ let n = Math.abs(t % 360 - (e % 360 || 0));
1262
1281
  return n = n > 180 ? 360 - n : n, n;
1263
1282
  }
1264
1283
  }
1265
- let $;
1284
+ let I;
1266
1285
  try {
1267
- $ = G.getLogger("vessel");
1286
+ I = z.getLogger("vessel");
1268
1287
  } catch {
1269
1288
  } finally {
1270
1289
  }
1271
- class re {
1290
+ class it {
1272
1291
  /**
1273
1292
  * 将原始数据转换为geojson
1274
1293
  * @param raw
1275
1294
  */
1276
- static convert2Geojson(e) {
1295
+ static convert2Geojson(t) {
1277
1296
  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) {
1297
+ const e = T.featureCollection([]);
1298
+ for (const r of t) {
1299
+ const i = (n = r.history) == null ? void 0 : n[0];
1300
+ if (r.forecasts) {
1301
+ i && i.wind && (i.wind.kts = i.kts);
1302
+ for (const c of r.forecasts) {
1284
1303
  let a;
1285
- const l = [], u = [], f = b(c.date).utc(), h = `${i.name}-${c.model}`;
1286
- for (const m in c == null ? void 0 : c.hours) {
1287
- const p = c.hours[m];
1288
- a = a || p;
1289
- const S = f.clone().add(Number(m), "hour"), x = T.point([p.lng, p.lat], {
1304
+ const l = [], u = [], m = b(c.date).utc(), h = `${r.name}-${c.model}`;
1305
+ for (const f in c == null ? void 0 : c.hours) {
1306
+ const g = c.hours[f];
1307
+ a = a || g;
1308
+ const y = m.clone().add(Number(f), "hour"), x = T.point([g.lng, g.lat], {
1290
1309
  model: c.model,
1291
- name: i.name,
1292
- nameCn: i.nameCn,
1293
- date: S.format(),
1294
- hour: Number(m),
1295
- format: S.format("MMM-DD/HHmm[Z]"),
1296
- pressure: p.pressure > 1e4 ? d.roundPrecision(p.pressure / 100, 0) : d.roundPrecision(p.pressure, 0),
1297
- gusts: p.gusts,
1298
- wind: p.wind || {},
1299
- movement: p.movement,
1310
+ name: r.name,
1311
+ nameCn: r.nameCn,
1312
+ date: y.format(),
1313
+ hour: Number(f),
1314
+ format: y.format("MMM-DD/HHmm[Z]"),
1315
+ pressure: g.pressure > 1e4 ? d.roundPrecision(g.pressure / 100, 0) : d.roundPrecision(g.pressure, 0),
1316
+ gusts: g.gusts,
1317
+ wind: g.wind || {},
1318
+ movement: g.movement,
1300
1319
  category: h,
1301
1320
  type: "forecast"
1302
1321
  });
1303
1322
  u.push(x), l.push(x.geometry.coordinates);
1304
1323
  }
1305
- const g = {
1324
+ const p = {
1306
1325
  kts: void 0,
1307
1326
  deg: void 0
1308
1327
  };
1309
- if (r) {
1310
- const m = b(r.updated).utc();
1328
+ if (i) {
1329
+ const f = b(i.updated).utc();
1311
1330
  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);
1331
+ const y = v.calculateDistance(i, a), x = b(a.utc || a.updated).diff(f, "h", !0);
1332
+ p.kts = Math.round(y / x * 100) / 100, p.deg = v.calculateBearing(i, a, !0, 0);
1314
1333
  }
1315
- const p = T.point([r.lng, r.lat], {
1334
+ const g = T.point([i.lng, i.lat], {
1316
1335
  model: c.model,
1317
- name: i.name,
1318
- nameCn: i.nameCn,
1319
- date: m.format(),
1336
+ name: r.name,
1337
+ nameCn: r.nameCn,
1338
+ date: f.format(),
1320
1339
  hour: 0,
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,
1324
- movement: g,
1340
+ format: f.format("MMM-DD/HHmm[Z]"),
1341
+ pressure: i.pressure > 1e4 ? d.roundPrecision((i == null ? void 0 : i.pressure) / 100, 0) : d.roundPrecision(i.pressure, 0),
1342
+ wind: i.wind,
1343
+ movement: p,
1325
1344
  category: h,
1326
1345
  type: "forecast",
1327
1346
  important: !0
1328
1347
  // 第一个预报点为重要点
1329
1348
  });
1330
- u.unshift(p), l.unshift(p.geometry.coordinates);
1349
+ u.unshift(g), l.unshift(g.geometry.coordinates);
1331
1350
  }
1332
- if (t.features.push(...u), (l == null ? void 0 : l.length) > 1) {
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,
1351
+ if (e.features.push(...u), (l == null ? void 0 : l.length) > 1) {
1352
+ const f = T.lineString(d.convertToMonotonicLng2(l), {
1353
+ date: (i == null ? void 0 : i.updated) || (m == null ? void 0 : m.format()),
1354
+ id: r.id || r.name,
1336
1355
  model: c.model,
1337
- name: i.name,
1356
+ name: r.name,
1338
1357
  category: h,
1339
1358
  type: "forecast",
1340
- movement: g
1359
+ movement: p
1341
1360
  });
1342
- t.features.push(m);
1361
+ e.features.push(f);
1343
1362
  }
1344
1363
  }
1345
1364
  }
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) {
1349
- const h = b(f.updated).utc(), g = h.isSameOrBefore(a) || h.isSame(l);
1350
- g && a.add(-u, "h");
1351
- const m = T.point([f.lng, f.lat], {
1352
- name: i.name,
1353
- nameCn: i.nameCn,
1365
+ 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) {
1366
+ 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;
1367
+ for (const m of r.history) {
1368
+ const h = b(m.updated).utc(), p = h.isSameOrBefore(a) || h.isSame(l);
1369
+ p && a.add(-u, "h");
1370
+ const f = T.point([m.lng, m.lat], {
1371
+ name: r.name,
1372
+ nameCn: r.nameCn,
1354
1373
  date: h.format(),
1355
1374
  format: h.format("MMM-DD/HHmm[Z]"),
1356
- pressure: f.pressure > 1e4 ? d.roundPrecision(f.pressure / 100, 0) : d.roundPrecision(f.pressure, 0),
1357
- kts: f.kts,
1358
- level: f.type,
1375
+ pressure: m.pressure > 1e4 ? d.roundPrecision(m.pressure / 100, 0) : d.roundPrecision(m.pressure, 0),
1376
+ kts: m.kts,
1377
+ level: m.type,
1359
1378
  type: "history",
1360
- category: `${i.name}-history`,
1361
- wind: f.wind,
1362
- movement: f.movement,
1363
- important: g
1379
+ category: `${r.name}-history`,
1380
+ wind: m.wind,
1381
+ movement: m.movement,
1382
+ important: p
1364
1383
  });
1365
- t.features.push(m), c.push(m.geometry.coordinates);
1384
+ e.features.push(f), c.push(f.geometry.coordinates);
1366
1385
  }
1367
1386
  if (c.length === 1 && c.push(c[0]), c.length > 1) {
1368
- const f = T.lineString(d.convertToMonotonicLng2(c), {
1369
- name: i.name,
1387
+ const m = T.lineString(d.convertToMonotonicLng2(c), {
1388
+ name: r.name,
1370
1389
  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
1390
+ updated: i == null ? void 0 : i.updated,
1391
+ 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),
1392
+ kts: i == null ? void 0 : i.kts,
1393
+ level: i == null ? void 0 : i.type
1375
1394
  });
1376
- t.features.push(f);
1395
+ e.features.push(m);
1377
1396
  }
1378
1397
  }
1379
1398
  }
1380
- return t;
1399
+ return e;
1381
1400
  }
1382
1401
  /**
1383
1402
  * 插值台风预报轨迹
1384
1403
  * @param tropicals
1385
1404
  * @param step
1386
1405
  */
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 = [];
1406
+ static interpolate(t, e = 3) {
1407
+ var o, r, i, c;
1408
+ 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
1409
  for (const a of n) {
1391
- const l = a.properties.name, u = a.properties.model, f = a.properties.showCircle, h = a.properties.disabled, g = b(a.properties.date).utc();
1392
- let m = t * 60;
1393
- const p = (i = e == null ? void 0 : e.data) == null ? void 0 : i.features.filter(
1394
- (M) => M.geometry.type === "Point" && M.properties.type === "forecast" && M.properties.category === `${l}-${u}`
1410
+ const l = a.properties.name, u = a.properties.model, m = a.properties.showCircle, h = a.properties.disabled, p = b(a.properties.date).utc();
1411
+ let f = e * 60;
1412
+ const g = (r = t == null ? void 0 : t.data) == null ? void 0 : r.features.filter(
1413
+ (P) => P.geometry.type === "Point" && P.properties.type === "forecast" && P.properties.category === `${l}-${u}`
1395
1414
  );
1396
- let S, x = g.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1397
- for (; S = this.pickIndex(p, x), S <= p.length - 1; ) {
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], {
1415
+ let y, x = p.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1416
+ for (; y = this.pickIndex(g, x), y <= g.length - 1; ) {
1417
+ if (y > 0) {
1418
+ const P = g[y], S = y === 0 ? void 0 : g[y - 1], M = (f / 60 - ((i = S == null ? void 0 : S.properties) == null ? void 0 : i.hour)) / (P.properties.hour - ((c = S == null ? void 0 : S.properties) == null ? void 0 : c.hour)), O = this.computeNumber(S == null ? void 0 : S.geometry.coordinates[0], P.geometry.coordinates[0], M), W = this.computeNumber(S == null ? void 0 : S.geometry.coordinates[1], P.geometry.coordinates[1], M), E = T.point([O, W], {
1400
1419
  name: l,
1401
1420
  model: u,
1402
- category: M == null ? void 0 : M.properties.category,
1421
+ category: P == null ? void 0 : P.properties.category,
1403
1422
  date: x.format(),
1404
1423
  format: x.format("MMM-DD/HHmm[Z]"),
1405
- gusts: this.computeNumber(y == null ? void 0 : y.properties.gusts, M.properties.gusts, N),
1406
- hour: this.computeNumber(y == null ? void 0 : y.properties.hour, M.properties.hour, N),
1407
- movement: this.computeNumber(y == null ? void 0 : y.properties.movement, M.properties.movement, N),
1408
- pressure: this.computeNumber(y == null ? void 0 : y.properties.pressure, M.properties.pressure, N),
1409
- wind: this.computeNumber(y == null ? void 0 : y.properties.wind, M.properties.wind, N),
1424
+ gusts: this.computeNumber(S == null ? void 0 : S.properties.gusts, P.properties.gusts, M),
1425
+ hour: this.computeNumber(S == null ? void 0 : S.properties.hour, P.properties.hour, M),
1426
+ movement: this.computeNumber(S == null ? void 0 : S.properties.movement, P.properties.movement, M),
1427
+ pressure: this.computeNumber(S == null ? void 0 : S.properties.pressure, P.properties.pressure, M),
1428
+ wind: this.computeNumber(S == null ? void 0 : S.properties.wind, P.properties.wind, M),
1410
1429
  type: "forecast",
1411
1430
  disabled: h,
1412
- showCircle: f
1431
+ showCircle: m
1413
1432
  });
1414
- s.push(U);
1433
+ s.push(E);
1415
1434
  }
1416
- m += t * 60, x = g.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1435
+ f += e * 60, x = p.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
1417
1436
  }
1418
1437
  }
1419
1438
  return s;
@@ -1424,9 +1443,9 @@ class re {
1424
1443
  * @param tropical 台风数据 { history: any[], forecasts: any[] }
1425
1444
  * @param options
1426
1445
  */
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 };
1446
+ static accelPassageAt(t, e) {
1447
+ const { t1: n, t2: s, hr: o, hours: r } = this.tropicalCenterTwin(t, 24, e);
1448
+ return { t1: n, t2: s, hr: o, hours: r };
1430
1449
  }
1431
1450
  /**
1432
1451
  * 计算最佳绕航点
@@ -1439,32 +1458,32 @@ class re {
1439
1458
  * @param speed 前进速度
1440
1459
  * @param options
1441
1460
  */
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) {
1461
+ static diversionPassageAt(t, e, n, s = {}) {
1462
+ const { t1: o, t2: r, hr: i, hours: c } = this.tropicalCenterTwin(e, 24, s);
1463
+ if (o && r) {
1445
1464
  if (!s.debug) {
1446
- const g = v.calculateDistance(e, o), m = v.calculateDistance(e, i);
1447
- if (g > 2 * n && m > 2 * n)
1448
- return $ == null || $.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, g, m, {
1449
- from: e,
1465
+ const p = v.calculateDistance(t, o), f = v.calculateDistance(t, r);
1466
+ if (p > 2 * n && f > 2 * n)
1467
+ return I == null || I.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, p, f, {
1468
+ from: t,
1450
1469
  t1: o,
1451
- t2: i,
1452
- hr: r
1470
+ t2: r,
1471
+ hr: i
1453
1472
  }), {};
1454
1473
  }
1455
- const a = v.calculateBearing(e, o), l = v.calculateBearing(o, i), u = Math.abs(a - l);
1456
- let f = 0;
1457
- u < 180 ? f = u + 90 : u >= 180 && (f = u - 90);
1458
- const h = v.calculateCoordinate(o, f, n);
1459
- return $ == null || $.info("[%s] the right tangent position: %j", s.requestId, {
1460
- from: e,
1474
+ const a = v.calculateBearing(t, o), l = v.calculateBearing(o, r), u = Math.abs(a - l);
1475
+ let m = 0;
1476
+ u < 180 ? m = u + 90 : u >= 180 && (m = u - 90);
1477
+ const h = v.calculateCoordinate(o, m, n);
1478
+ return I == null || I.info("[%s] the right tangent position: %j", s.requestId, {
1479
+ from: t,
1461
1480
  t1: o,
1462
- t2: i,
1481
+ t2: r,
1463
1482
  radius: n,
1464
1483
  bearing1: a,
1465
1484
  bearing2: l,
1466
1485
  right: h
1467
- }), { at: h, t1: o, t2: i, hr: Number(r), hours: c };
1486
+ }), { at: h, t1: o, t2: r, hr: Number(i), hours: c };
1468
1487
  }
1469
1488
  return {};
1470
1489
  }
@@ -1478,23 +1497,23 @@ class re {
1478
1497
  * @param radius 与台风中心的距离
1479
1498
  * @param options
1480
1499
  */
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) {
1500
+ static driftPassageAt(t, e, n, s = {}) {
1501
+ const { t1: o, t2: r, hr: i, hours: c } = this.tropicalCenterTwin(e, 24, s);
1502
+ if (o && r) {
1484
1503
  if (!s.debug) {
1485
- const h = v.calculateDistance(e, o), g = v.calculateDistance(e, i);
1486
- if (h > 2 * n && g > 2 * n)
1487
- return $ == null || $.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, h, g, {
1488
- from: e,
1504
+ const h = v.calculateDistance(t, o), p = v.calculateDistance(t, r);
1505
+ if (h > 2 * n && p > 2 * n)
1506
+ return I == null || I.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, h, p, {
1507
+ from: t,
1489
1508
  t1: o,
1490
- t2: i,
1491
- hr: r
1509
+ t2: r,
1510
+ hr: i
1492
1511
  }), {};
1493
1512
  }
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 };
1513
+ const a = v.calculateBearing(t, o), l = v.calculateBearing(o, r), u = v.calculateDistance(t, o);
1514
+ return { at: v.calculateCoordinate(o, a - l + 180, n < u ? n : u), t1: o, t2: r, hr: Number(i), hours: c };
1496
1515
  } else
1497
- return $ == null || $.info("[%s] no need drift: %j", s.requestId, { from: e, t1: o, t2: i, hr: r }), {};
1516
+ return I == null || I.info("[%s] no need drift: %j", s.requestId, { from: t, t1: o, t2: r, hr: i }), {};
1498
1517
  }
1499
1518
  /**
1500
1519
  * 获取台风中心点对
@@ -1504,53 +1523,53 @@ class re {
1504
1523
  * @returns { t1: 当前台风中心点, t2: 未来hr小时台风中心点, hr: 未来台风中心点与当前台风中心点之间的时间差, hours: 未来24小时内所有台风中心点 }
1505
1524
  * @private
1506
1525
  */
1507
- static tropicalCenterTwin(e, t = 24, n = {}) {
1508
- var l, u, f, h, g;
1526
+ static tropicalCenterTwin(t, e = 24, n = {}) {
1527
+ var l, u, m, h, p;
1509
1528
  let s = {};
1510
- (l = e.forecasts) == null || l.forEach((m) => {
1511
- s = { ...m.hours, ...s };
1529
+ (l = t.forecasts) == null || l.forEach((f) => {
1530
+ s = { ...f.hours, ...s };
1512
1531
  });
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]]);
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 };
1520
- for (const m of c)
1521
- a[m] = s[m];
1522
- return { t1: o, t2: r, hr: Number(i), hours: a };
1523
- }
1524
- static pickIndex(e, t) {
1532
+ const o = ((u = t == null ? void 0 : t.history) == null ? void 0 : u[0]) || (s == null ? void 0 : s[(m = Object.keys(s)) == null ? void 0 : m[0]]);
1533
+ I == null || I.info("[%s] the first tropical center: %j", n.requestId, o);
1534
+ let r = (h = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : e))) == null ? void 0 : h.at(-1);
1535
+ r || (r = (p = Object.keys(s || {}).filter((f) => Number(f) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : p.at(-1));
1536
+ const i = s == null ? void 0 : s[r || -1];
1537
+ I == null || I.info("[%s] the second tropical center: %j in %d hrs", n.requestId, i, r);
1538
+ const c = Object.keys(s || {}).filter((f) => Number(f) <= Number(r)), a = { 0: o };
1539
+ for (const f of c)
1540
+ a[f] = s[f];
1541
+ return { t1: o, t2: i, hr: Number(r), hours: a };
1542
+ }
1543
+ static pickIndex(t, e) {
1525
1544
  let n = 0;
1526
- for (const s of e) {
1527
- if (b(s.properties.date).isAfter(t))
1545
+ for (const s of t) {
1546
+ if (b(s.properties.date).isAfter(e))
1528
1547
  return n === 0 ? -1 : n;
1529
1548
  n++;
1530
1549
  }
1531
1550
  return n;
1532
1551
  }
1533
- static computeNumber(e, t, n) {
1534
- if (e)
1535
- if (t) {
1536
- if (isNaN(e) && isNaN(t) && typeof e != "string" && typeof t != "string") {
1552
+ static computeNumber(t, e, n) {
1553
+ if (t)
1554
+ if (e) {
1555
+ if (isNaN(t) && isNaN(e) && typeof t != "string" && typeof e != "string") {
1537
1556
  const s = {};
1538
- for (const o in e)
1539
- s[o] = this.computeNumber(e[o], t[o], n);
1557
+ for (const o in t)
1558
+ s[o] = this.computeNumber(t[o], e[o], n);
1540
1559
  return s;
1541
1560
  }
1542
- return Math.round((e + (t - e) * n) * 100) / 100;
1561
+ return Math.round((t + (e - t) * n) * 100) / 100;
1543
1562
  } else
1544
- return e;
1563
+ return t;
1545
1564
  else
1546
- return t;
1565
+ return e;
1547
1566
  }
1548
1567
  }
1549
1568
  typeof globalThis < "u" && typeof globalThis.Buffer > "u" && (globalThis.Buffer = {
1550
1569
  isBuffer(C) {
1551
1570
  return C instanceof Uint8Array;
1552
1571
  },
1553
- from(C, e) {
1572
+ from(C, t) {
1554
1573
  if (typeof C == "string")
1555
1574
  return new TextEncoder().encode(C);
1556
1575
  if (C instanceof ArrayBuffer)
@@ -1562,15 +1581,15 @@ typeof globalThis < "u" && typeof globalThis.Buffer > "u" && (globalThis.Buffer
1562
1581
  });
1563
1582
  let R;
1564
1583
  try {
1565
- R = G.getLogger("meteo");
1584
+ R = z.getLogger("meteo");
1566
1585
  } catch {
1567
1586
  } finally {
1568
1587
  }
1569
1588
  function H() {
1570
1589
  if (typeof DOMParser < "u")
1571
1590
  return new DOMParser();
1572
- const { JSDOM: C } = require("jsdom"), { DOMParser: e } = new C("").window;
1573
- return new e();
1591
+ const { JSDOM: C } = require("jsdom"), { DOMParser: t } = new C("").window;
1592
+ return new t();
1574
1593
  }
1575
1594
  class F {
1576
1595
  /**
@@ -1580,8 +1599,8 @@ class F {
1580
1599
  * @param buf
1581
1600
  * @returns
1582
1601
  */
1583
- static toArrayBuffer(e) {
1584
- return e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
1602
+ static toArrayBuffer(t) {
1603
+ return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
1585
1604
  }
1586
1605
  /**
1587
1606
  * 基于turf画圆,返回GeoJSON Feature<Polygon>
@@ -1590,11 +1609,11 @@ class F {
1590
1609
  * @param radius 半径
1591
1610
  * @param options 步数、单位等选项
1592
1611
  */
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();
1612
+ static drawCircle(t, e, n, s = {}) {
1613
+ 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();
1614
+ i.id = (s == null ? void 0 : s.id) || l.valueOf().toString();
1596
1615
  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 });
1616
+ return i.name = (s == null ? void 0 : s.name) || `${u}_${l.format()}`, i.radius = n, i.center = [t, e], i.end = a.geometry.coordinates.map((m) => d.roundPrecision(m, 9)), i.units = r, i.steps = o, i.shape = "circle", R.info("[%s] draw circle with %j", s == null ? void 0 : s.requestId, i), T.circle(c, n, { steps: o, units: r, properties: i });
1598
1617
  }
1599
1618
  /**
1600
1619
  * 基于turf画矩形,返回GeoJSON Feature<Polygon>
@@ -1602,12 +1621,12 @@ class F {
1602
1621
  * @param end 对角线终点 [lng, lat]
1603
1622
  * @param options 选项
1604
1623
  */
1605
- static drawRect(e, t, n = {}) {
1624
+ static drawRect(t, e, n = {}) {
1606
1625
  const s = (n == null ? void 0 : n.properties) ?? {}, o = b.utc();
1607
1626
  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])];
1627
+ const r = "rect";
1628
+ 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);
1629
+ 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
1630
  return T.bboxPolygon(a, { properties: s });
1612
1631
  }
1613
1632
  /**
@@ -1617,13 +1636,13 @@ class F {
1617
1636
  * @param options
1618
1637
  * @returns
1619
1638
  */
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();
1639
+ static drawLine(t, e = {}) {
1640
+ const n = (e == null ? void 0 : e.properties) ?? {}, s = b.utc();
1641
+ n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1623
1642
  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);
1643
+ 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);
1644
+ const r = d.convertToMonotonicLng2(t);
1645
+ return T.lineString(r, n);
1627
1646
  }
1628
1647
  /**
1629
1648
  * 基于turf画多边形,返回GeoJSON Feature<Polygon>
@@ -1631,13 +1650,13 @@ class F {
1631
1650
  * @param options
1632
1651
  * @returns
1633
1652
  */
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();
1653
+ static drawPolygon(t, e = {}) {
1654
+ const n = (e == null ? void 0 : e.properties) ?? {}, s = b.utc();
1655
+ n.id = (e == null ? void 0 : e.id) || s.valueOf().toString();
1637
1656
  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);
1657
+ 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);
1658
+ const r = d.convertToMonotonicLng2(t);
1659
+ return T.polygon([r], n);
1641
1660
  }
1642
1661
  /**
1643
1662
  * 基于turf画点,返回GeoJSON Feature<Point>
@@ -1646,11 +1665,11 @@ class F {
1646
1665
  * @param options
1647
1666
  * @returns
1648
1667
  */
1649
- static drawPoint(e, t, n = {}) {
1668
+ static drawPoint(t, e, n = {}) {
1650
1669
  const s = (n == null ? void 0 : n.properties) ?? {}, o = b.utc();
1651
1670
  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);
1671
+ const r = "point";
1672
+ 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
1673
  }
1655
1674
  /**
1656
1675
  * 解析ORM GeoJSON Feature (圆), 返回FeatureCollection
@@ -1659,29 +1678,29 @@ class F {
1659
1678
  * @returns
1660
1679
  * 如果feature是圆,则返回圆的中心、端点、半径线 和 边线四个Feature
1661
1680
  */
1662
- static parseCircle(e, t = {}) {
1681
+ static parseCircle(t, e = {}) {
1663
1682
  var s, o;
1664
- R.info("[%s] parse circle with %j", t == null ? void 0 : t.requestId, e.properties);
1665
- const n = e.properties || {};
1683
+ R.info("[%s] parse circle with %j", e == null ? void 0 : e.requestId, t.properties);
1684
+ const n = t.properties || {};
1666
1685
  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);
1686
+ const r = b.utc();
1687
+ n.id = (n == null ? void 0 : n.id) || r.valueOf().toString();
1688
+ 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
1689
  let a = "center";
1671
- c.properties = { id: `${a}_${r}`, parentId: r, name: a };
1690
+ c.properties = { id: `${a}_${i}`, parentId: i, name: a };
1672
1691
  const l = (n == null ? void 0 : n.units) || "nauticalmiles";
1673
1692
  let u = n == null ? void 0 : n.radius;
1674
1693
  if (!u) {
1675
- const g = T.polygonToLine(e);
1676
- u = T.pointToLineDistance(c, g, { units: l });
1694
+ const p = T.polygonToLine(t);
1695
+ u = T.pointToLineDistance(c, p, { units: l });
1677
1696
  }
1678
1697
  a = "end";
1679
- const f = ((o = n == null ? void 0 : n.end) == null ? void 0 : o.length) == 2 ? T.point(n.end) : T.destination(c, u, 90, { units: l });
1680
- f.properties = { id: `${a}_${r}`, parentId: r, name: a, radius: u, units: l };
1681
- const h = T.lineString([c.geometry.coordinates, f.geometry.coordinates]);
1682
- return a = "edge", h.properties = { id: `${a}_${r}`, parentId: r, name: a, radius: u, units: l }, T.featureCollection([c, f, h, e]);
1698
+ const m = ((o = n == null ? void 0 : n.end) == null ? void 0 : o.length) == 2 ? T.point(n.end) : T.destination(c, u, 90, { units: l });
1699
+ m.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l };
1700
+ const h = T.lineString([c.geometry.coordinates, m.geometry.coordinates]);
1701
+ return a = "edge", h.properties = { id: `${a}_${i}`, parentId: i, name: a, radius: u, units: l }, T.featureCollection([c, m, h, t]);
1683
1702
  } 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]);
1703
+ return R.warn("[%s] not a orm-std circle, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1685
1704
  }
1686
1705
  /**
1687
1706
  * 解析ORM GeoJSON Feature (矩形), 返回FeatureCollection
@@ -1690,19 +1709,19 @@ class F {
1690
1709
  * @returns
1691
1710
  * 如果feature是矩形,则返回矩形的四个顶点和矩形Feature
1692
1711
  */
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 || {};
1712
+ static parseRect(t, e = {}) {
1713
+ R.info("[%s] parse rect with %j", e == null ? void 0 : e.requestId, t.properties);
1714
+ const n = t.properties || {};
1696
1715
  if (n.shape == "rect") {
1697
1716
  const s = b.utc();
1698
1717
  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]);
1718
+ const o = n == null ? void 0 : n.id, r = t.geometry.coordinates[0], c = ["sw", "nw", "ne", "se"].map((a, l) => {
1719
+ const u = T.point(r[l]);
1701
1720
  return u.properties = { id: `${a}_${o}`, parentId: o, name: a }, u;
1702
1721
  });
1703
- return T.featureCollection([...c, e]);
1722
+ return T.featureCollection([...c, t]);
1704
1723
  } 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]);
1724
+ return R.warn("[%s] not a orm-std rect, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1706
1725
  }
1707
1726
  /**
1708
1727
  * 解析ORM GeoJSON Feature (线), 返回FeatureCollection
@@ -1711,19 +1730,19 @@ class F {
1711
1730
  * @returns
1712
1731
  * 如果feature是线,则返回所有坐标点(首为start、尾为end、中间为point_N)以及线Feature
1713
1732
  */
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 || {};
1733
+ static parseLine(t, e = {}) {
1734
+ R.info("[%s] parse line with %j", e == null ? void 0 : e.requestId, t.properties);
1735
+ const n = t.properties || {};
1717
1736
  if (n.shape == "line") {
1718
1737
  const s = b.utc();
1719
1738
  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) => {
1739
+ const o = n == null ? void 0 : n.id, i = t.geometry.coordinates.map((c, a) => {
1721
1740
  const l = `point_${a}`, u = T.point(c);
1722
1741
  return u.properties = { id: `${l}_${o}`, parentId: o, name: l, index: a }, u;
1723
1742
  });
1724
- return T.featureCollection([...r, e]);
1743
+ return T.featureCollection([...i, t]);
1725
1744
  } 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]);
1745
+ return R.warn("[%s] not a orm-std line, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1727
1746
  }
1728
1747
  /**
1729
1748
  * 解析ORM GeoJSON Feature (多边形), 返回FeatureCollection
@@ -1732,19 +1751,19 @@ class F {
1732
1751
  * @returns
1733
1752
  * 如果feature是多边形,则返回多边形的顶点和多边形Feature
1734
1753
  */
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 || {};
1754
+ static parsePolygon(t, e = {}) {
1755
+ R.info("[%s] parse polygon with %j", e == null ? void 0 : e.requestId, t.properties);
1756
+ const n = t.properties || {};
1738
1757
  if (n.shape == "polygon") {
1739
1758
  const s = b.utc();
1740
1759
  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) => {
1760
+ const o = n == null ? void 0 : n.id, i = t.geometry.coordinates[0].map((c, a) => {
1742
1761
  const l = T.point(c), u = `corner_${a}`;
1743
1762
  return l.properties = { id: `${u}_${o}`, parentId: o, name: u, index: a }, l;
1744
1763
  });
1745
- return T.featureCollection([...r, e]);
1764
+ return T.featureCollection([...i, t]);
1746
1765
  } 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]);
1766
+ return R.warn("[%s] not a orm-std polygon, just return the original feature", e == null ? void 0 : e.requestId), T.featureCollection([t]);
1748
1767
  }
1749
1768
  // ---------------------------------------------------------------------------
1750
1769
  // ZIP / KMZ 内部工具
@@ -1753,11 +1772,11 @@ class F {
1753
1772
  * 解压 DEFLATE raw 数据(ZIP compressionMethod=8)。
1754
1773
  * Node.js 环境使用内置 zlib.inflateRawSync;浏览器环境抛出错误提示使用异步版本。
1755
1774
  */
1756
- static _inflateRawSync(e) {
1757
- var t;
1758
- if (typeof process < "u" && ((t = process.versions) != null && t.node)) {
1775
+ static _inflateRawSync(t) {
1776
+ var e;
1777
+ if (typeof process < "u" && ((e = process.versions) != null && e.node)) {
1759
1778
  const n = require("zlib");
1760
- return new Uint8Array(n.inflateRawSync(Buffer.from(e)));
1779
+ return new Uint8Array(n.inflateRawSync(Buffer.from(t)));
1761
1780
  }
1762
1781
  throw new Error("Sync inflate is not supported in browser; use the async convertKMZ2GeoJSONAsync / convertZIP2GeoJSONAsync instead");
1763
1782
  }
@@ -1765,53 +1784,53 @@ class F {
1765
1784
  * 从 ZIP ArrayBuffer 中异步解析所有文件条目(浏览器 DecompressionStream)。
1766
1785
  * 使用 Central Directory 解析,避免 Data Descriptor 导致的大小不准问题。
1767
1786
  */
1768
- static async _parseZipEntries(e) {
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;
1787
+ static async _parseZipEntries(t) {
1788
+ var m;
1789
+ 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();
1790
+ let i = -1;
1772
1791
  for (let h = n.byteLength - 22; h >= 0; h--)
1773
1792
  if (s.getUint32(h, !0) === 101010256) {
1774
- r = h;
1793
+ i = h;
1775
1794
  break;
1776
1795
  }
1777
- if (r < 0)
1796
+ if (i < 0)
1778
1797
  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);
1798
+ s.getUint16(i + 8, !0);
1799
+ const c = s.getUint32(i + 12, !0), a = s.getUint32(i + 16, !0);
1781
1800
  let l = a;
1782
1801
  const u = a + c;
1783
1802
  for (; l < u; ) {
1784
1803
  if (s.getUint32(l, !0) !== 33639248)
1785
1804
  throw new Error(`Invalid ZIP file: Central Directory signature mismatch at offset ${l}`);
1786
- const g = s.getUint16(l + 10, !0), m = s.getUint32(l + 20, !0), p = s.getUint16(l + 28, !0), S = s.getUint16(l + 30, !0), x = s.getUint16(l + 32, !0), M = s.getUint32(l + 42, !0), y = o.slice(l + 46, l + 46 + p), N = new TextDecoder().decode(y), w = s.getUint16(M + 26, !0), q = s.getUint16(M + 28, !0), U = M + 30 + w + q, L = o.slice(U, U + m);
1787
- if (g === 0)
1788
- i.set(N, L);
1789
- else if (g === 8) {
1805
+ const p = s.getUint16(l + 10, !0), f = s.getUint32(l + 20, !0), g = s.getUint16(l + 28, !0), y = s.getUint16(l + 30, !0), x = s.getUint16(l + 32, !0), P = s.getUint32(l + 42, !0), S = o.slice(l + 46, l + 46 + g), M = new TextDecoder().decode(S), O = s.getUint16(P + 26, !0), W = s.getUint16(P + 28, !0), E = P + 30 + O + W, j = o.slice(E, E + f);
1806
+ if (p === 0)
1807
+ r.set(M, j);
1808
+ else if (p === 8) {
1790
1809
  if (typeof DecompressionStream < "u") {
1791
- const O = new DecompressionStream("deflate-raw"), P = O.writable.getWriter(), I = O.readable.getReader();
1792
- P.write(L), P.close();
1793
- const E = [];
1810
+ const w = new DecompressionStream("deflate-raw"), N = w.writable.getWriter(), $ = w.readable.getReader();
1811
+ N.write(j), N.close();
1812
+ const U = [];
1794
1813
  let B = 0;
1795
1814
  for (; ; ) {
1796
- const { done: k, value: D } = await I.read();
1815
+ const { done: k, value: D } = await $.read();
1797
1816
  if (k)
1798
1817
  break;
1799
- E.push(D), B += D.length;
1818
+ U.push(D), B += D.length;
1800
1819
  }
1801
- const Z = new Uint8Array(B);
1820
+ const q = new Uint8Array(B);
1802
1821
  let A = 0;
1803
- for (const k of E)
1804
- Z.set(k, A), A += k.length;
1805
- i.set(N, Z);
1806
- } else if (typeof process < "u" && ((f = process.versions) != null && f.node))
1822
+ for (const k of U)
1823
+ q.set(k, A), A += k.length;
1824
+ r.set(M, q);
1825
+ } else if (typeof process < "u" && ((m = process.versions) != null && m.node))
1807
1826
  try {
1808
- i.set(N, F._inflateRawSync(L));
1827
+ r.set(M, F._inflateRawSync(j));
1809
1828
  } catch {
1810
1829
  }
1811
1830
  }
1812
- l += 46 + p + S + x;
1831
+ l += 46 + g + y + x;
1813
1832
  }
1814
- return i;
1833
+ return r;
1815
1834
  }
1816
1835
  // ---------------------------------------------------------------------------
1817
1836
  // KMZ / ZIP → GeoJSON
@@ -1822,48 +1841,48 @@ class F {
1822
1841
  * @param options
1823
1842
  * @returns
1824
1843
  */
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 = [];
1844
+ static async convertKML2GeoJSON(t, e = {}) {
1845
+ var i, c;
1846
+ R.info("[%s] convert kml to geojson", e == null ? void 0 : e.requestId);
1847
+ const s = H().parseFromString(t, "application/xml"), o = Array.from(s.querySelectorAll("Placemark")), r = [];
1829
1848
  for (const a of o) {
1830
1849
  const l = {}, u = Array.from(a.querySelectorAll("ExtendedData > Data"));
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();
1833
- N && w !== void 0 && w !== null && (l[N] = w);
1850
+ for (const S of u) {
1851
+ const M = S.getAttribute("name"), O = (c = (i = S.querySelector("value")) == null ? void 0 : i.textContent) == null ? void 0 : c.trim();
1852
+ M && O !== void 0 && O !== null && (l[M] = O);
1834
1853
  }
1835
- const f = b.utc(), h = Object.keys(l).find((y) => y.toLowerCase().indexOf("name") !== -1), g = h ? l[h] : void 0, m = `${f.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, p = (y) => y.trim().split(/[\s\n]+/).filter((N) => N.length > 0).map((N) => {
1836
- const w = N.split(",").map(Number);
1837
- return [w[0], w[1]];
1838
- }), S = a.querySelector("LineString > coordinates");
1839
- if (S) {
1840
- const y = p(S.textContent || "");
1841
- if (y.length >= 2) {
1842
- const N = T.lineString(y, { ...l, shape: "line", id: m, name: g });
1843
- i.push(N);
1854
+ const m = b.utc(), h = Object.keys(l).find((S) => S.toLowerCase().indexOf("name") !== -1), p = h ? l[h] : void 0, f = `${m.valueOf().toString()}_${Math.random().toString(36).slice(2, 8)}`, g = (S) => S.trim().split(/[\s\n]+/).filter((M) => M.length > 0).map((M) => {
1855
+ const O = M.split(",").map(Number);
1856
+ return [O[0], O[1]];
1857
+ }), y = a.querySelector("LineString > coordinates");
1858
+ if (y) {
1859
+ const S = g(y.textContent || "");
1860
+ if (S.length >= 2) {
1861
+ const M = T.lineString(S, { ...l, shape: "line", id: f, name: p });
1862
+ r.push(M);
1844
1863
  }
1845
1864
  continue;
1846
1865
  }
1847
1866
  const x = a.querySelector("Polygon outerBoundaryIs LinearRing > coordinates");
1848
1867
  if (x) {
1849
- const y = p(x.textContent || "");
1850
- if (y.length >= 4) {
1851
- const N = y[0][0] === y[y.length - 1][0] && y[0][1] === y[y.length - 1][1] ? y : [...y, y[0]], w = T.polygon([N], { ...l, shape: "polygon", id: m, name: g });
1852
- i.push(w);
1868
+ const S = g(x.textContent || "");
1869
+ if (S.length >= 4) {
1870
+ const M = S[0][0] === S[S.length - 1][0] && S[0][1] === S[S.length - 1][1] ? S : [...S, S[0]], O = T.polygon([M], { ...l, shape: "polygon", id: f, name: p });
1871
+ r.push(O);
1853
1872
  }
1854
1873
  continue;
1855
1874
  }
1856
- const M = a.querySelector("Point > coordinates");
1857
- if (M) {
1858
- const y = p(M.textContent || "");
1859
- if (y.length >= 1) {
1860
- const N = T.point(y[0], { ...l, shape: "point", id: m, name: g });
1861
- i.push(N);
1875
+ const P = a.querySelector("Point > coordinates");
1876
+ if (P) {
1877
+ const S = g(P.textContent || "");
1878
+ if (S.length >= 1) {
1879
+ const M = T.point(S[0], { ...l, shape: "point", id: f, name: p });
1880
+ r.push(M);
1862
1881
  }
1863
1882
  continue;
1864
1883
  }
1865
1884
  }
1866
- return T.featureCollection(i);
1885
+ return T.featureCollection(r);
1867
1886
  }
1868
1887
  /**
1869
1888
  * 将 KMZ(ZIP 内含 doc.kml 或首个 .kml 文件)异步转换为 GeoJSON。
@@ -1874,14 +1893,14 @@ class F {
1874
1893
  * @param buffer KMZ 文件的 ArrayBuffer
1875
1894
  * @param options
1876
1895
  */
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]);
1896
+ static async convertKMZ2GeoJSON(t, e = {}) {
1897
+ var r;
1898
+ R.info("[%s] convert kmz to geojson (async)", e == null ? void 0 : e.requestId), typeof Buffer < "u" && Buffer.isBuffer(t) && (t = F.toArrayBuffer(t));
1899
+ 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
1900
  if (!s)
1882
- return R.warn("[%s] no .kml file found in kmz", t == null ? void 0 : t.requestId), T.featureCollection([]);
1901
+ return R.warn("[%s] no .kml file found in kmz", e == null ? void 0 : e.requestId), T.featureCollection([]);
1883
1902
  const o = new TextDecoder().decode(s);
1884
- return F.convertKML2GeoJSON(o, t);
1903
+ return F.convertKML2GeoJSON(o, e);
1885
1904
  }
1886
1905
  /**
1887
1906
  * 将 ZIP 文件中所有 .kml 文件合并转换为一个 GeoJSON FeatureCollection(异步)。
@@ -1892,16 +1911,16 @@ class F {
1892
1911
  * @param buffer ZIP 文件的 ArrayBuffer
1893
1912
  * @param options
1894
1913
  */
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) {
1914
+ static async convertZIP2GeoJSON(t, e = {}) {
1915
+ R.info("[%s] convert zip to geojson (async)", e == null ? void 0 : e.requestId), typeof Buffer < "u" && Buffer.isBuffer(t) && (t = F.toArrayBuffer(t));
1916
+ const n = await F._parseZipEntries(t), s = [];
1917
+ for (const [o, r] of n) {
1899
1918
  if (!o.toLowerCase().endsWith(".kml"))
1900
1919
  continue;
1901
- const r = new TextDecoder().decode(i), c = await F.convertKML2GeoJSON(r, t);
1920
+ const i = new TextDecoder().decode(r), c = await F.convertKML2GeoJSON(i, e);
1902
1921
  s.push(...c.features);
1903
1922
  }
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);
1923
+ 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
1924
  }
1906
1925
  /**
1907
1926
  * 将 Shapefile ZIP(含 .shp/.shx/.dbf/.prj)转换为 GeoJSON FeatureCollection。
@@ -1911,13 +1930,13 @@ class F {
1911
1930
  * @param buffer ZIP 文件的 ArrayBuffer
1912
1931
  * @param options
1913
1932
  */
1914
- static async convertSHP2GeoJSON(e, t = {}) {
1915
- R.info("[%s] convert shp zip to geojson", t == null ? void 0 : t.requestId);
1933
+ static async convertSHP2GeoJSON(t, e = {}) {
1934
+ R.info("[%s] convert shp zip to geojson", e == null ? void 0 : e.requestId);
1916
1935
  try {
1917
- typeof Buffer < "u" && Buffer.isBuffer(e) && (e = F.toArrayBuffer(e));
1918
- const n = await J(e);
1936
+ typeof Buffer < "u" && Buffer.isBuffer(t) && (t = F.toArrayBuffer(t));
1937
+ const n = await J(t);
1919
1938
  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 = {
1939
+ const s = n.flatMap((c) => c.features || []), o = b.utc(), r = (e == null ? void 0 : e.id) || o.valueOf().toString(), i = {
1921
1940
  Point: "point",
1922
1941
  MultiPoint: "point",
1923
1942
  LineString: "line",
@@ -1926,16 +1945,16 @@ class F {
1926
1945
  MultiPolygon: "polygon"
1927
1946
  };
1928
1947
  return s.forEach((c, a) => {
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}`;
1932
- const f = Object.keys(c.properties).find((m) => m.toLowerCase().indexOf("name") !== -1), h = f ? c.properties[f] : void 0;
1948
+ var p;
1949
+ const l = ((p = c.geometry) == null ? void 0 : p.type) || "", u = i[l] || l.toLowerCase();
1950
+ c.properties = c.properties || {}, c.properties.shape = u, c.properties.parentId = r, c.properties.id = `${r}_${a}`;
1951
+ const m = Object.keys(c.properties).find((f) => f.toLowerCase().indexOf("name") !== -1), h = m ? c.properties[m] : void 0;
1933
1952
  c.properties.name = h || `${u}_${o.format()}_${a}`;
1934
1953
  }), T.featureCollection(s);
1935
1954
  }
1936
1955
  return n;
1937
1956
  } catch (n) {
1938
- return R.warn("[%s] failed to convert shp zip: %s", t == null ? void 0 : t.requestId, n), T.featureCollection([]);
1957
+ return R.warn("[%s] failed to convert shp zip: %s", e == null ? void 0 : e.requestId, n), T.featureCollection([]);
1939
1958
  }
1940
1959
  }
1941
1960
  }
@@ -1944,5 +1963,5 @@ export {
1944
1963
  F as GeoJsonHelper,
1945
1964
  v as LaneHelper,
1946
1965
  d as LngLatHelper,
1947
- re as TropicalHelper
1966
+ it as TropicalHelper
1948
1967
  };