@idm-plugin/vessel 1.7.9 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +284 -278
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var G = (j, e, t) => (
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { LngLatHelper as
|
|
8
|
-
import { MeteoHelper2 as
|
|
9
|
-
import { Meteo2Assist as
|
|
10
|
-
let
|
|
1
|
+
var ht = Object.defineProperty;
|
|
2
|
+
var lt = (j, e, t) => e in j ? ht(j, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : j[e] = t;
|
|
3
|
+
var G = (j, e, t) => (lt(j, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import B from "got";
|
|
5
|
+
import it from "@log4js-node/log4js-api";
|
|
6
|
+
import g from "moment";
|
|
7
|
+
import { LngLatHelper as J, LaneHelper as W } from "@idm-plugin/geo2";
|
|
8
|
+
import { MeteoHelper2 as ft, MeteoHelper as mt } from "@idm-plugin/meteo2";
|
|
9
|
+
import { Meteo2Assist as ct } from "@idm-plugin/meteo";
|
|
10
|
+
let b;
|
|
11
11
|
try {
|
|
12
|
-
|
|
12
|
+
b = it.getLogger("vessel");
|
|
13
13
|
} catch {
|
|
14
14
|
} finally {
|
|
15
15
|
}
|
|
@@ -54,7 +54,7 @@ class et {
|
|
|
54
54
|
return { labelCn: t, labelEn: n };
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
class
|
|
57
|
+
class jt extends et {
|
|
58
58
|
constructor(t, n) {
|
|
59
59
|
super();
|
|
60
60
|
G(this, "clientId");
|
|
@@ -69,33 +69,33 @@ class Ct extends et {
|
|
|
69
69
|
client_secret: this.clientSecret,
|
|
70
70
|
grant_type: "client_credentials"
|
|
71
71
|
}
|
|
72
|
-
}, o = await
|
|
73
|
-
|
|
72
|
+
}, o = await B.post(n, i).json();
|
|
73
|
+
b == null || b.info("[%s] fetch access token from: %s - %j", t.requestId, n, o), o.error || (this.token = {
|
|
74
74
|
accessToken: o.access_token,
|
|
75
75
|
tokenType: o.token_type,
|
|
76
76
|
expiresIn: o.expires_in,
|
|
77
77
|
scope: o.scope,
|
|
78
78
|
jti: o.jti,
|
|
79
|
-
issuedAt:
|
|
79
|
+
issuedAt: g().utc().format()
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
async realTimePosition(t, n = {}) {
|
|
83
83
|
var u, m, l;
|
|
84
|
-
(!this.token ||
|
|
84
|
+
(!this.token || g().diff(g(this.token.issuedAt), "seconds") > ((u = this.token) == null ? void 0 : u.expiresIn) - 300) && await this.authToken(n);
|
|
85
85
|
const i = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit", o = {
|
|
86
86
|
headers: {
|
|
87
87
|
Authorization: `${(m = this.token) == null ? void 0 : m.tokenType} ${(l = this.token) == null ? void 0 : l.accessToken}`
|
|
88
88
|
},
|
|
89
89
|
searchParams: { mmsi: t }
|
|
90
90
|
};
|
|
91
|
-
|
|
92
|
-
const a = await
|
|
91
|
+
b == null || b.info("[%s] fetch realtime position from: %s - %j", n.requestId, i, o);
|
|
92
|
+
const a = await B.get(i, o).json();
|
|
93
93
|
if (a.code)
|
|
94
|
-
return
|
|
94
|
+
return b == null || b.warn("[%s] fetch realtime position failed: %j", n.requestId, i, { message: a.message, status: a.status, code: a.code }), a;
|
|
95
95
|
const s = a.data;
|
|
96
|
-
for (const
|
|
97
|
-
!isNaN(s[
|
|
98
|
-
const d =
|
|
96
|
+
for (const M in s)
|
|
97
|
+
!isNaN(s[M]) && Number(s[M]) !== 1 / 0 && (s[M] = Number(s[M]));
|
|
98
|
+
const d = g(`${s.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
99
99
|
return {
|
|
100
100
|
mmsi: s.mmsi,
|
|
101
101
|
name: s.vesselName,
|
|
@@ -110,7 +110,7 @@ class Ct extends et {
|
|
|
110
110
|
cog: s.cog,
|
|
111
111
|
hdg: s.hdg,
|
|
112
112
|
rot: s.rot,
|
|
113
|
-
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta) ?
|
|
113
|
+
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta) ? g.utc(s.eta).format() : void 0,
|
|
114
114
|
destination: s.dest,
|
|
115
115
|
positionTime: d.unix(),
|
|
116
116
|
status: s.status,
|
|
@@ -122,17 +122,17 @@ class Ct extends et {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
async trajectory(t, n, i, o, a = !0, s = {}) {
|
|
125
|
-
(!this.token ||
|
|
126
|
-
const d = await this.realTimePosition(t, s), r =
|
|
125
|
+
(!this.token || g().diff(g(this.token.issuedAt), "seconds") > this.token.expiresIn - 300) && await this.authToken(s);
|
|
126
|
+
const d = await this.realTimePosition(t, s), r = g(n), u = g(i), m = [];
|
|
127
127
|
for (; u.diff(r, "day", !0) > 30; )
|
|
128
128
|
await this.trajectoryIn30Day(t, r, r.clone().add(30, "day"), d, o, m, s), r.add(30, "day");
|
|
129
129
|
return await this.trajectoryIn30Day(t, r, u, d, o, m, s), m;
|
|
130
130
|
}
|
|
131
131
|
async trajectoryIn30Day(t, n, i, o, a, s, d = {}) {
|
|
132
|
-
var f,
|
|
132
|
+
var f, C, k, w, v;
|
|
133
133
|
const r = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/track", u = {
|
|
134
134
|
headers: {
|
|
135
|
-
Authorization: `${(f = this.token) == null ? void 0 : f.tokenType} ${(
|
|
135
|
+
Authorization: `${(f = this.token) == null ? void 0 : f.tokenType} ${(C = this.token) == null ? void 0 : C.accessToken}`
|
|
136
136
|
},
|
|
137
137
|
json: {
|
|
138
138
|
mmsi: t,
|
|
@@ -140,16 +140,16 @@ class Ct extends et {
|
|
|
140
140
|
endTime: i.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
|
|
144
|
-
const m = await
|
|
143
|
+
b == null || b.info("[%s] fetch trajectory from: %s - %j", d.requestId, r, u);
|
|
144
|
+
const m = await B.post(r, u).json();
|
|
145
145
|
if (m.code)
|
|
146
|
-
return
|
|
146
|
+
return b == null || b.warn("[%s] fetch trajectory failed: %j", d.requestId, r, { message: m.message, status: m.status, code: m.code }), m;
|
|
147
147
|
let l = -1;
|
|
148
|
-
const
|
|
149
|
-
return (
|
|
148
|
+
const M = g(`${(w = (k = m.data) == null ? void 0 : k[0]) == null ? void 0 : w.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
149
|
+
return (v = m.data) == null || v.forEach((c) => {
|
|
150
150
|
for (const Y in c)
|
|
151
151
|
!isNaN(c[Y]) && Number(c[Y]) !== 1 / 0 && (c[Y] = Number(c[Y]));
|
|
152
|
-
const p =
|
|
152
|
+
const p = g(`${c.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), y = c.status, { labelCn: h, labelEn: I } = this.parseStatus(y), S = {
|
|
153
153
|
mmsi: c.mmsi,
|
|
154
154
|
imo: o == null ? void 0 : o.imo,
|
|
155
155
|
lat: c.lat,
|
|
@@ -158,8 +158,8 @@ class Ct extends et {
|
|
|
158
158
|
cog: c.cog,
|
|
159
159
|
hdg: c.hdg,
|
|
160
160
|
draught: c.draught,
|
|
161
|
-
status:
|
|
162
|
-
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(c.eta) ?
|
|
161
|
+
status: y,
|
|
162
|
+
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(c.eta) ? g(`${c.eta} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00").utc().format() : void 0,
|
|
163
163
|
destination: c.dest,
|
|
164
164
|
positionTime: p.unix(),
|
|
165
165
|
labelCn: h,
|
|
@@ -167,12 +167,12 @@ class Ct extends et {
|
|
|
167
167
|
method: "trajectory",
|
|
168
168
|
vendor: "myVessel",
|
|
169
169
|
utc: p.utc().format()
|
|
170
|
-
}, D = Math.floor(p.diff(
|
|
170
|
+
}, D = Math.floor(p.diff(M, "minute", !0) / (a || 1));
|
|
171
171
|
D !== l && (l = D, s.push(S));
|
|
172
172
|
}), s;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
class
|
|
175
|
+
class Et extends et {
|
|
176
176
|
constructor(t) {
|
|
177
177
|
super();
|
|
178
178
|
G(this, "token");
|
|
@@ -184,15 +184,15 @@ class jt extends et {
|
|
|
184
184
|
mmsi: t,
|
|
185
185
|
usertoken: this.token
|
|
186
186
|
}
|
|
187
|
-
}, a = await
|
|
188
|
-
|
|
187
|
+
}, a = await B.post(i, o).json();
|
|
188
|
+
b == null || b.info("[%s] fetch realtime position from: %s - %j", n.requestId, i, o);
|
|
189
189
|
const s = a == null ? void 0 : a.list;
|
|
190
190
|
if (!s)
|
|
191
|
-
return
|
|
192
|
-
for (const
|
|
193
|
-
!isNaN(s[
|
|
191
|
+
return b == null || b.warn("[%s] fetch realtime position failed: %j", n.requestId, i, a), a;
|
|
192
|
+
for (const M in s)
|
|
193
|
+
!isNaN(s[M]) && Number(s[M]) !== 1 / 0 && (s[M] = Number(s[M]));
|
|
194
194
|
s.status = s.sp > 3 ? 0 : 1;
|
|
195
|
-
const d = s.status, { labelCn: r, labelEn: u } = this.parseStatus(d), m =
|
|
195
|
+
const d = s.status, { labelCn: r, labelEn: u } = this.parseStatus(d), m = g(`${s.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
196
196
|
return {
|
|
197
197
|
mmsi: s.m,
|
|
198
198
|
name: s.n,
|
|
@@ -207,7 +207,7 @@ class jt extends et {
|
|
|
207
207
|
cog: s.co,
|
|
208
208
|
hdg: s.h,
|
|
209
209
|
rot: isNaN(s.rot) ? 0 : s.rot,
|
|
210
|
-
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta) ?
|
|
210
|
+
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta) ? g.utc(s.eta).format() : void 0,
|
|
211
211
|
destination: s.destination,
|
|
212
212
|
positionTime: m.unix(),
|
|
213
213
|
utc: m.utc().format(),
|
|
@@ -230,8 +230,8 @@ class jt extends et {
|
|
|
230
230
|
Host: "www.hifleet.com"
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
|
-
let a = await
|
|
234
|
-
|
|
233
|
+
let a = await B.post(i, o).json();
|
|
234
|
+
b == null || b.info("[%s] fetch vessel props from: %s - %j", n.requestId, i, o), a instanceof Array && (a = a[0]);
|
|
235
235
|
for (const d in a)
|
|
236
236
|
!isNaN(a[d]) && Number(a[d]) !== 1 / 0 && (a[d] = Number(a[d]));
|
|
237
237
|
const s = {
|
|
@@ -244,7 +244,7 @@ class jt extends et {
|
|
|
244
244
|
draught: a.dr,
|
|
245
245
|
type: a.t
|
|
246
246
|
};
|
|
247
|
-
return i = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", a = await
|
|
247
|
+
return i = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", a = await B.post(i, o).json(), b == null || b.info("[%s] search vessel dead weight from: %s - %j", n.requestId, i, o), a instanceof Array && (a = a[0]), a && (s.deadweight = Number(a.dwt)), s;
|
|
248
248
|
}
|
|
249
249
|
async suggest(t, n = {}) {
|
|
250
250
|
const i = "https://www.hifleet.com/hifleetapi/getShipSuggest.do", o = {
|
|
@@ -256,8 +256,8 @@ class jt extends et {
|
|
|
256
256
|
Origin: "https://www.hifleet.com",
|
|
257
257
|
Host: "www.hifleet.com"
|
|
258
258
|
}
|
|
259
|
-
}, a = await
|
|
260
|
-
|
|
259
|
+
}, a = await B.post(i, o).json();
|
|
260
|
+
b == null || b.info("[%s] suggest vessel props from: %s - %j", n.requestId, i, o);
|
|
261
261
|
const s = [];
|
|
262
262
|
for (const d of a)
|
|
263
263
|
s.push({
|
|
@@ -270,10 +270,10 @@ class jt extends et {
|
|
|
270
270
|
return s.sort((d, r) => r.score - d.score), s;
|
|
271
271
|
}
|
|
272
272
|
async trajectory(t, n, i, o, a = !0, s = {}) {
|
|
273
|
-
var c, p,
|
|
273
|
+
var c, p, y;
|
|
274
274
|
const d = await this.realTimePosition(t, s);
|
|
275
|
-
let r =
|
|
276
|
-
const u =
|
|
275
|
+
let r = g(n);
|
|
276
|
+
const u = g(i), m = g();
|
|
277
277
|
if (a) {
|
|
278
278
|
let h = u.diff(r, "d", !0);
|
|
279
279
|
h < 0 ? r = u.clone().subtract(40, "d") : h < 30 ? r.subtract(10, "d") : h < 60 ? r.subtract(5, "d") : r = u.clone().subtract(80, "d"), h = m.diff(u, "d", !0), u.add(h > 10 ? 240 : h * 24, "h");
|
|
@@ -285,17 +285,17 @@ class jt extends et {
|
|
|
285
285
|
mmsi: t,
|
|
286
286
|
usertoken: this.token
|
|
287
287
|
}
|
|
288
|
-
},
|
|
289
|
-
|
|
290
|
-
let
|
|
291
|
-
f && (
|
|
288
|
+
}, M = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token", f = await B.get(M, l).json();
|
|
289
|
+
b == null || b.info("[%s] fetch trajectory from: %s - %j", s.requestId, M, l);
|
|
290
|
+
let C;
|
|
291
|
+
f && (C = ((p = (c = f.ships) == null ? void 0 : c.offors) == null ? void 0 : p.ship) || [], C.length || b == null || b.warn("[%s] fetch trajectory failed: %j", s.requestId, f));
|
|
292
292
|
const k = [];
|
|
293
|
-
let
|
|
294
|
-
const
|
|
295
|
-
for (const h of
|
|
293
|
+
let w = -1;
|
|
294
|
+
const v = g(`${(y = C == null ? void 0 : C[0]) == null ? void 0 : y.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
295
|
+
for (const h of C) {
|
|
296
296
|
for (const P in h)
|
|
297
297
|
!isNaN(h[P]) && Number(h[P]) !== 1 / 0 && (h[P] = Number(h[P]));
|
|
298
|
-
const I =
|
|
298
|
+
const I = g(`${h.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
299
299
|
h.status = h.sp > 4 ? 0 : 1;
|
|
300
300
|
const { labelEn: S, labelCn: D } = this.parseStatus(h.status), Y = {
|
|
301
301
|
mmsi: h.m,
|
|
@@ -314,13 +314,13 @@ class jt extends et {
|
|
|
314
314
|
labelEn: S,
|
|
315
315
|
method: "trajectory",
|
|
316
316
|
vendor: "hifleet"
|
|
317
|
-
},
|
|
318
|
-
|
|
317
|
+
}, E = Math.floor(I.diff(v, "minute", !0) / (o || 1));
|
|
318
|
+
E !== w && (w = E, k.push(Y));
|
|
319
319
|
}
|
|
320
320
|
return k;
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
class
|
|
323
|
+
class Nt extends et {
|
|
324
324
|
constructor(t) {
|
|
325
325
|
super();
|
|
326
326
|
G(this, "token");
|
|
@@ -333,13 +333,13 @@ class Et extends et {
|
|
|
333
333
|
k: this.token,
|
|
334
334
|
enc: 1
|
|
335
335
|
}
|
|
336
|
-
}, o = "https://api.shipxy.com/apicall/GetSingleShip", a = await
|
|
337
|
-
if (
|
|
336
|
+
}, o = "https://api.shipxy.com/apicall/GetSingleShip", a = await B.get(o, i).json();
|
|
337
|
+
if (b == null || b.info("[%s] fetch realtime position from: %s - %j", n.requestId, o, i), (a == null ? void 0 : a.status) !== 0)
|
|
338
338
|
return a;
|
|
339
339
|
const s = a.data[0];
|
|
340
340
|
for (const l in s)
|
|
341
341
|
!isNaN(s[l]) && Number(s[l]) !== 1 / 0 && (s[l] = Number(s[l]));
|
|
342
|
-
const { labelCn: d, labelEn: r } = await this.parseStatus(s.navistat), u =
|
|
342
|
+
const { labelCn: d, labelEn: r } = await this.parseStatus(s.navistat), u = g.unix(s.lasttime);
|
|
343
343
|
return {
|
|
344
344
|
mmsi: s.ShipID,
|
|
345
345
|
name: s.name,
|
|
@@ -364,8 +364,8 @@ class Et extends et {
|
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
async trajectory(t, n, i, o, a = !0, s = {}) {
|
|
367
|
-
var
|
|
368
|
-
const d = await this.realTimePosition(t, s), r =
|
|
367
|
+
var v;
|
|
368
|
+
const d = await this.realTimePosition(t, s), r = g(n), u = g(i), m = "https://api.shipxy.com/apicall/GetShipTrack", l = {
|
|
369
369
|
searchParams: {
|
|
370
370
|
id: t,
|
|
371
371
|
k: this.token,
|
|
@@ -374,13 +374,13 @@ class Et extends et {
|
|
|
374
374
|
btm: r.unix(),
|
|
375
375
|
etm: u.unix()
|
|
376
376
|
}
|
|
377
|
-
},
|
|
378
|
-
if (
|
|
379
|
-
return
|
|
380
|
-
const f =
|
|
381
|
-
let
|
|
377
|
+
}, M = await B.get(m, l).json();
|
|
378
|
+
if (b == null || b.info("[%s] fetch trajectory from: %s - %j", s.requestId, m, l), (M == null ? void 0 : M.status) !== 0)
|
|
379
|
+
return M;
|
|
380
|
+
const f = M == null ? void 0 : M.points, C = [], k = g.unix((v = f[0]) == null ? void 0 : v.utc);
|
|
381
|
+
let w = -1;
|
|
382
382
|
for (const c of f) {
|
|
383
|
-
const p =
|
|
383
|
+
const p = g.unix(c.utc), y = {
|
|
384
384
|
imo: d == null ? void 0 : d.imo,
|
|
385
385
|
mmsi: t,
|
|
386
386
|
sog: Math.round(c.sog * 3600 / 1e3 / 1852 * 100) / 100,
|
|
@@ -392,12 +392,12 @@ class Et extends et {
|
|
|
392
392
|
method: "trajectory",
|
|
393
393
|
vendor: "shipxy"
|
|
394
394
|
}, h = Math.floor(p.diff(k, "minute", !0) / (o || 1));
|
|
395
|
-
h !==
|
|
395
|
+
h !== w && (w = h, C.push(y));
|
|
396
396
|
}
|
|
397
|
-
return
|
|
397
|
+
return C;
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
class
|
|
400
|
+
class Tt extends et {
|
|
401
401
|
constructor(t) {
|
|
402
402
|
super();
|
|
403
403
|
G(this, "token");
|
|
@@ -411,8 +411,8 @@ class Nt extends et {
|
|
|
411
411
|
json: {
|
|
412
412
|
mmsiList: t
|
|
413
413
|
}
|
|
414
|
-
}, o = "https://api3.myships.com/sp/ships/getShipIdByMMSI", a = await
|
|
415
|
-
return
|
|
414
|
+
}, o = "https://api3.myships.com/sp/ships/getShipIdByMMSI", a = await B.post(o, i).json();
|
|
415
|
+
return b == null || b.info("[%s] fetch ship id from: %s - %j", n.requestId, o, i), a.code !== "0" ? a : a.data[0].shipId;
|
|
416
416
|
}
|
|
417
417
|
async getShipInfo(t, n = {}) {
|
|
418
418
|
const i = {
|
|
@@ -422,12 +422,12 @@ class Nt extends et {
|
|
|
422
422
|
json: {
|
|
423
423
|
shipId: t
|
|
424
424
|
}
|
|
425
|
-
}, o = "https://api3.myships.com/sp/ships/aissta", a = await
|
|
426
|
-
if (
|
|
425
|
+
}, o = "https://api3.myships.com/sp/ships/aissta", a = await B.post(o, i).json();
|
|
426
|
+
if (b == null || b.info("[%s] fetch ship info from: %s - %j", n.requestId, o, i), a.code !== "0")
|
|
427
427
|
return a;
|
|
428
428
|
const s = a.data;
|
|
429
429
|
let d = s.imo;
|
|
430
|
-
return t === "407170" && (d = "9198379",
|
|
430
|
+
return t === "407170" && (d = "9198379", b == null || b.warn("[%s] ship(%s) imo error: %s, should be %s", n.requestId, t, s.imo, d)), {
|
|
431
431
|
mmsi: s.mmsi,
|
|
432
432
|
name: s.shipnameEn,
|
|
433
433
|
imo: d,
|
|
@@ -445,12 +445,12 @@ class Nt extends et {
|
|
|
445
445
|
json: {
|
|
446
446
|
shipId: i
|
|
447
447
|
}
|
|
448
|
-
}, s = "https://api3.myships.com/sp/ships/position/latest", d = await
|
|
449
|
-
|
|
448
|
+
}, s = "https://api3.myships.com/sp/ships/position/latest", d = await B.post(s, a).json();
|
|
449
|
+
b == null || b.info("[%s] fetch realtime position from: %s - %j", n.requestId, s, a);
|
|
450
450
|
const r = d.data[0];
|
|
451
451
|
for (const f in r)
|
|
452
452
|
!isNaN(r[f]) && Number(r[f]) !== 1 / 0 && (r[f] = Number(r[f]));
|
|
453
|
-
const { labelCn: u, labelEn: m } = await this.parseStatus(r.aisNavStatus), l =
|
|
453
|
+
const { labelCn: u, labelEn: m } = await this.parseStatus(r.aisNavStatus), l = g.unix(r.posTime);
|
|
454
454
|
return {
|
|
455
455
|
...o,
|
|
456
456
|
mmsi: t,
|
|
@@ -470,7 +470,7 @@ class Nt extends et {
|
|
|
470
470
|
};
|
|
471
471
|
}
|
|
472
472
|
async trajectory(t, n, i, o, a = !0, s = {}) {
|
|
473
|
-
const d =
|
|
473
|
+
const d = g(n), r = g(i), u = await this.getShipId(t), m = await this.getShipInfo(u), l = [];
|
|
474
474
|
for (; r.diff(d, "day", !0) > 30; )
|
|
475
475
|
await this.trajectoryIn30Day(u, d.unix(), d.add(30, "day").unix(), m, t, o, l);
|
|
476
476
|
return await this.trajectoryIn30Day(u, d.unix(), r.unix(), m, t, o, l), l;
|
|
@@ -486,42 +486,42 @@ class Nt extends et {
|
|
|
486
486
|
startTime: n,
|
|
487
487
|
endTime: i
|
|
488
488
|
}
|
|
489
|
-
}, m = "https://api3.myships.com/sp/ships/position/history", l = await
|
|
490
|
-
if (
|
|
491
|
-
return
|
|
492
|
-
const
|
|
493
|
-
for (const
|
|
494
|
-
!isNaN(
|
|
495
|
-
const f =
|
|
496
|
-
let
|
|
497
|
-
for (const
|
|
498
|
-
const
|
|
489
|
+
}, m = "https://api3.myships.com/sp/ships/position/history", l = await B.post(m, u).json();
|
|
490
|
+
if (b == null || b.info("[%s] fetch trajectory from: %s - %j", r.requestId, m, u), l.code !== "0")
|
|
491
|
+
return b == null || b.warn("[%s] invoke myship trajectory failed: %j", r.requestId, l), l;
|
|
492
|
+
const M = l.data;
|
|
493
|
+
for (const w in M)
|
|
494
|
+
!isNaN(M[w]) && Number(M[w]) !== 1 / 0 && (M[w] = Number(M[w]));
|
|
495
|
+
const f = g.unix((k = M[0]) == null ? void 0 : k.posTime);
|
|
496
|
+
let C = -1;
|
|
497
|
+
for (const w of M) {
|
|
498
|
+
const v = g.unix(w.posTime), c = {
|
|
499
499
|
imo: o == null ? void 0 : o.imo,
|
|
500
500
|
mmsi: a,
|
|
501
|
-
lat: Math.round(
|
|
502
|
-
lng: Math.round(
|
|
503
|
-
sog: Math.round(
|
|
504
|
-
cog: Math.round(
|
|
505
|
-
hdg: Math.round(
|
|
506
|
-
rot: Math.round(
|
|
507
|
-
positionTime:
|
|
508
|
-
utc:
|
|
501
|
+
lat: Math.round(w.lat / 1e4 / 60 * 1e5) / 1e5,
|
|
502
|
+
lng: Math.round(w.lon / 1e4 / 60 * 1e5) / 1e5,
|
|
503
|
+
sog: Math.round(w.sog / 10 * 100) / 100,
|
|
504
|
+
cog: Math.round(w.cog / 10 * 100) / 100,
|
|
505
|
+
hdg: Math.round(w.heading * 100) / 100,
|
|
506
|
+
rot: Math.round(w.rot * 100) / 100,
|
|
507
|
+
positionTime: v.unix(),
|
|
508
|
+
utc: v.utc().format(),
|
|
509
509
|
method: "trajectory",
|
|
510
510
|
vendor: "myship"
|
|
511
|
-
}, p = Math.floor(
|
|
512
|
-
p !==
|
|
511
|
+
}, p = Math.floor(v.diff(f, "minute", !0) / (s || 1));
|
|
512
|
+
p !== C && (C = p, d.push(c));
|
|
513
513
|
}
|
|
514
514
|
return d;
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
517
|
let _;
|
|
518
518
|
try {
|
|
519
|
-
_ =
|
|
519
|
+
_ = it.getLogger("vessel");
|
|
520
520
|
} catch {
|
|
521
521
|
} finally {
|
|
522
522
|
}
|
|
523
|
-
var
|
|
524
|
-
class
|
|
523
|
+
var yt = /* @__PURE__ */ ((j) => (j.NOTICE = "NOTICE", j.WARN = "WARN", j.HEAVY = "HEAVY", j.SEVERE = "SEVERE", j.ERROR = "ERROR", j.FATAL = "FATAL", j))(yt || {});
|
|
524
|
+
class Mt {
|
|
525
525
|
/**
|
|
526
526
|
* 解析告警规则, 多规则场景
|
|
527
527
|
* @param rule
|
|
@@ -542,7 +542,7 @@ class yt {
|
|
|
542
542
|
if (u === 0 && !m)
|
|
543
543
|
a.scope = o[0];
|
|
544
544
|
else if (m)
|
|
545
|
-
for (let l = 0,
|
|
545
|
+
for (let l = 0, M = m.length; l < M; l++) {
|
|
546
546
|
const f = this.parseRule(m[l]);
|
|
547
547
|
f && (a[f.level] ? f.key ? a[f.level][f == null ? void 0 : f.key] = f : a[f.level] = f : f.key ? a[f.level] = { [f == null ? void 0 : f.key]: f } : a[f.level] = f);
|
|
548
548
|
}
|
|
@@ -575,25 +575,25 @@ class yt {
|
|
|
575
575
|
* @param options
|
|
576
576
|
*/
|
|
577
577
|
checkWeather(e, t, n = {}) {
|
|
578
|
-
var f,
|
|
578
|
+
var f, C, k, w, v, c, p, y, h, I, S, D, Y, E, P;
|
|
579
579
|
let i = 0, o = 0, a = 0, s = 0;
|
|
580
|
-
const d = Math.round(((
|
|
580
|
+
const d = Math.round(((C = (f = t == null ? void 0 : t.SEVERE) == null ? void 0 : f.sigWave) == null ? void 0 : C.number) * 1.6 * 100) / 100, r = (w = (k = t == null ? void 0 : t.SEVERE) == null ? void 0 : k.sigWave) == null ? void 0 : w.number, u = (c = (v = t == null ? void 0 : t.HEAVY) == null ? void 0 : v.sigWave) == null ? void 0 : c.number, m = Math.round((((y = (p = t == null ? void 0 : t.SEVERE) == null ? void 0 : p.wind) == null ? void 0 : y.number) + 2) * 100) / 100, l = (I = (h = t == null ? void 0 : t.SEVERE) == null ? void 0 : h.wind) == null ? void 0 : I.number, M = (D = (S = t == null ? void 0 : t.HEAVY) == null ? void 0 : S.wind) == null ? void 0 : D.number;
|
|
581
581
|
for (let T = 0; T < (e == null ? void 0 : e.length); T++) {
|
|
582
|
-
const
|
|
583
|
-
s = K > s ? K : s, _ == null || _.info("[%s] check sig.wave: %j", n.requestId, { ...A, dgThd4Wv: d, svThd4Wv: r, hvThd4Wv: u }), (A == null ? void 0 : A.height) >= d ?
|
|
582
|
+
const N = e[T], A = (E = (Y = N == null ? void 0 : N.meteo) == null ? void 0 : Y.wave) == null ? void 0 : E.sig, R = (P = N == null ? void 0 : N.meteo) == null ? void 0 : P.wind, K = T ? g(N.eta).diff(g(e[T - 1].eta), "hour", !0) : 0;
|
|
583
|
+
s = K > s ? K : s, _ == null || _.info("[%s] check sig.wave: %j", n.requestId, { ...A, dgThd4Wv: d, svThd4Wv: r, hvThd4Wv: u }), (A == null ? void 0 : A.height) >= d ? N.isDangerous = !0 : (A == null ? void 0 : A.height) >= r ? N.isSevere = !0 : (A == null ? void 0 : A.height) >= u && (N.isHeavy = !0), _ == null || _.info("[%s] check wind: %j", n.requestId, { ...R, dgThd4Wd: m, svThd4Wd: l, hvThd4Wd: M }), (R == null ? void 0 : R.scale) >= m ? (N.isDangerous = !0, delete N.isSevere, delete N.isHeavy) : (R == null ? void 0 : R.scale) > l ? (N.isDangerous || (N.isSevere = !0), delete N.isHeavy) : (R == null ? void 0 : R.scale) === M && !N.isDangerous && !N.isSevere && (N.isHeavy = !0), i += N.isDangerous ? K : 0, o += N.isSevere ? K : 0, a += N.isHeavy ? K : 0;
|
|
584
584
|
}
|
|
585
|
-
return i = Math.round(i * 100) / 100, o = Math.round(o * 100) / 100, a = Math.round(a * 100) / 100, s = Math.round(s), { sample: e, dangerous: i, severe: o, heavy: a, step: s < 3 ? 3 : s, wind: { dgThd4Wd: m, svThd4Wd: l, hvThd4Wd:
|
|
585
|
+
return i = Math.round(i * 100) / 100, o = Math.round(o * 100) / 100, a = Math.round(a * 100) / 100, s = Math.round(s), { sample: e, dangerous: i, severe: o, heavy: a, step: s < 3 ? 3 : s, wind: { dgThd4Wd: m, svThd4Wd: l, hvThd4Wd: M }, sig: { dgThd4Wv: d, svThd4Wv: r, hvThd4Wv: u } };
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
|
-
const
|
|
588
|
+
const Dt = new Mt();
|
|
589
589
|
let F;
|
|
590
590
|
try {
|
|
591
|
-
F =
|
|
591
|
+
F = it.getLogger("vessel");
|
|
592
592
|
} catch {
|
|
593
593
|
} finally {
|
|
594
594
|
}
|
|
595
|
-
const
|
|
596
|
-
var
|
|
595
|
+
const gt = new ft("", !0);
|
|
596
|
+
var bt = /* @__PURE__ */ ((j) => (j.common = "common", j.container = "container", j.tugs = "tugs", j))(bt || {}), pt = /* @__PURE__ */ ((j) => (j.Ballast = "Ballast", j.Laden = "Laden", j))(pt || {}), vt = /* @__PURE__ */ ((j) => (j.Cp = "CP", j.Perf = "Basis", j.Instruct = "Other", j))(vt || {});
|
|
597
597
|
class O {
|
|
598
598
|
/**
|
|
599
599
|
* @see https://baike.baidu.com/item/%E6%96%B9%E5%BD%A2%E7%B3%BB%E6%95%B0/4965568?fr=aladdin
|
|
@@ -734,23 +734,23 @@ class O {
|
|
|
734
734
|
*/
|
|
735
735
|
static async speedLoseAt(e, t, n, i = "", o = 2, a = !0, s = !1, d = {}) {
|
|
736
736
|
let r;
|
|
737
|
-
if (t.velocity && s && (e.speed =
|
|
737
|
+
if (t.velocity && s && (e.speed = J.roundPrecision(t.velocity * 1852 / 3600, 6)), a) {
|
|
738
738
|
let u;
|
|
739
739
|
if (d.meteo2)
|
|
740
740
|
try {
|
|
741
|
-
const f = await
|
|
742
|
-
u =
|
|
741
|
+
const f = await gt.spotForecast(t.lat, t.lng, n.utc().format(), !1, !1, !0, d), [C] = ct.pickHourly(f, n);
|
|
742
|
+
u = ct.toLegacy(C);
|
|
743
743
|
} catch (f) {
|
|
744
744
|
F.warn("[%s] meteo2 spot(%j) forecast failed: %s", d.requestId, { ...t, eta: n.utc().format() }, f);
|
|
745
745
|
}
|
|
746
746
|
else
|
|
747
|
-
u = await
|
|
748
|
-
const m = O.weatherFactor(e, u), l = O.currentFactor(e.bearing, u == null ? void 0 : u.current, o),
|
|
747
|
+
u = await mt.queryPointFactor(t.lng, t.lat, n.valueOf(), "wind,wave,current,watertemp", i, d);
|
|
748
|
+
const m = O.weatherFactor(e, u), l = O.currentFactor(e.bearing, u == null ? void 0 : u.current, o), M = Math.round((e.speed * 1.943844 + m + l) * 100) / 100;
|
|
749
749
|
r = {
|
|
750
750
|
meteo: { ...u },
|
|
751
751
|
wxFactor: m,
|
|
752
752
|
cFactor: l,
|
|
753
|
-
speed: t.velocity && s ? t.velocity :
|
|
753
|
+
speed: t.velocity && s ? t.velocity : M < 0 ? 1 : M,
|
|
754
754
|
eta: n.utc().format(),
|
|
755
755
|
etd: n.utc().format()
|
|
756
756
|
};
|
|
@@ -779,13 +779,13 @@ class O {
|
|
|
779
779
|
*/
|
|
780
780
|
static async speedLoseInHoursStep(e, t, n, i, o, a, s = "", d = !0, r = !1, u = {}) {
|
|
781
781
|
t.utc();
|
|
782
|
-
const m = t.clone().add(14, "days"), l = [],
|
|
783
|
-
let f = 0,
|
|
784
|
-
for (let
|
|
785
|
-
let c = a[
|
|
786
|
-
c.distanceFromStart = Math.round((o +
|
|
787
|
-
const p = a[
|
|
788
|
-
if (e.bearing =
|
|
782
|
+
const m = t.clone().add(14, "days"), l = [], M = [];
|
|
783
|
+
let f = 0, C = 0, k, w;
|
|
784
|
+
for (let v = 0; v < a.length - 1; v++) {
|
|
785
|
+
let c = a[v];
|
|
786
|
+
c.distanceFromStart = Math.round((o + C) * 1e4) / 1e4;
|
|
787
|
+
const p = a[v + 1];
|
|
788
|
+
if (e.bearing = W.calculateBearing(c, p, !p.gcToPrevious), c.bearing = e.bearing, c.suspend && r) {
|
|
789
789
|
c.eta = c.eta || t.utc().format(), c.elapsed = c.elapsed ?? 0;
|
|
790
790
|
const I = c.suspend - c.elapsed;
|
|
791
791
|
if (i - f > I)
|
|
@@ -795,35 +795,35 @@ class O {
|
|
|
795
795
|
c.elapsed += S, t.add(S, "hour"), i = 0;
|
|
796
796
|
}
|
|
797
797
|
if (F == null || F.info(`[%s] suspend ${c.elapsed} hours at %j, and remain ${i} hours need to go...`, u.requestId, c), i === 0)
|
|
798
|
-
return c.distanceFromPrevious =
|
|
798
|
+
return c.distanceFromPrevious = C, { etd: t, from: w || c, to: c, next: a.filter((S) => S), wps: l, days: M };
|
|
799
799
|
} else
|
|
800
800
|
c.suspend = 0;
|
|
801
|
-
d = t.isAfter(m) ? !1 : d, c = await O.speedLoseAt(e, c, t, s, 0, d, r, u),
|
|
802
|
-
const
|
|
803
|
-
let h = Math.round(
|
|
801
|
+
d = t.isAfter(m) ? !1 : d, c = await O.speedLoseAt(e, c, t, s, 0, d, r, u), w = w || c, c.important && l.push(c), t.isSameOrAfter(n) && (M.push(c), n.add(24, "hour"));
|
|
802
|
+
const y = W.calculateDistance(c, p, !p.gcToPrevious);
|
|
803
|
+
let h = Math.round(y / w.speed * 1e5) / 1e5;
|
|
804
804
|
if (f + h < i) {
|
|
805
|
-
if (f += h, t.add(h, "hour"), delete a[
|
|
806
|
-
`[%s] go to %j from %j with ${
|
|
805
|
+
if (f += h, t.add(h, "hour"), delete a[v], F == null || F.debug(
|
|
806
|
+
`[%s] go to %j from %j with ${y}nm, and cost ${h} hours`,
|
|
807
807
|
u.requestId,
|
|
808
808
|
{ lat: p.lat, lng: p.lng },
|
|
809
|
-
{ lat:
|
|
810
|
-
),
|
|
811
|
-
k = p, k.eta = t.utc().format(), k.distanceFromPrevious =
|
|
809
|
+
{ lat: w.lat, lng: w.lng, etd: w.etd }
|
|
810
|
+
), C += y, a.filter((I) => I).length <= 1) {
|
|
811
|
+
k = p, k.eta = t.utc().format(), k.distanceFromPrevious = y, k.distanceFromStart = Math.round((o + C) * 1e4) / 1e4, l.push(k), delete a[v + 1];
|
|
812
812
|
break;
|
|
813
813
|
}
|
|
814
814
|
} else {
|
|
815
815
|
h = i - f, t.add(h, "hour");
|
|
816
|
-
const I =
|
|
817
|
-
k =
|
|
816
|
+
const I = J.roundPrecision(w.speed * h, 5);
|
|
817
|
+
k = W.calculateCoordinate(c, e.bearing, I, "nauticalmiles", !p.gcToPrevious), k.eta = t.utc().format(), a[v] = k, F == null || F.debug(
|
|
818
818
|
`[%s] go to %j from %j with ${I}nm, and cost ${h} hours`,
|
|
819
819
|
u.requestId,
|
|
820
820
|
{ lat: k.lat, lng: k.lng },
|
|
821
821
|
{ lat: c.lat, lng: c.lng, etd: c.etd }
|
|
822
|
-
),
|
|
822
|
+
), C += I, k.distanceFromPrevious = Math.round(C * 1e4) / 1e4, k.distanceFromStart = Math.round((o + C) * 1e4) / 1e4;
|
|
823
823
|
break;
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
|
-
return { etd: t, from:
|
|
826
|
+
return { etd: t, from: w, to: k, next: a.filter((v) => v), wps: l, days: M };
|
|
827
827
|
}
|
|
828
828
|
/**
|
|
829
829
|
* 洋流影响因子
|
|
@@ -844,15 +844,15 @@ class O {
|
|
|
844
844
|
* @param wwc 气象要素
|
|
845
845
|
*/
|
|
846
846
|
static weatherFactor(e, t) {
|
|
847
|
-
var m, l,
|
|
847
|
+
var m, l, M, f, C, k, w;
|
|
848
848
|
F == null || F.debug("calculate weather factor via: %j", { ...e, ...t });
|
|
849
849
|
const n = O.blockCoefficient(e.displacement, e.lbp, e.breadthMoulded, e.draught), i = O.froudeNumber(e.speed, e.lbp), o = O.amendFactor(n, i, e.loadCondition);
|
|
850
850
|
let a = Math.abs(e.bearing % 360 - (((m = t == null ? void 0 : t.wind) == null ? void 0 : m.degree) % 360 || 0));
|
|
851
851
|
a = a > 180 ? 360 - a : a;
|
|
852
|
-
const s = O.directionFactor(a, (l = t == null ? void 0 : t.wind) == null ? void 0 : l.scale), d = O.vesselTagFactor(e.displacement, e.loadCondition, e.tag, (
|
|
852
|
+
const s = O.directionFactor(a, (l = t == null ? void 0 : t.wind) == null ? void 0 : l.scale), d = O.vesselTagFactor(e.displacement, e.loadCondition, e.tag, (M = t == null ? void 0 : t.wind) == null ? void 0 : M.scale);
|
|
853
853
|
let r = s * o * d / 100 * e.speed;
|
|
854
|
-
r = Math.round(r * 1.943844 * 1e4) / 1e4 * -1, e.tag === "tugs" && Math.abs(r) > 1 && (r = r / (Math.abs(Math.round(r)) + 1)), F == null || F.debug("wind wx factor = %d", r), a = Math.abs(e.bearing % 360 - (((
|
|
855
|
-
const u = O.waveHeightFactor(((
|
|
854
|
+
r = Math.round(r * 1.943844 * 1e4) / 1e4 * -1, e.tag === "tugs" && Math.abs(r) > 1 && (r = r / (Math.abs(Math.round(r)) + 1)), F == null || F.debug("wind wx factor = %d", r), a = Math.abs(e.bearing % 360 - (((C = (f = t == null ? void 0 : t.wave) == null ? void 0 : f.sig) == null ? void 0 : C.degree) % 360 || 0));
|
|
855
|
+
const u = O.waveHeightFactor(((w = (k = t == null ? void 0 : t.wave) == null ? void 0 : k.sig) == null ? void 0 : w.height) ?? 1, a);
|
|
856
856
|
return F == null || F.debug("wave wx factor = %d", u), r = r * 0.4 + u, F == null || F.debug("weather factor = %d", r), r = Math.abs(r) > 4 ? 4 * (Math.abs(r) / r) + Math.abs(r) / r * (Math.abs(r) - 4) * 0.1 : r, Math.round((r || 0) * 100) / 100;
|
|
857
857
|
}
|
|
858
858
|
/**
|
|
@@ -869,12 +869,12 @@ class O {
|
|
|
869
869
|
*/
|
|
870
870
|
static async analyseInstant(e, t, n, i, o, a = "", s = 0, d = !0, r = !1, u = {}) {
|
|
871
871
|
var z, U, Q, X, Z, $;
|
|
872
|
-
const m =
|
|
873
|
-
e.lng =
|
|
874
|
-
const { route: l, waypoints:
|
|
872
|
+
const m = g().valueOf();
|
|
873
|
+
e.lng = J.convertToStdLng(e.lng);
|
|
874
|
+
const { route: l, waypoints: M } = o.points, f = W.calculateSubRoute(e, l);
|
|
875
875
|
if (((z = f[0]) == null ? void 0 : z.length) <= 1)
|
|
876
876
|
return;
|
|
877
|
-
const { v0:
|
|
877
|
+
const { v0: C, label: k } = e.sog ? {
|
|
878
878
|
v0: e.sog,
|
|
879
879
|
label: "Other"
|
|
880
880
|
/* Instruct */
|
|
@@ -882,61 +882,63 @@ class O {
|
|
|
882
882
|
v0: i.speed,
|
|
883
883
|
label: "CP"
|
|
884
884
|
/* Cp */
|
|
885
|
-
},
|
|
886
|
-
|
|
885
|
+
}, w = O.assembleProperties(n, i.loadCondition, C, 0), v = M.length ? W.calculateSubWaypoints(e, M) : [];
|
|
886
|
+
v.forEach((q) => q.important = !0);
|
|
887
887
|
const c = {
|
|
888
888
|
from: { ...e },
|
|
889
889
|
route: f,
|
|
890
|
-
waypoints:
|
|
891
|
-
v0:
|
|
890
|
+
waypoints: v,
|
|
891
|
+
v0: C,
|
|
892
892
|
label: k
|
|
893
893
|
}, p = {
|
|
894
894
|
hours: [],
|
|
895
895
|
days: [],
|
|
896
896
|
wps: []
|
|
897
897
|
};
|
|
898
|
-
s || (
|
|
899
|
-
let
|
|
900
|
-
t =
|
|
898
|
+
s || (W.calculateRouteDistance(f) / i.speed <= 72 ? s = 3 : s = 6);
|
|
899
|
+
let y = W.simplifyRouteToCoordinates(f, v, 0), h = 0, I = 0, S = 0, D = 0;
|
|
900
|
+
t = g(t).utc();
|
|
901
901
|
const Y = t.clone();
|
|
902
|
-
for (;
|
|
903
|
-
const q = s - t.hour() % s, V = Math.ceil(t.clone().add(q, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4,
|
|
904
|
-
|
|
902
|
+
for (; y.length > 0; ) {
|
|
903
|
+
const q = s - t.hour() % s, V = Math.ceil(t.clone().add(q, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4, x = await O.speedLoseInHoursStep(
|
|
904
|
+
w,
|
|
905
905
|
t,
|
|
906
906
|
Y,
|
|
907
907
|
V,
|
|
908
908
|
h,
|
|
909
|
-
|
|
909
|
+
y,
|
|
910
910
|
a,
|
|
911
911
|
d,
|
|
912
912
|
r,
|
|
913
913
|
u
|
|
914
914
|
);
|
|
915
|
-
(U =
|
|
915
|
+
(U = x.from) != null && U.speed && (p.hours.push(x.from), p.wps.push(...x.wps), p.days.push(...x.days)), y = x == null ? void 0 : x.next, y.length || p.hours.push(x == null ? void 0 : x.to), h += Math.round((((Q = x == null ? void 0 : x.to) == null ? void 0 : Q.distanceFromPrevious) ?? 0) * 1e4) / 1e4;
|
|
916
916
|
}
|
|
917
|
-
const
|
|
918
|
-
for (let q = 0; q <
|
|
919
|
-
const V =
|
|
920
|
-
I += (
|
|
917
|
+
const E = p.hours;
|
|
918
|
+
for (let q = 0; q < E.length - 1; q++) {
|
|
919
|
+
const V = g(E[q + 1].eta).diff(E[q].etd, "hour", !0) || 1;
|
|
920
|
+
I += (E[q].wxFactor || 0) * V, S += (E[q].cFactor || 0) * V, D += V;
|
|
921
921
|
}
|
|
922
922
|
(X = p.wps) == null || X.forEach((q, V) => {
|
|
923
|
-
q.positionTime =
|
|
924
|
-
const
|
|
925
|
-
if (
|
|
926
|
-
const
|
|
927
|
-
q.avgSpd = Math.round(
|
|
923
|
+
q.positionTime = g.utc(q.etd || q.eta).unix();
|
|
924
|
+
const x = p.wps[V - 1];
|
|
925
|
+
if (x) {
|
|
926
|
+
const L = q.distanceFromStart - x.distanceFromStart, H = g(q.eta || q.etd).diff(g(x.etd || x.eta), "h", !0);
|
|
927
|
+
q.avgSpd = Math.round(L / H * 100) / 100;
|
|
928
|
+
const nt = W.calculateBearing(x, q);
|
|
929
|
+
x.bearing = nt;
|
|
928
930
|
}
|
|
929
|
-
}), p.wps = (Z = p.wps) == null ? void 0 : Z.reduce((q, V) => (q.some((
|
|
931
|
+
}), p.wps = (Z = p.wps) == null ? void 0 : Z.reduce((q, V) => (q.some((x) => Math.round(x.positionTime / 60) === Math.round(V.positionTime / 60)) || q.push(V), q), []), c.sample = p;
|
|
930
932
|
const P = p.hours.at(0), T = p.hours.at(-1);
|
|
931
|
-
c.distance = Math.round(T.distanceFromStart * 1e4) / 1e4, c.etd =
|
|
932
|
-
const { distanceInECA:
|
|
933
|
+
c.distance = Math.round(T.distanceFromStart * 1e4) / 1e4, c.etd = g(P.eta).utc().format(), c.eta = g(T.eta).utc().format(), c.wxFactor = Math.round(I / D * 1e4) / 1e4, c.cFactor = Math.round(S / D * 1e4) / 1e4, c.avgSpeed = Math.round(T.distanceFromStart / D * 1e4) / 1e4, c.totalHrs = Math.round(D * 1e4) / 1e4;
|
|
934
|
+
const { distanceInECA: N, hoursInECA: A, totalDgoConsInECA: R, eca: K } = await this.calculateECA(c, i, u), st = J.roundPrecision(i.fo / 24 * (D - A), 3), at = J.roundPrecision(i.dgo / 24 * D, 3);
|
|
933
935
|
c.extend = {
|
|
934
936
|
eca: K,
|
|
935
|
-
distanceInECA:
|
|
937
|
+
distanceInECA: N,
|
|
936
938
|
hoursInECA: A,
|
|
937
939
|
totalDgoConsInECA: R
|
|
938
940
|
}, c.totalFoCons = st, c.totalDgoCons = at;
|
|
939
|
-
const tt =
|
|
941
|
+
const tt = g().valueOf() - m, ot = (($ = p == null ? void 0 : p.hours) == null ? void 0 : $.length) || 1;
|
|
940
942
|
return F == null || F.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", u == null ? void 0 : u.requestId, tt, ot, Math.round(tt / ot * 1e3) / 1e3), c;
|
|
941
943
|
}
|
|
942
944
|
/**
|
|
@@ -954,9 +956,9 @@ class O {
|
|
|
954
956
|
*/
|
|
955
957
|
static async analyseInstantWithThreshed(e, t, n, i, o, a, s, d = "", r = 3, u = !0, m = !1, l = {}) {
|
|
956
958
|
var Q, X, Z, $, q, V;
|
|
957
|
-
const
|
|
958
|
-
e.lng =
|
|
959
|
-
const { v0: f, label:
|
|
959
|
+
const M = g().valueOf();
|
|
960
|
+
e.lng = J.convertToStdLng(e.lng);
|
|
961
|
+
const { v0: f, label: C } = e.sog ? {
|
|
960
962
|
v0: e.sog,
|
|
961
963
|
label: "Other"
|
|
962
964
|
/* Instruct */
|
|
@@ -964,63 +966,65 @@ class O {
|
|
|
964
966
|
v0: o.speed,
|
|
965
967
|
label: "CP"
|
|
966
968
|
/* Cp */
|
|
967
|
-
}, k = O.assembleProperties(i, o.loadCondition, f, 0),
|
|
968
|
-
if (((Q =
|
|
969
|
+
}, k = O.assembleProperties(i, o.loadCondition, f, 0), w = W.calculateSubRoute(e, a);
|
|
970
|
+
if (((Q = w[0]) == null ? void 0 : Q.length) <= 1)
|
|
969
971
|
return;
|
|
970
|
-
const
|
|
971
|
-
|
|
972
|
-
let c =
|
|
972
|
+
const v = s.length ? W.calculateSubWaypoints(e, s) : [];
|
|
973
|
+
v.forEach((x) => x.important = !0);
|
|
974
|
+
let c = W.simplifyRouteToCoordinates(w, v, 0), p = 0, y = 0, h = 0, I = 0;
|
|
973
975
|
const S = {
|
|
974
976
|
hours: [],
|
|
975
977
|
wps: [],
|
|
976
978
|
days: []
|
|
977
979
|
};
|
|
978
|
-
t =
|
|
980
|
+
t = g(t).utc();
|
|
979
981
|
const D = t.clone();
|
|
980
982
|
for (; c.length > 0; ) {
|
|
981
|
-
const
|
|
982
|
-
let
|
|
983
|
-
|
|
984
|
-
const H = await O.speedLoseInHoursStep(k, t, D,
|
|
985
|
-
if ((X = H.from) != null && X.speed && (S.hours.push(H.from), H != null && H.wps && S.wps.push(...H.wps), S.days.push(...H.days)), c = H == null ? void 0 : H.next, c.length || S.hours.push(H == null ? void 0 : H.to), p += Math.round((((Z = H == null ? void 0 : H.to) == null ? void 0 : Z.distanceFromPrevious) ?? 0) * 1e4) / 1e4, !
|
|
983
|
+
const x = r - t.hour() % r;
|
|
984
|
+
let L = Math.ceil(t.clone().add(x, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4;
|
|
985
|
+
L = t.clone().add(L, "h").isSameOrAfter(n) ? n.diff(t, "h", !0) * 1e4 / 1e4 : L;
|
|
986
|
+
const H = await O.speedLoseInHoursStep(k, t, D, L, p, c, d, u, m, l);
|
|
987
|
+
if ((X = H.from) != null && X.speed && (S.hours.push(H.from), H != null && H.wps && S.wps.push(...H.wps), S.days.push(...H.days)), c = H == null ? void 0 : H.next, c.length || S.hours.push(H == null ? void 0 : H.to), p += Math.round((((Z = H == null ? void 0 : H.to) == null ? void 0 : Z.distanceFromPrevious) ?? 0) * 1e4) / 1e4, !L)
|
|
986
988
|
break;
|
|
987
989
|
}
|
|
988
|
-
S.wps = ($ = S.wps) == null ? void 0 : $.reduce((
|
|
989
|
-
const H = S.wps[
|
|
990
|
+
S.wps = ($ = S.wps) == null ? void 0 : $.reduce((x, L) => (x.some((H) => Math.round(g(H.etd).unix() / 60) === Math.round(g(L.etd).unix() / 60)) || x.push(L), x), []), (q = S.wps) == null || q.forEach((x, L) => {
|
|
991
|
+
const H = S.wps[L - 1];
|
|
990
992
|
if (H) {
|
|
991
|
-
const
|
|
992
|
-
|
|
993
|
+
const nt = x.distanceFromStart - H.distanceFromStart, dt = g(x.eta || x.etd).diff(g(H.etd || H.eta), "h", !0);
|
|
994
|
+
x.avgSpd = Math.round(nt / dt * 100) / 100;
|
|
995
|
+
const ut = W.calculateBearing(H, x);
|
|
996
|
+
H.bearing = ut;
|
|
993
997
|
}
|
|
994
998
|
});
|
|
995
999
|
const Y = S.hours;
|
|
996
|
-
for (let
|
|
997
|
-
const
|
|
998
|
-
|
|
1000
|
+
for (let x = 0; x < Y.length - 1; x++) {
|
|
1001
|
+
const L = g(Y[x + 1].eta).diff(Y[x].etd, "hour", !0);
|
|
1002
|
+
y += Y[x].wxFactor * L, h += Y[x].cFactor * L, I += L;
|
|
999
1003
|
}
|
|
1000
|
-
const
|
|
1004
|
+
const E = S.hours.at(0), P = S.hours.at(-1), T = await W.calculateRangeRoute(E, P, w), N = await W.calculateRangeWaypoints(E, P, w, v), A = {
|
|
1001
1005
|
sample: S,
|
|
1002
1006
|
distance: Math.round(((P == null ? void 0 : P.distanceFromStart) || 0) * 1e4) / 1e4,
|
|
1003
1007
|
// 注意,可能会在first节点Drift,所有采用eta做为初始出发时间
|
|
1004
|
-
etd:
|
|
1005
|
-
eta:
|
|
1006
|
-
wxFactor: Math.round(
|
|
1008
|
+
etd: g(E.eta).utc().format(),
|
|
1009
|
+
eta: g(P == null ? void 0 : P.eta).utc().format(),
|
|
1010
|
+
wxFactor: Math.round(y / I * 1e4) / 1e4,
|
|
1007
1011
|
cFactor: Math.round(h / I * 1e4) / 1e4,
|
|
1008
1012
|
avgSpeed: Math.round(((P == null ? void 0 : P.distanceFromStart) || 0) / I * 1e4) / 1e4,
|
|
1009
1013
|
totalHrs: Math.round(I * 1e4) / 1e4,
|
|
1010
|
-
from:
|
|
1014
|
+
from: E,
|
|
1011
1015
|
to: P,
|
|
1012
1016
|
route: T,
|
|
1013
|
-
waypoints:
|
|
1017
|
+
waypoints: N,
|
|
1014
1018
|
v0: f,
|
|
1015
|
-
label:
|
|
1016
|
-
}, { distanceInECA: R, hoursInECA: K, totalDgoConsInECA: st, eca: at } = await this.calculateECA(A, o, l),
|
|
1019
|
+
label: C
|
|
1020
|
+
}, { distanceInECA: R, hoursInECA: K, totalDgoConsInECA: st, eca: at } = await this.calculateECA(A, o, l), rt = J.roundPrecision(o.fo / 24 * (I - K), 3), tt = J.roundPrecision(o.dgo / 24 * I, 3);
|
|
1017
1021
|
A.extend = {
|
|
1018
1022
|
eca: at,
|
|
1019
1023
|
distanceInECA: R,
|
|
1020
1024
|
hoursInECA: K,
|
|
1021
1025
|
totalDgoConsInECA: st
|
|
1022
|
-
}, A.totalDgoCons = tt, A.totalFoCons =
|
|
1023
|
-
const z =
|
|
1026
|
+
}, A.totalDgoCons = tt, A.totalFoCons = rt;
|
|
1027
|
+
const z = g().valueOf() - M, U = ((V = S == null ? void 0 : S.hours) == null ? void 0 : V.length) || 1;
|
|
1024
1028
|
return F == null || F.debug("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", l == null ? void 0 : l.requestId, z, U, Math.round(z / U * 1e3) / 1e3), A;
|
|
1025
1029
|
}
|
|
1026
1030
|
/**
|
|
@@ -1039,26 +1043,26 @@ class O {
|
|
|
1039
1043
|
* @param options
|
|
1040
1044
|
*/
|
|
1041
1045
|
static async analyseCost(e, t, n, i, o = {}) {
|
|
1042
|
-
var
|
|
1043
|
-
const a =
|
|
1046
|
+
var w, v;
|
|
1047
|
+
const a = g().valueOf(), s = [];
|
|
1044
1048
|
o.meteo2 = o.meteo2 || !0, e.speedStep = e.speedStep || 3, e.alterStep = e.alterStep ?? 1;
|
|
1045
|
-
const d =
|
|
1049
|
+
const d = W.calculateRouteDistance(i.route);
|
|
1046
1050
|
let r = 0;
|
|
1047
1051
|
n.forEach((c) => {
|
|
1048
1052
|
const p = Math.ceil(d / c.speed / 24);
|
|
1049
1053
|
r = r < p ? p : r;
|
|
1050
1054
|
}), r = r * 1.3;
|
|
1051
|
-
const u =
|
|
1055
|
+
const u = g.utc(e.etd).add(r ?? 14, "day");
|
|
1052
1056
|
let m = 1;
|
|
1053
1057
|
for (const c of n) {
|
|
1054
|
-
const p = JSON.parse(JSON.stringify(i.route)),
|
|
1058
|
+
const p = JSON.parse(JSON.stringify(i.route)), y = JSON.parse(JSON.stringify(i.waypoints)), h = await O.analyseInstantWithThreshed(
|
|
1055
1059
|
{ lat: e.lat, lng: e.lng },
|
|
1056
1060
|
e.etd,
|
|
1057
1061
|
u,
|
|
1058
1062
|
t,
|
|
1059
1063
|
c,
|
|
1060
1064
|
p,
|
|
1061
|
-
|
|
1065
|
+
y,
|
|
1062
1066
|
e.meteoVendor,
|
|
1063
1067
|
e.speedStep,
|
|
1064
1068
|
e.useMeteo,
|
|
@@ -1073,21 +1077,21 @@ class O {
|
|
|
1073
1077
|
})), m++;
|
|
1074
1078
|
}
|
|
1075
1079
|
s.sort((c, p) => c.cost.total - p.cost.total);
|
|
1076
|
-
const l = s.at(0),
|
|
1077
|
-
if (f.push({ combined: !1, speeds: [l], cost: (
|
|
1078
|
-
const c = l.cost.cp, p =
|
|
1080
|
+
const l = s.at(0), M = s.at(1), f = [];
|
|
1081
|
+
if (f.push({ combined: !1, speeds: [l], cost: (w = l.cost) == null ? void 0 : w.total }), M) {
|
|
1082
|
+
const c = l.cost.cp, p = M.cost.cp, y = g(l.eta), h = g(l.etd), I = y.diff(h, "days", !0);
|
|
1079
1083
|
let S = Math.ceil(I / 2);
|
|
1080
1084
|
S = S > 7 ? 7 : S < e.alterStep ? e.alterStep : S;
|
|
1081
|
-
let D = 2, Y = { combined: !1, speeds: [
|
|
1085
|
+
let D = 2, Y = { combined: !1, speeds: [M], cost: (v = M.cost) == null ? void 0 : v.total }, E;
|
|
1082
1086
|
for (; S >= e.alterStep; ) {
|
|
1083
1087
|
const P = await O.combinedAnalyse(e, t, u, [c, p], i, S, { ...o, level: D });
|
|
1084
|
-
if (Y.cost > P.cost ?
|
|
1088
|
+
if (Y.cost > P.cost ? E ? (E == null ? void 0 : E.cost) > P.cost && (E = P) : (E = Y, Y = P) : (!E || (E == null ? void 0 : E.cost) > P.cost) && (E = P), S <= e.alterStep)
|
|
1085
1089
|
break;
|
|
1086
1090
|
S = Math.ceil(S / 2), D += 1;
|
|
1087
1091
|
}
|
|
1088
|
-
f.push(Y),
|
|
1092
|
+
f.push(Y), E && f.push(E);
|
|
1089
1093
|
}
|
|
1090
|
-
const k =
|
|
1094
|
+
const k = g().valueOf() - a;
|
|
1091
1095
|
return F == null || F.info("[%s] analyse elapsed: %d ms", o == null ? void 0 : o.requestId, k), f.sort((c, p) => c.cost - p.cost);
|
|
1092
1096
|
}
|
|
1093
1097
|
/**
|
|
@@ -1102,9 +1106,9 @@ class O {
|
|
|
1102
1106
|
*/
|
|
1103
1107
|
static async combinedAnalyse(e, t, n, i, o, a, s = {}) {
|
|
1104
1108
|
s.counter = 1, F == null || F.info("[%s][L%d] analyse with alternate cp in every %d days", s.requestId, s.level, a);
|
|
1105
|
-
const d = await O.alternateAnalyse(e, t, n, i, 0, o, a, s), r = d.reduce((l,
|
|
1109
|
+
const d = await O.alternateAnalyse(e, t, n, i, 0, o, a, s), r = d.reduce((l, M) => l + M.cost.total, 0);
|
|
1106
1110
|
F == null || F.info("[%s][L%d] cost with cpa/cpb turn: %d", s.requestId, s.level, r);
|
|
1107
|
-
const u = await O.alternateAnalyse(e, t, n, i, 1, o, a, s), m = u.reduce((l,
|
|
1111
|
+
const u = await O.alternateAnalyse(e, t, n, i, 1, o, a, s), m = u.reduce((l, M) => l + M.cost.total, 0);
|
|
1108
1112
|
return F == null || F.info("[%s][L%d] cost with cpb/cpa turn: %d", s.requestId, s.level, m), r < m ? { combined: !0, cost: Math.round(r * 1e3) / 1e3, speeds: d, step: a } : { combined: !0, cost: Math.round(m * 1e3) / 1e3, speeds: u, step: a };
|
|
1109
1113
|
}
|
|
1110
1114
|
/**
|
|
@@ -1119,17 +1123,17 @@ class O {
|
|
|
1119
1123
|
* @param options
|
|
1120
1124
|
*/
|
|
1121
1125
|
static async alternateAnalyse(e, t, n, i, o, a, s, d = {}) {
|
|
1122
|
-
var l,
|
|
1123
|
-
let r =
|
|
1126
|
+
var l, M;
|
|
1127
|
+
let r = g.utc(e.etd);
|
|
1124
1128
|
const u = { lat: e.lat, lng: e.lng }, m = [];
|
|
1125
1129
|
for (; r.isBefore(n); ) {
|
|
1126
|
-
const f = r.clone().utc().add(s, "day"),
|
|
1130
|
+
const f = r.clone().utc().add(s, "day"), C = JSON.parse(JSON.stringify(a.route)), k = JSON.parse(JSON.stringify(a.waypoints)), w = i[o], v = await O.analyseInstantWithThreshed(
|
|
1127
1131
|
u,
|
|
1128
1132
|
r.utc().format(),
|
|
1129
1133
|
f,
|
|
1130
1134
|
t,
|
|
1131
|
-
|
|
1132
|
-
|
|
1135
|
+
w,
|
|
1136
|
+
C,
|
|
1133
1137
|
k,
|
|
1134
1138
|
e.meteoVendor,
|
|
1135
1139
|
e.speedStep,
|
|
@@ -1137,18 +1141,18 @@ class O {
|
|
|
1137
1141
|
e.useRouteParam,
|
|
1138
1142
|
d
|
|
1139
1143
|
);
|
|
1140
|
-
|
|
1144
|
+
v && (await O.calculateCost(v, w, e, d), F == null || F.info(
|
|
1141
1145
|
"[%s][L%d-%d] analyse from %s to %s cost: %j",
|
|
1142
1146
|
d.requestId,
|
|
1143
1147
|
d.level,
|
|
1144
1148
|
d.counter,
|
|
1145
1149
|
r.utc().format(),
|
|
1146
1150
|
f.utc().format(),
|
|
1147
|
-
{ cost:
|
|
1151
|
+
{ cost: v.cost.total, distance: v.distance, hours: v.totalHrs, cp: `${w.speed}/${w.fo}/${w.dgo}` }
|
|
1148
1152
|
)), d.counter = d.counter + 1;
|
|
1149
|
-
const c = (
|
|
1153
|
+
const c = (M = (l = v == null ? void 0 : v.sample) == null ? void 0 : l.hours) == null ? void 0 : M.at(-1);
|
|
1150
1154
|
if (c)
|
|
1151
|
-
u.lat = c.lat, u.lng = c.lng, r =
|
|
1155
|
+
u.lat = c.lat, u.lng = c.lng, r = g(c.eta), m.push(v), o = o ? 0 : 1;
|
|
1152
1156
|
else
|
|
1153
1157
|
break;
|
|
1154
1158
|
}
|
|
@@ -1179,17 +1183,17 @@ class O {
|
|
|
1179
1183
|
*/
|
|
1180
1184
|
static async calculateECA(e, t, n = {}) {
|
|
1181
1185
|
var d, r;
|
|
1182
|
-
const i = await
|
|
1186
|
+
const i = await W.intersectInECA(e.route);
|
|
1183
1187
|
let o = 0, a = 0, s = 0;
|
|
1184
1188
|
e.sample.wps.forEach((u) => {
|
|
1185
|
-
u.positionTime =
|
|
1189
|
+
u.positionTime = g.utc(u.etd || u.eta).unix();
|
|
1186
1190
|
});
|
|
1187
1191
|
for (const u of i) {
|
|
1188
1192
|
o += u.distance;
|
|
1189
|
-
const m = await
|
|
1190
|
-
u.in = m, u.out = l, u.totalHrs =
|
|
1193
|
+
const m = await W.deadReckoningTime((d = u.waypoints) == null ? void 0 : d.at(0), e.sample.wps), l = await W.deadReckoningTime((r = u.waypoints) == null ? void 0 : r.at(-1), e.sample.wps);
|
|
1194
|
+
u.in = m, u.out = l, u.totalHrs = J.roundPrecision((l.positionTime - m.positionTime) / 3600, 2), u.totalDgoCons = J.roundPrecision(t.fo / 24 * u.totalHrs, 3), a += u.totalHrs, s += u.totalDgoCons;
|
|
1191
1195
|
}
|
|
1192
|
-
return o =
|
|
1196
|
+
return o = J.roundPrecision(o, 3), a = J.roundPrecision(a, 3), s = J.roundPrecision(s, 3), {
|
|
1193
1197
|
distanceInECA: o,
|
|
1194
1198
|
hoursInECA: a,
|
|
1195
1199
|
totalDgoConsInECA: s,
|
|
@@ -1207,29 +1211,29 @@ class O {
|
|
|
1207
1211
|
hours: [],
|
|
1208
1212
|
wps: [],
|
|
1209
1213
|
days: []
|
|
1210
|
-
}, i = e.reduce((
|
|
1214
|
+
}, i = e.reduce((y, h) => y + h.distance, 0), o = e.reduce((y, h) => {
|
|
1211
1215
|
var I;
|
|
1212
|
-
return
|
|
1213
|
-
}, 0), a = e.reduce((
|
|
1216
|
+
return y + (((I = h.extend) == null ? void 0 : I.distanceInECA) || 0);
|
|
1217
|
+
}, 0), a = e.reduce((y, h) => y + h.totalHrs, 0), s = e.reduce((y, h) => {
|
|
1214
1218
|
var I;
|
|
1215
|
-
return
|
|
1216
|
-
}, 0), d = e.reduce((
|
|
1219
|
+
return y + (((I = h.extend) == null ? void 0 : I.hoursInECA) || 0);
|
|
1220
|
+
}, 0), d = e.reduce((y, h) => {
|
|
1217
1221
|
var I;
|
|
1218
|
-
return
|
|
1219
|
-
}, 0), r = e.reduce((
|
|
1220
|
-
let
|
|
1221
|
-
for (const
|
|
1222
|
-
|
|
1223
|
-
const h =
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
}), I.at(0).distanceFromPrevious =
|
|
1227
|
-
|
|
1228
|
-
}), S.at(0).distanceFromPrevious =
|
|
1229
|
-
|
|
1230
|
-
})), D.cp =
|
|
1231
|
-
const Y = [
|
|
1232
|
-
|
|
1222
|
+
return y + (((I = h.extend) == null ? void 0 : I.totalDgoConsInECA) || 0);
|
|
1223
|
+
}, 0), r = e.reduce((y, h) => y + h.wxFactor * h.totalHrs / a, 0), u = e.reduce((y, h) => y + h.cFactor * h.totalHrs / a, 0), m = e.reduce((y, h) => y + h.totalFoCons, 0), l = e.reduce((y, h) => y + h.totalDgoCons, 0), M = e.reduce((y, h) => y + h.cost.total, 0), f = e.reduce((y, h) => y + h.cost.hire, 0), C = e.reduce((y, h) => y + h.cost.bunker, 0), k = [], w = [];
|
|
1224
|
+
let v;
|
|
1225
|
+
for (const y of e) {
|
|
1226
|
+
w.push(...((c = y.extend) == null ? void 0 : c.eca) || []);
|
|
1227
|
+
const h = y.sample.hours, I = y.sample.wps, S = y.sample.days, D = h.at(0);
|
|
1228
|
+
v && (D.distanceFromPrevious = v.distanceFromPrevious, D.distanceFromStart = v.distanceFromStart, h.forEach((T, N) => {
|
|
1229
|
+
N && (T.distanceFromStart = T.distanceFromStart + v.distanceFromStart);
|
|
1230
|
+
}), I.at(0).distanceFromPrevious = v.distanceFromPrevious, I.at(0).distanceFromStart = v.distanceFromStart, I.forEach((T, N) => {
|
|
1231
|
+
N && (T.distanceFromStart = T.distanceFromStart + v.distanceFromStart);
|
|
1232
|
+
}), S.at(0).distanceFromPrevious = v.distanceFromPrevious, S.at(0).distanceFromStart = v.distanceFromStart, S.forEach((T, N) => {
|
|
1233
|
+
N && (T.distanceFromStart = T.distanceFromStart + v.distanceFromStart);
|
|
1234
|
+
})), D.cp = y.cost.cp;
|
|
1235
|
+
const Y = [y.etd, y.eta], E = k.findIndex((T) => T.id === D.cp.id);
|
|
1236
|
+
E === -1 ? (D.cp.segment = [Y], k.push(D.cp)) : k[E].segment.push(Y), h.forEach((T) => {
|
|
1233
1237
|
var A;
|
|
1234
1238
|
((A = n.hours) == null ? void 0 : A.findIndex((R) => R.eta === T.eta)) === -1 && n.hours.push(T);
|
|
1235
1239
|
}), I.forEach((T) => {
|
|
@@ -1240,15 +1244,17 @@ class O {
|
|
|
1240
1244
|
((A = n == null ? void 0 : n.days) == null ? void 0 : A.findIndex((R) => R.eta === T.eta)) === -1 && n.days.push(T);
|
|
1241
1245
|
});
|
|
1242
1246
|
const P = (p = n.wps) == null ? void 0 : p.findIndex((T) => T.eta === D.eta);
|
|
1243
|
-
P === -1 ? n.wps.push(D) : n.wps[P] = D,
|
|
1247
|
+
P === -1 ? n.wps.push(D) : n.wps[P] = D, v = h.at(-1);
|
|
1244
1248
|
}
|
|
1245
|
-
return n.wps.sort((
|
|
1246
|
-
|
|
1247
|
-
}), n.wps.forEach((
|
|
1249
|
+
return n.wps.sort((y, h) => {
|
|
1250
|
+
g(y.etd).unix() - g(h.etd).unix();
|
|
1251
|
+
}), n.wps.forEach((y, h) => {
|
|
1248
1252
|
const I = n.wps[h - 1];
|
|
1249
1253
|
if (I) {
|
|
1250
|
-
const S =
|
|
1251
|
-
|
|
1254
|
+
const S = y.distanceFromStart - (I.distanceFromStart || 0), D = g(y.eta || y.etd).diff(g(I.etd || I.eta), "hour", !0), Y = Math.round(S / D * 100) / 100;
|
|
1255
|
+
y.avgSpd = Y;
|
|
1256
|
+
const E = W.calculateBearing(I, y);
|
|
1257
|
+
I.bearing = E;
|
|
1252
1258
|
}
|
|
1253
1259
|
}), {
|
|
1254
1260
|
sample: n,
|
|
@@ -1266,13 +1272,13 @@ class O {
|
|
|
1266
1272
|
totalFoCons: Math.round(m * 1e3) / 1e3,
|
|
1267
1273
|
totalDgoCons: Math.round(l * 1e3) / 1e3,
|
|
1268
1274
|
cost: {
|
|
1269
|
-
total: Math.round(
|
|
1275
|
+
total: Math.round(M * 1e3) / 1e3,
|
|
1270
1276
|
hire: Math.round(f * 1e3) / 1e3,
|
|
1271
|
-
bunker: Math.round(
|
|
1277
|
+
bunker: Math.round(C * 1e3) / 1e3
|
|
1272
1278
|
},
|
|
1273
1279
|
extend: {
|
|
1274
1280
|
cps: k,
|
|
1275
|
-
eca:
|
|
1281
|
+
eca: w,
|
|
1276
1282
|
distanceInECA: Math.round(o * 1e4) / 1e4,
|
|
1277
1283
|
hoursInECA: Math.round(s * 1e3) / 1e3,
|
|
1278
1284
|
totalDgoConsInECA: Math.round(d * 1e3) / 1e3,
|
|
@@ -1283,15 +1289,15 @@ class O {
|
|
|
1283
1289
|
}
|
|
1284
1290
|
export {
|
|
1285
1291
|
et as AISImpl,
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1292
|
+
Mt as AlertHelper,
|
|
1293
|
+
yt as AlertLevel,
|
|
1294
|
+
Et as HifleetImpl,
|
|
1295
|
+
pt as LoadCondition,
|
|
1296
|
+
Tt as MyShipImpl,
|
|
1297
|
+
jt as MyVesselImpl,
|
|
1298
|
+
Nt as ShipxyImpl,
|
|
1293
1299
|
O as SpeedHelper,
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1300
|
+
vt as SpeedLabel,
|
|
1301
|
+
bt as VesselTag,
|
|
1302
|
+
Dt as alertHelper
|
|
1297
1303
|
};
|