@idm-plugin/vessel 1.6.8 → 1.7.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 +337 -331
- package/dist/index.umd.cjs +1 -1
- package/dist/speed/src/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var st = Object.defineProperty;
|
|
2
|
-
var at = (
|
|
3
|
-
var Z = (
|
|
2
|
+
var at = (j, e, t) => e in j ? st(j, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : j[e] = t;
|
|
3
|
+
var Z = (j, e, t) => (at(j, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
4
|
import R from "got";
|
|
5
5
|
import Q from "@log4js-node/log4js-api";
|
|
6
|
-
import
|
|
6
|
+
import p from "moment";
|
|
7
7
|
import { LngLatHelper as z, LaneHelper as B } from "@idm-plugin/geo";
|
|
8
8
|
import { MeteoHelper2 as ot, MeteoHelper as nt } from "@idm-plugin/meteo2";
|
|
9
9
|
import { Meteo2Assist as tt } from "@idm-plugin/meteo";
|
|
10
|
-
let
|
|
10
|
+
let b;
|
|
11
11
|
try {
|
|
12
|
-
|
|
12
|
+
b = Q.getLogger("vessel");
|
|
13
13
|
} catch {
|
|
14
14
|
} finally {
|
|
15
15
|
}
|
|
@@ -70,32 +70,32 @@ class vt extends U {
|
|
|
70
70
|
grant_type: "client_credentials"
|
|
71
71
|
}
|
|
72
72
|
}, a = await R.post(o, i).json();
|
|
73
|
-
|
|
73
|
+
b == null || b.info("[%s] fetch access token from: %s - %j", t.requestId, o, a), a.error || (this.token = {
|
|
74
74
|
accessToken: a.access_token,
|
|
75
75
|
tokenType: a.token_type,
|
|
76
76
|
expiresIn: a.expires_in,
|
|
77
77
|
scope: a.scope,
|
|
78
78
|
jti: a.jti,
|
|
79
|
-
issuedAt:
|
|
79
|
+
issuedAt: p().utc().format()
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
async realTimePosition(t, o = {}) {
|
|
83
|
-
var
|
|
84
|
-
(!this.token ||
|
|
83
|
+
var u, y, h;
|
|
84
|
+
(!this.token || p().diff(p(this.token.issuedAt), "seconds") > ((u = this.token) == null ? void 0 : u.expiresIn) - 300) && await this.authToken(o);
|
|
85
85
|
const i = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit", a = {
|
|
86
86
|
headers: {
|
|
87
|
-
Authorization: `${(y = this.token) == null ? void 0 : y.tokenType} ${(
|
|
87
|
+
Authorization: `${(y = this.token) == null ? void 0 : y.tokenType} ${(h = this.token) == null ? void 0 : h.accessToken}`
|
|
88
88
|
},
|
|
89
89
|
searchParams: { mmsi: t }
|
|
90
90
|
};
|
|
91
|
-
|
|
91
|
+
b == null || b.info("[%s] fetch realtime position from: %s - %j", o.requestId, i, a);
|
|
92
92
|
const n = await R.get(i, a).json();
|
|
93
93
|
if (n.code)
|
|
94
|
-
return
|
|
94
|
+
return b == null || b.warn("[%s] fetch realtime position failed: %j", o.requestId, i, { message: n.message, status: n.status, code: n.code }), n;
|
|
95
95
|
const s = n.data;
|
|
96
96
|
for (const f in s)
|
|
97
97
|
!isNaN(s[f]) && Number(s[f]) !== 1 / 0 && (s[f] = Number(s[f]));
|
|
98
|
-
const d =
|
|
98
|
+
const d = p(`${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 vt extends U {
|
|
|
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) ? p.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 vt extends U {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
async trajectory(t, o, i, a, n = !0, s = {}) {
|
|
125
|
-
(!this.token ||
|
|
126
|
-
const d = await this.realTimePosition(t, s), r =
|
|
127
|
-
for (;
|
|
125
|
+
(!this.token || p().diff(p(this.token.issuedAt), "seconds") > this.token.expiresIn - 300) && await this.authToken(s);
|
|
126
|
+
const d = await this.realTimePosition(t, s), r = p(o), u = p(i), y = [];
|
|
127
|
+
for (; u.diff(r, "day", !0) > 30; )
|
|
128
128
|
await this.trajectoryIn30Day(t, r, r.clone().add(30, "day"), d, a, y, s), r.add(30, "day");
|
|
129
|
-
return await this.trajectoryIn30Day(t, r,
|
|
129
|
+
return await this.trajectoryIn30Day(t, r, u, d, a, y, s), y;
|
|
130
130
|
}
|
|
131
131
|
async trajectoryIn30Day(t, o, i, a, n, s, d = {}) {
|
|
132
|
-
var
|
|
133
|
-
const r = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/track",
|
|
132
|
+
var l, m, M, g, I;
|
|
133
|
+
const r = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/track", u = {
|
|
134
134
|
headers: {
|
|
135
|
-
Authorization: `${(
|
|
135
|
+
Authorization: `${(l = this.token) == null ? void 0 : l.tokenType} ${(m = this.token) == null ? void 0 : m.accessToken}`
|
|
136
136
|
},
|
|
137
137
|
json: {
|
|
138
138
|
mmsi: t,
|
|
@@ -140,16 +140,16 @@ class vt extends U {
|
|
|
140
140
|
endTime: i.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
|
|
144
|
-
const y = await R.post(r,
|
|
143
|
+
b == null || b.info("[%s] fetch trajectory from: %s - %j", d.requestId, r, u);
|
|
144
|
+
const y = await R.post(r, u).json();
|
|
145
145
|
if (y.code)
|
|
146
|
-
return
|
|
147
|
-
let
|
|
148
|
-
const f =
|
|
149
|
-
return (
|
|
150
|
-
for (const
|
|
151
|
-
!isNaN(c[
|
|
152
|
-
const
|
|
146
|
+
return b == null || b.warn("[%s] fetch trajectory failed: %j", d.requestId, r, { message: y.message, status: y.status, code: y.code }), y;
|
|
147
|
+
let h = -1;
|
|
148
|
+
const f = p(`${(g = (M = y.data) == null ? void 0 : M[0]) == null ? void 0 : g.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
149
|
+
return (I = y.data) == null || I.forEach((c) => {
|
|
150
|
+
for (const T in c)
|
|
151
|
+
!isNaN(c[T]) && Number(c[T]) !== 1 / 0 && (c[T] = Number(c[T]));
|
|
152
|
+
const w = p(`${c.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), N = c.status, { labelCn: v, labelEn: S } = this.parseStatus(N), Y = {
|
|
153
153
|
mmsi: c.mmsi,
|
|
154
154
|
imo: a == null ? void 0 : a.imo,
|
|
155
155
|
lat: c.lat,
|
|
@@ -159,16 +159,16 @@ class vt extends U {
|
|
|
159
159
|
hdg: c.hdg,
|
|
160
160
|
draught: c.draught,
|
|
161
161
|
status: N,
|
|
162
|
-
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(c.eta) ?
|
|
162
|
+
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(c.eta) ? p(`${c.eta} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00").utc().format() : void 0,
|
|
163
163
|
destination: c.dest,
|
|
164
|
-
positionTime:
|
|
165
|
-
labelCn:
|
|
164
|
+
positionTime: w.unix(),
|
|
165
|
+
labelCn: v,
|
|
166
166
|
labelEn: S,
|
|
167
167
|
method: "trajectory",
|
|
168
168
|
vendor: "myVessel",
|
|
169
|
-
utc:
|
|
170
|
-
},
|
|
171
|
-
|
|
169
|
+
utc: w.utc().format()
|
|
170
|
+
}, F = Math.floor(w.diff(f, "minute", !0) / (n || 1));
|
|
171
|
+
F !== h && (h = F, s.push(Y));
|
|
172
172
|
}), s;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
@@ -185,14 +185,14 @@ class wt extends U {
|
|
|
185
185
|
usertoken: this.token
|
|
186
186
|
}
|
|
187
187
|
}, n = await R.post(i, a).json();
|
|
188
|
-
|
|
188
|
+
b == null || b.info("[%s] fetch realtime position from: %s - %j", o.requestId, i, a);
|
|
189
189
|
const s = n == null ? void 0 : n.list;
|
|
190
190
|
if (!s)
|
|
191
|
-
return
|
|
191
|
+
return b == null || b.warn("[%s] fetch realtime position failed: %j", o.requestId, i, n), n;
|
|
192
192
|
for (const f in s)
|
|
193
193
|
!isNaN(s[f]) && Number(s[f]) !== 1 / 0 && (s[f] = Number(s[f]));
|
|
194
194
|
s.status = s.sp > 3 ? 0 : 1;
|
|
195
|
-
const d = s.status, { labelCn: r, labelEn:
|
|
195
|
+
const d = s.status, { labelCn: r, labelEn: u } = this.parseStatus(d), y = p(`${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,13 +207,13 @@ class wt extends U {
|
|
|
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) ? p.utc(s.eta).format() : void 0,
|
|
211
211
|
destination: s.destination,
|
|
212
212
|
positionTime: y.unix(),
|
|
213
213
|
utc: y.utc().format(),
|
|
214
214
|
status: d,
|
|
215
215
|
labelCn: r,
|
|
216
|
-
labelEn:
|
|
216
|
+
labelEn: u,
|
|
217
217
|
method: "position",
|
|
218
218
|
vendor: "hifleet"
|
|
219
219
|
};
|
|
@@ -231,7 +231,7 @@ class wt extends U {
|
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
233
|
let n = await R.post(i, a).json();
|
|
234
|
-
|
|
234
|
+
b == null || b.info("[%s] fetch vessel props from: %s - %j", o.requestId, i, a), n instanceof Array && (n = n[0]);
|
|
235
235
|
for (const d in n)
|
|
236
236
|
!isNaN(n[d]) && Number(n[d]) !== 1 / 0 && (n[d] = Number(n[d]));
|
|
237
237
|
const s = {
|
|
@@ -244,7 +244,7 @@ class wt extends U {
|
|
|
244
244
|
draught: n.dr,
|
|
245
245
|
type: n.t
|
|
246
246
|
};
|
|
247
|
-
return i = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", n = await R.post(i, a).json(),
|
|
247
|
+
return i = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", n = await R.post(i, a).json(), b == null || b.info("[%s] search vessel dead weight from: %s - %j", o.requestId, i, a), n instanceof Array && (n = n[0]), n && (s.deadweight = Number(n.dwt)), s;
|
|
248
248
|
}
|
|
249
249
|
async suggest(t, o = {}) {
|
|
250
250
|
const i = "https://www.hifleet.com/hifleetapi/getShipSuggest.do", a = {
|
|
@@ -257,7 +257,7 @@ class wt extends U {
|
|
|
257
257
|
Host: "www.hifleet.com"
|
|
258
258
|
}
|
|
259
259
|
}, n = await R.post(i, a).json();
|
|
260
|
-
|
|
260
|
+
b == null || b.info("[%s] suggest vessel props from: %s - %j", o.requestId, i, a);
|
|
261
261
|
const s = [];
|
|
262
262
|
for (const d of n)
|
|
263
263
|
s.push({
|
|
@@ -270,54 +270,54 @@ class wt extends U {
|
|
|
270
270
|
return s.sort((d, r) => r.score - d.score), s;
|
|
271
271
|
}
|
|
272
272
|
async trajectory(t, o, i, a, n = !0, s = {}) {
|
|
273
|
-
var c,
|
|
273
|
+
var c, w, N;
|
|
274
274
|
const d = await this.realTimePosition(t, s);
|
|
275
|
-
let r =
|
|
276
|
-
const
|
|
275
|
+
let r = p(o);
|
|
276
|
+
const u = p(i), y = p();
|
|
277
277
|
if (n) {
|
|
278
|
-
let
|
|
279
|
-
|
|
278
|
+
let v = u.diff(r, "d", !0);
|
|
279
|
+
v < 0 ? r = u.clone().subtract(40, "d") : v < 30 ? r.subtract(10, "d") : v < 60 ? r.subtract(5, "d") : r = u.clone().subtract(80, "d"), v = y.diff(u, "d", !0), u.add(v > 10 ? 240 : v * 24, "h");
|
|
280
280
|
}
|
|
281
|
-
const
|
|
281
|
+
const h = {
|
|
282
282
|
searchParams: {
|
|
283
|
-
endtime:
|
|
283
|
+
endtime: u.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),
|
|
284
284
|
starttime: r.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),
|
|
285
285
|
mmsi: t,
|
|
286
286
|
usertoken: this.token
|
|
287
287
|
}
|
|
288
|
-
}, f = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token",
|
|
289
|
-
|
|
290
|
-
let
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
let
|
|
294
|
-
const
|
|
295
|
-
for (const
|
|
296
|
-
for (const
|
|
297
|
-
!isNaN(
|
|
298
|
-
const S =
|
|
299
|
-
|
|
300
|
-
const { labelEn:
|
|
301
|
-
mmsi:
|
|
302
|
-
name:
|
|
288
|
+
}, f = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token", l = await R.get(f, h).json();
|
|
289
|
+
b == null || b.info("[%s] fetch trajectory from: %s - %j", s.requestId, f, h);
|
|
290
|
+
let m;
|
|
291
|
+
l && (m = ((w = (c = l.ships) == null ? void 0 : c.offors) == null ? void 0 : w.ship) || [], m.length || b == null || b.warn("[%s] fetch trajectory failed: %j", s.requestId, l));
|
|
292
|
+
const M = [];
|
|
293
|
+
let g = -1;
|
|
294
|
+
const I = p(`${(N = m == null ? void 0 : m[0]) == null ? void 0 : N.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
295
|
+
for (const v of m) {
|
|
296
|
+
for (const H in v)
|
|
297
|
+
!isNaN(v[H]) && Number(v[H]) !== 1 / 0 && (v[H] = Number(v[H]));
|
|
298
|
+
const S = p(`${v.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
299
|
+
v.status = v.sp > 4 ? 0 : 1;
|
|
300
|
+
const { labelEn: Y, labelCn: F } = this.parseStatus(v.status), T = {
|
|
301
|
+
mmsi: v.m,
|
|
302
|
+
name: v.n,
|
|
303
303
|
imo: d == null ? void 0 : d.imo,
|
|
304
|
-
lat:
|
|
305
|
-
lng:
|
|
306
|
-
draught:
|
|
307
|
-
sog:
|
|
308
|
-
cog:
|
|
309
|
-
hdg:
|
|
304
|
+
lat: v.la,
|
|
305
|
+
lng: v.lo,
|
|
306
|
+
draught: v.draught,
|
|
307
|
+
sog: v.sp,
|
|
308
|
+
cog: v.co,
|
|
309
|
+
hdg: v.hdg,
|
|
310
310
|
positionTime: S.unix(),
|
|
311
311
|
utc: S.utc().format(),
|
|
312
|
-
status:
|
|
313
|
-
labelCn:
|
|
314
|
-
labelEn:
|
|
312
|
+
status: v.status,
|
|
313
|
+
labelCn: F,
|
|
314
|
+
labelEn: Y,
|
|
315
315
|
method: "trajectory",
|
|
316
316
|
vendor: "hifleet"
|
|
317
|
-
},
|
|
318
|
-
|
|
317
|
+
}, D = Math.floor(S.diff(I, "minute", !0) / (a || 1));
|
|
318
|
+
D !== g && (g = D, M.push(T));
|
|
319
319
|
}
|
|
320
|
-
return
|
|
320
|
+
return M;
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
class pt extends U {
|
|
@@ -334,12 +334,12 @@ class pt extends U {
|
|
|
334
334
|
enc: 1
|
|
335
335
|
}
|
|
336
336
|
}, a = "https://api.shipxy.com/apicall/GetSingleShip", n = await R.get(a, i).json();
|
|
337
|
-
if (
|
|
337
|
+
if (b == null || b.info("[%s] fetch realtime position from: %s - %j", o.requestId, a, i), (n == null ? void 0 : n.status) !== 0)
|
|
338
338
|
return n;
|
|
339
339
|
const s = n.data[0];
|
|
340
|
-
for (const
|
|
341
|
-
!isNaN(s[
|
|
342
|
-
const { labelCn: d, labelEn: r } = await this.parseStatus(s.navistat),
|
|
340
|
+
for (const h in s)
|
|
341
|
+
!isNaN(s[h]) && Number(s[h]) !== 1 / 0 && (s[h] = Number(s[h]));
|
|
342
|
+
const { labelCn: d, labelEn: r } = await this.parseStatus(s.navistat), u = p.unix(s.lasttime);
|
|
343
343
|
return {
|
|
344
344
|
mmsi: s.ShipID,
|
|
345
345
|
name: s.name,
|
|
@@ -355,7 +355,7 @@ class pt extends U {
|
|
|
355
355
|
hdg: Math.round(s.hdg / 100 * 100) / 100,
|
|
356
356
|
rot: Math.round(s.rot / 100 * 100) / 100,
|
|
357
357
|
positionTime: s.lasttime,
|
|
358
|
-
utc:
|
|
358
|
+
utc: u.utc().format(),
|
|
359
359
|
status: s.navistat,
|
|
360
360
|
labelEn: r,
|
|
361
361
|
labelCn: d,
|
|
@@ -364,37 +364,37 @@ class pt extends U {
|
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
async trajectory(t, o, i, a, n = !0, s = {}) {
|
|
367
|
-
var
|
|
368
|
-
const d = await this.realTimePosition(t, s), r =
|
|
367
|
+
var I;
|
|
368
|
+
const d = await this.realTimePosition(t, s), r = p(o), u = p(i), y = "https://api.shipxy.com/apicall/GetShipTrack", h = {
|
|
369
369
|
searchParams: {
|
|
370
370
|
id: t,
|
|
371
371
|
k: this.token,
|
|
372
372
|
enc: 1,
|
|
373
373
|
cut: 0,
|
|
374
374
|
btm: r.unix(),
|
|
375
|
-
etm:
|
|
375
|
+
etm: u.unix()
|
|
376
376
|
}
|
|
377
|
-
}, f = await R.get(y,
|
|
378
|
-
if (
|
|
377
|
+
}, f = await R.get(y, h).json();
|
|
378
|
+
if (b == null || b.info("[%s] fetch trajectory from: %s - %j", s.requestId, y, h), (f == null ? void 0 : f.status) !== 0)
|
|
379
379
|
return f;
|
|
380
|
-
const
|
|
381
|
-
let
|
|
382
|
-
for (const c of
|
|
383
|
-
const
|
|
380
|
+
const l = f == null ? void 0 : f.points, m = [], M = p.unix((I = l[0]) == null ? void 0 : I.utc);
|
|
381
|
+
let g = -1;
|
|
382
|
+
for (const c of l) {
|
|
383
|
+
const w = p.unix(c.utc), N = {
|
|
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,
|
|
387
387
|
cog: Math.round(c.cog / 100 * 100) / 100,
|
|
388
388
|
lat: Math.round(c.lat / 1e6 * 1e5) / 1e5,
|
|
389
389
|
lng: Math.round(c.lon / 1e6 * 1e5) / 1e5,
|
|
390
|
-
positionTime:
|
|
391
|
-
utc:
|
|
390
|
+
positionTime: w.unix(),
|
|
391
|
+
utc: w.utc().format(),
|
|
392
392
|
method: "trajectory",
|
|
393
393
|
vendor: "shipxy"
|
|
394
|
-
},
|
|
395
|
-
|
|
394
|
+
}, v = Math.floor(w.diff(M, "minute", !0) / (a || 1));
|
|
395
|
+
v !== g && (g = v, m.push(N));
|
|
396
396
|
}
|
|
397
|
-
return
|
|
397
|
+
return m;
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
400
|
class It extends U {
|
|
@@ -412,7 +412,7 @@ class It extends U {
|
|
|
412
412
|
mmsiList: t
|
|
413
413
|
}
|
|
414
414
|
}, a = "https://api3.myships.com/sp/ships/getShipIdByMMSI", n = await R.post(a, i).json();
|
|
415
|
-
return
|
|
415
|
+
return b == null || b.info("[%s] fetch ship id from: %s - %j", o.requestId, a, i), n.code !== "0" ? n : n.data[0].shipId;
|
|
416
416
|
}
|
|
417
417
|
async getShipInfo(t, o = {}) {
|
|
418
418
|
const i = {
|
|
@@ -423,11 +423,11 @@ class It extends U {
|
|
|
423
423
|
shipId: t
|
|
424
424
|
}
|
|
425
425
|
}, a = "https://api3.myships.com/sp/ships/aissta", n = await R.post(a, i).json();
|
|
426
|
-
if (
|
|
426
|
+
if (b == null || b.info("[%s] fetch ship info from: %s - %j", o.requestId, a, i), n.code !== "0")
|
|
427
427
|
return n;
|
|
428
428
|
const s = n.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", o.requestId, t, s.imo, d)), {
|
|
431
431
|
mmsi: s.mmsi,
|
|
432
432
|
name: s.shipnameEn,
|
|
433
433
|
imo: d,
|
|
@@ -446,11 +446,11 @@ class It extends U {
|
|
|
446
446
|
shipId: i
|
|
447
447
|
}
|
|
448
448
|
}, s = "https://api3.myships.com/sp/ships/position/latest", d = await R.post(s, n).json();
|
|
449
|
-
|
|
449
|
+
b == null || b.info("[%s] fetch realtime position from: %s - %j", o.requestId, s, n);
|
|
450
450
|
const r = d.data[0];
|
|
451
|
-
for (const
|
|
452
|
-
!isNaN(r[
|
|
453
|
-
const { labelCn:
|
|
451
|
+
for (const l in r)
|
|
452
|
+
!isNaN(r[l]) && Number(r[l]) !== 1 / 0 && (r[l] = Number(r[l]));
|
|
453
|
+
const { labelCn: u, labelEn: y } = await this.parseStatus(r.aisNavStatus), h = p.unix(r.posTime);
|
|
454
454
|
return {
|
|
455
455
|
...a,
|
|
456
456
|
mmsi: t,
|
|
@@ -461,23 +461,23 @@ class It extends U {
|
|
|
461
461
|
hdg: Math.round(r.heading * 100) / 100,
|
|
462
462
|
rot: Math.round(r.rot * 100) / 100,
|
|
463
463
|
positionTime: r.posTime,
|
|
464
|
-
utc:
|
|
464
|
+
utc: h.utc().format(),
|
|
465
465
|
status: r.aisNavStatus,
|
|
466
466
|
labelEn: y,
|
|
467
|
-
labelCn:
|
|
467
|
+
labelCn: u,
|
|
468
468
|
method: "position",
|
|
469
469
|
vendor: "myship"
|
|
470
470
|
};
|
|
471
471
|
}
|
|
472
472
|
async trajectory(t, o, i, a, n = !0, s = {}) {
|
|
473
|
-
const d =
|
|
473
|
+
const d = p(o), r = p(i), u = await this.getShipId(t), y = await this.getShipInfo(u), h = [];
|
|
474
474
|
for (; r.diff(d, "day", !0) > 30; )
|
|
475
|
-
await this.trajectoryIn30Day(
|
|
476
|
-
return await this.trajectoryIn30Day(
|
|
475
|
+
await this.trajectoryIn30Day(u, d.unix(), d.add(30, "day").unix(), y, t, a, h);
|
|
476
|
+
return await this.trajectoryIn30Day(u, d.unix(), r.unix(), y, t, a, h), h;
|
|
477
477
|
}
|
|
478
478
|
async trajectoryIn30Day(t, o, i, a, n, s, d, r = {}) {
|
|
479
|
-
var
|
|
480
|
-
const
|
|
479
|
+
var M;
|
|
480
|
+
const u = {
|
|
481
481
|
headers: {
|
|
482
482
|
appKey: this.token
|
|
483
483
|
},
|
|
@@ -486,30 +486,30 @@ class It extends U {
|
|
|
486
486
|
startTime: o,
|
|
487
487
|
endTime: i
|
|
488
488
|
}
|
|
489
|
-
}, y = "https://api3.myships.com/sp/ships/position/history",
|
|
490
|
-
if (
|
|
491
|
-
return
|
|
492
|
-
const f =
|
|
493
|
-
for (const
|
|
494
|
-
!isNaN(f[
|
|
495
|
-
const
|
|
496
|
-
let
|
|
497
|
-
for (const
|
|
498
|
-
const
|
|
489
|
+
}, y = "https://api3.myships.com/sp/ships/position/history", h = await R.post(y, u).json();
|
|
490
|
+
if (b == null || b.info("[%s] fetch trajectory from: %s - %j", r.requestId, y, u), h.code !== "0")
|
|
491
|
+
return b == null || b.warn("[%s] invoke myship trajectory failed: %j", r.requestId, h), h;
|
|
492
|
+
const f = h.data;
|
|
493
|
+
for (const g in f)
|
|
494
|
+
!isNaN(f[g]) && Number(f[g]) !== 1 / 0 && (f[g] = Number(f[g]));
|
|
495
|
+
const l = p.unix((M = f[0]) == null ? void 0 : M.posTime);
|
|
496
|
+
let m = -1;
|
|
497
|
+
for (const g of f) {
|
|
498
|
+
const I = p.unix(g.posTime), c = {
|
|
499
499
|
imo: a == null ? void 0 : a.imo,
|
|
500
500
|
mmsi: n,
|
|
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(g.lat / 1e4 / 60 * 1e5) / 1e5,
|
|
502
|
+
lng: Math.round(g.lon / 1e4 / 60 * 1e5) / 1e5,
|
|
503
|
+
sog: Math.round(g.sog / 10 * 100) / 100,
|
|
504
|
+
cog: Math.round(g.cog / 10 * 100) / 100,
|
|
505
|
+
hdg: Math.round(g.heading * 100) / 100,
|
|
506
|
+
rot: Math.round(g.rot * 100) / 100,
|
|
507
|
+
positionTime: I.unix(),
|
|
508
|
+
utc: I.utc().format(),
|
|
509
509
|
method: "trajectory",
|
|
510
510
|
vendor: "myship"
|
|
511
|
-
},
|
|
512
|
-
|
|
511
|
+
}, w = Math.floor(I.diff(l, "minute", !0) / (s || 1));
|
|
512
|
+
w !== m && (m = w, d.push(c));
|
|
513
513
|
}
|
|
514
514
|
return d;
|
|
515
515
|
}
|
|
@@ -520,7 +520,7 @@ try {
|
|
|
520
520
|
} catch {
|
|
521
521
|
} finally {
|
|
522
522
|
}
|
|
523
|
-
var it = /* @__PURE__ */ ((
|
|
523
|
+
var it = /* @__PURE__ */ ((j) => (j.NOTICE = "NOTICE", j.WARN = "WARN", j.HEAVY = "HEAVY", j.SEVERE = "SEVERE", j.ERROR = "ERROR", j.FATAL = "FATAL", j))(it || {});
|
|
524
524
|
class rt {
|
|
525
525
|
/**
|
|
526
526
|
* 解析告警规则, 多规则场景
|
|
@@ -537,14 +537,14 @@ class rt {
|
|
|
537
537
|
if (!a)
|
|
538
538
|
return;
|
|
539
539
|
const n = {};
|
|
540
|
-
for (let
|
|
541
|
-
const y = (r = (d = a[
|
|
542
|
-
if (
|
|
540
|
+
for (let u = 0; u < (a == null ? void 0 : a.length); u++) {
|
|
541
|
+
const y = (r = (d = a[u].match(o)) == null ? void 0 : d[0]) == null ? void 0 : r.split("],");
|
|
542
|
+
if (u === 0 && !y)
|
|
543
543
|
n.scope = a[0];
|
|
544
544
|
else if (y)
|
|
545
|
-
for (let
|
|
546
|
-
const
|
|
547
|
-
|
|
545
|
+
for (let h = 0, f = y.length; h < f; h++) {
|
|
546
|
+
const l = this.parseRule(y[h]);
|
|
547
|
+
l && (n[l.level] ? l.key ? n[l.level][l == null ? void 0 : l.key] = l : n[l.level] = l : l.key ? n[l.level] = { [l == null ? void 0 : l.key]: l } : n[l.level] = l);
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
550
|
return n;
|
|
@@ -575,26 +575,26 @@ class rt {
|
|
|
575
575
|
* @param options
|
|
576
576
|
*/
|
|
577
577
|
checkWeather(e, t, o = {}) {
|
|
578
|
-
var
|
|
578
|
+
var l, m, M, g, I, c, w, N, v, S, Y, F, T, D, H;
|
|
579
579
|
let i = 0, a = 0, n = 0, s = 0;
|
|
580
|
-
const d = Math.round(((
|
|
580
|
+
const d = Math.round(((m = (l = t == null ? void 0 : t.SEVERE) == null ? void 0 : l.sigWave) == null ? void 0 : m.number) * 1.6 * 100) / 100, r = (g = (M = t == null ? void 0 : t.SEVERE) == null ? void 0 : M.sigWave) == null ? void 0 : g.number, u = (c = (I = t == null ? void 0 : t.HEAVY) == null ? void 0 : I.sigWave) == null ? void 0 : c.number, y = Math.round((((N = (w = t == null ? void 0 : t.SEVERE) == null ? void 0 : w.wind) == null ? void 0 : N.number) + 2) * 100) / 100, h = (S = (v = t == null ? void 0 : t.SEVERE) == null ? void 0 : v.wind) == null ? void 0 : S.number, f = (F = (Y = t == null ? void 0 : t.HEAVY) == null ? void 0 : Y.wind) == null ? void 0 : F.number;
|
|
581
581
|
for (let V = 0; V < (e == null ? void 0 : e.length); V++) {
|
|
582
|
-
const
|
|
583
|
-
s = J > s ? J : s, W == null || W.info("[%s] check sig.wave: %j", o.requestId, { ...P, dgThd4Wv: d, svThd4Wv: r, hvThd4Wv:
|
|
582
|
+
const E = e[V], P = (D = (T = E == null ? void 0 : E.meteo) == null ? void 0 : T.wave) == null ? void 0 : D.sig, A = (H = E == null ? void 0 : E.meteo) == null ? void 0 : H.wind, J = V ? p(E.eta).diff(p(e[V - 1].eta), "hour", !0) : 0;
|
|
583
|
+
s = J > s ? J : s, W == null || W.info("[%s] check sig.wave: %j", o.requestId, { ...P, dgThd4Wv: d, svThd4Wv: r, hvThd4Wv: u }), (P == null ? void 0 : P.height) >= d ? E.isDangerous = !0 : (P == null ? void 0 : P.height) >= r ? E.isSevere = !0 : (P == null ? void 0 : P.height) >= u && (E.isHeavy = !0), W == null || W.info("[%s] check wind: %j", o.requestId, { ...A, dgThd4Wd: y, svThd4Wd: h, hvThd4Wd: f }), (A == null ? void 0 : A.scale) >= y ? (E.isDangerous = !0, delete E.isSevere, delete E.isHeavy) : (A == null ? void 0 : A.scale) > h ? (E.isDangerous || (E.isSevere = !0), delete E.isHeavy) : (A == null ? void 0 : A.scale) === f && !E.isDangerous && !E.isSevere && (E.isHeavy = !0), i += E.isDangerous ? J : 0, a += E.isSevere ? J : 0, n += E.isHeavy ? J : 0;
|
|
584
584
|
}
|
|
585
|
-
return i = Math.round(i * 100) / 100, a = Math.round(a * 100) / 100, n = Math.round(n * 100) / 100, s = Math.round(s), { sample: e, dangerous: i, severe: a, heavy: n, step: s < 3 ? 3 : s, wind: { dgThd4Wd: y, svThd4Wd:
|
|
585
|
+
return i = Math.round(i * 100) / 100, a = Math.round(a * 100) / 100, n = Math.round(n * 100) / 100, s = Math.round(s), { sample: e, dangerous: i, severe: a, heavy: n, step: s < 3 ? 3 : s, wind: { dgThd4Wd: y, svThd4Wd: h, hvThd4Wd: f }, sig: { dgThd4Wv: d, svThd4Wv: r, hvThd4Wv: u } };
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
588
|
const kt = new rt();
|
|
589
|
-
let
|
|
589
|
+
let k;
|
|
590
590
|
try {
|
|
591
|
-
|
|
591
|
+
k = Q.getLogger("vessel");
|
|
592
592
|
} catch {
|
|
593
593
|
} finally {
|
|
594
594
|
}
|
|
595
595
|
const ct = new ot("", !0);
|
|
596
|
-
var dt = /* @__PURE__ */ ((
|
|
597
|
-
class
|
|
596
|
+
var dt = /* @__PURE__ */ ((j) => (j.common = "common", j.container = "container", j.tugs = "tugs", j))(dt || {}), ut = /* @__PURE__ */ ((j) => (j.Ballast = "Ballast", j.Laden = "Laden", j))(ut || {}), ht = /* @__PURE__ */ ((j) => (j.Cp = "CP", j.Perf = "Basis", j.Instruct = "Other", j))(ht || {});
|
|
597
|
+
class C {
|
|
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
|
|
600
600
|
* 方形系数(block coefficient)
|
|
@@ -706,8 +706,8 @@ class E {
|
|
|
706
706
|
* @private
|
|
707
707
|
*/
|
|
708
708
|
static assembleProperties(e, t, o, i) {
|
|
709
|
-
var
|
|
710
|
-
const a = e.lbp ?? e.length ?? e.lengthOverall ?? 198.9642, n = e.draught ?? 8, s = e.breadthMoulded ?? e.breadth ?? e.breadthExtreme ?? 32.4572, d = e.deadweight ?? 67035.7773, r = ((
|
|
709
|
+
var h;
|
|
710
|
+
const a = e.lbp ?? e.length ?? e.lengthOverall ?? 198.9642, n = e.draught ?? 8, s = e.breadthMoulded ?? e.breadth ?? e.breadthExtreme ?? 32.4572, d = e.deadweight ?? 67035.7773, r = ((h = e == null ? void 0 : e.type) == null ? void 0 : h.toLowerCase()) || "common";
|
|
711
711
|
return {
|
|
712
712
|
tag: r.indexOf("container") > -1 ? "container" : r.indexOf("tugs") > -1 ? "tugs" : "common",
|
|
713
713
|
lbp: a,
|
|
@@ -735,21 +735,21 @@ class E {
|
|
|
735
735
|
static async speedLoseAt(e, t, o, i = "", a = 2, n = !0, s = !1, d = {}) {
|
|
736
736
|
let r;
|
|
737
737
|
if (t.velocity && s && (e.speed = z.roundPrecision(t.velocity * 1852 / 3600, 6)), n) {
|
|
738
|
-
let
|
|
738
|
+
let u;
|
|
739
739
|
if (d.meteo2)
|
|
740
740
|
try {
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
} catch (
|
|
744
|
-
|
|
741
|
+
const l = await ct.spotForecast(t.lat, t.lng, o.utc().format(), !1, !1, !0, d), [m] = tt.pickHourly(l, o);
|
|
742
|
+
u = tt.toLegacy(m);
|
|
743
|
+
} catch (l) {
|
|
744
|
+
k.warn("[%s] meteo2 spot(%j) forecast failed: %s", d.requestId, { ...t, eta: o.utc().format() }, l);
|
|
745
745
|
}
|
|
746
746
|
else
|
|
747
|
-
|
|
748
|
-
const y =
|
|
747
|
+
u = await nt.queryPointFactor(t.lng, t.lat, o.valueOf(), "wind,wave,current,watertemp", i, d);
|
|
748
|
+
const y = C.weatherFactor(e, u), h = C.currentFactor(e.bearing, u == null ? void 0 : u.current, a), f = Math.round((e.speed * 1.943844 + y + h) * 100) / 100;
|
|
749
749
|
r = {
|
|
750
|
-
meteo: { ...
|
|
750
|
+
meteo: { ...u },
|
|
751
751
|
wxFactor: y,
|
|
752
|
-
cFactor:
|
|
752
|
+
cFactor: h,
|
|
753
753
|
speed: t.velocity && s ? t.velocity : f < 0 ? 1 : f,
|
|
754
754
|
eta: o.utc().format("YYYY-MM-DDTHH:mm[Z]"),
|
|
755
755
|
etd: o.utc().format("YYYY-MM-DDTHH:mm[Z]")
|
|
@@ -777,53 +777,53 @@ class E {
|
|
|
777
777
|
* @param useRouteParam true 启用航线上设置的参数 { suspend: 停留时长(小时), velocity: 速度(kts)}
|
|
778
778
|
* @private
|
|
779
779
|
*/
|
|
780
|
-
static async speedLoseInHoursStep(e, t, o, i, a, n, s = "", d = !0, r = !1,
|
|
780
|
+
static async speedLoseInHoursStep(e, t, o, i, a, n, s = "", d = !0, r = !1, u = {}) {
|
|
781
781
|
t.utc();
|
|
782
|
-
const y = t.clone().add(14, "days"),
|
|
783
|
-
let
|
|
784
|
-
for (let
|
|
785
|
-
let c = n[
|
|
786
|
-
c.distanceFromStart = Math.round((a +
|
|
787
|
-
const
|
|
788
|
-
if (e.bearing = B.calculateBearing(c,
|
|
782
|
+
const y = t.clone().add(14, "days"), h = [], f = [];
|
|
783
|
+
let l = 0, m = 0, M, g;
|
|
784
|
+
for (let I = 0; I < n.length - 1; I++) {
|
|
785
|
+
let c = n[I];
|
|
786
|
+
c.distanceFromStart = Math.round((a + m) * 1e4) / 1e4;
|
|
787
|
+
const w = n[I + 1];
|
|
788
|
+
if (e.bearing = B.calculateBearing(c, w, !w.gcToPrevious), c.bearing = e.bearing, c.suspend && r) {
|
|
789
789
|
c.eta = c.eta || t.format("YYYY-MM-DDTHH:mm[Z]"), c.elapsed = c.elapsed ?? 0;
|
|
790
790
|
const S = c.suspend - c.elapsed;
|
|
791
|
-
if (i -
|
|
792
|
-
i = i -
|
|
791
|
+
if (i - l > S)
|
|
792
|
+
i = i - l - S, t.add(S, "hour"), c.elapsed = c.suspend;
|
|
793
793
|
else {
|
|
794
|
-
const
|
|
795
|
-
c.elapsed +=
|
|
794
|
+
const Y = i - l;
|
|
795
|
+
c.elapsed += Y, t.add(Y, "hour"), i = 0;
|
|
796
796
|
}
|
|
797
|
-
if (
|
|
798
|
-
return c.distanceFromPrevious =
|
|
797
|
+
if (k == null || k.info(`[%s] suspend ${c.elapsed} hours at %j, and remain ${i} hours need to go...`, u.requestId, c), i === 0)
|
|
798
|
+
return c.distanceFromPrevious = m, { etd: t, from: g || c, to: c, next: n.filter((Y) => Y), wps: h, days: f };
|
|
799
799
|
} else
|
|
800
800
|
c.suspend = 0;
|
|
801
|
-
d = t.isAfter(y) ? !1 : d, c = await
|
|
802
|
-
const N = B.calculateDistance(c,
|
|
803
|
-
let
|
|
804
|
-
if (
|
|
805
|
-
if (
|
|
806
|
-
`[%s] go to %j from %j with ${N}nm, and cost ${
|
|
807
|
-
|
|
808
|
-
{ lat:
|
|
809
|
-
{ lat:
|
|
810
|
-
),
|
|
811
|
-
|
|
801
|
+
d = t.isAfter(y) ? !1 : d, c = await C.speedLoseAt(e, c, t, s, 0, d, r, u), g = g || c, c.important && h.push(c), t.isSameOrAfter(o) && (f.push(c), o.add(24, "hour"));
|
|
802
|
+
const N = B.calculateDistance(c, w, !w.gcToPrevious);
|
|
803
|
+
let v = Math.ceil(N / g.speed * 1e4) / 1e4;
|
|
804
|
+
if (l + v < i) {
|
|
805
|
+
if (l += v, t.add(v, "hour"), delete n[I], k == null || k.debug(
|
|
806
|
+
`[%s] go to %j from %j with ${N}nm, and cost ${v} hours`,
|
|
807
|
+
u.requestId,
|
|
808
|
+
{ lat: w.lat, lng: w.lng },
|
|
809
|
+
{ lat: g.lat, lng: g.lng, etd: g.etd }
|
|
810
|
+
), m += N, n.filter((S) => S).length <= 1) {
|
|
811
|
+
M = w, M.eta = t.format("YYYY-MM-DDTHH:mm[Z]"), M.distanceFromPrevious = N, M.distanceFromStart = Math.round((a + m) * 1e4) / 1e4, h.push(M), delete n[I + 1];
|
|
812
812
|
break;
|
|
813
813
|
}
|
|
814
814
|
} else {
|
|
815
|
-
|
|
816
|
-
const S = z.roundPrecision(
|
|
817
|
-
|
|
818
|
-
`[%s] go to %j from %j with ${S}nm, and cost ${
|
|
819
|
-
|
|
820
|
-
{ lat:
|
|
815
|
+
v = i - l, t.add(v, "hour");
|
|
816
|
+
const S = z.roundPrecision(g.speed * v, 4);
|
|
817
|
+
M = B.calculateCoordinate(c, e.bearing, S, "nauticalmiles", !w.gcToPrevious), M.eta = t.format("YYYY-MM-DDTHH:mm[Z]"), n[I] = M, k == null || k.debug(
|
|
818
|
+
`[%s] go to %j from %j with ${S}nm, and cost ${v} hours`,
|
|
819
|
+
u.requestId,
|
|
820
|
+
{ lat: M.lat, lng: M.lng },
|
|
821
821
|
{ lat: c.lat, lng: c.lng, etd: c.etd }
|
|
822
|
-
),
|
|
822
|
+
), m += S, M.distanceFromPrevious = Math.round(m * 1e4) / 1e4, M.distanceFromStart = Math.round((a + m) * 1e4) / 1e4;
|
|
823
823
|
break;
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
|
-
return { etd: t, from:
|
|
826
|
+
return { etd: t, from: g, to: M, next: n.filter((I) => I), wps: h, days: f };
|
|
827
827
|
}
|
|
828
828
|
/**
|
|
829
829
|
* 洋流影响因子
|
|
@@ -844,16 +844,16 @@ class E {
|
|
|
844
844
|
* @param wwc 气象要素
|
|
845
845
|
*/
|
|
846
846
|
static weatherFactor(e, t) {
|
|
847
|
-
var y,
|
|
848
|
-
|
|
849
|
-
const o =
|
|
847
|
+
var y, h, f, l, m, M, g;
|
|
848
|
+
k == null || k.debug("calculate weather factor via: %j", { ...e, ...t });
|
|
849
|
+
const o = C.blockCoefficient(e.displacement, e.lbp, e.breadthMoulded, e.draught), i = C.froudeNumber(e.speed, e.lbp), a = C.amendFactor(o, i, e.loadCondition);
|
|
850
850
|
let n = Math.abs(e.bearing % 360 - (((y = t == null ? void 0 : t.wind) == null ? void 0 : y.degree) % 360 || 0));
|
|
851
851
|
n = n > 180 ? 360 - n : n;
|
|
852
|
-
const s =
|
|
852
|
+
const s = C.directionFactor(n, (h = t == null ? void 0 : t.wind) == null ? void 0 : h.scale), d = C.vesselTagFactor(e.displacement, e.loadCondition, e.tag, (f = t == null ? void 0 : t.wind) == null ? void 0 : f.scale);
|
|
853
853
|
let r = s * a * 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)),
|
|
855
|
-
const
|
|
856
|
-
return
|
|
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)), k == null || k.debug("wind wx factor = %d", r), n = Math.abs(e.bearing % 360 - (((m = (l = t == null ? void 0 : t.wave) == null ? void 0 : l.sig) == null ? void 0 : m.degree) % 360 || 0));
|
|
855
|
+
const u = C.waveHeightFactor(((g = (M = t == null ? void 0 : t.wave) == null ? void 0 : M.sig) == null ? void 0 : g.height) ?? 1, n);
|
|
856
|
+
return k == null || k.debug("wave wx factor = %d", u), r = r * 0.4 + u, k == null || k.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
|
/**
|
|
859
859
|
* 全程失速分析(走完航程)
|
|
@@ -867,14 +867,14 @@ class E {
|
|
|
867
867
|
* @param useMeteo true 启用气象分析
|
|
868
868
|
* @param useRouteParam
|
|
869
869
|
*/
|
|
870
|
-
static async analyseInstant(e, t, o, i, a, n = "", s = 0, d = !0, r = !1,
|
|
870
|
+
static async analyseInstant(e, t, o, i, a, n = "", s = 0, d = !0, r = !1, u = {}) {
|
|
871
871
|
var J, _, K, G, L;
|
|
872
|
-
const y =
|
|
872
|
+
const y = p().valueOf();
|
|
873
873
|
e.lng = z.convertToStdLng(e.lng);
|
|
874
|
-
const { route:
|
|
875
|
-
if (((J =
|
|
874
|
+
const { route: h, waypoints: f } = a.points, l = B.calculateSubRoute(e, h);
|
|
875
|
+
if (((J = l[0]) == null ? void 0 : J.length) <= 1)
|
|
876
876
|
return;
|
|
877
|
-
const { v0:
|
|
877
|
+
const { v0: m, label: M } = e.sog ? {
|
|
878
878
|
v0: e.sog,
|
|
879
879
|
label: "Other"
|
|
880
880
|
/* Instruct */
|
|
@@ -882,46 +882,46 @@ class E {
|
|
|
882
882
|
v0: i.speed,
|
|
883
883
|
label: "CP"
|
|
884
884
|
/* Cp */
|
|
885
|
-
},
|
|
886
|
-
|
|
885
|
+
}, g = C.assembleProperties(o, i.loadCondition, m, 0), I = f.length ? B.calculateSubWaypoints(e, f) : [];
|
|
886
|
+
I.forEach((x) => x.important = !0);
|
|
887
887
|
const c = {
|
|
888
888
|
from: { ...e },
|
|
889
|
-
route:
|
|
890
|
-
waypoints:
|
|
891
|
-
v0:
|
|
892
|
-
label:
|
|
893
|
-
},
|
|
889
|
+
route: l,
|
|
890
|
+
waypoints: I,
|
|
891
|
+
v0: m,
|
|
892
|
+
label: M
|
|
893
|
+
}, w = {
|
|
894
894
|
hours: [],
|
|
895
895
|
days: [],
|
|
896
896
|
wps: []
|
|
897
897
|
};
|
|
898
|
-
s || (B.calculateRouteDistance(
|
|
899
|
-
let N = B.simplifyRouteToCoordinates(
|
|
900
|
-
t =
|
|
901
|
-
const
|
|
898
|
+
s || (B.calculateRouteDistance(l) / i.speed <= 72 ? s = 3 : s = 6);
|
|
899
|
+
let N = B.simplifyRouteToCoordinates(l, I, 0), v = 0, S = 0, Y = 0, F = 0;
|
|
900
|
+
t = p(t).utc();
|
|
901
|
+
const T = t.clone();
|
|
902
902
|
for (; N.length > 0; ) {
|
|
903
|
-
const x = s - t.hour() % s,
|
|
904
|
-
|
|
903
|
+
const x = s - t.hour() % s, q = Math.ceil(t.clone().add(x, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4, O = await C.speedLoseInHoursStep(
|
|
904
|
+
g,
|
|
905
905
|
t,
|
|
906
|
+
T,
|
|
906
907
|
q,
|
|
907
|
-
|
|
908
|
-
m,
|
|
908
|
+
v,
|
|
909
909
|
N,
|
|
910
910
|
n,
|
|
911
911
|
d,
|
|
912
912
|
r,
|
|
913
|
-
|
|
913
|
+
u
|
|
914
914
|
);
|
|
915
|
-
(_ = O.from) != null && _.speed && (
|
|
915
|
+
(_ = O.from) != null && _.speed && (w.hours.push(O.from), w.wps.push(...O.wps), w.days.push(...O.days)), N = O == null ? void 0 : O.next, N.length || w.hours.push(O == null ? void 0 : O.to), v += Math.round((((K = O == null ? void 0 : O.to) == null ? void 0 : K.distanceFromPrevious) ?? 0) * 1e4) / 1e4;
|
|
916
916
|
}
|
|
917
|
-
const
|
|
918
|
-
for (let x = 0; x <
|
|
919
|
-
const
|
|
920
|
-
S += (
|
|
917
|
+
const D = w.hours;
|
|
918
|
+
for (let x = 0; x < D.length - 1; x++) {
|
|
919
|
+
const q = p(D[x + 1].eta).diff(D[x].etd, "hour", !0) || 1;
|
|
920
|
+
S += (D[x].wxFactor || 0) * q, Y += (D[x].cFactor || 0) * q, F += q;
|
|
921
921
|
}
|
|
922
|
-
(G =
|
|
923
|
-
if (
|
|
924
|
-
const O =
|
|
922
|
+
(G = w.wps) == null || G.forEach((x, q) => {
|
|
923
|
+
if (q) {
|
|
924
|
+
const O = w.wps[q - 1], et = x.distanceFromStart - O.distanceFromStart, X = p(x.eta).diff(p(O.etd), "h", !0);
|
|
925
925
|
if (X < 1)
|
|
926
926
|
x.avgSpd = O.speed;
|
|
927
927
|
else {
|
|
@@ -930,11 +930,11 @@ class E {
|
|
|
930
930
|
x.avgSpd = x.avgSpd > $ ? $ : x.avgSpd;
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
|
-
}), c.sample =
|
|
934
|
-
const
|
|
935
|
-
c.distance = Math.round(V.distanceFromStart * 1e4) / 1e4, c.etd =
|
|
936
|
-
const P =
|
|
937
|
-
return
|
|
933
|
+
}), c.sample = w;
|
|
934
|
+
const H = w.hours.at(0), V = w.hours.at(-1);
|
|
935
|
+
c.distance = Math.round(V.distanceFromStart * 1e4) / 1e4, c.etd = p(H.eta).utc().format(), c.eta = p(V.eta).utc().format(), c.wxFactor = Math.round(S / F * 1e4) / 1e4, c.cFactor = Math.round(Y / F * 1e4) / 1e4, c.avgSpeed = Math.round(V.distanceFromStart / F * 1e4) / 1e4, c.totalHrs = Math.round(F * 1e4) / 1e4, c.totalFoCons = Math.round((i == null ? void 0 : i.fo) / 24 * c.totalHrs * 1e3) / 1e3, c.totalDgoCons = Math.round((i == null ? void 0 : i.dgo) / 24 * c.totalHrs * 1e3) / 1e3;
|
|
936
|
+
const P = p().valueOf() - y, A = ((L = w == null ? void 0 : w.hours) == null ? void 0 : L.length) || 1;
|
|
937
|
+
return k == null || k.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", u == null ? void 0 : u.requestId, P, A, Math.round(P / A * 1e3) / 1e3), c;
|
|
938
938
|
}
|
|
939
939
|
/**
|
|
940
940
|
* 分段失速分析(最多走hours 小时)
|
|
@@ -949,11 +949,11 @@ class E {
|
|
|
949
949
|
* @param useMeteo true 启用气象分析
|
|
950
950
|
* @param useRouteParam
|
|
951
951
|
*/
|
|
952
|
-
static async analyseInstantWithThreshed(e, t, o, i, a, n, s, d = "", r = 3,
|
|
952
|
+
static async analyseInstantWithThreshed(e, t, o, i, a, n, s, d = "", r = 3, u = !0, y = !1, h = {}) {
|
|
953
953
|
var J, _, K, G;
|
|
954
|
-
const f =
|
|
954
|
+
const f = p().valueOf();
|
|
955
955
|
e.lng = z.convertToStdLng(e.lng);
|
|
956
|
-
const { v0:
|
|
956
|
+
const { v0: l, label: m } = e.sog ? {
|
|
957
957
|
v0: e.sog,
|
|
958
958
|
label: "Other"
|
|
959
959
|
/* Instruct */
|
|
@@ -961,52 +961,52 @@ class E {
|
|
|
961
961
|
v0: a.speed,
|
|
962
962
|
label: "CP"
|
|
963
963
|
/* Cp */
|
|
964
|
-
},
|
|
965
|
-
if (((J =
|
|
964
|
+
}, M = C.assembleProperties(i, a.loadCondition, l, 0), g = B.calculateSubRoute(e, n);
|
|
965
|
+
if (((J = g[0]) == null ? void 0 : J.length) <= 1)
|
|
966
966
|
return;
|
|
967
|
-
const
|
|
968
|
-
|
|
969
|
-
let c = B.simplifyRouteToCoordinates(
|
|
970
|
-
const
|
|
967
|
+
const I = s.length ? B.calculateSubWaypoints(e, s) : [];
|
|
968
|
+
I.forEach((L) => L.important = !0);
|
|
969
|
+
let c = B.simplifyRouteToCoordinates(g, I, 0), w = 0, N = 0, v = 0, S = 0;
|
|
970
|
+
const Y = {
|
|
971
971
|
hours: [],
|
|
972
972
|
wps: [],
|
|
973
973
|
days: []
|
|
974
974
|
};
|
|
975
|
-
t =
|
|
976
|
-
const
|
|
975
|
+
t = p(t).utc();
|
|
976
|
+
const F = t.clone();
|
|
977
977
|
for (; c.length > 0; ) {
|
|
978
978
|
const L = r - t.hour() % r;
|
|
979
979
|
let x = Math.ceil(t.clone().add(L, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4;
|
|
980
980
|
x = t.clone().add(x, "h").isSameOrAfter(o) ? o.diff(t, "h", !0) * 1e4 / 1e4 : x;
|
|
981
|
-
const
|
|
982
|
-
if ((_ =
|
|
981
|
+
const q = await C.speedLoseInHoursStep(M, t, F, x, w, c, d, u, y, h);
|
|
982
|
+
if ((_ = q.from) != null && _.speed && (Y.hours.push(q.from), q != null && q.wps && Y.wps.push(...q.wps), Y.days.push(...q.days)), c = q == null ? void 0 : q.next, c.length || Y.hours.push(q == null ? void 0 : q.to), w += Math.round((((K = q == null ? void 0 : q.to) == null ? void 0 : K.distanceFromPrevious) ?? 0) * 1e4) / 1e4, !x)
|
|
983
983
|
break;
|
|
984
984
|
}
|
|
985
|
-
const
|
|
986
|
-
for (let L = 0; L <
|
|
987
|
-
const x =
|
|
988
|
-
N +=
|
|
985
|
+
const T = Y.hours;
|
|
986
|
+
for (let L = 0; L < T.length - 1; L++) {
|
|
987
|
+
const x = p(T[L + 1].eta).diff(T[L].etd, "hour", !0);
|
|
988
|
+
N += T[L].wxFactor * x, v += T[L].cFactor * x, S += x;
|
|
989
989
|
}
|
|
990
|
-
const
|
|
991
|
-
sample:
|
|
992
|
-
distance: Math.round(((
|
|
990
|
+
const D = Y.hours.at(0), H = Y.hours.at(-1), V = {
|
|
991
|
+
sample: Y,
|
|
992
|
+
distance: Math.round(((H == null ? void 0 : H.distanceFromStart) || 0) * 1e4) / 1e4,
|
|
993
993
|
// 注意,可能会在first节点Drift,所有采用eta做为初始出发时间
|
|
994
|
-
etd:
|
|
995
|
-
eta:
|
|
994
|
+
etd: p(D.eta).utc().format(),
|
|
995
|
+
eta: p(H == null ? void 0 : H.eta).utc().format(),
|
|
996
996
|
wxFactor: Math.round(N / S * 1e4) / 1e4,
|
|
997
|
-
cFactor: Math.round(
|
|
998
|
-
avgSpeed: Math.round(((
|
|
997
|
+
cFactor: Math.round(v / S * 1e4) / 1e4,
|
|
998
|
+
avgSpeed: Math.round(((H == null ? void 0 : H.distanceFromStart) || 0) / S * 1e4) / 1e4,
|
|
999
999
|
totalHrs: Math.round(S * 1e4) / 1e4,
|
|
1000
1000
|
totalFoCons: Math.round((a == null ? void 0 : a.fo) / 24 * S * 1e3) / 1e3,
|
|
1001
1001
|
totalDgoCons: Math.round((a == null ? void 0 : a.dgo) / 24 * S * 1e3) / 1e3,
|
|
1002
|
-
from:
|
|
1003
|
-
to:
|
|
1004
|
-
route:
|
|
1005
|
-
waypoints:
|
|
1006
|
-
v0:
|
|
1007
|
-
label:
|
|
1008
|
-
}, P =
|
|
1009
|
-
return
|
|
1002
|
+
from: D,
|
|
1003
|
+
to: H,
|
|
1004
|
+
route: g,
|
|
1005
|
+
waypoints: I,
|
|
1006
|
+
v0: l,
|
|
1007
|
+
label: m
|
|
1008
|
+
}, P = p().valueOf() - f, A = ((G = Y == null ? void 0 : Y.hours) == null ? void 0 : G.length) || 1;
|
|
1009
|
+
return k == null || k.debug("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", h == null ? void 0 : h.requestId, P, A, Math.round(P / A * 1e3) / 1e3), V;
|
|
1010
1010
|
}
|
|
1011
1011
|
/**
|
|
1012
1012
|
* 在指定航线条件下,基于多CP,动态计算最优成本(租金+油费)方案
|
|
@@ -1024,25 +1024,25 @@ class E {
|
|
|
1024
1024
|
* @param options
|
|
1025
1025
|
*/
|
|
1026
1026
|
static async analyseCost(e, t, o, i, a = {}) {
|
|
1027
|
-
var
|
|
1028
|
-
const n =
|
|
1027
|
+
var g, I;
|
|
1028
|
+
const n = p().valueOf(), s = [];
|
|
1029
1029
|
a.meteo2 = a.meteo2 || !0, e.speedStep = e.speedStep || 3, e.alterStep = e.alterStep ?? 1;
|
|
1030
1030
|
const d = B.calculateRouteDistance(i.route);
|
|
1031
1031
|
let r = 0;
|
|
1032
1032
|
o.forEach((c) => {
|
|
1033
|
-
const
|
|
1034
|
-
r = r <
|
|
1033
|
+
const w = Math.ceil(d / c.speed / 24);
|
|
1034
|
+
r = r < w ? w : r;
|
|
1035
1035
|
}), r = r * 1.3;
|
|
1036
|
-
const
|
|
1036
|
+
const u = p.utc(e.etd).add(r ?? 14, "day");
|
|
1037
1037
|
let y = 1;
|
|
1038
1038
|
for (const c of o) {
|
|
1039
|
-
const
|
|
1039
|
+
const w = JSON.parse(JSON.stringify(i.route)), N = JSON.parse(JSON.stringify(i.waypoints)), v = await C.analyseInstantWithThreshed(
|
|
1040
1040
|
{ lat: e.lat, lng: e.lng },
|
|
1041
1041
|
e.etd,
|
|
1042
|
-
|
|
1042
|
+
u,
|
|
1043
1043
|
t,
|
|
1044
1044
|
c,
|
|
1045
|
-
|
|
1045
|
+
w,
|
|
1046
1046
|
N,
|
|
1047
1047
|
e.meteoVendor,
|
|
1048
1048
|
e.speedStep,
|
|
@@ -1050,30 +1050,30 @@ class E {
|
|
|
1050
1050
|
e.useRouteParam,
|
|
1051
1051
|
a
|
|
1052
1052
|
);
|
|
1053
|
-
|
|
1054
|
-
cost:
|
|
1055
|
-
distance:
|
|
1056
|
-
hours:
|
|
1053
|
+
v && (await C.calculateCost(v, c, e, a), s.push(v), k == null || k.info("[%s][L%d-%d] analyse from %s to %s cost: %j", a.requestId, 1, y, e.etd, u.format(), {
|
|
1054
|
+
cost: v.cost.total,
|
|
1055
|
+
distance: v.distance,
|
|
1056
|
+
hours: v.totalHrs,
|
|
1057
1057
|
cp: `${c.speed}/${c.fo}/${c.dgo}`
|
|
1058
1058
|
})), y++;
|
|
1059
1059
|
}
|
|
1060
|
-
s.sort((c,
|
|
1061
|
-
const
|
|
1062
|
-
if (
|
|
1063
|
-
const c =
|
|
1064
|
-
let
|
|
1065
|
-
|
|
1066
|
-
let
|
|
1067
|
-
for (;
|
|
1068
|
-
const
|
|
1069
|
-
if (
|
|
1060
|
+
s.sort((c, w) => c.cost.total - w.cost.total);
|
|
1061
|
+
const h = s.at(0), f = s.at(1), l = [];
|
|
1062
|
+
if (l.push({ combined: !1, speeds: [h], cost: (g = h.cost) == null ? void 0 : g.total }), f) {
|
|
1063
|
+
const c = h.cost.cp, w = f.cost.cp, N = p(h.eta), v = p(h.etd), S = N.diff(v, "days", !0);
|
|
1064
|
+
let Y = Math.ceil(S / 2);
|
|
1065
|
+
Y = Y > 7 ? 7 : Y < e.alterStep ? e.alterStep : Y;
|
|
1066
|
+
let F = 2, T = { combined: !1, speeds: [f], cost: (I = f.cost) == null ? void 0 : I.total }, D;
|
|
1067
|
+
for (; Y >= e.alterStep; ) {
|
|
1068
|
+
const H = await C.combinedAnalyse(e, t, u, [c, w], i, Y, { ...a, level: F });
|
|
1069
|
+
if (T.cost > H.cost ? D ? (D == null ? void 0 : D.cost) > H.cost && (D = H) : (D = T, T = H) : (!D || (D == null ? void 0 : D.cost) > H.cost) && (D = H), Y <= e.alterStep)
|
|
1070
1070
|
break;
|
|
1071
|
-
|
|
1071
|
+
Y = Math.ceil(Y / 2), F += 1;
|
|
1072
1072
|
}
|
|
1073
|
-
|
|
1073
|
+
l.push(T), D && l.push(D);
|
|
1074
1074
|
}
|
|
1075
|
-
const
|
|
1076
|
-
return
|
|
1075
|
+
const M = p().valueOf() - n;
|
|
1076
|
+
return k == null || k.info("[%s] analyse elapsed: %d ms", a == null ? void 0 : a.requestId, M), l.sort((c, w) => c.cost - w.cost);
|
|
1077
1077
|
}
|
|
1078
1078
|
/**
|
|
1079
1079
|
* 按步长多次减半,分别用7,4,2,1天步长及cpa,cpb交替计算各种组合下的成本
|
|
@@ -1086,11 +1086,11 @@ class E {
|
|
|
1086
1086
|
* @param options
|
|
1087
1087
|
*/
|
|
1088
1088
|
static async combinedAnalyse(e, t, o, i, a, n, s = {}) {
|
|
1089
|
-
s.counter = 1,
|
|
1090
|
-
const d = await
|
|
1091
|
-
|
|
1092
|
-
const
|
|
1093
|
-
return
|
|
1089
|
+
s.counter = 1, k == null || k.info("[%s][L%d] analyse with alternate cp in every %d days", s.requestId, s.level, n);
|
|
1090
|
+
const d = await C.alternateAnalyse(e, t, o, i, 0, a, n, s), r = d.reduce((h, f) => h + f.cost.total, 0);
|
|
1091
|
+
k == null || k.info("[%s][L%d] cost with cpa/cpb turn: %d", s.requestId, s.level, r);
|
|
1092
|
+
const u = await C.alternateAnalyse(e, t, o, i, 1, a, n, s), y = u.reduce((h, f) => h + f.cost.total, 0);
|
|
1093
|
+
return k == null || k.info("[%s][L%d] cost with cpb/cpa turn: %d", s.requestId, s.level, y), r < y ? { combined: !0, cost: Math.round(r * 1e3) / 1e3, speeds: d, step: n } : { combined: !0, cost: Math.round(y * 1e3) / 1e3, speeds: u, step: n };
|
|
1094
1094
|
}
|
|
1095
1095
|
/**
|
|
1096
1096
|
* 基于cp索引,交替计算指定步长下的成本
|
|
@@ -1104,36 +1104,36 @@ class E {
|
|
|
1104
1104
|
* @param options
|
|
1105
1105
|
*/
|
|
1106
1106
|
static async alternateAnalyse(e, t, o, i, a, n, s, d = {}) {
|
|
1107
|
-
var
|
|
1108
|
-
let r =
|
|
1109
|
-
const
|
|
1107
|
+
var h, f;
|
|
1108
|
+
let r = p.utc(e.etd);
|
|
1109
|
+
const u = { lat: e.lat, lng: e.lng }, y = [];
|
|
1110
1110
|
for (; r.isBefore(o); ) {
|
|
1111
|
-
const
|
|
1112
|
-
h,
|
|
1113
|
-
r.format(),
|
|
1111
|
+
const l = r.clone().utc().add(s, "day"), m = JSON.parse(JSON.stringify(n.route)), M = JSON.parse(JSON.stringify(n.waypoints)), g = i[a], I = await C.analyseInstantWithThreshed(
|
|
1114
1112
|
u,
|
|
1113
|
+
r.format(),
|
|
1114
|
+
l,
|
|
1115
1115
|
t,
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1116
|
+
g,
|
|
1117
|
+
m,
|
|
1118
|
+
M,
|
|
1119
1119
|
e.meteoVendor,
|
|
1120
1120
|
e.speedStep,
|
|
1121
1121
|
e.useMeteo,
|
|
1122
1122
|
e.useRouteParam,
|
|
1123
1123
|
d
|
|
1124
1124
|
);
|
|
1125
|
-
|
|
1125
|
+
I && (await C.calculateCost(I, g, e, d), k == null || k.info(
|
|
1126
1126
|
"[%s][L%d-%d] analyse from %s to %s cost: %j",
|
|
1127
1127
|
d.requestId,
|
|
1128
1128
|
d.level,
|
|
1129
1129
|
d.counter,
|
|
1130
1130
|
r.utc().format(),
|
|
1131
|
-
|
|
1132
|
-
{ cost:
|
|
1131
|
+
l.utc().format(),
|
|
1132
|
+
{ cost: I.cost.total, distance: I.distance, hours: I.totalHrs, cp: `${g.speed}/${g.fo}/${g.dgo}` }
|
|
1133
1133
|
)), d.counter = d.counter + 1;
|
|
1134
|
-
const c = (f = (
|
|
1134
|
+
const c = (f = (h = I == null ? void 0 : I.sample) == null ? void 0 : h.hours) == null ? void 0 : f.at(-1);
|
|
1135
1135
|
if (c)
|
|
1136
|
-
|
|
1136
|
+
u.lat = c.lat, u.lng = c.lng, r = p(c.eta), y.push(I), a = a ? 0 : 1;
|
|
1137
1137
|
else
|
|
1138
1138
|
break;
|
|
1139
1139
|
}
|
|
@@ -1159,35 +1159,40 @@ class E {
|
|
|
1159
1159
|
return e;
|
|
1160
1160
|
}
|
|
1161
1161
|
static async mergeSpeeds(e, t = {}) {
|
|
1162
|
-
var
|
|
1162
|
+
var l;
|
|
1163
1163
|
const o = {
|
|
1164
1164
|
hours: [],
|
|
1165
1165
|
wps: [],
|
|
1166
1166
|
days: []
|
|
1167
|
-
}, i = e.reduce((
|
|
1168
|
-
for (const
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1167
|
+
}, i = e.reduce((m, M) => m + M.distance, 0), a = e.reduce((m, M) => m + M.totalHrs, 0), n = e.reduce((m, M) => m + M.wxFactor * M.totalHrs / a, 0), s = e.reduce((m, M) => m + M.cFactor * M.totalHrs / a, 0), d = e.reduce((m, M) => m + M.totalFoCons, 0), r = e.reduce((m, M) => m + M.totalDgoCons, 0), u = e.reduce((m, M) => m + M.cost.total, 0), y = e.reduce((m, M) => m + M.cost.hire, 0), h = e.reduce((m, M) => m + M.cost.bunker, 0), f = [];
|
|
1168
|
+
for (const m of e) {
|
|
1169
|
+
const M = m.sample.hours, g = M.at(0);
|
|
1170
|
+
g.cp = m.cost.cp;
|
|
1171
|
+
const I = [m.etd, m.eta], c = f.findIndex((S) => S.id === g.cp.id);
|
|
1172
|
+
c === -1 ? (g.cp.segment = [I], f.push(g.cp)) : f[c].segment.push(I);
|
|
1173
|
+
const w = m.sample.wps, N = m.sample.days;
|
|
1174
|
+
M.forEach((S) => {
|
|
1175
|
+
var F;
|
|
1176
|
+
((F = o.hours) == null ? void 0 : F.findIndex((T) => T.eta === S.eta)) === -1 && o.hours.push(S);
|
|
1177
|
+
}), w.forEach((S) => {
|
|
1178
|
+
var F;
|
|
1179
|
+
((F = o.wps) == null ? void 0 : F.findIndex((T) => T.eta === S.eta)) === -1 && o.wps.push(S);
|
|
1180
|
+
}), N.forEach((S) => {
|
|
1181
|
+
var F;
|
|
1182
|
+
((F = o == null ? void 0 : o.days) == null ? void 0 : F.findIndex((T) => T.eta === S.eta)) === -1 && o.days.push(S);
|
|
1181
1183
|
});
|
|
1182
|
-
const
|
|
1183
|
-
|
|
1184
|
+
const v = (l = o.wps) == null ? void 0 : l.findIndex((S) => S.eta === g.eta);
|
|
1185
|
+
v === -1 ? o.wps.push(g) : o.wps[v] = g;
|
|
1184
1186
|
}
|
|
1185
|
-
return {
|
|
1187
|
+
return o.wps.sort((m, M) => {
|
|
1188
|
+
p(m.etd).unix() - p(M.etd).unix();
|
|
1189
|
+
}), {
|
|
1186
1190
|
sample: o,
|
|
1187
1191
|
etd: e.at(0).etd,
|
|
1188
1192
|
eta: e.at(-1).eta,
|
|
1189
1193
|
from: e.at(0).from,
|
|
1190
1194
|
to: e.at(-1).to,
|
|
1195
|
+
v0: e.at(0).v0,
|
|
1191
1196
|
label: "Combined",
|
|
1192
1197
|
distance: Math.round(i * 1e4) / 1e4,
|
|
1193
1198
|
totalHrs: Math.round(a * 1e3) / 1e3,
|
|
@@ -1197,10 +1202,11 @@ class E {
|
|
|
1197
1202
|
totalFoCons: Math.round(d * 1e3) / 1e3,
|
|
1198
1203
|
totalDgoCons: Math.round(r * 1e3) / 1e3,
|
|
1199
1204
|
cost: {
|
|
1200
|
-
total: Math.round(
|
|
1205
|
+
total: Math.round(u * 1e3) / 1e3,
|
|
1201
1206
|
hire: Math.round(y * 1e3) / 1e3,
|
|
1202
|
-
bunker: Math.round(
|
|
1203
|
-
}
|
|
1207
|
+
bunker: Math.round(h * 1e3) / 1e3
|
|
1208
|
+
},
|
|
1209
|
+
cps: f
|
|
1204
1210
|
};
|
|
1205
1211
|
}
|
|
1206
1212
|
}
|
|
@@ -1213,7 +1219,7 @@ export {
|
|
|
1213
1219
|
It as MyShipImpl,
|
|
1214
1220
|
vt as MyVesselImpl,
|
|
1215
1221
|
pt as ShipxyImpl,
|
|
1216
|
-
|
|
1222
|
+
C as SpeedHelper,
|
|
1217
1223
|
ht as SpeedLabel,
|
|
1218
1224
|
dt as VesselTag,
|
|
1219
1225
|
kt as alertHelper
|