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