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