@idm-plugin/geo 1.2.0 → 1.2.2

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 CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as g from "@turf/turf";
2
- import D from "moment";
2
+ import N from "moment";
3
3
  import "moment-timezone";
4
4
  import E from "tz-lookup";
5
- function F(S) {
6
- return S && S.__esModule && Object.prototype.hasOwnProperty.call(S, "default") ? S.default : S;
5
+ function F(C) {
6
+ return C && C.__esModule && Object.prototype.hasOwnProperty.call(C, "default") ? C.default : C;
7
7
  }
8
8
  class x {
9
9
  log() {
@@ -18,9 +18,9 @@ class x {
18
18
  clearContext() {
19
19
  }
20
20
  }
21
- ["Trace", "Debug", "Info", "Warn", "Error", "Fatal", "Mark"].forEach((S) => {
22
- x.prototype[S.toLowerCase()] = () => {
23
- }, x.prototype[`is${S}Enabled`] = () => !1;
21
+ ["Trace", "Debug", "Info", "Warn", "Error", "Fatal", "Mark"].forEach((C) => {
22
+ x.prototype[C.toLowerCase()] = () => {
23
+ }, x.prototype[`is${C}Enabled`] = () => !1;
24
24
  });
25
25
  const L = () => {
26
26
  try {
@@ -40,7 +40,7 @@ class l {
40
40
  * @param lat
41
41
  */
42
42
  static guessTimeZoneOffset(e, t) {
43
- const n = E(t, e), o = D().tz(n).utcOffset();
43
+ const n = E(t, e), o = N().tz(n).utcOffset();
44
44
  return this.roundPrecision(o / 60, 1);
45
45
  }
46
46
  /**
@@ -182,7 +182,7 @@ class l {
182
182
  return `${o}.${i}`;
183
183
  }
184
184
  }
185
- class v {
185
+ class S {
186
186
  /**
187
187
  * 计算方位角
188
188
  * @param from 坐标 {lng, lat}
@@ -300,8 +300,8 @@ class v {
300
300
  const p = g.lineIntersect(d, u);
301
301
  let f;
302
302
  if (p.features.length) {
303
- const C = g.getCoord(p.features[0]);
304
- f = l.roundPrecision(C[1], 8);
303
+ const M = g.getCoord(p.features[0]);
304
+ f = l.roundPrecision(M[1], 8);
305
305
  } else
306
306
  f = e[r].lat;
307
307
  c > 0 ? (n.push([180 - 1e-6, f]), o.push([...n]), n = [], n.push([-(180 - 1e-6), f])) : (n.push([-(180 - 1e-6), f]), o.push([...n]), n = [], n.push([180 - 1e-6, f]));
@@ -380,8 +380,8 @@ class v {
380
380
  */
381
381
  static appendCoordinateToRoute(e, t) {
382
382
  e.lng = l.convertToStdLng(e.lng, 8);
383
- const n = v.convertRouteToCoordinates(t);
384
- return n.push(e), v.divideAccordingToLng(n);
383
+ const n = S.convertRouteToCoordinates(t);
384
+ return n.push(e), S.divideAccordingToLng(n);
385
385
  }
386
386
  /**
387
387
  * 向route头加1个坐标
@@ -389,8 +389,8 @@ class v {
389
389
  * @param route
390
390
  */
391
391
  static unshiftCoordinateToRoute(e, t) {
392
- const n = v.convertRouteToCoordinates(t);
393
- return n.unshift(e), v.divideAccordingToLng(n);
392
+ const n = S.convertRouteToCoordinates(t);
393
+ return n.unshift(e), S.divideAccordingToLng(n);
394
394
  }
395
395
  /**
396
396
  * 合并多个waypoints进航线
@@ -627,31 +627,31 @@ class v {
627
627
  var p;
628
628
  const i = e.speed || 12, s = [];
629
629
  let r = [], c = !1, a = 0, d = 0, u;
630
- if (t && n.length ? (s.push(e), n.forEach((f, C) => {
630
+ if (t && n.length ? (s.push(e), n.forEach((f, M) => {
631
631
  if (c)
632
632
  r.push(f);
633
633
  else {
634
634
  const T = [];
635
635
  let P;
636
- for (let m = 0; m < f.length; m++)
636
+ for (let b = 0; b < f.length; b++)
637
637
  if (u)
638
- T.push(f[m]);
638
+ T.push(f[b]);
639
639
  else {
640
- P = { lng: f[m][0], lat: f[m][1] };
641
- const h = this.calculateDistance(e, P, !0, 8, o);
642
- if (a += h, a < t)
643
- d += h, s.push(P), e = P;
640
+ P = { lng: f[b][0], lat: f[b][1] };
641
+ const m = this.calculateDistance(e, P, !0, 8, o);
642
+ if (a += m, a < t)
643
+ d += m, s.push(P), e = P;
644
644
  else {
645
645
  if (d = t, a === t)
646
646
  u = P, T.push([u.lng, u.lat]);
647
647
  else {
648
- const b = a - t, R = this.calculateBearing(P, e);
649
- u = this.calculateCoordinate(P, R, b, o), T.push([u.lng, u.lat]), T.push([P.lng, P.lat]);
648
+ const h = a - t, v = this.calculateBearing(P, e);
649
+ u = this.calculateCoordinate(P, v, h, o), T.push([u.lng, u.lat]), T.push([P.lng, P.lat]);
650
650
  }
651
651
  c = !0;
652
652
  }
653
653
  }
654
- T.length && r.push(T), C === n.length - 1 && !u && (u = P);
654
+ T.length && r.push(T), M === n.length - 1 && !u && (u = P);
655
655
  }
656
656
  })) : (r = n, u = { ...e }), u)
657
657
  if (s.push(u), u.distanceFromPrevious = d, u.hourFromPrevious = Math.round(d / i * 1e4) / 1e4, ((p = r[0]) == null ? void 0 : p.length) > 1) {
@@ -775,7 +775,7 @@ class v {
775
775
  return this.calculateBBox(t);
776
776
  }
777
777
  }
778
- const N = j.getLogger("vessel");
778
+ const R = j.getLogger("vessel");
779
779
  class q {
780
780
  /**
781
781
  * 将原始数据转换为geojson
@@ -788,9 +788,9 @@ class q {
788
788
  if (o.forecasts) {
789
789
  const i = (n = o.history) == null ? void 0 : n[0];
790
790
  for (const s of o.forecasts) {
791
- const r = [], c = D(s.date).utc(), a = `${o.name}-${s.model}`;
791
+ const r = [], c = N(s.date).utc(), a = `${o.name}-${s.model}`;
792
792
  if (i) {
793
- const d = D(i.updated).utc(), u = g.point([i.lng, i.lat], {
793
+ const d = N(i.updated).utc(), u = g.point([i.lng, i.lat], {
794
794
  model: s.model,
795
795
  name: o.name,
796
796
  date: d.format(),
@@ -837,7 +837,7 @@ class q {
837
837
  if (o.history) {
838
838
  const i = [];
839
839
  for (const r of o.history) {
840
- const c = D(r.updated).utc(), a = g.point([r.lng, r.lat], {
840
+ const c = N(r.updated).utc(), a = g.point([r.lng, r.lat], {
841
841
  name: o.name,
842
842
  date: c.format(),
843
843
  format: c.format("MMM-DD/HHmm[Z]"),
@@ -878,31 +878,31 @@ class q {
878
878
  var i, s, r, c;
879
879
  const n = (i = e == null ? void 0 : e.data) == null ? void 0 : i.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), o = [];
880
880
  for (const a of n) {
881
- const d = a.properties.name, u = a.properties.model, p = D(a.properties.date).utc();
882
- let f = t * 60 - (p.get("hour") * 60 + p.get("minute")) % (t * 60);
883
- const C = (s = e == null ? void 0 : e.data) == null ? void 0 : s.features.filter(
881
+ const d = a.properties.name, u = a.properties.model, p = a.properties.showCircle, f = N(a.properties.date).utc();
882
+ let M = t * 60 - (f.get("hour") * 60 + f.get("minute")) % (t * 60);
883
+ const T = (s = e == null ? void 0 : e.data) == null ? void 0 : s.features.filter(
884
884
  (m) => m.geometry.type === "Point" && m.properties.type === "forecast" && m.properties.category === `${d}-${u}`
885
885
  );
886
- let T, P = p.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
887
- for (; T = this.pickIndex(C, P), T <= C.length - 1; ) {
888
- if (T > 0) {
889
- const m = C[T], h = T === 0 ? void 0 : C[T - 1], b = (f / 60 - ((r = h == null ? void 0 : h.properties) == null ? void 0 : r.hour)) / (m.properties.hour - ((c = h == null ? void 0 : h.properties) == null ? void 0 : c.hour)), R = this.computeNumber(h == null ? void 0 : h.geometry.coordinates[0], m.geometry.coordinates[0], b), y = this.computeNumber(h == null ? void 0 : h.geometry.coordinates[1], m.geometry.coordinates[1], b), I = g.point([R, y], {
886
+ let P, b = f.clone().add(M, "minute").set({ minute: 0, second: 0, millisecond: 0 });
887
+ for (; P = this.pickIndex(T, b), P <= T.length - 1; ) {
888
+ if (P > 0) {
889
+ const m = T[P], h = P === 0 ? void 0 : T[P - 1], v = (M / 60 - ((r = h == null ? void 0 : h.properties) == null ? void 0 : r.hour)) / (m.properties.hour - ((c = h == null ? void 0 : h.properties) == null ? void 0 : c.hour)), y = this.computeNumber(h == null ? void 0 : h.geometry.coordinates[0], m.geometry.coordinates[0], v), I = this.computeNumber(h == null ? void 0 : h.geometry.coordinates[1], m.geometry.coordinates[1], v), D = g.point([y, I], {
890
890
  name: d,
891
891
  model: u,
892
892
  category: m == null ? void 0 : m.properties.category,
893
- date: P.format(),
894
- format: P.format("MMM-DD/HHmm[Z]"),
895
- gusts: this.computeNumber(h == null ? void 0 : h.properties.gusts, m.properties.gusts, b),
896
- hour: this.computeNumber(h == null ? void 0 : h.properties.hour, m.properties.hour, b),
897
- movement: this.computeNumber(h == null ? void 0 : h.properties.movement, m.properties.movement, b),
898
- pressure: this.computeNumber(h == null ? void 0 : h.properties.pressure, m.properties.pressure, b),
899
- wind: this.computeNumber(h == null ? void 0 : h.properties.wind, m.properties.wind, b),
893
+ date: b.format(),
894
+ format: b.format("MMM-DD/HHmm[Z]"),
895
+ gusts: this.computeNumber(h == null ? void 0 : h.properties.gusts, m.properties.gusts, v),
896
+ hour: this.computeNumber(h == null ? void 0 : h.properties.hour, m.properties.hour, v),
897
+ movement: this.computeNumber(h == null ? void 0 : h.properties.movement, m.properties.movement, v),
898
+ pressure: this.computeNumber(h == null ? void 0 : h.properties.pressure, m.properties.pressure, v),
899
+ wind: this.computeNumber(h == null ? void 0 : h.properties.wind, m.properties.wind, v),
900
900
  type: "forecast",
901
- showCircle: a.showCircle
901
+ showCircle: p
902
902
  });
903
- o.push(I);
903
+ o.push(D);
904
904
  }
905
- f += t * 60, P = p.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
905
+ M += t * 60, b = f.clone().add(M, "minute").set({ minute: 0, second: 0, millisecond: 0 });
906
906
  }
907
907
  }
908
908
  return o;
@@ -916,27 +916,27 @@ class q {
916
916
  * @param options
917
917
  */
918
918
  static diversionPassageAt(e, t, n, o, i = { requestId: "" }) {
919
- var d, u, p, f, C, T, P, m, h;
919
+ var d, u, p, f, M, T, P, b, m;
920
920
  const s = (u = (d = t == null ? void 0 : t.forecasts) == null ? void 0 : d[0]) == null ? void 0 : u.hours, r = ((p = t == null ? void 0 : t.history) == null ? void 0 : p[0]) || (s == null ? void 0 : s[(f = Object.keys(s)) == null ? void 0 : f[0]]);
921
- N.info("[%s] the first evasion point: %j", i.requestId, r);
922
- const c = (C = Object.keys(s || {}).filter((b) => Number(b) <= 24)) == null ? void 0 : C.at(-1), a = s == null ? void 0 : s[c || -1];
923
- if (N.info("[%s] the second evasion point in %s hrs: %j", i.requestId, c, r), r && a) {
924
- const b = v.calculateBearing(e, r), R = v.calculateBearing(r, a), y = v.calculateCoordinate(r, b - R + 90, n);
925
- N.info("[%s] the right tangent point: %j", i.requestId, { from: e, p1: r, p2: a, radius: n, bearing1: b, bearing2: R, right: y });
926
- const I = v.calculateBearing(e, y);
927
- let M = v.calculateCoordinate(e, I, o * Number(c));
928
- M.utc = D((P = (T = t == null ? void 0 : t.forecasts) == null ? void 0 : T[0]) == null ? void 0 : P.date).add(Number(c), "hours").utc().format(), N.info("[%s] the temp evasion point: %j", i.requestId, M);
929
- const $ = v.calculateDistance(M, a);
930
- return N.info("[%s] the distance(%d) between tmp & p2: %j - %j", i.requestId, $, M, a), $ < n && (M = v.calculateCoordinate(e, I, o * Number(c) / 2), M.utc = D((h = (m = t == null ? void 0 : t.forecasts) == null ? void 0 : m[0]) == null ? void 0 : h.date).add(Number(c) / 2, "hours").utc().format(), N.warn("[%s] tmp is too close to p2, replace with 1/2 position: %j", i.requestId, M)), M;
921
+ R.info("[%s] the first evasion point: %j", i.requestId, r);
922
+ const c = (M = Object.keys(s || {}).filter((h) => Number(h) <= 24)) == null ? void 0 : M.at(-1), a = s == null ? void 0 : s[c || -1];
923
+ if (R.info("[%s] the second evasion point in %s hrs: %j", i.requestId, c, r), r && a) {
924
+ const h = S.calculateBearing(e, r), v = S.calculateBearing(r, a), y = S.calculateCoordinate(r, h - v + 90, n);
925
+ R.info("[%s] the right tangent point: %j", i.requestId, { from: e, p1: r, p2: a, radius: n, bearing1: h, bearing2: v, right: y });
926
+ const I = S.calculateBearing(e, y);
927
+ let D = S.calculateCoordinate(e, I, o * Number(c));
928
+ D.utc = N((P = (T = t == null ? void 0 : t.forecasts) == null ? void 0 : T[0]) == null ? void 0 : P.date).add(Number(c), "hours").utc().format(), R.info("[%s] the temp evasion point: %j", i.requestId, D);
929
+ const $ = S.calculateDistance(D, a);
930
+ return R.info("[%s] the distance(%d) between tmp & p2: %j - %j", i.requestId, $, D, a), $ < n && (D = S.calculateCoordinate(e, I, o * Number(c) / 2), D.utc = N((m = (b = t == null ? void 0 : t.forecasts) == null ? void 0 : b[0]) == null ? void 0 : m.date).add(Number(c) / 2, "hours").utc().format(), R.warn("[%s] tmp is too close to p2, replace with 1/2 position: %j", i.requestId, D)), D;
931
931
  } else {
932
- N.info("[%s] no need evasion: %j", i.requestId, { from: e, p1: r, p2: a });
932
+ R.info("[%s] no need evasion: %j", i.requestId, { from: e, p1: r, p2: a });
933
933
  return;
934
934
  }
935
935
  }
936
936
  static pickIndex(e, t) {
937
937
  let n = 0;
938
938
  for (const o of e) {
939
- if (D(o.properties.date).isAfter(t))
939
+ if (N(o.properties.date).isAfter(t))
940
940
  return n === 0 ? -1 : n;
941
941
  n++;
942
942
  }
@@ -959,7 +959,7 @@ class q {
959
959
  }
960
960
  }
961
961
  export {
962
- v as LaneHelper,
962
+ S as LaneHelper,
963
963
  l as LngLatHelper,
964
964
  q as TropicalHelper
965
965
  };
@@ -1 +1 @@
1
- (function(C,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("@turf/turf"),require("moment"),require("moment-timezone"),require("tz-lookup")):typeof define=="function"&&define.amd?define(["exports","@turf/turf","moment","moment-timezone","tz-lookup"],I):(C=typeof globalThis<"u"?globalThis:C||self,I(C["idm-plugin-rabbitmq"]={},C["@turf/turf"],C.moment,C["moment-timezone"],C["tz-lookup"]))})(this,function(C,I,D,q,W){"use strict";function F(T){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(T){for(const t in T)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(T,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>T[t]})}}return e.default=T,Object.freeze(e)}const g=F(I);function O(T){return T&&T.__esModule&&Object.prototype.hasOwnProperty.call(T,"default")?T.default:T}class j{log(){}isLevelEnabled(){return!1}addContext(){}removeContext(){}clearContext(){}}["Trace","Debug","Info","Warn","Error","Fatal","Mark"].forEach(T=>{j.prototype[T.toLowerCase()]=()=>{},j.prototype[`is${T}Enabled`]=()=>!1});const k=(()=>{try{return require("log4js")}catch{return null}})();var E={getLogger:k?k.getLogger:()=>new j};const A=O(E);class l{static guessTimeZoneOffset(e,t){const n=W(t,e),o=D().tz(n).utcOffset();return this.roundPrecision(o/60,1)}static prettyTimeZoneOffset(e){let t=Math.floor(Math.abs(e)),n=Math.round((Math.abs(e)-t)*60);return n=n>9?n:`0${n}`,t=t>9?t:`0${t}`,e>0?`+${t}:${n}`:`-${t}:${n}`}static lng2pretty(e,t=6,n="H°M′"){e=l.convertToStdLng(e,t);let o="E";e<0&&(o="W"),e=Math.abs(e),n=n.toUpperCase();let i=e*3600,s,r,c,u,d,a;s=i%3600%60,n.indexOf("S")!==-1&&(i=i-s,r=l.padNumber(s,2,2)),c=i/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?u=l.roundPrecision(c,t).toString().padStart(2,"0"):u=l.padNumber(c,2,2),i=i-c*60),d=i/3600,n.indexOf("M")!==-1?a=l.roundPrecision(d,t).toString().padStart(3,"0"):a=l.padNumber(d,3,2);const p=`${n.replace(/S+/gi,r).replace(/M+/gi,u).replace(/H+/gi,a)}${o}`;return{direction:o,degree:l.roundPrecision(d,t),minute:l.roundPrecision(c,t),second:l.roundPrecision(s,t),pretty:p}}static lat2pretty(e,t=6,n="H°M′"){e=e%180;let o="N";e<0&&(o="S"),e=Math.abs(e),n=n.toUpperCase();let i=e*3600,s,r,c,u,d,a;s=i%3600%60,n.indexOf("S")!==-1&&(i=i-s,r=l.padNumber(s,2,2)),c=i/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?u=l.roundPrecision(c,t).toString().padStart(2,"0"):u=l.padNumber(c,2,2),i=i-c*60),d=i/3600,n.indexOf("M")!==-1?a=l.roundPrecision(d,t).toString().padStart(2,"0"):a=l.padNumber(d,2,2);const p=`${n.replace(/S+/gi,r).replace(/M+/gi,u).replace(/H+/gi,a)}${o}`;return{direction:o,degree:l.roundPrecision(d,t),minute:l.roundPrecision(c,t),second:l.roundPrecision(s,t),pretty:p}}static str2Lng(e,t=6){let n;if(isNaN(e)){e=l.strReplace(e,"LNG");const o=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const i=e.split(" ").filter(c=>c!=="").map(c=>Number(c));let[s,r]=i;if(r=r>60?r/Math.pow(10,String(r).length-2):r,s>360&&!r){const c=this.roundPrecision(s/100,0);r=s-c*100,s=c}n=s+(r??0)/60,o==="W"&&(n=n*-1)}else n=Number(e);return l.convertToStdLng(n,t)}static str2Lat(e,t=6){let n;if(isNaN(e)){e=l.strReplace(e,"LAT");const o=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const i=e.split(" ").filter(c=>c!=="").map(c=>Number(c));let[s,r]=i;if(r=r>60?r/Math.pow(10,String(r).length-2):r,s>90&&!r){const c=this.roundPrecision(s/100,0);r=s-c*100,s=c}n=s+(r??0)/60,o==="S"&&(n=n*-1)}else n=Number(e);return l.roundPrecision(n,t)}static str2LngOrLat(e,t=6,n="LAT"){e=l.strReplace(e,n);const o=e[e.length-1].toUpperCase();return["N","S"].includes(o)?{lat:l.str2Lat(e,t)}:{lng:l.str2Lng(e,t)}}static convertToStdLng(e,t=4){return e>180?(e=e%360,e=e>180?e-360:e):e<-180&&(e=e%360,e=e<-180?e+360:e),l.roundPrecision(e,t)}static roundPrecision(e,t=4){if(typeof e=="number"){const n=Number("1".padEnd(t+1,"0"));return Math.round(e*n)/n}return e}static convertToMonotonicLng2(e){for(let t=1;t<e.length;t++)e[t][0]+=Math.round((e[t-1][0]-e[t][0])/360)*360;return e}static convertToMonotonicLng(e){for(let t=1;t<e.length;t++)e[t].lng+=Math.round((e[t-1].lng-e[t].lng)/360)*360;return e}static strReplace(e,t="LAT"){e=e.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g,"$1 $2").replace(/-/g," ").replace(/°/," ").replace(/'/g," ").replace(/′/g," ").replace(/"/g," ").replace(/∼/g," ").replace(/°/g," ").replace(/,/g,".").replace(/^ /g,"").replace(/ $/g,"").trim();const n=e[e.length-1].toUpperCase();if(!["N","S","E","W"].includes(n)){const o=e,i=Number(o.split(" ")[0]);if(isNaN(i))throw new Error(`invalid Lat/Lng: ${e}`);i>=90?e=`${o}E`:i<=-90?e=`${o}W`:["LAN","LNG"].includes(t==null?void 0:t.toUpperCase())?e=`${o}${i>0?"E":"W"}`:e=`${o}${i>0?"N":"S"}`}return e}static padNumber(e,t=2,n=2){const o=Math.trunc(e).toString().padStart(t,"0"),i=Math.trunc(l.roundPrecision(e-Math.trunc(e),n)*Math.pow(10,n)).toString().padStart(n,"0");return`${o}.${i}`}}class S{static calculateBearing(e,t,n=!0,o=4){const i=g.points([[e.lng,e.lat],[t.lng,t.lat]]);let s;return n?s=g.rhumbBearing(i.features[0],i.features[1]):s=g.bearing(i.features[0],i.features[1]),s<0&&(s+=360),l.roundPrecision(s,o)}static calculateDistance(e,t,n=!0,o=4,i="nauticalmiles"){e={...e},t={...t},e.lng=l.convertToStdLng(e.lng,o),t.lng=l.convertToStdLng(t.lng,o);const s=g.points([[e.lng,e.lat],[t.lng,t.lat]]);let r;return n?r=g.rhumbDistance(s.features[0],s.features[1],{units:i}):r=g.distance(s.features[0],s.features[1],{units:i}),l.roundPrecision(r,o)}static calculateRouteDistance(e,t=4,n="nauticalmiles"){let o=0,i;for(const s of e)for(let r=0;r<s.length-1;r++){const c={lng:s[r][0],lat:s[r][1]};r===0&&i&&(o+=this.calculateDistance(i,c,!0,t,n));const u={lng:s[r+1][0],lat:s[r+1][1]};o+=this.calculateDistance(c,u,!0,t,n),i=u}return l.roundPrecision(o,t)}static calculateCoordinate(e,t,n,o="nauticalmiles",i=!0){const s=g.point([e.lng,e.lat]);let r;i?r=g.rhumbDestination(s,n,t,{units:o}):r=g.destination(s,n,t,{units:o});const c=r.geometry.coordinates;return{lng:l.convertToStdLng(c[0],8),lat:l.roundPrecision(c[1],8)}}static interpolateCoordinates(e,t,n,o=!0,i=!0,s="nauticalmiles"){const r=[],c=this.calculateBearing(e,t,!1),u=this.calculateDistance(e,t,!1,8,s);o&&r.push({lng:e.lng,lat:e.lat});let d=0;for(;d<u;)d+=n,d<u&&r.push(this.calculateCoordinate(e,c,d,s,!1));return i&&r.push({lng:t.lng,lat:t.lat}),r}static divideAccordingToLng(e,t=!1){if((e==null?void 0:e.length)<2)return[];e=this.deduplicateCoordinates(e);let n=[];const o=[];let i,s;for(let r=0;r<e.length-1;r++){i=l.convertToStdLng(e[r].lng,8),s=l.convertToStdLng(e[r+1].lng,8),n.push([i,e[r].lat]);const c=i-s;if(Math.abs(c)>180){const u=l.convertToMonotonicLng2([[i,e[r].lat],[s,e[r+1].lat]]);let d,a;t?(d=g.lineString(u),a=g.lineString([[c>0?180:-180,89],[c>0?180:-180,-89]])):(d=g.greatCircle(u[0],u[1]),a=g.greatCircle([c>0?180:-180,89],[c>0?180:-180,-89]));const p=g.lineIntersect(d,a);let h;if(p.features.length){const M=g.getCoord(p.features[0]);h=l.roundPrecision(M[1],8)}else h=e[r].lat;c>0?(n.push([180-1e-6,h]),o.push([...n]),n=[],n.push([-(180-1e-6),h])):(n.push([-(180-1e-6),h]),o.push([...n]),n=[],n.push([180-1e-6,h]))}r===e.length-2&&n.push([s,e[r+1].lat])}return o.push(n),o}static deduplicateRoute(e){const t=[];for(const n of e){const o=n.reduce((i,s)=>(i.findIndex(r=>r[0]===s[0]&&r[1]===s[1])===-1&&i.push(s),i),[]);t.push(o)}return t}static deduplicateCoordinates(e){return e.reduce((t,n)=>(t.findIndex(o=>o.lat===n.lat&&o.lng===n.lng)===-1&&t.push(n),t),[])}static removeCoordinateFromRoute(e,t){e.lng=l.convertToStdLng(e.lng,8);for(const n of t)for(let o=n.length-1;o>=0;o--)l.roundPrecision(n[o][0],8)===e.lng&&l.roundPrecision(n[o][1],8)===l.roundPrecision(e.lat,8)&&n.splice(o,1);return t}static removeCoordinateFromWaypoints(e,t){e.lng=l.convertToStdLng(e.lng,8);for(let n=t.length-1;n>=0;n--)l.roundPrecision(t[n].lng,8)===e.lng&&l.roundPrecision(t[n].lat,8)===l.roundPrecision(e.lat,8)&&t.splice(n,1);return t}static mergeCoordinateToRoute(e,t){e.lng=l.convertToStdLng(e.lng,8);let n=Number.MAX_VALUE,o=0,i=0,s,r;return t.forEach((c,u)=>{for(let d=0;d<c.length-1;d++){const a={lng:c[d][0],lat:c[d][1]},p={lng:c[d+1][0],lat:c[d+1][1]},h=this.calculatePointToLineDistance(e,a,p);n>h&&(n=h,i=d,o=u,s=this.calculateDistance(a,e),r=this.calculateDistance(p,e))}}),s!==0&&r!==0?t[o].splice(i+1,0,[e.lng,e.lat]):s===0?t[o].splice(i,1,[e.lng,e.lat]):r===0&&t[o].splice(i+1,1,[e.lng,e.lat]),t}static appendCoordinateToRoute(e,t){e.lng=l.convertToStdLng(e.lng,8);const n=S.convertRouteToCoordinates(t);return n.push(e),S.divideAccordingToLng(n)}static unshiftCoordinateToRoute(e,t){const n=S.convertRouteToCoordinates(t);return n.unshift(e),S.divideAccordingToLng(n)}static mergeWaypointsToRoute(e,t){for(const n of e)t=this.mergeCoordinateToRoute(n,t);return t}static calculateRangeRoute(e,t,n){n=this.mergeWaypointsToRoute([e,t],n);const o=[];let i=0;return n.forEach(s=>{if(i===2)return;const r=[];for(const c of s){if(l.roundPrecision(t.lng,8)===l.roundPrecision(c[0],8)&&l.roundPrecision(t.lat,8)===l.roundPrecision(c[1],8)){r.push(c),i===0&&r.push([e.lng,e.lat]),i=2;break}i===1?r.push(c):l.roundPrecision(e.lng,8)===l.roundPrecision(c[0],8)&&l.roundPrecision(e.lat,8)===l.roundPrecision(c[1],8)&&(i=1,r.push(c))}r.length&&o.push(r)}),o}static calculateRangeWaypoints(e,t,n,o=[]){const i=this.convertRouteToCoordinates(n,0),s=this.mergeCoordinatesToWaypoints([e,t,...o],i),r=s.findIndex(d=>l.roundPrecision(e.lng,8)===l.roundPrecision(d.lng,8)&&l.roundPrecision(e.lat,8)===l.roundPrecision(d.lat,8)),c=s.findIndex(d=>l.roundPrecision(t.lng,8)===l.roundPrecision(d.lng,8)&&l.roundPrecision(t.lat,8)===l.roundPrecision(d.lat,8));return s.filter((d,a)=>a>=r&&a<=c)}static calculateMinDistanceToRoute(e,t){let n=Number.MAX_VALUE,o=0,i=0;return t.forEach((s,r)=>{for(let c=0;c<s.length-1;c++){const u={lng:s[c][0],lat:s[c][1]},d={lng:s[c+1][0],lat:s[c+1][1]},a=this.calculatePointToLineDistance(e,u,d);n>a&&(n=a,o=c,i=r)}}),{minDist:n,segIndex:i,minIndex:o}}static calculateSubRoute(e,t){const{segIndex:n,minIndex:o}=this.calculateMinDistanceToRoute({...e},t);e.lng=l.convertToStdLng(e.lng);const i=[];let s=!0;for(let r=n;r<t.length;r++)if(s){const c=[];c.push([e.lng,e.lat]);for(let u=o+1;u<t[r].length;u++)e.lng===t[r][u][0]&&e.lat===t[r][u][1]||c.push(t[r][u]);i.push(c),s=!1}else i.push([...t[r]]);return i}static calculateSubWaypoints(e,t){let n=Number.MAX_VALUE,o=0;for(let s=0;s<t.length-1;s++){const r=t[s],c=t[s+1];if(this.calculateDistance(e,r)===0)return t;if(this.calculateDistance(e,c)===0)return t.filter((d,a)=>a>0);const u=this.calculatePointToLineDistance(e,r,c);n>u&&(n=u,o=s)}e.lng=l.convertToStdLng(e.lng);const i=[e];for(let s=o+1;s<t.length;s++)i.push(t[s]);return i}static calculatePointToLineDistance(e,t,n,o={units:"nauticalmiles",method:"geodesic"}){e.lng=l.convertToStdLng(e.lng),t={...t},n={...n},t.lng=l.convertToStdLng(t.lng,8),n.lng=l.convertToStdLng(n.lng,8);const i=l.convertToMonotonicLng([t,n]);t=i[0],n=i[1];const s=g.lineString([[t.lng,t.lat],[n.lng,n.lat]]),r=g.pointToLineDistance(g.point([e.lng,e.lat]),s,o),c=g.pointToLineDistance(g.point([e.lng>0?e.lng-360:e.lng+360,e.lat]),s,o);return l.roundPrecision(Math.min(r,c),6)}static calculateWaypointsPropInRoute(e,t){t=this.mergeWaypointsToRoute(e,t);for(let n=0;n<e.length-1;n++){const o=e[n],i=e[n+1],s=this.calculateRangeRoute(o,i,t);n===0&&(o.distanceFromPrevious=0,o.distanceFromStart=0),i.distanceFromPrevious=this.calculateRouteDistance(s),i.distanceFromStart=l.roundPrecision((o.distanceFromStart||0)+i.distanceFromPrevious)}return e}static mergeCoordinatesToWaypoints(e,t,n=!0){for(const o of e)this.mergeCoordinateToWaypoints(o,t,n);return t}static mergeCoordinateToWaypoints(e,t,n=!0){e.lng=l.convertToStdLng(e.lng,8);let o=Number.MAX_VALUE,i=0,s=0,r=0;for(let c=0;c<t.length-1;c++){const u={lng:t[c].lng,lat:t[c].lat},d={lng:t[c+1].lng,lat:t[c+1].lat},a=this.calculatePointToLineDistance(e,u,d);o>=a&&(o=a,i=c,s=this.calculateDistance(u,e,!1,6),r=this.calculateDistance(d,e,!1,6))}return s!==0&&r!==0?s<o||s===o&&i===0?t.unshift(e):r<o||r===o&&i===t.length-2?t.push(e):t.splice(i+1,0,e):s===0?n&&t.splice(i,1,e):r===0&&n&&t.splice(i+1,1,e),t.map(c=>(c.lng=l.convertToStdLng(c.lng),c))}static generateRouteAccordingToWaypoints(e){const t=[];for(let n=1;n<e.length;n++){const o=e[n-1],i=e[n];if(n===1&&t.push(o),i.gcToPrevious){const s=this.interpolateCoordinates(o,i,200,!1,!0,"nauticalmiles");t.push(...s)}else t.push(i)}return this.divideAccordingToLng(t,!0)}static nearestCoordinateInRoute(e,t){const n=g.point([e.lng,e.lat]),o=[];for(const c of t){const u=c.map(d=>g.point(d));o.push(...u)}const i=g.featureCollection(o),s=g.nearestPoint(n,i),r=g.getCoord(s);return{lng:r[0],lat:r[1]}}static calculatePrevWaypoint(e,t){let n=0;this.mergeCoordinateToWaypoints(e,t);for(let o=0;o<t.length-1;o++){const i=t[o],s=t[o+1];if(this.calculateDistance(e,i)===0){n=o;break}if(this.calculateDistance(e,s)===0){n=o+1;break}}return t[n===0?0:n-1]}static calculateNextCoordinateAlongRoute(e,t,n,o="nauticalmiles"){var p;const i=e.speed||12,s=[];let r=[],c=!1,u=0,d=0,a;if(t&&n.length?(s.push(e),n.forEach((h,M)=>{if(c)r.push(h);else{const P=[];let b;for(let m=0;m<h.length;m++)if(a)P.push(h[m]);else{b={lng:h[m][0],lat:h[m][1]};const f=this.calculateDistance(e,b,!0,8,o);if(u+=f,u<t)d+=f,s.push(b),e=b;else{if(d=t,u===t)a=b,P.push([a.lng,a.lat]);else{const v=u-t,R=this.calculateBearing(b,e);a=this.calculateCoordinate(b,R,v,o),P.push([a.lng,a.lat]),P.push([b.lng,b.lat])}c=!0}}P.length&&r.push(P),M===n.length-1&&!a&&(a=b)}})):(r=n,a={...e}),a)if(s.push(a),a.distanceFromPrevious=d,a.hourFromPrevious=Math.round(d/i*1e4)/1e4,((p=r[0])==null?void 0:p.length)>1){const h={lng:r[0][1][0],lat:r[0][1][1]};a.bearing=this.calculateBearing(a,h)}else a.bearing=0;return{coordinate:a,nextRoute:r,prevRoute:s}}static nearestCoordinateInLine(e,t,n){const o=l.convertToStdLng(e.lng,6),i=g.point([o,e.lat]),s=l.convertToStdLng(t.lng,6),r=l.convertToStdLng(n.lng,6),c=g.lineString([[s,t.lat],[r,n.lat]]),u=g.nearestPointOnLine(c,i),d=g.getCoord(u),a=l.roundPrecision(d[0],6),p=l.roundPrecision(d[1],6);return{lng:a,lat:p,inline:!(a===s&&p===t.lat)&&!(a===r&&p===n.lat)}}static convertRouteToCoordinates(e,t=0){const n=[];let o,i;return e.forEach(s=>{s.forEach(r=>{const c={lng:r[0],lat:r[1]};if(!i)n.push(c),i=c;else if(i.bearing===void 0)i.bearing=this.calculateBearing(i,c,!0);else{const u=this.calculateDistance(o,c,!0);u&&u>=t&&(o.bearing=this.calculateBearing(o,c,!0),n.push(o),i=o)}o=c})}),o&&n.push(o),n}static simplifyRouteToCoordinates(e,t,n=1){let o=this.convertRouteToCoordinates(e,n);return o=this.simplifyGCCoordinates(o,t),o}static simplifyGCCoordinates(e,t){t.forEach(o=>{this.mergeCoordinateToWaypoints(o,e)});for(let o=1;o<t.length;o++){const i=t[o-1],s=t[o];if(s.gcToPrevious){const r=e.findIndex(u=>u.lng===i.lng&&u.lat===i.lat),c=e.findIndex(u=>u.lng===s.lng&&u.lat===s.lat);for(let u=c-1;u>r;u--)e.splice(u,1)}}let n=0;for(let o=1;o<e.length;o++){const i=e[o-1],s=e[o];s.gcToPrevious?(i.bearing=this.calculateBearing(i,s,!1),s.distanceFromPrevious=this.calculateDistance(i,s,!1)):(i.bearing=this.calculateBearing(i,s,!0),s.distanceFromPrevious=this.calculateDistance(i,s,!0)),n=l.roundPrecision(n+s.distanceFromPrevious),s.distanceFromStart=n}return e.map(o=>(o.lng=l.convertToStdLng(o.lng),o))}static calculateCenter(e){const t=[];for(const r of e)for(const c of r)t.push(c);const n=g.featureCollection([]),o=l.convertToMonotonicLng2(t);for(const r of o)n.features.push(g.point(r));const s=g.center(n).geometry.coordinates;return{lng:l.convertToStdLng(s[0],8),lat:l.roundPrecision(s[1],8)}}static calculateCenter2(e){const t=this.generateRouteAccordingToWaypoints(e);return this.calculateCenter(t)}static calculateBBox(e){const t=[];for(const i of e)for(const s of i)t.push(s);const n=l.convertToMonotonicLng2(t),o=g.lineString(n);return g.bbox(o)}static calculateBBox2(e){const t=this.generateRouteAccordingToWaypoints(e);return this.calculateBBox(t)}}const y=A.getLogger("vessel");class B{static convert2Geojson(e){var n;const t=g.featureCollection([]);for(const o of e){if(o.forecasts){const i=(n=o.history)==null?void 0:n[0];for(const s of o.forecasts){const r=[],c=D(s.date).utc(),u=`${o.name}-${s.model}`;if(i){const d=D(i.updated).utc(),a=g.point([i.lng,i.lat],{model:s.model,name:o.name,date:d.format(),hour:0,format:d.format("MMM-DD/HHmm[Z]"),pressure:i.pressure>1e4?l.roundPrecision(i.pressure/100,0):l.roundPrecision(i.pressure,0),wind:{kts:i.kts,spd:i.speed||i.spd},category:u,type:"forecast"});t.features.push(a),r.push(a.geometry.coordinates)}for(const d in s==null?void 0:s.hours){const a=s.hours[d];a.wind.spd=a.wind.spd||a.wind.speed;const p=c.clone().add(Number(d),"hour"),h=g.point([a.lng,a.lat],{model:s.model,name:o.name,date:p.format(),hour:Number(d),format:p.format("MMM-DD/HHmm[Z]"),pressure:a.pressure>1e4?l.roundPrecision(a.pressure/100,0):l.roundPrecision(a.pressure,0),gusts:a.gusts,wind:a.wind||{},movement:a.movement,category:u,type:"forecast"});t.features.push(h),r.push(h.geometry.coordinates)}if((r==null?void 0:r.length)>1){const d=g.lineString(l.convertToMonotonicLng2(r),{date:s.date,id:o.id||o.name,model:s.model,name:o.name,category:u,type:"forecast"});t.features.push(d)}}}if(o.history){const i=[];for(const r of o.history){const c=D(r.updated).utc(),u=g.point([r.lng,r.lat],{name:o.name,date:c.format(),format:c.format("MMM-DD/HHmm[Z]"),pressure:r.pressure>1e4?l.roundPrecision(r.pressure/100,0):l.roundPrecision(r.pressure,0),spd:r.speed||r.spd,kts:r.kts,source:r.source,level:r.type,type:"history",category:`${o.name}-history`});t.features.push(u),i.push(u.geometry.coordinates)}const s=o.history[0];if(i.length===1&&i.push(i[0]),i.length>1){const r=g.lineString(l.convertToMonotonicLng2(i),{name:o.name,type:"history",updated:s==null?void 0:s.updated,pressure:(s==null?void 0:s.pressure)>1e4?l.roundPrecision((s==null?void 0:s.pressure)/100,0):l.roundPrecision(s==null?void 0:s.pressure,0),spd:(s==null?void 0:s.speed)||(s==null?void 0:s.spd),kts:s==null?void 0:s.kts,source:s==null?void 0:s.source,level:s==null?void 0:s.type});t.features.push(r)}}}return t}static interpolate(e,t=3){var i,s,r,c;const n=(i=e==null?void 0:e.data)==null?void 0:i.features.filter(u=>u.geometry.type==="LineString"&&u.properties.type==="forecast"),o=[];for(const u of n){const d=u.properties.name,a=u.properties.model,p=D(u.properties.date).utc();let h=t*60-(p.get("hour")*60+p.get("minute"))%(t*60);const M=(s=e==null?void 0:e.data)==null?void 0:s.features.filter(m=>m.geometry.type==="Point"&&m.properties.type==="forecast"&&m.properties.category===`${d}-${a}`);let P,b=p.clone().add(h,"minute").set({minute:0,second:0,millisecond:0});for(;P=this.pickIndex(M,b),P<=M.length-1;){if(P>0){const m=M[P],f=P===0?void 0:M[P-1],v=(h/60-((r=f==null?void 0:f.properties)==null?void 0:r.hour))/(m.properties.hour-((c=f==null?void 0:f.properties)==null?void 0:c.hour)),R=this.computeNumber(f==null?void 0:f.geometry.coordinates[0],m.geometry.coordinates[0],v),x=this.computeNumber(f==null?void 0:f.geometry.coordinates[1],m.geometry.coordinates[1],v),$=g.point([R,x],{name:d,model:a,category:m==null?void 0:m.properties.category,date:b.format(),format:b.format("MMM-DD/HHmm[Z]"),gusts:this.computeNumber(f==null?void 0:f.properties.gusts,m.properties.gusts,v),hour:this.computeNumber(f==null?void 0:f.properties.hour,m.properties.hour,v),movement:this.computeNumber(f==null?void 0:f.properties.movement,m.properties.movement,v),pressure:this.computeNumber(f==null?void 0:f.properties.pressure,m.properties.pressure,v),wind:this.computeNumber(f==null?void 0:f.properties.wind,m.properties.wind,v),type:"forecast",showCircle:u.showCircle});o.push($)}h+=t*60,b=p.clone().add(h,"minute").set({minute:0,second:0,millisecond:0})}}return o}static diversionPassageAt(e,t,n,o,i={requestId:""}){var d,a,p,h,M,P,b,m,f;const s=(a=(d=t==null?void 0:t.forecasts)==null?void 0:d[0])==null?void 0:a.hours,r=((p=t==null?void 0:t.history)==null?void 0:p[0])||(s==null?void 0:s[(h=Object.keys(s))==null?void 0:h[0]]);y.info("[%s] the first evasion point: %j",i.requestId,r);const c=(M=Object.keys(s||{}).filter(v=>Number(v)<=24))==null?void 0:M.at(-1),u=s==null?void 0:s[c||-1];if(y.info("[%s] the second evasion point in %s hrs: %j",i.requestId,c,r),r&&u){const v=S.calculateBearing(e,r),R=S.calculateBearing(r,u),x=S.calculateCoordinate(r,v-R+90,n);y.info("[%s] the right tangent point: %j",i.requestId,{from:e,p1:r,p2:u,radius:n,bearing1:v,bearing2:R,right:x});const $=S.calculateBearing(e,x);let N=S.calculateCoordinate(e,$,o*Number(c));N.utc=D((b=(P=t==null?void 0:t.forecasts)==null?void 0:P[0])==null?void 0:b.date).add(Number(c),"hours").utc().format(),y.info("[%s] the temp evasion point: %j",i.requestId,N);const L=S.calculateDistance(N,u);return y.info("[%s] the distance(%d) between tmp & p2: %j - %j",i.requestId,L,N,u),L<n&&(N=S.calculateCoordinate(e,$,o*Number(c)/2),N.utc=D((f=(m=t==null?void 0:t.forecasts)==null?void 0:m[0])==null?void 0:f.date).add(Number(c)/2,"hours").utc().format(),y.warn("[%s] tmp is too close to p2, replace with 1/2 position: %j",i.requestId,N)),N}else{y.info("[%s] no need evasion: %j",i.requestId,{from:e,p1:r,p2:u});return}}static pickIndex(e,t){let n=0;for(const o of e){if(D(o.properties.date).isAfter(t))return n===0?-1:n;n++}return n}static computeNumber(e,t,n){if(e)if(t){if(isNaN(e)&&isNaN(t)&&typeof e!="string"&&typeof t!="string"){const o={};for(const i in e)o[i]=this.computeNumber(e[i],t[i],n);return o}return Math.round((e+(t-e)*n)*100)/100}else return e;else return t}}C.LaneHelper=S,C.LngLatHelper=l,C.TropicalHelper=B,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
1
+ (function(C,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("@turf/turf"),require("moment"),require("moment-timezone"),require("tz-lookup")):typeof define=="function"&&define.amd?define(["exports","@turf/turf","moment","moment-timezone","tz-lookup"],I):(C=typeof globalThis<"u"?globalThis:C||self,I(C["idm-plugin-rabbitmq"]={},C["@turf/turf"],C.moment,C["moment-timezone"],C["tz-lookup"]))})(this,function(C,I,y,q,W){"use strict";function F(T){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(T){for(const t in T)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(T,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>T[t]})}}return e.default=T,Object.freeze(e)}const g=F(I);function O(T){return T&&T.__esModule&&Object.prototype.hasOwnProperty.call(T,"default")?T.default:T}class j{log(){}isLevelEnabled(){return!1}addContext(){}removeContext(){}clearContext(){}}["Trace","Debug","Info","Warn","Error","Fatal","Mark"].forEach(T=>{j.prototype[T.toLowerCase()]=()=>{},j.prototype[`is${T}Enabled`]=()=>!1});const k=(()=>{try{return require("log4js")}catch{return null}})();var E={getLogger:k?k.getLogger:()=>new j};const A=O(E);class l{static guessTimeZoneOffset(e,t){const n=W(t,e),o=y().tz(n).utcOffset();return this.roundPrecision(o/60,1)}static prettyTimeZoneOffset(e){let t=Math.floor(Math.abs(e)),n=Math.round((Math.abs(e)-t)*60);return n=n>9?n:`0${n}`,t=t>9?t:`0${t}`,e>0?`+${t}:${n}`:`-${t}:${n}`}static lng2pretty(e,t=6,n="H°M′"){e=l.convertToStdLng(e,t);let o="E";e<0&&(o="W"),e=Math.abs(e),n=n.toUpperCase();let i=e*3600,s,r,c,u,d,a;s=i%3600%60,n.indexOf("S")!==-1&&(i=i-s,r=l.padNumber(s,2,2)),c=i/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?u=l.roundPrecision(c,t).toString().padStart(2,"0"):u=l.padNumber(c,2,2),i=i-c*60),d=i/3600,n.indexOf("M")!==-1?a=l.roundPrecision(d,t).toString().padStart(3,"0"):a=l.padNumber(d,3,2);const p=`${n.replace(/S+/gi,r).replace(/M+/gi,u).replace(/H+/gi,a)}${o}`;return{direction:o,degree:l.roundPrecision(d,t),minute:l.roundPrecision(c,t),second:l.roundPrecision(s,t),pretty:p}}static lat2pretty(e,t=6,n="H°M′"){e=e%180;let o="N";e<0&&(o="S"),e=Math.abs(e),n=n.toUpperCase();let i=e*3600,s,r,c,u,d,a;s=i%3600%60,n.indexOf("S")!==-1&&(i=i-s,r=l.padNumber(s,2,2)),c=i/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?u=l.roundPrecision(c,t).toString().padStart(2,"0"):u=l.padNumber(c,2,2),i=i-c*60),d=i/3600,n.indexOf("M")!==-1?a=l.roundPrecision(d,t).toString().padStart(2,"0"):a=l.padNumber(d,2,2);const p=`${n.replace(/S+/gi,r).replace(/M+/gi,u).replace(/H+/gi,a)}${o}`;return{direction:o,degree:l.roundPrecision(d,t),minute:l.roundPrecision(c,t),second:l.roundPrecision(s,t),pretty:p}}static str2Lng(e,t=6){let n;if(isNaN(e)){e=l.strReplace(e,"LNG");const o=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const i=e.split(" ").filter(c=>c!=="").map(c=>Number(c));let[s,r]=i;if(r=r>60?r/Math.pow(10,String(r).length-2):r,s>360&&!r){const c=this.roundPrecision(s/100,0);r=s-c*100,s=c}n=s+(r??0)/60,o==="W"&&(n=n*-1)}else n=Number(e);return l.convertToStdLng(n,t)}static str2Lat(e,t=6){let n;if(isNaN(e)){e=l.strReplace(e,"LAT");const o=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const i=e.split(" ").filter(c=>c!=="").map(c=>Number(c));let[s,r]=i;if(r=r>60?r/Math.pow(10,String(r).length-2):r,s>90&&!r){const c=this.roundPrecision(s/100,0);r=s-c*100,s=c}n=s+(r??0)/60,o==="S"&&(n=n*-1)}else n=Number(e);return l.roundPrecision(n,t)}static str2LngOrLat(e,t=6,n="LAT"){e=l.strReplace(e,n);const o=e[e.length-1].toUpperCase();return["N","S"].includes(o)?{lat:l.str2Lat(e,t)}:{lng:l.str2Lng(e,t)}}static convertToStdLng(e,t=4){return e>180?(e=e%360,e=e>180?e-360:e):e<-180&&(e=e%360,e=e<-180?e+360:e),l.roundPrecision(e,t)}static roundPrecision(e,t=4){if(typeof e=="number"){const n=Number("1".padEnd(t+1,"0"));return Math.round(e*n)/n}return e}static convertToMonotonicLng2(e){for(let t=1;t<e.length;t++)e[t][0]+=Math.round((e[t-1][0]-e[t][0])/360)*360;return e}static convertToMonotonicLng(e){for(let t=1;t<e.length;t++)e[t].lng+=Math.round((e[t-1].lng-e[t].lng)/360)*360;return e}static strReplace(e,t="LAT"){e=e.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g,"$1 $2").replace(/-/g," ").replace(/°/," ").replace(/'/g," ").replace(/′/g," ").replace(/"/g," ").replace(/∼/g," ").replace(/°/g," ").replace(/,/g,".").replace(/^ /g,"").replace(/ $/g,"").trim();const n=e[e.length-1].toUpperCase();if(!["N","S","E","W"].includes(n)){const o=e,i=Number(o.split(" ")[0]);if(isNaN(i))throw new Error(`invalid Lat/Lng: ${e}`);i>=90?e=`${o}E`:i<=-90?e=`${o}W`:["LAN","LNG"].includes(t==null?void 0:t.toUpperCase())?e=`${o}${i>0?"E":"W"}`:e=`${o}${i>0?"N":"S"}`}return e}static padNumber(e,t=2,n=2){const o=Math.trunc(e).toString().padStart(t,"0"),i=Math.trunc(l.roundPrecision(e-Math.trunc(e),n)*Math.pow(10,n)).toString().padStart(n,"0");return`${o}.${i}`}}class v{static calculateBearing(e,t,n=!0,o=4){const i=g.points([[e.lng,e.lat],[t.lng,t.lat]]);let s;return n?s=g.rhumbBearing(i.features[0],i.features[1]):s=g.bearing(i.features[0],i.features[1]),s<0&&(s+=360),l.roundPrecision(s,o)}static calculateDistance(e,t,n=!0,o=4,i="nauticalmiles"){e={...e},t={...t},e.lng=l.convertToStdLng(e.lng,o),t.lng=l.convertToStdLng(t.lng,o);const s=g.points([[e.lng,e.lat],[t.lng,t.lat]]);let r;return n?r=g.rhumbDistance(s.features[0],s.features[1],{units:i}):r=g.distance(s.features[0],s.features[1],{units:i}),l.roundPrecision(r,o)}static calculateRouteDistance(e,t=4,n="nauticalmiles"){let o=0,i;for(const s of e)for(let r=0;r<s.length-1;r++){const c={lng:s[r][0],lat:s[r][1]};r===0&&i&&(o+=this.calculateDistance(i,c,!0,t,n));const u={lng:s[r+1][0],lat:s[r+1][1]};o+=this.calculateDistance(c,u,!0,t,n),i=u}return l.roundPrecision(o,t)}static calculateCoordinate(e,t,n,o="nauticalmiles",i=!0){const s=g.point([e.lng,e.lat]);let r;i?r=g.rhumbDestination(s,n,t,{units:o}):r=g.destination(s,n,t,{units:o});const c=r.geometry.coordinates;return{lng:l.convertToStdLng(c[0],8),lat:l.roundPrecision(c[1],8)}}static interpolateCoordinates(e,t,n,o=!0,i=!0,s="nauticalmiles"){const r=[],c=this.calculateBearing(e,t,!1),u=this.calculateDistance(e,t,!1,8,s);o&&r.push({lng:e.lng,lat:e.lat});let d=0;for(;d<u;)d+=n,d<u&&r.push(this.calculateCoordinate(e,c,d,s,!1));return i&&r.push({lng:t.lng,lat:t.lat}),r}static divideAccordingToLng(e,t=!1){if((e==null?void 0:e.length)<2)return[];e=this.deduplicateCoordinates(e);let n=[];const o=[];let i,s;for(let r=0;r<e.length-1;r++){i=l.convertToStdLng(e[r].lng,8),s=l.convertToStdLng(e[r+1].lng,8),n.push([i,e[r].lat]);const c=i-s;if(Math.abs(c)>180){const u=l.convertToMonotonicLng2([[i,e[r].lat],[s,e[r+1].lat]]);let d,a;t?(d=g.lineString(u),a=g.lineString([[c>0?180:-180,89],[c>0?180:-180,-89]])):(d=g.greatCircle(u[0],u[1]),a=g.greatCircle([c>0?180:-180,89],[c>0?180:-180,-89]));const p=g.lineIntersect(d,a);let h;if(p.features.length){const D=g.getCoord(p.features[0]);h=l.roundPrecision(D[1],8)}else h=e[r].lat;c>0?(n.push([180-1e-6,h]),o.push([...n]),n=[],n.push([-(180-1e-6),h])):(n.push([-(180-1e-6),h]),o.push([...n]),n=[],n.push([180-1e-6,h]))}r===e.length-2&&n.push([s,e[r+1].lat])}return o.push(n),o}static deduplicateRoute(e){const t=[];for(const n of e){const o=n.reduce((i,s)=>(i.findIndex(r=>r[0]===s[0]&&r[1]===s[1])===-1&&i.push(s),i),[]);t.push(o)}return t}static deduplicateCoordinates(e){return e.reduce((t,n)=>(t.findIndex(o=>o.lat===n.lat&&o.lng===n.lng)===-1&&t.push(n),t),[])}static removeCoordinateFromRoute(e,t){e.lng=l.convertToStdLng(e.lng,8);for(const n of t)for(let o=n.length-1;o>=0;o--)l.roundPrecision(n[o][0],8)===e.lng&&l.roundPrecision(n[o][1],8)===l.roundPrecision(e.lat,8)&&n.splice(o,1);return t}static removeCoordinateFromWaypoints(e,t){e.lng=l.convertToStdLng(e.lng,8);for(let n=t.length-1;n>=0;n--)l.roundPrecision(t[n].lng,8)===e.lng&&l.roundPrecision(t[n].lat,8)===l.roundPrecision(e.lat,8)&&t.splice(n,1);return t}static mergeCoordinateToRoute(e,t){e.lng=l.convertToStdLng(e.lng,8);let n=Number.MAX_VALUE,o=0,i=0,s,r;return t.forEach((c,u)=>{for(let d=0;d<c.length-1;d++){const a={lng:c[d][0],lat:c[d][1]},p={lng:c[d+1][0],lat:c[d+1][1]},h=this.calculatePointToLineDistance(e,a,p);n>h&&(n=h,i=d,o=u,s=this.calculateDistance(a,e),r=this.calculateDistance(p,e))}}),s!==0&&r!==0?t[o].splice(i+1,0,[e.lng,e.lat]):s===0?t[o].splice(i,1,[e.lng,e.lat]):r===0&&t[o].splice(i+1,1,[e.lng,e.lat]),t}static appendCoordinateToRoute(e,t){e.lng=l.convertToStdLng(e.lng,8);const n=v.convertRouteToCoordinates(t);return n.push(e),v.divideAccordingToLng(n)}static unshiftCoordinateToRoute(e,t){const n=v.convertRouteToCoordinates(t);return n.unshift(e),v.divideAccordingToLng(n)}static mergeWaypointsToRoute(e,t){for(const n of e)t=this.mergeCoordinateToRoute(n,t);return t}static calculateRangeRoute(e,t,n){n=this.mergeWaypointsToRoute([e,t],n);const o=[];let i=0;return n.forEach(s=>{if(i===2)return;const r=[];for(const c of s){if(l.roundPrecision(t.lng,8)===l.roundPrecision(c[0],8)&&l.roundPrecision(t.lat,8)===l.roundPrecision(c[1],8)){r.push(c),i===0&&r.push([e.lng,e.lat]),i=2;break}i===1?r.push(c):l.roundPrecision(e.lng,8)===l.roundPrecision(c[0],8)&&l.roundPrecision(e.lat,8)===l.roundPrecision(c[1],8)&&(i=1,r.push(c))}r.length&&o.push(r)}),o}static calculateRangeWaypoints(e,t,n,o=[]){const i=this.convertRouteToCoordinates(n,0),s=this.mergeCoordinatesToWaypoints([e,t,...o],i),r=s.findIndex(d=>l.roundPrecision(e.lng,8)===l.roundPrecision(d.lng,8)&&l.roundPrecision(e.lat,8)===l.roundPrecision(d.lat,8)),c=s.findIndex(d=>l.roundPrecision(t.lng,8)===l.roundPrecision(d.lng,8)&&l.roundPrecision(t.lat,8)===l.roundPrecision(d.lat,8));return s.filter((d,a)=>a>=r&&a<=c)}static calculateMinDistanceToRoute(e,t){let n=Number.MAX_VALUE,o=0,i=0;return t.forEach((s,r)=>{for(let c=0;c<s.length-1;c++){const u={lng:s[c][0],lat:s[c][1]},d={lng:s[c+1][0],lat:s[c+1][1]},a=this.calculatePointToLineDistance(e,u,d);n>a&&(n=a,o=c,i=r)}}),{minDist:n,segIndex:i,minIndex:o}}static calculateSubRoute(e,t){const{segIndex:n,minIndex:o}=this.calculateMinDistanceToRoute({...e},t);e.lng=l.convertToStdLng(e.lng);const i=[];let s=!0;for(let r=n;r<t.length;r++)if(s){const c=[];c.push([e.lng,e.lat]);for(let u=o+1;u<t[r].length;u++)e.lng===t[r][u][0]&&e.lat===t[r][u][1]||c.push(t[r][u]);i.push(c),s=!1}else i.push([...t[r]]);return i}static calculateSubWaypoints(e,t){let n=Number.MAX_VALUE,o=0;for(let s=0;s<t.length-1;s++){const r=t[s],c=t[s+1];if(this.calculateDistance(e,r)===0)return t;if(this.calculateDistance(e,c)===0)return t.filter((d,a)=>a>0);const u=this.calculatePointToLineDistance(e,r,c);n>u&&(n=u,o=s)}e.lng=l.convertToStdLng(e.lng);const i=[e];for(let s=o+1;s<t.length;s++)i.push(t[s]);return i}static calculatePointToLineDistance(e,t,n,o={units:"nauticalmiles",method:"geodesic"}){e.lng=l.convertToStdLng(e.lng),t={...t},n={...n},t.lng=l.convertToStdLng(t.lng,8),n.lng=l.convertToStdLng(n.lng,8);const i=l.convertToMonotonicLng([t,n]);t=i[0],n=i[1];const s=g.lineString([[t.lng,t.lat],[n.lng,n.lat]]),r=g.pointToLineDistance(g.point([e.lng,e.lat]),s,o),c=g.pointToLineDistance(g.point([e.lng>0?e.lng-360:e.lng+360,e.lat]),s,o);return l.roundPrecision(Math.min(r,c),6)}static calculateWaypointsPropInRoute(e,t){t=this.mergeWaypointsToRoute(e,t);for(let n=0;n<e.length-1;n++){const o=e[n],i=e[n+1],s=this.calculateRangeRoute(o,i,t);n===0&&(o.distanceFromPrevious=0,o.distanceFromStart=0),i.distanceFromPrevious=this.calculateRouteDistance(s),i.distanceFromStart=l.roundPrecision((o.distanceFromStart||0)+i.distanceFromPrevious)}return e}static mergeCoordinatesToWaypoints(e,t,n=!0){for(const o of e)this.mergeCoordinateToWaypoints(o,t,n);return t}static mergeCoordinateToWaypoints(e,t,n=!0){e.lng=l.convertToStdLng(e.lng,8);let o=Number.MAX_VALUE,i=0,s=0,r=0;for(let c=0;c<t.length-1;c++){const u={lng:t[c].lng,lat:t[c].lat},d={lng:t[c+1].lng,lat:t[c+1].lat},a=this.calculatePointToLineDistance(e,u,d);o>=a&&(o=a,i=c,s=this.calculateDistance(u,e,!1,6),r=this.calculateDistance(d,e,!1,6))}return s!==0&&r!==0?s<o||s===o&&i===0?t.unshift(e):r<o||r===o&&i===t.length-2?t.push(e):t.splice(i+1,0,e):s===0?n&&t.splice(i,1,e):r===0&&n&&t.splice(i+1,1,e),t.map(c=>(c.lng=l.convertToStdLng(c.lng),c))}static generateRouteAccordingToWaypoints(e){const t=[];for(let n=1;n<e.length;n++){const o=e[n-1],i=e[n];if(n===1&&t.push(o),i.gcToPrevious){const s=this.interpolateCoordinates(o,i,200,!1,!0,"nauticalmiles");t.push(...s)}else t.push(i)}return this.divideAccordingToLng(t,!0)}static nearestCoordinateInRoute(e,t){const n=g.point([e.lng,e.lat]),o=[];for(const c of t){const u=c.map(d=>g.point(d));o.push(...u)}const i=g.featureCollection(o),s=g.nearestPoint(n,i),r=g.getCoord(s);return{lng:r[0],lat:r[1]}}static calculatePrevWaypoint(e,t){let n=0;this.mergeCoordinateToWaypoints(e,t);for(let o=0;o<t.length-1;o++){const i=t[o],s=t[o+1];if(this.calculateDistance(e,i)===0){n=o;break}if(this.calculateDistance(e,s)===0){n=o+1;break}}return t[n===0?0:n-1]}static calculateNextCoordinateAlongRoute(e,t,n,o="nauticalmiles"){var p;const i=e.speed||12,s=[];let r=[],c=!1,u=0,d=0,a;if(t&&n.length?(s.push(e),n.forEach((h,D)=>{if(c)r.push(h);else{const P=[];let b;for(let S=0;S<h.length;S++)if(a)P.push(h[S]);else{b={lng:h[S][0],lat:h[S][1]};const m=this.calculateDistance(e,b,!0,8,o);if(u+=m,u<t)d+=m,s.push(b),e=b;else{if(d=t,u===t)a=b,P.push([a.lng,a.lat]);else{const f=u-t,M=this.calculateBearing(b,e);a=this.calculateCoordinate(b,M,f,o),P.push([a.lng,a.lat]),P.push([b.lng,b.lat])}c=!0}}P.length&&r.push(P),D===n.length-1&&!a&&(a=b)}})):(r=n,a={...e}),a)if(s.push(a),a.distanceFromPrevious=d,a.hourFromPrevious=Math.round(d/i*1e4)/1e4,((p=r[0])==null?void 0:p.length)>1){const h={lng:r[0][1][0],lat:r[0][1][1]};a.bearing=this.calculateBearing(a,h)}else a.bearing=0;return{coordinate:a,nextRoute:r,prevRoute:s}}static nearestCoordinateInLine(e,t,n){const o=l.convertToStdLng(e.lng,6),i=g.point([o,e.lat]),s=l.convertToStdLng(t.lng,6),r=l.convertToStdLng(n.lng,6),c=g.lineString([[s,t.lat],[r,n.lat]]),u=g.nearestPointOnLine(c,i),d=g.getCoord(u),a=l.roundPrecision(d[0],6),p=l.roundPrecision(d[1],6);return{lng:a,lat:p,inline:!(a===s&&p===t.lat)&&!(a===r&&p===n.lat)}}static convertRouteToCoordinates(e,t=0){const n=[];let o,i;return e.forEach(s=>{s.forEach(r=>{const c={lng:r[0],lat:r[1]};if(!i)n.push(c),i=c;else if(i.bearing===void 0)i.bearing=this.calculateBearing(i,c,!0);else{const u=this.calculateDistance(o,c,!0);u&&u>=t&&(o.bearing=this.calculateBearing(o,c,!0),n.push(o),i=o)}o=c})}),o&&n.push(o),n}static simplifyRouteToCoordinates(e,t,n=1){let o=this.convertRouteToCoordinates(e,n);return o=this.simplifyGCCoordinates(o,t),o}static simplifyGCCoordinates(e,t){t.forEach(o=>{this.mergeCoordinateToWaypoints(o,e)});for(let o=1;o<t.length;o++){const i=t[o-1],s=t[o];if(s.gcToPrevious){const r=e.findIndex(u=>u.lng===i.lng&&u.lat===i.lat),c=e.findIndex(u=>u.lng===s.lng&&u.lat===s.lat);for(let u=c-1;u>r;u--)e.splice(u,1)}}let n=0;for(let o=1;o<e.length;o++){const i=e[o-1],s=e[o];s.gcToPrevious?(i.bearing=this.calculateBearing(i,s,!1),s.distanceFromPrevious=this.calculateDistance(i,s,!1)):(i.bearing=this.calculateBearing(i,s,!0),s.distanceFromPrevious=this.calculateDistance(i,s,!0)),n=l.roundPrecision(n+s.distanceFromPrevious),s.distanceFromStart=n}return e.map(o=>(o.lng=l.convertToStdLng(o.lng),o))}static calculateCenter(e){const t=[];for(const r of e)for(const c of r)t.push(c);const n=g.featureCollection([]),o=l.convertToMonotonicLng2(t);for(const r of o)n.features.push(g.point(r));const s=g.center(n).geometry.coordinates;return{lng:l.convertToStdLng(s[0],8),lat:l.roundPrecision(s[1],8)}}static calculateCenter2(e){const t=this.generateRouteAccordingToWaypoints(e);return this.calculateCenter(t)}static calculateBBox(e){const t=[];for(const i of e)for(const s of i)t.push(s);const n=l.convertToMonotonicLng2(t),o=g.lineString(n);return g.bbox(o)}static calculateBBox2(e){const t=this.generateRouteAccordingToWaypoints(e);return this.calculateBBox(t)}}const R=A.getLogger("vessel");class B{static convert2Geojson(e){var n;const t=g.featureCollection([]);for(const o of e){if(o.forecasts){const i=(n=o.history)==null?void 0:n[0];for(const s of o.forecasts){const r=[],c=y(s.date).utc(),u=`${o.name}-${s.model}`;if(i){const d=y(i.updated).utc(),a=g.point([i.lng,i.lat],{model:s.model,name:o.name,date:d.format(),hour:0,format:d.format("MMM-DD/HHmm[Z]"),pressure:i.pressure>1e4?l.roundPrecision(i.pressure/100,0):l.roundPrecision(i.pressure,0),wind:{kts:i.kts,spd:i.speed||i.spd},category:u,type:"forecast"});t.features.push(a),r.push(a.geometry.coordinates)}for(const d in s==null?void 0:s.hours){const a=s.hours[d];a.wind.spd=a.wind.spd||a.wind.speed;const p=c.clone().add(Number(d),"hour"),h=g.point([a.lng,a.lat],{model:s.model,name:o.name,date:p.format(),hour:Number(d),format:p.format("MMM-DD/HHmm[Z]"),pressure:a.pressure>1e4?l.roundPrecision(a.pressure/100,0):l.roundPrecision(a.pressure,0),gusts:a.gusts,wind:a.wind||{},movement:a.movement,category:u,type:"forecast"});t.features.push(h),r.push(h.geometry.coordinates)}if((r==null?void 0:r.length)>1){const d=g.lineString(l.convertToMonotonicLng2(r),{date:s.date,id:o.id||o.name,model:s.model,name:o.name,category:u,type:"forecast"});t.features.push(d)}}}if(o.history){const i=[];for(const r of o.history){const c=y(r.updated).utc(),u=g.point([r.lng,r.lat],{name:o.name,date:c.format(),format:c.format("MMM-DD/HHmm[Z]"),pressure:r.pressure>1e4?l.roundPrecision(r.pressure/100,0):l.roundPrecision(r.pressure,0),spd:r.speed||r.spd,kts:r.kts,source:r.source,level:r.type,type:"history",category:`${o.name}-history`});t.features.push(u),i.push(u.geometry.coordinates)}const s=o.history[0];if(i.length===1&&i.push(i[0]),i.length>1){const r=g.lineString(l.convertToMonotonicLng2(i),{name:o.name,type:"history",updated:s==null?void 0:s.updated,pressure:(s==null?void 0:s.pressure)>1e4?l.roundPrecision((s==null?void 0:s.pressure)/100,0):l.roundPrecision(s==null?void 0:s.pressure,0),spd:(s==null?void 0:s.speed)||(s==null?void 0:s.spd),kts:s==null?void 0:s.kts,source:s==null?void 0:s.source,level:s==null?void 0:s.type});t.features.push(r)}}}return t}static interpolate(e,t=3){var i,s,r,c;const n=(i=e==null?void 0:e.data)==null?void 0:i.features.filter(u=>u.geometry.type==="LineString"&&u.properties.type==="forecast"),o=[];for(const u of n){const d=u.properties.name,a=u.properties.model,p=u.properties.showCircle,h=y(u.properties.date).utc();let D=t*60-(h.get("hour")*60+h.get("minute"))%(t*60);const P=(s=e==null?void 0:e.data)==null?void 0:s.features.filter(m=>m.geometry.type==="Point"&&m.properties.type==="forecast"&&m.properties.category===`${d}-${a}`);let b,S=h.clone().add(D,"minute").set({minute:0,second:0,millisecond:0});for(;b=this.pickIndex(P,S),b<=P.length-1;){if(b>0){const m=P[b],f=b===0?void 0:P[b-1],M=(D/60-((r=f==null?void 0:f.properties)==null?void 0:r.hour))/(m.properties.hour-((c=f==null?void 0:f.properties)==null?void 0:c.hour)),x=this.computeNumber(f==null?void 0:f.geometry.coordinates[0],m.geometry.coordinates[0],M),$=this.computeNumber(f==null?void 0:f.geometry.coordinates[1],m.geometry.coordinates[1],M),N=g.point([x,$],{name:d,model:a,category:m==null?void 0:m.properties.category,date:S.format(),format:S.format("MMM-DD/HHmm[Z]"),gusts:this.computeNumber(f==null?void 0:f.properties.gusts,m.properties.gusts,M),hour:this.computeNumber(f==null?void 0:f.properties.hour,m.properties.hour,M),movement:this.computeNumber(f==null?void 0:f.properties.movement,m.properties.movement,M),pressure:this.computeNumber(f==null?void 0:f.properties.pressure,m.properties.pressure,M),wind:this.computeNumber(f==null?void 0:f.properties.wind,m.properties.wind,M),type:"forecast",showCircle:p});o.push(N)}D+=t*60,S=h.clone().add(D,"minute").set({minute:0,second:0,millisecond:0})}}return o}static diversionPassageAt(e,t,n,o,i={requestId:""}){var d,a,p,h,D,P,b,S,m;const s=(a=(d=t==null?void 0:t.forecasts)==null?void 0:d[0])==null?void 0:a.hours,r=((p=t==null?void 0:t.history)==null?void 0:p[0])||(s==null?void 0:s[(h=Object.keys(s))==null?void 0:h[0]]);R.info("[%s] the first evasion point: %j",i.requestId,r);const c=(D=Object.keys(s||{}).filter(f=>Number(f)<=24))==null?void 0:D.at(-1),u=s==null?void 0:s[c||-1];if(R.info("[%s] the second evasion point in %s hrs: %j",i.requestId,c,r),r&&u){const f=v.calculateBearing(e,r),M=v.calculateBearing(r,u),x=v.calculateCoordinate(r,f-M+90,n);R.info("[%s] the right tangent point: %j",i.requestId,{from:e,p1:r,p2:u,radius:n,bearing1:f,bearing2:M,right:x});const $=v.calculateBearing(e,x);let N=v.calculateCoordinate(e,$,o*Number(c));N.utc=y((b=(P=t==null?void 0:t.forecasts)==null?void 0:P[0])==null?void 0:b.date).add(Number(c),"hours").utc().format(),R.info("[%s] the temp evasion point: %j",i.requestId,N);const L=v.calculateDistance(N,u);return R.info("[%s] the distance(%d) between tmp & p2: %j - %j",i.requestId,L,N,u),L<n&&(N=v.calculateCoordinate(e,$,o*Number(c)/2),N.utc=y((m=(S=t==null?void 0:t.forecasts)==null?void 0:S[0])==null?void 0:m.date).add(Number(c)/2,"hours").utc().format(),R.warn("[%s] tmp is too close to p2, replace with 1/2 position: %j",i.requestId,N)),N}else{R.info("[%s] no need evasion: %j",i.requestId,{from:e,p1:r,p2:u});return}}static pickIndex(e,t){let n=0;for(const o of e){if(y(o.properties.date).isAfter(t))return n===0?-1:n;n++}return n}static computeNumber(e,t,n){if(e)if(t){if(isNaN(e)&&isNaN(t)&&typeof e!="string"&&typeof t!="string"){const o={};for(const i in e)o[i]=this.computeNumber(e[i],t[i],n);return o}return Math.round((e+(t-e)*n)*100)/100}else return e;else return t}}C.LaneHelper=v,C.LngLatHelper=l,C.TropicalHelper=B,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idm-plugin/geo",
3
3
  "private": false,
4
- "version": "1.2.0",
4
+ "version": "1.2.2",
5
5
  "description": "idm plugin for geo",
6
6
  "type": "module",
7
7
  "keywords": [