@idm-plugin/vessel 1.6.9 → 1.7.1
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 +609 -572
- package/dist/index.umd.cjs +1 -1
- package/dist/speed/src/index.d.ts +22 -18
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
var it = Object.defineProperty;
|
|
2
|
+
var ct = (j, e, t) => e in j ? it(j, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : j[e] = t;
|
|
3
|
+
var G = (j, e, t) => (ct(j, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import L from "got";
|
|
5
|
+
import at from "@log4js-node/log4js-api";
|
|
6
6
|
import w from "moment";
|
|
7
|
-
import { LngLatHelper as
|
|
8
|
-
import { MeteoHelper2 as
|
|
9
|
-
import { Meteo2Assist as
|
|
10
|
-
let
|
|
7
|
+
import { LngLatHelper as Z, LaneHelper as R } from "@idm-plugin/geo2";
|
|
8
|
+
import { MeteoHelper2 as rt, MeteoHelper as dt } from "@idm-plugin/meteo2";
|
|
9
|
+
import { Meteo2Assist as nt } from "@idm-plugin/meteo";
|
|
10
|
+
let M;
|
|
11
11
|
try {
|
|
12
|
-
|
|
12
|
+
M = at.getLogger("vessel");
|
|
13
13
|
} catch {
|
|
14
14
|
} finally {
|
|
15
15
|
}
|
|
16
|
-
class
|
|
16
|
+
class st {
|
|
17
17
|
/**
|
|
18
18
|
* 解析AIS状态码
|
|
19
19
|
* @param status
|
|
20
20
|
*/
|
|
21
21
|
parseStatus(e) {
|
|
22
|
-
let t,
|
|
22
|
+
let t, n;
|
|
23
23
|
switch (e) {
|
|
24
24
|
case 0:
|
|
25
|
-
t = "在航(主机推动)",
|
|
25
|
+
t = "在航(主机推动)", n = "The engine is in use";
|
|
26
26
|
break;
|
|
27
27
|
case 1:
|
|
28
|
-
t = "锚泊",
|
|
28
|
+
t = "锚泊", n = "Anchored";
|
|
29
29
|
break;
|
|
30
30
|
case 2:
|
|
31
|
-
t = "失控",
|
|
31
|
+
t = "失控", n = "Not operated";
|
|
32
32
|
break;
|
|
33
33
|
case 3:
|
|
34
|
-
t = "操纵受限",
|
|
34
|
+
t = "操纵受限", n = "Limited airworthiness";
|
|
35
35
|
break;
|
|
36
36
|
case 4:
|
|
37
|
-
t = "吃水受限",
|
|
37
|
+
t = "吃水受限", n = "Limited by ship's draft";
|
|
38
38
|
break;
|
|
39
39
|
case 5:
|
|
40
|
-
t = "靠泊",
|
|
40
|
+
t = "靠泊", n = "Mooring";
|
|
41
41
|
break;
|
|
42
42
|
case 6:
|
|
43
|
-
t = "搁浅",
|
|
43
|
+
t = "搁浅", n = "Stranded";
|
|
44
44
|
break;
|
|
45
45
|
case 7:
|
|
46
|
-
t = "捕捞作业",
|
|
46
|
+
t = "捕捞作业", n = "Engaged in fishing";
|
|
47
47
|
break;
|
|
48
48
|
case 8:
|
|
49
|
-
t = "靠帆船提供动力",
|
|
49
|
+
t = "靠帆船提供动力", n = "Sailing";
|
|
50
50
|
break;
|
|
51
51
|
default:
|
|
52
|
-
t = "未定义",
|
|
52
|
+
t = "未定义", n = "Undefined";
|
|
53
53
|
}
|
|
54
|
-
return { labelCn: t, labelEn:
|
|
54
|
+
return { labelCn: t, labelEn: n };
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
class
|
|
58
|
-
constructor(t,
|
|
57
|
+
class kt extends st {
|
|
58
|
+
constructor(t, n) {
|
|
59
59
|
super();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.clientId = t, this.clientSecret =
|
|
60
|
+
G(this, "clientId");
|
|
61
|
+
G(this, "clientSecret");
|
|
62
|
+
G(this, "token");
|
|
63
|
+
this.clientId = t, this.clientSecret = n;
|
|
64
64
|
}
|
|
65
65
|
async authToken(t = {}) {
|
|
66
|
-
const
|
|
66
|
+
const n = "https://svc.data.myvessel.cn/ada/oauth/token", c = {
|
|
67
67
|
searchParams: {
|
|
68
68
|
client_id: this.clientId,
|
|
69
69
|
client_secret: this.clientSecret,
|
|
70
70
|
grant_type: "client_credentials"
|
|
71
71
|
}
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
accessToken:
|
|
75
|
-
tokenType:
|
|
76
|
-
expiresIn:
|
|
77
|
-
scope:
|
|
78
|
-
jti:
|
|
72
|
+
}, o = await L.post(n, c).json();
|
|
73
|
+
M == null || M.info("[%s] fetch access token from: %s - %j", t.requestId, n, o), o.error || (this.token = {
|
|
74
|
+
accessToken: o.access_token,
|
|
75
|
+
tokenType: o.token_type,
|
|
76
|
+
expiresIn: o.expires_in,
|
|
77
|
+
scope: o.scope,
|
|
78
|
+
jti: o.jti,
|
|
79
79
|
issuedAt: w().utc().format()
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
async realTimePosition(t,
|
|
83
|
-
var
|
|
84
|
-
(!this.token || w().diff(w(this.token.issuedAt), "seconds") > ((
|
|
85
|
-
const
|
|
82
|
+
async realTimePosition(t, n = {}) {
|
|
83
|
+
var u, m, l;
|
|
84
|
+
(!this.token || w().diff(w(this.token.issuedAt), "seconds") > ((u = this.token) == null ? void 0 : u.expiresIn) - 300) && await this.authToken(n);
|
|
85
|
+
const c = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit", o = {
|
|
86
86
|
headers: {
|
|
87
|
-
Authorization: `${(
|
|
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
|
|
93
|
-
if (
|
|
94
|
-
return
|
|
95
|
-
const s =
|
|
96
|
-
for (const
|
|
97
|
-
!isNaN(s[
|
|
91
|
+
M == null || M.info("[%s] fetch realtime position from: %s - %j", n.requestId, c, o);
|
|
92
|
+
const a = await L.get(c, o).json();
|
|
93
|
+
if (a.code)
|
|
94
|
+
return M == null || M.warn("[%s] fetch realtime position failed: %j", n.requestId, c, { message: a.message, status: a.status, code: a.code }), a;
|
|
95
|
+
const s = a.data;
|
|
96
|
+
for (const y in s)
|
|
97
|
+
!isNaN(s[y]) && Number(s[y]) !== 1 / 0 && (s[y] = Number(s[y]));
|
|
98
98
|
const d = w(`${s.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
99
99
|
return {
|
|
100
100
|
mmsi: s.mmsi,
|
|
@@ -121,78 +121,78 @@ class vt extends U {
|
|
|
121
121
|
utc: d.utc().format()
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
async trajectory(t,
|
|
124
|
+
async trajectory(t, n, c, o, a = !0, s = {}) {
|
|
125
125
|
(!this.token || w().diff(w(this.token.issuedAt), "seconds") > this.token.expiresIn - 300) && await this.authToken(s);
|
|
126
|
-
const d = await this.realTimePosition(t, s), r = w(
|
|
127
|
-
for (;
|
|
128
|
-
await this.trajectoryIn30Day(t, r, r.clone().add(30, "day"), d,
|
|
129
|
-
return await this.trajectoryIn30Day(t, r,
|
|
126
|
+
const d = await this.realTimePosition(t, s), r = w(n), u = w(c), m = [];
|
|
127
|
+
for (; u.diff(r, "day", !0) > 30; )
|
|
128
|
+
await this.trajectoryIn30Day(t, r, r.clone().add(30, "day"), d, o, m, s), r.add(30, "day");
|
|
129
|
+
return await this.trajectoryIn30Day(t, r, u, d, o, m, s), m;
|
|
130
130
|
}
|
|
131
|
-
async trajectoryIn30Day(t,
|
|
132
|
-
var
|
|
133
|
-
const r = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/track",
|
|
131
|
+
async trajectoryIn30Day(t, n, c, o, a, s, d = {}) {
|
|
132
|
+
var f, S, I, b, v;
|
|
133
|
+
const r = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/track", u = {
|
|
134
134
|
headers: {
|
|
135
|
-
Authorization: `${(
|
|
135
|
+
Authorization: `${(f = this.token) == null ? void 0 : f.tokenType} ${(S = this.token) == null ? void 0 : S.accessToken}`
|
|
136
136
|
},
|
|
137
137
|
json: {
|
|
138
138
|
mmsi: t,
|
|
139
|
-
startTime:
|
|
140
|
-
endTime:
|
|
139
|
+
startTime: n.utcOffset(8).format("YYYY-MM-DD HH:mm:ss"),
|
|
140
|
+
endTime: c.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
146
|
-
return
|
|
143
|
+
M == null || M.info("[%s] fetch trajectory from: %s - %j", d.requestId, r, u);
|
|
144
|
+
const m = await L.post(r, u).json();
|
|
145
|
+
if (m.code)
|
|
146
|
+
return M == null || M.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 (
|
|
150
|
-
for (const
|
|
151
|
-
!isNaN(
|
|
152
|
-
const
|
|
153
|
-
mmsi:
|
|
154
|
-
imo:
|
|
155
|
-
lat:
|
|
156
|
-
lng:
|
|
157
|
-
sog:
|
|
158
|
-
cog:
|
|
159
|
-
hdg:
|
|
160
|
-
draught:
|
|
161
|
-
status:
|
|
162
|
-
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(
|
|
163
|
-
destination:
|
|
164
|
-
positionTime:
|
|
165
|
-
labelCn:
|
|
166
|
-
labelEn:
|
|
148
|
+
const y = w(`${(b = (I = m.data) == null ? void 0 : I[0]) == null ? void 0 : b.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
149
|
+
return (v = m.data) == null || v.forEach((i) => {
|
|
150
|
+
for (const E in i)
|
|
151
|
+
!isNaN(i[E]) && Number(i[E]) !== 1 / 0 && (i[E] = Number(i[E]));
|
|
152
|
+
const h = w(`${i.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), C = i.status, { labelCn: g, labelEn: D } = this.parseStatus(C), Y = {
|
|
153
|
+
mmsi: i.mmsi,
|
|
154
|
+
imo: o == null ? void 0 : o.imo,
|
|
155
|
+
lat: i.lat,
|
|
156
|
+
lng: i.lon,
|
|
157
|
+
sog: i.sog,
|
|
158
|
+
cog: i.cog,
|
|
159
|
+
hdg: i.hdg,
|
|
160
|
+
draught: i.draught,
|
|
161
|
+
status: C,
|
|
162
|
+
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(i.eta) ? w(`${i.eta} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00").utc().format() : void 0,
|
|
163
|
+
destination: i.dest,
|
|
164
|
+
positionTime: h.unix(),
|
|
165
|
+
labelCn: g,
|
|
166
|
+
labelEn: D,
|
|
167
167
|
method: "trajectory",
|
|
168
168
|
vendor: "myVessel",
|
|
169
|
-
utc:
|
|
170
|
-
},
|
|
171
|
-
|
|
169
|
+
utc: h.utc().format()
|
|
170
|
+
}, q = Math.floor(h.diff(y, "minute", !0) / (a || 1));
|
|
171
|
+
q !== l && (l = q, s.push(Y));
|
|
172
172
|
}), s;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
class
|
|
175
|
+
class St extends st {
|
|
176
176
|
constructor(t) {
|
|
177
177
|
super();
|
|
178
|
-
|
|
178
|
+
G(this, "token");
|
|
179
179
|
this.token = t;
|
|
180
180
|
}
|
|
181
|
-
async realTimePosition(t,
|
|
182
|
-
const
|
|
181
|
+
async realTimePosition(t, n = {}) {
|
|
182
|
+
const c = "https://api.hifleet.com/position/position/get/token", o = {
|
|
183
183
|
searchParams: {
|
|
184
184
|
mmsi: t,
|
|
185
185
|
usertoken: this.token
|
|
186
186
|
}
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
const s =
|
|
187
|
+
}, a = await L.post(c, o).json();
|
|
188
|
+
M == null || M.info("[%s] fetch realtime position from: %s - %j", n.requestId, c, o);
|
|
189
|
+
const s = a == null ? void 0 : a.list;
|
|
190
190
|
if (!s)
|
|
191
|
-
return
|
|
192
|
-
for (const
|
|
193
|
-
!isNaN(s[
|
|
191
|
+
return M == null || M.warn("[%s] fetch realtime position failed: %j", n.requestId, c, a), a;
|
|
192
|
+
for (const y in s)
|
|
193
|
+
!isNaN(s[y]) && Number(s[y]) !== 1 / 0 && (s[y] = Number(s[y]));
|
|
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), m = w(`${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,
|
|
@@ -209,18 +209,18 @@ class wt extends U {
|
|
|
209
209
|
rot: isNaN(s.rot) ? 0 : s.rot,
|
|
210
210
|
eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta) ? w.utc(s.eta).format() : void 0,
|
|
211
211
|
destination: s.destination,
|
|
212
|
-
positionTime:
|
|
213
|
-
utc:
|
|
212
|
+
positionTime: m.unix(),
|
|
213
|
+
utc: m.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
|
};
|
|
220
220
|
}
|
|
221
|
-
async search(t,
|
|
222
|
-
let
|
|
223
|
-
const
|
|
221
|
+
async search(t, n = {}) {
|
|
222
|
+
let c = "https://www.hifleet.com/hifleetapi/searchVesselOL.do";
|
|
223
|
+
const o = {
|
|
224
224
|
searchParams: {
|
|
225
225
|
keyword: t
|
|
226
226
|
},
|
|
@@ -230,24 +230,24 @@ class wt extends U {
|
|
|
230
230
|
Host: "www.hifleet.com"
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
|
-
let
|
|
234
|
-
|
|
235
|
-
for (const d in
|
|
236
|
-
!isNaN(
|
|
233
|
+
let a = await L.post(c, o).json();
|
|
234
|
+
M == null || M.info("[%s] fetch vessel props from: %s - %j", n.requestId, c, o), a instanceof Array && (a = a[0]);
|
|
235
|
+
for (const d in a)
|
|
236
|
+
!isNaN(a[d]) && Number(a[d]) !== 1 / 0 && (a[d] = Number(a[d]));
|
|
237
237
|
const s = {
|
|
238
|
-
mmsi:
|
|
239
|
-
name:
|
|
240
|
-
imo:
|
|
241
|
-
callSign:
|
|
242
|
-
length:
|
|
243
|
-
breadth:
|
|
244
|
-
draught:
|
|
245
|
-
type:
|
|
238
|
+
mmsi: a.m,
|
|
239
|
+
name: a.n,
|
|
240
|
+
imo: a.i,
|
|
241
|
+
callSign: a.c,
|
|
242
|
+
length: a.l,
|
|
243
|
+
breadth: a.b,
|
|
244
|
+
draught: a.dr,
|
|
245
|
+
type: a.t
|
|
246
246
|
};
|
|
247
|
-
return
|
|
247
|
+
return c = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", a = await L.post(c, o).json(), M == null || M.info("[%s] search vessel dead weight from: %s - %j", n.requestId, c, o), a instanceof Array && (a = a[0]), a && (s.deadweight = Number(a.dwt)), s;
|
|
248
248
|
}
|
|
249
|
-
async suggest(t,
|
|
250
|
-
const
|
|
249
|
+
async suggest(t, n = {}) {
|
|
250
|
+
const c = "https://www.hifleet.com/hifleetapi/getShipSuggest.do", o = {
|
|
251
251
|
searchParams: {
|
|
252
252
|
q: t
|
|
253
253
|
},
|
|
@@ -256,10 +256,10 @@ class wt extends U {
|
|
|
256
256
|
Origin: "https://www.hifleet.com",
|
|
257
257
|
Host: "www.hifleet.com"
|
|
258
258
|
}
|
|
259
|
-
},
|
|
260
|
-
|
|
259
|
+
}, a = await L.post(c, o).json();
|
|
260
|
+
M == null || M.info("[%s] suggest vessel props from: %s - %j", n.requestId, c, o);
|
|
261
261
|
const s = [];
|
|
262
|
-
for (const d of
|
|
262
|
+
for (const d of a)
|
|
263
263
|
s.push({
|
|
264
264
|
mmsi: !d.mmsi || isNaN(d.mmsi) ? null : Number(d.mmsi),
|
|
265
265
|
name: d.name,
|
|
@@ -269,77 +269,77 @@ class wt extends U {
|
|
|
269
269
|
});
|
|
270
270
|
return s.sort((d, r) => r.score - d.score), s;
|
|
271
271
|
}
|
|
272
|
-
async trajectory(t,
|
|
273
|
-
var
|
|
272
|
+
async trajectory(t, n, c, o, a = !0, s = {}) {
|
|
273
|
+
var i, h, C;
|
|
274
274
|
const d = await this.realTimePosition(t, s);
|
|
275
|
-
let r = w(
|
|
276
|
-
const
|
|
277
|
-
if (
|
|
278
|
-
let
|
|
279
|
-
|
|
275
|
+
let r = w(n);
|
|
276
|
+
const u = w(c), m = w();
|
|
277
|
+
if (a) {
|
|
278
|
+
let g = u.diff(r, "d", !0);
|
|
279
|
+
g < 0 ? r = u.clone().subtract(40, "d") : g < 30 ? r.subtract(10, "d") : g < 60 ? r.subtract(5, "d") : r = u.clone().subtract(80, "d"), g = m.diff(u, "d", !0), u.add(g > 10 ? 240 : g * 24, "h");
|
|
280
280
|
}
|
|
281
281
|
const l = {
|
|
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
|
-
},
|
|
289
|
-
|
|
290
|
-
let
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
let
|
|
294
|
-
const
|
|
295
|
-
for (const
|
|
296
|
-
for (const
|
|
297
|
-
!isNaN(
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
const { labelEn:
|
|
301
|
-
mmsi:
|
|
302
|
-
name:
|
|
288
|
+
}, y = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token", f = await L.get(y, l).json();
|
|
289
|
+
M == null || M.info("[%s] fetch trajectory from: %s - %j", s.requestId, y, l);
|
|
290
|
+
let S;
|
|
291
|
+
f && (S = ((h = (i = f.ships) == null ? void 0 : i.offors) == null ? void 0 : h.ship) || [], S.length || M == null || M.warn("[%s] fetch trajectory failed: %j", s.requestId, f));
|
|
292
|
+
const I = [];
|
|
293
|
+
let b = -1;
|
|
294
|
+
const v = w(`${(C = S == null ? void 0 : S[0]) == null ? void 0 : C.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
295
|
+
for (const g of S) {
|
|
296
|
+
for (const x in g)
|
|
297
|
+
!isNaN(g[x]) && Number(g[x]) !== 1 / 0 && (g[x] = Number(g[x]));
|
|
298
|
+
const D = w(`${g.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
|
|
299
|
+
g.status = g.sp > 4 ? 0 : 1;
|
|
300
|
+
const { labelEn: Y, labelCn: q } = this.parseStatus(g.status), E = {
|
|
301
|
+
mmsi: g.m,
|
|
302
|
+
name: g.n,
|
|
303
303
|
imo: d == null ? void 0 : d.imo,
|
|
304
|
-
lat:
|
|
305
|
-
lng:
|
|
306
|
-
draught:
|
|
307
|
-
sog:
|
|
308
|
-
cog:
|
|
309
|
-
hdg:
|
|
310
|
-
positionTime:
|
|
311
|
-
utc:
|
|
312
|
-
status:
|
|
313
|
-
labelCn:
|
|
314
|
-
labelEn:
|
|
304
|
+
lat: g.la,
|
|
305
|
+
lng: g.lo,
|
|
306
|
+
draught: g.draught,
|
|
307
|
+
sog: g.sp,
|
|
308
|
+
cog: g.co,
|
|
309
|
+
hdg: g.hdg,
|
|
310
|
+
positionTime: D.unix(),
|
|
311
|
+
utc: D.utc().format(),
|
|
312
|
+
status: g.status,
|
|
313
|
+
labelCn: q,
|
|
314
|
+
labelEn: Y,
|
|
315
315
|
method: "trajectory",
|
|
316
316
|
vendor: "hifleet"
|
|
317
|
-
},
|
|
318
|
-
|
|
317
|
+
}, k = Math.floor(D.diff(v, "minute", !0) / (o || 1));
|
|
318
|
+
k !== b && (b = k, I.push(E));
|
|
319
319
|
}
|
|
320
|
-
return
|
|
320
|
+
return I;
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
class
|
|
323
|
+
class Yt extends st {
|
|
324
324
|
constructor(t) {
|
|
325
325
|
super();
|
|
326
|
-
|
|
326
|
+
G(this, "token");
|
|
327
327
|
this.token = t;
|
|
328
328
|
}
|
|
329
|
-
async realTimePosition(t,
|
|
330
|
-
const
|
|
329
|
+
async realTimePosition(t, n = {}) {
|
|
330
|
+
const c = {
|
|
331
331
|
searchParams: {
|
|
332
332
|
id: t,
|
|
333
333
|
k: this.token,
|
|
334
334
|
enc: 1
|
|
335
335
|
}
|
|
336
|
-
},
|
|
337
|
-
if (
|
|
338
|
-
return
|
|
339
|
-
const s =
|
|
336
|
+
}, o = "https://api.shipxy.com/apicall/GetSingleShip", a = await L.get(o, c).json();
|
|
337
|
+
if (M == null || M.info("[%s] fetch realtime position from: %s - %j", n.requestId, o, c), (a == null ? void 0 : a.status) !== 0)
|
|
338
|
+
return a;
|
|
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),
|
|
342
|
+
const { labelCn: d, labelEn: r } = await this.parseStatus(s.navistat), u = w.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,
|
|
@@ -363,71 +363,71 @@ class pt extends U {
|
|
|
363
363
|
vendor: "shipxy"
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
async trajectory(t,
|
|
367
|
-
var
|
|
368
|
-
const d = await this.realTimePosition(t, s), r = w(
|
|
366
|
+
async trajectory(t, n, c, o, a = !0, s = {}) {
|
|
367
|
+
var v;
|
|
368
|
+
const d = await this.realTimePosition(t, s), r = w(n), u = w(c), m = "https://api.shipxy.com/apicall/GetShipTrack", l = {
|
|
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
|
-
},
|
|
378
|
-
if (
|
|
379
|
-
return
|
|
380
|
-
const
|
|
381
|
-
let
|
|
382
|
-
for (const
|
|
383
|
-
const
|
|
377
|
+
}, y = await L.get(m, l).json();
|
|
378
|
+
if (M == null || M.info("[%s] fetch trajectory from: %s - %j", s.requestId, m, l), (y == null ? void 0 : y.status) !== 0)
|
|
379
|
+
return y;
|
|
380
|
+
const f = y == null ? void 0 : y.points, S = [], I = w.unix((v = f[0]) == null ? void 0 : v.utc);
|
|
381
|
+
let b = -1;
|
|
382
|
+
for (const i of f) {
|
|
383
|
+
const h = w.unix(i.utc), C = {
|
|
384
384
|
imo: d == null ? void 0 : d.imo,
|
|
385
385
|
mmsi: t,
|
|
386
|
-
sog: Math.round(
|
|
387
|
-
cog: Math.round(
|
|
388
|
-
lat: Math.round(
|
|
389
|
-
lng: Math.round(
|
|
390
|
-
positionTime:
|
|
391
|
-
utc:
|
|
386
|
+
sog: Math.round(i.sog * 3600 / 1e3 / 1852 * 100) / 100,
|
|
387
|
+
cog: Math.round(i.cog / 100 * 100) / 100,
|
|
388
|
+
lat: Math.round(i.lat / 1e6 * 1e5) / 1e5,
|
|
389
|
+
lng: Math.round(i.lon / 1e6 * 1e5) / 1e5,
|
|
390
|
+
positionTime: h.unix(),
|
|
391
|
+
utc: h.utc().format(),
|
|
392
392
|
method: "trajectory",
|
|
393
393
|
vendor: "shipxy"
|
|
394
|
-
},
|
|
395
|
-
|
|
394
|
+
}, g = Math.floor(h.diff(I, "minute", !0) / (o || 1));
|
|
395
|
+
g !== b && (b = g, S.push(C));
|
|
396
396
|
}
|
|
397
|
-
return
|
|
397
|
+
return S;
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
class
|
|
400
|
+
class jt extends st {
|
|
401
401
|
constructor(t) {
|
|
402
402
|
super();
|
|
403
|
-
|
|
403
|
+
G(this, "token");
|
|
404
404
|
this.token = t;
|
|
405
405
|
}
|
|
406
|
-
async getShipId(t,
|
|
407
|
-
const
|
|
406
|
+
async getShipId(t, n = {}) {
|
|
407
|
+
const c = {
|
|
408
408
|
headers: {
|
|
409
409
|
appKey: this.token
|
|
410
410
|
},
|
|
411
411
|
json: {
|
|
412
412
|
mmsiList: t
|
|
413
413
|
}
|
|
414
|
-
},
|
|
415
|
-
return
|
|
414
|
+
}, o = "https://api3.myships.com/sp/ships/getShipIdByMMSI", a = await L.post(o, c).json();
|
|
415
|
+
return M == null || M.info("[%s] fetch ship id from: %s - %j", n.requestId, o, c), a.code !== "0" ? a : a.data[0].shipId;
|
|
416
416
|
}
|
|
417
|
-
async getShipInfo(t,
|
|
418
|
-
const
|
|
417
|
+
async getShipInfo(t, n = {}) {
|
|
418
|
+
const c = {
|
|
419
419
|
headers: {
|
|
420
420
|
appKey: this.token
|
|
421
421
|
},
|
|
422
422
|
json: {
|
|
423
423
|
shipId: t
|
|
424
424
|
}
|
|
425
|
-
},
|
|
426
|
-
if (
|
|
427
|
-
return
|
|
428
|
-
const s =
|
|
425
|
+
}, o = "https://api3.myships.com/sp/ships/aissta", a = await L.post(o, c).json();
|
|
426
|
+
if (M == null || M.info("[%s] fetch ship info from: %s - %j", n.requestId, o, c), a.code !== "0")
|
|
427
|
+
return a;
|
|
428
|
+
const s = a.data;
|
|
429
429
|
let d = s.imo;
|
|
430
|
-
return t === "407170" && (d = "9198379",
|
|
430
|
+
return t === "407170" && (d = "9198379", M == null || M.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,
|
|
@@ -437,22 +437,22 @@ class It extends U {
|
|
|
437
437
|
draught: (s.draught || 100) / 10
|
|
438
438
|
};
|
|
439
439
|
}
|
|
440
|
-
async realTimePosition(t,
|
|
441
|
-
const
|
|
440
|
+
async realTimePosition(t, n = {}) {
|
|
441
|
+
const c = await this.getShipId(t, n), o = await this.getShipInfo(c, n), a = {
|
|
442
442
|
headers: {
|
|
443
443
|
appKey: this.token
|
|
444
444
|
},
|
|
445
445
|
json: {
|
|
446
|
-
shipId:
|
|
446
|
+
shipId: c
|
|
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 L.post(s, a).json();
|
|
449
|
+
M == null || M.info("[%s] fetch realtime position from: %s - %j", n.requestId, s, a);
|
|
450
450
|
const r = d.data[0];
|
|
451
|
-
for (const
|
|
452
|
-
!isNaN(r[
|
|
453
|
-
const { labelCn:
|
|
451
|
+
for (const f in r)
|
|
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 = w.unix(r.posTime);
|
|
454
454
|
return {
|
|
455
|
-
...
|
|
455
|
+
...o,
|
|
456
456
|
mmsi: t,
|
|
457
457
|
lat: Math.round(r.lat / 1e4 / 60 * 1e5) / 1e5,
|
|
458
458
|
lng: Math.round(r.lon / 1e4 / 60 * 1e5) / 1e5,
|
|
@@ -463,65 +463,65 @@ class It extends U {
|
|
|
463
463
|
positionTime: r.posTime,
|
|
464
464
|
utc: l.utc().format(),
|
|
465
465
|
status: r.aisNavStatus,
|
|
466
|
-
labelEn:
|
|
467
|
-
labelCn:
|
|
466
|
+
labelEn: m,
|
|
467
|
+
labelCn: u,
|
|
468
468
|
method: "position",
|
|
469
469
|
vendor: "myship"
|
|
470
470
|
};
|
|
471
471
|
}
|
|
472
|
-
async trajectory(t,
|
|
473
|
-
const d = w(
|
|
472
|
+
async trajectory(t, n, c, o, a = !0, s = {}) {
|
|
473
|
+
const d = w(n), r = w(c), u = await this.getShipId(t), m = await this.getShipInfo(u), l = [];
|
|
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(), m, t, o, l);
|
|
476
|
+
return await this.trajectoryIn30Day(u, d.unix(), r.unix(), m, t, o, l), l;
|
|
477
477
|
}
|
|
478
|
-
async trajectoryIn30Day(t,
|
|
479
|
-
var
|
|
480
|
-
const
|
|
478
|
+
async trajectoryIn30Day(t, n, c, o, a, s, d, r = {}) {
|
|
479
|
+
var I;
|
|
480
|
+
const u = {
|
|
481
481
|
headers: {
|
|
482
482
|
appKey: this.token
|
|
483
483
|
},
|
|
484
484
|
json: {
|
|
485
485
|
shipId: t,
|
|
486
|
-
startTime:
|
|
487
|
-
endTime:
|
|
486
|
+
startTime: n,
|
|
487
|
+
endTime: c
|
|
488
488
|
}
|
|
489
|
-
},
|
|
490
|
-
if (
|
|
491
|
-
return
|
|
492
|
-
const
|
|
493
|
-
for (const
|
|
494
|
-
!isNaN(
|
|
495
|
-
const
|
|
496
|
-
let
|
|
497
|
-
for (const
|
|
498
|
-
const
|
|
499
|
-
imo:
|
|
500
|
-
mmsi:
|
|
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:
|
|
489
|
+
}, m = "https://api3.myships.com/sp/ships/position/history", l = await L.post(m, u).json();
|
|
490
|
+
if (M == null || M.info("[%s] fetch trajectory from: %s - %j", r.requestId, m, u), l.code !== "0")
|
|
491
|
+
return M == null || M.warn("[%s] invoke myship trajectory failed: %j", r.requestId, l), l;
|
|
492
|
+
const y = l.data;
|
|
493
|
+
for (const b in y)
|
|
494
|
+
!isNaN(y[b]) && Number(y[b]) !== 1 / 0 && (y[b] = Number(y[b]));
|
|
495
|
+
const f = w.unix((I = y[0]) == null ? void 0 : I.posTime);
|
|
496
|
+
let S = -1;
|
|
497
|
+
for (const b of y) {
|
|
498
|
+
const v = w.unix(b.posTime), i = {
|
|
499
|
+
imo: o == null ? void 0 : o.imo,
|
|
500
|
+
mmsi: a,
|
|
501
|
+
lat: Math.round(b.lat / 1e4 / 60 * 1e5) / 1e5,
|
|
502
|
+
lng: Math.round(b.lon / 1e4 / 60 * 1e5) / 1e5,
|
|
503
|
+
sog: Math.round(b.sog / 10 * 100) / 100,
|
|
504
|
+
cog: Math.round(b.cog / 10 * 100) / 100,
|
|
505
|
+
hdg: Math.round(b.heading * 100) / 100,
|
|
506
|
+
rot: Math.round(b.rot * 100) / 100,
|
|
507
|
+
positionTime: v.unix(),
|
|
508
|
+
utc: v.utc().format(),
|
|
509
509
|
method: "trajectory",
|
|
510
510
|
vendor: "myship"
|
|
511
|
-
},
|
|
512
|
-
|
|
511
|
+
}, h = Math.floor(v.diff(f, "minute", !0) / (s || 1));
|
|
512
|
+
h !== S && (S = h, d.push(i));
|
|
513
513
|
}
|
|
514
514
|
return d;
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
|
-
let
|
|
517
|
+
let V;
|
|
518
518
|
try {
|
|
519
|
-
|
|
519
|
+
V = at.getLogger("vessel");
|
|
520
520
|
} catch {
|
|
521
521
|
} finally {
|
|
522
522
|
}
|
|
523
|
-
var
|
|
524
|
-
class
|
|
523
|
+
var ut = /* @__PURE__ */ ((j) => (j.NOTICE = "NOTICE", j.WARN = "WARN", j.HEAVY = "HEAVY", j.SEVERE = "SEVERE", j.ERROR = "ERROR", j.FATAL = "FATAL", j))(ut || {});
|
|
524
|
+
class ht {
|
|
525
525
|
/**
|
|
526
526
|
* 解析告警规则, 多规则场景
|
|
527
527
|
* @param rule
|
|
@@ -532,22 +532,22 @@ class rt {
|
|
|
532
532
|
*/
|
|
533
533
|
parsePrinciple(e, t = {}) {
|
|
534
534
|
var s, d, r;
|
|
535
|
-
|
|
536
|
-
const
|
|
537
|
-
if (!
|
|
535
|
+
V == null || V.info("[%s] parse rule: %s", t.requestId, e);
|
|
536
|
+
const n = new RegExp("(?<=\\[)(.+)(?=])", "g"), c = e.match(n) ? (s = e.match(n)) == null ? void 0 : s[0] : void 0, o = c == null ? void 0 : c.split(";");
|
|
537
|
+
if (!o)
|
|
538
538
|
return;
|
|
539
|
-
const
|
|
540
|
-
for (let
|
|
541
|
-
const
|
|
542
|
-
if (
|
|
543
|
-
|
|
544
|
-
else if (
|
|
545
|
-
for (let l = 0,
|
|
546
|
-
const
|
|
547
|
-
|
|
539
|
+
const a = {};
|
|
540
|
+
for (let u = 0; u < (o == null ? void 0 : o.length); u++) {
|
|
541
|
+
const m = (r = (d = o[u].match(n)) == null ? void 0 : d[0]) == null ? void 0 : r.split("],");
|
|
542
|
+
if (u === 0 && !m)
|
|
543
|
+
a.scope = o[0];
|
|
544
|
+
else if (m)
|
|
545
|
+
for (let l = 0, y = m.length; l < y; l++) {
|
|
546
|
+
const f = this.parseRule(m[l]);
|
|
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
|
}
|
|
549
549
|
}
|
|
550
|
-
return
|
|
550
|
+
return a;
|
|
551
551
|
}
|
|
552
552
|
/**
|
|
553
553
|
* 解析单一告警规则
|
|
@@ -556,16 +556,16 @@ class rt {
|
|
|
556
556
|
* @param options
|
|
557
557
|
*/
|
|
558
558
|
parseRule(e, t = {}) {
|
|
559
|
-
var
|
|
560
|
-
|
|
561
|
-
const
|
|
562
|
-
if (
|
|
559
|
+
var a;
|
|
560
|
+
V == null || V.info("[%s] parse rule: %s", t.requestId, e), e = e.startsWith("[") ? e : `[${e}`, e = e.endsWith("]") ? e : `${e}]`;
|
|
561
|
+
const n = new RegExp("(?<=\\[)(.+?)(?=])", "g"), c = (a = e == null ? void 0 : e.match(n)) == null ? void 0 : a[0], o = c == null ? void 0 : c.split(",");
|
|
562
|
+
if (o)
|
|
563
563
|
return {
|
|
564
|
-
operator:
|
|
565
|
-
number: Number.isNaN(Number(
|
|
566
|
-
level:
|
|
567
|
-
time: Number(
|
|
568
|
-
key:
|
|
564
|
+
operator: o[0],
|
|
565
|
+
number: Number.isNaN(Number(o[1])) ? o[1] : Number(o[1]),
|
|
566
|
+
level: o[2],
|
|
567
|
+
time: Number(o[3]),
|
|
568
|
+
key: o[4]
|
|
569
569
|
};
|
|
570
570
|
}
|
|
571
571
|
/**
|
|
@@ -574,27 +574,27 @@ class rt {
|
|
|
574
574
|
* @param principle 告警规则
|
|
575
575
|
* @param options
|
|
576
576
|
*/
|
|
577
|
-
checkWeather(e, t,
|
|
578
|
-
var
|
|
579
|
-
let
|
|
580
|
-
const d = Math.round(((
|
|
581
|
-
for (let
|
|
582
|
-
const
|
|
583
|
-
s =
|
|
577
|
+
checkWeather(e, t, n = {}) {
|
|
578
|
+
var f, S, I, b, v, i, h, C, g, D, Y, q, E, k, x;
|
|
579
|
+
let c = 0, o = 0, a = 0, s = 0;
|
|
580
|
+
const d = Math.round(((S = (f = t == null ? void 0 : t.SEVERE) == null ? void 0 : f.sigWave) == null ? void 0 : S.number) * 1.6 * 100) / 100, r = (b = (I = t == null ? void 0 : t.SEVERE) == null ? void 0 : I.sigWave) == null ? void 0 : b.number, u = (i = (v = t == null ? void 0 : t.HEAVY) == null ? void 0 : v.sigWave) == null ? void 0 : i.number, m = Math.round((((C = (h = t == null ? void 0 : t.SEVERE) == null ? void 0 : h.wind) == null ? void 0 : C.number) + 2) * 100) / 100, l = (D = (g = t == null ? void 0 : t.SEVERE) == null ? void 0 : g.wind) == null ? void 0 : D.number, y = (q = (Y = t == null ? void 0 : t.HEAVY) == null ? void 0 : Y.wind) == null ? void 0 : q.number;
|
|
581
|
+
for (let P = 0; P < (e == null ? void 0 : e.length); P++) {
|
|
582
|
+
const T = e[P], F = (k = (E = T == null ? void 0 : T.meteo) == null ? void 0 : E.wave) == null ? void 0 : k.sig, W = (x = T == null ? void 0 : T.meteo) == null ? void 0 : x.wind, B = P ? w(T.eta).diff(w(e[P - 1].eta), "hour", !0) : 0;
|
|
583
|
+
s = B > s ? B : s, V == null || V.info("[%s] check sig.wave: %j", n.requestId, { ...F, dgThd4Wv: d, svThd4Wv: r, hvThd4Wv: u }), (F == null ? void 0 : F.height) >= d ? T.isDangerous = !0 : (F == null ? void 0 : F.height) >= r ? T.isSevere = !0 : (F == null ? void 0 : F.height) >= u && (T.isHeavy = !0), V == null || V.info("[%s] check wind: %j", n.requestId, { ...W, dgThd4Wd: m, svThd4Wd: l, hvThd4Wd: y }), (W == null ? void 0 : W.scale) >= m ? (T.isDangerous = !0, delete T.isSevere, delete T.isHeavy) : (W == null ? void 0 : W.scale) > l ? (T.isDangerous || (T.isSevere = !0), delete T.isHeavy) : (W == null ? void 0 : W.scale) === y && !T.isDangerous && !T.isSevere && (T.isHeavy = !0), c += T.isDangerous ? B : 0, o += T.isSevere ? B : 0, a += T.isHeavy ? B : 0;
|
|
584
584
|
}
|
|
585
|
-
return
|
|
585
|
+
return c = Math.round(c * 100) / 100, o = Math.round(o * 100) / 100, a = Math.round(a * 100) / 100, s = Math.round(s), { sample: e, dangerous: c, severe: o, heavy: a, step: s < 3 ? 3 : s, wind: { dgThd4Wd: m, svThd4Wd: l, hvThd4Wd: y }, sig: { dgThd4Wv: d, svThd4Wv: r, hvThd4Wv: u } };
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
|
-
const
|
|
589
|
-
let
|
|
588
|
+
const Ct = new ht();
|
|
589
|
+
let p;
|
|
590
590
|
try {
|
|
591
|
-
|
|
591
|
+
p = at.getLogger("vessel");
|
|
592
592
|
} catch {
|
|
593
593
|
} finally {
|
|
594
594
|
}
|
|
595
|
-
const
|
|
596
|
-
var
|
|
597
|
-
class
|
|
595
|
+
const lt = new rt("", !0);
|
|
596
|
+
var ft = /* @__PURE__ */ ((j) => (j.common = "common", j.container = "container", j.tugs = "tugs", j))(ft || {}), mt = /* @__PURE__ */ ((j) => (j.Ballast = "Ballast", j.Laden = "Laden", j))(mt || {}), yt = /* @__PURE__ */ ((j) => (j.Cp = "CP", j.Perf = "Basis", j.Instruct = "Other", j))(yt || {});
|
|
597
|
+
class A {
|
|
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)
|
|
@@ -607,11 +607,11 @@ class E {
|
|
|
607
607
|
* @param draught 吃水 m
|
|
608
608
|
* @return [0.55, 0.85]
|
|
609
609
|
*/
|
|
610
|
-
static blockCoefficient(e, t,
|
|
611
|
-
let
|
|
612
|
-
|
|
613
|
-
const
|
|
614
|
-
return
|
|
610
|
+
static blockCoefficient(e, t, n, c) {
|
|
611
|
+
let o = Math.round(e / (t * n * c) * 100) / 100;
|
|
612
|
+
o = o < 0.55 ? 0.55 : o > 0.85 ? 0.85 : o;
|
|
613
|
+
const a = [0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85], s = a.map((d) => Math.abs(d - o));
|
|
614
|
+
return a[s.indexOf(Math.min(...s))];
|
|
615
615
|
}
|
|
616
616
|
/**
|
|
617
617
|
* @see https://baike.baidu.com/item/%E5%BC%97%E5%8A%B3%E5%BE%B7%E6%95%B0/228891?fromModule=search-result_lemma-recommend
|
|
@@ -624,9 +624,9 @@ class E {
|
|
|
624
624
|
* @param g 重力加速度 9.80 m/s^2
|
|
625
625
|
* @return [0.05, 0.30]
|
|
626
626
|
*/
|
|
627
|
-
static froudeNumber(e, t,
|
|
628
|
-
let
|
|
629
|
-
return
|
|
627
|
+
static froudeNumber(e, t, n = 9.8) {
|
|
628
|
+
let c = Math.round(Math.sqrt(e * e / (n * t)) * 100) / 100;
|
|
629
|
+
return c = c < 0.05 ? 0.05 : c > 0.3 ? 0.3 : c, c;
|
|
630
630
|
}
|
|
631
631
|
/**
|
|
632
632
|
* 失速修正系數
|
|
@@ -635,8 +635,8 @@ class E {
|
|
|
635
635
|
* @param loadCondition
|
|
636
636
|
* @private
|
|
637
637
|
*/
|
|
638
|
-
static amendFactor(e, t,
|
|
639
|
-
const
|
|
638
|
+
static amendFactor(e, t, n) {
|
|
639
|
+
const c = {
|
|
640
640
|
0.55: [1.7, -1.4, -7.4],
|
|
641
641
|
0.6: [2.2, -2.5, -9.7],
|
|
642
642
|
0.65: [2.6, -3.7, -11.6],
|
|
@@ -645,7 +645,7 @@ class E {
|
|
|
645
645
|
0.8: [2.6, -13.1, -15.1],
|
|
646
646
|
0.85: [3.1, -18.7, 28]
|
|
647
647
|
};
|
|
648
|
-
let
|
|
648
|
+
let a = {
|
|
649
649
|
0.55: [1.7, -1.4, -7.4],
|
|
650
650
|
0.6: [2.2, -2.5, -9.7],
|
|
651
651
|
0.65: [2.6, -3.7, -11.6],
|
|
@@ -654,7 +654,7 @@ class E {
|
|
|
654
654
|
0.8: [3, -16.3, -21.6],
|
|
655
655
|
0.85: [3.4, -20.9, 31.8]
|
|
656
656
|
}[e];
|
|
657
|
-
return
|
|
657
|
+
return n === "Laden" && (a = c[e]), a[0] + a[1] * t + a[2] * Math.pow(t, 2);
|
|
658
658
|
}
|
|
659
659
|
/**
|
|
660
660
|
* 失速方向因子
|
|
@@ -668,8 +668,8 @@ class E {
|
|
|
668
668
|
* @private
|
|
669
669
|
*/
|
|
670
670
|
static directionFactor(e, t = 0) {
|
|
671
|
-
let
|
|
672
|
-
return e > 30 && e <= 60 ?
|
|
671
|
+
let n;
|
|
672
|
+
return e > 30 && e <= 60 ? n = (1.7 - 0.03 * Math.pow(t - 4, 2)) / 2 : e > 60 && e <= 150 ? n = (0.9 - 0.06 * Math.pow(t - 6, 2)) / 2 : e > 150 && e <= 180 ? n = (0.4 - 0.03 * Math.pow(t - 8, 2)) / 2 : n = 1, Math.round(n * 1e5) / 1e5;
|
|
673
673
|
}
|
|
674
674
|
/**
|
|
675
675
|
* 失速船型因子
|
|
@@ -682,10 +682,10 @@ class E {
|
|
|
682
682
|
* @param bn
|
|
683
683
|
* @private
|
|
684
684
|
*/
|
|
685
|
-
static vesselTagFactor(e, t,
|
|
686
|
-
|
|
687
|
-
let
|
|
688
|
-
return
|
|
685
|
+
static vesselTagFactor(e, t, n, c = 0) {
|
|
686
|
+
c = c > 6 ? c - 0.9 * (c - 6) : c;
|
|
687
|
+
let o;
|
|
688
|
+
return n === "container" ? o = 0.7 * c + Math.pow(c, 6.5) / (22 * Math.pow(e, 2 / 3)) : t === "Ballast" ? o = 0.7 * c + Math.pow(c, 6.5) / (2.7 * Math.pow(e, 2 / 3)) : o = 0.5 * c + Math.pow(c, 6.5) / (2.7 * Math.pow(e, 2 / 3)), o;
|
|
689
689
|
}
|
|
690
690
|
/**
|
|
691
691
|
* 浪高影响因子
|
|
@@ -694,8 +694,8 @@ class E {
|
|
|
694
694
|
*/
|
|
695
695
|
static waveHeightFactor(e, t) {
|
|
696
696
|
e = e < 0 ? 0.2 : e, e = e > 6 ? e - 0.9 * (e - 6) : e, e = e > 9 ? 9 : e;
|
|
697
|
-
let
|
|
698
|
-
return t > 30 && t <= 60 ?
|
|
697
|
+
let n;
|
|
698
|
+
return t > 30 && t <= 60 ? n = -0.6 : t > 60 && t <= 90 ? n = -0.4 : t > 90 && t <= 120 ? n = e < 3 ? 0.4 : -0.3 : t > 120 && t <= 150 ? n = e < 3 ? 0.6 : -0.5 : t > 150 && t <= 180 ? n = e < 3 ? 0.7 : -0.6 : n = -0.7, Math.round(n * (0.144 * Math.pow(e, 2) + 0.178 * e) * 1e4) / 1e4;
|
|
699
699
|
}
|
|
700
700
|
/**
|
|
701
701
|
* 组装船舶运行参数
|
|
@@ -705,21 +705,21 @@ class E {
|
|
|
705
705
|
* @param bearing 方位角
|
|
706
706
|
* @private
|
|
707
707
|
*/
|
|
708
|
-
static assembleProperties(e, t,
|
|
708
|
+
static assembleProperties(e, t, n, c) {
|
|
709
709
|
var l;
|
|
710
|
-
const
|
|
710
|
+
const o = e.lbp ?? e.length ?? e.lengthOverall ?? 198.9642, a = e.draught ?? 8, s = e.breadthMoulded ?? e.breadth ?? e.breadthExtreme ?? 32.4572, d = e.deadweight ?? 67035.7773, r = ((l = e == null ? void 0 : e.type) == null ? void 0 : l.toLowerCase()) || "common";
|
|
711
711
|
return {
|
|
712
712
|
tag: r.indexOf("container") > -1 ? "container" : r.indexOf("tugs") > -1 ? "tugs" : "common",
|
|
713
|
-
lbp:
|
|
713
|
+
lbp: o,
|
|
714
714
|
loadCondition: t,
|
|
715
|
-
draught:
|
|
715
|
+
draught: a,
|
|
716
716
|
breadthMoulded: s,
|
|
717
717
|
// 排水量(吨)= 载重量(吨)/ 1.025 + 吃水(米)× 船舶型宽(米)× 船舶型长(米)× 0.7
|
|
718
718
|
// 其中,1.025是指海水的密度,吨是指公吨,吃水是指船舶的最大吃水深度。船舶型宽是指船舶的最大型宽,船舶型长是指船舶的设计型长。上述公式是针对常规船舶适用的,不同类型的船舶可能会有一些差异。
|
|
719
|
-
displacement: Math.round((d / 1.025 +
|
|
719
|
+
displacement: Math.round((d / 1.025 + a * s * o * 0.7) * 1e4) / 1e4,
|
|
720
720
|
// 换算为m/s
|
|
721
|
-
speed: Math.round((
|
|
722
|
-
bearing:
|
|
721
|
+
speed: Math.round((n ?? 14.1382) * 1852 / 3600 * 1e4) / 1e4,
|
|
722
|
+
bearing: c || 90
|
|
723
723
|
};
|
|
724
724
|
}
|
|
725
725
|
/**
|
|
@@ -732,35 +732,35 @@ class E {
|
|
|
732
732
|
* @param useMeteo true 启用气象分析
|
|
733
733
|
* @param useRouteParam true 启用设置速度
|
|
734
734
|
*/
|
|
735
|
-
static async speedLoseAt(e, t,
|
|
735
|
+
static async speedLoseAt(e, t, n, c = "", o = 2, a = !0, s = !1, d = {}) {
|
|
736
736
|
let r;
|
|
737
|
-
if (t.velocity && s && (e.speed =
|
|
738
|
-
let
|
|
737
|
+
if (t.velocity && s && (e.speed = Z.roundPrecision(t.velocity * 1852 / 3600, 6)), a) {
|
|
738
|
+
let u;
|
|
739
739
|
if (d.meteo2)
|
|
740
740
|
try {
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
} catch (
|
|
744
|
-
|
|
741
|
+
const f = await lt.spotForecast(t.lat, t.lng, n.utc().format(), !1, !1, !0, d), [S] = nt.pickHourly(f, n);
|
|
742
|
+
u = nt.toLegacy(S);
|
|
743
|
+
} catch (f) {
|
|
744
|
+
p.warn("[%s] meteo2 spot(%j) forecast failed: %s", d.requestId, { ...t, eta: n.utc().format() }, f);
|
|
745
745
|
}
|
|
746
746
|
else
|
|
747
|
-
|
|
748
|
-
const
|
|
747
|
+
u = await dt.queryPointFactor(t.lng, t.lat, n.valueOf(), "wind,wave,current,watertemp", c, d);
|
|
748
|
+
const m = A.weatherFactor(e, u), l = A.currentFactor(e.bearing, u == null ? void 0 : u.current, o), y = Math.round((e.speed * 1.943844 + m + l) * 100) / 100;
|
|
749
749
|
r = {
|
|
750
|
-
meteo: { ...
|
|
751
|
-
wxFactor:
|
|
750
|
+
meteo: { ...u },
|
|
751
|
+
wxFactor: m,
|
|
752
752
|
cFactor: l,
|
|
753
|
-
speed: t.velocity && s ? t.velocity :
|
|
754
|
-
eta:
|
|
755
|
-
etd:
|
|
753
|
+
speed: t.velocity && s ? t.velocity : y < 0 ? 1 : y,
|
|
754
|
+
eta: n.utc().format("YYYY-MM-DDTHH:mm[Z]"),
|
|
755
|
+
etd: n.utc().format("YYYY-MM-DDTHH:mm[Z]")
|
|
756
756
|
};
|
|
757
757
|
} else
|
|
758
758
|
r = {
|
|
759
759
|
wxFactor: 0,
|
|
760
760
|
cFactor: 0,
|
|
761
761
|
speed: t.velocity && s ? t.velocity : Math.round((e.speed * 1.943844 + 0 + 0) * 100) / 100,
|
|
762
|
-
eta:
|
|
763
|
-
etd:
|
|
762
|
+
eta: n.utc().format("YYYY-MM-DDTHH:mm[Z]"),
|
|
763
|
+
etd: n.utc().format("YYYY-MM-DDTHH:mm[Z]")
|
|
764
764
|
};
|
|
765
765
|
return delete t.meteo, delete t.wxFactor, delete t.cFactor, delete t.speed, delete t.etd, { ...r, ...t };
|
|
766
766
|
}
|
|
@@ -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,
|
|
780
|
+
static async speedLoseInHoursStep(e, t, n, c, o, a, s = "", d = !0, r = !1, u = {}) {
|
|
781
781
|
t.utc();
|
|
782
|
-
const
|
|
783
|
-
let
|
|
784
|
-
for (let
|
|
785
|
-
let
|
|
786
|
-
|
|
787
|
-
const
|
|
788
|
-
if (e.bearing =
|
|
789
|
-
|
|
790
|
-
const
|
|
791
|
-
if (
|
|
792
|
-
|
|
782
|
+
const m = t.clone().add(14, "days"), l = [], y = [];
|
|
783
|
+
let f = 0, S = 0, I, b;
|
|
784
|
+
for (let v = 0; v < a.length - 1; v++) {
|
|
785
|
+
let i = a[v];
|
|
786
|
+
i.distanceFromStart = Math.round((o + S) * 1e4) / 1e4;
|
|
787
|
+
const h = a[v + 1];
|
|
788
|
+
if (e.bearing = R.calculateBearing(i, h, !h.gcToPrevious), i.bearing = e.bearing, i.suspend && r) {
|
|
789
|
+
i.eta = i.eta || t.format("YYYY-MM-DDTHH:mm[Z]"), i.elapsed = i.elapsed ?? 0;
|
|
790
|
+
const D = i.suspend - i.elapsed;
|
|
791
|
+
if (c - f > D)
|
|
792
|
+
c = c - f - D, t.add(D, "hour"), i.elapsed = i.suspend;
|
|
793
793
|
else {
|
|
794
|
-
const
|
|
795
|
-
|
|
794
|
+
const Y = c - f;
|
|
795
|
+
i.elapsed += Y, t.add(Y, "hour"), c = 0;
|
|
796
796
|
}
|
|
797
|
-
if (
|
|
798
|
-
return
|
|
797
|
+
if (p == null || p.info(`[%s] suspend ${i.elapsed} hours at %j, and remain ${c} hours need to go...`, u.requestId, i), c === 0)
|
|
798
|
+
return i.distanceFromPrevious = S, { etd: t, from: b || i, to: i, next: a.filter((Y) => Y), wps: l, days: y };
|
|
799
799
|
} else
|
|
800
|
-
|
|
801
|
-
d = t.isAfter(
|
|
802
|
-
const
|
|
803
|
-
let
|
|
804
|
-
if (
|
|
805
|
-
if (
|
|
806
|
-
`[%s] go to %j from %j with ${
|
|
807
|
-
|
|
808
|
-
{ lat:
|
|
809
|
-
{ lat:
|
|
810
|
-
),
|
|
811
|
-
|
|
800
|
+
i.suspend = 0;
|
|
801
|
+
d = t.isAfter(m) ? !1 : d, i = await A.speedLoseAt(e, i, t, s, 0, d, r, u), b = b || i, i.important && l.push(i), t.isSameOrAfter(n) && (y.push(i), n.add(24, "hour"));
|
|
802
|
+
const C = R.calculateDistance(i, h, !h.gcToPrevious);
|
|
803
|
+
let g = Math.ceil(C / b.speed * 1e4) / 1e4;
|
|
804
|
+
if (f + g < c) {
|
|
805
|
+
if (f += g, t.add(g, "hour"), delete a[v], p == null || p.debug(
|
|
806
|
+
`[%s] go to %j from %j with ${C}nm, and cost ${g} hours`,
|
|
807
|
+
u.requestId,
|
|
808
|
+
{ lat: h.lat, lng: h.lng },
|
|
809
|
+
{ lat: b.lat, lng: b.lng, etd: b.etd }
|
|
810
|
+
), S += C, a.filter((D) => D).length <= 1) {
|
|
811
|
+
I = h, I.eta = t.format("YYYY-MM-DDTHH:mm[Z]"), I.distanceFromPrevious = C, I.distanceFromStart = Math.round((o + S) * 1e4) / 1e4, l.push(I), delete a[v + 1];
|
|
812
812
|
break;
|
|
813
813
|
}
|
|
814
814
|
} else {
|
|
815
|
-
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
`[%s] go to %j from %j with ${
|
|
819
|
-
|
|
820
|
-
{ lat:
|
|
821
|
-
{ lat:
|
|
822
|
-
),
|
|
815
|
+
g = c - f, t.add(g, "hour");
|
|
816
|
+
const D = Z.roundPrecision(b.speed * g, 4);
|
|
817
|
+
I = R.calculateCoordinate(i, e.bearing, D, "nauticalmiles", !h.gcToPrevious), I.eta = t.format("YYYY-MM-DDTHH:mm[Z]"), a[v] = I, p == null || p.debug(
|
|
818
|
+
`[%s] go to %j from %j with ${D}nm, and cost ${g} hours`,
|
|
819
|
+
u.requestId,
|
|
820
|
+
{ lat: I.lat, lng: I.lng },
|
|
821
|
+
{ lat: i.lat, lng: i.lng, etd: i.etd }
|
|
822
|
+
), S += D, I.distanceFromPrevious = Math.round(S * 1e4) / 1e4, I.distanceFromStart = Math.round((o + S) * 1e4) / 1e4;
|
|
823
823
|
break;
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
|
-
return { etd: t, from:
|
|
826
|
+
return { etd: t, from: b, to: I, next: a.filter((v) => v), wps: l, days: y };
|
|
827
827
|
}
|
|
828
828
|
/**
|
|
829
829
|
* 洋流影响因子
|
|
@@ -831,12 +831,12 @@ class E {
|
|
|
831
831
|
* @param current 洋流要素
|
|
832
832
|
* @param role 1: 船东, 2: 租家, 0: 未知
|
|
833
833
|
*/
|
|
834
|
-
static currentFactor(e, t,
|
|
835
|
-
const
|
|
836
|
-
if (Math.abs(
|
|
834
|
+
static currentFactor(e, t, n = 0) {
|
|
835
|
+
const c = (e - (t == null ? void 0 : t.degree) || 0) / 180 * Math.PI;
|
|
836
|
+
if (Math.abs(c) === Math.PI / 2)
|
|
837
837
|
return 0;
|
|
838
|
-
let
|
|
839
|
-
return
|
|
838
|
+
let o = ((t == null ? void 0 : t.kts) || 0) * Math.cos(c);
|
|
839
|
+
return n & 2 ? o = Math.ceil(o * 100) / 100 : n & 1 ? o = Math.floor(o * 100) / 100 : o = Math.round(o * 100) / 100, Math.abs(o) > 5 ? 0 : o;
|
|
840
840
|
}
|
|
841
841
|
/**
|
|
842
842
|
* 风浪影响因子
|
|
@@ -844,16 +844,16 @@ class E {
|
|
|
844
844
|
* @param wwc 气象要素
|
|
845
845
|
*/
|
|
846
846
|
static weatherFactor(e, t) {
|
|
847
|
-
var
|
|
848
|
-
|
|
849
|
-
const
|
|
850
|
-
let
|
|
851
|
-
|
|
852
|
-
const s =
|
|
853
|
-
let r = s *
|
|
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
|
|
847
|
+
var m, l, y, f, S, I, b;
|
|
848
|
+
p == null || p.debug("calculate weather factor via: %j", { ...e, ...t });
|
|
849
|
+
const n = A.blockCoefficient(e.displacement, e.lbp, e.breadthMoulded, e.draught), c = A.froudeNumber(e.speed, e.lbp), o = A.amendFactor(n, c, e.loadCondition);
|
|
850
|
+
let a = Math.abs(e.bearing % 360 - (((m = t == null ? void 0 : t.wind) == null ? void 0 : m.degree) % 360 || 0));
|
|
851
|
+
a = a > 180 ? 360 - a : a;
|
|
852
|
+
const s = A.directionFactor(a, (l = t == null ? void 0 : t.wind) == null ? void 0 : l.scale), d = A.vesselTagFactor(e.displacement, e.loadCondition, e.tag, (y = t == null ? void 0 : t.wind) == null ? void 0 : y.scale);
|
|
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)), p == null || p.debug("wind wx factor = %d", r), a = Math.abs(e.bearing % 360 - (((S = (f = t == null ? void 0 : t.wave) == null ? void 0 : f.sig) == null ? void 0 : S.degree) % 360 || 0));
|
|
855
|
+
const u = A.waveHeightFactor(((b = (I = t == null ? void 0 : t.wave) == null ? void 0 : I.sig) == null ? void 0 : b.height) ?? 1, a);
|
|
856
|
+
return p == null || p.debug("wave wx factor = %d", u), r = r * 0.4 + u, p == null || p.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,74 +867,74 @@ class E {
|
|
|
867
867
|
* @param useMeteo true 启用气象分析
|
|
868
868
|
* @param useRouteParam
|
|
869
869
|
*/
|
|
870
|
-
static async analyseInstant(e, t,
|
|
871
|
-
var
|
|
872
|
-
const
|
|
873
|
-
e.lng =
|
|
874
|
-
const { route: l, waypoints:
|
|
875
|
-
if (((
|
|
870
|
+
static async analyseInstant(e, t, n, c, o, a = "", s = 0, d = !0, r = !1, u = {}) {
|
|
871
|
+
var B, Q, X, $, tt;
|
|
872
|
+
const m = w().valueOf();
|
|
873
|
+
e.lng = Z.convertToStdLng(e.lng);
|
|
874
|
+
const { route: l, waypoints: y } = o.points, f = R.calculateSubRoute(e, l);
|
|
875
|
+
if (((B = f[0]) == null ? void 0 : B.length) <= 1)
|
|
876
876
|
return;
|
|
877
|
-
const { v0:
|
|
877
|
+
const { v0: S, label: I } = e.sog ? {
|
|
878
878
|
v0: e.sog,
|
|
879
879
|
label: "Other"
|
|
880
880
|
/* Instruct */
|
|
881
881
|
} : {
|
|
882
|
-
v0:
|
|
882
|
+
v0: c.speed,
|
|
883
883
|
label: "CP"
|
|
884
884
|
/* Cp */
|
|
885
|
-
},
|
|
886
|
-
|
|
887
|
-
const
|
|
885
|
+
}, b = A.assembleProperties(n, c.loadCondition, S, 0), v = y.length ? R.calculateSubWaypoints(e, y) : [];
|
|
886
|
+
v.forEach((N) => N.important = !0);
|
|
887
|
+
const i = {
|
|
888
888
|
from: { ...e },
|
|
889
|
-
route:
|
|
890
|
-
waypoints:
|
|
891
|
-
v0:
|
|
892
|
-
label:
|
|
893
|
-
},
|
|
889
|
+
route: f,
|
|
890
|
+
waypoints: v,
|
|
891
|
+
v0: S,
|
|
892
|
+
label: I
|
|
893
|
+
}, h = {
|
|
894
894
|
hours: [],
|
|
895
895
|
days: [],
|
|
896
896
|
wps: []
|
|
897
897
|
};
|
|
898
|
-
s || (
|
|
899
|
-
let
|
|
898
|
+
s || (R.calculateRouteDistance(f) / c.speed <= 72 ? s = 3 : s = 6);
|
|
899
|
+
let C = R.simplifyRouteToCoordinates(f, v, 0), g = 0, D = 0, Y = 0, q = 0;
|
|
900
900
|
t = w(t).utc();
|
|
901
|
-
const
|
|
902
|
-
for (;
|
|
903
|
-
const
|
|
904
|
-
|
|
901
|
+
const E = t.clone();
|
|
902
|
+
for (; C.length > 0; ) {
|
|
903
|
+
const N = s - t.hour() % s, J = Math.ceil(t.clone().add(N, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4, H = await A.speedLoseInHoursStep(
|
|
904
|
+
b,
|
|
905
905
|
t,
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
906
|
+
E,
|
|
907
|
+
J,
|
|
908
|
+
g,
|
|
909
|
+
C,
|
|
910
|
+
a,
|
|
911
911
|
d,
|
|
912
912
|
r,
|
|
913
|
-
|
|
913
|
+
u
|
|
914
914
|
);
|
|
915
|
-
(
|
|
915
|
+
(Q = H.from) != null && Q.speed && (h.hours.push(H.from), h.wps.push(...H.wps), h.days.push(...H.days)), C = H == null ? void 0 : H.next, C.length || h.hours.push(H == null ? void 0 : H.to), g += Math.round((((X = H == null ? void 0 : H.to) == null ? void 0 : X.distanceFromPrevious) ?? 0) * 1e4) / 1e4;
|
|
916
916
|
}
|
|
917
|
-
const
|
|
918
|
-
for (let
|
|
919
|
-
const
|
|
920
|
-
|
|
917
|
+
const k = h.hours;
|
|
918
|
+
for (let N = 0; N < k.length - 1; N++) {
|
|
919
|
+
const J = w(k[N + 1].eta).diff(k[N].etd, "hour", !0) || 1;
|
|
920
|
+
D += (k[N].wxFactor || 0) * J, Y += (k[N].cFactor || 0) * J, q += J;
|
|
921
921
|
}
|
|
922
|
-
(
|
|
923
|
-
if (
|
|
924
|
-
const
|
|
925
|
-
if (
|
|
926
|
-
|
|
922
|
+
($ = h.wps) == null || $.forEach((N, J) => {
|
|
923
|
+
if (N.positionTime = w.utc(N.etd || N.eta).unix(), J) {
|
|
924
|
+
const H = h.wps[J - 1], et = N.distanceFromStart - H.distanceFromStart, z = w(N.eta).diff(w(H.etd), "h", !0);
|
|
925
|
+
if (z < 1)
|
|
926
|
+
N.avgSpd = H.speed;
|
|
927
927
|
else {
|
|
928
|
-
|
|
929
|
-
const
|
|
930
|
-
|
|
928
|
+
N.avgSpd = Math.round(et / z * 100) / 100;
|
|
929
|
+
const U = Math.round((H.speed + N.speed) / 2 * 100) / 100;
|
|
930
|
+
N.avgSpd = N.avgSpd > U ? U : N.avgSpd;
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
|
-
}),
|
|
934
|
-
const
|
|
935
|
-
|
|
936
|
-
const
|
|
937
|
-
return
|
|
933
|
+
}), i.sample = h;
|
|
934
|
+
const x = h.hours.at(0), P = h.hours.at(-1);
|
|
935
|
+
i.distance = Math.round(P.distanceFromStart * 1e4) / 1e4, i.etd = w(x.eta).utc().format(), i.eta = w(P.eta).utc().format(), i.wxFactor = Math.round(D / q * 1e4) / 1e4, i.cFactor = Math.round(Y / q * 1e4) / 1e4, i.avgSpeed = Math.round(P.distanceFromStart / q * 1e4) / 1e4, i.totalHrs = Math.round(q * 1e4) / 1e4, i.totalFoCons = Math.round((c == null ? void 0 : c.fo) / 24 * i.totalHrs * 1e3) / 1e3, i.totalDgoCons = Math.round((c == null ? void 0 : c.dgo) / 24 * i.totalHrs * 1e3) / 1e3;
|
|
936
|
+
const F = w().valueOf() - m, W = ((tt = h == null ? void 0 : h.hours) == null ? void 0 : tt.length) || 1;
|
|
937
|
+
return p == null || p.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", u == null ? void 0 : u.requestId, F, W, Math.round(F / W * 1e3) / 1e3), i;
|
|
938
938
|
}
|
|
939
939
|
/**
|
|
940
940
|
* 分段失速分析(最多走hours 小时)
|
|
@@ -949,64 +949,64 @@ class E {
|
|
|
949
949
|
* @param useMeteo true 启用气象分析
|
|
950
950
|
* @param useRouteParam
|
|
951
951
|
*/
|
|
952
|
-
static async analyseInstantWithThreshed(e, t,
|
|
953
|
-
var
|
|
954
|
-
const
|
|
955
|
-
e.lng =
|
|
956
|
-
const { v0:
|
|
952
|
+
static async analyseInstantWithThreshed(e, t, n, c, o, a, s, d = "", r = 3, u = !0, m = !1, l = {}) {
|
|
953
|
+
var et, z, U, ot;
|
|
954
|
+
const y = w().valueOf();
|
|
955
|
+
e.lng = Z.convertToStdLng(e.lng);
|
|
956
|
+
const { v0: f, label: S } = e.sog ? {
|
|
957
957
|
v0: e.sog,
|
|
958
958
|
label: "Other"
|
|
959
959
|
/* Instruct */
|
|
960
960
|
} : {
|
|
961
|
-
v0:
|
|
961
|
+
v0: o.speed,
|
|
962
962
|
label: "CP"
|
|
963
963
|
/* Cp */
|
|
964
|
-
},
|
|
965
|
-
if (((
|
|
964
|
+
}, I = A.assembleProperties(c, o.loadCondition, f, 0), b = R.calculateSubRoute(e, a);
|
|
965
|
+
if (((et = b[0]) == null ? void 0 : et.length) <= 1)
|
|
966
966
|
return;
|
|
967
|
-
const
|
|
968
|
-
|
|
969
|
-
let
|
|
970
|
-
const
|
|
967
|
+
const v = s.length ? R.calculateSubWaypoints(e, s) : [];
|
|
968
|
+
v.forEach((_) => _.important = !0);
|
|
969
|
+
let i = R.simplifyRouteToCoordinates(b, v, 0), h = 0, C = 0, g = 0, D = 0;
|
|
970
|
+
const Y = {
|
|
971
971
|
hours: [],
|
|
972
972
|
wps: [],
|
|
973
973
|
days: []
|
|
974
974
|
};
|
|
975
975
|
t = w(t).utc();
|
|
976
|
-
const
|
|
977
|
-
for (;
|
|
978
|
-
const
|
|
979
|
-
let
|
|
980
|
-
|
|
981
|
-
const
|
|
982
|
-
if ((
|
|
976
|
+
const q = t.clone();
|
|
977
|
+
for (; i.length > 0; ) {
|
|
978
|
+
const _ = r - t.hour() % r;
|
|
979
|
+
let K = Math.ceil(t.clone().add(_, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4;
|
|
980
|
+
K = t.clone().add(K, "h").isSameOrAfter(n) ? n.diff(t, "h", !0) * 1e4 / 1e4 : K;
|
|
981
|
+
const O = await A.speedLoseInHoursStep(I, t, q, K, h, i, d, u, m, l);
|
|
982
|
+
if ((z = O.from) != null && z.speed && (Y.hours.push(O.from), O != null && O.wps && Y.wps.push(...O.wps), Y.days.push(...O.days)), i = O == null ? void 0 : O.next, i.length || Y.hours.push(O == null ? void 0 : O.to), h += Math.round((((U = O == null ? void 0 : O.to) == null ? void 0 : U.distanceFromPrevious) ?? 0) * 1e4) / 1e4, !K)
|
|
983
983
|
break;
|
|
984
984
|
}
|
|
985
|
-
const
|
|
986
|
-
for (let
|
|
987
|
-
const
|
|
988
|
-
|
|
985
|
+
const E = Y.hours;
|
|
986
|
+
for (let _ = 0; _ < E.length - 1; _++) {
|
|
987
|
+
const K = w(E[_ + 1].eta).diff(E[_].etd, "hour", !0);
|
|
988
|
+
C += E[_].wxFactor * K, g += E[_].cFactor * K, D += K;
|
|
989
989
|
}
|
|
990
|
-
const
|
|
991
|
-
sample:
|
|
992
|
-
distance: Math.round(((
|
|
990
|
+
const k = Y.hours.at(0), x = Y.hours.at(-1), P = await R.calculateRangeRoute(k, x, b), T = await R.calculateRangeWaypoints(k, x, b, v), F = {
|
|
991
|
+
sample: Y,
|
|
992
|
+
distance: Math.round(((x == null ? void 0 : x.distanceFromStart) || 0) * 1e4) / 1e4,
|
|
993
993
|
// 注意,可能会在first节点Drift,所有采用eta做为初始出发时间
|
|
994
|
-
etd: w(
|
|
995
|
-
eta: w(
|
|
996
|
-
wxFactor: Math.round(
|
|
997
|
-
cFactor: Math.round(
|
|
998
|
-
avgSpeed: Math.round(((
|
|
999
|
-
totalHrs: Math.round(
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
return
|
|
994
|
+
etd: w(k.eta).utc().format(),
|
|
995
|
+
eta: w(x == null ? void 0 : x.eta).utc().format(),
|
|
996
|
+
wxFactor: Math.round(C / D * 1e4) / 1e4,
|
|
997
|
+
cFactor: Math.round(g / D * 1e4) / 1e4,
|
|
998
|
+
avgSpeed: Math.round(((x == null ? void 0 : x.distanceFromStart) || 0) / D * 1e4) / 1e4,
|
|
999
|
+
totalHrs: Math.round(D * 1e4) / 1e4,
|
|
1000
|
+
from: k,
|
|
1001
|
+
to: x,
|
|
1002
|
+
route: P,
|
|
1003
|
+
waypoints: T,
|
|
1004
|
+
v0: f,
|
|
1005
|
+
label: S
|
|
1006
|
+
}, { distanceInECA: W, hoursInECA: B, totalDgoConsInECA: Q, eca: X } = await this.calculateECA(F, o, l), $ = Z.roundPrecision(o.fo / 24 * (D - B), 3), tt = Z.roundPrecision(o.dgo / 24 * D, 3);
|
|
1007
|
+
F.eca = X, F.distanceInECA = W, F.hoursInECA = B, F.totalDgoConsInECA = Q, F.totalDgoCons = tt, F.totalFoCons = $;
|
|
1008
|
+
const J = w().valueOf() - y, H = ((ot = Y == null ? void 0 : Y.hours) == null ? void 0 : ot.length) || 1;
|
|
1009
|
+
return p == null || p.debug("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", l == null ? void 0 : l.requestId, J, H, Math.round(J / H * 1e3) / 1e3), F;
|
|
1010
1010
|
}
|
|
1011
1011
|
/**
|
|
1012
1012
|
* 在指定航线条件下,基于多CP,动态计算最优成本(租金+油费)方案
|
|
@@ -1023,57 +1023,57 @@ class E {
|
|
|
1023
1023
|
* @param lane 基础航线(重要转向点)
|
|
1024
1024
|
* @param options
|
|
1025
1025
|
*/
|
|
1026
|
-
static async analyseCost(e, t,
|
|
1027
|
-
var
|
|
1028
|
-
const
|
|
1029
|
-
|
|
1030
|
-
const d =
|
|
1026
|
+
static async analyseCost(e, t, n, c, o = {}) {
|
|
1027
|
+
var b, v;
|
|
1028
|
+
const a = w().valueOf(), s = [];
|
|
1029
|
+
o.meteo2 = o.meteo2 || !0, e.speedStep = e.speedStep || 3, e.alterStep = e.alterStep ?? 1;
|
|
1030
|
+
const d = R.calculateRouteDistance(c.route);
|
|
1031
1031
|
let r = 0;
|
|
1032
|
-
|
|
1033
|
-
const
|
|
1034
|
-
r = r <
|
|
1032
|
+
n.forEach((i) => {
|
|
1033
|
+
const h = Math.ceil(d / i.speed / 24);
|
|
1034
|
+
r = r < h ? h : r;
|
|
1035
1035
|
}), r = r * 1.3;
|
|
1036
|
-
const
|
|
1037
|
-
let
|
|
1038
|
-
for (const
|
|
1039
|
-
const
|
|
1036
|
+
const u = w.utc(e.etd).add(r ?? 14, "day");
|
|
1037
|
+
let m = 1;
|
|
1038
|
+
for (const i of n) {
|
|
1039
|
+
const h = JSON.parse(JSON.stringify(c.route)), C = JSON.parse(JSON.stringify(c.waypoints)), g = await A.analyseInstantWithThreshed(
|
|
1040
1040
|
{ lat: e.lat, lng: e.lng },
|
|
1041
1041
|
e.etd,
|
|
1042
|
-
|
|
1042
|
+
u,
|
|
1043
1043
|
t,
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1044
|
+
i,
|
|
1045
|
+
h,
|
|
1046
|
+
C,
|
|
1047
1047
|
e.meteoVendor,
|
|
1048
1048
|
e.speedStep,
|
|
1049
1049
|
e.useMeteo,
|
|
1050
1050
|
e.useRouteParam,
|
|
1051
|
-
|
|
1051
|
+
o
|
|
1052
1052
|
);
|
|
1053
|
-
|
|
1054
|
-
cost:
|
|
1055
|
-
distance:
|
|
1056
|
-
hours:
|
|
1057
|
-
cp: `${
|
|
1058
|
-
})),
|
|
1053
|
+
g && (await A.calculateCost(g, i, e, o), s.push(g), p == null || p.info("[%s][L%d-%d] analyse from %s to %s cost: %j", o.requestId, 1, m, e.etd, u.format(), {
|
|
1054
|
+
cost: g.cost.total,
|
|
1055
|
+
distance: g.distance,
|
|
1056
|
+
hours: g.totalHrs,
|
|
1057
|
+
cp: `${i.speed}/${i.fo}/${i.dgo}`
|
|
1058
|
+
})), m++;
|
|
1059
1059
|
}
|
|
1060
|
-
s.sort((
|
|
1061
|
-
const l = s.at(0),
|
|
1062
|
-
if (
|
|
1063
|
-
const
|
|
1064
|
-
let
|
|
1065
|
-
|
|
1066
|
-
let
|
|
1067
|
-
for (;
|
|
1068
|
-
const
|
|
1069
|
-
if (
|
|
1060
|
+
s.sort((i, h) => i.cost.total - h.cost.total);
|
|
1061
|
+
const l = s.at(0), y = s.at(1), f = [];
|
|
1062
|
+
if (f.push({ combined: !1, speeds: [l], cost: (b = l.cost) == null ? void 0 : b.total }), y) {
|
|
1063
|
+
const i = l.cost.cp, h = y.cost.cp, C = w(l.eta), g = w(l.etd), D = C.diff(g, "days", !0);
|
|
1064
|
+
let Y = Math.ceil(D / 2);
|
|
1065
|
+
Y = Y > 7 ? 7 : Y < e.alterStep ? e.alterStep : Y;
|
|
1066
|
+
let q = 2, E = { combined: !1, speeds: [y], cost: (v = y.cost) == null ? void 0 : v.total }, k;
|
|
1067
|
+
for (; Y >= e.alterStep; ) {
|
|
1068
|
+
const x = await A.combinedAnalyse(e, t, u, [i, h], c, Y, { ...o, level: q });
|
|
1069
|
+
if (E.cost > x.cost ? k ? (k == null ? void 0 : k.cost) > x.cost && (k = x) : (k = E, E = x) : (!k || (k == null ? void 0 : k.cost) > x.cost) && (k = x), Y <= e.alterStep)
|
|
1070
1070
|
break;
|
|
1071
|
-
|
|
1071
|
+
Y = Math.ceil(Y / 2), q += 1;
|
|
1072
1072
|
}
|
|
1073
|
-
|
|
1073
|
+
f.push(E), k && f.push(k);
|
|
1074
1074
|
}
|
|
1075
|
-
const
|
|
1076
|
-
return
|
|
1075
|
+
const I = w().valueOf() - a;
|
|
1076
|
+
return p == null || p.info("[%s] analyse elapsed: %d ms", o == null ? void 0 : o.requestId, I), f.sort((i, h) => i.cost - h.cost);
|
|
1077
1077
|
}
|
|
1078
1078
|
/**
|
|
1079
1079
|
* 按步长多次减半,分别用7,4,2,1天步长及cpa,cpb交替计算各种组合下的成本
|
|
@@ -1085,12 +1085,12 @@ class E {
|
|
|
1085
1085
|
* @param step 步长,7,4,2,1
|
|
1086
1086
|
* @param options
|
|
1087
1087
|
*/
|
|
1088
|
-
static async combinedAnalyse(e, t,
|
|
1089
|
-
s.counter = 1,
|
|
1090
|
-
const d = await
|
|
1091
|
-
|
|
1092
|
-
const
|
|
1093
|
-
return
|
|
1088
|
+
static async combinedAnalyse(e, t, n, c, o, a, s = {}) {
|
|
1089
|
+
s.counter = 1, p == null || p.info("[%s][L%d] analyse with alternate cp in every %d days", s.requestId, s.level, a);
|
|
1090
|
+
const d = await A.alternateAnalyse(e, t, n, c, 0, o, a, s), r = d.reduce((l, y) => l + y.cost.total, 0);
|
|
1091
|
+
p == null || p.info("[%s][L%d] cost with cpa/cpb turn: %d", s.requestId, s.level, r);
|
|
1092
|
+
const u = await A.alternateAnalyse(e, t, n, c, 1, o, a, s), m = u.reduce((l, y) => l + y.cost.total, 0);
|
|
1093
|
+
return p == null || p.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 };
|
|
1094
1094
|
}
|
|
1095
1095
|
/**
|
|
1096
1096
|
* 基于cp索引,交替计算指定步长下的成本
|
|
@@ -1103,41 +1103,41 @@ class E {
|
|
|
1103
1103
|
* @param step 步长,7,4,2,1
|
|
1104
1104
|
* @param options
|
|
1105
1105
|
*/
|
|
1106
|
-
static async alternateAnalyse(e, t,
|
|
1107
|
-
var l,
|
|
1106
|
+
static async alternateAnalyse(e, t, n, c, o, a, s, d = {}) {
|
|
1107
|
+
var l, y;
|
|
1108
1108
|
let r = w.utc(e.etd);
|
|
1109
|
-
const
|
|
1110
|
-
for (; r.isBefore(
|
|
1111
|
-
const
|
|
1112
|
-
h,
|
|
1113
|
-
r.format(),
|
|
1109
|
+
const u = { lat: e.lat, lng: e.lng }, m = [];
|
|
1110
|
+
for (; r.isBefore(n); ) {
|
|
1111
|
+
const f = r.clone().utc().add(s, "day"), S = JSON.parse(JSON.stringify(a.route)), I = JSON.parse(JSON.stringify(a.waypoints)), b = c[o], v = await A.analyseInstantWithThreshed(
|
|
1114
1112
|
u,
|
|
1113
|
+
r.format(),
|
|
1114
|
+
f,
|
|
1115
1115
|
t,
|
|
1116
|
-
v,
|
|
1117
1116
|
b,
|
|
1118
|
-
|
|
1117
|
+
S,
|
|
1118
|
+
I,
|
|
1119
1119
|
e.meteoVendor,
|
|
1120
1120
|
e.speedStep,
|
|
1121
1121
|
e.useMeteo,
|
|
1122
1122
|
e.useRouteParam,
|
|
1123
1123
|
d
|
|
1124
1124
|
);
|
|
1125
|
-
|
|
1125
|
+
v && (await A.calculateCost(v, b, e, d), p == null || p.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
|
+
f.utc().format(),
|
|
1132
|
+
{ cost: v.cost.total, distance: v.distance, hours: v.totalHrs, cp: `${b.speed}/${b.fo}/${b.dgo}` }
|
|
1133
1133
|
)), d.counter = d.counter + 1;
|
|
1134
|
-
const
|
|
1135
|
-
if (
|
|
1136
|
-
|
|
1134
|
+
const i = (y = (l = v == null ? void 0 : v.sample) == null ? void 0 : l.hours) == null ? void 0 : y.at(-1);
|
|
1135
|
+
if (i)
|
|
1136
|
+
u.lat = i.lat, u.lng = i.lng, r = w(i.eta), m.push(v), o = o ? 0 : 1;
|
|
1137
1137
|
else
|
|
1138
1138
|
break;
|
|
1139
1139
|
}
|
|
1140
|
-
return
|
|
1140
|
+
return m;
|
|
1141
1141
|
}
|
|
1142
1142
|
/**
|
|
1143
1143
|
* 计算Speed的cost
|
|
@@ -1146,76 +1146,113 @@ class E {
|
|
|
1146
1146
|
* @param props
|
|
1147
1147
|
* @param options
|
|
1148
1148
|
*/
|
|
1149
|
-
static async calculateCost(e, t,
|
|
1149
|
+
static async calculateCost(e, t, n, c = {}) {
|
|
1150
1150
|
if (e) {
|
|
1151
|
-
const
|
|
1151
|
+
const o = Math.round(e.totalHrs / 24 * (n.dailyHire || 0) * (1 - (n.addComm || 0)) * 1e3) / 1e3, a = Math.round(e.totalFoCons * (n.priceFO || 0) * 1e3) / 1e3, s = Math.round((e.totalDgoCons + e.totalDgoConsInECA) * (n.priceDGO || 0) * 1e3) / 1e3;
|
|
1152
1152
|
e.cost = {
|
|
1153
|
-
total: Math.round((
|
|
1154
|
-
hire:
|
|
1155
|
-
bunker: Math.round((
|
|
1153
|
+
total: Math.round((o + a + s) * 1e3) / 1e3,
|
|
1154
|
+
hire: o,
|
|
1155
|
+
bunker: Math.round((a + s) * 1e3) / 1e3,
|
|
1156
1156
|
cp: t
|
|
1157
1157
|
};
|
|
1158
1158
|
}
|
|
1159
1159
|
return e;
|
|
1160
1160
|
}
|
|
1161
|
+
/**
|
|
1162
|
+
* 计算单cp模式下的ECA属性
|
|
1163
|
+
*/
|
|
1164
|
+
static async calculateECA(e, t, n = {}) {
|
|
1165
|
+
var d, r;
|
|
1166
|
+
const c = await R.intersectInECA(e.route);
|
|
1167
|
+
let o = 0, a = 0, s = 0;
|
|
1168
|
+
e.sample.wps.forEach((u) => {
|
|
1169
|
+
u.positionTime = w.utc(u.etd || u.eta).unix();
|
|
1170
|
+
});
|
|
1171
|
+
for (const u of c) {
|
|
1172
|
+
o += u.distance;
|
|
1173
|
+
const m = await R.deadReckoningTime((d = u.waypoints) == null ? void 0 : d.at(0), e.sample.wps), l = await R.deadReckoningTime((r = u.waypoints) == null ? void 0 : r.at(-1), e.sample.wps);
|
|
1174
|
+
u.in = m, u.out = l, u.totalHrs = Z.roundPrecision((l.positionTime - m.positionTime) / 3600, 2), u.totalDgoCons = Z.roundPrecision(t.fo / 24 * u.totalHrs, 3), a += u.totalHrs;
|
|
1175
|
+
}
|
|
1176
|
+
return o = Z.roundPrecision(o, 3), a = Z.roundPrecision(a, 3), s = Z.roundPrecision(s, 3), {
|
|
1177
|
+
distanceInECA: o,
|
|
1178
|
+
hoursInECA: a,
|
|
1179
|
+
totalDgoConsInECA: s,
|
|
1180
|
+
eca: c
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* 合并多cp组合模式下的速度集合
|
|
1185
|
+
* @param speeds
|
|
1186
|
+
* @param options
|
|
1187
|
+
*/
|
|
1161
1188
|
static async mergeSpeeds(e, t = {}) {
|
|
1162
|
-
var
|
|
1163
|
-
const
|
|
1189
|
+
var v;
|
|
1190
|
+
const n = {
|
|
1164
1191
|
hours: [],
|
|
1165
1192
|
wps: [],
|
|
1166
1193
|
days: []
|
|
1167
|
-
},
|
|
1168
|
-
for (const
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
var
|
|
1177
|
-
((
|
|
1178
|
-
}),
|
|
1179
|
-
var
|
|
1180
|
-
((
|
|
1194
|
+
}, c = e.reduce((i, h) => i + h.distance, 0), o = e.reduce((i, h) => i + h.distanceInECA, 0), a = e.reduce((i, h) => i + h.totalHrs, 0), s = e.reduce((i, h) => i + h.hoursInECA, 0), d = e.reduce((i, h) => i + h.totalDgoConsInECA, 0), r = e.reduce((i, h) => i + h.wxFactor * h.totalHrs / a, 0), u = e.reduce((i, h) => i + h.cFactor * h.totalHrs / a, 0), m = e.reduce((i, h) => i + h.totalFoCons, 0), l = e.reduce((i, h) => i + h.totalDgoCons, 0), y = e.reduce((i, h) => i + h.cost.total, 0), f = e.reduce((i, h) => i + h.cost.hire, 0), S = e.reduce((i, h) => i + h.cost.bunker, 0), I = [], b = [];
|
|
1195
|
+
for (const i of e) {
|
|
1196
|
+
b.push(...i.eca);
|
|
1197
|
+
const h = i.sample.hours, C = h.at(0);
|
|
1198
|
+
C.cp = i.cost.cp;
|
|
1199
|
+
const g = [i.etd, i.eta], D = I.findIndex((k) => k.id === C.cp.id);
|
|
1200
|
+
D === -1 ? (C.cp.segment = [g], I.push(C.cp)) : I[D].segment.push(g);
|
|
1201
|
+
const Y = i.sample.wps, q = i.sample.days;
|
|
1202
|
+
h.forEach((k) => {
|
|
1203
|
+
var P;
|
|
1204
|
+
((P = n.hours) == null ? void 0 : P.findIndex((T) => T.eta === k.eta)) === -1 && n.hours.push(k);
|
|
1205
|
+
}), Y.forEach((k) => {
|
|
1206
|
+
var P;
|
|
1207
|
+
((P = n.wps) == null ? void 0 : P.findIndex((T) => T.eta === k.eta)) === -1 && n.wps.push(k);
|
|
1208
|
+
}), q.forEach((k) => {
|
|
1209
|
+
var P;
|
|
1210
|
+
((P = n == null ? void 0 : n.days) == null ? void 0 : P.findIndex((T) => T.eta === k.eta)) === -1 && n.days.push(k);
|
|
1181
1211
|
});
|
|
1182
|
-
const
|
|
1183
|
-
|
|
1212
|
+
const E = (v = n.wps) == null ? void 0 : v.findIndex((k) => k.eta === C.eta);
|
|
1213
|
+
E === -1 ? n.wps.push(C) : n.wps[E] = C;
|
|
1184
1214
|
}
|
|
1185
|
-
return {
|
|
1186
|
-
|
|
1215
|
+
return n.wps.sort((i, h) => {
|
|
1216
|
+
w(i.etd).unix() - w(h.etd).unix();
|
|
1217
|
+
}), {
|
|
1218
|
+
sample: n,
|
|
1187
1219
|
etd: e.at(0).etd,
|
|
1188
1220
|
eta: e.at(-1).eta,
|
|
1189
1221
|
from: e.at(0).from,
|
|
1190
1222
|
to: e.at(-1).to,
|
|
1191
1223
|
v0: e.at(0).v0,
|
|
1192
1224
|
label: "Combined",
|
|
1193
|
-
distance: Math.round(
|
|
1225
|
+
distance: Math.round(c * 1e4) / 1e4,
|
|
1226
|
+
distanceInECA: Math.round(o * 1e4) / 1e4,
|
|
1194
1227
|
totalHrs: Math.round(a * 1e3) / 1e3,
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1228
|
+
hoursInECA: Math.round(s * 1e3) / 1e3,
|
|
1229
|
+
avgSpeed: Math.round(c / a * 1e3) / 1e3,
|
|
1230
|
+
wxFactor: Math.round(r / a * 1e3) / 1e3,
|
|
1231
|
+
cFactor: Math.round(u / a * 1e3) / 1e3,
|
|
1232
|
+
totalFoCons: Math.round(m * 1e3) / 1e3,
|
|
1233
|
+
totalDgoCons: Math.round(l * 1e3) / 1e3,
|
|
1234
|
+
totalDgoConsInECA: Math.round(d * 1e3) / 1e3,
|
|
1200
1235
|
cost: {
|
|
1201
|
-
total: Math.round(
|
|
1202
|
-
hire: Math.round(
|
|
1203
|
-
bunker: Math.round(
|
|
1204
|
-
}
|
|
1236
|
+
total: Math.round(y * 1e3) / 1e3,
|
|
1237
|
+
hire: Math.round(f * 1e3) / 1e3,
|
|
1238
|
+
bunker: Math.round(S * 1e3) / 1e3
|
|
1239
|
+
},
|
|
1240
|
+
cps: I,
|
|
1241
|
+
eca: b
|
|
1205
1242
|
};
|
|
1206
1243
|
}
|
|
1207
1244
|
}
|
|
1208
1245
|
export {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1246
|
+
st as AISImpl,
|
|
1247
|
+
ht as AlertHelper,
|
|
1248
|
+
ut as AlertLevel,
|
|
1249
|
+
St as HifleetImpl,
|
|
1250
|
+
mt as LoadCondition,
|
|
1251
|
+
jt as MyShipImpl,
|
|
1252
|
+
kt as MyVesselImpl,
|
|
1253
|
+
Yt as ShipxyImpl,
|
|
1254
|
+
A as SpeedHelper,
|
|
1255
|
+
yt as SpeedLabel,
|
|
1256
|
+
ft as VesselTag,
|
|
1257
|
+
Ct as alertHelper
|
|
1221
1258
|
};
|