@idm-plugin/geo 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -2
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import h from "moment";
|
|
2
2
|
import "moment-timezone";
|
|
3
3
|
import l from "tz-lookup";
|
|
4
|
-
import * as M from "log4js";
|
|
5
4
|
import * as f from "@turf/turf";
|
|
6
5
|
class s {
|
|
7
6
|
/**
|
|
@@ -152,7 +151,6 @@ class s {
|
|
|
152
151
|
return `${i}.${o}`;
|
|
153
152
|
}
|
|
154
153
|
}
|
|
155
|
-
M.getLogger();
|
|
156
154
|
class $ {
|
|
157
155
|
static convert2Geojson(e) {
|
|
158
156
|
const r = f.featureCollection([]);
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(p,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("moment"),require("moment-timezone"),require("tz-lookup"),require("@turf/turf")):typeof define=="function"&&define.amd?define(["exports","moment","moment-timezone","tz-lookup","@turf/turf"],m):(p=typeof globalThis<"u"?globalThis:p||self,m(p["idm-plugin-rabbitmq"]={},p.moment,p["moment-timezone"],p["tz-lookup"],p["@turf/turf"]))})(this,function(p,m,v,S,b){"use strict";function N(h){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const t in h)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(h,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>h[t]})}}return e.default=h,Object.freeze(e)}const l=N(b);class n{static guessTimeZoneOffset(e,t){const o=S(t,e),i=m().tz(o).utcOffset();return this.roundPrecision(i/60,1)}static prettyTimeZoneOffset(e){let t=Math.floor(Math.abs(e)),o=Math.round((Math.abs(e)-t)*60);return o=o>9?o:`0${o}`,t=t>9?t:`0${t}`,e>0?`+${t}:${o}`:`-${t}:${o}`}static lng2pretty(e,t=6,o="H°M′"){e=n.convertToStdLng(e,t);let i="E";e<0&&(i="W"),e=Math.abs(e),o=o.toUpperCase();let r=e*3600,s,c,u,d,f,a;s=r%3600%60,o.indexOf("S")!==-1&&(r=r-s,c=n.padNumber(s,2,2)),u=r/60%60,o.indexOf("M")!==-1&&(o.indexOf("S")!==-1?d=n.roundPrecision(u,t).toString().padStart(2,"0"):d=n.padNumber(u,2,2),r=r-u*60),f=r/3600,o.indexOf("M")!==-1?a=n.roundPrecision(f,t).toString().padStart(3,"0"):a=n.padNumber(f,3,2);const M=`${o.replace(/S+/gi,c).replace(/M+/gi,d).replace(/H+/gi,a)}${i}`;return{direction:i,degree:n.roundPrecision(f,t),minute:n.roundPrecision(u,t),second:n.roundPrecision(s,t),pretty:M}}static lat2pretty(e,t=6,o="H°M′"){e=e%180;let i="N";e<0&&(i="S"),e=Math.abs(e),o=o.toUpperCase();let r=e*3600,s,c,u,d,f,a;s=r%3600%60,o.indexOf("S")!==-1&&(r=r-s,c=n.padNumber(s,2,2)),u=r/60%60,o.indexOf("M")!==-1&&(o.indexOf("S")!==-1?d=n.roundPrecision(u,t).toString().padStart(2,"0"):d=n.padNumber(u,2,2),r=r-u*60),f=r/3600,o.indexOf("M")!==-1?a=n.roundPrecision(f,t).toString().padStart(2,"0"):a=n.padNumber(f,2,2);const M=`${o.replace(/S+/gi,c).replace(/M+/gi,d).replace(/H+/gi,a)}${i}`;return{direction:i,degree:n.roundPrecision(f,t),minute:n.roundPrecision(u,t),second:n.roundPrecision(s,t),pretty:M}}static str2Lng(e,t=6){let o;if(isNaN(e)){e=n.strReplace(e,"LNG");const i=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const r=e.split(" ").filter(u=>u!=="").map(u=>Number(u));let[s,c]=r;if(s>360&&!c){const u=this.roundPrecision(s/100,0);c=s-u*100,s=u}o=s+(c??0)/60,i==="W"&&(o=o*-1)}else o=Number(e);return n.convertToStdLng(o,t)}static str2Lat(e,t=6){let o;if(isNaN(e)){e=n.strReplace(e,"LAT");const i=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const r=e.split(" ").filter(u=>u!=="").map(u=>Number(u));let[s,c]=r;if(s>90&&!c){const u=this.roundPrecision(s/100,0);c=s-u*100,s=u}o=s+(c??0)/60,i==="S"&&(o=o*-1)}else o=Number(e);return n.roundPrecision(o,t)}static str2LngOrLat(e,t=6,o="LAT"){e=n.strReplace(e,o);const i=e[e.length-1].toUpperCase();return["N","S"].includes(i)?{lat:n.str2Lat(e,t)}:{lng:n.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),n.roundPrecision(e,t)}static roundPrecision(e,t=4){if(typeof e=="number"){const o=Number("1".padEnd(t+1,"0"));return Math.round(e*o)/o}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 o=e[e.length-1].toUpperCase();if(!["N","S","E","W"].includes(o)){const i=e,r=Number(i.split(" ")[0]);if(isNaN(r))throw new Error(`invalid Lat/Lng: ${e}`);r>=90?e=`${i}E`:r<=-90?e=`${i}W`:["LAN","LNG"].includes(t==null?void 0:t.toUpperCase())?e=`${i}${r>0?"E":"W"}`:e=`${i}${r>0?"N":"S"}`}return e}static padNumber(e,t=2,o=2){const i=Math.trunc(e).toString().padStart(t,"0"),r=Math.trunc(n.roundPrecision(e-Math.trunc(e),o)*Math.pow(10,o)).toString().padStart(o,"0");return`${i}.${r}`}}class g{static convert2Geojson(e){const t=l.featureCollection([]);for(const o of e){if(o.forecasts)for(const i of o.forecasts){const r=[],s=m(i.date).utc(),c=`${o.name}-${i.model}`;for(const u in i==null?void 0:i.hours){const d=i.hours[u],f=s.clone().add(Number(u),"hour"),a=l.point([d.lng,d.lat],{date:f.format(),hour:Number(u),format:f.format("MMM-DD/HHmm[Z]"),pressure:d.pressure>1e4?n.roundPrecision(d.pressure/100,0):n.roundPrecision(d.pressure,0),gusts:d.gusts,wind:d.wind||{},movement:d.movement,category:c,type:"forecast"});t.features.push(a),r.push(a.geometry.coordinates)}if((r==null?void 0:r.length)>1){const u=l.lineString(n.convertToMonotonicLng2(r),{date:i.date,id:o.id||o.name,model:i.model,name:o.name,category:c,type:"forecast"});t.features.push(u)}}if(o.history){const i=[];for(const s of o.history){const c=m(s.updated).utc(),u=l.point([s.lng,s.lat],{date:c.format(),format:c.format("MMM-DD/HHmm[Z]"),pressure:s.pressure>1e4?n.roundPrecision(s.pressure/100,0):n.roundPrecision(s.pressure,0),speed:s.speed,kts:s.kts,source:s.source,level:s.type,type:"history",category:`${o.name}-history`});t.features.push(u),i.push(u.geometry.coordinates)}const r=o.history[0];if(i.length===1&&i.push(i[0]),i.length>1){const s=l.lineString(n.convertToMonotonicLng2(i),{name:o.name,type:"history",updated:r==null?void 0:r.updated,pressure:(r==null?void 0:r.pressure)>1e4?n.roundPrecision((r==null?void 0:r.pressure)/100,0):n.roundPrecision(r==null?void 0:r.pressure,0),speed:r==null?void 0:r.speed,kts:r==null?void 0:r.kts,source:r==null?void 0:r.source,level:r==null?void 0:r.type});t.features.push(s)}}}return t}}p.LngLatHelper=n,p.TropicalHelper=g,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|