@idm-plugin/geo 1.2.7 → 1.2.9

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,5 +1,5 @@
1
1
  import * as g from "@turf/turf";
2
- import N from "moment";
2
+ import D from "moment";
3
3
  import "moment-timezone";
4
4
  import W from "tz-lookup";
5
5
  function E(v) {
@@ -39,31 +39,31 @@ class l {
39
39
  * @param lng
40
40
  * @param lat
41
41
  */
42
- static guessTimeZoneOffset(e, t) {
43
- const n = W(t, e), o = N().tz(n).utcOffset();
44
- return this.roundPrecision(o / 60, 1);
42
+ static guessTimeZoneOffset(t, e) {
43
+ const n = W(e, t), i = D().tz(n).utcOffset();
44
+ return this.roundPrecision(i / 60, 1);
45
45
  }
46
46
  /**
47
47
  * 将时间offset转换为时区,例如:8.5 => +08:30
48
48
  * @param offset => 8.5
49
49
  * @return timezone => +08:30
50
50
  */
51
- static prettyTimeZoneOffset(e) {
52
- let t = Math.floor(Math.abs(e)), n = Math.round((Math.abs(e) - t) * 60);
53
- return n = n > 9 ? n : `0${n}`, t = t > 9 ? t : `0${t}`, e > 0 ? `+${t}:${n}` : `-${t}:${n}`;
54
- }
55
- static lng2pretty(e, t = 6, n = "H°M′") {
56
- e = l.convertToStdLng(e, t);
57
- let o = "E";
58
- e < 0 && (o = "W"), e = Math.abs(e), n = n.toUpperCase();
59
- let i = e * 3600, s, r, c, a, d, u;
60
- s = i % 3600 % 60, n.indexOf("S") !== -1 && (i = i - s, r = l.padNumber(s, 2, 2)), c = i / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = l.roundPrecision(c, t).toString().padStart(2, "0") : a = l.padNumber(c, 2, 2), i = i - c * 60), d = i / 3600, n.indexOf("M") !== -1 ? u = l.roundPrecision(d, t).toString().padStart(3, "0") : u = l.padNumber(d, 3, 2);
61
- const f = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${o}`;
51
+ static prettyTimeZoneOffset(t) {
52
+ let e = Math.floor(Math.abs(t)), n = Math.round((Math.abs(t) - e) * 60);
53
+ return n = n > 9 ? n : `0${n}`, e = e > 9 ? e : `0${e}`, t > 0 ? `+${e}:${n}` : `-${e}:${n}`;
54
+ }
55
+ static lng2pretty(t, e = 6, n = "H°M′") {
56
+ t = l.convertToStdLng(t, e);
57
+ let i = "E";
58
+ t < 0 && (i = "W"), t = Math.abs(t), n = n.toUpperCase();
59
+ let o = t * 3600, s, r, c, a, d, u;
60
+ s = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - s, r = l.padNumber(s, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = l.roundPrecision(c, e).toString().padStart(2, "0") : a = l.padNumber(c, 2, 2), o = o - c * 60), d = o / 3600, n.indexOf("M") !== -1 ? u = l.roundPrecision(d, e).toString().padStart(3, "0") : u = l.padNumber(d, 3, 2);
61
+ const f = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${i}`;
62
62
  return {
63
- direction: o,
64
- degree: l.roundPrecision(d, t),
65
- minute: l.roundPrecision(c, t),
66
- second: l.roundPrecision(s, t),
63
+ direction: i,
64
+ degree: l.roundPrecision(d, e),
65
+ minute: l.roundPrecision(c, e),
66
+ second: l.roundPrecision(s, e),
67
67
  pretty: f
68
68
  };
69
69
  }
@@ -73,102 +73,102 @@ class l {
73
73
  * @param precision 精确度
74
74
  * @param format 格式化
75
75
  */
76
- static lat2pretty(e, t = 6, n = "H°M′") {
77
- e = e % 180;
78
- let o = "N";
79
- e < 0 && (o = "S"), e = Math.abs(e), n = n.toUpperCase();
80
- let i = e * 3600, s, r, c, a, d, u;
81
- s = i % 3600 % 60, n.indexOf("S") !== -1 && (i = i - s, r = l.padNumber(s, 2, 2)), c = i / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = l.roundPrecision(c, t).toString().padStart(2, "0") : a = l.padNumber(c, 2, 2), i = i - c * 60), d = i / 3600, n.indexOf("M") !== -1 ? u = l.roundPrecision(d, t).toString().padStart(2, "0") : u = l.padNumber(d, 2, 2);
82
- const f = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${o}`;
76
+ static lat2pretty(t, e = 6, n = "H°M′") {
77
+ t = t % 180;
78
+ let i = "N";
79
+ t < 0 && (i = "S"), t = Math.abs(t), n = n.toUpperCase();
80
+ let o = t * 3600, s, r, c, a, d, u;
81
+ s = o % 3600 % 60, n.indexOf("S") !== -1 && (o = o - s, r = l.padNumber(s, 2, 2)), c = o / 60 % 60, n.indexOf("M") !== -1 && (n.indexOf("S") !== -1 ? a = l.roundPrecision(c, e).toString().padStart(2, "0") : a = l.padNumber(c, 2, 2), o = o - c * 60), d = o / 3600, n.indexOf("M") !== -1 ? u = l.roundPrecision(d, e).toString().padStart(2, "0") : u = l.padNumber(d, 2, 2);
82
+ const f = `${n.replace(/S+/gi, r).replace(/M+/gi, a).replace(/H+/gi, u)}${i}`;
83
83
  return {
84
- direction: o,
85
- degree: l.roundPrecision(d, t),
86
- minute: l.roundPrecision(c, t),
87
- second: l.roundPrecision(s, t),
84
+ direction: i,
85
+ degree: l.roundPrecision(d, e),
86
+ minute: l.roundPrecision(c, e),
87
+ second: l.roundPrecision(s, e),
88
88
  pretty: f
89
89
  };
90
90
  }
91
- static str2Lng(e, t = 6) {
91
+ static str2Lng(t, e = 6) {
92
92
  let n;
93
- if (isNaN(e)) {
94
- e = l.strReplace(e, "LNG");
95
- const o = e[e.length - 1].toUpperCase();
96
- e = e.substring(0, e.length - 1).trim();
97
- const i = e.split(" ").filter((c) => c !== "").map((c) => Number(c));
98
- let [s, r] = i;
93
+ if (isNaN(t)) {
94
+ t = l.strReplace(t, "LNG");
95
+ const i = t[t.length - 1].toUpperCase();
96
+ t = t.substring(0, t.length - 1).trim();
97
+ const o = t.split(" ").filter((c) => c !== "").map((c) => Number(c));
98
+ let [s, r] = o;
99
99
  if (r = r > 60 ? r / Math.pow(10, String(r).length - 2) : r, s > 360 && !r) {
100
100
  const c = this.roundPrecision(s / 100, 0);
101
101
  r = s - c * 100, s = c;
102
102
  }
103
- n = s + (r ?? 0) / 60, o === "W" && (n = n * -1);
103
+ n = s + (r ?? 0) / 60, i === "W" && (n = n * -1);
104
104
  } else
105
- n = Number(e);
106
- return l.convertToStdLng(n, t);
105
+ n = Number(t);
106
+ return l.convertToStdLng(n, e);
107
107
  }
108
- static str2Lat(e, t = 6) {
108
+ static str2Lat(t, e = 6) {
109
109
  let n;
110
- if (isNaN(e)) {
111
- e = l.strReplace(e, "LAT");
112
- const o = e[e.length - 1].toUpperCase();
113
- e = e.substring(0, e.length - 1).trim();
114
- const i = e.split(" ").filter((c) => c !== "").map((c) => Number(c));
115
- let [s, r] = i;
110
+ if (isNaN(t)) {
111
+ t = l.strReplace(t, "LAT");
112
+ const i = t[t.length - 1].toUpperCase();
113
+ t = t.substring(0, t.length - 1).trim();
114
+ const o = t.split(" ").filter((c) => c !== "").map((c) => Number(c));
115
+ let [s, r] = o;
116
116
  if (r = r > 60 ? r / Math.pow(10, String(r).length - 2) : r, s > 90 && !r) {
117
117
  const c = this.roundPrecision(s / 100, 0);
118
118
  r = s - c * 100, s = c;
119
119
  }
120
- n = s + (r ?? 0) / 60, o === "S" && (n = n * -1);
120
+ n = s + (r ?? 0) / 60, i === "S" && (n = n * -1);
121
121
  } else
122
- n = Number(e);
123
- return l.roundPrecision(n, t);
124
- }
125
- static str2LngOrLat(e, t = 6, n = "LAT") {
126
- e = l.strReplace(e, n);
127
- const o = e[e.length - 1].toUpperCase();
128
- return ["N", "S"].includes(o) ? {
129
- lat: l.str2Lat(e, t)
122
+ n = Number(t);
123
+ return l.roundPrecision(n, e);
124
+ }
125
+ static str2LngOrLat(t, e = 6, n = "LAT") {
126
+ t = l.strReplace(t, n);
127
+ const i = t[t.length - 1].toUpperCase();
128
+ return ["N", "S"].includes(i) ? {
129
+ lat: l.str2Lat(t, e)
130
130
  } : {
131
- lng: l.str2Lng(e, t)
131
+ lng: l.str2Lng(t, e)
132
132
  };
133
133
  }
134
- static convertToStdLng(e, t = 4) {
135
- return e > 180 ? (e = e % 360, e = e > 180 ? e - 360 : e) : e < -180 && (e = e % 360, e = e < -180 ? e + 360 : e), l.roundPrecision(e, t);
134
+ static convertToStdLng(t, e = 4) {
135
+ return t > 180 ? (t = t % 360, t = t > 180 ? t - 360 : t) : t < -180 && (t = t % 360, t = t < -180 ? t + 360 : t), l.roundPrecision(t, e);
136
136
  }
137
- static roundPrecision(e, t = 4) {
138
- if (typeof e == "number") {
139
- const n = Number("1".padEnd(t + 1, "0"));
140
- return Math.round(e * n) / n;
137
+ static roundPrecision(t, e = 4) {
138
+ if (typeof t == "number") {
139
+ const n = Number("1".padEnd(e + 1, "0"));
140
+ return Math.round(t * n) / n;
141
141
  }
142
- return e;
142
+ return t;
143
143
  }
144
144
  /**
145
145
  * 转换为按经度单调增/减的坐标数组
146
146
  * @param coordinates [[lng, lat]]
147
147
  */
148
- static convertToMonotonicLng2(e) {
149
- for (let t = 1; t < e.length; t++)
150
- e[t][0] += Math.round((e[t - 1][0] - e[t][0]) / 360) * 360;
151
- return e;
148
+ static convertToMonotonicLng2(t) {
149
+ for (let e = 1; e < t.length; e++)
150
+ t[e][0] += Math.round((t[e - 1][0] - t[e][0]) / 360) * 360;
151
+ return t;
152
152
  }
153
153
  /**
154
154
  * 转移为按经度单调增/减的坐标数组
155
155
  * @param coordinates [{lng, lat}]
156
156
  */
157
- static convertToMonotonicLng(e) {
158
- for (let t = 1; t < e.length; t++)
159
- e[t].lng += Math.round((e[t - 1].lng - e[t].lng) / 360) * 360;
160
- return e;
157
+ static convertToMonotonicLng(t) {
158
+ for (let e = 1; e < t.length; e++)
159
+ t[e].lng += Math.round((t[e - 1].lng - t[e].lng) / 360) * 360;
160
+ return t;
161
161
  }
162
- static strReplace(e, t = "LAT") {
163
- e = e.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g, "$1 $2").replace(/-/g, " ").replace(/°/, " ").replace(/'/g, " ").replace(/′/g, " ").replace(/"/g, " ").replace(/∼/g, " ").replace(/°/g, " ").replace(/,/g, ".").replace(/^ /g, "").replace(/ $/g, "").trim();
164
- const n = e[e.length - 1].toUpperCase();
162
+ static strReplace(t, e = "LAT") {
163
+ t = t.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g, "$1 $2").replace(/-/g, " ").replace(/°/, " ").replace(/'/g, " ").replace(/′/g, " ").replace(/"/g, " ").replace(/∼/g, " ").replace(/°/g, " ").replace(/,/g, ".").replace(/^ /g, "").replace(/ $/g, "").trim();
164
+ const n = t[t.length - 1].toUpperCase();
165
165
  if (!["N", "S", "E", "W"].includes(n)) {
166
- const o = e, i = Number(o.split(" ")[0]);
167
- if (isNaN(i))
168
- throw new Error(`invalid Lat/Lng: ${e}`);
169
- i >= 90 ? e = `${o}E` : i <= -90 ? e = `${o}W` : ["LAN", "LNG"].includes(t == null ? void 0 : t.toUpperCase()) ? e = `${o}${i > 0 ? "E" : "W"}` : e = `${o}${i > 0 ? "N" : "S"}`;
166
+ const i = t, o = Number(i.split(" ")[0]);
167
+ if (isNaN(o))
168
+ throw new Error(`invalid Lat/Lng: ${t}`);
169
+ o >= 90 ? t = `${i}E` : o <= -90 ? t = `${i}W` : ["LAN", "LNG"].includes(e == null ? void 0 : e.toUpperCase()) ? t = `${i}${o > 0 ? "E" : "W"}` : t = `${i}${o > 0 ? "N" : "S"}`;
170
170
  }
171
- return e;
171
+ return t;
172
172
  }
173
173
  /**
174
174
  * 数据格式
@@ -177,12 +177,12 @@ class l {
177
177
  * @param intPrecision 整数位数
178
178
  * @param dcmPrecision 小数位数
179
179
  */
180
- static padNumber(e, t = 2, n = 2) {
181
- const o = Math.trunc(e).toString().padStart(t, "0"), i = Math.trunc(l.roundPrecision(e - Math.trunc(e), n) * Math.pow(10, n)).toString().padStart(n, "0");
182
- return `${o}.${i}`;
180
+ static padNumber(t, e = 2, n = 2) {
181
+ const i = Math.trunc(t).toString().padStart(e, "0"), o = Math.trunc(l.roundPrecision(t - Math.trunc(t), n) * Math.pow(10, n)).toString().padStart(n, "0");
182
+ return `${i}.${o}`;
183
183
  }
184
184
  }
185
- class P {
185
+ class S {
186
186
  /**
187
187
  * 计算方位角
188
188
  * @param from 坐标 {lng, lat}
@@ -191,13 +191,13 @@ class P {
191
191
  * @param precision
192
192
  * @returns {number} 单位度
193
193
  */
194
- static calculateBearing(e, t, n = !0, o = 4) {
195
- const i = g.points([
196
- [e.lng, e.lat],
197
- [t.lng, t.lat]
194
+ static calculateBearing(t, e, n = !0, i = 4) {
195
+ const o = g.points([
196
+ [t.lng, t.lat],
197
+ [e.lng, e.lat]
198
198
  ]);
199
199
  let s;
200
- return n ? s = g.rhumbBearing(i.features[0], i.features[1]) : s = g.bearing(i.features[0], i.features[1]), s < 0 && (s += 360), l.roundPrecision(s, o);
200
+ return n ? s = g.rhumbBearing(o.features[0], o.features[1]) : s = g.bearing(o.features[0], o.features[1]), s < 0 && (s += 360), l.roundPrecision(s, i);
201
201
  }
202
202
  /**
203
203
  * 计算两点间距离
@@ -208,14 +208,14 @@ class P {
208
208
  * @param units 单位,默认 nm(海里)
209
209
  * @returns {number}
210
210
  */
211
- static calculateDistance(e, t, n = !0, o = 4, i = "nauticalmiles") {
212
- e = { ...e }, t = { ...t }, e.lng = l.convertToStdLng(e.lng, o), t.lng = l.convertToStdLng(t.lng, o);
211
+ static calculateDistance(t, e, n = !0, i = 4, o = "nauticalmiles") {
212
+ t = { ...t }, e = { ...e }, t.lng = l.convertToStdLng(t.lng, i), e.lng = l.convertToStdLng(e.lng, i);
213
213
  const s = g.points([
214
- [e.lng, e.lat],
215
- [t.lng, t.lat]
214
+ [t.lng, t.lat],
215
+ [e.lng, e.lat]
216
216
  ]);
217
217
  let r;
218
- return n ? r = g.rhumbDistance(s.features[0], s.features[1], { units: i }) : r = g.distance(s.features[0], s.features[1], { units: i }), l.roundPrecision(r, o);
218
+ return n ? r = g.rhumbDistance(s.features[0], s.features[1], { units: o }) : r = g.distance(s.features[0], s.features[1], { units: o }), l.roundPrecision(r, i);
219
219
  }
220
220
  /**
221
221
  * 计算航线距离
@@ -223,16 +223,16 @@ class P {
223
223
  * @param precision
224
224
  * @param units
225
225
  */
226
- static calculateRouteDistance(e, t = 4, n = "nauticalmiles") {
227
- let o = 0, i;
228
- for (const s of e)
226
+ static calculateRouteDistance(t, e = 4, n = "nauticalmiles") {
227
+ let i = 0, o;
228
+ for (const s of t)
229
229
  for (let r = 0; r < s.length - 1; r++) {
230
230
  const c = { lng: s[r][0], lat: s[r][1] };
231
- r === 0 && i && (o += this.calculateDistance(i, c, !0, t, n));
231
+ r === 0 && o && (i += this.calculateDistance(o, c, !0, e, n));
232
232
  const a = { lng: s[r + 1][0], lat: s[r + 1][1] };
233
- o += this.calculateDistance(c, a, !0, t, n), i = a;
233
+ i += this.calculateDistance(c, a, !0, e, n), o = a;
234
234
  }
235
- return l.roundPrecision(o, t);
235
+ return l.roundPrecision(i, e);
236
236
  }
237
237
  /**
238
238
  * 计算坐标(基于方位角和距离)
@@ -242,10 +242,10 @@ class P {
242
242
  * @param units 单位,默认 nm(海里)
243
243
  * @param rhumb
244
244
  */
245
- static calculateCoordinate(e, t, n, o = "nauticalmiles", i = !0) {
246
- const s = g.point([e.lng, e.lat]);
245
+ static calculateCoordinate(t, e, n, i = "nauticalmiles", o = !0) {
246
+ const s = g.point([t.lng, t.lat]);
247
247
  let r;
248
- i ? r = g.rhumbDestination(s, n, t, { units: o }) : r = g.destination(s, n, t, { units: o });
248
+ o ? r = g.rhumbDestination(s, n, e, { units: i }) : r = g.destination(s, n, e, { units: i });
249
249
  const c = r.geometry.coordinates;
250
250
  return { lng: l.convertToStdLng(c[0], 8), lat: l.roundPrecision(c[1], 8) };
251
251
  }
@@ -258,13 +258,13 @@ class P {
258
258
  * @param includeTail true 包含终点 to
259
259
  * @param units 单位,默认 nm(海里)
260
260
  */
261
- static interpolateCoordinates(e, t, n, o = !0, i = !0, s = "nauticalmiles") {
262
- const r = [], c = this.calculateBearing(e, t, !1), a = this.calculateDistance(e, t, !1, 8, s);
263
- o && r.push({ lng: e.lng, lat: e.lat });
261
+ static interpolateCoordinates(t, e, n, i = !0, o = !0, s = "nauticalmiles") {
262
+ const r = [], c = this.calculateBearing(t, e, !1), a = this.calculateDistance(t, e, !1, 8, s);
263
+ i && r.push({ lng: t.lng, lat: t.lat });
264
264
  let d = 0;
265
265
  for (; d < a; )
266
- d += n, d < a && r.push(this.calculateCoordinate(e, c, d, s, !1));
267
- return i && r.push({ lng: t.lng, lat: t.lat }), r;
266
+ d += n, d < a && r.push(this.calculateCoordinate(t, c, d, s, !1));
267
+ return o && r.push({ lng: e.lng, lat: e.lat }), r;
268
268
  }
269
269
  /**
270
270
  * 分组坐标(如相邻两个坐标经度差超180度,需以180为界将坐标分为两组)
@@ -277,80 +277,80 @@ class P {
277
277
  * [[-170,40],[-160,30]]
278
278
  * ]
279
279
  */
280
- static divideAccordingToLng(e, t = !1) {
281
- if ((e == null ? void 0 : e.length) < 2)
280
+ static divideAccordingToLng(t, e = !1) {
281
+ if ((t == null ? void 0 : t.length) < 2)
282
282
  return [];
283
- e = this.deduplicateCoordinates(e);
283
+ t = this.deduplicateCoordinates(t);
284
284
  let n = [];
285
- const o = [];
286
- let i, s;
287
- for (let r = 0; r < e.length - 1; r++) {
288
- i = l.convertToStdLng(e[r].lng, 8), s = l.convertToStdLng(e[r + 1].lng, 8), n.push([i, e[r].lat]);
289
- const c = i - s;
285
+ const i = [];
286
+ let o, s;
287
+ for (let r = 0; r < t.length - 1; r++) {
288
+ o = l.convertToStdLng(t[r].lng, 8), s = l.convertToStdLng(t[r + 1].lng, 8), n.push([o, t[r].lat]);
289
+ const c = o - s;
290
290
  if (Math.abs(c) > 180) {
291
291
  const a = l.convertToMonotonicLng2([
292
- [i, e[r].lat],
293
- [s, e[r + 1].lat]
292
+ [o, t[r].lat],
293
+ [s, t[r + 1].lat]
294
294
  ]);
295
295
  let d, u;
296
- t ? (d = g.lineString(a), u = g.lineString([
296
+ e ? (d = g.lineString(a), u = g.lineString([
297
297
  [c > 0 ? 180 : -180, 89],
298
298
  [c > 0 ? 180 : -180, -89]
299
299
  ])) : (d = g.greatCircle(a[0], a[1]), u = g.greatCircle([c > 0 ? 180 : -180, 89], [c > 0 ? 180 : -180, -89]));
300
300
  const f = g.lineIntersect(d, u);
301
301
  let h;
302
302
  if (f.features.length) {
303
- const S = g.getCoord(f.features[0]);
304
- h = l.roundPrecision(S[1], 8);
303
+ const C = g.getCoord(f.features[0]);
304
+ h = l.roundPrecision(C[1], 8);
305
305
  } else
306
- h = e[r].lat;
307
- c > 0 ? (n.push([180 - 1e-6, h]), o.push([...n]), n = [], n.push([-(180 - 1e-6), h])) : (n.push([-(180 - 1e-6), h]), o.push([...n]), n = [], n.push([180 - 1e-6, h]));
306
+ h = t[r].lat;
307
+ c > 0 ? (n.push([180 - 1e-6, h]), i.push([...n]), n = [], n.push([-(180 - 1e-6), h])) : (n.push([-(180 - 1e-6), h]), i.push([...n]), n = [], n.push([180 - 1e-6, h]));
308
308
  }
309
- r === e.length - 2 && n.push([s, e[r + 1].lat]);
309
+ r === t.length - 2 && n.push([s, t[r + 1].lat]);
310
310
  }
311
- return o.push(n), o;
311
+ return i.push(n), i;
312
312
  }
313
313
  /**
314
314
  * 去除重复坐标
315
315
  * @param route
316
316
  */
317
- static deduplicateRoute(e) {
318
- const t = [];
319
- for (const n of e) {
320
- const o = n.reduce((i, s) => (i.findIndex((r) => r[0] === s[0] && r[1] === s[1]) === -1 && i.push(s), i), []);
321
- t.push(o);
317
+ static deduplicateRoute(t) {
318
+ const e = [];
319
+ for (const n of t) {
320
+ const i = n.reduce((o, s) => (o.findIndex((r) => r[0] === s[0] && r[1] === s[1]) === -1 && o.push(s), o), []);
321
+ e.push(i);
322
322
  }
323
- return t;
323
+ return e;
324
324
  }
325
325
  /**
326
326
  * 去除重新坐标
327
327
  * @param coordinates
328
328
  */
329
- static deduplicateCoordinates(e) {
330
- return e.reduce((t, n) => (t.findIndex((o) => o.lat === n.lat && o.lng === n.lng) === -1 && t.push(n), t), []);
329
+ static deduplicateCoordinates(t) {
330
+ return t.reduce((e, n) => (e.findIndex((i) => i.lat === n.lat && i.lng === n.lng) === -1 && e.push(n), e), []);
331
331
  }
332
332
  /**
333
333
  * 移出坐标
334
334
  * @param coordinate {lng, lat}
335
335
  * @param route 航线[[[lng, lat],[lng, lat]]]
336
336
  */
337
- static removeCoordinateFromRoute(e, t) {
338
- e.lng = l.convertToStdLng(e.lng, 8);
339
- for (const n of t)
340
- for (let o = n.length - 1; o >= 0; o--)
341
- l.roundPrecision(n[o][0], 8) === e.lng && l.roundPrecision(n[o][1], 8) === l.roundPrecision(e.lat, 8) && n.splice(o, 1);
342
- return t;
337
+ static removeCoordinateFromRoute(t, e) {
338
+ t.lng = l.convertToStdLng(t.lng, 8);
339
+ for (const n of e)
340
+ for (let i = n.length - 1; i >= 0; i--)
341
+ l.roundPrecision(n[i][0], 8) === t.lng && l.roundPrecision(n[i][1], 8) === l.roundPrecision(t.lat, 8) && n.splice(i, 1);
342
+ return e;
343
343
  }
344
344
  /**
345
345
  * 移出坐标
346
346
  * @param coordinate {lng, lat}
347
347
  * @param waypoints [{lat, lng}, {lat, lng}]
348
348
  */
349
- static removeCoordinateFromWaypoints(e, t) {
350
- e.lng = l.convertToStdLng(e.lng, 8);
351
- for (let n = t.length - 1; n >= 0; n--)
352
- l.roundPrecision(t[n].lng, 8) === e.lng && l.roundPrecision(t[n].lat, 8) === l.roundPrecision(e.lat, 8) && t.splice(n, 1);
353
- return t;
349
+ static removeCoordinateFromWaypoints(t, e) {
350
+ t.lng = l.convertToStdLng(t.lng, 8);
351
+ for (let n = e.length - 1; n >= 0; n--)
352
+ l.roundPrecision(e[n].lng, 8) === t.lng && l.roundPrecision(e[n].lat, 8) === l.roundPrecision(t.lat, 8) && e.splice(n, 1);
353
+ return e;
354
354
  }
355
355
  /**
356
356
  * 合并坐标进航线(基于坐标到线段最短距离边合并)
@@ -363,44 +363,44 @@ class P {
363
363
  * @return
364
364
  * [[[120, 30], [120, 35], [125,40], [130, 37]], [[-150, 40], [-130, 30]]]
365
365
  */
366
- static mergeCoordinateToRoute(e, t) {
367
- e.lng = l.convertToStdLng(e.lng, 8);
368
- let n = Number.MAX_VALUE, o = 0, i = 0, s, r;
369
- return t.forEach((c, a) => {
366
+ static mergeCoordinateToRoute(t, e) {
367
+ t.lng = l.convertToStdLng(t.lng, 8);
368
+ let n = Number.MAX_VALUE, i = 0, o = 0, s, r;
369
+ return e.forEach((c, a) => {
370
370
  for (let d = 0; d < c.length - 1; d++) {
371
- const u = { lng: c[d][0], lat: c[d][1] }, f = { lng: c[d + 1][0], lat: c[d + 1][1] }, h = this.calculatePointToLineDistance(e, u, f);
372
- n > h && (n = h, i = d, o = a, s = this.calculateDistance(u, e), r = this.calculateDistance(f, e));
371
+ const u = { lng: c[d][0], lat: c[d][1] }, f = { lng: c[d + 1][0], lat: c[d + 1][1] }, h = this.calculatePointToLineDistance(t, u, f);
372
+ n > h && (n = h, o = d, i = a, s = this.calculateDistance(u, t), r = this.calculateDistance(f, t));
373
373
  }
374
- }), s !== 0 && r !== 0 ? t[o].splice(i + 1, 0, [e.lng, e.lat]) : s === 0 ? t[o].splice(i, 1, [e.lng, e.lat]) : r === 0 && t[o].splice(i + 1, 1, [e.lng, e.lat]), t;
374
+ }), s !== 0 && r !== 0 ? e[i].splice(o + 1, 0, [t.lng, t.lat]) : s === 0 ? e[i].splice(o, 1, [t.lng, t.lat]) : r === 0 && e[i].splice(o + 1, 1, [t.lng, t.lat]), e;
375
375
  }
376
376
  /**
377
377
  * 向Route尾加1个坐标
378
378
  * @param coordinate
379
379
  * @param route
380
380
  */
381
- static appendCoordinateToRoute(e, t) {
382
- e.lng = l.convertToStdLng(e.lng, 8);
383
- const n = P.convertRouteToCoordinates(t);
384
- return n.push(e), P.divideAccordingToLng(n);
381
+ static appendCoordinateToRoute(t, e) {
382
+ t.lng = l.convertToStdLng(t.lng, 8);
383
+ const n = S.convertRouteToCoordinates(e);
384
+ return n.push(t), S.divideAccordingToLng(n);
385
385
  }
386
386
  /**
387
387
  * 向route头加1个坐标
388
388
  * @param coordinate
389
389
  * @param route
390
390
  */
391
- static unshiftCoordinateToRoute(e, t) {
392
- const n = P.convertRouteToCoordinates(t);
393
- return n.unshift(e), P.divideAccordingToLng(n);
391
+ static unshiftCoordinateToRoute(t, e) {
392
+ const n = S.convertRouteToCoordinates(e);
393
+ return n.unshift(t), S.divideAccordingToLng(n);
394
394
  }
395
395
  /**
396
396
  * 合并多个waypoints进航线
397
397
  * @param waypoints [{lat, lng}, {lat, lng}]
398
398
  * @param route 航线 [[[lng, lat],[lng, lat]]]
399
399
  */
400
- static mergeWaypointsToRoute(e, t) {
401
- for (const n of e)
402
- t = this.mergeCoordinateToRoute(n, t);
403
- return t;
400
+ static mergeWaypointsToRoute(t, e) {
401
+ for (const n of t)
402
+ e = this.mergeCoordinateToRoute(n, e);
403
+ return e;
404
404
  }
405
405
  /**
406
406
  * 计算区间航线
@@ -409,23 +409,23 @@ class P {
409
409
  * @param route [[[lng, lat]]]
410
410
  * @return [[[lng, lat]]]
411
411
  */
412
- static calculateRangeRoute(e, t, n) {
413
- n = this.mergeWaypointsToRoute([e, t], n);
414
- const o = [];
415
- let i = 0;
412
+ static calculateRangeRoute(t, e, n) {
413
+ n = this.mergeWaypointsToRoute([t, e], n);
414
+ const i = [];
415
+ let o = 0;
416
416
  return n.forEach((s) => {
417
- if (i === 2)
417
+ if (o === 2)
418
418
  return;
419
419
  const r = [];
420
420
  for (const c of s) {
421
- if (l.roundPrecision(t.lng, 8) === l.roundPrecision(c[0], 8) && l.roundPrecision(t.lat, 8) === l.roundPrecision(c[1], 8)) {
422
- r.push(c), i === 0 && r.push([e.lng, e.lat]), i = 2;
421
+ if (l.roundPrecision(e.lng, 8) === l.roundPrecision(c[0], 8) && l.roundPrecision(e.lat, 8) === l.roundPrecision(c[1], 8)) {
422
+ r.push(c), o === 0 && r.push([t.lng, t.lat]), o = 2;
423
423
  break;
424
424
  }
425
- i === 1 ? r.push(c) : l.roundPrecision(e.lng, 8) === l.roundPrecision(c[0], 8) && l.roundPrecision(e.lat, 8) === l.roundPrecision(c[1], 8) && (i = 1, r.push(c));
425
+ o === 1 ? r.push(c) : l.roundPrecision(t.lng, 8) === l.roundPrecision(c[0], 8) && l.roundPrecision(t.lat, 8) === l.roundPrecision(c[1], 8) && (o = 1, r.push(c));
426
426
  }
427
- r.length && o.push(r);
428
- }), o;
427
+ r.length && i.push(r);
428
+ }), i;
429
429
  }
430
430
  /**
431
431
  * 计算from到to之间的航线
@@ -435,11 +435,11 @@ class P {
435
435
  * @param waypoints
436
436
  * @return [{lng, lat}]
437
437
  */
438
- static calculateRangeWaypoints(e, t, n, o = []) {
439
- const i = this.convertRouteToCoordinates(n, 0), s = this.mergeCoordinatesToWaypoints([e, t, ...o], i), r = s.findIndex(
440
- (d) => l.roundPrecision(e.lng, 8) === l.roundPrecision(d.lng, 8) && l.roundPrecision(e.lat, 8) === l.roundPrecision(d.lat, 8)
441
- ), c = s.findIndex(
438
+ static calculateRangeWaypoints(t, e, n, i = []) {
439
+ const o = this.convertRouteToCoordinates(n, 0), s = this.mergeCoordinatesToWaypoints([t, e, ...i], o), r = s.findIndex(
442
440
  (d) => l.roundPrecision(t.lng, 8) === l.roundPrecision(d.lng, 8) && l.roundPrecision(t.lat, 8) === l.roundPrecision(d.lat, 8)
441
+ ), c = s.findIndex(
442
+ (d) => l.roundPrecision(e.lng, 8) === l.roundPrecision(d.lng, 8) && l.roundPrecision(e.lat, 8) === l.roundPrecision(d.lat, 8)
443
443
  );
444
444
  return s.filter((d, u) => u >= r && u <= c);
445
445
  }
@@ -448,14 +448,14 @@ class P {
448
448
  * @param from
449
449
  * @param route
450
450
  */
451
- static calculateMinDistanceToRoute(e, t) {
452
- let n = Number.MAX_VALUE, o = 0, i = 0;
453
- return t.forEach((s, r) => {
451
+ static calculateMinDistanceToRoute(t, e) {
452
+ let n = Number.MAX_VALUE, i = 0, o = 0;
453
+ return e.forEach((s, r) => {
454
454
  for (let c = 0; c < s.length - 1; c++) {
455
- const a = { lng: s[c][0], lat: s[c][1] }, d = { lng: s[c + 1][0], lat: s[c + 1][1] }, u = this.calculatePointToLineDistance(e, a, d);
456
- n > u && (n = u, o = c, i = r);
455
+ const a = { lng: s[c][0], lat: s[c][1] }, d = { lng: s[c + 1][0], lat: s[c + 1][1] }, u = this.calculatePointToLineDistance(t, a, d);
456
+ n > u && (n = u, i = c, o = r);
457
457
  }
458
- }), { minDist: n, segIndex: i, minIndex: o };
458
+ }), { minDist: n, segIndex: o, minIndex: i };
459
459
  }
460
460
  /**
461
461
  * 计算子航线
@@ -463,21 +463,21 @@ class P {
463
463
  * @param route [[[lng, lat]]] 剩余航线
464
464
  * @return [[[lng, lat]]]
465
465
  */
466
- static calculateSubRoute(e, t) {
467
- const { segIndex: n, minIndex: o } = this.calculateMinDistanceToRoute({ ...e }, t);
468
- e.lng = l.convertToStdLng(e.lng);
469
- const i = [];
466
+ static calculateSubRoute(t, e) {
467
+ const { segIndex: n, minIndex: i } = this.calculateMinDistanceToRoute({ ...t }, e);
468
+ t.lng = l.convertToStdLng(t.lng);
469
+ const o = [];
470
470
  let s = !0;
471
- for (let r = n; r < t.length; r++)
471
+ for (let r = n; r < e.length; r++)
472
472
  if (s) {
473
473
  const c = [];
474
- c.push([e.lng, e.lat]);
475
- for (let a = o + 1; a < t[r].length; a++)
476
- e.lng === t[r][a][0] && e.lat === t[r][a][1] || c.push(t[r][a]);
477
- i.push(c), s = !1;
474
+ c.push([t.lng, t.lat]);
475
+ for (let a = i + 1; a < e[r].length; a++)
476
+ t.lng === e[r][a][0] && t.lat === e[r][a][1] || c.push(e[r][a]);
477
+ o.push(c), s = !1;
478
478
  } else
479
- i.push([...t[r]]);
480
- return i;
479
+ o.push([...e[r]]);
480
+ return o;
481
481
  }
482
482
  /**
483
483
  * 计算子途经点
@@ -485,22 +485,22 @@ class P {
485
485
  * @param waypoints [{lng, lat}]
486
486
  * @return [{lng, lat}]
487
487
  */
488
- static calculateSubWaypoints(e, t) {
489
- let n = Number.MAX_VALUE, o = 0;
490
- for (let s = 0; s < t.length - 1; s++) {
491
- const r = t[s], c = t[s + 1];
492
- if (this.calculateDistance(e, r) === 0)
493
- return t;
494
- if (this.calculateDistance(e, c) === 0)
495
- return t.filter((d, u) => u > 0);
496
- const a = this.calculatePointToLineDistance(e, r, c);
497
- n > a && (n = a, o = s);
488
+ static calculateSubWaypoints(t, e) {
489
+ let n = Number.MAX_VALUE, i = 0;
490
+ for (let s = 0; s < e.length - 1; s++) {
491
+ const r = e[s], c = e[s + 1];
492
+ if (this.calculateDistance(t, r) === 0)
493
+ return e;
494
+ if (this.calculateDistance(t, c) === 0)
495
+ return e.filter((d, u) => u > 0);
496
+ const a = this.calculatePointToLineDistance(t, r, c);
497
+ n > a && (n = a, i = s);
498
498
  }
499
- e.lng = l.convertToStdLng(e.lng);
500
- const i = [e];
501
- for (let s = o + 1; s < t.length; s++)
502
- i.push(t[s]);
503
- return i;
499
+ t.lng = l.convertToStdLng(t.lng);
500
+ const o = [t];
501
+ for (let s = i + 1; s < e.length; s++)
502
+ o.push(e[s]);
503
+ return o;
504
504
  }
505
505
  /**
506
506
  * 计算坐标到以(from, to)横向线上的距离
@@ -509,14 +509,14 @@ class P {
509
509
  * @param to { lng, lat }
510
510
  * @param options
511
511
  */
512
- static calculatePointToLineDistance(e, t, n, o = { units: "nauticalmiles", method: "geodesic" }) {
513
- e.lng = l.convertToStdLng(e.lng), t = { ...t }, n = { ...n }, t.lng = l.convertToStdLng(t.lng, 8), n.lng = l.convertToStdLng(n.lng, 8);
514
- const i = l.convertToMonotonicLng([t, n]);
515
- t = i[0], n = i[1];
512
+ static calculatePointToLineDistance(t, e, n, i = { units: "nauticalmiles", method: "geodesic" }) {
513
+ t.lng = l.convertToStdLng(t.lng), e = { ...e }, n = { ...n }, e.lng = l.convertToStdLng(e.lng, 8), n.lng = l.convertToStdLng(n.lng, 8);
514
+ const o = l.convertToMonotonicLng([e, n]);
515
+ e = o[0], n = o[1];
516
516
  const s = g.lineString([
517
- [t.lng, t.lat],
517
+ [e.lng, e.lat],
518
518
  [n.lng, n.lat]
519
- ]), r = g.pointToLineDistance(g.point([e.lng, e.lat]), s, o), c = g.pointToLineDistance(g.point([e.lng > 0 ? e.lng - 360 : e.lng + 360, e.lat]), s, o);
519
+ ]), r = g.pointToLineDistance(g.point([t.lng, t.lat]), s, i), c = g.pointToLineDistance(g.point([t.lng > 0 ? t.lng - 360 : t.lng + 360, t.lat]), s, i);
520
520
  return l.roundPrecision(Math.min(r, c), 6);
521
521
  }
522
522
  /**
@@ -524,23 +524,23 @@ class P {
524
524
  * @param waypoints
525
525
  * @param route
526
526
  */
527
- static calculateWaypointsPropInRoute(e, t) {
528
- t = this.mergeWaypointsToRoute(e, t);
529
- for (let n = 0; n < e.length - 1; n++) {
530
- const o = e[n], i = e[n + 1], s = this.calculateRangeRoute(o, i, t);
531
- n === 0 && (o.distanceFromPrevious = 0, o.distanceFromStart = 0), i.distanceFromPrevious = this.calculateRouteDistance(s), i.distanceFromStart = l.roundPrecision((o.distanceFromStart || 0) + i.distanceFromPrevious);
527
+ static calculateWaypointsPropInRoute(t, e) {
528
+ e = this.mergeWaypointsToRoute(t, e);
529
+ for (let n = 0; n < t.length - 1; n++) {
530
+ const i = t[n], o = t[n + 1], s = this.calculateRangeRoute(i, o, e);
531
+ n === 0 && (i.distanceFromPrevious = 0, i.distanceFromStart = 0), o.distanceFromPrevious = this.calculateRouteDistance(s), o.distanceFromStart = l.roundPrecision((i.distanceFromStart || 0) + o.distanceFromPrevious);
532
532
  }
533
- return e;
533
+ return t;
534
534
  }
535
535
  /**
536
536
  * @param coordinates [{lng, lat}]
537
537
  * @param waypoints [{lng, lat}]
538
538
  * @param replace true replace the same waypoint with coordinate
539
539
  */
540
- static mergeCoordinatesToWaypoints(e, t, n = !0) {
541
- for (const o of e)
542
- this.mergeCoordinateToWaypoints(o, t, n);
543
- return t;
540
+ static mergeCoordinatesToWaypoints(t, e, n = !0) {
541
+ for (const i of t)
542
+ this.mergeCoordinateToWaypoints(i, e, n);
543
+ return e;
544
544
  }
545
545
  /**
546
546
  * 合并坐标进航路途经点
@@ -554,44 +554,44 @@ class P {
554
554
  * @return
555
555
  * [{ lng: 160, lat: 30}, { lng: 170, lat: 40}, {lng: 179, lat: 50}, {lng: -170, lat: 40}, {lng: -160, lat: 30}]
556
556
  */
557
- static mergeCoordinateToWaypoints(e, t, n = !0) {
558
- e.lng = l.convertToStdLng(e.lng, 8);
559
- let o = Number.MAX_VALUE, i = 0, s = 0, r = 0;
560
- for (let c = 0; c < t.length - 1; c++) {
561
- const a = { lng: t[c].lng, lat: t[c].lat }, d = { lng: t[c + 1].lng, lat: t[c + 1].lat }, u = this.calculatePointToLineDistance(e, a, d);
562
- o >= u && (o = u, i = c, s = this.calculateDistance(a, e, !1, 6), r = this.calculateDistance(d, e, !1, 6));
557
+ static mergeCoordinateToWaypoints(t, e, n = !0) {
558
+ t.lng = l.convertToStdLng(t.lng, 8);
559
+ let i = Number.MAX_VALUE, o = 0, s = 0, r = 0;
560
+ for (let c = 0; c < e.length - 1; c++) {
561
+ const a = { lng: e[c].lng, lat: e[c].lat }, d = { lng: e[c + 1].lng, lat: e[c + 1].lat }, u = this.calculatePointToLineDistance(t, a, d);
562
+ i >= u && (i = u, o = c, s = this.calculateDistance(a, t, !1, 6), r = this.calculateDistance(d, t, !1, 6));
563
563
  }
564
- return s !== 0 && r !== 0 ? s < o || s === o && i === 0 ? t.unshift(e) : r < o || r === o && i === t.length - 2 ? t.push(e) : t.splice(i + 1, 0, e) : s === 0 ? n && t.splice(i, 1, e) : r === 0 && n && t.splice(i + 1, 1, e), t.map((c) => (c.lng = l.convertToStdLng(c.lng), c));
564
+ return s !== 0 && r !== 0 ? s < i || s === i && o === 0 ? e.unshift(t) : r < i || r === i && o === e.length - 2 ? e.push(t) : e.splice(o + 1, 0, t) : s === 0 ? n && e.splice(o, 1, t) : r === 0 && n && e.splice(o + 1, 1, t), e.map((c) => (c.lng = l.convertToStdLng(c.lng), c));
565
565
  }
566
566
  /**
567
567
  * 生成航线(基于途经点生成大圆/横向航线,并根据是否跨180度分组)
568
568
  * @param waypoints [{lng, lat}, {lng: lat, gcToPrevious: true}]
569
569
  * @return [[[lng, lat], [lng, lat]]]
570
570
  */
571
- static generateRouteAccordingToWaypoints(e) {
572
- const t = [];
573
- for (let n = 1; n < e.length; n++) {
574
- const o = e[n - 1], i = e[n];
575
- if (n === 1 && t.push(o), i.gcToPrevious) {
576
- const s = this.interpolateCoordinates(o, i, 200, !1, !0, "nauticalmiles");
577
- t.push(...s);
571
+ static generateRouteAccordingToWaypoints(t) {
572
+ const e = [];
573
+ for (let n = 1; n < t.length; n++) {
574
+ const i = t[n - 1], o = t[n];
575
+ if (n === 1 && e.push(i), o.gcToPrevious) {
576
+ const s = this.interpolateCoordinates(i, o, 200, !1, !0, "nauticalmiles");
577
+ e.push(...s);
578
578
  } else
579
- t.push(i);
579
+ e.push(o);
580
580
  }
581
- return this.divideAccordingToLng(t, !0);
581
+ return this.divideAccordingToLng(e, !0);
582
582
  }
583
583
  /**
584
584
  * 最近点(从route中找出距离目标点最近的点)
585
585
  * @param coordinate 目标点 {lng, lat}
586
586
  * @param route [[[lng, lat]]]
587
587
  */
588
- static nearestCoordinateInRoute(e, t) {
589
- const n = g.point([e.lng, e.lat]), o = [];
590
- for (const c of t) {
588
+ static nearestCoordinateInRoute(t, e) {
589
+ const n = g.point([t.lng, t.lat]), i = [];
590
+ for (const c of e) {
591
591
  const a = c.map((d) => g.point(d));
592
- o.push(...a);
592
+ i.push(...a);
593
593
  }
594
- const i = g.featureCollection(o), s = g.nearestPoint(n, i), r = g.getCoord(s);
594
+ const o = g.featureCollection(i), s = g.nearestPoint(n, o), r = g.getCoord(s);
595
595
  return { lng: r[0], lat: r[1] };
596
596
  }
597
597
  /**
@@ -599,21 +599,21 @@ class P {
599
599
  * @param from
600
600
  * @param waypoints
601
601
  */
602
- static calculatePrevWaypoint(e, t) {
602
+ static calculatePrevWaypoint(t, e) {
603
603
  let n = 0;
604
- this.mergeCoordinateToWaypoints(e, t);
605
- for (let o = 0; o < t.length - 1; o++) {
606
- const i = t[o], s = t[o + 1];
607
- if (this.calculateDistance(e, i) === 0) {
608
- n = o;
604
+ this.mergeCoordinateToWaypoints(t, e);
605
+ for (let i = 0; i < e.length - 1; i++) {
606
+ const o = e[i], s = e[i + 1];
607
+ if (this.calculateDistance(t, o) === 0) {
608
+ n = i;
609
609
  break;
610
610
  }
611
- if (this.calculateDistance(e, s) === 0) {
612
- n = o + 1;
611
+ if (this.calculateDistance(t, s) === 0) {
612
+ n = i + 1;
613
613
  break;
614
614
  }
615
615
  }
616
- return t[n === 0 ? 0 : n - 1];
616
+ return e[n === 0 ? 0 : n - 1];
617
617
  }
618
618
  /**
619
619
  * 计算下一个距离单位的坐标及其子航线
@@ -623,38 +623,38 @@ class P {
623
623
  * @param units
624
624
  * @return { coordinate: {lng, lat}, route: [[[lng, lat]]]}
625
625
  */
626
- static calculateNextCoordinateAlongRoute(e, t, n, o = "nauticalmiles") {
626
+ static calculateNextCoordinateAlongRoute(t, e, n, i = "nauticalmiles") {
627
627
  var f;
628
- const i = e.speed || 12, s = [];
628
+ const o = t.speed || 12, s = [];
629
629
  let r = [], c = !1, a = 0, d = 0, u;
630
- if (t && n.length ? (s.push(e), n.forEach((h, S) => {
630
+ if (e && n.length ? (s.push(t), n.forEach((h, C) => {
631
631
  if (c)
632
632
  r.push(h);
633
633
  else {
634
634
  const m = [];
635
635
  let b;
636
- for (let C = 0; C < h.length; C++)
636
+ for (let M = 0; M < h.length; M++)
637
637
  if (u)
638
- m.push(h[C]);
638
+ m.push(h[M]);
639
639
  else {
640
- b = { lng: h[C][0], lat: h[C][1] };
641
- const T = this.calculateDistance(e, b, !0, 8, o);
642
- if (a += T, a < t)
643
- d += T, s.push(b), e = b;
640
+ b = { lng: h[M][0], lat: h[M][1] };
641
+ const T = this.calculateDistance(t, b, !0, 8, i);
642
+ if (a += T, a < e)
643
+ d += T, s.push(b), t = b;
644
644
  else {
645
- if (d = t, a === t)
645
+ if (d = e, a === e)
646
646
  u = b, m.push([u.lng, u.lat]);
647
647
  else {
648
- const p = a - t, M = this.calculateBearing(b, e);
649
- u = this.calculateCoordinate(b, M, p, o), m.push([u.lng, u.lat]), m.push([b.lng, b.lat]);
648
+ const p = a - e, N = this.calculateBearing(b, t);
649
+ u = this.calculateCoordinate(b, N, p, i), m.push([u.lng, u.lat]), m.push([b.lng, b.lat]);
650
650
  }
651
651
  c = !0;
652
652
  }
653
653
  }
654
- m.length && r.push(m), S === n.length - 1 && !u && (u = b);
654
+ m.length && r.push(m), C === n.length - 1 && !u && (u = b);
655
655
  }
656
- })) : (r = n, u = { ...e }), u)
657
- if (s.push(u), u.distanceFromPrevious = d, u.hourFromPrevious = Math.round(d / i * 1e4) / 1e4, ((f = r[0]) == null ? void 0 : f.length) > 1) {
656
+ })) : (r = n, u = { ...t }), u)
657
+ if (s.push(u), u.distanceFromPrevious = d, u.hourFromPrevious = Math.round(d / o * 1e4) / 1e4, ((f = r[0]) == null ? void 0 : f.length) > 1) {
658
658
  const h = { lng: r[0][1][0], lat: r[0][1][1] };
659
659
  u.bearing = this.calculateBearing(u, h);
660
660
  } else
@@ -667,35 +667,35 @@ class P {
667
667
  * @param from {lng, lat}
668
668
  * @param to {lng, lat}
669
669
  */
670
- static nearestCoordinateInLine(e, t, n) {
671
- const o = l.convertToStdLng(e.lng, 6), i = g.point([o, e.lat]), s = l.convertToStdLng(t.lng, 6), r = l.convertToStdLng(n.lng, 6), c = g.lineString([
672
- [s, t.lat],
670
+ static nearestCoordinateInLine(t, e, n) {
671
+ const i = l.convertToStdLng(t.lng, 6), o = g.point([i, t.lat]), s = l.convertToStdLng(e.lng, 6), r = l.convertToStdLng(n.lng, 6), c = g.lineString([
672
+ [s, e.lat],
673
673
  [r, n.lat]
674
- ]), a = g.nearestPointOnLine(c, i), d = g.getCoord(a), u = l.roundPrecision(d[0], 6), f = l.roundPrecision(d[1], 6);
675
- return { lng: u, lat: f, inline: !(u === s && f === t.lat) && !(u === r && f === n.lat) };
674
+ ]), a = g.nearestPointOnLine(c, o), d = g.getCoord(a), u = l.roundPrecision(d[0], 6), f = l.roundPrecision(d[1], 6);
675
+ return { lng: u, lat: f, inline: !(u === s && f === e.lat) && !(u === r && f === n.lat) };
676
676
  }
677
677
  /**
678
678
  * 将route转coordinate
679
679
  * @param route
680
680
  * @param distance 临近点过虑
681
681
  */
682
- static convertRouteToCoordinates(e, t = 0) {
682
+ static convertRouteToCoordinates(t, e = 0) {
683
683
  const n = [];
684
- let o, i;
685
- return e.forEach((s) => {
684
+ let i, o;
685
+ return t.forEach((s) => {
686
686
  s.forEach((r) => {
687
687
  const c = { lng: r[0], lat: r[1] };
688
- if (!i)
689
- n.push(c), i = c;
690
- else if (i.bearing === void 0)
691
- i.bearing = this.calculateBearing(i, c, !0);
688
+ if (!o)
689
+ n.push(c), o = c;
690
+ else if (o.bearing === void 0)
691
+ o.bearing = this.calculateBearing(o, c, !0);
692
692
  else {
693
- const a = this.calculateDistance(o, c, !0);
694
- a && a >= t && (o.bearing = this.calculateBearing(o, c, !0), n.push(o), i = o);
693
+ const a = this.calculateDistance(i, c, !0);
694
+ a && a >= e && (i.bearing = this.calculateBearing(i, c, !0), n.push(i), o = i);
695
695
  }
696
- o = c;
696
+ i = c;
697
697
  });
698
- }), o && n.push(o), n;
698
+ }), i && n.push(i), n;
699
699
  }
700
700
  /**
701
701
  * 抽稀(基于转向点)
@@ -703,45 +703,45 @@ class P {
703
703
  * @param waypoints [{ lng, lat, gcToPrevious }]
704
704
  * @param distance
705
705
  */
706
- static simplifyRouteToCoordinates(e, t, n = 1) {
707
- let o = this.convertRouteToCoordinates(e, n);
708
- return o = this.simplifyGCCoordinates(o, t), o;
706
+ static simplifyRouteToCoordinates(t, e, n = 1) {
707
+ let i = this.convertRouteToCoordinates(t, n);
708
+ return i = this.simplifyGCCoordinates(i, e), i;
709
709
  }
710
710
  /**
711
711
  * 基于大圆标识抽稀
712
712
  * @param coordinates
713
713
  * @param waypoints
714
714
  */
715
- static simplifyGCCoordinates(e, t) {
716
- t.forEach((o) => {
717
- this.mergeCoordinateToWaypoints(o, e);
715
+ static simplifyGCCoordinates(t, e) {
716
+ e.forEach((i) => {
717
+ this.mergeCoordinateToWaypoints(i, t);
718
718
  });
719
- for (let o = 1; o < t.length; o++) {
720
- const i = t[o - 1], s = t[o];
719
+ for (let i = 1; i < e.length; i++) {
720
+ const o = e[i - 1], s = e[i];
721
721
  if (s.gcToPrevious) {
722
- const r = e.findIndex((a) => a.lng === i.lng && a.lat === i.lat), c = e.findIndex((a) => a.lng === s.lng && a.lat === s.lat);
722
+ const r = t.findIndex((a) => a.lng === o.lng && a.lat === o.lat), c = t.findIndex((a) => a.lng === s.lng && a.lat === s.lat);
723
723
  for (let a = c - 1; a > r; a--)
724
- e.splice(a, 1);
724
+ t.splice(a, 1);
725
725
  }
726
726
  }
727
727
  let n = 0;
728
- for (let o = 1; o < e.length; o++) {
729
- const i = e[o - 1], s = e[o];
730
- s.gcToPrevious ? (i.bearing = this.calculateBearing(i, s, !1), s.distanceFromPrevious = this.calculateDistance(i, s, !1)) : (i.bearing = this.calculateBearing(i, s, !0), s.distanceFromPrevious = this.calculateDistance(i, s, !0)), n = l.roundPrecision(n + s.distanceFromPrevious), s.distanceFromStart = n;
728
+ for (let i = 1; i < t.length; i++) {
729
+ const o = t[i - 1], s = t[i];
730
+ s.gcToPrevious ? (o.bearing = this.calculateBearing(o, s, !1), s.distanceFromPrevious = this.calculateDistance(o, s, !1)) : (o.bearing = this.calculateBearing(o, s, !0), s.distanceFromPrevious = this.calculateDistance(o, s, !0)), n = l.roundPrecision(n + s.distanceFromPrevious), s.distanceFromStart = n;
731
731
  }
732
- return e.map((o) => (o.lng = l.convertToStdLng(o.lng), o));
732
+ return t.map((i) => (i.lng = l.convertToStdLng(i.lng), i));
733
733
  }
734
734
  /**
735
735
  * 计算轨迹中心点
736
736
  * @param route
737
737
  */
738
- static calculateCenter(e) {
739
- const t = [];
740
- for (const r of e)
738
+ static calculateCenter(t) {
739
+ const e = [];
740
+ for (const r of t)
741
741
  for (const c of r)
742
- t.push(c);
743
- const n = g.featureCollection([]), o = l.convertToMonotonicLng2(t);
744
- for (const r of o)
742
+ e.push(c);
743
+ const n = g.featureCollection([]), i = l.convertToMonotonicLng2(e);
744
+ for (const r of i)
745
745
  n.features.push(g.point(r));
746
746
  const s = g.center(n).geometry.coordinates;
747
747
  return { lng: l.convertToStdLng(s[0], 8), lat: l.roundPrecision(s[1], 8) };
@@ -750,65 +750,70 @@ class P {
750
750
  * 计算中心点
751
751
  * @param coords
752
752
  */
753
- static calculateCenter2(e) {
754
- const t = this.generateRouteAccordingToWaypoints(e);
755
- return this.calculateCenter(t);
753
+ static calculateCenter2(t) {
754
+ const e = this.generateRouteAccordingToWaypoints(t);
755
+ return this.calculateCenter(e);
756
756
  }
757
757
  /**
758
758
  * 计算BBox
759
759
  * @param route
760
760
  */
761
- static calculateBBox(e) {
762
- const t = [];
763
- for (const i of e)
764
- for (const s of i)
765
- t.push(s);
766
- const n = l.convertToMonotonicLng2(t), o = g.lineString(n);
767
- return g.bbox(o);
761
+ static calculateBBox(t) {
762
+ const e = [];
763
+ for (const o of t)
764
+ for (const s of o)
765
+ e.push(s);
766
+ const n = l.convertToMonotonicLng2(e), i = g.lineString(n);
767
+ return g.bbox(i);
768
768
  }
769
769
  /**
770
770
  * 计算BBox
771
771
  * @param coords
772
772
  */
773
- static calculateBBox2(e) {
774
- const t = this.generateRouteAccordingToWaypoints(e);
775
- return this.calculateBBox(t);
773
+ static calculateBBox2(t) {
774
+ const e = this.generateRouteAccordingToWaypoints(t);
775
+ return this.calculateBBox(e);
776
776
  }
777
777
  }
778
- const D = L.getLogger("vessel");
778
+ let P;
779
+ try {
780
+ P = L.getLogger("vessel");
781
+ } catch {
782
+ } finally {
783
+ }
779
784
  class U {
780
785
  /**
781
786
  * 将原始数据转换为geojson
782
787
  * @param raw
783
788
  */
784
- static convert2Geojson(e) {
789
+ static convert2Geojson(t) {
785
790
  var n;
786
- const t = g.featureCollection([]);
787
- for (const o of e) {
788
- if (o.forecasts) {
789
- const i = (n = o.history) == null ? void 0 : n[0];
790
- for (const s of o.forecasts) {
791
- const r = [], c = N(s.date).utc(), a = `${o.name}-${s.model}`;
792
- if (i) {
793
- const d = N(i.updated).utc(), u = g.point([i.lng, i.lat], {
791
+ const e = g.featureCollection([]);
792
+ for (const i of t) {
793
+ if (i.forecasts) {
794
+ const o = (n = i.history) == null ? void 0 : n[0];
795
+ for (const s of i.forecasts) {
796
+ const r = [], c = D(s.date).utc(), a = `${i.name}-${s.model}`;
797
+ if (o) {
798
+ const d = D(o.updated).utc(), u = g.point([o.lng, o.lat], {
794
799
  model: s.model,
795
- name: o.name,
800
+ name: i.name,
796
801
  date: d.format(),
797
802
  hour: 0,
798
803
  format: d.format("MMM-DD/HHmm[Z]"),
799
- pressure: i.pressure > 1e4 ? l.roundPrecision(i.pressure / 100, 0) : l.roundPrecision(i.pressure, 0),
800
- wind: { kts: i.kts, spd: i.speed || i.spd },
804
+ pressure: o.pressure > 1e4 ? l.roundPrecision(o.pressure / 100, 0) : l.roundPrecision(o.pressure, 0),
805
+ wind: { kts: o.kts, spd: o.speed || o.spd },
801
806
  category: a,
802
807
  type: "forecast"
803
808
  });
804
- t.features.push(u), r.push(u.geometry.coordinates);
809
+ e.features.push(u), r.push(u.geometry.coordinates);
805
810
  }
806
811
  for (const d in s == null ? void 0 : s.hours) {
807
812
  const u = s.hours[d];
808
813
  u.wind.spd = u.wind.spd || u.wind.speed;
809
814
  const f = c.clone().add(Number(d), "hour"), h = g.point([u.lng, u.lat], {
810
815
  model: s.model,
811
- name: o.name,
816
+ name: i.name,
812
817
  date: f.format(),
813
818
  hour: Number(d),
814
819
  format: f.format("MMM-DD/HHmm[Z]"),
@@ -819,26 +824,26 @@ class U {
819
824
  category: a,
820
825
  type: "forecast"
821
826
  });
822
- t.features.push(h), r.push(h.geometry.coordinates);
827
+ e.features.push(h), r.push(h.geometry.coordinates);
823
828
  }
824
829
  if ((r == null ? void 0 : r.length) > 1) {
825
830
  const d = g.lineString(l.convertToMonotonicLng2(r), {
826
831
  date: s.date,
827
- id: o.id || o.name,
832
+ id: i.id || i.name,
828
833
  model: s.model,
829
- name: o.name,
834
+ name: i.name,
830
835
  category: a,
831
836
  type: "forecast"
832
837
  });
833
- t.features.push(d);
838
+ e.features.push(d);
834
839
  }
835
840
  }
836
841
  }
837
- if (o.history) {
838
- const i = [];
839
- for (const r of o.history) {
840
- const c = N(r.updated).utc(), a = g.point([r.lng, r.lat], {
841
- name: o.name,
842
+ if (i.history) {
843
+ const o = [];
844
+ for (const r of i.history) {
845
+ const c = D(r.updated).utc(), a = g.point([r.lng, r.lat], {
846
+ name: i.name,
842
847
  date: c.format(),
843
848
  format: c.format("MMM-DD/HHmm[Z]"),
844
849
  pressure: r.pressure > 1e4 ? l.roundPrecision(r.pressure / 100, 0) : l.roundPrecision(r.pressure, 0),
@@ -847,14 +852,14 @@ class U {
847
852
  source: r.source,
848
853
  level: r.type,
849
854
  type: "history",
850
- category: `${o.name}-history`
855
+ category: `${i.name}-history`
851
856
  });
852
- t.features.push(a), i.push(a.geometry.coordinates);
857
+ e.features.push(a), o.push(a.geometry.coordinates);
853
858
  }
854
- const s = o.history[0];
855
- if (i.length === 1 && i.push(i[0]), i.length > 1) {
856
- const r = g.lineString(l.convertToMonotonicLng2(i), {
857
- name: o.name,
859
+ const s = i.history[0];
860
+ if (o.length === 1 && o.push(o[0]), o.length > 1) {
861
+ const r = g.lineString(l.convertToMonotonicLng2(o), {
862
+ name: i.name,
858
863
  type: "history",
859
864
  updated: s == null ? void 0 : s.updated,
860
865
  pressure: (s == null ? void 0 : s.pressure) > 1e4 ? l.roundPrecision((s == null ? void 0 : s.pressure) / 100, 0) : l.roundPrecision(s == null ? void 0 : s.pressure, 0),
@@ -863,49 +868,49 @@ class U {
863
868
  source: s == null ? void 0 : s.source,
864
869
  level: s == null ? void 0 : s.type
865
870
  });
866
- t.features.push(r);
871
+ e.features.push(r);
867
872
  }
868
873
  }
869
874
  }
870
- return t;
875
+ return e;
871
876
  }
872
877
  /**
873
878
  * 插值台风预报轨迹
874
879
  * @param tropicals
875
880
  * @param step
876
881
  */
877
- static interpolate(e, t = 3) {
878
- var i, s, r, c;
879
- const n = (i = e == null ? void 0 : e.data) == null ? void 0 : i.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), o = [];
882
+ static interpolate(t, e = 3) {
883
+ var o, s, r, c;
884
+ const n = (o = t == null ? void 0 : t.data) == null ? void 0 : o.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), i = [];
880
885
  for (const a of n) {
881
- const d = a.properties.name, u = a.properties.model, f = a.properties.showCircle, h = N(a.properties.date).utc();
882
- let S = t * 60 - (h.get("hour") * 60 + h.get("minute")) % (t * 60);
883
- const m = (s = e == null ? void 0 : e.data) == null ? void 0 : s.features.filter(
886
+ const d = a.properties.name, u = a.properties.model, f = a.properties.showCircle, h = D(a.properties.date).utc();
887
+ let C = e * 60 - (h.get("hour") * 60 + h.get("minute")) % (e * 60);
888
+ const m = (s = t == null ? void 0 : t.data) == null ? void 0 : s.features.filter(
884
889
  (T) => T.geometry.type === "Point" && T.properties.type === "forecast" && T.properties.category === `${d}-${u}`
885
890
  );
886
- let b, C = h.clone().add(S, "minute").set({ minute: 0, second: 0, millisecond: 0 });
887
- for (; b = this.pickIndex(m, C), b <= m.length - 1; ) {
891
+ let b, M = h.clone().add(C, "minute").set({ minute: 0, second: 0, millisecond: 0 });
892
+ for (; b = this.pickIndex(m, M), b <= m.length - 1; ) {
888
893
  if (b > 0) {
889
- const T = m[b], p = b === 0 ? void 0 : m[b - 1], M = (S / 60 - ((r = p == null ? void 0 : p.properties) == null ? void 0 : r.hour)) / (T.properties.hour - ((c = p == null ? void 0 : p.properties) == null ? void 0 : c.hour)), I = this.computeNumber(p == null ? void 0 : p.geometry.coordinates[0], T.geometry.coordinates[0], M), x = this.computeNumber(p == null ? void 0 : p.geometry.coordinates[1], T.geometry.coordinates[1], M), $ = g.point([I, x], {
894
+ const T = m[b], p = b === 0 ? void 0 : m[b - 1], N = (C / 60 - ((r = p == null ? void 0 : p.properties) == null ? void 0 : r.hour)) / (T.properties.hour - ((c = p == null ? void 0 : p.properties) == null ? void 0 : c.hour)), x = this.computeNumber(p == null ? void 0 : p.geometry.coordinates[0], T.geometry.coordinates[0], N), I = this.computeNumber(p == null ? void 0 : p.geometry.coordinates[1], T.geometry.coordinates[1], N), $ = g.point([x, I], {
890
895
  name: d,
891
896
  model: u,
892
897
  category: T == null ? void 0 : T.properties.category,
893
- date: C.format(),
894
- format: C.format("MMM-DD/HHmm[Z]"),
895
- gusts: this.computeNumber(p == null ? void 0 : p.properties.gusts, T.properties.gusts, M),
896
- hour: this.computeNumber(p == null ? void 0 : p.properties.hour, T.properties.hour, M),
897
- movement: this.computeNumber(p == null ? void 0 : p.properties.movement, T.properties.movement, M),
898
- pressure: this.computeNumber(p == null ? void 0 : p.properties.pressure, T.properties.pressure, M),
899
- wind: this.computeNumber(p == null ? void 0 : p.properties.wind, T.properties.wind, M),
898
+ date: M.format(),
899
+ format: M.format("MMM-DD/HHmm[Z]"),
900
+ gusts: this.computeNumber(p == null ? void 0 : p.properties.gusts, T.properties.gusts, N),
901
+ hour: this.computeNumber(p == null ? void 0 : p.properties.hour, T.properties.hour, N),
902
+ movement: this.computeNumber(p == null ? void 0 : p.properties.movement, T.properties.movement, N),
903
+ pressure: this.computeNumber(p == null ? void 0 : p.properties.pressure, T.properties.pressure, N),
904
+ wind: this.computeNumber(p == null ? void 0 : p.properties.wind, T.properties.wind, N),
900
905
  type: "forecast",
901
906
  showCircle: f
902
907
  });
903
- o.push($);
908
+ i.push($);
904
909
  }
905
- S += t * 60, C = h.clone().add(S, "minute").set({ minute: 0, second: 0, millisecond: 0 });
910
+ C += e * 60, M = h.clone().add(C, "minute").set({ minute: 0, second: 0, millisecond: 0 });
906
911
  }
907
912
  }
908
- return o;
913
+ return i;
909
914
  }
910
915
  /**
911
916
  * 计算最佳绕航点
@@ -918,22 +923,22 @@ class U {
918
923
  * @param speed 前进速度
919
924
  * @param options
920
925
  */
921
- static diversionPassageAt(e, t, n, o = { requestId: "" }) {
922
- const { t1: i, t2: s, hr: r, hours: c } = this.tropicalCenterTwin(t, 24, o);
923
- if (i && s) {
924
- const a = P.calculateBearing(e, i), d = P.calculateBearing(i, s), u = Math.abs(a - d);
926
+ static diversionPassageAt(t, e, n, i = {}) {
927
+ const { t1: o, t2: s, hr: r, hours: c } = this.tropicalCenterTwin(e, 24, i);
928
+ if (o && s) {
929
+ const a = S.calculateBearing(t, o), d = S.calculateBearing(o, s), u = Math.abs(a - d);
925
930
  let f = 0;
926
931
  u < 180 ? f = u + 90 : u >= 180 && (f = u - 90);
927
- const h = P.calculateCoordinate(i, f, n);
928
- return D.info("[%s] the right tangent position: %j", o.requestId, {
929
- from: e,
930
- t1: i,
932
+ const h = S.calculateCoordinate(o, f, n);
933
+ return P == null || P.info("[%s] the right tangent position: %j", i.requestId, {
934
+ from: t,
935
+ t1: o,
931
936
  t2: s,
932
937
  radius: n,
933
938
  bearing1: a,
934
939
  bearing2: d,
935
940
  right: h
936
- }), { at: h, t1: i, t2: s, hr: Number(r), hours: c };
941
+ }), { at: h, t1: o, t2: s, hr: Number(r), hours: c };
937
942
  }
938
943
  return {};
939
944
  }
@@ -947,13 +952,13 @@ class U {
947
952
  * @param radius 与台风中心的距离
948
953
  * @param options
949
954
  */
950
- static driftPassageAt(e, t, n, o = { requestId: "" }) {
951
- const { t1: i, t2: s, hr: r, hours: c } = this.tropicalCenterTwin(t, 24, o);
952
- if (i && s) {
953
- const a = P.calculateBearing(e, i), d = P.calculateBearing(i, s), u = P.calculateDistance(e, i);
954
- return { at: P.calculateCoordinate(i, a - d + 180, n < u ? n : u), t1: i, t2: s, hr: Number(r), hours: c };
955
+ static driftPassageAt(t, e, n, i = {}) {
956
+ const { t1: o, t2: s, hr: r, hours: c } = this.tropicalCenterTwin(e, 24, i);
957
+ if (o && s) {
958
+ const a = S.calculateBearing(t, o), d = S.calculateBearing(o, s), u = S.calculateDistance(t, o);
959
+ return { at: S.calculateCoordinate(o, a - d + 180, n < u ? n : u), t1: o, t2: s, hr: Number(r), hours: c };
955
960
  } else
956
- return D.info("[%s] no need drift: %j", o.requestId, { from: e, t1: i, t2: s, hr: r }), {};
961
+ return P == null || P.info("[%s] no need drift: %j", i.requestId, { from: t, t1: o, t2: s, hr: r }), {};
957
962
  }
958
963
  /**
959
964
  * 获取台风中心点对
@@ -962,50 +967,50 @@ class U {
962
967
  * @param options
963
968
  * @private
964
969
  */
965
- static tropicalCenterTwin(e, t = 24, n = { requestId: "" }) {
966
- var d, u, f, h, S;
967
- let o = {};
968
- (d = e.forecasts) == null || d.forEach((m) => {
969
- o = { ...m.hours, ...o };
970
+ static tropicalCenterTwin(t, e = 24, n = {}) {
971
+ var d, u, f, h, C;
972
+ let i = {};
973
+ (d = t.forecasts) == null || d.forEach((m) => {
974
+ i = { ...m.hours, ...i };
970
975
  });
971
- const i = ((u = e == null ? void 0 : e.history) == null ? void 0 : u[0]) || (o == null ? void 0 : o[(f = Object.keys(o)) == null ? void 0 : f[0]]);
972
- D.info("[%s] the first tropical center: %j", n.requestId, i);
973
- let s = (h = Object.keys(o || {}).filter((m) => Number(m) <= (t < 0 ? 24 : t))) == null ? void 0 : h.at(-1);
974
- s || (s = (S = Object.keys(o || {}).filter((m) => Number(m) <= (t < 0 ? 24 : 2 * t))) == null ? void 0 : S.at(-1));
975
- const r = o == null ? void 0 : o[s || -1];
976
- D.info("[%s] the second tropical center: %j in %d hrs", n.requestId, r, s);
977
- const c = Object.keys(o || {}).filter((m) => Number(m) <= Number(s)), a = { 0: i };
976
+ const o = ((u = t == null ? void 0 : t.history) == null ? void 0 : u[0]) || (i == null ? void 0 : i[(f = Object.keys(i)) == null ? void 0 : f[0]]);
977
+ P == null || P.info("[%s] the first tropical center: %j", n.requestId, o);
978
+ let s = (h = Object.keys(i || {}).filter((m) => Number(m) <= (e < 0 ? 24 : e))) == null ? void 0 : h.at(-1);
979
+ s || (s = (C = Object.keys(i || {}).filter((m) => Number(m) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : C.at(-1));
980
+ const r = i == null ? void 0 : i[s || -1];
981
+ P == null || P.info("[%s] the second tropical center: %j in %d hrs", n.requestId, r, s);
982
+ const c = Object.keys(i || {}).filter((m) => Number(m) <= Number(s)), a = { 0: o };
978
983
  for (const m of c)
979
- a[m] = o[m];
980
- return { t1: i, t2: r, hr: s, hours: a };
984
+ a[m] = i[m];
985
+ return { t1: o, t2: r, hr: s, hours: a };
981
986
  }
982
- static pickIndex(e, t) {
987
+ static pickIndex(t, e) {
983
988
  let n = 0;
984
- for (const o of e) {
985
- if (N(o.properties.date).isAfter(t))
989
+ for (const i of t) {
990
+ if (D(i.properties.date).isAfter(e))
986
991
  return n === 0 ? -1 : n;
987
992
  n++;
988
993
  }
989
994
  return n;
990
995
  }
991
- static computeNumber(e, t, n) {
992
- if (e)
993
- if (t) {
994
- if (isNaN(e) && isNaN(t) && typeof e != "string" && typeof t != "string") {
995
- const o = {};
996
- for (const i in e)
997
- o[i] = this.computeNumber(e[i], t[i], n);
998
- return o;
996
+ static computeNumber(t, e, n) {
997
+ if (t)
998
+ if (e) {
999
+ if (isNaN(t) && isNaN(e) && typeof t != "string" && typeof e != "string") {
1000
+ const i = {};
1001
+ for (const o in t)
1002
+ i[o] = this.computeNumber(t[o], e[o], n);
1003
+ return i;
999
1004
  }
1000
- return Math.round((e + (t - e) * n) * 100) / 100;
1005
+ return Math.round((t + (e - t) * n) * 100) / 100;
1001
1006
  } else
1002
- return e;
1007
+ return t;
1003
1008
  else
1004
- return t;
1009
+ return e;
1005
1010
  }
1006
1011
  }
1007
1012
  export {
1008
- P as LaneHelper,
1013
+ S as LaneHelper,
1009
1014
  l as LngLatHelper,
1010
1015
  U as TropicalHelper
1011
1016
  };