@idm-plugin/vessel 3.4.7 → 3.4.8
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 +472 -458
- package/dist/index.umd.cjs +1 -1
- package/dist/speed/src/index.d.ts +12 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var lt = Object.defineProperty;
|
|
2
|
+
var mt = (x, e, t) => e in x ? lt(x, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : x[e] = t;
|
|
3
|
+
var U = (x, e, t) => (mt(x, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
4
|
import B from "got";
|
|
5
|
-
import
|
|
5
|
+
import dt from "@log4js-node/log4js-api";
|
|
6
6
|
import v from "moment";
|
|
7
|
-
import { LaneHelper as
|
|
8
|
-
import { MeteoHelper2 as
|
|
9
|
-
import { Meteo2Assist as
|
|
7
|
+
import { LaneHelper as W, LngLatHelper as z } from "@idm-plugin/geo2";
|
|
8
|
+
import { MeteoHelper2 as ft } from "@idm-plugin/meteo2";
|
|
9
|
+
import { Meteo2Assist as ct } from "@idm-plugin/meteo";
|
|
10
10
|
let M;
|
|
11
11
|
try {
|
|
12
|
-
M =
|
|
12
|
+
M = dt.getLogger("vessel");
|
|
13
13
|
} catch {
|
|
14
14
|
} finally {
|
|
15
15
|
}
|
|
16
|
-
class
|
|
16
|
+
class at {
|
|
17
17
|
/**
|
|
18
18
|
* 解析AIS状态码
|
|
19
19
|
* @param status
|
|
20
20
|
*/
|
|
21
|
-
parseStatus(
|
|
21
|
+
parseStatus(e) {
|
|
22
22
|
let t, a;
|
|
23
|
-
switch (
|
|
23
|
+
switch (e) {
|
|
24
24
|
case 0:
|
|
25
25
|
t = "在航(主机推动)", a = "Underway Using Engine";
|
|
26
26
|
break;
|
|
@@ -54,12 +54,12 @@ class ot {
|
|
|
54
54
|
return { labelCn: t, labelEn: a };
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
class
|
|
57
|
+
class Tt extends at {
|
|
58
58
|
constructor(t, a) {
|
|
59
59
|
super();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
U(this, "clientId");
|
|
61
|
+
U(this, "clientSecret");
|
|
62
|
+
U(this, "token");
|
|
63
63
|
this.clientId = t, this.clientSecret = a;
|
|
64
64
|
}
|
|
65
65
|
async authToken(t = {}) {
|
|
@@ -89,11 +89,11 @@ class Nt extends ot {
|
|
|
89
89
|
* @param options
|
|
90
90
|
*/
|
|
91
91
|
async suggest(t, a = {}) {
|
|
92
|
-
var
|
|
92
|
+
var s, r;
|
|
93
93
|
await this.checkToken(a);
|
|
94
94
|
const i = "https://market.myvessel.cn/sdc/v1/mkt/vessels/fuzzy", n = {
|
|
95
95
|
headers: {
|
|
96
|
-
Authorization: `${(
|
|
96
|
+
Authorization: `${(s = this.token) == null ? void 0 : s.tokenType} ${(r = this.token) == null ? void 0 : r.accessToken}`
|
|
97
97
|
},
|
|
98
98
|
json: {
|
|
99
99
|
kw: t,
|
|
@@ -122,14 +122,14 @@ class Nt extends ot {
|
|
|
122
122
|
async search(t, a = {}) {
|
|
123
123
|
var h, l;
|
|
124
124
|
await this.checkToken(a);
|
|
125
|
-
const i = /^\d{7}$/.test(t.toString()), n = i ? "https://market.myvessel.cn/sdc/v1/mkt/vessels/detail/imo" : "https://market.myvessel.cn/sdc/v1/mkt/vessels/detail/mmsi", o = i ? { imo: t } : { mmsi: t },
|
|
125
|
+
const i = /^\d{7}$/.test(t.toString()), n = i ? "https://market.myvessel.cn/sdc/v1/mkt/vessels/detail/imo" : "https://market.myvessel.cn/sdc/v1/mkt/vessels/detail/mmsi", o = i ? { imo: t } : { mmsi: t }, s = {
|
|
126
126
|
headers: {
|
|
127
127
|
Authorization: `${(h = this.token) == null ? void 0 : h.tokenType} ${(l = this.token) == null ? void 0 : l.accessToken}`
|
|
128
128
|
},
|
|
129
129
|
searchParams: o
|
|
130
130
|
};
|
|
131
|
-
M == null || M.info("[%s] fetch vessel from: %s - %j", a.requestId, n,
|
|
132
|
-
const r = await B.get(n,
|
|
131
|
+
M == null || M.info("[%s] fetch vessel from: %s - %j", a.requestId, n, s);
|
|
132
|
+
const r = await B.get(n, s).json();
|
|
133
133
|
if (r.status !== 200)
|
|
134
134
|
return M == null || M.warn("[%s] fetch suggest vessels failed: %j", a.requestId, { message: r.message, status: r.status, code: r.code }), {};
|
|
135
135
|
{
|
|
@@ -162,11 +162,11 @@ class Nt extends ot {
|
|
|
162
162
|
return {};
|
|
163
163
|
}
|
|
164
164
|
async archives(t, a = {}) {
|
|
165
|
-
var
|
|
165
|
+
var s, r;
|
|
166
166
|
await this.checkToken(a);
|
|
167
167
|
const i = "https://svc.data.myvessel.cn/sdc/v1/ship/info/batch", n = {
|
|
168
168
|
headers: {
|
|
169
|
-
Authorization: `${(
|
|
169
|
+
Authorization: `${(s = this.token) == null ? void 0 : s.tokenType} ${(r = this.token) == null ? void 0 : r.accessToken}`
|
|
170
170
|
},
|
|
171
171
|
json: {
|
|
172
172
|
mmsiList: typeof t == "number" ? [t] : t
|
|
@@ -189,38 +189,38 @@ class Nt extends ot {
|
|
|
189
189
|
const o = await B.get(i, n).json();
|
|
190
190
|
if (o.code)
|
|
191
191
|
return M == null || M.warn("[%s] fetch realtime position failed: %j", a.requestId, { message: o.message, status: o.status, code: o.code }), o;
|
|
192
|
-
const
|
|
193
|
-
for (const l in
|
|
194
|
-
!isNaN(
|
|
195
|
-
if (
|
|
196
|
-
const l = v(`${
|
|
192
|
+
const s = o.data;
|
|
193
|
+
for (const l in s)
|
|
194
|
+
!isNaN(s[l]) && Number(s[l]) !== 1 / 0 && (s[l] = Number(s[l]));
|
|
195
|
+
if (s) {
|
|
196
|
+
const l = v(`${s.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
197
197
|
return {
|
|
198
|
-
mmsi:
|
|
199
|
-
name:
|
|
200
|
-
imo:
|
|
201
|
-
callSign:
|
|
202
|
-
lat:
|
|
203
|
-
lng:
|
|
204
|
-
length:
|
|
205
|
-
width:
|
|
206
|
-
draught:
|
|
207
|
-
sog:
|
|
208
|
-
cog:
|
|
209
|
-
hdg:
|
|
210
|
-
rot:
|
|
211
|
-
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(
|
|
212
|
-
destination:
|
|
198
|
+
mmsi: s.mmsi,
|
|
199
|
+
name: s.vesselName || s.aisVesselName,
|
|
200
|
+
imo: s.imo,
|
|
201
|
+
callSign: s.callsign || s.aisCallSign,
|
|
202
|
+
lat: s.lat,
|
|
203
|
+
lng: s.lon,
|
|
204
|
+
length: s.length,
|
|
205
|
+
width: s.width,
|
|
206
|
+
draught: s.currDraught,
|
|
207
|
+
sog: s.sog,
|
|
208
|
+
cog: s.cog,
|
|
209
|
+
hdg: s.hdg,
|
|
210
|
+
rot: s.rot,
|
|
211
|
+
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta) ? v.utc(s.eta).format() : void 0,
|
|
212
|
+
destination: s.dest,
|
|
213
213
|
positionTime: l.unix(),
|
|
214
|
-
status:
|
|
215
|
-
labelCn:
|
|
216
|
-
labelEn:
|
|
217
|
-
vesselType:
|
|
218
|
-
flag:
|
|
219
|
-
clasz:
|
|
220
|
-
build:
|
|
221
|
-
dwt:
|
|
222
|
-
grt:
|
|
223
|
-
net:
|
|
214
|
+
status: s.status,
|
|
215
|
+
labelCn: s.statusNameCn,
|
|
216
|
+
labelEn: s.statusNameEn,
|
|
217
|
+
vesselType: s.vesselTypeNameEn,
|
|
218
|
+
flag: s.flagCtryNameEn,
|
|
219
|
+
clasz: s.classSociety,
|
|
220
|
+
build: s.buildYear,
|
|
221
|
+
dwt: s.dwt,
|
|
222
|
+
grt: s.grt,
|
|
223
|
+
net: s.net,
|
|
224
224
|
method: "position",
|
|
225
225
|
vendor: "myVessel",
|
|
226
226
|
utc: l.utc().format()
|
|
@@ -236,10 +236,10 @@ class Nt extends ot {
|
|
|
236
236
|
* @param excludeSeas 排除水域, [sea.code]
|
|
237
237
|
* @param options { requiretId: '请求ID', useAIModel: '启用AI算法', withECA: '是否计算低硫区航行距离', withSpecial: '是否计算穿越的特战区列表和海盗区列表', draught: '最大吃水' }
|
|
238
238
|
*/
|
|
239
|
-
async calculateRoute(t, a, i, n, o,
|
|
239
|
+
async calculateRoute(t, a, i, n, o, s = {}) {
|
|
240
240
|
var y, w, g;
|
|
241
241
|
const r = v();
|
|
242
|
-
await this.checkToken(
|
|
242
|
+
await this.checkToken(s);
|
|
243
243
|
const h = "https://svc.data.myvessel.cn/sdc/v1/routes/routing/nodes", l = {
|
|
244
244
|
headers: {
|
|
245
245
|
Authorization: `${(y = this.token) == null ? void 0 : y.tokenType} ${(w = this.token) == null ? void 0 : w.accessToken}`
|
|
@@ -253,16 +253,16 @@ class Nt extends ot {
|
|
|
253
253
|
lon: a.lng,
|
|
254
254
|
lat: a.lat
|
|
255
255
|
},
|
|
256
|
-
maxDraught:
|
|
257
|
-
useAIModel:
|
|
258
|
-
withECA:
|
|
259
|
-
withSpecialRegion:
|
|
256
|
+
maxDraught: s.draught || 10,
|
|
257
|
+
useAIModel: s.useAIModel || !1,
|
|
258
|
+
withECA: s.withECA || !1,
|
|
259
|
+
withSpecialRegion: s.withSpecial || !1
|
|
260
260
|
}
|
|
261
261
|
};
|
|
262
|
-
i != null && i.length && (l.json.crossMonthList = i), n != null && n.length && (l.json.excludeNodes = n), o != null && o.length && (l.json.excludeSeaAreas = o), M == null || M.info("[%s] fetch route from: %s - %j",
|
|
262
|
+
i != null && i.length && (l.json.crossMonthList = i), n != null && n.length && (l.json.excludeNodes = n), o != null && o.length && (l.json.excludeSeaAreas = o), M == null || M.info("[%s] fetch route from: %s - %j", s.requestId, h, l);
|
|
263
263
|
const d = await B.post(h, l).json();
|
|
264
264
|
if (d.status !== 200)
|
|
265
|
-
return M == null || M.warn("[%s] fetch route failed: %j",
|
|
265
|
+
return M == null || M.warn("[%s] fetch route failed: %j", s.requestId, { message: d.message, status: d.status, code: d.code }), {};
|
|
266
266
|
{
|
|
267
267
|
const k = {
|
|
268
268
|
status: "Success",
|
|
@@ -273,7 +273,7 @@ class Nt extends ot {
|
|
|
273
273
|
route: [],
|
|
274
274
|
distance: 0,
|
|
275
275
|
memo: ""
|
|
276
|
-
}, { nodes: j, seas:
|
|
276
|
+
}, { nodes: j, seas: b, tracks: p, specialRegions: f } = d.data;
|
|
277
277
|
k.nodes = j == null ? void 0 : j.map((c) => ({
|
|
278
278
|
code: c.nodeCode,
|
|
279
279
|
nameEn: c.nameEn,
|
|
@@ -297,7 +297,7 @@ class Nt extends ot {
|
|
|
297
297
|
isKey: c.isKeyNode,
|
|
298
298
|
// 重要枢纽节点
|
|
299
299
|
isHub: c.isHubNode
|
|
300
|
-
})), k.seas =
|
|
300
|
+
})), k.seas = b == null ? void 0 : b.map((c) => ({
|
|
301
301
|
code: c.mrgidSea,
|
|
302
302
|
nameEn: c.nameEn,
|
|
303
303
|
nameCn: c.nameCn,
|
|
@@ -326,23 +326,23 @@ class Nt extends ot {
|
|
|
326
326
|
distance: I.length
|
|
327
327
|
}))
|
|
328
328
|
});
|
|
329
|
-
}), k.waypoints =
|
|
329
|
+
}), k.waypoints = p == null ? void 0 : p.map((c) => ({
|
|
330
330
|
lat: Math.round(c.lat * 1e5) / 1e5,
|
|
331
331
|
lng: Math.round(c.lon * 1e5) / 1e5
|
|
332
|
-
})), (g = k.waypoints) != null && g.length && (k.waypoints =
|
|
332
|
+
})), (g = k.waypoints) != null && g.length && (k.waypoints = W.simplifyCoordinates(k.waypoints), k.route = W.divideAccordingToLng(k.waypoints), k.distance = W.calculateRouteDistance(k.route));
|
|
333
333
|
const m = v().diff(r, "second");
|
|
334
|
-
return k.memo = `time cost: ${m}s`, M.info("[%s] calculate route cost: %d seconds",
|
|
334
|
+
return k.memo = `time cost: ${m}s`, M.info("[%s] calculate route cost: %d seconds", s.requestId, m), k;
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
-
async trajectory(t, a, i, n, o = !0,
|
|
338
|
-
await this.checkToken(
|
|
339
|
-
const r = await this.realTimePosition(t,
|
|
337
|
+
async trajectory(t, a, i, n, o = !0, s = {}) {
|
|
338
|
+
await this.checkToken(s);
|
|
339
|
+
const r = await this.realTimePosition(t, s), h = v(a), l = v(i), d = [];
|
|
340
340
|
for (; l.diff(h, "day", !0) > 30; )
|
|
341
|
-
await this.trajectoryIn30Day(t, h, h.clone().add(30, "day"), r, n, d,
|
|
342
|
-
return await this.trajectoryIn30Day(t, h, l, r, n, d,
|
|
341
|
+
await this.trajectoryIn30Day(t, h, h.clone().add(30, "day"), r, n, d, s), h.add(30, "day");
|
|
342
|
+
return await this.trajectoryIn30Day(t, h, l, r, n, d, s), d;
|
|
343
343
|
}
|
|
344
|
-
async trajectoryIn30Day(t, a, i, n, o,
|
|
345
|
-
var g, k, j,
|
|
344
|
+
async trajectoryIn30Day(t, a, i, n, o, s, r = {}) {
|
|
345
|
+
var g, k, j, b, p;
|
|
346
346
|
const h = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/track", l = {
|
|
347
347
|
headers: {
|
|
348
348
|
Authorization: `${(g = this.token) == null ? void 0 : g.tokenType} ${(k = this.token) == null ? void 0 : k.accessToken}`
|
|
@@ -358,10 +358,10 @@ class Nt extends ot {
|
|
|
358
358
|
if (d.code)
|
|
359
359
|
return M == null || M.warn("[%s] fetch trajectory failed: %j", r.requestId, h, { message: d.message, status: d.status, code: d.code }), d;
|
|
360
360
|
let y = -1;
|
|
361
|
-
const w = v(`${(
|
|
362
|
-
return (
|
|
363
|
-
for (const
|
|
364
|
-
!isNaN(f[
|
|
361
|
+
const w = v(`${(b = (j = d.data) == null ? void 0 : j[0]) == null ? void 0 : b.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
362
|
+
return (p = d.data) == null || p.forEach((f) => {
|
|
363
|
+
for (const P in f)
|
|
364
|
+
!isNaN(f[P]) && Number(f[P]) !== 1 / 0 && (f[P] = Number(f[P]));
|
|
365
365
|
const u = v(`${f.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), m = f.status, { labelCn: c, labelEn: I } = this.parseStatus(m), C = {
|
|
366
366
|
mmsi: f.mmsi,
|
|
367
367
|
imo: n == null ? void 0 : n.imo,
|
|
@@ -381,14 +381,14 @@ class Nt extends ot {
|
|
|
381
381
|
vendor: "myVessel",
|
|
382
382
|
utc: u.utc().format()
|
|
383
383
|
}, F = Math.floor(u.diff(w, "minute", !0) / (o || 1));
|
|
384
|
-
F !== y && (y = F,
|
|
385
|
-
}),
|
|
384
|
+
F !== y && (y = F, s.push(C));
|
|
385
|
+
}), s;
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
class
|
|
388
|
+
class Ft extends at {
|
|
389
389
|
constructor(t) {
|
|
390
390
|
super();
|
|
391
|
-
|
|
391
|
+
U(this, "token");
|
|
392
392
|
this.token = t;
|
|
393
393
|
}
|
|
394
394
|
async realTimePosition(t, a = {}) {
|
|
@@ -399,33 +399,33 @@ class xt extends ot {
|
|
|
399
399
|
}
|
|
400
400
|
}, o = await B.post(i, n).json();
|
|
401
401
|
M == null || M.info("[%s] fetch realtime position from: %s - %j", a.requestId, i, n);
|
|
402
|
-
const
|
|
403
|
-
if (!
|
|
402
|
+
const s = o == null ? void 0 : o.list;
|
|
403
|
+
if (!s)
|
|
404
404
|
return M == null || M.warn("[%s] fetch realtime position failed: %j", a.requestId, i, o), o;
|
|
405
|
-
for (const w in
|
|
406
|
-
!isNaN(
|
|
407
|
-
|
|
408
|
-
const r =
|
|
405
|
+
for (const w in s)
|
|
406
|
+
!isNaN(s[w]) && Number(s[w]) !== 1 / 0 && (s[w] = Number(s[w]));
|
|
407
|
+
s.status = s.sp > 3 ? 0 : 1;
|
|
408
|
+
const r = s.status, { labelCn: h, labelEn: l } = this.parseStatus(r), d = v(`${s.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
409
409
|
return {
|
|
410
|
-
mmsi:
|
|
411
|
-
name:
|
|
412
|
-
imo:
|
|
413
|
-
callSign:
|
|
414
|
-
lat: Math.round(
|
|
415
|
-
lng: Math.round(
|
|
416
|
-
length:
|
|
417
|
-
width:
|
|
418
|
-
draught:
|
|
419
|
-
sog:
|
|
420
|
-
cog:
|
|
421
|
-
hdg:
|
|
422
|
-
rot: isNaN(
|
|
423
|
-
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(
|
|
424
|
-
destination:
|
|
425
|
-
vesselType:
|
|
426
|
-
dwt:
|
|
427
|
-
build:
|
|
428
|
-
flag:
|
|
410
|
+
mmsi: s.m,
|
|
411
|
+
name: s.n,
|
|
412
|
+
imo: s.imonumber,
|
|
413
|
+
callSign: s.callsign,
|
|
414
|
+
lat: Math.round(s.la / 60 * 1e5) / 1e5,
|
|
415
|
+
lng: Math.round(s.lo / 60 * 1e5) / 1e5,
|
|
416
|
+
length: s.l,
|
|
417
|
+
width: s.w,
|
|
418
|
+
draught: s.draught,
|
|
419
|
+
sog: s.sp,
|
|
420
|
+
cog: s.co,
|
|
421
|
+
hdg: s.h,
|
|
422
|
+
rot: isNaN(s.rot) ? 0 : s.rot,
|
|
423
|
+
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta) ? v.utc(s.eta).format() : void 0,
|
|
424
|
+
destination: s.destination,
|
|
425
|
+
vesselType: s.type,
|
|
426
|
+
dwt: s.dwt,
|
|
427
|
+
build: s.buildyear,
|
|
428
|
+
flag: s.fn,
|
|
429
429
|
positionTime: d.unix(),
|
|
430
430
|
utc: d.utc().format(),
|
|
431
431
|
status: r,
|
|
@@ -451,7 +451,7 @@ class xt extends ot {
|
|
|
451
451
|
M == null || M.info("[%s] fetch vessel props from: %s - %j", a.requestId, i, n), o instanceof Array && (o = o[0]);
|
|
452
452
|
for (const r in o)
|
|
453
453
|
!isNaN(o[r]) && Number(o[r]) !== 1 / 0 && (o[r] = Number(o[r]));
|
|
454
|
-
const
|
|
454
|
+
const s = {
|
|
455
455
|
mmsi: o.m,
|
|
456
456
|
name: o.n,
|
|
457
457
|
imo: o.i,
|
|
@@ -461,7 +461,7 @@ class xt extends ot {
|
|
|
461
461
|
draught: o.dr,
|
|
462
462
|
type: o.t
|
|
463
463
|
};
|
|
464
|
-
return i = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", o = await B.post(i, n).json(), M == null || M.info("[%s] search vessel dead weight from: %s - %j", a.requestId, i, n), o instanceof Array && (o = o[0]), o && (
|
|
464
|
+
return i = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", o = await B.post(i, n).json(), M == null || M.info("[%s] search vessel dead weight from: %s - %j", a.requestId, i, n), o instanceof Array && (o = o[0]), o && (s.deadweight = Number(o.dwt)), s;
|
|
465
465
|
}
|
|
466
466
|
async suggest(t, a = {}) {
|
|
467
467
|
const i = "https://www.hifleet.com/hifleetapi/getShipSuggest.do", n = {
|
|
@@ -475,20 +475,20 @@ class xt extends ot {
|
|
|
475
475
|
}
|
|
476
476
|
}, o = await B.post(i, n).json();
|
|
477
477
|
M == null || M.info("[%s] suggest vessel props from: %s - %j", a.requestId, i, n);
|
|
478
|
-
const
|
|
478
|
+
const s = [];
|
|
479
479
|
for (const r of o)
|
|
480
|
-
|
|
480
|
+
s.push({
|
|
481
481
|
mmsi: !r.mmsi || isNaN(r.mmsi) ? null : Number(r.mmsi),
|
|
482
482
|
name: r.name,
|
|
483
483
|
callSign: r.callsign,
|
|
484
484
|
imo: !r.imo || isNaN(r.imo) ? null : Number(r.imo),
|
|
485
485
|
score: r._score
|
|
486
486
|
});
|
|
487
|
-
return
|
|
487
|
+
return s.sort((r, h) => h.score - r.score), s;
|
|
488
488
|
}
|
|
489
|
-
async trajectory(t, a, i, n, o = !0,
|
|
489
|
+
async trajectory(t, a, i, n, o = !0, s = {}) {
|
|
490
490
|
var f, u, m;
|
|
491
|
-
const r = await this.realTimePosition(t,
|
|
491
|
+
const r = await this.realTimePosition(t, s);
|
|
492
492
|
let h = v(a);
|
|
493
493
|
const l = v(i), d = v();
|
|
494
494
|
if (o) {
|
|
@@ -503,18 +503,18 @@ class xt extends ot {
|
|
|
503
503
|
usertoken: this.token
|
|
504
504
|
}
|
|
505
505
|
}, w = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token", g = await B.get(w, y).json();
|
|
506
|
-
M == null || M.info("[%s] fetch trajectory from: %s - %j",
|
|
506
|
+
M == null || M.info("[%s] fetch trajectory from: %s - %j", s.requestId, w, y);
|
|
507
507
|
let k;
|
|
508
|
-
g && (k = ((u = (f = g.ships) == null ? void 0 : f.offors) == null ? void 0 : u.ship) || [], k.length || M == null || M.warn("[%s] fetch trajectory failed: %j",
|
|
508
|
+
g && (k = ((u = (f = g.ships) == null ? void 0 : f.offors) == null ? void 0 : u.ship) || [], k.length || M == null || M.warn("[%s] fetch trajectory failed: %j", s.requestId, g));
|
|
509
509
|
const j = [];
|
|
510
|
-
let
|
|
511
|
-
const
|
|
510
|
+
let b = -1;
|
|
511
|
+
const p = v(`${(m = k == null ? void 0 : k[0]) == null ? void 0 : m.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
512
512
|
for (const c of k) {
|
|
513
513
|
for (const H in c)
|
|
514
514
|
!isNaN(c[H]) && Number(c[H]) !== 1 / 0 && (c[H] = Number(c[H]));
|
|
515
515
|
const I = v(`${c.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
516
516
|
c.status = c.sp > 4 ? 0 : 1;
|
|
517
|
-
const { labelEn: C, labelCn: F } = this.parseStatus(c.status),
|
|
517
|
+
const { labelEn: C, labelCn: F } = this.parseStatus(c.status), P = {
|
|
518
518
|
mmsi: c.m,
|
|
519
519
|
name: c.n,
|
|
520
520
|
imo: r == null ? void 0 : r.imo,
|
|
@@ -531,16 +531,16 @@ class xt extends ot {
|
|
|
531
531
|
labelEn: C,
|
|
532
532
|
method: "trajectory",
|
|
533
533
|
vendor: "hifleet"
|
|
534
|
-
},
|
|
535
|
-
|
|
534
|
+
}, D = Math.floor(I.diff(p, "minute", !0) / (n || 1));
|
|
535
|
+
D !== b && (b = D, j.push(P));
|
|
536
536
|
}
|
|
537
537
|
return j;
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
|
-
class
|
|
540
|
+
class Nt extends at {
|
|
541
541
|
constructor(t) {
|
|
542
542
|
super();
|
|
543
|
-
|
|
543
|
+
U(this, "token");
|
|
544
544
|
this.token = t;
|
|
545
545
|
}
|
|
546
546
|
async realTimePosition(t, a = {}) {
|
|
@@ -553,36 +553,36 @@ class Dt extends ot {
|
|
|
553
553
|
}, n = "https://api.shipxy.com/apicall/GetSingleShip", o = await B.get(n, i).json();
|
|
554
554
|
if (M == null || M.info("[%s] fetch realtime position from: %s - %j", a.requestId, n, i), (o == null ? void 0 : o.status) !== 0)
|
|
555
555
|
return o;
|
|
556
|
-
const
|
|
557
|
-
for (const y in
|
|
558
|
-
!isNaN(
|
|
559
|
-
const { labelCn: r, labelEn: h } = await this.parseStatus(
|
|
556
|
+
const s = o.data[0];
|
|
557
|
+
for (const y in s)
|
|
558
|
+
!isNaN(s[y]) && Number(s[y]) !== 1 / 0 && (s[y] = Number(s[y]));
|
|
559
|
+
const { labelCn: r, labelEn: h } = await this.parseStatus(s.navistat), l = v.unix(s.lasttime);
|
|
560
560
|
return {
|
|
561
|
-
mmsi:
|
|
562
|
-
name:
|
|
563
|
-
imo:
|
|
564
|
-
callSign:
|
|
565
|
-
lat: Math.round(
|
|
566
|
-
lng: Math.round(
|
|
567
|
-
length: Math.round(
|
|
568
|
-
width: Math.round(
|
|
569
|
-
draught: Math.round(
|
|
570
|
-
sog: Math.round(
|
|
571
|
-
cog: Math.round(
|
|
572
|
-
hdg: Math.round(
|
|
573
|
-
rot: Math.round(
|
|
574
|
-
positionTime:
|
|
561
|
+
mmsi: s.ShipID,
|
|
562
|
+
name: s.name,
|
|
563
|
+
imo: s.imo,
|
|
564
|
+
callSign: s.callsign,
|
|
565
|
+
lat: Math.round(s.lat / 1e6 * 1e5) / 1e5,
|
|
566
|
+
lng: Math.round(s.lon / 1e6 * 1e5) / 1e5,
|
|
567
|
+
length: Math.round(s.length / 10 * 100) / 100,
|
|
568
|
+
width: Math.round(s.width / 10 * 100) / 100,
|
|
569
|
+
draught: Math.round(s.draught / 1e3 * 100) / 100,
|
|
570
|
+
sog: Math.round(s.sog * 3600 / 1e3 / 1852 * 100) / 100,
|
|
571
|
+
cog: Math.round(s.cog / 100 * 100) / 100,
|
|
572
|
+
hdg: Math.round(s.hdg / 100 * 100) / 100,
|
|
573
|
+
rot: Math.round(s.rot / 100 * 100) / 100,
|
|
574
|
+
positionTime: s.lasttime,
|
|
575
575
|
utc: l.utc().format(),
|
|
576
|
-
status:
|
|
576
|
+
status: s.navistat,
|
|
577
577
|
labelEn: h,
|
|
578
578
|
labelCn: r,
|
|
579
579
|
method: "position",
|
|
580
580
|
vendor: "shipxy"
|
|
581
581
|
};
|
|
582
582
|
}
|
|
583
|
-
async trajectory(t, a, i, n, o = !0,
|
|
584
|
-
var
|
|
585
|
-
const r = await this.realTimePosition(t,
|
|
583
|
+
async trajectory(t, a, i, n, o = !0, s = {}) {
|
|
584
|
+
var p;
|
|
585
|
+
const r = await this.realTimePosition(t, s), h = v(a), l = v(i), d = "https://api.shipxy.com/apicall/GetShipTrack", y = {
|
|
586
586
|
searchParams: {
|
|
587
587
|
id: t,
|
|
588
588
|
k: this.token,
|
|
@@ -592,10 +592,10 @@ class Dt extends ot {
|
|
|
592
592
|
etm: l.unix()
|
|
593
593
|
}
|
|
594
594
|
}, w = await B.get(d, y).json();
|
|
595
|
-
if (M == null || M.info("[%s] fetch trajectory from: %s - %j",
|
|
595
|
+
if (M == null || M.info("[%s] fetch trajectory from: %s - %j", s.requestId, d, y), (w == null ? void 0 : w.status) !== 0)
|
|
596
596
|
return w;
|
|
597
|
-
const g = w == null ? void 0 : w.points, k = [], j = v.unix((
|
|
598
|
-
let
|
|
597
|
+
const g = w == null ? void 0 : w.points, k = [], j = v.unix((p = g[0]) == null ? void 0 : p.utc);
|
|
598
|
+
let b = -1;
|
|
599
599
|
for (const f of g) {
|
|
600
600
|
const u = v.unix(f.utc), m = {
|
|
601
601
|
imo: r == null ? void 0 : r.imo,
|
|
@@ -609,15 +609,15 @@ class Dt extends ot {
|
|
|
609
609
|
method: "trajectory",
|
|
610
610
|
vendor: "shipxy"
|
|
611
611
|
}, c = Math.floor(u.diff(j, "minute", !0) / (n || 1));
|
|
612
|
-
c !==
|
|
612
|
+
c !== b && (b = c, k.push(m));
|
|
613
613
|
}
|
|
614
614
|
return k;
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
|
-
class
|
|
617
|
+
class xt extends at {
|
|
618
618
|
constructor(t) {
|
|
619
619
|
super();
|
|
620
|
-
|
|
620
|
+
U(this, "token");
|
|
621
621
|
this.token = t;
|
|
622
622
|
}
|
|
623
623
|
async getShipId(t, a = {}) {
|
|
@@ -642,16 +642,16 @@ class At extends ot {
|
|
|
642
642
|
}, n = "https://api3.myships.com/sp/ships/aissta", o = await B.post(n, i).json();
|
|
643
643
|
if (M == null || M.info("[%s] fetch ship info from: %s - %j", a.requestId, n, i), o.code !== "0")
|
|
644
644
|
return o;
|
|
645
|
-
const
|
|
646
|
-
let r =
|
|
647
|
-
return t === "407170" && (r = "9198379", M == null || M.warn("[%s] ship(%s) imo error: %s, should be %s", a.requestId, t,
|
|
648
|
-
mmsi:
|
|
649
|
-
name:
|
|
645
|
+
const s = o.data;
|
|
646
|
+
let r = s.imo;
|
|
647
|
+
return t === "407170" && (r = "9198379", M == null || M.warn("[%s] ship(%s) imo error: %s, should be %s", a.requestId, t, s.imo, r)), {
|
|
648
|
+
mmsi: s.mmsi,
|
|
649
|
+
name: s.shipnameEn,
|
|
650
650
|
imo: r,
|
|
651
|
-
callSign:
|
|
652
|
-
length:
|
|
653
|
-
width:
|
|
654
|
-
draught: (
|
|
651
|
+
callSign: s.callSign,
|
|
652
|
+
length: s.length,
|
|
653
|
+
width: s.breadth,
|
|
654
|
+
draught: (s.draught || 100) / 10
|
|
655
655
|
};
|
|
656
656
|
}
|
|
657
657
|
async realTimePosition(t, a = {}) {
|
|
@@ -662,8 +662,8 @@ class At extends ot {
|
|
|
662
662
|
json: {
|
|
663
663
|
shipId: i
|
|
664
664
|
}
|
|
665
|
-
},
|
|
666
|
-
M == null || M.info("[%s] fetch realtime position from: %s - %j", a.requestId,
|
|
665
|
+
}, s = "https://api3.myships.com/sp/ships/position/latest", r = await B.post(s, o).json();
|
|
666
|
+
M == null || M.info("[%s] fetch realtime position from: %s - %j", a.requestId, s, o);
|
|
667
667
|
const h = r.data[0];
|
|
668
668
|
for (const g in h)
|
|
669
669
|
!isNaN(h[g]) && Number(h[g]) !== 1 / 0 && (h[g] = Number(h[g]));
|
|
@@ -686,13 +686,13 @@ class At extends ot {
|
|
|
686
686
|
vendor: "myship"
|
|
687
687
|
};
|
|
688
688
|
}
|
|
689
|
-
async trajectory(t, a, i, n, o = !0,
|
|
689
|
+
async trajectory(t, a, i, n, o = !0, s = {}) {
|
|
690
690
|
const r = v(a), h = v(i), l = await this.getShipId(t), d = await this.getShipInfo(l), y = [];
|
|
691
691
|
for (; h.diff(r, "day", !0) > 30; )
|
|
692
692
|
await this.trajectoryIn30Day(l, r.unix(), r.add(30, "day").unix(), d, t, n, y);
|
|
693
693
|
return await this.trajectoryIn30Day(l, r.unix(), h.unix(), d, t, n, y), y;
|
|
694
694
|
}
|
|
695
|
-
async trajectoryIn30Day(t, a, i, n, o,
|
|
695
|
+
async trajectoryIn30Day(t, a, i, n, o, s, r, h = {}) {
|
|
696
696
|
var j;
|
|
697
697
|
const l = {
|
|
698
698
|
headers: {
|
|
@@ -707,38 +707,38 @@ class At extends ot {
|
|
|
707
707
|
if (M == null || M.info("[%s] fetch trajectory from: %s - %j", h.requestId, d, l), y.code !== "0")
|
|
708
708
|
return M == null || M.warn("[%s] invoke myship trajectory failed: %j", h.requestId, y), y;
|
|
709
709
|
const w = y.data;
|
|
710
|
-
for (const
|
|
711
|
-
!isNaN(w[
|
|
710
|
+
for (const b in w)
|
|
711
|
+
!isNaN(w[b]) && Number(w[b]) !== 1 / 0 && (w[b] = Number(w[b]));
|
|
712
712
|
const g = v.unix((j = w[0]) == null ? void 0 : j.posTime);
|
|
713
713
|
let k = -1;
|
|
714
|
-
for (const
|
|
715
|
-
const
|
|
714
|
+
for (const b of w) {
|
|
715
|
+
const p = v.unix(b.posTime), f = {
|
|
716
716
|
imo: n == null ? void 0 : n.imo,
|
|
717
717
|
mmsi: o,
|
|
718
|
-
lat: Math.round(
|
|
719
|
-
lng: Math.round(
|
|
720
|
-
sog: Math.round(
|
|
721
|
-
cog: Math.round(
|
|
722
|
-
hdg: Math.round(
|
|
723
|
-
rot: Math.round(
|
|
724
|
-
positionTime:
|
|
725
|
-
utc:
|
|
718
|
+
lat: Math.round(b.lat / 1e4 / 60 * 1e5) / 1e5,
|
|
719
|
+
lng: Math.round(b.lon / 1e4 / 60 * 1e5) / 1e5,
|
|
720
|
+
sog: Math.round(b.sog / 10 * 100) / 100,
|
|
721
|
+
cog: Math.round(b.cog / 10 * 100) / 100,
|
|
722
|
+
hdg: Math.round(b.heading * 100) / 100,
|
|
723
|
+
rot: Math.round(b.rot * 100) / 100,
|
|
724
|
+
positionTime: p.unix(),
|
|
725
|
+
utc: p.utc().format(),
|
|
726
726
|
method: "trajectory",
|
|
727
727
|
vendor: "myship"
|
|
728
|
-
}, u = Math.floor(
|
|
728
|
+
}, u = Math.floor(p.diff(g, "minute", !0) / (s || 1));
|
|
729
729
|
u !== k && (k = u, r.push(f));
|
|
730
730
|
}
|
|
731
731
|
return r;
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
|
-
let
|
|
734
|
+
let J;
|
|
735
735
|
try {
|
|
736
|
-
|
|
736
|
+
J = dt.getLogger("vessel");
|
|
737
737
|
} catch {
|
|
738
738
|
} finally {
|
|
739
739
|
}
|
|
740
|
-
var
|
|
741
|
-
class
|
|
740
|
+
var yt = /* @__PURE__ */ ((x) => (x.NOTICE = "NOTICE", x.WARN = "WARN", x.HEAVY = "HEAVY", x.SEVERE = "SEVERE", x.ERROR = "ERROR", x.FATAL = "FATAL", x))(yt || {});
|
|
741
|
+
class Mt {
|
|
742
742
|
/**
|
|
743
743
|
* 解析告警规则, 多规则场景
|
|
744
744
|
* @param rule
|
|
@@ -747,10 +747,10 @@ class pt {
|
|
|
747
747
|
*
|
|
748
748
|
* @param options
|
|
749
749
|
*/
|
|
750
|
-
parsePrinciple(
|
|
751
|
-
var
|
|
752
|
-
|
|
753
|
-
const a = new RegExp("(?<=\\[)(.+)(?=])", "g"), i =
|
|
750
|
+
parsePrinciple(e, t = {}) {
|
|
751
|
+
var s, r, h;
|
|
752
|
+
J == null || J.debug("[%s] parse rule: %s", t.requestId, e);
|
|
753
|
+
const a = new RegExp("(?<=\\[)(.+)(?=])", "g"), i = e.match(a) ? (s = e.match(a)) == null ? void 0 : s[0] : void 0, n = i == null ? void 0 : i.split(";");
|
|
754
754
|
if (!n)
|
|
755
755
|
return;
|
|
756
756
|
const o = {};
|
|
@@ -772,17 +772,17 @@ class pt {
|
|
|
772
772
|
* @param rule
|
|
773
773
|
* @param options
|
|
774
774
|
*/
|
|
775
|
-
parseRule(
|
|
775
|
+
parseRule(e, t = {}) {
|
|
776
776
|
var o;
|
|
777
|
-
|
|
778
|
-
const a = new RegExp("(?<=\\[)(.+?)(?=])", "g"), i = (o =
|
|
777
|
+
J == null || J.debug("[%s] parse rule: %s", t.requestId, e), e = e.startsWith("[") ? e : `[${e}`, e = e.endsWith("]") ? e : `${e}]`;
|
|
778
|
+
const a = new RegExp("(?<=\\[)(.+?)(?=])", "g"), i = (o = e == null ? void 0 : e.match(a)) == null ? void 0 : o[0], n = i == null ? void 0 : i.split(",");
|
|
779
779
|
if (n) {
|
|
780
|
-
let
|
|
781
|
-
return
|
|
780
|
+
let s = n[3] === "Number.MAX_VALUE" ? 100 : Number(n[3]);
|
|
781
|
+
return s = isNaN(s) ? 1 : s, {
|
|
782
782
|
operator: n[0],
|
|
783
783
|
number: Number.isNaN(Number(n[1])) ? n[1] : Number(n[1]),
|
|
784
784
|
level: n[2],
|
|
785
|
-
time:
|
|
785
|
+
time: s,
|
|
786
786
|
key: n[4]
|
|
787
787
|
};
|
|
788
788
|
}
|
|
@@ -793,27 +793,27 @@ class pt {
|
|
|
793
793
|
* @param principle 告警规则
|
|
794
794
|
* @param options
|
|
795
795
|
*/
|
|
796
|
-
checkWeather(
|
|
797
|
-
var g, k, j,
|
|
798
|
-
let i = 0, n = 0, o = 0,
|
|
799
|
-
const r = Math.round(((k = (g = t == null ? void 0 : t.SEVERE) == null ? void 0 : g.sigWave) == null ? void 0 : k.number) * 1.6 * 100) / 100, h = (
|
|
800
|
-
for (let
|
|
801
|
-
const N =
|
|
802
|
-
|
|
796
|
+
checkWeather(e, t, a = {}) {
|
|
797
|
+
var g, k, j, b, p, f, u, m, c, I, C, F, P, D, H;
|
|
798
|
+
let i = 0, n = 0, o = 0, s = 0;
|
|
799
|
+
const r = Math.round(((k = (g = t == null ? void 0 : t.SEVERE) == null ? void 0 : g.sigWave) == null ? void 0 : k.number) * 1.6 * 100) / 100, h = (b = (j = t == null ? void 0 : t.SEVERE) == null ? void 0 : j.sigWave) == null ? void 0 : b.number, l = (f = (p = t == null ? void 0 : t.HEAVY) == null ? void 0 : p.sigWave) == null ? void 0 : f.number, d = Math.round((((m = (u = t == null ? void 0 : t.SEVERE) == null ? void 0 : u.wind) == null ? void 0 : m.number) + 2) * 100) / 100, y = (I = (c = t == null ? void 0 : t.SEVERE) == null ? void 0 : c.wind) == null ? void 0 : I.number, w = (F = (C = t == null ? void 0 : t.HEAVY) == null ? void 0 : C.wind) == null ? void 0 : F.number;
|
|
800
|
+
for (let T = 0; T < (e == null ? void 0 : e.length); T++) {
|
|
801
|
+
const N = e[T], O = (D = (P = N == null ? void 0 : N.meteo) == null ? void 0 : P.wave) == null ? void 0 : D.sig, R = (H = N == null ? void 0 : N.meteo) == null ? void 0 : H.wind, K = T ? v(N.eta).diff(v(e[T - 1].eta), "hour", !0) : 0;
|
|
802
|
+
s = K > s ? K : s, J == null || J.debug("[%s] check sig.wave: %j", a.requestId, { ...O, dgThd4Wv: r, svThd4Wv: h, hvThd4Wv: l }), (O == null ? void 0 : O.height) >= r ? N.isDangerous = !0 : (O == null ? void 0 : O.height) >= h ? N.isSevere = !0 : (O == null ? void 0 : O.height) >= l && (N.isHeavy = !0), J == null || J.debug("[%s] check wind: %j", a.requestId, { ...R, dgThd4Wd: d, svThd4Wd: y, hvThd4Wd: w }), (R == null ? void 0 : R.scale) >= d ? (N.isDangerous = !0, delete N.isSevere, delete N.isHeavy) : (R == null ? void 0 : R.scale) > y ? (N.isDangerous || (N.isSevere = !0), delete N.isHeavy) : (R == null ? void 0 : R.scale) === w && !N.isDangerous && !N.isSevere && (N.isHeavy = !0), i += N.isDangerous ? K : 0, n += N.isSevere ? K : 0, o += N.isHeavy ? K : 0;
|
|
803
803
|
}
|
|
804
|
-
return i = Math.round(i * 100) / 100, n = Math.round(n * 100) / 100, o = Math.round(o * 100) / 100,
|
|
804
|
+
return i = Math.round(i * 100) / 100, n = Math.round(n * 100) / 100, o = Math.round(o * 100) / 100, s = Math.round(s), { sample: e, dangerous: i, severe: n, heavy: o, step: s < 3 ? 3 : s, wind: { dgThd4Wd: d, svThd4Wd: y, hvThd4Wd: w }, sig: { dgThd4Wv: r, svThd4Wv: h, hvThd4Wv: l } };
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
|
-
const
|
|
808
|
-
let
|
|
807
|
+
const Dt = new Mt();
|
|
808
|
+
let S;
|
|
809
809
|
try {
|
|
810
|
-
|
|
810
|
+
S = dt.getLogger("vessel");
|
|
811
811
|
} catch {
|
|
812
812
|
} finally {
|
|
813
813
|
}
|
|
814
|
-
const
|
|
815
|
-
var
|
|
816
|
-
class
|
|
814
|
+
const gt = new ft("", !0);
|
|
815
|
+
var bt = /* @__PURE__ */ ((x) => (x.common = "common", x.container = "container", x.tugs = "tugs", x))(bt || {}), pt = /* @__PURE__ */ ((x) => (x.Ballast = "Ballast", x.Laden = "Laden", x))(pt || {}), vt = /* @__PURE__ */ ((x) => (x.Cp = "CP", x.Perf = "Basis", x.Instruct = "Other", x))(vt || {});
|
|
816
|
+
class Y {
|
|
817
817
|
/**
|
|
818
818
|
* @see https://baike.baidu.com/item/%E6%96%B9%E5%BD%A2%E7%B3%BB%E6%95%B0/4965568?fr=aladdin
|
|
819
819
|
* 方形系数(block coefficient)
|
|
@@ -826,11 +826,11 @@ class W {
|
|
|
826
826
|
* @param draught 吃水 m
|
|
827
827
|
* @return [0.55, 0.85]
|
|
828
828
|
*/
|
|
829
|
-
static blockCoefficient(
|
|
830
|
-
let n = Math.round(
|
|
829
|
+
static blockCoefficient(e, t, a, i) {
|
|
830
|
+
let n = Math.round(e / (t * a * i) * 100) / 100;
|
|
831
831
|
n = n < 0.55 ? 0.55 : n > 0.85 ? 0.85 : n;
|
|
832
|
-
const o = [0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85],
|
|
833
|
-
return o[
|
|
832
|
+
const o = [0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85], s = o.map((r) => Math.abs(r - n));
|
|
833
|
+
return o[s.indexOf(Math.min(...s))];
|
|
834
834
|
}
|
|
835
835
|
/**
|
|
836
836
|
* @see https://baike.baidu.com/item/%E5%BC%97%E5%8A%B3%E5%BE%B7%E6%95%B0/228891?fromModule=search-result_lemma-recommend
|
|
@@ -843,8 +843,8 @@ class W {
|
|
|
843
843
|
* @param g 重力加速度 9.80 m/s^2
|
|
844
844
|
* @return [0.05, 0.30]
|
|
845
845
|
*/
|
|
846
|
-
static froudeNumber(
|
|
847
|
-
let i = Math.round(Math.sqrt(
|
|
846
|
+
static froudeNumber(e, t, a = 9.8) {
|
|
847
|
+
let i = Math.round(Math.sqrt(e * e / (a * t)) * 100) / 100;
|
|
848
848
|
return i = i < 0.05 ? 0.05 : i > 0.3 ? 0.3 : i, i;
|
|
849
849
|
}
|
|
850
850
|
/**
|
|
@@ -854,7 +854,7 @@ class W {
|
|
|
854
854
|
* @param loadCondition
|
|
855
855
|
* @private
|
|
856
856
|
*/
|
|
857
|
-
static amendFactor(
|
|
857
|
+
static amendFactor(e, t, a) {
|
|
858
858
|
const i = {
|
|
859
859
|
0.55: [1.7, -1.4, -7.4],
|
|
860
860
|
0.6: [2.2, -2.5, -9.7],
|
|
@@ -872,8 +872,8 @@ class W {
|
|
|
872
872
|
0.75: [2.6, -12.5, -13.5],
|
|
873
873
|
0.8: [3, -16.3, -21.6],
|
|
874
874
|
0.85: [3.4, -20.9, 31.8]
|
|
875
|
-
}[
|
|
876
|
-
return a === "Laden" && (o = i[
|
|
875
|
+
}[e];
|
|
876
|
+
return a === "Laden" && (o = i[e]), o[0] + o[1] * t + o[2] * Math.pow(t, 2);
|
|
877
877
|
}
|
|
878
878
|
/**
|
|
879
879
|
* 失速方向因子
|
|
@@ -886,9 +886,9 @@ class W {
|
|
|
886
886
|
* @param bn
|
|
887
887
|
* @private
|
|
888
888
|
*/
|
|
889
|
-
static directionFactor(
|
|
889
|
+
static directionFactor(e, t = 0) {
|
|
890
890
|
let a;
|
|
891
|
-
return
|
|
891
|
+
return e > 30 && e <= 60 ? a = (1.7 - 0.03 * Math.pow(t - 4, 2)) / 2 : e > 60 && e <= 150 ? a = (0.9 - 0.06 * Math.pow(t - 6, 2)) / 2 : e > 150 && e <= 180 ? a = (0.4 - 0.03 * Math.pow(t - 8, 2)) / 2 : a = 1, Math.round(a * 1e5) / 1e5;
|
|
892
892
|
}
|
|
893
893
|
/**
|
|
894
894
|
* 失速船型因子
|
|
@@ -902,9 +902,9 @@ class W {
|
|
|
902
902
|
* @param kts
|
|
903
903
|
* @private
|
|
904
904
|
*/
|
|
905
|
-
static vesselTagFactor(
|
|
905
|
+
static vesselTagFactor(e, t, a, i) {
|
|
906
906
|
let n;
|
|
907
|
-
return a === "container" ? n = 0.7 * i / 2 + Math.pow(i, 3) / (22 * Math.pow(
|
|
907
|
+
return a === "container" ? n = 0.7 * i / 2 + Math.pow(i, 3) / (22 * Math.pow(e, 2 / 3)) : t === "Ballast" ? n = 0.7 * i / 2 + Math.pow(i, 3) / (2.7 * Math.pow(e, 2 / 3)) : n = 0.5 * i / 2 + Math.pow(i, 3) / (2.7 * Math.pow(e, 2 / 3)), n;
|
|
908
908
|
}
|
|
909
909
|
/**
|
|
910
910
|
* 浪高影响因子
|
|
@@ -912,10 +912,10 @@ class W {
|
|
|
912
912
|
* @param beta 夹角
|
|
913
913
|
* @private
|
|
914
914
|
*/
|
|
915
|
-
static waveHeightFactor(
|
|
916
|
-
|
|
915
|
+
static waveHeightFactor(e, t) {
|
|
916
|
+
e = e < 3 ? e * 0.7 : e, e = e < 0 ? 0.2 : e, e = e > 6 ? e - 0.9 * (e - 6) : e, e = e > 9 ? 9 : e;
|
|
917
917
|
let a;
|
|
918
|
-
return t > 30 && t <= 60 ? a = -0.6 : t > 60 && t <= 90 ? a = -0.4 : t > 90 && t <= 120 ? a =
|
|
918
|
+
return t > 30 && t <= 60 ? a = -0.6 : t > 60 && t <= 90 ? a = -0.4 : t > 90 && t <= 120 ? a = e < 3 ? 0.4 : -0.3 : t > 120 && t <= 150 ? a = e < 3 ? 0.6 : -0.5 : t > 150 && t <= 180 ? a = e < 3 ? 0.7 : -0.6 : a = -0.7, Math.round(a * (0.144 * Math.pow(e, 2) + 0.278 * e) * 1e4) / 1e4;
|
|
919
919
|
}
|
|
920
920
|
/**
|
|
921
921
|
* 组装船舶运行参数
|
|
@@ -925,18 +925,18 @@ class W {
|
|
|
925
925
|
* @param bearing 方位角
|
|
926
926
|
* @private
|
|
927
927
|
*/
|
|
928
|
-
static assembleProperties(
|
|
928
|
+
static assembleProperties(e, t, a, i) {
|
|
929
929
|
var y;
|
|
930
|
-
const n =
|
|
930
|
+
const n = e.lbp ?? e.length ?? e.lengthOverall ?? 198.9642, o = e.draught ?? 8, s = e.breadthMoulded ?? e.breadth ?? e.breadthExtreme ?? 32.4572, r = e.deadweight ?? 67035.7773, h = ((y = e == null ? void 0 : e.type) == null ? void 0 : y.toLowerCase()) || "common";
|
|
931
931
|
return {
|
|
932
932
|
tag: h.indexOf("container") > -1 ? "container" : h.indexOf("tugs") > -1 ? "tugs" : "common",
|
|
933
933
|
lbp: n,
|
|
934
934
|
loadCondition: t,
|
|
935
935
|
draught: o,
|
|
936
|
-
breadthMoulded:
|
|
936
|
+
breadthMoulded: s,
|
|
937
937
|
// 排水量(吨)= 载重量(吨)/ 1.025 + 吃水(米)× 船舶型宽(米)× 船舶型长(米)× 0.7
|
|
938
938
|
// 其中,1.025是指海水的密度,吨是指公吨,吃水是指船舶的最大吃水深度。船舶型宽是指船舶的最大型宽,船舶型长是指船舶的设计型长。上述公式是针对常规船舶适用的,不同类型的船舶可能会有一些差异。
|
|
939
|
-
displacement: Math.round((r / 1.025 + o *
|
|
939
|
+
displacement: Math.round((r / 1.025 + o * s * n * 0.7) * 1e4) / 1e4,
|
|
940
940
|
// 换算为m/s
|
|
941
941
|
speed: Math.round((a ?? 14.1382) * 1852 / 3600 * 1e4) / 1e4,
|
|
942
942
|
bearing: i || 90
|
|
@@ -953,29 +953,29 @@ class W {
|
|
|
953
953
|
* @param useRouteParam true 启用设置速度
|
|
954
954
|
* @param options
|
|
955
955
|
*/
|
|
956
|
-
static async speedLoseAt(
|
|
956
|
+
static async speedLoseAt(e, t, a, i = "", n = 2, o = !0, s = !1, r = {}) {
|
|
957
957
|
let h;
|
|
958
|
-
if (t.velocity &&
|
|
958
|
+
if (t.velocity && s && (e.speed = z.roundPrecision(t.velocity * 1852 / 3600, 6)), o) {
|
|
959
959
|
let l;
|
|
960
960
|
try {
|
|
961
961
|
i = (i == null ? void 0 : i.toUpperCase()) === "CMEMS" ? "ECMWF" : i, i = (i == null ? void 0 : i.toUpperCase()) === "METEO2" ? "best_match" : i;
|
|
962
|
-
const { weatherModels: g, marineModels: k } = await
|
|
962
|
+
const { weatherModels: g, marineModels: k } = await ct.autoPickMeteoModel(i), j = await gt.spotForecast(t.lat, t.lng, a.utc().format(), !1, !1, !0, {
|
|
963
963
|
...r,
|
|
964
964
|
pastDays: 1,
|
|
965
965
|
forecastDays: 1,
|
|
966
966
|
weatherModels: g,
|
|
967
967
|
marineModels: k
|
|
968
|
-
}), [
|
|
969
|
-
l =
|
|
968
|
+
}), [b] = ct.pickHourly(j, a);
|
|
969
|
+
l = ct.toLegacy(b);
|
|
970
970
|
} catch (g) {
|
|
971
|
-
|
|
971
|
+
S.warn("[%s] meteo2 spot(%j) forecast failed: %s", r.requestId, { ...t, eta: a.utc().format(), source: i }, g);
|
|
972
972
|
}
|
|
973
|
-
const d =
|
|
973
|
+
const d = Y.currentFactor(e.bearing, l == null ? void 0 : l.current, n), y = Y.weatherFactor(e, l, d), w = Math.round((e.speed * 1.943844 + y + d) * 100) / 100;
|
|
974
974
|
h = {
|
|
975
975
|
meteo: { ...l },
|
|
976
976
|
wxFactor: y,
|
|
977
977
|
cFactor: d,
|
|
978
|
-
speed: t.velocity &&
|
|
978
|
+
speed: t.velocity && s ? t.velocity : w < 0 ? 1 : w,
|
|
979
979
|
eta: a.utc().format(),
|
|
980
980
|
etd: a.utc().format()
|
|
981
981
|
};
|
|
@@ -983,7 +983,7 @@ class W {
|
|
|
983
983
|
h = {
|
|
984
984
|
wxFactor: 0,
|
|
985
985
|
cFactor: 0,
|
|
986
|
-
speed: t.velocity &&
|
|
986
|
+
speed: t.velocity && s ? t.velocity : Math.round(e.speed * 1.943844 * 100) / 100,
|
|
987
987
|
eta: a.utc().format(),
|
|
988
988
|
etd: a.utc().format()
|
|
989
989
|
};
|
|
@@ -1003,15 +1003,15 @@ class W {
|
|
|
1003
1003
|
* @param options
|
|
1004
1004
|
* @private
|
|
1005
1005
|
*/
|
|
1006
|
-
static async speedLoseInHoursStep(
|
|
1006
|
+
static async speedLoseInHoursStep(e, t, a, i, n, o, s = "", r = !0, h = !1, l = {}) {
|
|
1007
1007
|
t.utc();
|
|
1008
1008
|
const d = t.clone().add(14, "days"), y = [], w = [], g = [];
|
|
1009
|
-
let k = 0, j = 0,
|
|
1009
|
+
let k = 0, j = 0, b, p;
|
|
1010
1010
|
for (let f = 0; f < o.length - 1; f++) {
|
|
1011
1011
|
let u = o[f];
|
|
1012
1012
|
u.distanceFromStart = Math.round((n + j) * 1e3) / 1e3;
|
|
1013
1013
|
const m = o[f + 1];
|
|
1014
|
-
if (
|
|
1014
|
+
if (e.bearing = W.calculateBearing(u, m, !m.gcToPrevious), u.bearing = e.bearing, u.suspend && h) {
|
|
1015
1015
|
u.eta = u.eta || t.utc().format(), u.elapsed = u.elapsed ?? 0;
|
|
1016
1016
|
const C = u.suspend - u.elapsed;
|
|
1017
1017
|
if (i - k > C)
|
|
@@ -1020,36 +1020,36 @@ class W {
|
|
|
1020
1020
|
const F = i - k;
|
|
1021
1021
|
u.elapsed += F, t.add(F, "hour"), i = 0;
|
|
1022
1022
|
}
|
|
1023
|
-
if (
|
|
1024
|
-
return u.distanceFromPrevious = j, { etd: t, from:
|
|
1023
|
+
if (S == null || S.info(`[%s] suspend ${u.elapsed} hours at %j, and remain ${i} hours need to go...`, l.requestId, u), i === 0)
|
|
1024
|
+
return u.distanceFromPrevious = j, { etd: t, from: p || u, to: u, next: o.filter((F) => F), wps: y, days: w, all: g };
|
|
1025
1025
|
} else
|
|
1026
1026
|
u.suspend = 0;
|
|
1027
|
-
r = t.isAfter(d) ? !1 : r, u = await
|
|
1028
|
-
const c =
|
|
1029
|
-
let I = Math.round(c /
|
|
1027
|
+
r = t.isAfter(d) ? !1 : r, u = await Y.speedLoseAt(e, u, t, s, 0, r, h, l), g.push(u), p = p || u, u.important && y.push(u), t.isSameOrAfter(a) && (w.push(u), a.add(24, "hour"));
|
|
1028
|
+
const c = W.calculateDistance(u, m, !m.gcToPrevious);
|
|
1029
|
+
let I = Math.round(c / p.speed * 1e5) / 1e5;
|
|
1030
1030
|
if (k + I < i) {
|
|
1031
|
-
if (k += I, t.add(I, "hour"), delete o[f],
|
|
1031
|
+
if (k += I, t.add(I, "hour"), delete o[f], S == null || S.debug(
|
|
1032
1032
|
`[%s] go to %j from %j with ${c}nm, and cost ${I} hours`,
|
|
1033
1033
|
l.requestId,
|
|
1034
1034
|
{ lat: m.lat, lng: m.lng },
|
|
1035
|
-
{ lat:
|
|
1035
|
+
{ lat: p.lat, lng: p.lng, etd: p.etd }
|
|
1036
1036
|
), j += c, o.filter((C) => C).length <= 1) {
|
|
1037
|
-
|
|
1037
|
+
b = m, b.eta = t.utc().format(), b.distanceFromPrevious = c, b.distanceFromStart = Math.round((n + j) * 1e4) / 1e4, y.push(b), g.push(b), delete o[f + 1];
|
|
1038
1038
|
break;
|
|
1039
1039
|
}
|
|
1040
1040
|
} else {
|
|
1041
1041
|
I = i - k, t.add(I, "hour");
|
|
1042
|
-
const C = z.roundPrecision(
|
|
1043
|
-
|
|
1042
|
+
const C = z.roundPrecision(p.speed * I, 5);
|
|
1043
|
+
b = W.calculateCoordinate(u, e.bearing, C, "nauticalmiles", !m.gcToPrevious), b.eta = t.utc().format(), o[f] = b, S == null || S.debug(
|
|
1044
1044
|
`[%s] go to %j from %j with ${C}nm, and cost ${I} hours`,
|
|
1045
1045
|
l.requestId,
|
|
1046
|
-
{ lat:
|
|
1046
|
+
{ lat: b.lat, lng: b.lng },
|
|
1047
1047
|
{ lat: u.lat, lng: u.lng, etd: u.etd }
|
|
1048
|
-
), j += C,
|
|
1048
|
+
), j += C, b.distanceFromPrevious = Math.round(j * 1e4) / 1e4, b.distanceFromStart = Math.round((n + j) * 1e4) / 1e4;
|
|
1049
1049
|
break;
|
|
1050
1050
|
}
|
|
1051
1051
|
}
|
|
1052
|
-
return { etd: t, from:
|
|
1052
|
+
return { etd: t, from: p, to: b, next: o.filter((f) => f), wps: y, days: w, all: g };
|
|
1053
1053
|
}
|
|
1054
1054
|
/**
|
|
1055
1055
|
* 洋流影响因子
|
|
@@ -1057,8 +1057,8 @@ class W {
|
|
|
1057
1057
|
* @param current 洋流要素
|
|
1058
1058
|
* @param role 1: 船东, 2: 租家, 0: 未知
|
|
1059
1059
|
*/
|
|
1060
|
-
static currentFactor(
|
|
1061
|
-
const i = (
|
|
1060
|
+
static currentFactor(e, t, a = 0) {
|
|
1061
|
+
const i = (e - (t == null ? void 0 : t.degree) || 0) / 180 * Math.PI;
|
|
1062
1062
|
if (Math.abs(i) === Math.PI / 2)
|
|
1063
1063
|
return 0;
|
|
1064
1064
|
let n = ((t == null ? void 0 : t.kts) || 0) * Math.cos(i);
|
|
@@ -1070,17 +1070,33 @@ class W {
|
|
|
1070
1070
|
* @param wwc 气象要素
|
|
1071
1071
|
* @param cFactor 洋流因子
|
|
1072
1072
|
*/
|
|
1073
|
-
static weatherFactor(
|
|
1074
|
-
var w, g, k, j,
|
|
1075
|
-
|
|
1076
|
-
const i =
|
|
1077
|
-
let r = Math.abs(
|
|
1073
|
+
static weatherFactor(e, t, a = 0) {
|
|
1074
|
+
var w, g, k, j, b, p, f;
|
|
1075
|
+
S == null || S.debug("calculate weather factor via: %j", { ...e, ...t });
|
|
1076
|
+
const i = Y.blockCoefficient(e.displacement, e.lbp, e.breadthMoulded, e.draught), n = z.roundPrecision(a * 1852 / 3600, 6), o = Y.froudeNumber(e.speed - n, e.lbp), s = Y.amendFactor(i, o, e.loadCondition);
|
|
1077
|
+
let r = Math.abs(e.bearing % 360 - (((w = t == null ? void 0 : t.wind) == null ? void 0 : w.degree) % 360 || 0));
|
|
1078
1078
|
r = r > 180 ? 360 - r : r;
|
|
1079
|
-
const h =
|
|
1080
|
-
let d = h *
|
|
1081
|
-
d = Math.round(d * 1.943844 * 1e4) / 1e4 * -1,
|
|
1082
|
-
const y =
|
|
1083
|
-
return
|
|
1079
|
+
const h = Y.directionFactor(r, (g = t == null ? void 0 : t.wind) == null ? void 0 : g.scale), l = Y.vesselTagFactor(e.displacement, e.loadCondition, e.tag, (k = t == null ? void 0 : t.wind) == null ? void 0 : k.kts);
|
|
1080
|
+
let d = h * s * l / 100 * (e.speed - n);
|
|
1081
|
+
d = Math.round(d * 1.943844 * 1e4) / 1e4 * -1, e.tag === "tugs" && Math.abs(d) > 1 && (d = d / (Math.abs(Math.round(d)) + 1)), S == null || S.debug("wind wx factor = %d", d), r = Math.abs(e.bearing % 360 - (((b = (j = t == null ? void 0 : t.wave) == null ? void 0 : j.sig) == null ? void 0 : b.degree) % 360 || 0)), r = r > 180 ? 360 - r : r;
|
|
1082
|
+
const y = Y.waveHeightFactor(((f = (p = t == null ? void 0 : t.wave) == null ? void 0 : p.sig) == null ? void 0 : f.height) ?? 1, r);
|
|
1083
|
+
return S == null || S.debug("wave wx factor = %d", y), d = Math.abs(d) > Math.abs(y) ? d : d * 0.3 + y * 0.7, S == null || S.debug("weather factor = %d", d), d = Math.abs(d) > 3 ? 3 * (Math.abs(d) / d) + Math.abs(d) / d * (Math.abs(d) - 2) * 0.1 : d, Math.round((d || 0) * 100) / 100;
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* 以12小时级别去掉重复的days
|
|
1087
|
+
* @param days
|
|
1088
|
+
* @param interval 12 hours
|
|
1089
|
+
*/
|
|
1090
|
+
static async reduceDays(e, t = 12 * 60 * 60) {
|
|
1091
|
+
return e = e == null ? void 0 : e.reduce((a, i) => (a.some((n) => Math.floor(n.positionTime / t) === Math.floor(i.positionTime / t)) || a.push(i), a), []), e;
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* 以分钟级别去掉重复的wps
|
|
1095
|
+
* @param wps
|
|
1096
|
+
* @param interval 1 minute
|
|
1097
|
+
*/
|
|
1098
|
+
static async reduceWPS(e, t = 60) {
|
|
1099
|
+
return e = e == null ? void 0 : e.reduce((a, i) => (a.some((n) => Math.floor(v(n.etd).unix() / t) === Math.floor(v(i.etd).unix() / t)) || a.push(i), a), []), e;
|
|
1084
1100
|
}
|
|
1085
1101
|
/**
|
|
1086
1102
|
* 全程失速分析(走完航程)
|
|
@@ -1095,27 +1111,27 @@ class W {
|
|
|
1095
1111
|
* @param useRouteParam
|
|
1096
1112
|
* @param options
|
|
1097
1113
|
*/
|
|
1098
|
-
static async analyseInstant(
|
|
1099
|
-
var
|
|
1114
|
+
static async analyseInstant(e, t, a, i, n, o = "", s = 0, r = !0, h = !1, l = {}) {
|
|
1115
|
+
var _, G, X, Q, Z, $;
|
|
1100
1116
|
const d = v().valueOf();
|
|
1101
|
-
|
|
1102
|
-
const { route: y, waypoints: w } = n.points, g =
|
|
1103
|
-
if (((
|
|
1117
|
+
e.lng = z.convertToStdLng(e.lng);
|
|
1118
|
+
const { route: y, waypoints: w } = n.points, g = W.calculateSubRoute(e, y);
|
|
1119
|
+
if (((_ = g[0]) == null ? void 0 : _.length) <= 1)
|
|
1104
1120
|
return;
|
|
1105
|
-
const { v0: k, label: j } =
|
|
1106
|
-
v0:
|
|
1107
|
-
label:
|
|
1121
|
+
const { v0: k, label: j } = e.sog ? {
|
|
1122
|
+
v0: e.sog,
|
|
1123
|
+
label: e.label || "Other"
|
|
1108
1124
|
/* Instruct */
|
|
1109
1125
|
} : {
|
|
1110
1126
|
v0: i.speed,
|
|
1111
1127
|
label: "CP"
|
|
1112
1128
|
/* Cp */
|
|
1113
|
-
},
|
|
1114
|
-
|
|
1129
|
+
}, b = Y.assembleProperties(a, i.loadCondition, k, 0), p = w.length ? W.calculateSubWaypoints(e, w) : [];
|
|
1130
|
+
p.forEach((A) => A.important = !0);
|
|
1115
1131
|
const f = {
|
|
1116
|
-
from: { ...
|
|
1132
|
+
from: { ...e },
|
|
1117
1133
|
route: g,
|
|
1118
|
-
waypoints:
|
|
1134
|
+
waypoints: p,
|
|
1119
1135
|
v0: k,
|
|
1120
1136
|
label: j
|
|
1121
1137
|
}, u = {
|
|
@@ -1124,16 +1140,16 @@ class W {
|
|
|
1124
1140
|
wps: [],
|
|
1125
1141
|
all: []
|
|
1126
1142
|
};
|
|
1127
|
-
|
|
1128
|
-
let m =
|
|
1143
|
+
s || (W.calculateRouteDistance(g) / i.speed <= 72 ? s = 3 : s = 6);
|
|
1144
|
+
let m = W.simplifyRouteToCoordinates(g, p, 0), c = 0, I = 0, C = 0, F = 0;
|
|
1129
1145
|
t = v(t).utc();
|
|
1130
|
-
const
|
|
1146
|
+
const P = t.clone();
|
|
1131
1147
|
for (; m.length > 0; ) {
|
|
1132
|
-
const
|
|
1133
|
-
|
|
1148
|
+
const A = s - t.hour() % s, V = Math.ceil(t.clone().add(A, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4, E = await Y.speedLoseInHoursStep(
|
|
1149
|
+
b,
|
|
1134
1150
|
t,
|
|
1135
|
-
|
|
1136
|
-
|
|
1151
|
+
P,
|
|
1152
|
+
V,
|
|
1137
1153
|
c,
|
|
1138
1154
|
m,
|
|
1139
1155
|
o,
|
|
@@ -1141,38 +1157,38 @@ class W {
|
|
|
1141
1157
|
h,
|
|
1142
1158
|
l
|
|
1143
1159
|
);
|
|
1144
|
-
if (u.all.push(...
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1160
|
+
if (u.all.push(...E.all), (G = E.from) != null && G.speed && (u.hours.push(E.from), u.wps.push(...E.wps), u.days.push(...E.days)), m = E == null ? void 0 : E.next, !m.length) {
|
|
1161
|
+
const L = await Y.speedLoseAt(b, E.to, v(E.to.eta), o, 0, r, h, l);
|
|
1162
|
+
L.bearing = b.bearing, u.hours.push(L), u.all.push(L);
|
|
1147
1163
|
}
|
|
1148
|
-
c += Math.round((((X =
|
|
1164
|
+
c += Math.round((((X = E == null ? void 0 : E.to) == null ? void 0 : X.distanceFromPrevious) ?? 0) * 1e4) / 1e4;
|
|
1149
1165
|
}
|
|
1150
|
-
const
|
|
1151
|
-
for (let
|
|
1152
|
-
const
|
|
1153
|
-
I += (A
|
|
1166
|
+
const D = u.hours;
|
|
1167
|
+
for (let A = 0; A < D.length - 1; A++) {
|
|
1168
|
+
const V = v(D[A + 1].eta).diff(D[A].etd, "hour", !0) || 1;
|
|
1169
|
+
I += (D[A].wxFactor || 0) * V, C += (D[A].cFactor || 0) * V, F += V;
|
|
1154
1170
|
}
|
|
1155
|
-
const H =
|
|
1156
|
-
(Q = u.wps) == null || Q.forEach((
|
|
1157
|
-
|
|
1158
|
-
const
|
|
1159
|
-
if (
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1171
|
+
const H = D.reduce((A, V) => A + (V.suspend || 0), 0);
|
|
1172
|
+
(Q = u.wps) == null || Q.forEach((A, V) => {
|
|
1173
|
+
A.positionTime = v.utc(A.etd || A.eta).unix();
|
|
1174
|
+
const E = u.wps[V - 1];
|
|
1175
|
+
if (E) {
|
|
1176
|
+
const L = A.distanceFromStart - E.distanceFromStart, q = v(A.eta || A.etd).diff(v(E.etd || E.eta), "h", !0);
|
|
1177
|
+
A.avgSpd = Math.round(L / q * 100) / 100, E.bearing = W.calculateBearing(E, A);
|
|
1162
1178
|
}
|
|
1163
|
-
}), u.wps = (
|
|
1164
|
-
const
|
|
1165
|
-
f.distance = Math.round(N.distanceFromStart * 1e3) / 1e3, f.etd = v(
|
|
1166
|
-
const O = z.roundPrecision(i.dgo / 24 * H, 3), { distanceInECA: R, hoursInECA:
|
|
1179
|
+
}), u.wps = await Y.reduceWPS(u.wps), u.days = await Y.reduceDays(u.days), u.all = (Z = u.all) == null ? void 0 : Z.reduce((A, V) => (V.positionTime = v.utc(V.etd || V.eta).unix(), A.some((E) => Math.round(E.positionTime / 60) === Math.round(V.positionTime / 60)) || A.push(V), A), []), f.sample = u;
|
|
1180
|
+
const T = u.hours.at(0), N = u.hours.at(-1);
|
|
1181
|
+
f.distance = Math.round(N.distanceFromStart * 1e3) / 1e3, f.etd = v(T.eta).utc().format(), f.eta = v(N.eta).utc().format(), f.wxFactor = Math.round(I / F * 1e3) / 1e3, f.cFactor = Math.round(C / F * 1e3) / 1e3, f.avgSpeed = Math.round(N.distanceFromStart / F * 1e3) / 1e3, f.totalHrs = Math.round(F * 1e3) / 1e3, f.suspend = Math.round(H * 1e3) / 1e3;
|
|
1182
|
+
const O = z.roundPrecision(i.dgo / 24 * H, 3), { distanceInECA: R, hoursInECA: K, totalDgoConsInECA: nt, eca: tt } = await this.calculateECA(f, i, l), et = z.roundPrecision(i.fo / 24 * (F - K), 3), ot = z.roundPrecision(i.dgo / 24 * F + O, 3);
|
|
1167
1183
|
f.extend = {
|
|
1168
|
-
eca:
|
|
1184
|
+
eca: tt,
|
|
1169
1185
|
distanceInECA: R,
|
|
1170
|
-
hoursInECA:
|
|
1171
|
-
totalDgoConsInECA:
|
|
1186
|
+
hoursInECA: K,
|
|
1187
|
+
totalDgoConsInECA: nt,
|
|
1172
1188
|
totalDgoConsInSuspend: O
|
|
1173
|
-
}, f.totalFoCons =
|
|
1174
|
-
const
|
|
1175
|
-
return
|
|
1189
|
+
}, f.totalFoCons = et < 0 ? 0 : et, f.totalDgoCons = ot;
|
|
1190
|
+
const st = v().valueOf() - d, rt = (($ = u == null ? void 0 : u.hours) == null ? void 0 : $.length) || 1;
|
|
1191
|
+
return S == null || S.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", l == null ? void 0 : l.requestId, st, rt, Math.round(st / rt * 1e3) / 1e3), f;
|
|
1176
1192
|
}
|
|
1177
1193
|
/**
|
|
1178
1194
|
* 分段失速分析(最多走hours 小时)
|
|
@@ -1189,24 +1205,24 @@ class W {
|
|
|
1189
1205
|
* @param useRouteParam
|
|
1190
1206
|
* @param options
|
|
1191
1207
|
*/
|
|
1192
|
-
static async analyseInstantWithThreshed(
|
|
1193
|
-
var X, Q, Z, $,
|
|
1208
|
+
static async analyseInstantWithThreshed(e, t, a, i, n, o, s, r = "", h = 3, l = !0, d = !1, y = {}) {
|
|
1209
|
+
var X, Q, Z, $, A, V;
|
|
1194
1210
|
const w = v().valueOf();
|
|
1195
|
-
|
|
1196
|
-
const { v0: g, label: k } =
|
|
1197
|
-
v0:
|
|
1198
|
-
label:
|
|
1211
|
+
e.lng = z.convertToStdLng(e.lng);
|
|
1212
|
+
const { v0: g, label: k } = e.sog ? {
|
|
1213
|
+
v0: e.sog,
|
|
1214
|
+
label: e.label || "Other"
|
|
1199
1215
|
/* Instruct */
|
|
1200
1216
|
} : {
|
|
1201
1217
|
v0: n.speed,
|
|
1202
1218
|
label: "CP"
|
|
1203
1219
|
/* Cp */
|
|
1204
|
-
}, j =
|
|
1205
|
-
if (((X =
|
|
1220
|
+
}, j = Y.assembleProperties(i, n.loadCondition, g, 0), b = W.calculateSubRoute(e, o);
|
|
1221
|
+
if (((X = b[0]) == null ? void 0 : X.length) <= 1)
|
|
1206
1222
|
return;
|
|
1207
|
-
const
|
|
1208
|
-
|
|
1209
|
-
let f =
|
|
1223
|
+
const p = s.length ? W.calculateSubWaypoints(e, s) : [];
|
|
1224
|
+
p.forEach((E) => E.important = !0);
|
|
1225
|
+
let f = W.simplifyRouteToCoordinates(b, p, 0), u = 0, m = 0, c = 0, I = 0;
|
|
1210
1226
|
const C = {
|
|
1211
1227
|
hours: [],
|
|
1212
1228
|
wps: [],
|
|
@@ -1216,52 +1232,52 @@ class W {
|
|
|
1216
1232
|
t = v(t).utc();
|
|
1217
1233
|
const F = t.clone();
|
|
1218
1234
|
for (; f.length > 0; ) {
|
|
1219
|
-
const
|
|
1220
|
-
let
|
|
1221
|
-
|
|
1222
|
-
const
|
|
1223
|
-
if (C.all.push(...
|
|
1235
|
+
const E = h - t.hour() % h;
|
|
1236
|
+
let L = Math.ceil(t.clone().add(E, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4;
|
|
1237
|
+
L = t.clone().add(L, "h").isSameOrAfter(a) ? a.diff(t, "h", !0) * 1e4 / 1e4 : L;
|
|
1238
|
+
const q = await Y.speedLoseInHoursStep(j, t, F, L, u, f, r, l, d, y);
|
|
1239
|
+
if (C.all.push(...q.all), (Q = q.from) != null && Q.speed && (C.hours.push(q.from), q != null && q.wps && C.wps.push(...q.wps), C.days.push(...q.days)), f = q == null ? void 0 : q.next, f.length || C.hours.push(q == null ? void 0 : q.to), u += Math.round((((Z = q == null ? void 0 : q.to) == null ? void 0 : Z.distanceFromPrevious) ?? 0) * 1e4) / 1e4, !L)
|
|
1224
1240
|
break;
|
|
1225
1241
|
}
|
|
1226
|
-
C.wps = (
|
|
1227
|
-
const
|
|
1228
|
-
if (
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1242
|
+
C.wps = await Y.reduceWPS(C.wps), C.days = await Y.reduceDays(C.days), C.all = ($ = C.all) == null ? void 0 : $.reduce((E, L) => (L.positionTime = v.utc(L.etd || L.eta).unix(), E.some((q) => Math.round(v(q.etd).unix() / 60) === Math.round(v(L.etd).unix() / 60)) || E.push(L), E), []), (A = C.wps) == null || A.forEach((E, L) => {
|
|
1243
|
+
const q = C.wps[L - 1];
|
|
1244
|
+
if (q) {
|
|
1245
|
+
const ut = E.distanceFromStart - q.distanceFromStart, ht = v(E.eta || E.etd).diff(v(q.etd || q.eta), "h", !0);
|
|
1246
|
+
q.bearing = W.calculateBearing(q, E), E.avgSpd = Math.round(ut / ht * 100) / 100;
|
|
1231
1247
|
}
|
|
1232
1248
|
});
|
|
1233
|
-
const
|
|
1234
|
-
for (let
|
|
1235
|
-
const
|
|
1236
|
-
m +=
|
|
1249
|
+
const P = C.hours;
|
|
1250
|
+
for (let E = 0; E < P.length - 1; E++) {
|
|
1251
|
+
const L = v(P[E + 1].eta).diff(P[E].etd, "hour", !0);
|
|
1252
|
+
m += P[E].wxFactor * L, c += P[E].cFactor * L, I += L;
|
|
1237
1253
|
}
|
|
1238
|
-
const
|
|
1254
|
+
const D = P.reduce((E, L) => E + (L.suspend || 0), 0), H = C.hours.at(0), T = C.hours.at(-1), N = await W.calculateRangeRoute(H, T, b), O = await W.calculateRangeWaypoints(H, T, b, p), R = {
|
|
1239
1255
|
sample: C,
|
|
1240
|
-
distance: Math.round(((
|
|
1256
|
+
distance: Math.round(((T == null ? void 0 : T.distanceFromStart) || 0) * 1e4) / 1e4,
|
|
1241
1257
|
// 注意,可能会在first节点Drift,所有采用eta做为初始出发时间
|
|
1242
1258
|
etd: v(H.eta).utc().format(),
|
|
1243
|
-
eta: v(
|
|
1259
|
+
eta: v(T == null ? void 0 : T.eta).utc().format(),
|
|
1244
1260
|
wxFactor: Math.round(m / I * 1e3) / 1e3,
|
|
1245
1261
|
cFactor: Math.round(c / I * 1e3) / 1e3,
|
|
1246
|
-
avgSpeed: Math.round(((
|
|
1262
|
+
avgSpeed: Math.round(((T == null ? void 0 : T.distanceFromStart) || 0) / I * 1e3) / 1e3,
|
|
1247
1263
|
totalHrs: Math.round(I * 1e3) / 1e3,
|
|
1248
|
-
suspend: Math.round(
|
|
1264
|
+
suspend: Math.round(D * 1e3) / 1e3,
|
|
1249
1265
|
from: H,
|
|
1250
|
-
to:
|
|
1266
|
+
to: T,
|
|
1251
1267
|
route: N,
|
|
1252
1268
|
waypoints: O,
|
|
1253
1269
|
v0: g,
|
|
1254
1270
|
label: k
|
|
1255
|
-
},
|
|
1271
|
+
}, K = z.roundPrecision(n.dgo / 24 * D, 3), { distanceInECA: nt, hoursInECA: tt, totalDgoConsInECA: et, eca: ot } = await this.calculateECA(R, n, y), it = z.roundPrecision(n.fo / 24 * (I - tt), 3), st = z.roundPrecision(n.dgo / 24 * I + K, 3);
|
|
1256
1272
|
R.extend = {
|
|
1257
|
-
eca:
|
|
1258
|
-
distanceInECA:
|
|
1259
|
-
hoursInECA:
|
|
1260
|
-
totalDgoConsInECA:
|
|
1261
|
-
totalDgoConsInSuspend:
|
|
1262
|
-
}, R.totalDgoCons =
|
|
1263
|
-
const
|
|
1264
|
-
return
|
|
1273
|
+
eca: ot,
|
|
1274
|
+
distanceInECA: nt,
|
|
1275
|
+
hoursInECA: tt,
|
|
1276
|
+
totalDgoConsInECA: et,
|
|
1277
|
+
totalDgoConsInSuspend: K
|
|
1278
|
+
}, R.totalDgoCons = st, R.totalFoCons = it < 0 ? 0 : it;
|
|
1279
|
+
const _ = v().valueOf() - w, G = ((V = C == null ? void 0 : C.hours) == null ? void 0 : V.length) || 1;
|
|
1280
|
+
return S == null || S.debug("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", y == null ? void 0 : y.requestId, _, G, Math.round(_ / G * 1e3) / 1e3), R;
|
|
1265
1281
|
}
|
|
1266
1282
|
/**
|
|
1267
1283
|
* 在指定航线条件下,基于多CP,动态计算最优成本(租金+油费)方案
|
|
@@ -1278,34 +1294,34 @@ class W {
|
|
|
1278
1294
|
* @param lane 基础航线(重要转向点)
|
|
1279
1295
|
* @param options
|
|
1280
1296
|
*/
|
|
1281
|
-
static async analyseCost(
|
|
1282
|
-
var
|
|
1283
|
-
const o = v().valueOf(),
|
|
1284
|
-
|
|
1285
|
-
const r =
|
|
1297
|
+
static async analyseCost(e, t, a, i, n = {}) {
|
|
1298
|
+
var b, p;
|
|
1299
|
+
const o = v().valueOf(), s = [];
|
|
1300
|
+
e.speedStep = e.speedStep || 3, e.alterStep = e.alterStep ?? 1;
|
|
1301
|
+
const r = W.calculateRouteDistance(i.route);
|
|
1286
1302
|
let h = 0;
|
|
1287
1303
|
a.forEach((f) => {
|
|
1288
1304
|
const u = Math.ceil(r / f.speed / 24);
|
|
1289
1305
|
h = h < u ? u : h;
|
|
1290
1306
|
}), h = h * 1.3;
|
|
1291
|
-
const l = v.utc(
|
|
1307
|
+
const l = v.utc(e.etd).add(h ?? 14, "day");
|
|
1292
1308
|
let d = 1;
|
|
1293
1309
|
for (const f of a) {
|
|
1294
|
-
const u = JSON.parse(JSON.stringify(i.route)), m = JSON.parse(JSON.stringify(i.waypoints)), c = await
|
|
1295
|
-
{ lat:
|
|
1296
|
-
|
|
1310
|
+
const u = JSON.parse(JSON.stringify(i.route)), m = JSON.parse(JSON.stringify(i.waypoints)), c = await Y.analyseInstantWithThreshed(
|
|
1311
|
+
{ lat: e.lat, lng: e.lng },
|
|
1312
|
+
e.etd,
|
|
1297
1313
|
l,
|
|
1298
1314
|
t,
|
|
1299
1315
|
f,
|
|
1300
1316
|
u,
|
|
1301
1317
|
m,
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1318
|
+
e.meteoVendor,
|
|
1319
|
+
e.speedStep,
|
|
1320
|
+
e.useMeteo,
|
|
1321
|
+
e.useRouteParam,
|
|
1306
1322
|
n
|
|
1307
1323
|
);
|
|
1308
|
-
c && (await
|
|
1324
|
+
c && (await Y.calculateCost(c, f, e, n), s.push(c), S == null || S.info("[%s][L%d-%d] analyse from %s to %s cost: %j", n.requestId, 1, d, e.etd, l.format(), {
|
|
1309
1325
|
cost: c.cost.total,
|
|
1310
1326
|
hire: c.cost.hire,
|
|
1311
1327
|
bunker: c.cost.bunker,
|
|
@@ -1314,23 +1330,23 @@ class W {
|
|
|
1314
1330
|
cp: `${f.speed}/${f.fo}/${f.dgo}`
|
|
1315
1331
|
})), d++;
|
|
1316
1332
|
}
|
|
1317
|
-
|
|
1318
|
-
const y =
|
|
1319
|
-
if (g.push({ combined: !1, speeds: [y], cost: (
|
|
1333
|
+
s.sort((f, u) => f.cost.total - u.cost.total);
|
|
1334
|
+
const y = s.at(0), w = s.at(1), g = [];
|
|
1335
|
+
if (g.push({ combined: !1, speeds: [y], cost: (b = y.cost) == null ? void 0 : b.total }), w) {
|
|
1320
1336
|
const f = y.cost.cp, u = w.cost.cp, m = v(y.eta), c = v(y.etd), I = m.diff(c, "days", !0);
|
|
1321
1337
|
let C = Math.ceil(I / 2);
|
|
1322
|
-
C = C > 7 ? 7 : C <
|
|
1323
|
-
let F = 2,
|
|
1324
|
-
for (; C >=
|
|
1325
|
-
const H = await
|
|
1326
|
-
if (
|
|
1338
|
+
C = C > 7 ? 7 : C < e.alterStep ? e.alterStep : C;
|
|
1339
|
+
let F = 2, P = { combined: !1, speeds: [w], cost: (p = w.cost) == null ? void 0 : p.total }, D;
|
|
1340
|
+
for (; C >= e.alterStep; ) {
|
|
1341
|
+
const H = await Y.combinedAnalyse(e, t, l, [f, u], i, C, { ...n, level: F });
|
|
1342
|
+
if (P.cost > H.cost ? D ? (D == null ? void 0 : D.cost) > H.cost && (D = H) : (D = P, P = H) : (!D || (D == null ? void 0 : D.cost) > H.cost) && (D = H), C <= e.alterStep)
|
|
1327
1343
|
break;
|
|
1328
1344
|
C = Math.ceil(C / 2), F += 1;
|
|
1329
1345
|
}
|
|
1330
|
-
g.push(
|
|
1346
|
+
g.push(P), D && g.push(D);
|
|
1331
1347
|
}
|
|
1332
1348
|
const j = v().valueOf() - o;
|
|
1333
|
-
return
|
|
1349
|
+
return S == null || S.info("[%s] analyse elapsed: %d ms", n == null ? void 0 : n.requestId, j), g.sort((f, u) => f.cost - u.cost);
|
|
1334
1350
|
}
|
|
1335
1351
|
/**
|
|
1336
1352
|
* 按步长多次减半,分别用7,4,2,1天步长及cpa,cpb交替计算各种组合下的成本
|
|
@@ -1342,22 +1358,22 @@ class W {
|
|
|
1342
1358
|
* @param step 步长,7,4,2,1
|
|
1343
1359
|
* @param options
|
|
1344
1360
|
*/
|
|
1345
|
-
static async combinedAnalyse(
|
|
1346
|
-
|
|
1347
|
-
const r = await
|
|
1348
|
-
|
|
1361
|
+
static async combinedAnalyse(e, t, a, i, n, o, s = {}) {
|
|
1362
|
+
s.counter = 1, S == null || S.info("[%s][L%d] analyse with alternate cp in every %d days", s.requestId, s.level, o);
|
|
1363
|
+
const r = await Y.alternateAnalyse(e, t, a, i, 0, n, o, s), h = r.reduce((u, m) => u + m.cost.total, 0), l = r.reduce((u, m) => u + m.cost.hire, 0), d = r.reduce((u, m) => u + m.cost.bunker, 0), y = r.reduce((u, m) => u + m.distance, 0), w = r.reduce((u, m) => u + m.totalHrs, 0);
|
|
1364
|
+
S == null || S.info("[%s][L%d] cost with cpa/cpb turn: %j", s.requestId, s.level, {
|
|
1349
1365
|
cost: h,
|
|
1350
1366
|
hire: l,
|
|
1351
1367
|
bunker: d,
|
|
1352
1368
|
distance: y,
|
|
1353
1369
|
hours: w
|
|
1354
1370
|
});
|
|
1355
|
-
const g = await
|
|
1356
|
-
return
|
|
1371
|
+
const g = await Y.alternateAnalyse(e, t, a, i, 1, n, o, s), k = g.reduce((u, m) => u + m.cost.total, 0), j = g.reduce((u, m) => u + m.cost.hire, 0), b = g.reduce((u, m) => u + m.cost.bunker, 0), p = g.reduce((u, m) => u + m.distance, 0), f = g.reduce((u, m) => u + m.totalHrs, 0);
|
|
1372
|
+
return S == null || S.info("[%s][L%d] cost with cpb/cpa turn: %j", s.requestId, s.level, {
|
|
1357
1373
|
cost: k,
|
|
1358
1374
|
hire: j,
|
|
1359
|
-
bunker:
|
|
1360
|
-
distance:
|
|
1375
|
+
bunker: b,
|
|
1376
|
+
distance: p,
|
|
1361
1377
|
hours: f
|
|
1362
1378
|
}), h < k ? { combined: !0, cost: Math.round(h * 1e3) / 1e3, speeds: r, step: o } : { combined: !0, cost: Math.round(k * 1e3) / 1e3, speeds: g, step: o };
|
|
1363
1379
|
}
|
|
@@ -1372,26 +1388,26 @@ class W {
|
|
|
1372
1388
|
* @param step 步长,7,4,2,1
|
|
1373
1389
|
* @param options
|
|
1374
1390
|
*/
|
|
1375
|
-
static async alternateAnalyse(
|
|
1391
|
+
static async alternateAnalyse(e, t, a, i, n, o, s, r = {}) {
|
|
1376
1392
|
var y, w;
|
|
1377
|
-
let h = v.utc(
|
|
1378
|
-
const l = { lat:
|
|
1393
|
+
let h = v.utc(e.etd);
|
|
1394
|
+
const l = { lat: e.lat, lng: e.lng }, d = [];
|
|
1379
1395
|
for (; h.isBefore(a); ) {
|
|
1380
|
-
const g = h.clone().utc().add(
|
|
1396
|
+
const g = h.clone().utc().add(s, "day"), k = JSON.parse(JSON.stringify(o.route)), j = JSON.parse(JSON.stringify(o.waypoints)), b = i[n], p = await Y.analyseInstantWithThreshed(
|
|
1381
1397
|
l,
|
|
1382
1398
|
h.utc().format(),
|
|
1383
1399
|
g,
|
|
1384
1400
|
t,
|
|
1385
|
-
|
|
1401
|
+
b,
|
|
1386
1402
|
k,
|
|
1387
1403
|
j,
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1404
|
+
e.meteoVendor,
|
|
1405
|
+
e.speedStep,
|
|
1406
|
+
e.useMeteo,
|
|
1407
|
+
e.useRouteParam,
|
|
1392
1408
|
r
|
|
1393
1409
|
);
|
|
1394
|
-
|
|
1410
|
+
p && (await Y.calculateCost(p, b, e, r), S == null || S.info(
|
|
1395
1411
|
"[%s][L%d-%d] analyse from %s to %s cost: %j",
|
|
1396
1412
|
r.requestId,
|
|
1397
1413
|
r.level,
|
|
@@ -1399,17 +1415,17 @@ class W {
|
|
|
1399
1415
|
h.utc().format(),
|
|
1400
1416
|
g.utc().format(),
|
|
1401
1417
|
{
|
|
1402
|
-
cost:
|
|
1403
|
-
hire:
|
|
1404
|
-
bunker:
|
|
1405
|
-
distance:
|
|
1406
|
-
hours:
|
|
1407
|
-
cp: `${
|
|
1418
|
+
cost: p.cost.total,
|
|
1419
|
+
hire: p.cost.hire,
|
|
1420
|
+
bunker: p.cost.bunker,
|
|
1421
|
+
distance: p.distance,
|
|
1422
|
+
hours: p.totalHrs,
|
|
1423
|
+
cp: `${b.speed}/${b.fo}/${b.dgo}`
|
|
1408
1424
|
}
|
|
1409
1425
|
)), r.counter = r.counter + 1;
|
|
1410
|
-
const f = (w = (y =
|
|
1426
|
+
const f = (w = (y = p == null ? void 0 : p.sample) == null ? void 0 : y.hours) == null ? void 0 : w.at(-1);
|
|
1411
1427
|
if (f)
|
|
1412
|
-
l.lat = f.lat, l.lng = f.lng, h = v(f.eta), d.push(
|
|
1428
|
+
l.lat = f.lat, l.lng = f.lng, h = v(f.eta), d.push(p), n = n ? 0 : 1;
|
|
1413
1429
|
else
|
|
1414
1430
|
break;
|
|
1415
1431
|
}
|
|
@@ -1422,40 +1438,40 @@ class W {
|
|
|
1422
1438
|
* @param props
|
|
1423
1439
|
* @param options
|
|
1424
1440
|
*/
|
|
1425
|
-
static async calculateCost(
|
|
1441
|
+
static async calculateCost(e, t, a, i = {}) {
|
|
1426
1442
|
var n;
|
|
1427
|
-
if (
|
|
1428
|
-
const o = (a.addComm || 0) >= 1 ? (a.addComm || 0) / 100 : a.addComm || 0,
|
|
1429
|
-
|
|
1443
|
+
if (e) {
|
|
1444
|
+
const o = (a.addComm || 0) >= 1 ? (a.addComm || 0) / 100 : a.addComm || 0, s = Math.round((a.dailyHire || 0) * (e.suspend || 0) / 24 * 1e3) / 1e3, r = Math.round(e.totalHrs / 24 * (a.dailyHire || 0) * (1 - o) * 1e3) / 1e3 + s, h = Math.round(e.totalFoCons * (a.priceFO || 0) * 1e3) / 1e3, l = Math.round((e.totalDgoCons + (((n = e.extend) == null ? void 0 : n.totalDgoConsInECA) || 0)) * (a.priceDGO || 0) * 1e3) / 1e3;
|
|
1445
|
+
e.cost = {
|
|
1430
1446
|
total: Math.round((r + h + l) * 1e3) / 1e3,
|
|
1431
1447
|
hire: Math.round(r * 1e3) / 1e3,
|
|
1432
|
-
suspendHire:
|
|
1448
|
+
suspendHire: s,
|
|
1433
1449
|
bunker: Math.round((h + l) * 1e3) / 1e3,
|
|
1434
1450
|
cp: t
|
|
1435
1451
|
};
|
|
1436
1452
|
}
|
|
1437
|
-
return
|
|
1453
|
+
return e;
|
|
1438
1454
|
}
|
|
1439
1455
|
/**
|
|
1440
1456
|
* 计算单cp模式下的ECA属性
|
|
1441
1457
|
*
|
|
1442
1458
|
*/
|
|
1443
|
-
static async calculateECA(
|
|
1459
|
+
static async calculateECA(e, t, a = {}) {
|
|
1444
1460
|
var r, h, l, d;
|
|
1445
|
-
const i = await
|
|
1446
|
-
let n = 0, o = 0,
|
|
1447
|
-
(h = (r =
|
|
1461
|
+
const i = await W.intersectInECA((e == null ? void 0 : e.route) || []);
|
|
1462
|
+
let n = 0, o = 0, s = 0;
|
|
1463
|
+
(h = (r = e == null ? void 0 : e.sample) == null ? void 0 : r.wps) == null || h.forEach((y) => {
|
|
1448
1464
|
y.positionTime = v.utc(y.etd || y.eta).unix();
|
|
1449
1465
|
});
|
|
1450
1466
|
for (const y of i) {
|
|
1451
1467
|
n += y.distance;
|
|
1452
|
-
const w = await
|
|
1453
|
-
y.in = w, y.out = g, y.totalHrs = z.roundPrecision((g.positionTime - w.positionTime) / 3600, 3), y.totalDgoCons = z.roundPrecision(t.fo / 24 * y.totalHrs, 3), o += y.totalHrs,
|
|
1468
|
+
const w = await W.deadReckoningTime((l = y.waypoints) == null ? void 0 : l.at(0), e.sample.all || e.sample.wps), g = await W.deadReckoningTime((d = y.waypoints) == null ? void 0 : d.at(-1), e.sample.all || e.sample.wps);
|
|
1469
|
+
y.in = w, y.out = g, y.totalHrs = z.roundPrecision((g.positionTime - w.positionTime) / 3600, 3), y.totalDgoCons = z.roundPrecision(t.fo / 24 * y.totalHrs, 3), o += y.totalHrs, s += y.totalDgoCons;
|
|
1454
1470
|
}
|
|
1455
|
-
return n = z.roundPrecision(n, 3), o = z.roundPrecision(o, 3),
|
|
1471
|
+
return n = z.roundPrecision(n, 3), o = z.roundPrecision(o, 3), s = z.roundPrecision(s, 3), {
|
|
1456
1472
|
distanceInECA: n,
|
|
1457
1473
|
hoursInECA: o,
|
|
1458
|
-
totalDgoConsInECA:
|
|
1474
|
+
totalDgoConsInECA: s,
|
|
1459
1475
|
eca: i
|
|
1460
1476
|
};
|
|
1461
1477
|
}
|
|
@@ -1464,64 +1480,62 @@ class W {
|
|
|
1464
1480
|
* @param speeds
|
|
1465
1481
|
* @param options
|
|
1466
1482
|
*/
|
|
1467
|
-
static async mergeSpeeds(
|
|
1483
|
+
static async mergeSpeeds(e, t = {}) {
|
|
1468
1484
|
var f, u;
|
|
1469
1485
|
const a = {
|
|
1470
1486
|
hours: [],
|
|
1471
1487
|
wps: [],
|
|
1472
1488
|
days: []
|
|
1473
|
-
}, i =
|
|
1489
|
+
}, i = e.reduce((m, c) => m + c.distance, 0), n = e.reduce((m, c) => {
|
|
1474
1490
|
var I;
|
|
1475
1491
|
return m + (((I = c.extend) == null ? void 0 : I.distanceInECA) || 0);
|
|
1476
|
-
}, 0), o =
|
|
1492
|
+
}, 0), o = e.reduce((m, c) => m + c.totalHrs, 0), s = e.reduce((m, c) => {
|
|
1477
1493
|
var I;
|
|
1478
1494
|
return m + (((I = c.extend) == null ? void 0 : I.hoursInECA) || 0);
|
|
1479
|
-
}, 0), r =
|
|
1495
|
+
}, 0), r = e.reduce((m, c) => {
|
|
1480
1496
|
var I;
|
|
1481
1497
|
return m + (((I = c.extend) == null ? void 0 : I.totalDgoConsInECA) || 0);
|
|
1482
|
-
}, 0), h =
|
|
1483
|
-
let
|
|
1484
|
-
for (const m of
|
|
1485
|
-
|
|
1498
|
+
}, 0), h = e.reduce((m, c) => m + c.wxFactor * c.totalHrs / o, 0), l = e.reduce((m, c) => m + c.cFactor * c.totalHrs / o, 0), d = e.reduce((m, c) => m + c.totalFoCons, 0), y = e.reduce((m, c) => m + c.totalDgoCons, 0), w = e.reduce((m, c) => m + c.cost.total, 0), g = e.reduce((m, c) => m + c.cost.hire, 0), k = e.reduce((m, c) => m + c.cost.bunker, 0), j = [], b = [];
|
|
1499
|
+
let p;
|
|
1500
|
+
for (const m of e) {
|
|
1501
|
+
b.push(...((f = m.extend) == null ? void 0 : f.eca) || []);
|
|
1486
1502
|
const c = m.sample.hours, I = m.sample.wps, C = m.sample.days, F = c.at(0);
|
|
1487
|
-
|
|
1488
|
-
N && (
|
|
1489
|
-
}), I.at(0).distanceFromPrevious =
|
|
1490
|
-
N && (
|
|
1491
|
-
}), C.at(0).distanceFromPrevious =
|
|
1492
|
-
N && (
|
|
1503
|
+
p && (F.distanceFromPrevious = p.distanceFromPrevious, F.distanceFromStart = p.distanceFromStart, c.forEach((T, N) => {
|
|
1504
|
+
N && (T.distanceFromStart = T.distanceFromStart + p.distanceFromStart);
|
|
1505
|
+
}), I.at(0).distanceFromPrevious = p.distanceFromPrevious, I.at(0).distanceFromStart = p.distanceFromStart, I.forEach((T, N) => {
|
|
1506
|
+
N && (T.distanceFromStart = T.distanceFromStart + p.distanceFromStart);
|
|
1507
|
+
}), C.at(0).distanceFromPrevious = p.distanceFromPrevious, C.at(0).distanceFromStart = p.distanceFromStart, C.forEach((T, N) => {
|
|
1508
|
+
N && (T.distanceFromStart = T.distanceFromStart + p.distanceFromStart);
|
|
1493
1509
|
})), F.cp = m.cost.cp;
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1510
|
+
const P = [m.etd, m.eta], D = j.findIndex((T) => T.id === F.cp.id);
|
|
1511
|
+
D === -1 ? (F.cp.segment = [P], j.push(F.cp)) : j[D].segment.push(P), c.forEach((T) => {
|
|
1496
1512
|
var O;
|
|
1497
|
-
((O = a.hours) == null ? void 0 : O.findIndex((R) => R.eta ===
|
|
1498
|
-
}), I.forEach((
|
|
1513
|
+
((O = a.hours) == null ? void 0 : O.findIndex((R) => R.eta === T.eta)) === -1 && a.hours.push(T);
|
|
1514
|
+
}), I.forEach((T) => {
|
|
1499
1515
|
var O;
|
|
1500
|
-
((O = a.wps) == null ? void 0 : O.findIndex((R) => R.eta ===
|
|
1501
|
-
}), C.forEach((
|
|
1516
|
+
((O = a.wps) == null ? void 0 : O.findIndex((R) => R.eta === T.eta)) === -1 && a.wps.push(T);
|
|
1517
|
+
}), C.forEach((T) => {
|
|
1502
1518
|
var O;
|
|
1503
|
-
((O = a == null ? void 0 : a.days) == null ? void 0 : O.findIndex((R) => R.eta ===
|
|
1519
|
+
((O = a == null ? void 0 : a.days) == null ? void 0 : O.findIndex((R) => R.eta === T.eta)) === -1 && a.days.push(T);
|
|
1504
1520
|
});
|
|
1505
|
-
const H = (u = a.wps) == null ? void 0 : u.findIndex((
|
|
1506
|
-
H === -1 ? a.wps.push(F) : a.wps[H] = F,
|
|
1521
|
+
const H = (u = a.wps) == null ? void 0 : u.findIndex((T) => T.eta === F.eta);
|
|
1522
|
+
H === -1 ? a.wps.push(F) : a.wps[H] = F, p = c.at(-1);
|
|
1507
1523
|
}
|
|
1508
|
-
return a.wps.sort((m, c) => {
|
|
1509
|
-
v(m.etd).unix() - v(c.etd).unix();
|
|
1510
|
-
}), a.wps.forEach((m, c) => {
|
|
1524
|
+
return a.wps.sort((m, c) => v(m.etd).unix() - v(c.etd).unix()), a.wps.forEach((m, c) => {
|
|
1511
1525
|
const I = a.wps[c - 1];
|
|
1512
1526
|
if (I) {
|
|
1513
|
-
const C = m.distanceFromStart - (I.distanceFromStart || 0), F = v(m.eta || m.etd).diff(v(I.etd || I.eta), "hour", !0),
|
|
1514
|
-
m.avgSpd =
|
|
1515
|
-
const
|
|
1516
|
-
I.bearing =
|
|
1527
|
+
const C = m.distanceFromStart - (I.distanceFromStart || 0), F = v(m.eta || m.etd).diff(v(I.etd || I.eta), "hour", !0), P = Math.round(C / F * 100) / 100;
|
|
1528
|
+
m.avgSpd = P;
|
|
1529
|
+
const D = W.calculateBearing(I, m);
|
|
1530
|
+
I.bearing = D;
|
|
1517
1531
|
}
|
|
1518
1532
|
}), {
|
|
1519
1533
|
sample: a,
|
|
1520
|
-
etd:
|
|
1521
|
-
eta:
|
|
1522
|
-
from:
|
|
1523
|
-
to:
|
|
1524
|
-
v0:
|
|
1534
|
+
etd: e.at(0).etd,
|
|
1535
|
+
eta: e.at(-1).eta,
|
|
1536
|
+
from: e.at(0).from,
|
|
1537
|
+
to: e.at(-1).to,
|
|
1538
|
+
v0: e.at(0).v0,
|
|
1525
1539
|
label: "Combined",
|
|
1526
1540
|
distance: Math.round(i * 1e3) / 1e3,
|
|
1527
1541
|
totalHrs: Math.round(o * 1e3) / 1e3,
|
|
@@ -1537,26 +1551,26 @@ class W {
|
|
|
1537
1551
|
},
|
|
1538
1552
|
extend: {
|
|
1539
1553
|
cps: j,
|
|
1540
|
-
eca:
|
|
1554
|
+
eca: b,
|
|
1541
1555
|
distanceInECA: Math.round(n * 1e3) / 1e3,
|
|
1542
|
-
hoursInECA: Math.round(
|
|
1556
|
+
hoursInECA: Math.round(s * 1e3) / 1e3,
|
|
1543
1557
|
totalDgoConsInECA: Math.round(r * 1e3) / 1e3,
|
|
1544
|
-
speeds:
|
|
1558
|
+
speeds: e
|
|
1545
1559
|
}
|
|
1546
1560
|
};
|
|
1547
1561
|
}
|
|
1548
1562
|
}
|
|
1549
1563
|
export {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1564
|
+
at as AISImpl,
|
|
1565
|
+
Mt as AlertHelper,
|
|
1566
|
+
yt as AlertLevel,
|
|
1567
|
+
Ft as HifleetImpl,
|
|
1568
|
+
pt as LoadCondition,
|
|
1569
|
+
xt as MyShipImpl,
|
|
1570
|
+
Tt as MyVesselImpl,
|
|
1571
|
+
Nt as ShipxyImpl,
|
|
1572
|
+
Y as SpeedHelper,
|
|
1573
|
+
vt as SpeedLabel,
|
|
1574
|
+
bt as VesselTag,
|
|
1575
|
+
Dt as alertHelper
|
|
1562
1576
|
};
|