@idm-plugin/geo 1.3.5 → 1.3.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/README.md CHANGED
@@ -1,2 +1,2 @@
1
- ## Geo Plugin
1
+ ## Geo Plugin
2
2
  Geo插件
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as g from "@turf/turf";
2
2
  import R from "moment";
3
3
  import "moment-timezone";
4
- import E from "tz-lookup";
5
- function k(C) {
4
+ import A from "tz-lookup";
5
+ function E(C) {
6
6
  return C && C.__esModule && Object.prototype.hasOwnProperty.call(C, "default") ? C.default : C;
7
7
  }
8
8
  class y {
@@ -22,17 +22,17 @@ class y {
22
22
  y.prototype[C.toLowerCase()] = () => {
23
23
  }, y.prototype[`is${C}Enabled`] = () => !1;
24
24
  });
25
- const A = () => {
25
+ const k = () => {
26
26
  try {
27
27
  return require("log4js");
28
28
  } catch {
29
29
  return null;
30
30
  }
31
- }, x = A(), L = x ? x.getLogger : () => new y();
32
- var F = {
33
- getLogger: L
31
+ }, x = k(), F = x ? x.getLogger : () => new y();
32
+ var L = {
33
+ getLogger: F
34
34
  };
35
- const O = /* @__PURE__ */ k(F);
35
+ const O = /* @__PURE__ */ E(L);
36
36
  class l {
37
37
  /**
38
38
  * 基于输入的经度,计算出时区
@@ -40,7 +40,7 @@ class l {
40
40
  * @param lat
41
41
  */
42
42
  static guessTimeZoneOffset(t, e) {
43
- const n = E(e, t), s = R().tz(n).utcOffset();
43
+ const n = A(e, t), s = R().tz(n).utcOffset();
44
44
  return this.roundPrecision(s / 60, 1);
45
45
  }
46
46
  /**
@@ -182,7 +182,7 @@ class l {
182
182
  return `${s}.${o}`;
183
183
  }
184
184
  }
185
- class S {
185
+ class P {
186
186
  /**
187
187
  * 计算方位角
188
188
  * @param from 坐标 {lng, lat}
@@ -300,8 +300,8 @@ class S {
300
300
  const f = g.lineIntersect(d, u);
301
301
  let h;
302
302
  if (f.features.length) {
303
- const P = g.getCoord(f.features[0]);
304
- h = l.roundPrecision(P[1], 8);
303
+ const T = g.getCoord(f.features[0]);
304
+ h = l.roundPrecision(T[1], 8);
305
305
  } else
306
306
  h = t[r].lat;
307
307
  c > 0 ? (n.push([180 - 1e-6, h]), s.push([...n]), n = [], n.push([-(180 - 1e-6), h])) : (n.push([-(180 - 1e-6), h]), s.push([...n]), n = [], n.push([180 - 1e-6, h]));
@@ -380,8 +380,8 @@ class S {
380
380
  */
381
381
  static appendCoordinateToRoute(t, e) {
382
382
  t.lng = l.convertToStdLng(t.lng, 8);
383
- const n = S.convertRouteToCoordinates(e);
384
- return n.push(t), S.divideAccordingToLng(n);
383
+ const n = P.convertRouteToCoordinates(e);
384
+ return n.push(t), P.divideAccordingToLng(n);
385
385
  }
386
386
  /**
387
387
  * 向route头加1个坐标
@@ -389,8 +389,8 @@ class S {
389
389
  * @param route
390
390
  */
391
391
  static unshiftCoordinateToRoute(t, e) {
392
- const n = S.convertRouteToCoordinates(e);
393
- return n.unshift(t), S.divideAccordingToLng(n);
392
+ const n = P.convertRouteToCoordinates(e);
393
+ return n.unshift(t), P.divideAccordingToLng(n);
394
394
  }
395
395
  /**
396
396
  * 合并多个waypoints进航线
@@ -464,20 +464,22 @@ class S {
464
464
  * @return [[[lng, lat]]]
465
465
  */
466
466
  static calculateSubRoute(t, e) {
467
- const { segIndex: n, minIndex: s } = this.calculateMinDistanceToRoute({ ...t }, e);
467
+ const n = P.convertRouteToCoordinates(e);
468
+ P.mergeCoordinateToWaypoints(t, n, !0), e = P.divideAccordingToLng(n);
469
+ const { segIndex: s, minIndex: o } = this.calculateMinDistanceToRoute({ ...t }, e);
468
470
  t.lng = l.convertToStdLng(t.lng);
469
- const o = [];
470
- let i = !0;
471
- for (let r = n; r < e.length; r++)
472
- if (i) {
473
- const c = [];
474
- c.push([t.lng, t.lat]);
475
- for (let a = s + 1; a < e[r].length; a++)
476
- t.lng === e[r][a][0] && t.lat === e[r][a][1] || c.push(e[r][a]);
477
- o.push(c), i = !1;
471
+ const i = [];
472
+ let r = !0;
473
+ for (let c = s; c < e.length; c++)
474
+ if (r) {
475
+ const a = [];
476
+ a.push([t.lng, t.lat]);
477
+ for (let d = o + 1; d < e[c].length; d++)
478
+ t.lng === e[c][d][0] && t.lat === e[c][d][1] || a.push(e[c][d]);
479
+ i.push(a), r = !1;
478
480
  } else
479
- o.push([...e[r]]);
480
- return o;
481
+ i.push([...e[c]]);
482
+ return i;
481
483
  }
482
484
  /**
483
485
  * 计算子途经点
@@ -622,31 +624,31 @@ class S {
622
624
  var f;
623
625
  const o = t.speed || 12, i = [];
624
626
  let r = [], c = !1, a = 0, d = 0, u;
625
- if (e && n.length ? (i.push(t), n.forEach((h, P) => {
627
+ if (e && n.length ? (i.push(t), n.forEach((h, T) => {
626
628
  if (c)
627
629
  r.push(h);
628
630
  else {
629
631
  const m = [];
630
- let v;
632
+ let S;
631
633
  for (let M = 0; M < h.length; M++)
632
634
  if (u)
633
635
  m.push(h[M]);
634
636
  else {
635
- v = { lng: h[M][0], lat: h[M][1] };
636
- const D = this.calculateDistance(t, v, !0, 8, s);
637
+ S = { lng: h[M][0], lat: h[M][1] };
638
+ const D = this.calculateDistance(t, S, !0, 8, s);
637
639
  if (a += D, a < e)
638
- d += D, i.push(v), t = v;
640
+ d += D, i.push(S), t = S;
639
641
  else {
640
642
  if (d = e, a === e)
641
- u = v, m.push([u.lng, u.lat]);
643
+ u = S, m.push([u.lng, u.lat]);
642
644
  else {
643
- const T = a - e, p = this.calculateBearing(v, t);
644
- u = this.calculateCoordinate(v, p, T, s), m.push([u.lng, u.lat]), m.push([v.lng, v.lat]);
645
+ const v = a - e, p = this.calculateBearing(S, t);
646
+ u = this.calculateCoordinate(S, p, v, s), m.push([u.lng, u.lat]), m.push([S.lng, S.lat]);
645
647
  }
646
648
  c = !0;
647
649
  }
648
650
  }
649
- m.length && r.push(m), P === n.length - 1 && !u && (u = v);
651
+ m.length && r.push(m), T === n.length - 1 && !u && (u = S);
650
652
  }
651
653
  })) : (r = n, u = { ...t }), u)
652
654
  if (i.push(u), u.distanceFromPrevious = d, u.hourFromPrevious = Math.round(d / o * 1e4) / 1e4, ((f = r[0]) == null ? void 0 : f.length) > 1) {
@@ -878,32 +880,32 @@ class q {
878
880
  var o, i, r, c;
879
881
  const n = (o = t == null ? void 0 : t.data) == null ? void 0 : o.features.filter((a) => a.geometry.type === "LineString" && a.properties.type === "forecast"), s = [];
880
882
  for (const a of n) {
881
- const d = a.properties.name, u = a.properties.model, f = a.properties.showCircle, h = a.properties.disabled, P = R(a.properties.date).utc();
882
- let m = e * 60 - (P.get("hour") * 60 + P.get("minute")) % (e * 60);
883
- const v = (i = t == null ? void 0 : t.data) == null ? void 0 : i.features.filter(
884
- (T) => T.geometry.type === "Point" && T.properties.type === "forecast" && T.properties.category === `${d}-${u}`
883
+ const d = a.properties.name, u = a.properties.model, f = a.properties.showCircle, h = a.properties.disabled, T = R(a.properties.date).utc();
884
+ let m = e * 60 - (T.get("hour") * 60 + T.get("minute")) % (e * 60);
885
+ const S = (i = t == null ? void 0 : t.data) == null ? void 0 : i.features.filter(
886
+ (v) => v.geometry.type === "Point" && v.properties.type === "forecast" && v.properties.category === `${d}-${u}`
885
887
  );
886
- let M, D = P.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
887
- for (; M = this.pickIndex(v, D), M <= v.length - 1; ) {
888
+ let M, D = T.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
889
+ for (; M = this.pickIndex(S, D), M <= S.length - 1; ) {
888
890
  if (M > 0) {
889
- const T = v[M], p = M === 0 ? void 0 : v[M - 1], N = (m / 60 - ((r = p == null ? void 0 : p.properties) == null ? void 0 : r.hour)) / (T.properties.hour - ((c = p == null ? void 0 : p.properties) == null ? void 0 : c.hour)), I = this.computeNumber(p == null ? void 0 : p.geometry.coordinates[0], T.geometry.coordinates[0], N), $ = this.computeNumber(p == null ? void 0 : p.geometry.coordinates[1], T.geometry.coordinates[1], N), W = g.point([I, $], {
891
+ const v = S[M], p = M === 0 ? void 0 : S[M - 1], N = (m / 60 - ((r = p == null ? void 0 : p.properties) == null ? void 0 : r.hour)) / (v.properties.hour - ((c = p == null ? void 0 : p.properties) == null ? void 0 : c.hour)), I = this.computeNumber(p == null ? void 0 : p.geometry.coordinates[0], v.geometry.coordinates[0], N), $ = this.computeNumber(p == null ? void 0 : p.geometry.coordinates[1], v.geometry.coordinates[1], N), W = g.point([I, $], {
890
892
  name: d,
891
893
  model: u,
892
- category: T == null ? void 0 : T.properties.category,
894
+ category: v == null ? void 0 : v.properties.category,
893
895
  date: D.format(),
894
896
  format: D.format("MMM-DD/HHmm[Z]"),
895
- gusts: this.computeNumber(p == null ? void 0 : p.properties.gusts, T.properties.gusts, N),
896
- hour: this.computeNumber(p == null ? void 0 : p.properties.hour, T.properties.hour, N),
897
- movement: this.computeNumber(p == null ? void 0 : p.properties.movement, T.properties.movement, N),
898
- pressure: this.computeNumber(p == null ? void 0 : p.properties.pressure, T.properties.pressure, N),
899
- wind: this.computeNumber(p == null ? void 0 : p.properties.wind, T.properties.wind, N),
897
+ gusts: this.computeNumber(p == null ? void 0 : p.properties.gusts, v.properties.gusts, N),
898
+ hour: this.computeNumber(p == null ? void 0 : p.properties.hour, v.properties.hour, N),
899
+ movement: this.computeNumber(p == null ? void 0 : p.properties.movement, v.properties.movement, N),
900
+ pressure: this.computeNumber(p == null ? void 0 : p.properties.pressure, v.properties.pressure, N),
901
+ wind: this.computeNumber(p == null ? void 0 : p.properties.wind, v.properties.wind, N),
900
902
  type: "forecast",
901
903
  disabled: h,
902
904
  showCircle: f
903
905
  });
904
906
  s.push(W);
905
907
  }
906
- m += e * 60, D = P.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
908
+ m += e * 60, D = T.clone().add(m, "minute").set({ minute: 0, second: 0, millisecond: 0 });
907
909
  }
908
910
  }
909
911
  return s;
@@ -933,19 +935,19 @@ class q {
933
935
  const { t1: o, t2: i, hr: r, hours: c } = this.tropicalCenterTwin(e, 24, s);
934
936
  if (o && i) {
935
937
  if (!s.debug) {
936
- const P = S.calculateDistance(t, o), m = S.calculateDistance(t, i);
937
- if (P > 2 * n && m > 2 * n)
938
- return b == null || b.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, P, m, {
938
+ const T = P.calculateDistance(t, o), m = P.calculateDistance(t, i);
939
+ if (T > 2 * n && m > 2 * n)
940
+ return b == null || b.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j", s.requestId, T, m, {
939
941
  from: t,
940
942
  t1: o,
941
943
  t2: i,
942
944
  hr: r
943
945
  }), {};
944
946
  }
945
- const a = S.calculateBearing(t, o), d = S.calculateBearing(o, i), u = Math.abs(a - d);
947
+ const a = P.calculateBearing(t, o), d = P.calculateBearing(o, i), u = Math.abs(a - d);
946
948
  let f = 0;
947
949
  u < 180 ? f = u + 90 : u >= 180 && (f = u - 90);
948
- const h = S.calculateCoordinate(o, f, n);
950
+ const h = P.calculateCoordinate(o, f, n);
949
951
  return b == null || b.info("[%s] the right tangent position: %j", s.requestId, {
950
952
  from: t,
951
953
  t1: o,
@@ -972,17 +974,17 @@ class q {
972
974
  const { t1: o, t2: i, hr: r, hours: c } = this.tropicalCenterTwin(e, 24, s);
973
975
  if (o && i) {
974
976
  if (!s.debug) {
975
- const h = S.calculateDistance(t, o), P = S.calculateDistance(t, i);
976
- if (h > 2 * n && P > 2 * n)
977
- return b == null || b.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, h, P, {
977
+ const h = P.calculateDistance(t, o), T = P.calculateDistance(t, i);
978
+ if (h > 2 * n && T > 2 * n)
979
+ return b == null || b.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j", s.requestId, h, T, {
978
980
  from: t,
979
981
  t1: o,
980
982
  t2: i,
981
983
  hr: r
982
984
  }), {};
983
985
  }
984
- const a = S.calculateBearing(t, o), d = S.calculateBearing(o, i), u = S.calculateDistance(t, o);
985
- return { at: S.calculateCoordinate(o, a - d + 180, n < u ? n : u), t1: o, t2: i, hr: Number(r), hours: c };
986
+ const a = P.calculateBearing(t, o), d = P.calculateBearing(o, i), u = P.calculateDistance(t, o);
987
+ return { at: P.calculateCoordinate(o, a - d + 180, n < u ? n : u), t1: o, t2: i, hr: Number(r), hours: c };
986
988
  } else
987
989
  return b == null || b.info("[%s] no need drift: %j", s.requestId, { from: t, t1: o, t2: i, hr: r }), {};
988
990
  }
@@ -995,7 +997,7 @@ class q {
995
997
  * @private
996
998
  */
997
999
  static tropicalCenterTwin(t, e = 24, n = {}) {
998
- var d, u, f, h, P;
1000
+ var d, u, f, h, T;
999
1001
  let s = {};
1000
1002
  (d = t.forecasts) == null || d.forEach((m) => {
1001
1003
  s = { ...m.hours, ...s };
@@ -1003,7 +1005,7 @@ class q {
1003
1005
  const o = ((u = t == null ? void 0 : t.history) == null ? void 0 : u[0]) || (s == null ? void 0 : s[(f = Object.keys(s)) == null ? void 0 : f[0]]);
1004
1006
  b == null || b.info("[%s] the first tropical center: %j", n.requestId, o);
1005
1007
  let i = (h = Object.keys(s || {}).filter((m) => Number(m) <= (e < 0 ? 24 : e))) == null ? void 0 : h.at(-1);
1006
- i || (i = (P = Object.keys(s || {}).filter((m) => Number(m) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : P.at(-1));
1008
+ i || (i = (T = Object.keys(s || {}).filter((m) => Number(m) <= (e < 0 ? 24 : 2 * e))) == null ? void 0 : T.at(-1));
1007
1009
  const r = s == null ? void 0 : s[i || -1];
1008
1010
  b == null || b.info("[%s] the second tropical center: %j in %d hrs", n.requestId, r, i);
1009
1011
  const c = Object.keys(s || {}).filter((m) => Number(m) <= Number(i)), a = { 0: o };
@@ -1037,7 +1039,7 @@ class q {
1037
1039
  }
1038
1040
  }
1039
1041
  export {
1040
- S as LaneHelper,
1042
+ P as LaneHelper,
1041
1043
  l as LngLatHelper,
1042
1044
  q as TropicalHelper
1043
1045
  };
@@ -1 +1 @@
1
- (function(M,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):(M=typeof globalThis<"u"?globalThis:M||self,I(M["idm-plugin-rabbitmq"]={},M["@turf/turf"],M.moment,M["moment-timezone"],M["tz-lookup"]))})(this,function(M,I,R,q,j){"use strict";function k(P){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(P){for(const t in P)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(P,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>P[t]})}}return e.default=P,Object.freeze(e)}const g=k(I);function L(P){return P&&P.__esModule&&Object.prototype.hasOwnProperty.call(P,"default")?P.default:P}class x{log(){}isLevelEnabled(){return!1}addContext(){}removeContext(){}clearContext(){}}["Trace","Debug","Info","Warn","Error","Fatal","Mark"].forEach(P=>{x.prototype[P.toLowerCase()]=()=>{},x.prototype[`is${P}Enabled`]=()=>!1});const $=(()=>{try{return require("log4js")}catch{return null}})();var O={getLogger:$?$.getLogger:()=>new x};const W=L(O);class l{static guessTimeZoneOffset(e,t){const n=j(t,e),s=R().tz(n).utcOffset();return this.roundPrecision(s/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 s="E";e<0&&(s="W"),e=Math.abs(e),n=n.toUpperCase();let o=e*3600,i,r,c,a,d,u;i=o%3600%60,n.indexOf("S")!==-1&&(o=o-i,r=l.padNumber(i,2,2)),c=o/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?a=l.roundPrecision(c,t).toString().padStart(2,"0"):a=l.padNumber(c,2,2),o=o-c*60),d=o/3600,n.indexOf("M")!==-1?u=l.roundPrecision(d,t).toString().padStart(3,"0"):u=l.padNumber(d,3,2);const h=`${n.replace(/S+/gi,r).replace(/M+/gi,a).replace(/H+/gi,u)}${s}`;return{direction:s,degree:l.roundPrecision(d,t),minute:l.roundPrecision(c,t),second:l.roundPrecision(i,t),pretty:h}}static lat2pretty(e,t=6,n="H°M′"){e=e%180;let s="N";e<0&&(s="S"),e=Math.abs(e),n=n.toUpperCase();let o=e*3600,i,r,c,a,d,u;i=o%3600%60,n.indexOf("S")!==-1&&(o=o-i,r=l.padNumber(i,2,2)),c=o/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?a=l.roundPrecision(c,t).toString().padStart(2,"0"):a=l.padNumber(c,2,2),o=o-c*60),d=o/3600,n.indexOf("M")!==-1?u=l.roundPrecision(d,t).toString().padStart(2,"0"):u=l.padNumber(d,2,2);const h=`${n.replace(/S+/gi,r).replace(/M+/gi,a).replace(/H+/gi,u)}${s}`;return{direction:s,degree:l.roundPrecision(d,t),minute:l.roundPrecision(c,t),second:l.roundPrecision(i,t),pretty:h}}static str2Lng(e,t=6){let n;if(isNaN(e)){e=l.strReplace(e,"LNG");const s=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const o=e.split(" ").filter(c=>c!=="").map(c=>Number(c));let[i,r]=o;if(r=r>60?r/Math.pow(10,String(r).length-2):r,i>360&&!r){const c=this.roundPrecision(i/100,0);r=i-c*100,i=c}n=i+(r??0)/60,s==="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 s=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const o=e.split(" ").filter(c=>c!=="").map(c=>Number(c));let[i,r]=o;if(r=r>60?r/Math.pow(10,String(r).length-2):r,i>90&&!r){const c=this.roundPrecision(i/100,0);r=i-c*100,i=c}n=i+(r??0)/60,s==="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 s=e[e.length-1].toUpperCase();return["N","S"].includes(s)?{lat:l.str2Lat(e,t)}:{lng:l.str2Lng(e,t)}}static convertToStdLng(e,t=6){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 s=e,o=Number(s.split(" ")[0]);if(isNaN(o))throw new Error(`invalid Lat/Lng: ${e}`);o>=90?e=`${s}E`:o<=-90?e=`${s}W`:["LAN","LNG"].includes(t==null?void 0:t.toUpperCase())?e=`${s}${o>0?"E":"W"}`:e=`${s}${o>0?"N":"S"}`}return e}static padNumber(e,t=2,n=2){const s=Math.trunc(e).toString().padStart(t,"0"),o=Math.trunc(l.roundPrecision(e-Math.trunc(e),n)*Math.pow(10,n)).toString().padStart(n,"0");return`${s}.${o}`}}class T{static calculateBearing(e,t,n=!0,s=4){const o=g.points([[e.lng,e.lat],[t.lng,t.lat]]);let i;return n?i=g.rhumbBearing(o.features[0],o.features[1]):i=g.bearing(o.features[0],o.features[1]),i<0&&(i+=360),l.roundPrecision(i,s)}static calculateDistance(e,t,n=!0,s=4,o="nauticalmiles"){e={...e},t={...t},e.lng=l.convertToStdLng(e.lng,s),t.lng=l.convertToStdLng(t.lng,s);const i=g.points([[e.lng,e.lat],[t.lng,t.lat]]);let r;return n?r=g.rhumbDistance(i.features[0],i.features[1],{units:o}):r=g.distance(i.features[0],i.features[1],{units:o}),l.roundPrecision(r,s)}static calculateRouteDistance(e,t=4,n="nauticalmiles"){let s=0,o;for(const i of e)for(let r=0;r<i.length-1;r++){const c={lng:i[r][0],lat:i[r][1]};r===0&&o&&(s+=this.calculateDistance(o,c,!0,t,n));const a={lng:i[r+1][0],lat:i[r+1][1]};s+=this.calculateDistance(c,a,!0,t,n),o=a}return l.roundPrecision(s,t)}static calculateCoordinate(e,t,n,s="nauticalmiles",o=!0){const i=g.point([e.lng,e.lat]);let r;o?r=g.rhumbDestination(i,n,t,{units:s}):r=g.destination(i,n,t,{units:s});const c=r.geometry.coordinates;return{lng:l.convertToStdLng(c[0],8),lat:l.roundPrecision(c[1],8)}}static interpolateCoordinates(e,t,n,s=!0,o=!0,i="nauticalmiles"){const r=[],c=this.calculateBearing(e,t,!1),a=this.calculateDistance(e,t,!1,8,i);s&&r.push({lng:e.lng,lat:e.lat});let d=0;for(;d<a;)d+=n,d<a&&r.push(this.calculateCoordinate(e,c,d,i,!1));return o&&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 s=[];let o,i;for(let r=0;r<e.length-1;r++){o=l.convertToStdLng(e[r].lng,8),i=l.convertToStdLng(e[r+1].lng,8),e[r].lat=l.roundPrecision(e[r].lat,8),e[r+1].lat=l.roundPrecision(e[r+1].lat,8),n.push([o,e[r].lat]);const c=o-i;if(Math.abs(c)>180){const a=l.convertToMonotonicLng2([[o,e[r].lat],[i,e[r+1].lat]]);let d,u;t?(d=g.lineString(a),u=g.lineString([[c>0?180:-180,89],[c>0?180:-180,-89]])):(d=g.greatCircle(a[0],a[1]),u=g.greatCircle([c>0?180:-180,89],[c>0?180:-180,-89]));const h=g.lineIntersect(d,u);let f;if(h.features.length){const v=g.getCoord(h.features[0]);f=l.roundPrecision(v[1],8)}else f=e[r].lat;c>0?(n.push([180-1e-6,f]),s.push([...n]),n=[],n.push([-(180-1e-6),f])):(n.push([-(180-1e-6),f]),s.push([...n]),n=[],n.push([180-1e-6,f]))}r===e.length-2&&n.push([i,e[r+1].lat])}return s.push(n),s}static deduplicateRoute(e){const t=[];for(const n of e){const s=n.reduce((o,i)=>(o.findIndex(r=>r[0]===i[0]&&r[1]===i[1])===-1&&o.push(i),o),[]);t.push(s)}return t}static deduplicateCoordinates(e){return e.reduce((t,n)=>(t.findIndex(s=>s.lat===n.lat&&s.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 s=n.length-1;s>=0;s--)l.roundPrecision(n[s][0],8)===e.lng&&l.roundPrecision(n[s][1],8)===l.roundPrecision(e.lat,8)&&n.splice(s,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,s=0,o=0,i,r;return t.forEach((c,a)=>{for(let d=0;d<c.length-1;d++){const u={lng:c[d][0],lat:c[d][1]},h={lng:c[d+1][0],lat:c[d+1][1]},f=this.calculatePointToLineDistance(e,u,h);n>f&&(n=f,o=d,s=a,i=this.calculateDistance(u,e),r=this.calculateDistance(h,e))}}),i!==0&&r!==0?t[s].splice(o+1,0,[e.lng,e.lat]):i===0?t[s].splice(o,1,[e.lng,e.lat]):r===0&&t[s].splice(o+1,1,[e.lng,e.lat]),t}static appendCoordinateToRoute(e,t){e.lng=l.convertToStdLng(e.lng,8);const n=T.convertRouteToCoordinates(t);return n.push(e),T.divideAccordingToLng(n)}static unshiftCoordinateToRoute(e,t){const n=T.convertRouteToCoordinates(t);return n.unshift(e),T.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 s=[];let o=0;return n.forEach(i=>{if(o===2)return;const r=[];for(const c of i){if(l.roundPrecision(t.lng,8)===l.roundPrecision(c[0],8)&&l.roundPrecision(t.lat,8)===l.roundPrecision(c[1],8)){r.push(c),o===0&&r.push([e.lng,e.lat]),o=2;break}o===1?r.push(c):l.roundPrecision(e.lng,8)===l.roundPrecision(c[0],8)&&l.roundPrecision(e.lat,8)===l.roundPrecision(c[1],8)&&(o=1,r.push(c))}r.length&&s.push(r)}),s}static calculateRangeWaypoints(e,t,n,s=[]){const o=this.convertRouteToCoordinates(n,0),i=this.mergeCoordinatesToWaypoints([e,t,...s],o),r=i.findIndex(d=>l.roundPrecision(e.lng,8)===l.roundPrecision(d.lng,8)&&l.roundPrecision(e.lat,8)===l.roundPrecision(d.lat,8)),c=i.findIndex(d=>l.roundPrecision(t.lng,8)===l.roundPrecision(d.lng,8)&&l.roundPrecision(t.lat,8)===l.roundPrecision(d.lat,8));return i.filter((d,u)=>u>=r&&u<=c)}static calculateMinDistanceToRoute(e,t){let n=Number.MAX_VALUE,s=0,o=0;return t.forEach((i,r)=>{for(let c=0;c<i.length-1;c++){const a={lng:i[c][0],lat:i[c][1]},d={lng:i[c+1][0],lat:i[c+1][1]},u=this.calculatePointToLineDistance(e,a,d);n>u&&(n=u,s=c,o=r)}}),{minDist:n,segIndex:o,minIndex:s}}static calculateSubRoute(e,t){const{segIndex:n,minIndex:s}=this.calculateMinDistanceToRoute({...e},t);e.lng=l.convertToStdLng(e.lng);const o=[];let i=!0;for(let r=n;r<t.length;r++)if(i){const c=[];c.push([e.lng,e.lat]);for(let a=s+1;a<t[r].length;a++)e.lng===t[r][a][0]&&e.lat===t[r][a][1]||c.push(t[r][a]);o.push(c),i=!1}else o.push([...t[r]]);return o}static calculateSubWaypoints(e,t){let n=Number.MAX_VALUE,s=0;for(let i=0;i<t.length-1;i++){const r=t[i],c=t[i+1];if(this.calculateDistance(e,r)===0)return t;if(this.calculateDistance(e,c)===0)return t.filter((d,u)=>u>0);const a=this.calculatePointToLineDistance(e,r,c);n>a&&(n=a,s=i)}e.lng=l.convertToStdLng(e.lng);const o=[e];for(let i=s+1;i<t.length;i++)o.push(t[i]);return o}static calculatePointToLineDistance(e,t,n,s={units:"nauticalmiles",method:"geodesic"}){e.lng=l.convertToStdLng(e.lng,8),t={...t},n={...n},t.lng=l.convertToStdLng(t.lng,8),n.lng=l.convertToStdLng(n.lng,8);const o=l.convertToMonotonicLng([t,n]);t=o[0],n=o[1];const i=g.lineString([[t.lng,t.lat],[n.lng,n.lat]]),r=g.pointToLineDistance(g.point([e.lng,e.lat]),i,s),c=g.pointToLineDistance(g.point([e.lng>0?e.lng-360:e.lng+360,e.lat]),i,s);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 s=e[n],o=e[n+1],i=this.calculateRangeRoute(s,o,t);n===0&&(s.distanceFromPrevious=0,s.distanceFromStart=0),o.distanceFromPrevious=this.calculateRouteDistance(i),o.distanceFromStart=l.roundPrecision((s.distanceFromStart||0)+o.distanceFromPrevious)}return e}static mergeCoordinatesToWaypoints(e,t,n=!0){for(const s of e)this.mergeCoordinateToWaypoints(s,t,n);return t}static mergeCoordinateToWaypoints(e,t,n=!0){e.lng=l.convertToStdLng(e.lng,8);let s=Number.MAX_VALUE,o=0,i=0,r=0;for(let c=0;c<t.length-1;c++){const a={lng:t[c].lng,lat:t[c].lat},d={lng:t[c+1].lng,lat:t[c+1].lat},u=this.calculatePointToLineDistance(e,a,d);s>=u&&(s=u,o=c,i=this.calculateDistance(a,e,!1,6),r=this.calculateDistance(d,e,!1,6))}return i!==0&&r!==0?i<s||i===s&&o===0?t.unshift(e):r<s||r===s&&o===t.length-2?t.push(e):t.splice(o+1,0,e):i===0?n&&t.splice(o,1,e):r===0&&n&&t.splice(o+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 s=e[n-1],o=e[n];if(n===1&&t.push(s),o.gcToPrevious){const i=this.interpolateCoordinates(s,o,200,!1,!0,"nauticalmiles");t.push(...i)}else t.push(o)}return this.divideAccordingToLng(t,!0)}static nearestCoordinateInRoute(e,t){const n=g.point([e.lng,e.lat]),o=this.convertRouteToCoordinates(t).map(a=>[a.lng,a.lat]),i=g.lineString(o),r=g.nearestPointOnLine(i,n),c=g.getCoord(r);return{lng:l.roundPrecision(c[0],8),lat:l.roundPrecision(c[1],8)}}static calculatePrevWaypoint(e,t){let n=0;this.mergeCoordinateToWaypoints(e,t);for(let s=0;s<t.length-1;s++){const o=t[s],i=t[s+1];if(this.calculateDistance(e,o)===0){n=s;break}if(this.calculateDistance(e,i)===0){n=s+1;break}}return t[n===0?0:n-1]}static calculateNextCoordinateAlongRoute(e,t,n,s="nauticalmiles"){var h;const o=e.speed||12,i=[];let r=[],c=!1,a=0,d=0,u;if(t&&n.length?(i.push(e),n.forEach((f,v)=>{if(c)r.push(f);else{const m=[];let C;for(let D=0;D<f.length;D++)if(u)m.push(f[D]);else{C={lng:f[D][0],lat:f[D][1]};const N=this.calculateDistance(e,C,!0,8,s);if(a+=N,a<t)d+=N,i.push(C),e=C;else{if(d=t,a===t)u=C,m.push([u.lng,u.lat]);else{const S=a-t,p=this.calculateBearing(C,e);u=this.calculateCoordinate(C,p,S,s),m.push([u.lng,u.lat]),m.push([C.lng,C.lat])}c=!0}}m.length&&r.push(m),v===n.length-1&&!u&&(u=C)}})):(r=n,u={...e}),u)if(i.push(u),u.distanceFromPrevious=d,u.hourFromPrevious=Math.round(d/o*1e4)/1e4,((h=r[0])==null?void 0:h.length)>1){const f={lng:r[0][1][0],lat:r[0][1][1]};u.bearing=this.calculateBearing(u,f)}else u.bearing=0;return{coordinate:u,nextRoute:r,prevRoute:i}}static nearestCoordinateInLine(e,t,n){const s=l.convertToStdLng(e.lng,6),o=g.point([s,e.lat]),i=l.convertToStdLng(t.lng,6),r=l.convertToStdLng(n.lng,6),c=g.lineString([[i,t.lat],[r,n.lat]]),a=g.nearestPointOnLine(c,o),d=g.getCoord(a),u=l.roundPrecision(d[0],6),h=l.roundPrecision(d[1],6);return{lng:u,lat:h,inline:!(u===i&&h===t.lat)&&!(u===r&&h===n.lat)}}static convertRouteToCoordinates(e,t=0){const n=[];let s,o;return e.forEach(i=>{i.forEach(r=>{const c={lng:l.roundPrecision(r[0],8),lat:l.roundPrecision(r[1],8)};if(!o)n.push(c),o=c;else if(o.bearing===void 0)o.bearing=this.calculateBearing(o,c,!0);else{const a=this.calculateDistance(s,c,!0);a&&a>=t&&(s.bearing=this.calculateBearing(s,c,!0),n.push(s),o=s)}s=c})}),s&&n.push(s),n}static simplifyRouteToCoordinates(e,t,n=1){let s=this.convertRouteToCoordinates(e,n);return s=this.simplifyGCCoordinates(s,t),s}static simplifyGCCoordinates(e,t){t.forEach(s=>{this.mergeCoordinateToWaypoints(s,e,!0)});for(let s=1;s<t.length;s++){const o=t[s-1],i=t[s];if(i.gcToPrevious){const r=e.findIndex(a=>a.lng===o.lng&&a.lat===o.lat),c=e.findIndex(a=>a.lng===i.lng&&a.lat===i.lat);for(let a=c-1;a>r;a--)e.splice(a,1)}}let n=0;for(let s=1;s<e.length;s++){const o=e[s-1],i=e[s];i.gcToPrevious?(o.bearing=this.calculateBearing(o,i,!1),i.distanceFromPrevious=this.calculateDistance(o,i,!1)):(o.bearing=this.calculateBearing(o,i,!0),i.distanceFromPrevious=this.calculateDistance(o,i,!0)),n=l.roundPrecision(n+i.distanceFromPrevious),i.distanceFromStart=n}return e.map(s=>(s.lng=l.convertToStdLng(s.lng),s))}static calculateCenter(e){const t=[];for(const r of e)for(const c of r)t.push(c);const n=g.featureCollection([]),s=l.convertToMonotonicLng2(t);for(const r of s)n.features.push(g.point(r));const i=g.center(n).geometry.coordinates;return{lng:l.convertToStdLng(i[0],8),lat:l.roundPrecision(i[1],8)}}static calculateCenter2(e){const t=this.generateRouteAccordingToWaypoints(e);return this.calculateCenter(t)}static calculateBBox(e){const t=[];for(const o of e)for(const i of o)t.push(i);const n=l.convertToMonotonicLng2(t),s=g.lineString(n);return g.bbox(s)}static calculateBBox2(e){const t=this.generateRouteAccordingToWaypoints(e);return this.calculateBBox(t)}}let b;try{b=W.getLogger("vessel")}catch{}finally{}class E{static convert2Geojson(e){var n;const t=g.featureCollection([]);for(const s of e){if(s.forecasts){const o=(n=s.history)==null?void 0:n[0];for(const i of s.forecasts){const r=[],c=R(i.date).utc(),a=`${s.name}-${i.model}`;if(o){const d=R(o.updated).utc(),u=g.point([o.lng,o.lat],{model:i.model,name:s.name,date:d.format(),hour:0,format:d.format("MMM-DD/HHmm[Z]"),pressure:o.pressure>1e4?l.roundPrecision(o.pressure/100,0):l.roundPrecision(o.pressure,0),wind:{kts:o.kts,spd:o.speed||o.spd},category:a,type:"forecast"});t.features.push(u),r.push(u.geometry.coordinates)}for(const d in i==null?void 0:i.hours){const u=i.hours[d];u.wind.spd=u.wind.spd||u.wind.speed;const h=c.clone().add(Number(d),"hour"),f=g.point([u.lng,u.lat],{model:i.model,name:s.name,date:h.format(),hour:Number(d),format:h.format("MMM-DD/HHmm[Z]"),pressure:u.pressure>1e4?l.roundPrecision(u.pressure/100,0):l.roundPrecision(u.pressure,0),gusts:u.gusts,wind:u.wind||{},movement:u.movement,category:a,type:"forecast"});t.features.push(f),r.push(f.geometry.coordinates)}if((r==null?void 0:r.length)>1){const d=g.lineString(l.convertToMonotonicLng2(r),{date:i.date,id:s.id||s.name,model:i.model,name:s.name,category:a,type:"forecast"});t.features.push(d)}}}if(s.history){const o=[];for(const r of s.history){const c=R(r.updated).utc(),a=g.point([r.lng,r.lat],{name:s.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:`${s.name}-history`});t.features.push(a),o.push(a.geometry.coordinates)}const i=s.history[0];if(o.length===1&&o.push(o[0]),o.length>1){const r=g.lineString(l.convertToMonotonicLng2(o),{name:s.name,type:"history",updated:i==null?void 0:i.updated,pressure:(i==null?void 0:i.pressure)>1e4?l.roundPrecision((i==null?void 0:i.pressure)/100,0):l.roundPrecision(i==null?void 0:i.pressure,0),spd:(i==null?void 0:i.speed)||(i==null?void 0:i.spd),kts:i==null?void 0:i.kts,source:i==null?void 0:i.source,level:i==null?void 0:i.type});t.features.push(r)}}}return t}static interpolate(e,t=3){var o,i,r,c;const n=(o=e==null?void 0:e.data)==null?void 0:o.features.filter(a=>a.geometry.type==="LineString"&&a.properties.type==="forecast"),s=[];for(const a of n){const d=a.properties.name,u=a.properties.model,h=a.properties.showCircle,f=a.properties.disabled,v=R(a.properties.date).utc();let m=t*60-(v.get("hour")*60+v.get("minute"))%(t*60);const C=(i=e==null?void 0:e.data)==null?void 0:i.features.filter(S=>S.geometry.type==="Point"&&S.properties.type==="forecast"&&S.properties.category===`${d}-${u}`);let D,N=v.clone().add(m,"minute").set({minute:0,second:0,millisecond:0});for(;D=this.pickIndex(C,N),D<=C.length-1;){if(D>0){const S=C[D],p=D===0?void 0:C[D-1],y=(m/60-((r=p==null?void 0:p.properties)==null?void 0:r.hour))/(S.properties.hour-((c=p==null?void 0:p.properties)==null?void 0:c.hour)),F=this.computeNumber(p==null?void 0:p.geometry.coordinates[0],S.geometry.coordinates[0],y),A=this.computeNumber(p==null?void 0:p.geometry.coordinates[1],S.geometry.coordinates[1],y),B=g.point([F,A],{name:d,model:u,category:S==null?void 0:S.properties.category,date:N.format(),format:N.format("MMM-DD/HHmm[Z]"),gusts:this.computeNumber(p==null?void 0:p.properties.gusts,S.properties.gusts,y),hour:this.computeNumber(p==null?void 0:p.properties.hour,S.properties.hour,y),movement:this.computeNumber(p==null?void 0:p.properties.movement,S.properties.movement,y),pressure:this.computeNumber(p==null?void 0:p.properties.pressure,S.properties.pressure,y),wind:this.computeNumber(p==null?void 0:p.properties.wind,S.properties.wind,y),type:"forecast",disabled:f,showCircle:h});s.push(B)}m+=t*60,N=v.clone().add(m,"minute").set({minute:0,second:0,millisecond:0})}}return s}static accelPassageAt(e,t){const{t1:n,t2:s,hr:o,hours:i}=this.tropicalCenterTwin(e,24,t);return{t1:n,t2:s,hr:o,hours:i}}static diversionPassageAt(e,t,n,s={}){const{t1:o,t2:i,hr:r,hours:c}=this.tropicalCenterTwin(t,24,s);if(o&&i){if(!s.debug){const v=T.calculateDistance(e,o),m=T.calculateDistance(e,i);if(v>2*n&&m>2*n)return b==null||b.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j",s.requestId,v,m,{from:e,t1:o,t2:i,hr:r}),{}}const a=T.calculateBearing(e,o),d=T.calculateBearing(o,i),u=Math.abs(a-d);let h=0;u<180?h=u+90:u>=180&&(h=u-90);const f=T.calculateCoordinate(o,h,n);return b==null||b.info("[%s] the right tangent position: %j",s.requestId,{from:e,t1:o,t2:i,radius:n,bearing1:a,bearing2:d,right:f}),{at:f,t1:o,t2:i,hr:Number(r),hours:c}}return{}}static driftPassageAt(e,t,n,s={}){const{t1:o,t2:i,hr:r,hours:c}=this.tropicalCenterTwin(t,24,s);if(o&&i){if(!s.debug){const f=T.calculateDistance(e,o),v=T.calculateDistance(e,i);if(f>2*n&&v>2*n)return b==null||b.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j",s.requestId,f,v,{from:e,t1:o,t2:i,hr:r}),{}}const a=T.calculateBearing(e,o),d=T.calculateBearing(o,i),u=T.calculateDistance(e,o);return{at:T.calculateCoordinate(o,a-d+180,n<u?n:u),t1:o,t2:i,hr:Number(r),hours:c}}else return b==null||b.info("[%s] no need drift: %j",s.requestId,{from:e,t1:o,t2:i,hr:r}),{}}static tropicalCenterTwin(e,t=24,n={}){var d,u,h,f,v;let s={};(d=e.forecasts)==null||d.forEach(m=>{s={...m.hours,...s}});const o=((u=e==null?void 0:e.history)==null?void 0:u[0])||(s==null?void 0:s[(h=Object.keys(s))==null?void 0:h[0]]);b==null||b.info("[%s] the first tropical center: %j",n.requestId,o);let i=(f=Object.keys(s||{}).filter(m=>Number(m)<=(t<0?24:t)))==null?void 0:f.at(-1);i||(i=(v=Object.keys(s||{}).filter(m=>Number(m)<=(t<0?24:2*t)))==null?void 0:v.at(-1));const r=s==null?void 0:s[i||-1];b==null||b.info("[%s] the second tropical center: %j in %d hrs",n.requestId,r,i);const c=Object.keys(s||{}).filter(m=>Number(m)<=Number(i)),a={0:o};for(const m of c)a[m]=s[m];return{t1:o,t2:r,hr:Number(i),hours:a}}static pickIndex(e,t){let n=0;for(const s of e){if(R(s.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 s={};for(const o in e)s[o]=this.computeNumber(e[o],t[o],n);return s}return Math.round((e+(t-e)*n)*100)/100}else return e;else return t}}M.LaneHelper=T,M.LngLatHelper=l,M.TropicalHelper=E,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
1
+ (function(M,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):(M=typeof globalThis<"u"?globalThis:M||self,I(M["idm-plugin-rabbitmq"]={},M["@turf/turf"],M.moment,M["moment-timezone"],M["tz-lookup"]))})(this,function(M,I,R,q,j){"use strict";function k(P){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(P){for(const t in P)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(P,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>P[t]})}}return e.default=P,Object.freeze(e)}const g=k(I);function O(P){return P&&P.__esModule&&Object.prototype.hasOwnProperty.call(P,"default")?P.default:P}class x{log(){}isLevelEnabled(){return!1}addContext(){}removeContext(){}clearContext(){}}["Trace","Debug","Info","Warn","Error","Fatal","Mark"].forEach(P=>{x.prototype[P.toLowerCase()]=()=>{},x.prototype[`is${P}Enabled`]=()=>!1});const $=(()=>{try{return require("log4js")}catch{return null}})();var W={getLogger:$?$.getLogger:()=>new x};const L=O(W);class l{static guessTimeZoneOffset(e,t){const n=j(t,e),s=R().tz(n).utcOffset();return this.roundPrecision(s/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 s="E";e<0&&(s="W"),e=Math.abs(e),n=n.toUpperCase();let o=e*3600,i,r,c,a,d,u;i=o%3600%60,n.indexOf("S")!==-1&&(o=o-i,r=l.padNumber(i,2,2)),c=o/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?a=l.roundPrecision(c,t).toString().padStart(2,"0"):a=l.padNumber(c,2,2),o=o-c*60),d=o/3600,n.indexOf("M")!==-1?u=l.roundPrecision(d,t).toString().padStart(3,"0"):u=l.padNumber(d,3,2);const h=`${n.replace(/S+/gi,r).replace(/M+/gi,a).replace(/H+/gi,u)}${s}`;return{direction:s,degree:l.roundPrecision(d,t),minute:l.roundPrecision(c,t),second:l.roundPrecision(i,t),pretty:h}}static lat2pretty(e,t=6,n="H°M′"){e=e%180;let s="N";e<0&&(s="S"),e=Math.abs(e),n=n.toUpperCase();let o=e*3600,i,r,c,a,d,u;i=o%3600%60,n.indexOf("S")!==-1&&(o=o-i,r=l.padNumber(i,2,2)),c=o/60%60,n.indexOf("M")!==-1&&(n.indexOf("S")!==-1?a=l.roundPrecision(c,t).toString().padStart(2,"0"):a=l.padNumber(c,2,2),o=o-c*60),d=o/3600,n.indexOf("M")!==-1?u=l.roundPrecision(d,t).toString().padStart(2,"0"):u=l.padNumber(d,2,2);const h=`${n.replace(/S+/gi,r).replace(/M+/gi,a).replace(/H+/gi,u)}${s}`;return{direction:s,degree:l.roundPrecision(d,t),minute:l.roundPrecision(c,t),second:l.roundPrecision(i,t),pretty:h}}static str2Lng(e,t=6){let n;if(isNaN(e)){e=l.strReplace(e,"LNG");const s=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const o=e.split(" ").filter(c=>c!=="").map(c=>Number(c));let[i,r]=o;if(r=r>60?r/Math.pow(10,String(r).length-2):r,i>360&&!r){const c=this.roundPrecision(i/100,0);r=i-c*100,i=c}n=i+(r??0)/60,s==="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 s=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const o=e.split(" ").filter(c=>c!=="").map(c=>Number(c));let[i,r]=o;if(r=r>60?r/Math.pow(10,String(r).length-2):r,i>90&&!r){const c=this.roundPrecision(i/100,0);r=i-c*100,i=c}n=i+(r??0)/60,s==="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 s=e[e.length-1].toUpperCase();return["N","S"].includes(s)?{lat:l.str2Lat(e,t)}:{lng:l.str2Lng(e,t)}}static convertToStdLng(e,t=6){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 s=e,o=Number(s.split(" ")[0]);if(isNaN(o))throw new Error(`invalid Lat/Lng: ${e}`);o>=90?e=`${s}E`:o<=-90?e=`${s}W`:["LAN","LNG"].includes(t==null?void 0:t.toUpperCase())?e=`${s}${o>0?"E":"W"}`:e=`${s}${o>0?"N":"S"}`}return e}static padNumber(e,t=2,n=2){const s=Math.trunc(e).toString().padStart(t,"0"),o=Math.trunc(l.roundPrecision(e-Math.trunc(e),n)*Math.pow(10,n)).toString().padStart(n,"0");return`${s}.${o}`}}class b{static calculateBearing(e,t,n=!0,s=4){const o=g.points([[e.lng,e.lat],[t.lng,t.lat]]);let i;return n?i=g.rhumbBearing(o.features[0],o.features[1]):i=g.bearing(o.features[0],o.features[1]),i<0&&(i+=360),l.roundPrecision(i,s)}static calculateDistance(e,t,n=!0,s=4,o="nauticalmiles"){e={...e},t={...t},e.lng=l.convertToStdLng(e.lng,s),t.lng=l.convertToStdLng(t.lng,s);const i=g.points([[e.lng,e.lat],[t.lng,t.lat]]);let r;return n?r=g.rhumbDistance(i.features[0],i.features[1],{units:o}):r=g.distance(i.features[0],i.features[1],{units:o}),l.roundPrecision(r,s)}static calculateRouteDistance(e,t=4,n="nauticalmiles"){let s=0,o;for(const i of e)for(let r=0;r<i.length-1;r++){const c={lng:i[r][0],lat:i[r][1]};r===0&&o&&(s+=this.calculateDistance(o,c,!0,t,n));const a={lng:i[r+1][0],lat:i[r+1][1]};s+=this.calculateDistance(c,a,!0,t,n),o=a}return l.roundPrecision(s,t)}static calculateCoordinate(e,t,n,s="nauticalmiles",o=!0){const i=g.point([e.lng,e.lat]);let r;o?r=g.rhumbDestination(i,n,t,{units:s}):r=g.destination(i,n,t,{units:s});const c=r.geometry.coordinates;return{lng:l.convertToStdLng(c[0],8),lat:l.roundPrecision(c[1],8)}}static interpolateCoordinates(e,t,n,s=!0,o=!0,i="nauticalmiles"){const r=[],c=this.calculateBearing(e,t,!1),a=this.calculateDistance(e,t,!1,8,i);s&&r.push({lng:e.lng,lat:e.lat});let d=0;for(;d<a;)d+=n,d<a&&r.push(this.calculateCoordinate(e,c,d,i,!1));return o&&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 s=[];let o,i;for(let r=0;r<e.length-1;r++){o=l.convertToStdLng(e[r].lng,8),i=l.convertToStdLng(e[r+1].lng,8),e[r].lat=l.roundPrecision(e[r].lat,8),e[r+1].lat=l.roundPrecision(e[r+1].lat,8),n.push([o,e[r].lat]);const c=o-i;if(Math.abs(c)>180){const a=l.convertToMonotonicLng2([[o,e[r].lat],[i,e[r+1].lat]]);let d,u;t?(d=g.lineString(a),u=g.lineString([[c>0?180:-180,89],[c>0?180:-180,-89]])):(d=g.greatCircle(a[0],a[1]),u=g.greatCircle([c>0?180:-180,89],[c>0?180:-180,-89]));const h=g.lineIntersect(d,u);let f;if(h.features.length){const v=g.getCoord(h.features[0]);f=l.roundPrecision(v[1],8)}else f=e[r].lat;c>0?(n.push([180-1e-6,f]),s.push([...n]),n=[],n.push([-(180-1e-6),f])):(n.push([-(180-1e-6),f]),s.push([...n]),n=[],n.push([180-1e-6,f]))}r===e.length-2&&n.push([i,e[r+1].lat])}return s.push(n),s}static deduplicateRoute(e){const t=[];for(const n of e){const s=n.reduce((o,i)=>(o.findIndex(r=>r[0]===i[0]&&r[1]===i[1])===-1&&o.push(i),o),[]);t.push(s)}return t}static deduplicateCoordinates(e){return e.reduce((t,n)=>(t.findIndex(s=>s.lat===n.lat&&s.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 s=n.length-1;s>=0;s--)l.roundPrecision(n[s][0],8)===e.lng&&l.roundPrecision(n[s][1],8)===l.roundPrecision(e.lat,8)&&n.splice(s,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,s=0,o=0,i,r;return t.forEach((c,a)=>{for(let d=0;d<c.length-1;d++){const u={lng:c[d][0],lat:c[d][1]},h={lng:c[d+1][0],lat:c[d+1][1]},f=this.calculatePointToLineDistance(e,u,h);n>f&&(n=f,o=d,s=a,i=this.calculateDistance(u,e),r=this.calculateDistance(h,e))}}),i!==0&&r!==0?t[s].splice(o+1,0,[e.lng,e.lat]):i===0?t[s].splice(o,1,[e.lng,e.lat]):r===0&&t[s].splice(o+1,1,[e.lng,e.lat]),t}static appendCoordinateToRoute(e,t){e.lng=l.convertToStdLng(e.lng,8);const n=b.convertRouteToCoordinates(t);return n.push(e),b.divideAccordingToLng(n)}static unshiftCoordinateToRoute(e,t){const n=b.convertRouteToCoordinates(t);return n.unshift(e),b.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 s=[];let o=0;return n.forEach(i=>{if(o===2)return;const r=[];for(const c of i){if(l.roundPrecision(t.lng,8)===l.roundPrecision(c[0],8)&&l.roundPrecision(t.lat,8)===l.roundPrecision(c[1],8)){r.push(c),o===0&&r.push([e.lng,e.lat]),o=2;break}o===1?r.push(c):l.roundPrecision(e.lng,8)===l.roundPrecision(c[0],8)&&l.roundPrecision(e.lat,8)===l.roundPrecision(c[1],8)&&(o=1,r.push(c))}r.length&&s.push(r)}),s}static calculateRangeWaypoints(e,t,n,s=[]){const o=this.convertRouteToCoordinates(n,0),i=this.mergeCoordinatesToWaypoints([e,t,...s],o),r=i.findIndex(d=>l.roundPrecision(e.lng,8)===l.roundPrecision(d.lng,8)&&l.roundPrecision(e.lat,8)===l.roundPrecision(d.lat,8)),c=i.findIndex(d=>l.roundPrecision(t.lng,8)===l.roundPrecision(d.lng,8)&&l.roundPrecision(t.lat,8)===l.roundPrecision(d.lat,8));return i.filter((d,u)=>u>=r&&u<=c)}static calculateMinDistanceToRoute(e,t){let n=Number.MAX_VALUE,s=0,o=0;return t.forEach((i,r)=>{for(let c=0;c<i.length-1;c++){const a={lng:i[c][0],lat:i[c][1]},d={lng:i[c+1][0],lat:i[c+1][1]},u=this.calculatePointToLineDistance(e,a,d);n>u&&(n=u,s=c,o=r)}}),{minDist:n,segIndex:o,minIndex:s}}static calculateSubRoute(e,t){const n=b.convertRouteToCoordinates(t);b.mergeCoordinateToWaypoints(e,n,!0),t=b.divideAccordingToLng(n);const{segIndex:s,minIndex:o}=this.calculateMinDistanceToRoute({...e},t);e.lng=l.convertToStdLng(e.lng);const i=[];let r=!0;for(let c=s;c<t.length;c++)if(r){const a=[];a.push([e.lng,e.lat]);for(let d=o+1;d<t[c].length;d++)e.lng===t[c][d][0]&&e.lat===t[c][d][1]||a.push(t[c][d]);i.push(a),r=!1}else i.push([...t[c]]);return i}static calculateSubWaypoints(e,t){let n=Number.MAX_VALUE,s=0;for(let i=0;i<t.length-1;i++){const r=t[i],c=t[i+1];if(this.calculateDistance(e,r)===0)return t;if(this.calculateDistance(e,c)===0)return t.filter((d,u)=>u>0);const a=this.calculatePointToLineDistance(e,r,c);n>a&&(n=a,s=i)}e.lng=l.convertToStdLng(e.lng);const o=[e];for(let i=s+1;i<t.length;i++)o.push(t[i]);return o}static calculatePointToLineDistance(e,t,n,s={units:"nauticalmiles",method:"geodesic"}){e.lng=l.convertToStdLng(e.lng,8),t={...t},n={...n},t.lng=l.convertToStdLng(t.lng,8),n.lng=l.convertToStdLng(n.lng,8);const o=l.convertToMonotonicLng([t,n]);t=o[0],n=o[1];const i=g.lineString([[t.lng,t.lat],[n.lng,n.lat]]),r=g.pointToLineDistance(g.point([e.lng,e.lat]),i,s),c=g.pointToLineDistance(g.point([e.lng>0?e.lng-360:e.lng+360,e.lat]),i,s);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 s=e[n],o=e[n+1],i=this.calculateRangeRoute(s,o,t);n===0&&(s.distanceFromPrevious=0,s.distanceFromStart=0),o.distanceFromPrevious=this.calculateRouteDistance(i),o.distanceFromStart=l.roundPrecision((s.distanceFromStart||0)+o.distanceFromPrevious)}return e}static mergeCoordinatesToWaypoints(e,t,n=!0){for(const s of e)this.mergeCoordinateToWaypoints(s,t,n);return t}static mergeCoordinateToWaypoints(e,t,n=!0){e.lng=l.convertToStdLng(e.lng,8);let s=Number.MAX_VALUE,o=0,i=0,r=0;for(let c=0;c<t.length-1;c++){const a={lng:t[c].lng,lat:t[c].lat},d={lng:t[c+1].lng,lat:t[c+1].lat},u=this.calculatePointToLineDistance(e,a,d);s>=u&&(s=u,o=c,i=this.calculateDistance(a,e,!1,6),r=this.calculateDistance(d,e,!1,6))}return i!==0&&r!==0?i<s||i===s&&o===0?t.unshift(e):r<s||r===s&&o===t.length-2?t.push(e):t.splice(o+1,0,e):i===0?n&&t.splice(o,1,e):r===0&&n&&t.splice(o+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 s=e[n-1],o=e[n];if(n===1&&t.push(s),o.gcToPrevious){const i=this.interpolateCoordinates(s,o,200,!1,!0,"nauticalmiles");t.push(...i)}else t.push(o)}return this.divideAccordingToLng(t,!0)}static nearestCoordinateInRoute(e,t){const n=g.point([e.lng,e.lat]),o=this.convertRouteToCoordinates(t).map(a=>[a.lng,a.lat]),i=g.lineString(o),r=g.nearestPointOnLine(i,n),c=g.getCoord(r);return{lng:l.roundPrecision(c[0],8),lat:l.roundPrecision(c[1],8)}}static calculatePrevWaypoint(e,t){let n=0;this.mergeCoordinateToWaypoints(e,t);for(let s=0;s<t.length-1;s++){const o=t[s],i=t[s+1];if(this.calculateDistance(e,o)===0){n=s;break}if(this.calculateDistance(e,i)===0){n=s+1;break}}return t[n===0?0:n-1]}static calculateNextCoordinateAlongRoute(e,t,n,s="nauticalmiles"){var h;const o=e.speed||12,i=[];let r=[],c=!1,a=0,d=0,u;if(t&&n.length?(i.push(e),n.forEach((f,v)=>{if(c)r.push(f);else{const m=[];let C;for(let D=0;D<f.length;D++)if(u)m.push(f[D]);else{C={lng:f[D][0],lat:f[D][1]};const N=this.calculateDistance(e,C,!0,8,s);if(a+=N,a<t)d+=N,i.push(C),e=C;else{if(d=t,a===t)u=C,m.push([u.lng,u.lat]);else{const S=a-t,p=this.calculateBearing(C,e);u=this.calculateCoordinate(C,p,S,s),m.push([u.lng,u.lat]),m.push([C.lng,C.lat])}c=!0}}m.length&&r.push(m),v===n.length-1&&!u&&(u=C)}})):(r=n,u={...e}),u)if(i.push(u),u.distanceFromPrevious=d,u.hourFromPrevious=Math.round(d/o*1e4)/1e4,((h=r[0])==null?void 0:h.length)>1){const f={lng:r[0][1][0],lat:r[0][1][1]};u.bearing=this.calculateBearing(u,f)}else u.bearing=0;return{coordinate:u,nextRoute:r,prevRoute:i}}static nearestCoordinateInLine(e,t,n){const s=l.convertToStdLng(e.lng,6),o=g.point([s,e.lat]),i=l.convertToStdLng(t.lng,6),r=l.convertToStdLng(n.lng,6),c=g.lineString([[i,t.lat],[r,n.lat]]),a=g.nearestPointOnLine(c,o),d=g.getCoord(a),u=l.roundPrecision(d[0],6),h=l.roundPrecision(d[1],6);return{lng:u,lat:h,inline:!(u===i&&h===t.lat)&&!(u===r&&h===n.lat)}}static convertRouteToCoordinates(e,t=0){const n=[];let s,o;return e.forEach(i=>{i.forEach(r=>{const c={lng:l.roundPrecision(r[0],8),lat:l.roundPrecision(r[1],8)};if(!o)n.push(c),o=c;else if(o.bearing===void 0)o.bearing=this.calculateBearing(o,c,!0);else{const a=this.calculateDistance(s,c,!0);a&&a>=t&&(s.bearing=this.calculateBearing(s,c,!0),n.push(s),o=s)}s=c})}),s&&n.push(s),n}static simplifyRouteToCoordinates(e,t,n=1){let s=this.convertRouteToCoordinates(e,n);return s=this.simplifyGCCoordinates(s,t),s}static simplifyGCCoordinates(e,t){t.forEach(s=>{this.mergeCoordinateToWaypoints(s,e,!0)});for(let s=1;s<t.length;s++){const o=t[s-1],i=t[s];if(i.gcToPrevious){const r=e.findIndex(a=>a.lng===o.lng&&a.lat===o.lat),c=e.findIndex(a=>a.lng===i.lng&&a.lat===i.lat);for(let a=c-1;a>r;a--)e.splice(a,1)}}let n=0;for(let s=1;s<e.length;s++){const o=e[s-1],i=e[s];i.gcToPrevious?(o.bearing=this.calculateBearing(o,i,!1),i.distanceFromPrevious=this.calculateDistance(o,i,!1)):(o.bearing=this.calculateBearing(o,i,!0),i.distanceFromPrevious=this.calculateDistance(o,i,!0)),n=l.roundPrecision(n+i.distanceFromPrevious),i.distanceFromStart=n}return e.map(s=>(s.lng=l.convertToStdLng(s.lng),s))}static calculateCenter(e){const t=[];for(const r of e)for(const c of r)t.push(c);const n=g.featureCollection([]),s=l.convertToMonotonicLng2(t);for(const r of s)n.features.push(g.point(r));const i=g.center(n).geometry.coordinates;return{lng:l.convertToStdLng(i[0],8),lat:l.roundPrecision(i[1],8)}}static calculateCenter2(e){const t=this.generateRouteAccordingToWaypoints(e);return this.calculateCenter(t)}static calculateBBox(e){const t=[];for(const o of e)for(const i of o)t.push(i);const n=l.convertToMonotonicLng2(t),s=g.lineString(n);return g.bbox(s)}static calculateBBox2(e){const t=this.generateRouteAccordingToWaypoints(e);return this.calculateBBox(t)}}let T;try{T=L.getLogger("vessel")}catch{}finally{}class A{static convert2Geojson(e){var n;const t=g.featureCollection([]);for(const s of e){if(s.forecasts){const o=(n=s.history)==null?void 0:n[0];for(const i of s.forecasts){const r=[],c=R(i.date).utc(),a=`${s.name}-${i.model}`;if(o){const d=R(o.updated).utc(),u=g.point([o.lng,o.lat],{model:i.model,name:s.name,date:d.format(),hour:0,format:d.format("MMM-DD/HHmm[Z]"),pressure:o.pressure>1e4?l.roundPrecision(o.pressure/100,0):l.roundPrecision(o.pressure,0),wind:{kts:o.kts,spd:o.speed||o.spd},category:a,type:"forecast"});t.features.push(u),r.push(u.geometry.coordinates)}for(const d in i==null?void 0:i.hours){const u=i.hours[d];u.wind.spd=u.wind.spd||u.wind.speed;const h=c.clone().add(Number(d),"hour"),f=g.point([u.lng,u.lat],{model:i.model,name:s.name,date:h.format(),hour:Number(d),format:h.format("MMM-DD/HHmm[Z]"),pressure:u.pressure>1e4?l.roundPrecision(u.pressure/100,0):l.roundPrecision(u.pressure,0),gusts:u.gusts,wind:u.wind||{},movement:u.movement,category:a,type:"forecast"});t.features.push(f),r.push(f.geometry.coordinates)}if((r==null?void 0:r.length)>1){const d=g.lineString(l.convertToMonotonicLng2(r),{date:i.date,id:s.id||s.name,model:i.model,name:s.name,category:a,type:"forecast"});t.features.push(d)}}}if(s.history){const o=[];for(const r of s.history){const c=R(r.updated).utc(),a=g.point([r.lng,r.lat],{name:s.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:`${s.name}-history`});t.features.push(a),o.push(a.geometry.coordinates)}const i=s.history[0];if(o.length===1&&o.push(o[0]),o.length>1){const r=g.lineString(l.convertToMonotonicLng2(o),{name:s.name,type:"history",updated:i==null?void 0:i.updated,pressure:(i==null?void 0:i.pressure)>1e4?l.roundPrecision((i==null?void 0:i.pressure)/100,0):l.roundPrecision(i==null?void 0:i.pressure,0),spd:(i==null?void 0:i.speed)||(i==null?void 0:i.spd),kts:i==null?void 0:i.kts,source:i==null?void 0:i.source,level:i==null?void 0:i.type});t.features.push(r)}}}return t}static interpolate(e,t=3){var o,i,r,c;const n=(o=e==null?void 0:e.data)==null?void 0:o.features.filter(a=>a.geometry.type==="LineString"&&a.properties.type==="forecast"),s=[];for(const a of n){const d=a.properties.name,u=a.properties.model,h=a.properties.showCircle,f=a.properties.disabled,v=R(a.properties.date).utc();let m=t*60-(v.get("hour")*60+v.get("minute"))%(t*60);const C=(i=e==null?void 0:e.data)==null?void 0:i.features.filter(S=>S.geometry.type==="Point"&&S.properties.type==="forecast"&&S.properties.category===`${d}-${u}`);let D,N=v.clone().add(m,"minute").set({minute:0,second:0,millisecond:0});for(;D=this.pickIndex(C,N),D<=C.length-1;){if(D>0){const S=C[D],p=D===0?void 0:C[D-1],y=(m/60-((r=p==null?void 0:p.properties)==null?void 0:r.hour))/(S.properties.hour-((c=p==null?void 0:p.properties)==null?void 0:c.hour)),E=this.computeNumber(p==null?void 0:p.geometry.coordinates[0],S.geometry.coordinates[0],y),F=this.computeNumber(p==null?void 0:p.geometry.coordinates[1],S.geometry.coordinates[1],y),B=g.point([E,F],{name:d,model:u,category:S==null?void 0:S.properties.category,date:N.format(),format:N.format("MMM-DD/HHmm[Z]"),gusts:this.computeNumber(p==null?void 0:p.properties.gusts,S.properties.gusts,y),hour:this.computeNumber(p==null?void 0:p.properties.hour,S.properties.hour,y),movement:this.computeNumber(p==null?void 0:p.properties.movement,S.properties.movement,y),pressure:this.computeNumber(p==null?void 0:p.properties.pressure,S.properties.pressure,y),wind:this.computeNumber(p==null?void 0:p.properties.wind,S.properties.wind,y),type:"forecast",disabled:f,showCircle:h});s.push(B)}m+=t*60,N=v.clone().add(m,"minute").set({minute:0,second:0,millisecond:0})}}return s}static accelPassageAt(e,t){const{t1:n,t2:s,hr:o,hours:i}=this.tropicalCenterTwin(e,24,t);return{t1:n,t2:s,hr:o,hours:i}}static diversionPassageAt(e,t,n,s={}){const{t1:o,t2:i,hr:r,hours:c}=this.tropicalCenterTwin(t,24,s);if(o&&i){if(!s.debug){const v=b.calculateDistance(e,o),m=b.calculateDistance(e,i);if(v>2*n&&m>2*n)return T==null||T.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need diversion: %j",s.requestId,v,m,{from:e,t1:o,t2:i,hr:r}),{}}const a=b.calculateBearing(e,o),d=b.calculateBearing(o,i),u=Math.abs(a-d);let h=0;u<180?h=u+90:u>=180&&(h=u-90);const f=b.calculateCoordinate(o,h,n);return T==null||T.info("[%s] the right tangent position: %j",s.requestId,{from:e,t1:o,t2:i,radius:n,bearing1:a,bearing2:d,right:f}),{at:f,t1:o,t2:i,hr:Number(r),hours:c}}return{}}static driftPassageAt(e,t,n,s={}){const{t1:o,t2:i,hr:r,hours:c}=this.tropicalCenterTwin(t,24,s);if(o&&i){if(!s.debug){const f=b.calculateDistance(e,o),v=b.calculateDistance(e,i);if(f>2*n&&v>2*n)return T==null||T.info("[%s] the distance between from and t1(%d) and t2(%d) is enough, no need drifting: %j",s.requestId,f,v,{from:e,t1:o,t2:i,hr:r}),{}}const a=b.calculateBearing(e,o),d=b.calculateBearing(o,i),u=b.calculateDistance(e,o);return{at:b.calculateCoordinate(o,a-d+180,n<u?n:u),t1:o,t2:i,hr:Number(r),hours:c}}else return T==null||T.info("[%s] no need drift: %j",s.requestId,{from:e,t1:o,t2:i,hr:r}),{}}static tropicalCenterTwin(e,t=24,n={}){var d,u,h,f,v;let s={};(d=e.forecasts)==null||d.forEach(m=>{s={...m.hours,...s}});const o=((u=e==null?void 0:e.history)==null?void 0:u[0])||(s==null?void 0:s[(h=Object.keys(s))==null?void 0:h[0]]);T==null||T.info("[%s] the first tropical center: %j",n.requestId,o);let i=(f=Object.keys(s||{}).filter(m=>Number(m)<=(t<0?24:t)))==null?void 0:f.at(-1);i||(i=(v=Object.keys(s||{}).filter(m=>Number(m)<=(t<0?24:2*t)))==null?void 0:v.at(-1));const r=s==null?void 0:s[i||-1];T==null||T.info("[%s] the second tropical center: %j in %d hrs",n.requestId,r,i);const c=Object.keys(s||{}).filter(m=>Number(m)<=Number(i)),a={0:o};for(const m of c)a[m]=s[m];return{t1:o,t2:r,hr:Number(i),hours:a}}static pickIndex(e,t){let n=0;for(const s of e){if(R(s.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 s={};for(const o in e)s[o]=this.computeNumber(e[o],t[o],n);return s}return Math.round((e+(t-e)*n)*100)/100}else return e;else return t}}M.LaneHelper=b,M.LngLatHelper=l,M.TropicalHelper=A,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,69 +1,69 @@
1
- {
2
- "name": "@idm-plugin/geo",
3
- "private": false,
4
- "version": "1.3.5",
5
- "description": "idm plugin for geo",
6
- "type": "module",
7
- "keywords": [
8
- "idm",
9
- "geo"
10
- ],
11
- "author": "chenheng@idmwx.com",
12
- "contributors": [
13
- "ChenHeng"
14
- ],
15
- "license": "GPL-3.0",
16
- "files": [
17
- "dist"
18
- ],
19
- "main": "./dist/index.umd.cjs",
20
- "module": "./dist/index.js",
21
- "types": "index.d.ts",
22
- "scripts": {
23
- "dev": "vite --config ./build/base.config.ts",
24
- "build": "vite build --config ./build/lib.config.ts",
25
- "lint:fix": "eslint --fix --ext .js,.ts,.",
26
- "prettier": "yarn lint:fix && prettier --write '**/*.{js,ts}'",
27
- "release": "yarn build && yarn publish --access public"
28
- },
29
- "dependencies": {
30
- "@log4js-node/log4js-api": "^1.0.2",
31
- "@turf/turf": "^6.5.0",
32
- "moment": "^2.30.1",
33
- "moment-timezone": "^0.5.45",
34
- "tz-lookup": "^6.1.25"
35
- },
36
- "devDependencies": {
37
- "@types/jest": "^25.2.2",
38
- "@types/node": "^18.14.2",
39
- "@types/tz-lookup": "^6.1.2",
40
- "@typescript-eslint/eslint-plugin": "^5.53.0",
41
- "@typescript-eslint/parser": "^5.53.0",
42
- "@vitejs/plugin-vue": "^4.2.3",
43
- "eslint": "^8.35.0",
44
- "eslint-config-prettier": "^8.6.0",
45
- "eslint-define-config": "^1.15.0",
46
- "eslint-plugin-prettier": "^4.2.1",
47
- "jest": "^26.6.3",
48
- "lint-staged": "^13.1.2",
49
- "prettier": "^2.8.4",
50
- "sass": "^1.58.3",
51
- "simple-git-hooks": "^2.8.1",
52
- "stylelint": "^15.2.0",
53
- "supertest": "^4.0.2",
54
- "ts-jest": "^26.5.3",
55
- "ts-node-dev": "^2.0.0-0",
56
- "tsconfig-paths": "^3.12.0",
57
- "typescript": "^4.9.3",
58
- "vite": "^4.1.0",
59
- "vite-plugin-dts": "^2.0.2",
60
- "vite-plugin-static-copy": "^0.17.0"
61
- },
62
- "lint-staged": {
63
- "*.{ts,tsx,js}": "eslint --fix",
64
- "*.{ts,tsx,js,scss}": "prettier --write"
65
- },
66
- "simple-git-hooks": {
67
- "pre-commit": "npx lint-staged"
68
- }
69
- }
1
+ {
2
+ "name": "@idm-plugin/geo",
3
+ "private": false,
4
+ "version": "1.3.6",
5
+ "description": "idm plugin for geo",
6
+ "type": "module",
7
+ "keywords": [
8
+ "idm",
9
+ "geo"
10
+ ],
11
+ "author": "chenheng@idmwx.com",
12
+ "contributors": [
13
+ "ChenHeng"
14
+ ],
15
+ "license": "GPL-3.0",
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "main": "./dist/index.umd.cjs",
20
+ "module": "./dist/index.js",
21
+ "types": "index.d.ts",
22
+ "scripts": {
23
+ "dev": "vite --config ./build/base.config.ts",
24
+ "build": "vite build --config ./build/lib.config.ts",
25
+ "lint:fix": "eslint --fix --ext .js,.ts,.",
26
+ "prettier": "yarn lint:fix && prettier --write '**/*.{js,ts}'",
27
+ "release": "yarn build && yarn publish --access public"
28
+ },
29
+ "dependencies": {
30
+ "@log4js-node/log4js-api": "^1.0.2",
31
+ "@turf/turf": "^6.5.0",
32
+ "moment": "^2.30.1",
33
+ "moment-timezone": "^0.5.45",
34
+ "tz-lookup": "^6.1.25"
35
+ },
36
+ "devDependencies": {
37
+ "@types/jest": "^25.2.2",
38
+ "@types/node": "^18.14.2",
39
+ "@types/tz-lookup": "^6.1.2",
40
+ "@typescript-eslint/eslint-plugin": "^5.53.0",
41
+ "@typescript-eslint/parser": "^5.53.0",
42
+ "@vitejs/plugin-vue": "^4.2.3",
43
+ "eslint": "^8.35.0",
44
+ "eslint-config-prettier": "^8.6.0",
45
+ "eslint-define-config": "^1.15.0",
46
+ "eslint-plugin-prettier": "^4.2.1",
47
+ "jest": "^26.6.3",
48
+ "lint-staged": "^13.1.2",
49
+ "prettier": "^2.8.4",
50
+ "sass": "^1.58.3",
51
+ "simple-git-hooks": "^2.8.1",
52
+ "stylelint": "^15.2.0",
53
+ "supertest": "^4.0.2",
54
+ "ts-jest": "^26.5.3",
55
+ "ts-node-dev": "^2.0.0-0",
56
+ "tsconfig-paths": "^3.12.0",
57
+ "typescript": "^4.9.3",
58
+ "vite": "^4.1.0",
59
+ "vite-plugin-dts": "^2.0.2",
60
+ "vite-plugin-static-copy": "^0.17.0"
61
+ },
62
+ "lint-staged": {
63
+ "*.{ts,tsx,js}": "eslint --fix",
64
+ "*.{ts,tsx,js,scss}": "prettier --write"
65
+ },
66
+ "simple-git-hooks": {
67
+ "pre-commit": "npx lint-staged"
68
+ }
69
+ }