@idm-plugin/vessel 1.2.1 → 1.2.3
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 +439 -386
- package/dist/index.umd.cjs +1 -1
- package/dist/speed/src/index.d.ts +7 -2
- package/package.json +1 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(j,Y){typeof exports=="object"&&typeof module<"u"?Y(exports,require("got"),require("@log4js-node/log4js-api"),require("moment"),require("@idm-plugin/geo"),require("@idm-plugin/meteo")):typeof define=="function"&&define.amd?define(["exports","got","@log4js-node/log4js-api","moment","@idm-plugin/geo","@idm-plugin/meteo"],Y):(j=typeof globalThis<"u"?globalThis:j||self,Y(j["idm-plugin-rabbitmq"]={},j.got,j["@log4js-node/log4js-api"],j.moment,j["@idm-plugin/geo"],j["@idm-plugin/meteo"]))})(this,function(j,Y,R,y,x,st){"use strict";var dt=Object.defineProperty;var ut=(j,Y,R)=>Y in j?dt(j,Y,{enumerable:!0,configurable:!0,writable:!0,value:R}):j[Y]=R;var _=(j,Y,R)=>(ut(j,typeof Y!="symbol"?Y+"":Y,R),R);const D=R.getLogger("vessel");class Z{parseStatus(a){let t,i;switch(a){case 0:t="在航(主机推动)",i="The engine is in use";break;case 1:t="锚泊",i="Anchored";break;case 2:t="失控",i="Not operated";break;case 3:t="操纵受限",i="Limited airworthiness";break;case 4:t="吃水受限",i="Limited by ship's draft";break;case 5:t="靠泊",i="Mooring";break;case 6:t="搁浅",i="Stranded";break;case 7:t="捕捞作业",i="Engaged in fishing";break;case 8:t="靠帆船提供动力",i="Sailing";break;default:t="未定义",i="Undefined"}return{labelCn:t,labelEn:i}}}class at extends Z{constructor(t,i){super();_(this,"clientId");_(this,"clientSecret");_(this,"token");this.clientId=t,this.clientSecret=i}async authToken(t={}){const i="https://svc.data.myvessel.cn/ada/oauth/token",o={searchParams:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"client_credentials"}},n=await Y.post(i,o).json();D.info("[%s] fetch access token from: %s - %j",t.requestId,i,n),n.error||(this.token={accessToken:n.access_token,tokenType:n.token_type,expiresIn:n.expires_in,scope:n.scope,jti:n.jti,issuedAt:y().utc().format()})}async realTimePosition(t,i={}){var m,g,p;(!this.token||y().diff(y(this.token.issuedAt),"seconds")>((m=this.token)==null?void 0:m.expiresIn)-300)&&await this.authToken(i);const o="https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit",n={headers:{Authorization:`${(g=this.token)==null?void 0:g.tokenType} ${(p=this.token)==null?void 0:p.accessToken}`},searchParams:{mmsi:t}};D.info("[%s] fetch realtime position from: %s - %j",i.requestId,o,n);const s=await Y.get(o,n).json();if(s.code)return D.warn("[%s] fetch realtime position failed: %j",i.requestId,o,{message:s.message,status:s.status,code:s.code}),s;const e=s.data;for(const f in e)!isNaN(e[f])&&Number(e[f])!==1/0&&(e[f]=Number(e[f]));const d=y(`${e.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:e.mmsi,name:e.vesselName,imo:e.imo,callSign:e.callsign,lat:e.lat,lng:e.lon,length:e.length,width:e.width,draught:e.currDraught,sog:e.sog,cog:e.cog,hdg:e.hdg,rot:e.rot,eta:e.eta,destination:e.dest,positionTime:d.unix(),status:e.status,labelCn:e.statusNameCn,labelEn:e.statusNameEn,method:"position",vendor:"myVessel",utc:d.utc().format()}}async trajectory(t,i,o,n,s=!0,e={}){(!this.token||y().diff(y(this.token.issuedAt),"seconds")>this.token.expiresIn-300)&&await this.authToken(e);const d=await this.realTimePosition(t,e),r=y(i),m=y(o),g=[];for(;m.diff(r,"day",!0)>30;)await this.trajectoryIn30Day(t,r,r.clone().add(30,"day"),d,n,g,e),r.add(30,"day");return await this.trajectoryIn30Day(t,r,m,d,n,g,e),g}async trajectoryIn30Day(t,i,o,n,s,e,d={}){var l,b,w,u,c;const r="https://svc.data.myvessel.cn/sdc/v1/vessels/status/track",m={headers:{Authorization:`${(l=this.token)==null?void 0:l.tokenType} ${(b=this.token)==null?void 0:b.accessToken}`},json:{mmsi:t,startTime:i.utcOffset(8).format("YYYY-MM-DD HH:mm:ss"),endTime:o.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")}};D.info("[%s] fetch trajectory from: %s - %j",d.requestId,r,m);const g=await Y.post(r,m).json();if(g.code)return D.warn("[%s] fetch trajectory failed: %j",d.requestId,r,{message:g.message,status:g.status,code:g.code}),g;let p=-1;const f=y(`${(u=(w=g.data)==null?void 0:w[0])==null?void 0:u.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return(c=g.data)==null||c.forEach(h=>{for(const S in h)!isNaN(h[S])&&Number(h[S])!==1/0&&(h[S]=Number(h[S]));const v=y(`${h.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00"),I=h.eta?y(`${h.eta} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00"):void 0,M=h.status,{labelCn:E,labelEn:q}=this.parseStatus(M),A={mmsi:h.mmsi,imo:n==null?void 0:n.imo,lat:h.lat,lng:h.lon,sog:h.sog,cog:h.cog,hdg:h.hdg,draught:h.draught,status:M,eta:I==null?void 0:I.unix(),destination:h.dest,positionTime:v.unix(),labelCn:E,labelEn:q,method:"trajectory",vendor:"myVessel",utc:v.utc().format()},H=Math.floor(v.diff(f,"minute",!0)/(s||1));H!==p&&(p=H,e.push(A))}),e}}class ot extends Z{constructor(t){super();_(this,"token");this.token=t}async realTimePosition(t,i={}){const o="https://api.hifleet.com/position/position/get/token",n={searchParams:{mmsi:t,usertoken:this.token}},s=await Y.post(o,n).json();D.info("[%s] fetch realtime position from: %s - %j",i.requestId,o,n);const e=s==null?void 0:s.list;if(!e)return D.warn("[%s] fetch realtime position failed: %j",i.requestId,o,s),s;for(const f in e)!isNaN(e[f])&&Number(e[f])!==1/0&&(e[f]=Number(e[f]));e.status=e.sp>3?0:1;const d=e.status,{labelCn:r,labelEn:m}=this.parseStatus(d),g=y(`${e.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:e.m,name:e.n,imo:e.imonumber,callSign:e.callsign,lat:Math.round(e.la/60*1e5)/1e5,lng:Math.round(e.lo/60*1e5)/1e5,length:e.l,width:e.w,draught:e.draught,sog:e.sp,cog:e.co,hdg:e.h,rot:isNaN(e.rot)?0:e.rot,eta:/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(e.eta)?y(`${e.eta} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00").unix():void 0,destination:e.destination,positionTime:g.unix(),utc:g.utc().format(),status:d,labelCn:r,labelEn:m,method:"position",vendor:"hifleet"}}async search(t,i={}){let o="https://www.hifleet.com/hifleetapi/searchVesselOL.do";const n={searchParams:{keyword:t},headers:{Referer:"https://www.hifleet.com",Origin:"https://www.hifleet.com",Host:"www.hifleet.com"}};let s=await Y.post(o,n).json();D.info("[%s] fetch vessel props from: %s - %j",i.requestId,o,n),s instanceof Array&&(s=s[0]);for(const d in s)!isNaN(s[d])&&Number(s[d])!==1/0&&(s[d]=Number(s[d]));const e={mmsi:s.m,name:s.n,imo:s.i,callSign:s.c,length:s.l,breadth:s.b,draught:s.dr};return o="https://www.hifleet.com/hifleetapi/sameShipSearch.do",s=await Y.post(o,n).json(),D.info("[%s] fetch vessel dead weight from: %s - %j",i.requestId,o,n),s instanceof Array&&(s=s[0]),s&&(e.deadweight=Number(s.dwt)),e}async trajectory(t,i,o,n,s=!0,e={}){var h,v,I;const d=await this.realTimePosition(t,e);let r=y(i);const m=y(o),g=y();if(s){let M=m.diff(r,"d",!0);M<0?r=m.clone().subtract(40,"d"):M<30?r.subtract(10,"d"):M<60?r.subtract(5,"d"):r=m.clone().subtract(80,"d"),M=g.diff(m,"d",!0),m.add(M>10?240:M*24,"h")}const p={searchParams:{endtime:m.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),starttime:r.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),mmsi:t,usertoken:this.token}},f="https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token",l=await Y.get(f,p).json();D.info("[%s] fetch trajectory from: %s - %j",e.requestId,f,p);let b;l&&(b=((v=(h=l.ships)==null?void 0:h.offors)==null?void 0:v.ship)||[],b.length||D.warn("[%s] fetch trajectory failed: %j",e.requestId,l));const w=[];let u=-1;const c=y(`${(I=b==null?void 0:b[0])==null?void 0:I.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");for(const M of b){for(const O in M)!isNaN(M[O])&&Number(M[O])!==1/0&&(M[O]=Number(M[O]));const E=y(`${M.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");M.status=M.sp>4?0:1;const{labelEn:q,labelCn:A}=this.parseStatus(M.status),H={mmsi:M.m,name:M.n,imo:d==null?void 0:d.imo,lat:M.la,lng:M.lo,draught:M.draught,sog:M.sp,cog:M.co,hdg:M.hdg,positionTime:E.unix(),utc:E.utc().format(),status:M.status,labelCn:A,labelEn:q,method:"trajectory",vendor:"hifleet"},S=Math.floor(E.diff(c,"minute",!0)/(n||1));S!==u&&(u=S,w.push(H))}return w}}class nt extends Z{constructor(t){super();_(this,"token");this.token=t}async realTimePosition(t,i={}){const o={searchParams:{id:t,k:this.token,enc:1}},n="https://api.shipxy.com/apicall/GetSingleShip",s=await Y.get(n,o).json();if(D.info("[%s] fetch realtime position from: %s - %j",i.requestId,n,o),(s==null?void 0:s.status)!==0)return s;const e=s.data[0];for(const p in e)!isNaN(e[p])&&Number(e[p])!==1/0&&(e[p]=Number(e[p]));const{labelCn:d,labelEn:r}=await this.parseStatus(e.navistat),m=y.unix(e.lasttime);return{mmsi:e.ShipID,name:e.name,imo:e.imo,callSign:e.callsign,lat:Math.round(e.lat/1e6*1e5)/1e5,lng:Math.round(e.lon/1e6*1e5)/1e5,length:Math.round(e.length/10*100)/100,width:Math.round(e.width/10*100)/100,draught:Math.round(e.draught/1e3*100)/100,sog:Math.round(e.sog*3600/1e3/1852*100)/100,cog:Math.round(e.cog/100*100)/100,hdg:Math.round(e.hdg/100*100)/100,rot:Math.round(e.rot/100*100)/100,positionTime:e.lasttime,utc:m.utc().format(),status:e.navistat,labelEn:r,labelCn:d,method:"position",vendor:"shipxy"}}async trajectory(t,i,o,n,s=!0,e={}){var c;const d=await this.realTimePosition(t,e),r=y(i),m=y(o),g="https://api.shipxy.com/apicall/GetShipTrack",p={searchParams:{id:t,k:this.token,enc:1,cut:0,btm:r.unix(),etm:m.unix()}},f=await Y.get(g,p).json();if(D.info("[%s] fetch trajectory from: %s - %j",e.requestId,g,p),(f==null?void 0:f.status)!==0)return f;const l=f==null?void 0:f.points,b=[],w=y.unix((c=l[0])==null?void 0:c.utc);let u=-1;for(const h of l){const v=y.unix(h.utc),I={imo:d==null?void 0:d.imo,mmsi:t,sog:Math.round(h.sog*3600/1e3/1852*100)/100,cog:Math.round(h.cog/100*100)/100,lat:Math.round(h.lat/1e6*1e5)/1e5,lng:Math.round(h.lon/1e6*1e5)/1e5,positionTime:v.unix(),utc:v.utc().format(),method:"trajectory",vendor:"shipxy"},M=Math.floor(v.diff(w,"minute",!0)/(n||1));M!==u&&(u=M,b.push(I))}return b}}class it extends Z{constructor(t){super();_(this,"token");this.token=t}async getShipId(t,i={}){const o={headers:{appKey:this.token},json:{mmsiList:t}},n="https://api3.myships.com/sp/ships/getShipIdByMMSI",s=await Y.post(n,o).json();return D.info("[%s] fetch ship id from: %s - %j",i.requestId,n,o),s.code!=="0"?s:s.data[0].shipId}async getShipInfo(t,i={}){const o={headers:{appKey:this.token},json:{shipId:t}},n="https://api3.myships.com/sp/ships/aissta",s=await Y.post(n,o).json();if(D.info("[%s] fetch ship info from: %s - %j",i.requestId,n,o),s.code!=="0")return s;const e=s.data;let d=e.imo;return t==="407170"&&(d="9198379",D.warn("[%s] ship(%s) imo error: %s, should be %s",i.requestId,t,e.imo,d)),{mmsi:e.mmsi,name:e.shipnameEn,imo:d,callSign:e.callSign,length:e.length,width:e.breadth,draught:(e.draught||100)/10}}async realTimePosition(t,i={}){const o=await this.getShipId(t,i),n=await this.getShipInfo(o,i),s={headers:{appKey:this.token},json:{shipId:o}},e="https://api3.myships.com/sp/ships/position/latest",d=await Y.post(e,s).json();D.info("[%s] fetch realtime position from: %s - %j",i.requestId,e,s);const r=d.data[0];for(const l in r)!isNaN(r[l])&&Number(r[l])!==1/0&&(r[l]=Number(r[l]));const{labelCn:m,labelEn:g}=await this.parseStatus(r.aisNavStatus),p=y.unix(r.posTime);return{...n,mmsi:t,lat:Math.round(r.lat/1e4/60*1e5)/1e5,lng:Math.round(r.lon/1e4/60*1e5)/1e5,sog:Math.round(r.sog/10*100)/100,cog:Math.round(r.cog/10*100)/100,hdg:Math.round(r.heading*100)/100,rot:Math.round(r.rot*100)/100,positionTime:r.posTime,utc:p.utc().format(),status:r.aisNavStatus,labelEn:g,labelCn:m,method:"position",vendor:"myship"}}async trajectory(t,i,o,n,s=!0,e={}){const d=y(i),r=y(o),m=await this.getShipId(t),g=await this.getShipInfo(m),p=[];for(;r.diff(d,"day",!0)>30;)await this.trajectoryIn30Day(m,d.unix(),d.add(30,"day").unix(),g,t,n,p);return await this.trajectoryIn30Day(m,d.unix(),r.unix(),g,t,n,p),p}async trajectoryIn30Day(t,i,o,n,s,e,d,r={}){var w;const m={headers:{appKey:this.token},json:{shipId:t,startTime:i,endTime:o}},g="https://api3.myships.com/sp/ships/position/history",p=await Y.post(g,m).json();if(D.info("[%s] fetch trajectory from: %s - %j",r.requestId,g,m),p.code!=="0")return D.warn("[%s] invoke myship trajectory failed: %j",r.requestId,p),p;const f=p.data;for(const u in f)!isNaN(f[u])&&Number(f[u])!==1/0&&(f[u]=Number(f[u]));const l=y.unix((w=f[0])==null?void 0:w.posTime);let b=-1;for(const u of f){const c=y.unix(u.posTime),h={imo:n==null?void 0:n.imo,mmsi:s,lat:Math.round(u.lat/1e4/60*1e5)/1e5,lng:Math.round(u.lon/1e4/60*1e5)/1e5,sog:Math.round(u.sog/10*100)/100,cog:Math.round(u.cog/10*100)/100,hdg:Math.round(u.heading*100)/100,rot:Math.round(u.rot*100)/100,positionTime:c.unix(),utc:c.utc().format(),method:"trajectory",vendor:"myship"},v=Math.floor(c.diff(l,"minute",!0)/(e||1));v!==b&&(b=v,d.push(h))}return d}}const K=R.getLogger("vessel");var z=(k=>(k.NOTICE="NOTICE",k.WARN="WARN",k.HEAVY="HEAVY",k.SEVERE="SEVERE",k.ERROR="ERROR",k.FATAL="FATAL",k))(z||{});class G{parsePrinciple(a,t={}){var e,d,r;K.info("[%s] parse rule: %s",t.requestId,a);const i=new RegExp("(?<=\\[)(.+)(?=])","g"),o=a.match(i)?(e=a.match(i))==null?void 0:e[0]:void 0,n=o==null?void 0:o.split(";");if(!n)return;const s={};for(let m=0;m<(n==null?void 0:n.length);m++){const g=(r=(d=n[m].match(i))==null?void 0:d[0])==null?void 0:r.split("],");if(m===0&&!g)s.scope=n[0];else if(g)for(let p=0,f=g.length;p<f;p++){const l=this.parseRule(g[p]);l&&(s[l.level]?l.key?s[l.level][l==null?void 0:l.key]=l:s[l.level]=l:l.key?s[l.level]={[l==null?void 0:l.key]:l}:s[l.level]=l)}}return s}parseRule(a,t={}){var s;K.info("[%s] parse rule: %s",t.requestId,a),a=a.startsWith("[")?a:`[${a}`,a=a.endsWith("]")?a:`${a}]`;const i=new RegExp("(?<=\\[)(.+?)(?=])","g"),o=(s=a==null?void 0:a.match(i))==null?void 0:s[0],n=o==null?void 0:o.split(",");if(n)return{operator:n[0],number:Number.isNaN(Number(n[1]))?n[1]:Number(n[1]),level:n[2],time:Number(n[3]),key:n[4]}}checkWeather(a,t,i={}){var l,b,w,u,c,h,v,I,M,E,q,A,H,S,O;let o=0,n=0,s=0,e=0;const d=Math.round(((b=(l=t==null?void 0:t.SEVERE)==null?void 0:l.sigWave)==null?void 0:b.number)*1.6*100)/100,r=(u=(w=t==null?void 0:t.SEVERE)==null?void 0:w.sigWave)==null?void 0:u.number,m=(h=(c=t==null?void 0:t.HEAVY)==null?void 0:c.sigWave)==null?void 0:h.number,g=Math.round((((I=(v=t==null?void 0:t.SEVERE)==null?void 0:v.wind)==null?void 0:I.number)+2)*100)/100,p=(E=(M=t==null?void 0:t.SEVERE)==null?void 0:M.wind)==null?void 0:E.number,f=(A=(q=t==null?void 0:t.HEAVY)==null?void 0:q.wind)==null?void 0:A.number;for(let W=0;W<(a==null?void 0:a.length);W++){const T=a[W],L=(S=(H=T==null?void 0:T.meteo)==null?void 0:H.wave)==null?void 0:S.sig,C=(O=T==null?void 0:T.meteo)==null?void 0:O.wind,V=W?y(T.eta).diff(y(a[W-1].eta),"hour",!0):0;e=V>e?V:e,K.info("[%s] check sig.wave: %j",i.requestId,{...L,dgThd4Wv:d,svThd4Wv:r,hvThd4Wv:m}),(L==null?void 0:L.height)>=d?T.isDangerous=!0:(L==null?void 0:L.height)>=r?T.isSevere=!0:(L==null?void 0:L.height)>=m&&(T.isHeavy=!0),K.info("[%s] check wind: %j",i.requestId,{...C,dgThd4Wd:g,svThd4Wd:p,hvThd4Wd:f}),(C==null?void 0:C.scale)>=g?(T.isDangerous=!0,delete T.isSevere,delete T.isHeavy):(C==null?void 0:C.scale)>p?(T.isDangerous||(T.isSevere=!0),delete T.isHeavy):(C==null?void 0:C.scale)===f&&!T.isDangerous&&!T.isSevere&&(T.isHeavy=!0),o+=T.isDangerous?V:0,n+=T.isSevere?V:0,s+=T.isHeavy?V:0}return o=Math.round(o*100)/100,n=Math.round(n*100)/100,s=Math.round(s*100)/100,e=Math.round(e),{sample:a,dangerous:o,severe:n,heavy:s,step:e<3?3:e,wind:{dgThd4Wd:g,svThd4Wd:p,hvThd4Wd:f},sig:{dgThd4Wv:d,svThd4Wv:r,hvThd4Wv:m}}}}const rt=new G,B=R.getLogger("vessel");var U=(k=>(k.common="common",k.container="container",k))(U||{}),J=(k=>(k.Ballast="Ballast",k.Laden="Laden",k))(J||{}),Q=(k=>(k.Cp="CP",k.Perf="Basis",k.Instruct="Other",k))(Q||{});class F{static blockCoefficient(a,t,i,o){let n=Math.round(a/(t*i*o)*100)/100;n=n<.55?.55:n>.85?.85:n;const s=[.55,.6,.65,.7,.75,.8,.85],e=s.map(d=>Math.abs(d-n));return s[e.indexOf(Math.min(...e))]}static froudeNumber(a,t,i=9.8){let o=Math.round(Math.sqrt(a*a/(i*t))*100)/100;return o=o<.05?.05:o>.3?.3:o,o}static amendFactor(a,t,i){const o={.55:[1.7,-1.4,-7.4],.6:[2.2,-2.5,-9.7],.65:[2.6,-3.7,-11.6],.7:[3.1,-5.3,-12.4],.75:[2.4,-10.6,-9.5],.8:[2.6,-13.1,-15.1],.85:[3.1,-18.7,28]};let s={.55:[1.7,-1.4,-7.4],.6:[2.2,-2.5,-9.7],.65:[2.6,-3.7,-11.6],.7:[3.1,-5.3,-12.4],.75:[2.6,-12.5,-13.5],.8:[3,-16.3,-21.6],.85:[3.4,-20.9,31.8]}[a];return i==="Laden"&&(s=o[a]),s[0]+s[1]*t+s[2]*Math.pow(t,2)}static directionFactor(a,t=0){let i;return a>30&&a<=60?i=(1.7-.03*Math.pow(t-4,2))/2:a>60&&a<=150?i=(.9-.06*Math.pow(t-6,2))/2:i=(.4-.03*Math.pow(t-8,2))/2,Math.round(i*1e5)/1e5}static vesselTagFactor(a,t,i,o=0){o=o>5?o-.9*(o-5):o;let n;return i==="container"?n=.7*o+Math.pow(o,6.5)/(22*Math.pow(a,2/3)):t==="Ballast"?n=.7*o+Math.pow(o,6.5)/(2.7*Math.pow(a,2/3)):n=.5*o+Math.pow(o,6.5)/(2.7*Math.pow(a,2/3)),n}static waveHeightFactor(a){return a=a<1.25?1.25:a,a=a>6?a-.9*(a-6):a,Math.round((-.144*Math.pow(a,2)+.178*a)*1e4)/1e4}static assembleProperties(a,t,i,o){var m,g;const n=a.lbp??a.length??a.lengthOverall??198.9642,s=a.draught??8,e=a.breadthMoulded??a.breadth??a.breadthExtreme??32.4572,d=a.deadweight??67035.7773;return{tag:((g=(m=a==null?void 0:a.type)==null?void 0:m.toLowerCase())==null?void 0:g.indexOf("container"))>-1?"container":"common",lbp:n,loadCondition:t,draught:s,breadthMoulded:e,displacement:Math.round((d/1.025+s*e*n*.7)*1e4)/1e4,speed:Math.round((i??14.1382)*1852/3600*1e4)/1e4,bearing:o||90}}static async speedLoseAt(a,t,i,o="",n=2,s=!1,e={}){t.velocity&&!t.noFactor&&s&&(a.speed=x.LngLatHelper.roundPrecision(t.velocity*1852/3600,6));const d=await st.MeteoHelper.queryPointFactor(t.lng,t.lat,i.valueOf(),"wind,wave,current,watertemp",o,e),r=F.weatherFactor(a,d),m=F.currentFactor(a.bearing,d==null?void 0:d.current,n),g={meteo:{...d},wxFactor:r,cFactor:m,speed:t.velocity&&s?t.velocity:Math.round((a.speed*1.943844+r+m)*100)/100,eta:i.utc().format("YYYY-MM-DDTHH:mm[Z]"),etd:i.utc().format("YYYY-MM-DDTHH:mm[Z]")};return delete t.meteo,delete t.wxFactor,delete t.cFactor,delete t.speed,delete t.etd,{...g,...t}}static async speedLoseInHoursStep(a,t,i,o,n,s,e="",d=!1,r={}){t.utc();const m=[],g=[];let p=0,f=0,l,b;for(let w=0;w<s.length-1;w++){let u=s[w];u.distanceFromStart=n+f;const c=s[w+1];if(a.bearing=x.LaneHelper.calculateBearing(u,c,!c.gcToPrevious),u.bearing=a.bearing,u.suspend&&d){u.eta=u.eta||t.format("YYYY-MM-DDTHH:mm[Z]"),u.elapsed=u.elapsed??0;const I=u.suspend-u.elapsed;if(o-p>I)o=o-p-I,t.add(I,"hour"),u.elapsed=u.suspend;else{const M=o-p;u.elapsed+=M,t.add(M,"hour"),o=0}if(B.info(`[%s] suspend ${u.elapsed} hours at %j, and remain ${o} hours need to go...`,r.requestId,u),o===0)return u.distanceFromPrevious=f,{etd:t,from:b||u,to:u,next:s.filter(M=>M),wps:m,days:g}}u=await F.speedLoseAt(a,u,t,e,0,d,r),b=b||u,u.important&&m.push(u),t.isSameOrAfter(i)&&(g.push(u),i.add(24,"hour"));const h=x.LaneHelper.calculateDistance(u,c,!c.gcToPrevious);let v=Math.ceil(h/b.speed*1e4)/1e4;if(p+v<o){if(p+=v,t.add(v,"hour"),delete s[w],B.info(`[%s] go to %j from %j with ${h}nm, and cost ${v} hours`,r.requestId,{lat:c.lat,lng:c.lng},{lat:b.lat,lng:b.lng,etd:b.etd}),f+=h,s.filter(I=>I).length<=1){l=c,l.eta=t.format("YYYY-MM-DDTHH:mm[Z]"),l.distanceFromPrevious=h,l.distanceFromStart=n+f,m.push(l),delete s[w+1];break}}else{v=o-p,t.add(v,"hour");const I=x.LngLatHelper.roundPrecision(b.speed*v,4);l=x.LaneHelper.calculateCoordinate(u,a.bearing,I,"nauticalmiles",!c.gcToPrevious),l.eta=t.format("YYYY-MM-DDTHH:mm[Z]"),s[w]=l,B.info(`[%s] go to %j from %j with ${I}nm, and cost ${v} hours`,r.requestId,{lat:l.lat,lng:l.lng},{lat:u.lat,lng:u.lng,etd:u.etd}),f+=I,l.distanceFromPrevious=f,l.distanceFromStart=n+f;break}}return{etd:t,from:b,to:l,next:s.filter(w=>w),wps:m,days:g}}static currentFactor(a,t,i=0){const o=(a-(t==null?void 0:t.degree)||0)/180*Math.PI;if(Math.abs(o)===Math.PI/2)return 0;let n=((t==null?void 0:t.kts)||0)*Math.cos(o);return i&2?n=Math.ceil(n*100)/100:i&1?n=Math.floor(n*100)/100:n=Math.round(n*100)/100,Math.abs(n)>5?0:n}static weatherFactor(a,t){var g,p,f,l,b;B.debug("calculate weather factor via: %j",{...a,...t});const i=F.blockCoefficient(a.displacement,a.lbp,a.breadthMoulded,a.draught),o=F.froudeNumber(a.speed,a.lbp),n=F.amendFactor(i,o,a.loadCondition);let s=Math.abs(a.bearing%360-(((g=t==null?void 0:t.wind)==null?void 0:g.degree)%360||0));s=s>180?360-s:s;const e=F.directionFactor(s,(p=t==null?void 0:t.wind)==null?void 0:p.scale),d=F.vesselTagFactor(a.displacement,a.loadCondition,a.tag,(f=t==null?void 0:t.wind)==null?void 0:f.scale);let r=e*n*d/100*a.speed;r=Math.round(r*1.943844*1e4)/1e4*-1;const m=F.waveHeightFactor(((b=(l=t==null?void 0:t.wave)==null?void 0:l.sig)==null?void 0:b.height)??1);return r=r*.24+m*.76,B.debug("weather factor = %s",r),Math.round(r*100)/100}static async analyseInstant(a,t,i,o,n,s="",e=0,d=!1,r={}){var L,C,V,X,tt;const m=y().valueOf();a.lng=x.LngLatHelper.convertToStdLng(a.lng);const{route:g,waypoints:p}=n.points,f=x.LaneHelper.calculateSubRoute(a,g);if(((L=f[0])==null?void 0:L.length)<=1)return;const{v0:l,label:b}=a.sog?{v0:a.sog,label:"Other"}:{v0:o.speed,label:"CP"},w=F.assembleProperties(i,o.loadCondition,l,0),u=p.length?x.LaneHelper.calculateSubWaypoints(a,p):[],c={from:{...a},route:f,waypoints:u,v0:l,label:b},h={hours:[],days:[],wps:[]};e||(x.LaneHelper.calculateRouteDistance(f)/o.speed<=72?e=3:e=6);let v=x.LaneHelper.simplifyRouteToCoordinates(f,u,0),I=0,M=0,E=0,q=0;t=y(t).utc();const A=t.clone();for(;v.length>0;){const P=e-t.hour()%e,$=Math.ceil(t.clone().add(P,"h").set({minute:0,second:0,millisecond:0}).diff(t,"h",!0)*1e4)/1e4,N=await F.speedLoseInHoursStep(w,t,A,$,I,v,s,d,r);(C=N.from)!=null&&C.speed&&(h.hours.push(N.from),h.wps.push(...N.wps),h.days.push(...N.days)),v=N==null?void 0:N.next,v.length||h.hours.push(N==null?void 0:N.to),I+=((V=N==null?void 0:N.to)==null?void 0:V.distanceFromPrevious)??0}const H=h.hours;for(let P=0;P<H.length-1;P++){const $=y(H[P+1].eta).diff(H[P].etd,"hour",!0)||1;M+=H[P].wxFactor*$,E+=H[P].cFactor*$,q+=$}(X=h.wps)==null||X.forEach((P,$)=>{if($){const N=h.wps[$-1],ct=P.distanceFromStart-N.distanceFromStart,et=y(P.eta).diff(y(N.etd),"h",!0);et<1?P.avgSpd=N.speed:P.avgSpd=Math.round(ct/et*100)/100}}),c.sample=h;const S=h.hours.at(-1);c.distance=Math.round(S.distanceFromStart*1e4)/1e4,c.eta=y(S.eta).toDate(),c.wxFactor=Math.round(M/q*1e4)/1e4,c.cFactor=Math.round(E/q*1e4)/1e4,c.avgSpeed=Math.round(S.distanceFromStart/q*1e4)/1e4,c.totalHrs=Math.round(q*1e4)/1e4,c.totalFoCons=Math.round((o==null?void 0:o.fo)/24*c.totalHrs*1e3)/1e3,c.totalDgoCons=Math.round((o==null?void 0:o.dgo)/24*c.totalHrs*1e3)/1e3;const W=y().valueOf()-m,T=((tt=h==null?void 0:h.hours)==null?void 0:tt.length)||1;return B.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms",r==null?void 0:r.requestId,W,T,Math.round(W/T*1e3)/1e3),c}static async analyseInstantWithThreshed(a,t,i,o,n,s,e="",d=3,r=!1,m={}){var E,q,A;a.lng=x.LngLatHelper.convertToStdLng(a.lng);const g=F.assembleProperties(o,n.loadCondition,n.speed,0),p=x.LaneHelper.calculateSubRoute(a,s);if(((E=p[0])==null?void 0:E.length)<=1)return;let f=x.LaneHelper.simplifyRouteToCoordinates(p,[],0);f.forEach(H=>H.important=!0);let l=0,b=0,w=0,u=0,c;const h={hours:[],wps:[],days:[]};for(t=y(t).utc();f.length>0;){const H=d-t.hour()%d;let S=Math.ceil(t.clone().add(H,"h").set({minute:0,second:0,millisecond:0}).diff(t,"h",!0)*1e4)/1e4;if(S=t.clone().add(S,"h").isAfter(i)?i.diff(t,"h",!0)*1e4/1e4:S,S)c=await F.speedLoseInHoursStep(g,t,i.clone(),S,l,f,e,r,m),(q=c.from)!=null&&q.speed&&(h.hours.push(c.from),c!=null&&c.wps&&h.wps.push(...c.wps),h.days.push(...c.days)),f=c==null?void 0:c.next,f.length||(h.hours.push(c==null?void 0:c.to),c!=null&&c.wps&&h.wps.push(...c.wps),h.days.push(c==null?void 0:c.to)),l+=((A=c==null?void 0:c.to)==null?void 0:A.distanceFromPrevious)??0;else{c&&(h.hours.push(c.to),c!=null&&c.wps&&h.wps.push(...c.wps),h.days.push(c.to));break}}const v=h.hours;for(let H=0;H<v.length-1;H++){const S=y(v[H+1].eta).diff(v[H].etd,"hour",!0);b+=v[H].wxFactor*S,w+=v[H].cFactor*S,u+=S}const I=h.hours.at(-1);return{sample:h,distance:Math.round(((I==null?void 0:I.distanceFromStart)||0)*1e4)/1e4,eta:y(I==null?void 0:I.eta).utc().format(),wxFactor:Math.round(b/u*1e4)/1e4,cFactor:Math.round(w/u*1e4)/1e4,avgSpeed:Math.round(((I==null?void 0:I.distanceFromStart)||0)/u*1e4)/1e4,totalHrs:Math.round(u*1e4)/1e4,to:I,route:x.LaneHelper.generateRouteAccordingToWaypoints(f)}}}j.AISImpl=Z,j.AlertHelper=G,j.AlertLevel=z,j.HifleetImpl=ot,j.LoadCondition=J,j.MyShipImpl=it,j.MyVesselImpl=at,j.ShipxyImpl=nt,j.SpeedHelper=F,j.SpeedLabel=Q,j.VesselTag=U,j.alertHelper=rt,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(j,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("got"),require("@log4js-node/log4js-api"),require("moment"),require("@idm-plugin/geo"),require("@idm-plugin/meteo")):typeof define=="function"&&define.amd?define(["exports","got","@log4js-node/log4js-api","moment","@idm-plugin/geo","@idm-plugin/meteo"],T):(j=typeof globalThis<"u"?globalThis:j||self,T(j["idm-plugin-rabbitmq"]={},j.got,j["@log4js-node/log4js-api"],j.moment,j["@idm-plugin/geo"],j["@idm-plugin/meteo"]))})(this,function(j,T,V,g,L,at){"use strict";var ut=Object.defineProperty;var ht=(j,T,V)=>T in j?ut(j,T,{enumerable:!0,configurable:!0,writable:!0,value:V}):j[T]=V;var B=(j,T,V)=>(ht(j,typeof T!="symbol"?T+"":T,V),V);let l;try{l=V.getLogger("vessel")}catch{}finally{}class z{parseStatus(a){let t,i;switch(a){case 0:t="在航(主机推动)",i="The engine is in use";break;case 1:t="锚泊",i="Anchored";break;case 2:t="失控",i="Not operated";break;case 3:t="操纵受限",i="Limited airworthiness";break;case 4:t="吃水受限",i="Limited by ship's draft";break;case 5:t="靠泊",i="Mooring";break;case 6:t="搁浅",i="Stranded";break;case 7:t="捕捞作业",i="Engaged in fishing";break;case 8:t="靠帆船提供动力",i="Sailing";break;default:t="未定义",i="Undefined"}return{labelCn:t,labelEn:i}}}class nt extends z{constructor(t,i){super();B(this,"clientId");B(this,"clientSecret");B(this,"token");this.clientId=t,this.clientSecret=i}async authToken(t={}){const i="https://svc.data.myvessel.cn/ada/oauth/token",n={searchParams:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"client_credentials"}},o=await T.post(i,n).json();l==null||l.info("[%s] fetch access token from: %s - %j",t.requestId,i,o),o.error||(this.token={accessToken:o.access_token,tokenType:o.token_type,expiresIn:o.expires_in,scope:o.scope,jti:o.jti,issuedAt:g().utc().format()})}async realTimePosition(t,i={}){var u,f,M;(!this.token||g().diff(g(this.token.issuedAt),"seconds")>((u=this.token)==null?void 0:u.expiresIn)-300)&&await this.authToken(i);const n="https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit",o={headers:{Authorization:`${(f=this.token)==null?void 0:f.tokenType} ${(M=this.token)==null?void 0:M.accessToken}`},searchParams:{mmsi:t}};l==null||l.info("[%s] fetch realtime position from: %s - %j",i.requestId,n,o);const s=await T.get(n,o).json();if(s.code)return l==null||l.warn("[%s] fetch realtime position failed: %j",i.requestId,n,{message:s.message,status:s.status,code:s.code}),s;const e=s.data;for(const p in e)!isNaN(e[p])&&Number(e[p])!==1/0&&(e[p]=Number(e[p]));const d=g(`${e.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:e.mmsi,name:e.vesselName,imo:e.imo,callSign:e.callsign,lat:e.lat,lng:e.lon,length:e.length,width:e.width,draught:e.currDraught,sog:e.sog,cog:e.cog,hdg:e.hdg,rot:e.rot,eta:e.eta,destination:e.dest,positionTime:d.unix(),status:e.status,labelCn:e.statusNameCn,labelEn:e.statusNameEn,method:"position",vendor:"myVessel",utc:d.utc().format()}}async trajectory(t,i,n,o,s=!0,e={}){(!this.token||g().diff(g(this.token.issuedAt),"seconds")>this.token.expiresIn-300)&&await this.authToken(e);const d=await this.realTimePosition(t,e),c=g(i),u=g(n),f=[];for(;u.diff(c,"day",!0)>30;)await this.trajectoryIn30Day(t,c,c.clone().add(30,"day"),d,o,f,e),c.add(30,"day");return await this.trajectoryIn30Day(t,c,u,d,o,f,e),f}async trajectoryIn30Day(t,i,n,o,s,e,d={}){var h,v,k,Y,y;const c="https://svc.data.myvessel.cn/sdc/v1/vessels/status/track",u={headers:{Authorization:`${(h=this.token)==null?void 0:h.tokenType} ${(v=this.token)==null?void 0:v.accessToken}`},json:{mmsi:t,startTime:i.utcOffset(8).format("YYYY-MM-DD HH:mm:ss"),endTime:n.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")}};l==null||l.info("[%s] fetch trajectory from: %s - %j",d.requestId,c,u);const f=await T.post(c,u).json();if(f.code)return l==null||l.warn("[%s] fetch trajectory failed: %j",d.requestId,c,{message:f.message,status:f.status,code:f.code}),f;let M=-1;const p=g(`${(Y=(k=f.data)==null?void 0:k[0])==null?void 0:Y.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return(y=f.data)==null||y.forEach(r=>{for(const H in r)!isNaN(r[H])&&Number(r[H])!==1/0&&(r[H]=Number(r[H]));const b=g(`${r.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00"),I=r.eta?g(`${r.eta} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00"):void 0,m=r.status,{labelCn:F,labelEn:O}=this.parseStatus(m),E={mmsi:r.mmsi,imo:o==null?void 0:o.imo,lat:r.lat,lng:r.lon,sog:r.sog,cog:r.cog,hdg:r.hdg,draught:r.draught,status:m,eta:I==null?void 0:I.unix(),destination:r.dest,positionTime:b.unix(),labelCn:F,labelEn:O,method:"trajectory",vendor:"myVessel",utc:b.utc().format()},W=Math.floor(b.diff(p,"minute",!0)/(s||1));W!==M&&(M=W,e.push(E))}),e}}class ot extends z{constructor(t){super();B(this,"token");this.token=t}async realTimePosition(t,i={}){const n="https://api.hifleet.com/position/position/get/token",o={searchParams:{mmsi:t,usertoken:this.token}},s=await T.post(n,o).json();l==null||l.info("[%s] fetch realtime position from: %s - %j",i.requestId,n,o);const e=s==null?void 0:s.list;if(!e)return l==null||l.warn("[%s] fetch realtime position failed: %j",i.requestId,n,s),s;for(const p in e)!isNaN(e[p])&&Number(e[p])!==1/0&&(e[p]=Number(e[p]));e.status=e.sp>3?0:1;const d=e.status,{labelCn:c,labelEn:u}=this.parseStatus(d),f=g(`${e.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:e.m,name:e.n,imo:e.imonumber,callSign:e.callsign,lat:Math.round(e.la/60*1e5)/1e5,lng:Math.round(e.lo/60*1e5)/1e5,length:e.l,width:e.w,draught:e.draught,sog:e.sp,cog:e.co,hdg:e.h,rot:isNaN(e.rot)?0:e.rot,eta:/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(e.eta)?g(`${e.eta} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00").unix():void 0,destination:e.destination,positionTime:f.unix(),utc:f.utc().format(),status:d,labelCn:c,labelEn:u,method:"position",vendor:"hifleet"}}async search(t,i={}){let n="https://www.hifleet.com/hifleetapi/searchVesselOL.do";const o={searchParams:{keyword:t},headers:{Referer:"https://www.hifleet.com",Origin:"https://www.hifleet.com",Host:"www.hifleet.com"}};let s=await T.post(n,o).json();l==null||l.info("[%s] fetch vessel props from: %s - %j",i.requestId,n,o),s instanceof Array&&(s=s[0]);for(const d in s)!isNaN(s[d])&&Number(s[d])!==1/0&&(s[d]=Number(s[d]));const e={mmsi:s.m,name:s.n,imo:s.i,callSign:s.c,length:s.l,breadth:s.b,draught:s.dr};return n="https://www.hifleet.com/hifleetapi/sameShipSearch.do",s=await T.post(n,o).json(),l==null||l.info("[%s] fetch vessel dead weight from: %s - %j",i.requestId,n,o),s instanceof Array&&(s=s[0]),s&&(e.deadweight=Number(s.dwt)),e}async trajectory(t,i,n,o,s=!0,e={}){var r,b,I;const d=await this.realTimePosition(t,e);let c=g(i);const u=g(n),f=g();if(s){let m=u.diff(c,"d",!0);m<0?c=u.clone().subtract(40,"d"):m<30?c.subtract(10,"d"):m<60?c.subtract(5,"d"):c=u.clone().subtract(80,"d"),m=f.diff(u,"d",!0),u.add(m>10?240:m*24,"h")}const M={searchParams:{endtime:u.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),starttime:c.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),mmsi:t,usertoken:this.token}},p="https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token",h=await T.get(p,M).json();l==null||l.info("[%s] fetch trajectory from: %s - %j",e.requestId,p,M);let v;h&&(v=((b=(r=h.ships)==null?void 0:r.offors)==null?void 0:b.ship)||[],v.length||l==null||l.warn("[%s] fetch trajectory failed: %j",e.requestId,h));const k=[];let Y=-1;const y=g(`${(I=v==null?void 0:v[0])==null?void 0:I.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");for(const m of v){for(const D in m)!isNaN(m[D])&&Number(m[D])!==1/0&&(m[D]=Number(m[D]));const F=g(`${m.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");m.status=m.sp>4?0:1;const{labelEn:O,labelCn:E}=this.parseStatus(m.status),W={mmsi:m.m,name:m.n,imo:d==null?void 0:d.imo,lat:m.la,lng:m.lo,draught:m.draught,sog:m.sp,cog:m.co,hdg:m.hdg,positionTime:F.unix(),utc:F.utc().format(),status:m.status,labelCn:E,labelEn:O,method:"trajectory",vendor:"hifleet"},H=Math.floor(F.diff(y,"minute",!0)/(o||1));H!==Y&&(Y=H,k.push(W))}return k}}class it extends z{constructor(t){super();B(this,"token");this.token=t}async realTimePosition(t,i={}){const n={searchParams:{id:t,k:this.token,enc:1}},o="https://api.shipxy.com/apicall/GetSingleShip",s=await T.get(o,n).json();if(l==null||l.info("[%s] fetch realtime position from: %s - %j",i.requestId,o,n),(s==null?void 0:s.status)!==0)return s;const e=s.data[0];for(const M in e)!isNaN(e[M])&&Number(e[M])!==1/0&&(e[M]=Number(e[M]));const{labelCn:d,labelEn:c}=await this.parseStatus(e.navistat),u=g.unix(e.lasttime);return{mmsi:e.ShipID,name:e.name,imo:e.imo,callSign:e.callsign,lat:Math.round(e.lat/1e6*1e5)/1e5,lng:Math.round(e.lon/1e6*1e5)/1e5,length:Math.round(e.length/10*100)/100,width:Math.round(e.width/10*100)/100,draught:Math.round(e.draught/1e3*100)/100,sog:Math.round(e.sog*3600/1e3/1852*100)/100,cog:Math.round(e.cog/100*100)/100,hdg:Math.round(e.hdg/100*100)/100,rot:Math.round(e.rot/100*100)/100,positionTime:e.lasttime,utc:u.utc().format(),status:e.navistat,labelEn:c,labelCn:d,method:"position",vendor:"shipxy"}}async trajectory(t,i,n,o,s=!0,e={}){var y;const d=await this.realTimePosition(t,e),c=g(i),u=g(n),f="https://api.shipxy.com/apicall/GetShipTrack",M={searchParams:{id:t,k:this.token,enc:1,cut:0,btm:c.unix(),etm:u.unix()}},p=await T.get(f,M).json();if(l==null||l.info("[%s] fetch trajectory from: %s - %j",e.requestId,f,M),(p==null?void 0:p.status)!==0)return p;const h=p==null?void 0:p.points,v=[],k=g.unix((y=h[0])==null?void 0:y.utc);let Y=-1;for(const r of h){const b=g.unix(r.utc),I={imo:d==null?void 0:d.imo,mmsi:t,sog:Math.round(r.sog*3600/1e3/1852*100)/100,cog:Math.round(r.cog/100*100)/100,lat:Math.round(r.lat/1e6*1e5)/1e5,lng:Math.round(r.lon/1e6*1e5)/1e5,positionTime:b.unix(),utc:b.utc().format(),method:"trajectory",vendor:"shipxy"},m=Math.floor(b.diff(k,"minute",!0)/(o||1));m!==Y&&(Y=m,v.push(I))}return v}}class rt extends z{constructor(t){super();B(this,"token");this.token=t}async getShipId(t,i={}){const n={headers:{appKey:this.token},json:{mmsiList:t}},o="https://api3.myships.com/sp/ships/getShipIdByMMSI",s=await T.post(o,n).json();return l==null||l.info("[%s] fetch ship id from: %s - %j",i.requestId,o,n),s.code!=="0"?s:s.data[0].shipId}async getShipInfo(t,i={}){const n={headers:{appKey:this.token},json:{shipId:t}},o="https://api3.myships.com/sp/ships/aissta",s=await T.post(o,n).json();if(l==null||l.info("[%s] fetch ship info from: %s - %j",i.requestId,o,n),s.code!=="0")return s;const e=s.data;let d=e.imo;return t==="407170"&&(d="9198379",l==null||l.warn("[%s] ship(%s) imo error: %s, should be %s",i.requestId,t,e.imo,d)),{mmsi:e.mmsi,name:e.shipnameEn,imo:d,callSign:e.callSign,length:e.length,width:e.breadth,draught:(e.draught||100)/10}}async realTimePosition(t,i={}){const n=await this.getShipId(t,i),o=await this.getShipInfo(n,i),s={headers:{appKey:this.token},json:{shipId:n}},e="https://api3.myships.com/sp/ships/position/latest",d=await T.post(e,s).json();l==null||l.info("[%s] fetch realtime position from: %s - %j",i.requestId,e,s);const c=d.data[0];for(const h in c)!isNaN(c[h])&&Number(c[h])!==1/0&&(c[h]=Number(c[h]));const{labelCn:u,labelEn:f}=await this.parseStatus(c.aisNavStatus),M=g.unix(c.posTime);return{...o,mmsi:t,lat:Math.round(c.lat/1e4/60*1e5)/1e5,lng:Math.round(c.lon/1e4/60*1e5)/1e5,sog:Math.round(c.sog/10*100)/100,cog:Math.round(c.cog/10*100)/100,hdg:Math.round(c.heading*100)/100,rot:Math.round(c.rot*100)/100,positionTime:c.posTime,utc:M.utc().format(),status:c.aisNavStatus,labelEn:f,labelCn:u,method:"position",vendor:"myship"}}async trajectory(t,i,n,o,s=!0,e={}){const d=g(i),c=g(n),u=await this.getShipId(t),f=await this.getShipInfo(u),M=[];for(;c.diff(d,"day",!0)>30;)await this.trajectoryIn30Day(u,d.unix(),d.add(30,"day").unix(),f,t,o,M);return await this.trajectoryIn30Day(u,d.unix(),c.unix(),f,t,o,M),M}async trajectoryIn30Day(t,i,n,o,s,e,d,c={}){var k;const u={headers:{appKey:this.token},json:{shipId:t,startTime:i,endTime:n}},f="https://api3.myships.com/sp/ships/position/history",M=await T.post(f,u).json();if(l==null||l.info("[%s] fetch trajectory from: %s - %j",c.requestId,f,u),M.code!=="0")return l==null||l.warn("[%s] invoke myship trajectory failed: %j",c.requestId,M),M;const p=M.data;for(const Y in p)!isNaN(p[Y])&&Number(p[Y])!==1/0&&(p[Y]=Number(p[Y]));const h=g.unix((k=p[0])==null?void 0:k.posTime);let v=-1;for(const Y of p){const y=g.unix(Y.posTime),r={imo:o==null?void 0:o.imo,mmsi:s,lat:Math.round(Y.lat/1e4/60*1e5)/1e5,lng:Math.round(Y.lon/1e4/60*1e5)/1e5,sog:Math.round(Y.sog/10*100)/100,cog:Math.round(Y.cog/10*100)/100,hdg:Math.round(Y.heading*100)/100,rot:Math.round(Y.rot*100)/100,positionTime:y.unix(),utc:y.utc().format(),method:"trajectory",vendor:"myship"},b=Math.floor(y.diff(h,"minute",!0)/(e||1));b!==v&&(v=b,d.push(r))}return d}}let C;try{C=V.getLogger("vessel")}catch{}finally{}var G=(w=>(w.NOTICE="NOTICE",w.WARN="WARN",w.HEAVY="HEAVY",w.SEVERE="SEVERE",w.ERROR="ERROR",w.FATAL="FATAL",w))(G||{});class U{parsePrinciple(a,t={}){var e,d,c;C==null||C.info("[%s] parse rule: %s",t.requestId,a);const i=new RegExp("(?<=\\[)(.+)(?=])","g"),n=a.match(i)?(e=a.match(i))==null?void 0:e[0]:void 0,o=n==null?void 0:n.split(";");if(!o)return;const s={};for(let u=0;u<(o==null?void 0:o.length);u++){const f=(c=(d=o[u].match(i))==null?void 0:d[0])==null?void 0:c.split("],");if(u===0&&!f)s.scope=o[0];else if(f)for(let M=0,p=f.length;M<p;M++){const h=this.parseRule(f[M]);h&&(s[h.level]?h.key?s[h.level][h==null?void 0:h.key]=h:s[h.level]=h:h.key?s[h.level]={[h==null?void 0:h.key]:h}:s[h.level]=h)}}return s}parseRule(a,t={}){var s;C==null||C.info("[%s] parse rule: %s",t.requestId,a),a=a.startsWith("[")?a:`[${a}`,a=a.endsWith("]")?a:`${a}]`;const i=new RegExp("(?<=\\[)(.+?)(?=])","g"),n=(s=a==null?void 0:a.match(i))==null?void 0:s[0],o=n==null?void 0:n.split(",");if(o)return{operator:o[0],number:Number.isNaN(Number(o[1]))?o[1]:Number(o[1]),level:o[2],time:Number(o[3]),key:o[4]}}checkWeather(a,t,i={}){var h,v,k,Y,y,r,b,I,m,F,O,E,W,H,D;let n=0,o=0,s=0,e=0;const d=Math.round(((v=(h=t==null?void 0:t.SEVERE)==null?void 0:h.sigWave)==null?void 0:v.number)*1.6*100)/100,c=(Y=(k=t==null?void 0:t.SEVERE)==null?void 0:k.sigWave)==null?void 0:Y.number,u=(r=(y=t==null?void 0:t.HEAVY)==null?void 0:y.sigWave)==null?void 0:r.number,f=Math.round((((I=(b=t==null?void 0:t.SEVERE)==null?void 0:b.wind)==null?void 0:I.number)+2)*100)/100,M=(F=(m=t==null?void 0:t.SEVERE)==null?void 0:m.wind)==null?void 0:F.number,p=(E=(O=t==null?void 0:t.HEAVY)==null?void 0:O.wind)==null?void 0:E.number;for(let K=0;K<(a==null?void 0:a.length);K++){const S=a[K],A=(H=(W=S==null?void 0:S.meteo)==null?void 0:W.wave)==null?void 0:H.sig,R=(D=S==null?void 0:S.meteo)==null?void 0:D.wind,Z=K?g(S.eta).diff(g(a[K-1].eta),"hour",!0):0;e=Z>e?Z:e,C==null||C.info("[%s] check sig.wave: %j",i.requestId,{...A,dgThd4Wv:d,svThd4Wv:c,hvThd4Wv:u}),(A==null?void 0:A.height)>=d?S.isDangerous=!0:(A==null?void 0:A.height)>=c?S.isSevere=!0:(A==null?void 0:A.height)>=u&&(S.isHeavy=!0),C==null||C.info("[%s] check wind: %j",i.requestId,{...R,dgThd4Wd:f,svThd4Wd:M,hvThd4Wd:p}),(R==null?void 0:R.scale)>=f?(S.isDangerous=!0,delete S.isSevere,delete S.isHeavy):(R==null?void 0:R.scale)>M?(S.isDangerous||(S.isSevere=!0),delete S.isHeavy):(R==null?void 0:R.scale)===p&&!S.isDangerous&&!S.isSevere&&(S.isHeavy=!0),n+=S.isDangerous?Z:0,o+=S.isSevere?Z:0,s+=S.isHeavy?Z:0}return n=Math.round(n*100)/100,o=Math.round(o*100)/100,s=Math.round(s*100)/100,e=Math.round(e),{sample:a,dangerous:n,severe:o,heavy:s,step:e<3?3:e,wind:{dgThd4Wd:f,svThd4Wd:M,hvThd4Wd:p},sig:{dgThd4Wv:d,svThd4Wv:c,hvThd4Wv:u}}}}const ct=new U;let N;try{N=V.getLogger("vessel")}catch{}finally{}var J=(w=>(w.common="common",w.container="container",w))(J||{}),Q=(w=>(w.Ballast="Ballast",w.Laden="Laden",w))(Q||{}),X=(w=>(w.Cp="CP",w.Perf="Basis",w.Instruct="Other",w))(X||{});class x{static blockCoefficient(a,t,i,n){let o=Math.round(a/(t*i*n)*100)/100;o=o<.55?.55:o>.85?.85:o;const s=[.55,.6,.65,.7,.75,.8,.85],e=s.map(d=>Math.abs(d-o));return s[e.indexOf(Math.min(...e))]}static froudeNumber(a,t,i=9.8){let n=Math.round(Math.sqrt(a*a/(i*t))*100)/100;return n=n<.05?.05:n>.3?.3:n,n}static amendFactor(a,t,i){const n={.55:[1.7,-1.4,-7.4],.6:[2.2,-2.5,-9.7],.65:[2.6,-3.7,-11.6],.7:[3.1,-5.3,-12.4],.75:[2.4,-10.6,-9.5],.8:[2.6,-13.1,-15.1],.85:[3.1,-18.7,28]};let s={.55:[1.7,-1.4,-7.4],.6:[2.2,-2.5,-9.7],.65:[2.6,-3.7,-11.6],.7:[3.1,-5.3,-12.4],.75:[2.6,-12.5,-13.5],.8:[3,-16.3,-21.6],.85:[3.4,-20.9,31.8]}[a];return i==="Laden"&&(s=n[a]),s[0]+s[1]*t+s[2]*Math.pow(t,2)}static directionFactor(a,t=0){let i;return a>30&&a<=60?i=(1.7-.03*Math.pow(t-4,2))/2:a>60&&a<=150?i=(.9-.06*Math.pow(t-6,2))/2:i=(.4-.03*Math.pow(t-8,2))/2,Math.round(i*1e5)/1e5}static vesselTagFactor(a,t,i,n=0){n=n>5?n-.9*(n-5):n;let o;return i==="container"?o=.7*n+Math.pow(n,6.5)/(22*Math.pow(a,2/3)):t==="Ballast"?o=.7*n+Math.pow(n,6.5)/(2.7*Math.pow(a,2/3)):o=.5*n+Math.pow(n,6.5)/(2.7*Math.pow(a,2/3)),o}static waveHeightFactor(a){return a=a<1.25?1.25:a,a=a>6?a-.9*(a-6):a,Math.round((-.144*Math.pow(a,2)+.178*a)*1e4)/1e4}static assembleProperties(a,t,i,n){var u,f;const o=a.lbp??a.length??a.lengthOverall??198.9642,s=a.draught??8,e=a.breadthMoulded??a.breadth??a.breadthExtreme??32.4572,d=a.deadweight??67035.7773;return{tag:((f=(u=a==null?void 0:a.type)==null?void 0:u.toLowerCase())==null?void 0:f.indexOf("container"))>-1?"container":"common",lbp:o,loadCondition:t,draught:s,breadthMoulded:e,displacement:Math.round((d/1.025+s*e*o*.7)*1e4)/1e4,speed:Math.round((i??14.1382)*1852/3600*1e4)/1e4,bearing:n||90}}static async speedLoseAt(a,t,i,n="",o=2,s=!0,e=!1,d={}){let c;if(t.velocity&&e&&(a.speed=L.LngLatHelper.roundPrecision(t.velocity*1852/3600,6)),s){const u=await at.MeteoHelper.queryPointFactor(t.lng,t.lat,i.valueOf(),"wind,wave,current,watertemp",n,d),f=x.weatherFactor(a,u),M=x.currentFactor(a.bearing,u==null?void 0:u.current,o);c={meteo:{...u},wxFactor:f,cFactor:M,speed:t.velocity&&e?t.velocity:Math.round((a.speed*1.943844+f+M)*100)/100,eta:i.utc().format("YYYY-MM-DDTHH:mm[Z]"),etd:i.utc().format("YYYY-MM-DDTHH:mm[Z]")}}else c={wxFactor:0,cFactor:0,speed:t.velocity&&e?t.velocity:Math.round((a.speed*1.943844+0+0)*100)/100,eta:i.utc().format("YYYY-MM-DDTHH:mm[Z]"),etd:i.utc().format("YYYY-MM-DDTHH:mm[Z]")};return delete t.meteo,delete t.wxFactor,delete t.cFactor,delete t.speed,delete t.etd,{...c,...t}}static async speedLoseInHoursStep(a,t,i,n,o,s,e="",d=!0,c=!1,u={}){t.utc();const f=[],M=[];let p=0,h=0,v,k;for(let Y=0;Y<s.length-1;Y++){let y=s[Y];y.distanceFromStart=o+h;const r=s[Y+1];if(a.bearing=L.LaneHelper.calculateBearing(y,r,!r.gcToPrevious),y.bearing=a.bearing,y.suspend&&c){y.eta=y.eta||t.format("YYYY-MM-DDTHH:mm[Z]"),y.elapsed=y.elapsed??0;const m=y.suspend-y.elapsed;if(n-p>m)n=n-p-m,t.add(m,"hour"),y.elapsed=y.suspend;else{const F=n-p;y.elapsed+=F,t.add(F,"hour"),n=0}if(N==null||N.info(`[%s] suspend ${y.elapsed} hours at %j, and remain ${n} hours need to go...`,u.requestId,y),n===0)return y.distanceFromPrevious=h,{etd:t,from:k||y,to:y,next:s.filter(F=>F),wps:f,days:M}}y=await x.speedLoseAt(a,y,t,e,0,d,c,u),k=k||y,y.important&&f.push(y),t.isSameOrAfter(i)&&(M.push(y),i.add(24,"hour"));const b=L.LaneHelper.calculateDistance(y,r,!r.gcToPrevious);let I=Math.ceil(b/k.speed*1e4)/1e4;if(p+I<n){if(p+=I,t.add(I,"hour"),delete s[Y],N==null||N.info(`[%s] go to %j from %j with ${b}nm, and cost ${I} hours`,u.requestId,{lat:r.lat,lng:r.lng},{lat:k.lat,lng:k.lng,etd:k.etd}),h+=b,s.filter(m=>m).length<=1){v=r,v.eta=t.format("YYYY-MM-DDTHH:mm[Z]"),v.distanceFromPrevious=b,v.distanceFromStart=o+h,f.push(v),delete s[Y+1];break}}else{I=n-p,t.add(I,"hour");const m=L.LngLatHelper.roundPrecision(k.speed*I,4);v=L.LaneHelper.calculateCoordinate(y,a.bearing,m,"nauticalmiles",!r.gcToPrevious),v.eta=t.format("YYYY-MM-DDTHH:mm[Z]"),s[Y]=v,N==null||N.info(`[%s] go to %j from %j with ${m}nm, and cost ${I} hours`,u.requestId,{lat:v.lat,lng:v.lng},{lat:y.lat,lng:y.lng,etd:y.etd}),h+=m,v.distanceFromPrevious=h,v.distanceFromStart=o+h;break}}return{etd:t,from:k,to:v,next:s.filter(Y=>Y),wps:f,days:M}}static currentFactor(a,t,i=0){const n=(a-(t==null?void 0:t.degree)||0)/180*Math.PI;if(Math.abs(n)===Math.PI/2)return 0;let o=((t==null?void 0:t.kts)||0)*Math.cos(n);return i&2?o=Math.ceil(o*100)/100:i&1?o=Math.floor(o*100)/100:o=Math.round(o*100)/100,Math.abs(o)>5?0:o}static weatherFactor(a,t){var f,M,p,h,v;N==null||N.debug("calculate weather factor via: %j",{...a,...t});const i=x.blockCoefficient(a.displacement,a.lbp,a.breadthMoulded,a.draught),n=x.froudeNumber(a.speed,a.lbp),o=x.amendFactor(i,n,a.loadCondition);let s=Math.abs(a.bearing%360-(((f=t==null?void 0:t.wind)==null?void 0:f.degree)%360||0));s=s>180?360-s:s;const e=x.directionFactor(s,(M=t==null?void 0:t.wind)==null?void 0:M.scale),d=x.vesselTagFactor(a.displacement,a.loadCondition,a.tag,(p=t==null?void 0:t.wind)==null?void 0:p.scale);let c=e*o*d/100*a.speed;c=Math.round(c*1.943844*1e4)/1e4*-1;const u=x.waveHeightFactor(((v=(h=t==null?void 0:t.wave)==null?void 0:h.sig)==null?void 0:v.height)??1);return c=c*.24+u*.76,N==null||N.debug("weather factor = %s",c),Math.round(c*100)/100}static async analyseInstant(a,t,i,n,o,s="",e=0,d=!0,c=!1,u={}){var R,Z,$,tt,et;const f=g().valueOf();a.lng=L.LngLatHelper.convertToStdLng(a.lng);const{route:M,waypoints:p}=o.points,h=L.LaneHelper.calculateSubRoute(a,M);if(((R=h[0])==null?void 0:R.length)<=1)return;const{v0:v,label:k}=a.sog?{v0:a.sog,label:"Other"}:{v0:n.speed,label:"CP"},Y=x.assembleProperties(i,n.loadCondition,v,0),y=p.length?L.LaneHelper.calculateSubWaypoints(a,p):[],r={from:{...a},route:h,waypoints:y,v0:v,label:k},b={hours:[],days:[],wps:[]};e||(L.LaneHelper.calculateRouteDistance(h)/n.speed<=72?e=3:e=6);let I=L.LaneHelper.simplifyRouteToCoordinates(h,y,0),m=0,F=0,O=0,E=0;t=g(t).utc();const W=t.clone();for(;I.length>0;){const P=e-t.hour()%e,_=Math.ceil(t.clone().add(P,"h").set({minute:0,second:0,millisecond:0}).diff(t,"h",!0)*1e4)/1e4,q=await x.speedLoseInHoursStep(Y,t,W,_,m,I,s,d,c,u);(Z=q.from)!=null&&Z.speed&&(b.hours.push(q.from),b.wps.push(...q.wps),b.days.push(...q.days)),I=q==null?void 0:q.next,I.length||b.hours.push(q==null?void 0:q.to),m+=(($=q==null?void 0:q.to)==null?void 0:$.distanceFromPrevious)??0}const H=b.hours;for(let P=0;P<H.length-1;P++){const _=g(H[P+1].eta).diff(H[P].etd,"hour",!0)||1;F+=H[P].wxFactor||0*_,O+=H[P].cFactor||0*_,E+=_}(tt=b.wps)==null||tt.forEach((P,_)=>{if(_){const q=b.wps[_-1],dt=P.distanceFromStart-q.distanceFromStart,st=g(P.eta).diff(g(q.etd),"h",!0);st<1?P.avgSpd=q.speed:P.avgSpd=Math.round(dt/st*100)/100}}),r.sample=b;const D=b.hours.at(-1);r.distance=Math.round(D.distanceFromStart*1e4)/1e4,r.eta=g(D.eta).toDate(),r.wxFactor=Math.round(F/E*1e4)/1e4,r.cFactor=Math.round(O/E*1e4)/1e4,r.avgSpeed=Math.round(D.distanceFromStart/E*1e4)/1e4,r.totalHrs=Math.round(E*1e4)/1e4,r.totalFoCons=Math.round((n==null?void 0:n.fo)/24*r.totalHrs*1e3)/1e3,r.totalDgoCons=Math.round((n==null?void 0:n.dgo)/24*r.totalHrs*1e3)/1e3;const S=g().valueOf()-f,A=((et=b==null?void 0:b.hours)==null?void 0:et.length)||1;return N==null||N.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms",u==null?void 0:u.requestId,S,A,Math.round(S/A*1e3)/1e3),r}static async analyseInstantWithThreshed(a,t,i,n,o,s,e="",d=3,c=!0,u=!1,f={}){var O,E,W;a.lng=L.LngLatHelper.convertToStdLng(a.lng);const M=x.assembleProperties(n,o.loadCondition,o.speed,0),p=L.LaneHelper.calculateSubRoute(a,s);if(((O=p[0])==null?void 0:O.length)<=1)return;let h=L.LaneHelper.simplifyRouteToCoordinates(p,[],0);h.forEach(H=>H.important=!0);let v=0,k=0,Y=0,y=0,r;const b={hours:[],wps:[],days:[]};for(t=g(t).utc();h.length>0;){const H=d-t.hour()%d;let D=Math.ceil(t.clone().add(H,"h").set({minute:0,second:0,millisecond:0}).diff(t,"h",!0)*1e4)/1e4;if(D=t.clone().add(D,"h").isAfter(i)?i.diff(t,"h",!0)*1e4/1e4:D,D)r=await x.speedLoseInHoursStep(M,t,i.clone(),D,v,h,e,c,u,f),(E=r.from)!=null&&E.speed&&(b.hours.push(r.from),r!=null&&r.wps&&b.wps.push(...r.wps),b.days.push(...r.days)),h=r==null?void 0:r.next,h.length||(b.hours.push(r==null?void 0:r.to),r!=null&&r.wps&&b.wps.push(...r.wps),b.days.push(r==null?void 0:r.to)),v+=((W=r==null?void 0:r.to)==null?void 0:W.distanceFromPrevious)??0;else{r&&(b.hours.push(r.to),r!=null&&r.wps&&b.wps.push(...r.wps),b.days.push(r.to));break}}const I=b.hours;for(let H=0;H<I.length-1;H++){const D=g(I[H+1].eta).diff(I[H].etd,"hour",!0);k+=I[H].wxFactor*D,Y+=I[H].cFactor*D,y+=D}const m=b.hours.at(-1);return{sample:b,distance:Math.round(((m==null?void 0:m.distanceFromStart)||0)*1e4)/1e4,eta:g(m==null?void 0:m.eta).utc().format(),wxFactor:Math.round(k/y*1e4)/1e4,cFactor:Math.round(Y/y*1e4)/1e4,avgSpeed:Math.round(((m==null?void 0:m.distanceFromStart)||0)/y*1e4)/1e4,totalHrs:Math.round(y*1e4)/1e4,to:m,route:L.LaneHelper.generateRouteAccordingToWaypoints(h)}}}j.AISImpl=z,j.AlertHelper=U,j.AlertLevel=G,j.HifleetImpl=ot,j.LoadCondition=Q,j.MyShipImpl=rt,j.MyVesselImpl=nt,j.ShipxyImpl=it,j.SpeedHelper=x,j.SpeedLabel=X,j.VesselTag=J,j.alertHelper=ct,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -130,6 +130,7 @@ export declare class SpeedHelper {
|
|
|
130
130
|
* @param eta 位置时间
|
|
131
131
|
* @param source [CMEMS, GFS, Other]
|
|
132
132
|
* @param role 1: 船东, 2: 租家, 0: 未知
|
|
133
|
+
* @param useMeteo true 启用气象分析
|
|
133
134
|
* @param useRouteParam true 启用设置速度
|
|
134
135
|
*/
|
|
135
136
|
private static speedLoseAt;
|
|
@@ -142,6 +143,7 @@ export declare class SpeedHelper {
|
|
|
142
143
|
* @param distanceFromStart 与最开始起点的距离
|
|
143
144
|
* @param keypoints 剩下的航路点
|
|
144
145
|
* @param source 气象数据源: CMEMS / GFS
|
|
146
|
+
* @param useMeteo true 启用气象分析
|
|
145
147
|
* @param useRouteParam true 启用航线上设置的参数 { suspend: 停留时长(小时), velocity: 速度(kts)}
|
|
146
148
|
* @private
|
|
147
149
|
*/
|
|
@@ -168,6 +170,7 @@ export declare class SpeedHelper {
|
|
|
168
170
|
* @param lane 航线 { points: { route, waypoints }}
|
|
169
171
|
* @param source 气象数据源,GFS or CMEMES, 默认CMEMS
|
|
170
172
|
* @param stepHrs 样本步长, 0表示动态计算(6 or 3 hrs)
|
|
173
|
+
* @param useMeteo true 启用气象分析
|
|
171
174
|
* @param useRouteParam
|
|
172
175
|
*/
|
|
173
176
|
static analyseInstant(from: any, etd: any, vessel: VesselAssemble, cp: {
|
|
@@ -181,7 +184,7 @@ export declare class SpeedHelper {
|
|
|
181
184
|
waypoints: any[];
|
|
182
185
|
};
|
|
183
186
|
voyage: any;
|
|
184
|
-
}, source?: string, stepHrs?: number, useRouteParam?: boolean, options?: {
|
|
187
|
+
}, source?: string, stepHrs?: number, useMeteo?: boolean, useRouteParam?: boolean, options?: {
|
|
185
188
|
requestId?: string;
|
|
186
189
|
}): Promise<any>;
|
|
187
190
|
/**
|
|
@@ -194,13 +197,15 @@ export declare class SpeedHelper {
|
|
|
194
197
|
* @param route 航路[[[lng, lat]]]
|
|
195
198
|
* @param source 气象数据源,GFS or CMEMES, 默认CMEMS
|
|
196
199
|
* @param stepHrs
|
|
200
|
+
* @param useMeteo true 启用气象分析
|
|
201
|
+
* @param useRouteParam
|
|
197
202
|
*/
|
|
198
203
|
static analyseInstantWithThreshed(from: any, etd: any, threshed: moment.Moment, vessel: VesselAssemble, cp: {
|
|
199
204
|
loadCondition: string;
|
|
200
205
|
speed: number;
|
|
201
206
|
fo: number;
|
|
202
207
|
dgo: number;
|
|
203
|
-
}, route: number[][][], source?: string, stepHrs?: number, useRouteParam?: boolean, options?: {
|
|
208
|
+
}, route: number[][][], source?: string, stepHrs?: number, useMeteo?: boolean, useRouteParam?: boolean, options?: {
|
|
204
209
|
requestId?: string;
|
|
205
210
|
}): Promise<{
|
|
206
211
|
sample: any;
|