@idm-plugin/geo 2.0.5 → 2.0.6
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 +3 -3
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2134,12 +2134,12 @@ class S {
|
|
|
2134
2134
|
{ hours: 0, distance: 0, spd: 0, duration: 0 }
|
|
2135
2135
|
);
|
|
2136
2136
|
d.hours = Math.round(d.duration / 3600 * 100) / 100, d.distance = Math.round(d.distance * 100) / 100, d.spd = d.hours ? Math.round(d.distance / d.hours * 100) / 100 : 0;
|
|
2137
|
-
const R = A ? Math.round(q / (A - d.hours) * 100) / 100 : 0;
|
|
2137
|
+
const R = A ? Math.round((q - d.distance) / (A - d.hours) * 100) / 100 : 0;
|
|
2138
2138
|
return {
|
|
2139
2139
|
begin: c.utc().format(),
|
|
2140
2140
|
end: O.utc().format(),
|
|
2141
|
-
distance: q,
|
|
2142
|
-
hours: A - d.hours,
|
|
2141
|
+
distance: Math.round((q - d.distance) * 100) / 100,
|
|
2142
|
+
hours: Math.round((A - d.hours) * 100) / 100,
|
|
2143
2143
|
avgSpeed: R,
|
|
2144
2144
|
stoppage: d
|
|
2145
2145
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
`;for(let p=0;p<z.length;p++)b+=`<waypoint id="${p+1}" revision="0"><position lat="${z[p].lat}" lon="${z[p].lng}" /></waypoint>
|
|
11
11
|
`;return b+=`</waypoints>
|
|
12
12
|
`,b+=`</route>
|
|
13
|
-
`,b}static coordinatesSummary(M,z=3){if(M.length>1){const b=M[0],p=M[M.length-1],c=(b==null?void 0:b.positionTime)<(p==null?void 0:p.positionTime)?U.unix(b==null?void 0:b.positionTime):U.unix(p==null?void 0:p.positionTime),O=(b==null?void 0:b.positionTime)>(p==null?void 0:p.positionTime)?U.unix(b==null?void 0:b.positionTime):U.unix(p==null?void 0:p.positionTime),A=Math.round(O.diff(c,"hours",!0)*100)/100,W=this.generateRouteAccordingToWaypoints(M,!0,!0),q=this.calculateRouteDistance(W),d=x.inspectStoppages(M,z).reduce((T,f)=>(T.duration+=f.duration,T.distance+=f.distance,T),{hours:0,distance:0,spd:0,duration:0});d.hours=Math.round(d.duration/3600*100)/100,d.distance=Math.round(d.distance*100)/100,d.spd=d.hours?Math.round(d.distance/d.hours*100)/100:0;const R=A?Math.round(q/(A-d.hours)*100)/100:0;return{begin:c.utc().format(),end:O.utc().format(),distance:q,hours:A-d.hours,avgSpeed:R,stoppage:d}}return{begin:void 0,end:void 0,distance:0,hours:0,avgSpeed:0}}static pickUTCSampleFromSpeed(M,z){var Y,d,R;if(!((d=(Y=z==null?void 0:z.sample)==null?void 0:Y.hours)!=null&&d.length))return{routes:[],hour:void 0};const b=z.sample.hours.at(0),p=U.utc(M),c=U.utc(z.eta),O=p.isAfter(c)?c:p;let A=z.sample.hours.find(T=>T.eta===O.format());if(!A){const T=z.sample.hours.filter(C=>U.utc(C.eta).isBefore(O)).at(-1),f=this.calculateSubRoute(T,z.route);A=(R=this.calculateNextCoordinateAlongRoute(T,T.speed*O.diff(U(T.etd),"hours",!0),f))==null?void 0:R.coordinate;const{cFactor:i,cog:r,wxFactor:s,meteo:P}=T,l=Math.round(A.distanceFromPrevious*1e4)/1e4,B=Math.round((l+T.distanceFromStart)*1e4)/1e4;A={...A,cFactor:i,cog:r,speed:T.speed,wxFactor:s,distanceFromStart:B,distanceFromPrevious:l,meteo:P,eta:O.format(),etd:O.format()}}A.distanceToGo=Math.round((z.distance-A.distanceFromStart)*100)/100,A.timeToGo=Math.round(c.diff(A.etd,"hours",!0)*100)/100;const W=this.calculateRangeWaypoints(b,A,z.route);return{routes:this.generateRouteAccordingToWaypoints(W),hour:A}}static pickUTCSampleFromRoute(M,z,b){var T;const p=this.calculateSubRoute(z,b),c=this.calculateRouteDistance(p),O=c/z.speed,A=U.utc(M),W=U(z.etd),q=(T=this.calculateNextCoordinateAlongRoute(z,z.speed*A.diff(U(z.etd),"hours",!0),p))==null?void 0:T.coordinate;q.speed=z.speed;const Y=W.clone().add(q.hourFromPrevious,"hour");q.eta=Math.abs(Y.diff(A,"second"))<2?A.format():Y.format(),q.etd=q.eta,q.distanceFromStart=Math.round(q.distanceFromPrevious*100)/100,q.distanceToGo=Math.round((c-q.distanceFromStart)*100)/100,q.timeToGo=Math.round(W.clone().add(O,"hour").diff(U(q.etd),"hour")*100)/100;const d=this.calculateRangeWaypoints(z,q,b);return{routes:this.generateRouteAccordingToWaypoints(d),hour:q}}static includedAngle(M,z){F==null||F.debug("calculate bearing via: %j",{bearing:M,degree:z});let b=Math.abs(M%360-(z%360||0));return b=b>180?360-b:b,b}}let G;try{G=w.getLogger("vessel")}catch{}finally{}class a0{static convert2Geojson(M){var b,p,c;const z=N.featureCollection([]);for(const O of M){const A=(b=O.history)==null?void 0:b[0];if(O.forecasts){A&&A.wind&&(A.wind.kts=A.kts);for(const W of O.forecasts){let q;const Y=[],d=[],R=U(W.date).utc(),T=`${O.name}-${W.model}`;for(const i in W==null?void 0:W.hours){const r=W.hours[i];q=q||r;const s=R.clone().add(Number(i),"hour"),P=N.point([r.lng,r.lat],{model:W.model,name:O.name,nameCn:O.nameCn,date:s.format(),hour:Number(i),format:s.format("MMM-DD/HHmm[Z]"),pressure:r.pressure>1e4?a.roundPrecision(r.pressure/100,0):a.roundPrecision(r.pressure,0),gusts:r.gusts,wind:r.wind||{},movement:r.movement,category:T,type:"forecast"});d.push(P),Y.push(P.geometry.coordinates)}const f={kts:void 0,deg:void 0};if(A){const i=U(A.updated).utc();if(q){const s=S.calculateDistance(A,q),P=U(q.utc||q.updated).diff(i,"h",!0);f.kts=Math.round(s/P*100)/100,f.deg=S.calculateBearing(A,q,!0,0)}const r=N.point([A.lng,A.lat],{model:W.model,name:O.name,nameCn:O.nameCn,date:i.format(),hour:0,format:i.format("MMM-DD/HHmm[Z]"),pressure:A.pressure>1e4?a.roundPrecision((A==null?void 0:A.pressure)/100,0):a.roundPrecision(A.pressure,0),wind:A.wind,movement:f,category:T,type:"forecast",important:!0});d.unshift(r),Y.unshift(r.geometry.coordinates)}if(z.features.push(...d),(Y==null?void 0:Y.length)>1){const i=N.lineString(a.convertToMonotonicLng2(Y),{date:(A==null?void 0:A.updated)||(R==null?void 0:R.format()),id:O.id||O.name,model:W.model,name:O.name,category:T,type:"forecast",movement:f});z.features.push(i)}}}if(z.features.sort((W,q)=>W.properties.type==="forecast"&&q.properties.type==="forecast"&&W.geometry.type==="Point"&&q.geometry.type==="Point"?U(W.properties.date).valueOf()-U(q.properties.date).valueOf():0),(p=O.history)!=null&&p.length){const W=[],q=U(A==null?void 0:A.updated).utc(),Y=U((c=O.history)==null?void 0:c.at(-1).updated).utc(),d=q.diff(Y,"h")%24>2?24:12;for(const R of O.history){const T=U(R.updated).utc(),f=T.isSameOrBefore(q)||T.isSame(Y);f&&q.add(-d,"h");const i=N.point([R.lng,R.lat],{name:O.name,nameCn:O.nameCn,date:T.format(),format:T.format("MMM-DD/HHmm[Z]"),pressure:R.pressure>1e4?a.roundPrecision(R.pressure/100,0):a.roundPrecision(R.pressure,0),kts:R.kts,level:R.type,type:"history",category:`${O.name}-history`,wind:R.wind,movement:R.movement,important:f});z.features.push(i),W.push(i.geometry.coordinates)}if(W.length===1&&W.push(W[0]),W.length>1){const R=N.lineString(a.convertToMonotonicLng2(W),{name:O.name,type:"history",updated:A==null?void 0:A.updated,pressure:(A==null?void 0:A.pressure)>1e4?a.roundPrecision((A==null?void 0:A.pressure)/100,0):a.roundPrecision(A==null?void 0:A.pressure,0),kts:A==null?void 0:A.kts,level:A==null?void 0:A.type});z.features.push(R)}}}return z}static interpolate(M,z=3){var c,O,A,W;const b=(c=M==null?void 0:M.data)==null?void 0:c.features.filter(q=>q.geometry.type==="LineString"&&q.properties.type==="forecast"),p=[];for(const q of b){const Y=q.properties.name,d=q.properties.model,R=q.properties.showCircle,T=q.properties.disabled,f=U(q.properties.date).utc();let i=z*60;const r=(O=M==null?void 0:M.data)==null?void 0:O.features.filter(l=>l.geometry.type==="Point"&&l.properties.type==="forecast"&&l.properties.category===`${Y}-${d}`);let s,P=f.clone().add(i,"minute").set({minute:0,second:0,millisecond:0});for(;s=this.pickIndex(r,P),s<=r.length-1;){if(s>0){const l=r[s],B=s===0?void 0:r[s-1],C=(i/60-((A=B==null?void 0:B.properties)==null?void 0:A.hour))/(l.properties.hour-((W=B==null?void 0:B.properties)==null?void 0:W.hour)),J=this.computeNumber(B==null?void 0:B.geometry.coordinates[0],l.geometry.coordinates[0],C),$=this.computeNumber(B==null?void 0:B.geometry.coordinates[1],l.geometry.coordinates[1],C),v=N.point([J,$],{name:Y,model:d,category:l==null?void 0:l.properties.category,date:P.format(),format:P.format("MMM-DD/HHmm[Z]"),gusts:this.computeNumber(B==null?void 0:B.properties.gusts,l.properties.gusts,C),hour:this.computeNumber(B==null?void 0:B.properties.hour,l.properties.hour,C),movement:this.computeNumber(B==null?void 0:B.properties.movement,l.properties.movement,C),pressure:this.computeNumber(B==null?void 0:B.properties.pressure,l.properties.pressure,C),wind:this.computeNumber(B==null?void 0:B.properties.wind,l.properties.wind,C),type:"forecast",disabled:T,showCircle:R});p.push(v)}i+=z*60,P=f.clone().add(i,"minute").set({minute:0,second:0,millisecond:0})}}return p}static accelPassageAt(M,z){const{t1:b,t2:p,hr:c,hours:O}=this.tropicalCenterTwin(M,24,z);return{t1:b,t2:p,hr:c,hours:O}}static diversionPassageAt(M,z,b,p={}){const{t1:c,t2:O,hr:A,hours:W}=this.tropicalCenterTwin(z,24,p);if(c&&O){if(!p.debug){const f=S.calculateDistance(M,c),i=S.calculateDistance(M,O);if(f>2*b&&i>2*b)return G==null||G.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j",p.requestId,f,i,{from:M,t1:c,t2:O,hr:A}),{}}const q=S.calculateBearing(M,c),Y=S.calculateBearing(c,O),d=Math.abs(q-Y);let R=0;d<180?R=d+90:d>=180&&(R=d-90);const T=S.calculateCoordinate(c,R,b);return G==null||G.info("[%s] the right tangent position: %j",p.requestId,{from:M,t1:c,t2:O,radius:b,bearing1:q,bearing2:Y,right:T}),{at:T,t1:c,t2:O,hr:Number(A),hours:W}}return{}}static driftPassageAt(M,z,b,p={}){const{t1:c,t2:O,hr:A,hours:W}=this.tropicalCenterTwin(z,24,p);if(c&&O){if(!p.debug){const T=S.calculateDistance(M,c),f=S.calculateDistance(M,O);if(T>2*b&&f>2*b)return G==null||G.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j",p.requestId,T,f,{from:M,t1:c,t2:O,hr:A}),{}}const q=S.calculateBearing(M,c),Y=S.calculateBearing(c,O),d=S.calculateDistance(M,c);return{at:S.calculateCoordinate(c,q-Y+180,b<d?b:d),t1:c,t2:O,hr:Number(A),hours:W}}else return G==null||G.info("[%s] no need drift: %j",p.requestId,{from:M,t1:c,t2:O,hr:A}),{}}static tropicalCenterTwin(M,z=24,b={}){var Y,d,R,T,f;let p={};(Y=M.forecasts)==null||Y.forEach(i=>{p={...i.hours,...p}});const c=((d=M==null?void 0:M.history)==null?void 0:d[0])||(p==null?void 0:p[(R=Object.keys(p))==null?void 0:R[0]]);G==null||G.info("[%s] the first tropical center: %j",b.requestId,c);let O=(T=Object.keys(p||{}).filter(i=>Number(i)<=(z<0?24:z)))==null?void 0:T.at(-1);O||(O=(f=Object.keys(p||{}).filter(i=>Number(i)<=(z<0?24:2*z)))==null?void 0:f.at(-1));const A=p==null?void 0:p[O||-1];G==null||G.info("[%s] the second tropical center: %j in %d hrs",b.requestId,A,O);const W=Object.keys(p||{}).filter(i=>Number(i)<=Number(O)),q={0:c};for(const i of W)q[i]=p[i];return{t1:c,t2:A,hr:Number(O),hours:q}}static pickIndex(M,z){let b=0;for(const p of M){if(U(p.properties.date).isAfter(z))return b===0?-1:b;b++}return b}static computeNumber(M,z,b){if(M)if(z){if(isNaN(M)&&isNaN(z)&&typeof M!="string"&&typeof z!="string"){const p={};for(const c in M)p[c]=this.computeNumber(M[c],z[c],b);return p}return Math.round((M+(z-M)*b)*100)/100}else return M;else return z}}m.AisHelper=x,m.LaneHelper=S,m.LngLatHelper=a,m.TropicalHelper=a0,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
|
13
|
+
`,b}static coordinatesSummary(M,z=3){if(M.length>1){const b=M[0],p=M[M.length-1],c=(b==null?void 0:b.positionTime)<(p==null?void 0:p.positionTime)?U.unix(b==null?void 0:b.positionTime):U.unix(p==null?void 0:p.positionTime),O=(b==null?void 0:b.positionTime)>(p==null?void 0:p.positionTime)?U.unix(b==null?void 0:b.positionTime):U.unix(p==null?void 0:p.positionTime),A=Math.round(O.diff(c,"hours",!0)*100)/100,W=this.generateRouteAccordingToWaypoints(M,!0,!0),q=this.calculateRouteDistance(W),d=x.inspectStoppages(M,z).reduce((T,f)=>(T.duration+=f.duration,T.distance+=f.distance,T),{hours:0,distance:0,spd:0,duration:0});d.hours=Math.round(d.duration/3600*100)/100,d.distance=Math.round(d.distance*100)/100,d.spd=d.hours?Math.round(d.distance/d.hours*100)/100:0;const R=A?Math.round((q-d.distance)/(A-d.hours)*100)/100:0;return{begin:c.utc().format(),end:O.utc().format(),distance:Math.round((q-d.distance)*100)/100,hours:Math.round((A-d.hours)*100)/100,avgSpeed:R,stoppage:d}}return{begin:void 0,end:void 0,distance:0,hours:0,avgSpeed:0}}static pickUTCSampleFromSpeed(M,z){var Y,d,R;if(!((d=(Y=z==null?void 0:z.sample)==null?void 0:Y.hours)!=null&&d.length))return{routes:[],hour:void 0};const b=z.sample.hours.at(0),p=U.utc(M),c=U.utc(z.eta),O=p.isAfter(c)?c:p;let A=z.sample.hours.find(T=>T.eta===O.format());if(!A){const T=z.sample.hours.filter(C=>U.utc(C.eta).isBefore(O)).at(-1),f=this.calculateSubRoute(T,z.route);A=(R=this.calculateNextCoordinateAlongRoute(T,T.speed*O.diff(U(T.etd),"hours",!0),f))==null?void 0:R.coordinate;const{cFactor:i,cog:r,wxFactor:s,meteo:P}=T,l=Math.round(A.distanceFromPrevious*1e4)/1e4,B=Math.round((l+T.distanceFromStart)*1e4)/1e4;A={...A,cFactor:i,cog:r,speed:T.speed,wxFactor:s,distanceFromStart:B,distanceFromPrevious:l,meteo:P,eta:O.format(),etd:O.format()}}A.distanceToGo=Math.round((z.distance-A.distanceFromStart)*100)/100,A.timeToGo=Math.round(c.diff(A.etd,"hours",!0)*100)/100;const W=this.calculateRangeWaypoints(b,A,z.route);return{routes:this.generateRouteAccordingToWaypoints(W),hour:A}}static pickUTCSampleFromRoute(M,z,b){var T;const p=this.calculateSubRoute(z,b),c=this.calculateRouteDistance(p),O=c/z.speed,A=U.utc(M),W=U(z.etd),q=(T=this.calculateNextCoordinateAlongRoute(z,z.speed*A.diff(U(z.etd),"hours",!0),p))==null?void 0:T.coordinate;q.speed=z.speed;const Y=W.clone().add(q.hourFromPrevious,"hour");q.eta=Math.abs(Y.diff(A,"second"))<2?A.format():Y.format(),q.etd=q.eta,q.distanceFromStart=Math.round(q.distanceFromPrevious*100)/100,q.distanceToGo=Math.round((c-q.distanceFromStart)*100)/100,q.timeToGo=Math.round(W.clone().add(O,"hour").diff(U(q.etd),"hour")*100)/100;const d=this.calculateRangeWaypoints(z,q,b);return{routes:this.generateRouteAccordingToWaypoints(d),hour:q}}static includedAngle(M,z){F==null||F.debug("calculate bearing via: %j",{bearing:M,degree:z});let b=Math.abs(M%360-(z%360||0));return b=b>180?360-b:b,b}}let G;try{G=w.getLogger("vessel")}catch{}finally{}class a0{static convert2Geojson(M){var b,p,c;const z=N.featureCollection([]);for(const O of M){const A=(b=O.history)==null?void 0:b[0];if(O.forecasts){A&&A.wind&&(A.wind.kts=A.kts);for(const W of O.forecasts){let q;const Y=[],d=[],R=U(W.date).utc(),T=`${O.name}-${W.model}`;for(const i in W==null?void 0:W.hours){const r=W.hours[i];q=q||r;const s=R.clone().add(Number(i),"hour"),P=N.point([r.lng,r.lat],{model:W.model,name:O.name,nameCn:O.nameCn,date:s.format(),hour:Number(i),format:s.format("MMM-DD/HHmm[Z]"),pressure:r.pressure>1e4?a.roundPrecision(r.pressure/100,0):a.roundPrecision(r.pressure,0),gusts:r.gusts,wind:r.wind||{},movement:r.movement,category:T,type:"forecast"});d.push(P),Y.push(P.geometry.coordinates)}const f={kts:void 0,deg:void 0};if(A){const i=U(A.updated).utc();if(q){const s=S.calculateDistance(A,q),P=U(q.utc||q.updated).diff(i,"h",!0);f.kts=Math.round(s/P*100)/100,f.deg=S.calculateBearing(A,q,!0,0)}const r=N.point([A.lng,A.lat],{model:W.model,name:O.name,nameCn:O.nameCn,date:i.format(),hour:0,format:i.format("MMM-DD/HHmm[Z]"),pressure:A.pressure>1e4?a.roundPrecision((A==null?void 0:A.pressure)/100,0):a.roundPrecision(A.pressure,0),wind:A.wind,movement:f,category:T,type:"forecast",important:!0});d.unshift(r),Y.unshift(r.geometry.coordinates)}if(z.features.push(...d),(Y==null?void 0:Y.length)>1){const i=N.lineString(a.convertToMonotonicLng2(Y),{date:(A==null?void 0:A.updated)||(R==null?void 0:R.format()),id:O.id||O.name,model:W.model,name:O.name,category:T,type:"forecast",movement:f});z.features.push(i)}}}if(z.features.sort((W,q)=>W.properties.type==="forecast"&&q.properties.type==="forecast"&&W.geometry.type==="Point"&&q.geometry.type==="Point"?U(W.properties.date).valueOf()-U(q.properties.date).valueOf():0),(p=O.history)!=null&&p.length){const W=[],q=U(A==null?void 0:A.updated).utc(),Y=U((c=O.history)==null?void 0:c.at(-1).updated).utc(),d=q.diff(Y,"h")%24>2?24:12;for(const R of O.history){const T=U(R.updated).utc(),f=T.isSameOrBefore(q)||T.isSame(Y);f&&q.add(-d,"h");const i=N.point([R.lng,R.lat],{name:O.name,nameCn:O.nameCn,date:T.format(),format:T.format("MMM-DD/HHmm[Z]"),pressure:R.pressure>1e4?a.roundPrecision(R.pressure/100,0):a.roundPrecision(R.pressure,0),kts:R.kts,level:R.type,type:"history",category:`${O.name}-history`,wind:R.wind,movement:R.movement,important:f});z.features.push(i),W.push(i.geometry.coordinates)}if(W.length===1&&W.push(W[0]),W.length>1){const R=N.lineString(a.convertToMonotonicLng2(W),{name:O.name,type:"history",updated:A==null?void 0:A.updated,pressure:(A==null?void 0:A.pressure)>1e4?a.roundPrecision((A==null?void 0:A.pressure)/100,0):a.roundPrecision(A==null?void 0:A.pressure,0),kts:A==null?void 0:A.kts,level:A==null?void 0:A.type});z.features.push(R)}}}return z}static interpolate(M,z=3){var c,O,A,W;const b=(c=M==null?void 0:M.data)==null?void 0:c.features.filter(q=>q.geometry.type==="LineString"&&q.properties.type==="forecast"),p=[];for(const q of b){const Y=q.properties.name,d=q.properties.model,R=q.properties.showCircle,T=q.properties.disabled,f=U(q.properties.date).utc();let i=z*60;const r=(O=M==null?void 0:M.data)==null?void 0:O.features.filter(l=>l.geometry.type==="Point"&&l.properties.type==="forecast"&&l.properties.category===`${Y}-${d}`);let s,P=f.clone().add(i,"minute").set({minute:0,second:0,millisecond:0});for(;s=this.pickIndex(r,P),s<=r.length-1;){if(s>0){const l=r[s],B=s===0?void 0:r[s-1],C=(i/60-((A=B==null?void 0:B.properties)==null?void 0:A.hour))/(l.properties.hour-((W=B==null?void 0:B.properties)==null?void 0:W.hour)),J=this.computeNumber(B==null?void 0:B.geometry.coordinates[0],l.geometry.coordinates[0],C),$=this.computeNumber(B==null?void 0:B.geometry.coordinates[1],l.geometry.coordinates[1],C),v=N.point([J,$],{name:Y,model:d,category:l==null?void 0:l.properties.category,date:P.format(),format:P.format("MMM-DD/HHmm[Z]"),gusts:this.computeNumber(B==null?void 0:B.properties.gusts,l.properties.gusts,C),hour:this.computeNumber(B==null?void 0:B.properties.hour,l.properties.hour,C),movement:this.computeNumber(B==null?void 0:B.properties.movement,l.properties.movement,C),pressure:this.computeNumber(B==null?void 0:B.properties.pressure,l.properties.pressure,C),wind:this.computeNumber(B==null?void 0:B.properties.wind,l.properties.wind,C),type:"forecast",disabled:T,showCircle:R});p.push(v)}i+=z*60,P=f.clone().add(i,"minute").set({minute:0,second:0,millisecond:0})}}return p}static accelPassageAt(M,z){const{t1:b,t2:p,hr:c,hours:O}=this.tropicalCenterTwin(M,24,z);return{t1:b,t2:p,hr:c,hours:O}}static diversionPassageAt(M,z,b,p={}){const{t1:c,t2:O,hr:A,hours:W}=this.tropicalCenterTwin(z,24,p);if(c&&O){if(!p.debug){const f=S.calculateDistance(M,c),i=S.calculateDistance(M,O);if(f>2*b&&i>2*b)return G==null||G.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j",p.requestId,f,i,{from:M,t1:c,t2:O,hr:A}),{}}const q=S.calculateBearing(M,c),Y=S.calculateBearing(c,O),d=Math.abs(q-Y);let R=0;d<180?R=d+90:d>=180&&(R=d-90);const T=S.calculateCoordinate(c,R,b);return G==null||G.info("[%s] the right tangent position: %j",p.requestId,{from:M,t1:c,t2:O,radius:b,bearing1:q,bearing2:Y,right:T}),{at:T,t1:c,t2:O,hr:Number(A),hours:W}}return{}}static driftPassageAt(M,z,b,p={}){const{t1:c,t2:O,hr:A,hours:W}=this.tropicalCenterTwin(z,24,p);if(c&&O){if(!p.debug){const T=S.calculateDistance(M,c),f=S.calculateDistance(M,O);if(T>2*b&&f>2*b)return G==null||G.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j",p.requestId,T,f,{from:M,t1:c,t2:O,hr:A}),{}}const q=S.calculateBearing(M,c),Y=S.calculateBearing(c,O),d=S.calculateDistance(M,c);return{at:S.calculateCoordinate(c,q-Y+180,b<d?b:d),t1:c,t2:O,hr:Number(A),hours:W}}else return G==null||G.info("[%s] no need drift: %j",p.requestId,{from:M,t1:c,t2:O,hr:A}),{}}static tropicalCenterTwin(M,z=24,b={}){var Y,d,R,T,f;let p={};(Y=M.forecasts)==null||Y.forEach(i=>{p={...i.hours,...p}});const c=((d=M==null?void 0:M.history)==null?void 0:d[0])||(p==null?void 0:p[(R=Object.keys(p))==null?void 0:R[0]]);G==null||G.info("[%s] the first tropical center: %j",b.requestId,c);let O=(T=Object.keys(p||{}).filter(i=>Number(i)<=(z<0?24:z)))==null?void 0:T.at(-1);O||(O=(f=Object.keys(p||{}).filter(i=>Number(i)<=(z<0?24:2*z)))==null?void 0:f.at(-1));const A=p==null?void 0:p[O||-1];G==null||G.info("[%s] the second tropical center: %j in %d hrs",b.requestId,A,O);const W=Object.keys(p||{}).filter(i=>Number(i)<=Number(O)),q={0:c};for(const i of W)q[i]=p[i];return{t1:c,t2:A,hr:Number(O),hours:q}}static pickIndex(M,z){let b=0;for(const p of M){if(U(p.properties.date).isAfter(z))return b===0?-1:b;b++}return b}static computeNumber(M,z,b){if(M)if(z){if(isNaN(M)&&isNaN(z)&&typeof M!="string"&&typeof z!="string"){const p={};for(const c in M)p[c]=this.computeNumber(M[c],z[c],b);return p}return Math.round((M+(z-M)*b)*100)/100}else return M;else return z}}m.AisHelper=x,m.LaneHelper=S,m.LngLatHelper=a,m.TropicalHelper=a0,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|