@idm-plugin/geo 1.0.4 → 1.0.5
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 +2 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -178,6 +178,7 @@ class x {
|
|
|
178
178
|
const p = o.hours[a];
|
|
179
179
|
p.wind.spd = p.wind.spd || p.wind.speed;
|
|
180
180
|
const h = c.clone().add(Number(a), "hour"), l = N.point([p.lng, p.lat], {
|
|
181
|
+
model: o.model,
|
|
181
182
|
name: s.name,
|
|
182
183
|
date: h.format(),
|
|
183
184
|
hour: Number(a),
|
|
@@ -246,7 +247,7 @@ class x {
|
|
|
246
247
|
const a = m.properties.name, p = m.properties.model, h = y(m.properties.date).utc();
|
|
247
248
|
let l = t * 60 - (h.get("hour") * 60 + h.get("minute")) % (t * 60);
|
|
248
249
|
const b = (o = e == null ? void 0 : e.data) == null ? void 0 : o.features.filter(
|
|
249
|
-
(f) =>
|
|
250
|
+
(f) => f.geometry.type === "Point" && f.properties.type === "forecast" && f.properties.category === `${a}-${p}`
|
|
250
251
|
);
|
|
251
252
|
let M, S = h.clone().add(l, "minute").set({ minute: 0, second: 0, millisecond: 0 });
|
|
252
253
|
for (; M = this.pickIndex(b, S), M <= b.length - 1; ) {
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(h,g){typeof exports=="object"&&typeof module<"u"?g(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"],g):(h=typeof globalThis<"u"?globalThis:h||self,g(h["idm-plugin-rabbitmq"]={},h.moment,h["moment-timezone"],h["tz-lookup"],h["@turf/turf"]))})(this,function(h,g,j,T,O){"use strict";function w(b){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(b){for(const t in b)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(b,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>b[t]})}}return e.default=b,Object.freeze(e)}const y=w(O);class s{static guessTimeZoneOffset(e,t){const o=T(t,e),n=g().tz(o).utcOffset();return this.roundPrecision(n/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=s.convertToStdLng(e,t);let n="E";e<0&&(n="W"),e=Math.abs(e),o=o.toUpperCase();let i=e*3600,r,u,c,a,
|
|
1
|
+
(function(h,g){typeof exports=="object"&&typeof module<"u"?g(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"],g):(h=typeof globalThis<"u"?globalThis:h||self,g(h["idm-plugin-rabbitmq"]={},h.moment,h["moment-timezone"],h["tz-lookup"],h["@turf/turf"]))})(this,function(h,g,j,T,O){"use strict";function w(b){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(b){for(const t in b)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(b,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>b[t]})}}return e.default=b,Object.freeze(e)}const y=w(O);class s{static guessTimeZoneOffset(e,t){const o=T(t,e),n=g().tz(o).utcOffset();return this.roundPrecision(n/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=s.convertToStdLng(e,t);let n="E";e<0&&(n="W"),e=Math.abs(e),o=o.toUpperCase();let i=e*3600,r,u,c,m,a,p;r=i%3600%60,o.indexOf("S")!==-1&&(i=i-r,u=s.padNumber(r,2,2)),c=i/60%60,o.indexOf("M")!==-1&&(o.indexOf("S")!==-1?m=s.roundPrecision(c,t).toString().padStart(2,"0"):m=s.padNumber(c,2,2),i=i-c*60),a=i/3600,o.indexOf("M")!==-1?p=s.roundPrecision(a,t).toString().padStart(3,"0"):p=s.padNumber(a,3,2);const l=`${o.replace(/S+/gi,u).replace(/M+/gi,m).replace(/H+/gi,p)}${n}`;return{direction:n,degree:s.roundPrecision(a,t),minute:s.roundPrecision(c,t),second:s.roundPrecision(r,t),pretty:l}}static lat2pretty(e,t=6,o="H°M′"){e=e%180;let n="N";e<0&&(n="S"),e=Math.abs(e),o=o.toUpperCase();let i=e*3600,r,u,c,m,a,p;r=i%3600%60,o.indexOf("S")!==-1&&(i=i-r,u=s.padNumber(r,2,2)),c=i/60%60,o.indexOf("M")!==-1&&(o.indexOf("S")!==-1?m=s.roundPrecision(c,t).toString().padStart(2,"0"):m=s.padNumber(c,2,2),i=i-c*60),a=i/3600,o.indexOf("M")!==-1?p=s.roundPrecision(a,t).toString().padStart(2,"0"):p=s.padNumber(a,2,2);const l=`${o.replace(/S+/gi,u).replace(/M+/gi,m).replace(/H+/gi,p)}${n}`;return{direction:n,degree:s.roundPrecision(a,t),minute:s.roundPrecision(c,t),second:s.roundPrecision(r,t),pretty:l}}static str2Lng(e,t=6){let o;if(isNaN(e)){e=s.strReplace(e,"LNG");const n=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[r,u]=i;if(r>360&&!u){const c=this.roundPrecision(r/100,0);u=r-c*100,r=c}o=r+(u??0)/60,n==="W"&&(o=o*-1)}else o=Number(e);return s.convertToStdLng(o,t)}static str2Lat(e,t=6){let o;if(isNaN(e)){e=s.strReplace(e,"LAT");const n=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[r,u]=i;if(r>90&&!u){const c=this.roundPrecision(r/100,0);u=r-c*100,r=c}o=r+(u??0)/60,n==="S"&&(o=o*-1)}else o=Number(e);return s.roundPrecision(o,t)}static str2LngOrLat(e,t=6,o="LAT"){e=s.strReplace(e,o);const n=e[e.length-1].toUpperCase();return["N","S"].includes(n)?{lat:s.str2Lat(e,t)}:{lng:s.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),s.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 n=e,i=Number(n.split(" ")[0]);if(isNaN(i))throw new Error(`invalid Lat/Lng: ${e}`);i>=90?e=`${n}E`:i<=-90?e=`${n}W`:["LAN","LNG"].includes(t==null?void 0:t.toUpperCase())?e=`${n}${i>0?"E":"W"}`:e=`${n}${i>0?"N":"S"}`}return e}static padNumber(e,t=2,o=2){const n=Math.trunc(e).toString().padStart(t,"0"),i=Math.trunc(s.roundPrecision(e-Math.trunc(e),o)*Math.pow(10,o)).toString().padStart(o,"0");return`${n}.${i}`}}class k{static convert2Geojson(e){var o;const t=y.featureCollection([]);for(const n of e){if(n.forecasts){const i=(o=n.history)==null?void 0:o[0];for(const r of n.forecasts){const u=[],c=g(r.date).utc(),m=`${n.name}-${r.model}`;if(i){const a=g(i.updated).utc(),p=y.point([i.lng,i.lat],{model:r.model,name:n.name,date:a.format(),hour:0,format:a.format("MMM-DD/HHmm[Z]"),pressure:i.pressure>1e4?s.roundPrecision(i.pressure/100,0):s.roundPrecision(i.pressure,0),wind:{kts:i.kts,spd:i.speed||i.spd},category:m,type:"forecast"});t.features.push(p),u.push(p.geometry.coordinates)}for(const a in r==null?void 0:r.hours){const p=r.hours[a];p.wind.spd=p.wind.spd||p.wind.speed;const l=c.clone().add(Number(a),"hour"),M=y.point([p.lng,p.lat],{model:r.model,name:n.name,date:l.format(),hour:Number(a),format:l.format("MMM-DD/HHmm[Z]"),pressure:p.pressure>1e4?s.roundPrecision(p.pressure/100,0):s.roundPrecision(p.pressure,0),gusts:p.gusts,wind:p.wind||{},movement:p.movement,category:m,type:"forecast"});t.features.push(M),u.push(M.geometry.coordinates)}if((u==null?void 0:u.length)>1){const a=y.lineString(s.convertToMonotonicLng2(u),{date:r.date,id:n.id||n.name,model:r.model,name:n.name,category:m,type:"forecast"});t.features.push(a)}}}if(n.history){const i=[];for(const u of n.history){const c=g(u.updated).utc(),m=y.point([u.lng,u.lat],{name:n.name,date:c.format(),format:c.format("MMM-DD/HHmm[Z]"),pressure:u.pressure>1e4?s.roundPrecision(u.pressure/100,0):s.roundPrecision(u.pressure,0),spd:u.speed||u.spd,kts:u.kts,source:u.source,level:u.type,type:"history",category:`${n.name}-history`});t.features.push(m),i.push(m.geometry.coordinates)}const r=n.history[0];if(i.length===1&&i.push(i[0]),i.length>1){const u=y.lineString(s.convertToMonotonicLng2(i),{name:n.name,type:"history",updated:r==null?void 0:r.updated,pressure:(r==null?void 0:r.pressure)>1e4?s.roundPrecision((r==null?void 0:r.pressure)/100,0):s.roundPrecision(r==null?void 0:r.pressure,0),spd:(r==null?void 0:r.speed)||(r==null?void 0:r.spd),kts:r==null?void 0:r.kts,source:r==null?void 0:r.source,level:r==null?void 0:r.type});t.features.push(u)}}}return t}static interpolate(e,t=3){var i,r,u,c;const o=(i=e==null?void 0:e.data)==null?void 0:i.features.filter(m=>m.geometry.type==="LineString"&&m.properties.type==="forecast"),n=[];for(const m of o){const a=m.properties.name,p=m.properties.model,l=g(m.properties.date).utc();let M=t*60-(l.get("hour")*60+l.get("minute"))%(t*60);const P=(r=e==null?void 0:e.data)==null?void 0:r.features.filter(f=>f.geometry.type==="Point"&&f.properties.type==="forecast"&&f.properties.category===`${a}-${p}`);let S,$=l.clone().add(M,"minute").set({minute:0,second:0,millisecond:0});for(;S=this.pickIndex(P,$),S<=P.length-1;){if(S>0){const f=P[S],d=S===0?void 0:P[S-1],N=(M/60-((u=d==null?void 0:d.properties)==null?void 0:u.hour))/(f.properties.hour-((c=d==null?void 0:d.properties)==null?void 0:c.hour)),D=this.computeNumber(d==null?void 0:d.geometry.coordinates[0],f.geometry.coordinates[0],N),z=this.computeNumber(d==null?void 0:d.geometry.coordinates[1],f.geometry.coordinates[1],N),C=y.point([D,z],{name:a,model:p,category:f==null?void 0:f.properties.category,date:$.format(),format:$.format("MMM-DD/HHmm[Z]"),gusts:this.computeNumber(d==null?void 0:d.properties.gusts,f.properties.gusts,N),hour:this.computeNumber(d==null?void 0:d.properties.hour,f.properties.hour,N),movement:this.computeNumber(d==null?void 0:d.properties.movement,f.properties.movement,N),pressure:this.computeNumber(d==null?void 0:d.properties.pressure,f.properties.pressure,N),wind:this.computeNumber(d==null?void 0:d.properties.wind,f.properties.wind,N),type:"forecast"});n.push(C)}M+=t*60,$=l.clone().add(M,"minute").set({minute:0,second:0,millisecond:0})}}return n}static pickIndex(e,t){let o=0;for(const n of e){if(g(n.properties.date).isAfter(t))return o===0?-1:o;o++}return o}static computeNumber(e,t,o){if(e)if(t){if(isNaN(e)&&isNaN(t)&&typeof e!="string"&&typeof t!="string"){const n={};for(const i in e)n[i]=this.computeNumber(e[i],t[i],o);return n}return Math.round((e+(t-e)*o)*100)/100}else return e;else return t}}h.LngLatHelper=s,h.TropicalHelper=k,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|