@idm-plugin/geo 2.0.4 → 2.0.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/ais/src/index.d.ts +11 -0
- package/dist/index.js +100 -82
- package/dist/index.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/ais/src/index.d.ts
CHANGED
|
@@ -32,4 +32,15 @@ export declare class AisHelper {
|
|
|
32
32
|
static json2Str(json: AISRecord): string;
|
|
33
33
|
static str2Json(str: string): AISRecord;
|
|
34
34
|
static inspectStoppages(rows: AISRecord[], threshold?: number, onlyAis?: boolean): any[];
|
|
35
|
+
/**
|
|
36
|
+
* 计算轨迹摘要
|
|
37
|
+
* @param rows
|
|
38
|
+
* @param stm
|
|
39
|
+
* @param etm
|
|
40
|
+
*/
|
|
41
|
+
static inspectSummary(rows: AISRecord[], stm: string, etm: string): {
|
|
42
|
+
distance: number;
|
|
43
|
+
interval: number;
|
|
44
|
+
avgSpd: number;
|
|
45
|
+
};
|
|
35
46
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as f from "@turf/turf";
|
|
2
2
|
import u from "moment";
|
|
3
3
|
import j from "@log4js-node/log4js-api";
|
|
4
4
|
var n0 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
@@ -40,7 +40,7 @@ var x = { exports: {} };
|
|
|
40
40
|
o[X] = Math.round((o[X - 1] || 0) + o[X] * 6e4);
|
|
41
41
|
o[n - 1] = 1 / 0;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function r(o, n) {
|
|
44
44
|
var X = [], L;
|
|
45
45
|
for (L = 0; L < n.length; L++)
|
|
46
46
|
X[L] = o[n[L]];
|
|
@@ -50,8 +50,8 @@ var x = { exports: {} };
|
|
|
50
50
|
var n = o.split("|"), X = n[2].split(" "), L = n[3].split(""), e = n[4].split(" ");
|
|
51
51
|
return N(X), N(L), N(e), i(e, L.length), {
|
|
52
52
|
name: n[0],
|
|
53
|
-
abbrs:
|
|
54
|
-
offsets:
|
|
53
|
+
abbrs: r(n[1].split(" "), L),
|
|
54
|
+
offsets: r(X, L),
|
|
55
55
|
untils: e,
|
|
56
56
|
population: n[5] | 0
|
|
57
57
|
};
|
|
@@ -1135,8 +1135,8 @@ const L0 = "2025b", T0 = [
|
|
|
1135
1135
|
links: i0,
|
|
1136
1136
|
countries: e0
|
|
1137
1137
|
};
|
|
1138
|
-
var
|
|
1139
|
-
|
|
1138
|
+
var f0 = R0;
|
|
1139
|
+
f0.tz.load(N0);
|
|
1140
1140
|
var M0 = { exports: {} };
|
|
1141
1141
|
(function(m) {
|
|
1142
1142
|
function M(z, b) {
|
|
@@ -1152,8 +1152,8 @@ var M0 = { exports: {} };
|
|
|
1152
1152
|
}
|
|
1153
1153
|
m.exports = M;
|
|
1154
1154
|
})(M0);
|
|
1155
|
-
var
|
|
1156
|
-
const r0 = /* @__PURE__ */ X0(
|
|
1155
|
+
var S0 = M0.exports;
|
|
1156
|
+
const r0 = /* @__PURE__ */ X0(S0);
|
|
1157
1157
|
class a {
|
|
1158
1158
|
/**
|
|
1159
1159
|
* 基于输入的经度,计算出时区
|
|
@@ -1344,7 +1344,7 @@ class B0 {
|
|
|
1344
1344
|
if (b && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))
|
|
1345
1345
|
continue;
|
|
1346
1346
|
const T = R.positionTime - d.positionTime;
|
|
1347
|
-
if (
|
|
1347
|
+
if (S.calculateDistance(R, d, !0, 4) / (T / 3600) < z)
|
|
1348
1348
|
O || (O = q), Y === M.length - 1 && (A = R, W = Y);
|
|
1349
1349
|
else {
|
|
1350
1350
|
O && (A = M[Y - 1], W = Y);
|
|
@@ -1368,14 +1368,32 @@ class B0 {
|
|
|
1368
1368
|
utc: u.unix(A.positionTime).utc().format()
|
|
1369
1369
|
},
|
|
1370
1370
|
duration: A.positionTime - O.positionTime
|
|
1371
|
-
}, d = M.filter((T) => T.positionTime >= Y.start.positionTime && T.positionTime <= Y.end.positionTime), R =
|
|
1372
|
-
Y.distance =
|
|
1371
|
+
}, d = M.filter((T) => T.positionTime >= Y.start.positionTime && T.positionTime <= Y.end.positionTime), R = S.divideAccordingToLng(d);
|
|
1372
|
+
Y.distance = S.calculateRouteDistance(R), Y.hours = Math.round(Y.duration / 3600 * 10) / 10, Y.avgSog = Math.round(Y.distance / Y.hours * 10) / 10, c.push(Y);
|
|
1373
1373
|
}
|
|
1374
1374
|
O = void 0, A = void 0;
|
|
1375
1375
|
}
|
|
1376
1376
|
}
|
|
1377
1377
|
return p || M.sort((W, q) => q.positionTime - W.positionTime), c;
|
|
1378
1378
|
}
|
|
1379
|
+
/**
|
|
1380
|
+
* 计算轨迹摘要
|
|
1381
|
+
* @param rows
|
|
1382
|
+
* @param stm
|
|
1383
|
+
* @param etm
|
|
1384
|
+
*/
|
|
1385
|
+
static inspectSummary(M, z, b) {
|
|
1386
|
+
const p = u(z), c = u(b), O = M.filter((Y) => Y.positionTime >= p.unix() && Y.positionTime <= c.unix());
|
|
1387
|
+
let A = 0, W = 0;
|
|
1388
|
+
if (O.length > 1)
|
|
1389
|
+
for (let Y = 0; Y < O.length - 1; Y++) {
|
|
1390
|
+
const d = O[Y], R = O[Y + 1];
|
|
1391
|
+
A += S.calculateDistance(d, R, !0, 4), W += Math.abs(R.positionTime - d.positionTime);
|
|
1392
|
+
}
|
|
1393
|
+
A = Math.round(A * 100) / 100, W = Math.round(W / 3600 * 100) / 100;
|
|
1394
|
+
const q = W ? Math.round(A / W * 100) / 100 : 0;
|
|
1395
|
+
return { distance: A, interval: W, avgSpd: q };
|
|
1396
|
+
}
|
|
1379
1397
|
}
|
|
1380
1398
|
let Q;
|
|
1381
1399
|
try {
|
|
@@ -1383,7 +1401,7 @@ try {
|
|
|
1383
1401
|
} catch {
|
|
1384
1402
|
} finally {
|
|
1385
1403
|
}
|
|
1386
|
-
class
|
|
1404
|
+
class S {
|
|
1387
1405
|
/**
|
|
1388
1406
|
* 计算方位角
|
|
1389
1407
|
* @param from 坐标 {lng, lat}
|
|
@@ -1393,12 +1411,12 @@ class r {
|
|
|
1393
1411
|
* @returns {number} 单位度
|
|
1394
1412
|
*/
|
|
1395
1413
|
static calculateBearing(M, z, b = !0, p = 4) {
|
|
1396
|
-
const c =
|
|
1414
|
+
const c = f.points([
|
|
1397
1415
|
[M.lng, M.lat],
|
|
1398
1416
|
[z.lng, z.lat]
|
|
1399
1417
|
]);
|
|
1400
1418
|
let O;
|
|
1401
|
-
return b ? O =
|
|
1419
|
+
return b ? O = f.rhumbBearing(c.features[0], c.features[1]) : O = f.bearing(c.features[0], c.features[1]), O < 0 && (O += 360), a.roundPrecision(O, p);
|
|
1402
1420
|
}
|
|
1403
1421
|
/**
|
|
1404
1422
|
* 计算两点间距离
|
|
@@ -1411,12 +1429,12 @@ class r {
|
|
|
1411
1429
|
*/
|
|
1412
1430
|
static calculateDistance(M, z, b = !0, p = 4, c = "nauticalmiles") {
|
|
1413
1431
|
M = { ...M }, z = { ...z }, M.lng = a.convertToStdLng(M.lng, p), z.lng = a.convertToStdLng(z.lng, p);
|
|
1414
|
-
const O =
|
|
1432
|
+
const O = f.points([
|
|
1415
1433
|
[M.lng, M.lat],
|
|
1416
1434
|
[z.lng, z.lat]
|
|
1417
1435
|
]);
|
|
1418
1436
|
let A;
|
|
1419
|
-
return b ? A =
|
|
1437
|
+
return b ? A = f.rhumbDistance(O.features[0], O.features[1], { units: c }) : A = f.distance(O.features[0], O.features[1], { units: c }), a.roundPrecision(A, p);
|
|
1420
1438
|
}
|
|
1421
1439
|
/**
|
|
1422
1440
|
* 计算航线距离
|
|
@@ -1444,9 +1462,9 @@ class r {
|
|
|
1444
1462
|
* @param rhumb
|
|
1445
1463
|
*/
|
|
1446
1464
|
static calculateCoordinate(M, z, b, p = "nauticalmiles", c = !0) {
|
|
1447
|
-
const O =
|
|
1465
|
+
const O = f.point([M.lng, M.lat]);
|
|
1448
1466
|
let A;
|
|
1449
|
-
c ? A =
|
|
1467
|
+
c ? A = f.rhumbDestination(O, b, z, { units: p }) : A = f.destination(O, b, z, { units: p });
|
|
1450
1468
|
const W = A.geometry.coordinates;
|
|
1451
1469
|
return { lng: a.convertToStdLng(W[0], 8), lat: a.roundPrecision(W[1], 8) };
|
|
1452
1470
|
}
|
|
@@ -1495,14 +1513,14 @@ class r {
|
|
|
1495
1513
|
[A, M[W + 1].lat]
|
|
1496
1514
|
]);
|
|
1497
1515
|
let d, R;
|
|
1498
|
-
z ? (d =
|
|
1516
|
+
z ? (d = f.lineString(Y), R = f.lineString([
|
|
1499
1517
|
[q > 0 ? 180 : -180, 89],
|
|
1500
1518
|
[q > 0 ? 180 : -180, -89]
|
|
1501
|
-
])) : (d =
|
|
1502
|
-
const T =
|
|
1519
|
+
])) : (d = f.greatCircle(Y[0], Y[1]), R = f.greatCircle([q > 0 ? 180 : -180, 89], [q > 0 ? 180 : -180, -89]));
|
|
1520
|
+
const T = f.lineIntersect(d, R);
|
|
1503
1521
|
let N;
|
|
1504
1522
|
if (T.features.length) {
|
|
1505
|
-
const i =
|
|
1523
|
+
const i = f.getCoord(T.features[0]);
|
|
1506
1524
|
N = a.roundPrecision(i[1], 8);
|
|
1507
1525
|
} else
|
|
1508
1526
|
N = M[W].lat;
|
|
@@ -1582,8 +1600,8 @@ class r {
|
|
|
1582
1600
|
*/
|
|
1583
1601
|
static appendCoordinateToRoute(M, z) {
|
|
1584
1602
|
M.lng = a.convertToStdLng(M.lng, 8);
|
|
1585
|
-
const b =
|
|
1586
|
-
return b.push(M),
|
|
1603
|
+
const b = S.convertRouteToCoordinates(z);
|
|
1604
|
+
return b.push(M), S.divideAccordingToLng(b);
|
|
1587
1605
|
}
|
|
1588
1606
|
/**
|
|
1589
1607
|
* 向route头加1个坐标
|
|
@@ -1591,8 +1609,8 @@ class r {
|
|
|
1591
1609
|
* @param route
|
|
1592
1610
|
*/
|
|
1593
1611
|
static unshiftCoordinateToRoute(M, z) {
|
|
1594
|
-
const b =
|
|
1595
|
-
return b.unshift(M),
|
|
1612
|
+
const b = S.convertRouteToCoordinates(z);
|
|
1613
|
+
return b.unshift(M), S.divideAccordingToLng(b);
|
|
1596
1614
|
}
|
|
1597
1615
|
/**
|
|
1598
1616
|
* 合并多个waypoints进航线
|
|
@@ -1666,8 +1684,8 @@ class r {
|
|
|
1666
1684
|
* @return [[[lng, lat]]]
|
|
1667
1685
|
*/
|
|
1668
1686
|
static calculateSubRoute(M, z) {
|
|
1669
|
-
const b =
|
|
1670
|
-
|
|
1687
|
+
const b = S.convertRouteToCoordinates(z);
|
|
1688
|
+
S.mergeCoordinateToWaypoints(M, b, !0), z = S.divideAccordingToLng(b);
|
|
1671
1689
|
const { segIndex: p, minIndex: c } = this.calculateMinDistanceToRoute({ ...M }, z);
|
|
1672
1690
|
M.lng = a.convertToStdLng(M.lng);
|
|
1673
1691
|
const O = [];
|
|
@@ -1717,10 +1735,10 @@ class r {
|
|
|
1717
1735
|
M.lng = a.convertToStdLng(M.lng, 8), z = { ...z }, b = { ...b }, z.lng = a.convertToStdLng(z.lng, 8), b.lng = a.convertToStdLng(b.lng, 8);
|
|
1718
1736
|
const c = a.convertToMonotonicLng([z, b]);
|
|
1719
1737
|
z = c[0], b = c[1];
|
|
1720
|
-
const O =
|
|
1738
|
+
const O = f.lineString([
|
|
1721
1739
|
[z.lng, z.lat],
|
|
1722
1740
|
[b.lng, b.lat]
|
|
1723
|
-
]), A =
|
|
1741
|
+
]), A = f.pointToLineDistance(f.point([M.lng, M.lat]), O, p), W = f.pointToLineDistance(f.point([M.lng > 0 ? M.lng - 360 : M.lng + 360, M.lat]), O, p);
|
|
1724
1742
|
return a.roundPrecision(Math.min(A, W), 6);
|
|
1725
1743
|
}
|
|
1726
1744
|
/**
|
|
@@ -1805,7 +1823,7 @@ class r {
|
|
|
1805
1823
|
* @param route [[[lng, lat]]]
|
|
1806
1824
|
*/
|
|
1807
1825
|
static nearestCoordinateInRoute(M, z) {
|
|
1808
|
-
const b =
|
|
1826
|
+
const b = f.point([M.lng, M.lat]), c = this.convertRouteToCoordinates(z).map((q) => [q.lng, q.lat]), O = f.lineString(c), A = f.nearestPointOnLine(O, b), W = f.getCoord(A);
|
|
1809
1827
|
return { lng: a.roundPrecision(W[0], 8), lat: a.roundPrecision(W[1], 8) };
|
|
1810
1828
|
}
|
|
1811
1829
|
/**
|
|
@@ -1846,26 +1864,26 @@ class r {
|
|
|
1846
1864
|
A.push(T);
|
|
1847
1865
|
else {
|
|
1848
1866
|
const i = [];
|
|
1849
|
-
let
|
|
1867
|
+
let r;
|
|
1850
1868
|
for (let s = 0; s < T.length; s++)
|
|
1851
1869
|
if (d)
|
|
1852
1870
|
i.push(T[s]);
|
|
1853
1871
|
else {
|
|
1854
|
-
|
|
1855
|
-
const P = this.calculateDistance(M,
|
|
1872
|
+
r = { lng: T[s][0], lat: T[s][1] };
|
|
1873
|
+
const P = this.calculateDistance(M, r, !0, 8, p);
|
|
1856
1874
|
if (q += P, q < z)
|
|
1857
|
-
Y += P, P && O.push(
|
|
1875
|
+
Y += P, P && O.push(r), M = r;
|
|
1858
1876
|
else {
|
|
1859
1877
|
if (Y = z, q === z)
|
|
1860
|
-
d =
|
|
1878
|
+
d = r, i.push([d.lng, d.lat]);
|
|
1861
1879
|
else {
|
|
1862
|
-
const l = q - z, B = this.calculateBearing(
|
|
1863
|
-
d = this.calculateCoordinate(
|
|
1880
|
+
const l = q - z, B = this.calculateBearing(r, M);
|
|
1881
|
+
d = this.calculateCoordinate(r, B, l, p), i.push([d.lng, d.lat]), i.push([r.lng, r.lat]);
|
|
1864
1882
|
}
|
|
1865
1883
|
W = !0;
|
|
1866
1884
|
}
|
|
1867
1885
|
}
|
|
1868
|
-
i.length && A.push(i), N === b.length - 1 && !d && (d =
|
|
1886
|
+
i.length && A.push(i), N === b.length - 1 && !d && (d = r);
|
|
1869
1887
|
}
|
|
1870
1888
|
})) : (A = b, d = { ...M }), d)
|
|
1871
1889
|
if (O.push(d), d.distanceFromPrevious = Math.round(Y * 1e4) / 1e4, d.hourFromPrevious = Math.round(Y / c * 1e4) / 1e4, ((R = A[0]) == null ? void 0 : R.length) > 1) {
|
|
@@ -1882,10 +1900,10 @@ class r {
|
|
|
1882
1900
|
* @param to {lng, lat}
|
|
1883
1901
|
*/
|
|
1884
1902
|
static nearestCoordinateInLine(M, z, b) {
|
|
1885
|
-
const p = a.convertToStdLng(M.lng, 6), c =
|
|
1903
|
+
const p = a.convertToStdLng(M.lng, 6), c = f.point([p, M.lat]), O = a.convertToStdLng(z.lng, 6), A = a.convertToStdLng(b.lng, 6), W = f.lineString([
|
|
1886
1904
|
[O, z.lat],
|
|
1887
1905
|
[A, b.lat]
|
|
1888
|
-
]), q =
|
|
1906
|
+
]), q = f.nearestPointOnLine(W, c), Y = f.getCoord(q), d = a.roundPrecision(Y[0], 6), R = a.roundPrecision(Y[1], 6);
|
|
1889
1907
|
return { lng: d, lat: R, inline: !(d === O && R === z.lat) && !(d === A && R === b.lat) };
|
|
1890
1908
|
}
|
|
1891
1909
|
/**
|
|
@@ -1954,10 +1972,10 @@ class r {
|
|
|
1954
1972
|
for (const A of M)
|
|
1955
1973
|
for (const W of A)
|
|
1956
1974
|
z.push(W);
|
|
1957
|
-
const b =
|
|
1975
|
+
const b = f.featureCollection([]), p = a.convertToMonotonicLng2(z);
|
|
1958
1976
|
for (const A of p)
|
|
1959
|
-
b.features.push(
|
|
1960
|
-
const O =
|
|
1977
|
+
b.features.push(f.point(A));
|
|
1978
|
+
const O = f.center(b).geometry.coordinates;
|
|
1961
1979
|
return { lng: a.convertToStdLng(O[0], 8), lat: a.roundPrecision(O[1], 8) };
|
|
1962
1980
|
}
|
|
1963
1981
|
/**
|
|
@@ -1977,8 +1995,8 @@ class r {
|
|
|
1977
1995
|
for (const c of M)
|
|
1978
1996
|
for (const O of c)
|
|
1979
1997
|
z.push(O);
|
|
1980
|
-
const b = a.convertToMonotonicLng2(z), p =
|
|
1981
|
-
return
|
|
1998
|
+
const b = a.convertToMonotonicLng2(z), p = f.lineString(b);
|
|
1999
|
+
return f.bbox(p);
|
|
1982
2000
|
}
|
|
1983
2001
|
/**
|
|
1984
2002
|
* 计算BBox
|
|
@@ -2000,7 +2018,7 @@ class r {
|
|
|
2000
2018
|
const O = M[c - 1], A = M[c], W = M[c + 1];
|
|
2001
2019
|
let q = !1, Y = !1;
|
|
2002
2020
|
if ((O.velocity || O.suspend || O.important || O.pilot || c === 1) && (q = !0, p.push(O)), A.gcToPrevious && (q || (q = !0, p.push(O)), Y = !0, p.push(A), c++), W) {
|
|
2003
|
-
const d =
|
|
2021
|
+
const d = S.calculateDistance(O, A, !0), R = S.calculateDistance(A, W, !0), T = S.calculateDistance(O, W, !0), N = (Math.pow(d, 2) + Math.pow(R, 2) - Math.pow(T, 2)) / (2 * d * R);
|
|
2004
2022
|
Math.round(Math.acos(N) * 180 / Math.PI) < b && T > z && !Y && (p.push(A), c++);
|
|
2005
2023
|
}
|
|
2006
2024
|
if (c >= M.length - 1) {
|
|
@@ -2035,8 +2053,8 @@ class r {
|
|
|
2035
2053
|
if (!p) {
|
|
2036
2054
|
const q = (O = (c = z.filter((d) => (d == null ? void 0 : d.positionTime) < b.unix())) == null ? void 0 : c.sort((d, R) => (d.positionTime || 0) - (R.positionTime || 0))) == null ? void 0 : O.at(-1), Y = (W = (A = z.filter((d) => (d == null ? void 0 : d.positionTime) > b.unix())) == null ? void 0 : A.sort((d, R) => (d.positionTime || 0) - (R.positionTime || 0))) == null ? void 0 : W.at(0);
|
|
2037
2055
|
if (q && Y) {
|
|
2038
|
-
const d =
|
|
2039
|
-
p =
|
|
2056
|
+
const d = S.calculateBearing(q, Y, !0), R = S.calculateDistance(q, Y), T = (b.unix() - q.positionTime) / (Y.positionTime - q.positionTime);
|
|
2057
|
+
p = S.calculateCoordinate(q, d, R * T), p.positionTime = b.unix(), p.utc = b.utc().format(), p.cog = d, p.sog = Math.round(R / ((Y.positionTime - q.positionTime) / 3600) * 100) / 100;
|
|
2040
2058
|
} else
|
|
2041
2059
|
p = q || Y, p && (p.utc = u.unix(p == null ? void 0 : p.positionTime).utc().format());
|
|
2042
2060
|
}
|
|
@@ -2051,16 +2069,16 @@ class r {
|
|
|
2051
2069
|
z = JSON.parse(JSON.stringify(z)), z.sort((q, Y) => (q.positionTime || 0) - (Y.positionTime || 0));
|
|
2052
2070
|
let b = Number.MAX_SAFE_INTEGER, p = Number.MAX_SAFE_INTEGER;
|
|
2053
2071
|
for (let q = 0; q < z.length - 1; q++) {
|
|
2054
|
-
const Y = z[q], d = z[q + 1], R =
|
|
2072
|
+
const Y = z[q], d = z[q + 1], R = S.calculatePointToLineDistance(M, Y, d);
|
|
2055
2073
|
R < b && (b = R, p = q);
|
|
2056
2074
|
}
|
|
2057
|
-
const c = z[p], O = z[p + 1], A =
|
|
2075
|
+
const c = z[p], O = z[p + 1], A = S.calculateDistance(c, M), W = S.calculateDistance(O, M);
|
|
2058
2076
|
if (A === 0)
|
|
2059
2077
|
M = c;
|
|
2060
2078
|
else if (W === 0)
|
|
2061
2079
|
M = O;
|
|
2062
2080
|
else {
|
|
2063
|
-
const q = c.positionTime || 0, Y = O.positionTime || 0, d =
|
|
2081
|
+
const q = c.positionTime || 0, Y = O.positionTime || 0, d = S.calculateDistance(c, O);
|
|
2064
2082
|
M.positionTime = Math.round(q + (Y - q) * (A / d));
|
|
2065
2083
|
}
|
|
2066
2084
|
return M.utc = M.positionTime ? u.unix(M.positionTime).utc().format() : void 0, M.positionTime ? M : void 0;
|
|
@@ -2116,12 +2134,12 @@ class r {
|
|
|
2116
2134
|
{ hours: 0, distance: 0, spd: 0, duration: 0 }
|
|
2117
2135
|
);
|
|
2118
2136
|
d.hours = Math.round(d.duration / 3600 * 100) / 100, d.distance = Math.round(d.distance * 100) / 100, d.spd = d.hours ? Math.round(d.distance / d.hours * 100) / 100 : 0;
|
|
2119
|
-
const R = A ? Math.round(q / (A - d.hours) * 100) / 100 : 0;
|
|
2137
|
+
const R = A ? Math.round((q - d.distance) / (A - d.hours) * 100) / 100 : 0;
|
|
2120
2138
|
return {
|
|
2121
2139
|
begin: c.utc().format(),
|
|
2122
2140
|
end: O.utc().format(),
|
|
2123
|
-
distance: q,
|
|
2124
|
-
hours: A - d.hours,
|
|
2141
|
+
distance: Math.round((q - d.distance) * 100) / 100,
|
|
2142
|
+
hours: Math.round((A - d.hours) * 100) / 100,
|
|
2125
2143
|
avgSpeed: R,
|
|
2126
2144
|
stoppage: d
|
|
2127
2145
|
};
|
|
@@ -2152,11 +2170,11 @@ class r {
|
|
|
2152
2170
|
if (!A) {
|
|
2153
2171
|
const T = z.sample.hours.filter((G) => u.utc(G.eta).isBefore(O)).at(-1), N = this.calculateSubRoute(T, z.route);
|
|
2154
2172
|
A = (R = this.calculateNextCoordinateAlongRoute(T, T.speed * O.diff(u(T.etd), "hours", !0), N)) == null ? void 0 : R.coordinate;
|
|
2155
|
-
const { cFactor: i, cog:
|
|
2173
|
+
const { cFactor: i, cog: r, wxFactor: s, meteo: P } = T, l = Math.round(A.distanceFromPrevious * 1e4) / 1e4, B = Math.round((l + T.distanceFromStart) * 1e4) / 1e4;
|
|
2156
2174
|
A = {
|
|
2157
2175
|
...A,
|
|
2158
2176
|
cFactor: i,
|
|
2159
|
-
cog:
|
|
2177
|
+
cog: r,
|
|
2160
2178
|
speed: T.speed,
|
|
2161
2179
|
wxFactor: s,
|
|
2162
2180
|
distanceFromStart: B,
|
|
@@ -2219,7 +2237,7 @@ class V0 {
|
|
|
2219
2237
|
*/
|
|
2220
2238
|
static convert2Geojson(M) {
|
|
2221
2239
|
var b, p, c;
|
|
2222
|
-
const z =
|
|
2240
|
+
const z = f.featureCollection([]);
|
|
2223
2241
|
for (const O of M) {
|
|
2224
2242
|
const A = (b = O.history) == null ? void 0 : b[0];
|
|
2225
2243
|
if (O.forecasts) {
|
|
@@ -2228,19 +2246,19 @@ class V0 {
|
|
|
2228
2246
|
let q;
|
|
2229
2247
|
const Y = [], d = [], R = u(W.date).utc(), T = `${O.name}-${W.model}`;
|
|
2230
2248
|
for (const i in W == null ? void 0 : W.hours) {
|
|
2231
|
-
const
|
|
2232
|
-
q = q ||
|
|
2233
|
-
const s = R.clone().add(Number(i), "hour"), P =
|
|
2249
|
+
const r = W.hours[i];
|
|
2250
|
+
q = q || r;
|
|
2251
|
+
const s = R.clone().add(Number(i), "hour"), P = f.point([r.lng, r.lat], {
|
|
2234
2252
|
model: W.model,
|
|
2235
2253
|
name: O.name,
|
|
2236
2254
|
nameCn: O.nameCn,
|
|
2237
2255
|
date: s.format(),
|
|
2238
2256
|
hour: Number(i),
|
|
2239
2257
|
format: s.format("MMM-DD/HHmm[Z]"),
|
|
2240
|
-
pressure:
|
|
2241
|
-
gusts:
|
|
2242
|
-
wind:
|
|
2243
|
-
movement:
|
|
2258
|
+
pressure: r.pressure > 1e4 ? a.roundPrecision(r.pressure / 100, 0) : a.roundPrecision(r.pressure, 0),
|
|
2259
|
+
gusts: r.gusts,
|
|
2260
|
+
wind: r.wind || {},
|
|
2261
|
+
movement: r.movement,
|
|
2244
2262
|
category: T,
|
|
2245
2263
|
type: "forecast"
|
|
2246
2264
|
});
|
|
@@ -2253,10 +2271,10 @@ class V0 {
|
|
|
2253
2271
|
if (A) {
|
|
2254
2272
|
const i = u(A.updated).utc();
|
|
2255
2273
|
if (q) {
|
|
2256
|
-
const s =
|
|
2257
|
-
N.kts = Math.round(s / P * 100) / 100, N.deg =
|
|
2274
|
+
const s = S.calculateDistance(A, q), P = u(q.utc || q.updated).diff(i, "h", !0);
|
|
2275
|
+
N.kts = Math.round(s / P * 100) / 100, N.deg = S.calculateBearing(A, q, !0, 0);
|
|
2258
2276
|
}
|
|
2259
|
-
const
|
|
2277
|
+
const r = f.point([A.lng, A.lat], {
|
|
2260
2278
|
model: W.model,
|
|
2261
2279
|
name: O.name,
|
|
2262
2280
|
nameCn: O.nameCn,
|
|
@@ -2271,10 +2289,10 @@ class V0 {
|
|
|
2271
2289
|
important: !0
|
|
2272
2290
|
// 第一个预报点为重要点
|
|
2273
2291
|
});
|
|
2274
|
-
d.unshift(
|
|
2292
|
+
d.unshift(r), Y.unshift(r.geometry.coordinates);
|
|
2275
2293
|
}
|
|
2276
2294
|
if (z.features.push(...d), (Y == null ? void 0 : Y.length) > 1) {
|
|
2277
|
-
const i =
|
|
2295
|
+
const i = f.lineString(a.convertToMonotonicLng2(Y), {
|
|
2278
2296
|
date: (A == null ? void 0 : A.updated) || (R == null ? void 0 : R.format()),
|
|
2279
2297
|
id: O.id || O.name,
|
|
2280
2298
|
model: W.model,
|
|
@@ -2292,7 +2310,7 @@ class V0 {
|
|
|
2292
2310
|
for (const R of O.history) {
|
|
2293
2311
|
const T = u(R.updated).utc(), N = T.isSameOrBefore(q) || T.isSame(Y);
|
|
2294
2312
|
N && q.add(-d, "h");
|
|
2295
|
-
const i =
|
|
2313
|
+
const i = f.point([R.lng, R.lat], {
|
|
2296
2314
|
name: O.name,
|
|
2297
2315
|
nameCn: O.nameCn,
|
|
2298
2316
|
date: T.format(),
|
|
@@ -2309,7 +2327,7 @@ class V0 {
|
|
|
2309
2327
|
z.features.push(i), W.push(i.geometry.coordinates);
|
|
2310
2328
|
}
|
|
2311
2329
|
if (W.length === 1 && W.push(W[0]), W.length > 1) {
|
|
2312
|
-
const R =
|
|
2330
|
+
const R = f.lineString(a.convertToMonotonicLng2(W), {
|
|
2313
2331
|
name: O.name,
|
|
2314
2332
|
type: "history",
|
|
2315
2333
|
updated: A == null ? void 0 : A.updated,
|
|
@@ -2334,13 +2352,13 @@ class V0 {
|
|
|
2334
2352
|
for (const q of b) {
|
|
2335
2353
|
const Y = q.properties.name, d = q.properties.model, R = q.properties.showCircle, T = q.properties.disabled, N = u(q.properties.date).utc();
|
|
2336
2354
|
let i = z * 60;
|
|
2337
|
-
const
|
|
2355
|
+
const r = (O = M == null ? void 0 : M.data) == null ? void 0 : O.features.filter(
|
|
2338
2356
|
(l) => l.geometry.type === "Point" && l.properties.type === "forecast" && l.properties.category === `${Y}-${d}`
|
|
2339
2357
|
);
|
|
2340
2358
|
let s, P = N.clone().add(i, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
2341
|
-
for (; s = this.pickIndex(
|
|
2359
|
+
for (; s = this.pickIndex(r, P), s <= r.length - 1; ) {
|
|
2342
2360
|
if (s > 0) {
|
|
2343
|
-
const l =
|
|
2361
|
+
const l = r[s], B = s === 0 ? void 0 : r[s - 1], G = (i / 60 - ((A = B == null ? void 0 : B.properties) == null ? void 0 : A.hour)) / (l.properties.hour - ((W = B == null ? void 0 : B.properties) == null ? void 0 : W.hour)), H = this.computeNumber(B == null ? void 0 : B.geometry.coordinates[0], l.geometry.coordinates[0], G), F = this.computeNumber(B == null ? void 0 : B.geometry.coordinates[1], l.geometry.coordinates[1], G), $ = f.point([H, F], {
|
|
2344
2362
|
name: Y,
|
|
2345
2363
|
model: d,
|
|
2346
2364
|
category: l == null ? void 0 : l.properties.category,
|
|
@@ -2387,7 +2405,7 @@ class V0 {
|
|
|
2387
2405
|
const { t1: c, t2: O, hr: A, hours: W } = this.tropicalCenterTwin(z, 24, p);
|
|
2388
2406
|
if (c && O) {
|
|
2389
2407
|
if (!p.debug) {
|
|
2390
|
-
const N =
|
|
2408
|
+
const N = S.calculateDistance(M, c), i = S.calculateDistance(M, O);
|
|
2391
2409
|
if (N > 2 * b && i > 2 * b)
|
|
2392
2410
|
return I == null || I.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", p.requestId, N, i, {
|
|
2393
2411
|
from: M,
|
|
@@ -2396,10 +2414,10 @@ class V0 {
|
|
|
2396
2414
|
hr: A
|
|
2397
2415
|
}), {};
|
|
2398
2416
|
}
|
|
2399
|
-
const q =
|
|
2417
|
+
const q = S.calculateBearing(M, c), Y = S.calculateBearing(c, O), d = Math.abs(q - Y);
|
|
2400
2418
|
let R = 0;
|
|
2401
2419
|
d < 180 ? R = d + 90 : d >= 180 && (R = d - 90);
|
|
2402
|
-
const T =
|
|
2420
|
+
const T = S.calculateCoordinate(c, R, b);
|
|
2403
2421
|
return I == null || I.info("[%s] the right tangent position: %j", p.requestId, {
|
|
2404
2422
|
from: M,
|
|
2405
2423
|
t1: c,
|
|
@@ -2426,7 +2444,7 @@ class V0 {
|
|
|
2426
2444
|
const { t1: c, t2: O, hr: A, hours: W } = this.tropicalCenterTwin(z, 24, p);
|
|
2427
2445
|
if (c && O) {
|
|
2428
2446
|
if (!p.debug) {
|
|
2429
|
-
const T =
|
|
2447
|
+
const T = S.calculateDistance(M, c), N = S.calculateDistance(M, O);
|
|
2430
2448
|
if (T > 2 * b && N > 2 * b)
|
|
2431
2449
|
return I == null || I.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", p.requestId, T, N, {
|
|
2432
2450
|
from: M,
|
|
@@ -2435,8 +2453,8 @@ class V0 {
|
|
|
2435
2453
|
hr: A
|
|
2436
2454
|
}), {};
|
|
2437
2455
|
}
|
|
2438
|
-
const q =
|
|
2439
|
-
return { at:
|
|
2456
|
+
const q = S.calculateBearing(M, c), Y = S.calculateBearing(c, O), d = S.calculateDistance(M, c);
|
|
2457
|
+
return { at: S.calculateCoordinate(c, q - Y + 180, b < d ? b : d), t1: c, t2: O, hr: Number(A), hours: W };
|
|
2440
2458
|
} else
|
|
2441
2459
|
return I == null || I.info("[%s] no need drift: %j", p.requestId, { from: M, t1: c, t2: O, hr: A }), {};
|
|
2442
2460
|
}
|
|
@@ -2492,7 +2510,7 @@ class V0 {
|
|
|
2492
2510
|
}
|
|
2493
2511
|
export {
|
|
2494
2512
|
B0 as AisHelper,
|
|
2495
|
-
|
|
2513
|
+
S as LaneHelper,
|
|
2496
2514
|
a as LngLatHelper,
|
|
2497
2515
|
V0 as TropicalHelper
|
|
2498
2516
|
};
|