@metoceanapi/wxtiles-leaflet 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +137 -305
- package/dist/es/defaults/styles.d.ts +2 -2
- package/dist/es/defaults/uconv.d.ts +2 -2
- package/dist/es/index.d.ts +31 -4
- package/dist/es/index.js +1 -1
- package/dist/es/utils/RawCLUT.d.ts +32 -22
- package/dist/es/utils/qtree.d.ts +11 -5
- package/dist/es/utils/wxtools.d.ts +226 -60
- package/dist/es/wxAPI/WxDataSetManager.d.ts +65 -35
- package/dist/es/wxAPI/wxAPI.d.ts +115 -43
- package/dist/es/wxlayer/WxImplementation.d.ts +74 -32
- package/dist/es/wxlayer/loader.d.ts +27 -3
- package/dist/es/wxlayer/loadertools.d.ts +41 -3
- package/dist/es/wxlayer/painter.d.ts +39 -0
- package/dist/es/wxlayer/wxlayer.d.ts +77 -9
- package/dist/es/wxsource/wxsource.d.ts +60 -20
- package/dist/es/wxsource/wxsourcetypes.d.ts +13 -0
- package/dist/web/index.js +1 -1
- package/docs/docs/assets/highlight.css +92 -0
- package/docs/docs/assets/main.js +54 -0
- package/docs/docs/assets/search.js +1 -0
- package/docs/docs/assets/style.css +1257 -0
- package/docs/docs/classes/FrameworkParentClass.html +86 -0
- package/docs/docs/classes/Loader.html +165 -0
- package/docs/docs/classes/Painter.html +161 -0
- package/docs/docs/classes/QTree.html +129 -0
- package/docs/docs/classes/RawCLUT.html +143 -0
- package/docs/docs/classes/WxAPI.html +336 -0
- package/docs/docs/classes/WxDataSetManager.html +389 -0
- package/docs/docs/classes/WxLayer.html +363 -0
- package/docs/docs/classes/WxLayerBaseImplementation.html +358 -0
- package/docs/docs/classes/WxTileSource.html +435 -0
- package/docs/docs/enums/TileType.html +80 -0
- package/docs/docs/functions/WXLOG.html +118 -0
- package/docs/docs/functions/WxCreateLegend.html +126 -0
- package/docs/docs/functions/WxGetColorSchemes.html +113 -0
- package/docs/docs/functions/WxGetColorStyles.html +113 -0
- package/docs/docs/functions/WxTilesLogging.html +118 -0
- package/docs/docs/index.html +199 -0
- package/docs/docs/interfaces/ColorStylesIncomplete.html +116 -0
- package/docs/docs/interfaces/Converter.html +81 -0
- package/docs/docs/interfaces/DataIntegral.html +112 -0
- package/docs/docs/interfaces/DataPicture.html +93 -0
- package/docs/docs/interfaces/FrameworkOptions.html +118 -0
- package/docs/docs/interfaces/IntegralPare.html +81 -0
- package/docs/docs/interfaces/SLinePoint.html +77 -0
- package/docs/docs/interfaces/Tree.html +70 -0
- package/docs/docs/interfaces/WxAPIOptions.html +164 -0
- package/docs/docs/interfaces/WxAllBoundariesMeta.html +85 -0
- package/docs/docs/interfaces/WxBoundaryMeta.html +91 -0
- package/docs/docs/interfaces/WxColorSchemes.html +117 -0
- package/docs/docs/interfaces/WxColorStyleStrict.html +299 -0
- package/docs/docs/interfaces/WxColorStyleWeak.html +325 -0
- package/docs/docs/interfaces/WxColorStylesStrict.html +74 -0
- package/docs/docs/interfaces/WxColorStylesWeakMixed.html +116 -0
- package/docs/docs/interfaces/WxData.html +81 -0
- package/docs/docs/interfaces/WxDataSetManagerOptions.html +108 -0
- package/docs/docs/interfaces/WxDataSetsMetasJSON.html +75 -0
- package/docs/docs/interfaces/WxDatasetMeta.html +135 -0
- package/docs/docs/interfaces/WxDatasetShortMeta.html +90 -0
- package/docs/docs/interfaces/WxLayerAPI.html +313 -0
- package/docs/docs/interfaces/WxLayerBaseAPI.html +246 -0
- package/docs/docs/interfaces/WxLayerOptions.html +111 -0
- package/docs/docs/interfaces/WxLegend.html +117 -0
- package/docs/docs/interfaces/WxLngLat.html +81 -0
- package/docs/docs/interfaces/WxRasterData.html +99 -0
- package/docs/docs/interfaces/WxRequestInit.html +70 -0
- package/docs/docs/interfaces/WxTick.html +99 -0
- package/docs/docs/interfaces/WxTileInfo.html +142 -0
- package/docs/docs/interfaces/WxTilesLibOptions.html +92 -0
- package/docs/docs/interfaces/WxUnits.html +116 -0
- package/docs/docs/interfaces/WxVariableMeta.html +108 -0
- package/docs/docs/interfaces/WxVariablesMetas.html +116 -0
- package/docs/docs/interfaces/XYZ.html +84 -0
- package/docs/docs/modules.html +208 -0
- package/docs/docs/types/DataIntegrals.html +109 -0
- package/docs/docs/types/DataPictures.html +109 -0
- package/docs/docs/types/SLine.html +109 -0
- package/docs/docs/types/SubTrees.html +109 -0
- package/docs/docs/types/SubTreesN.html +109 -0
- package/docs/docs/types/TreeN.html +109 -0
- package/docs/docs/types/UriLoaderPromiseFunc.html +129 -0
- package/docs/docs/types/WxDate.html +109 -0
- package/docs/docs/types/WxURIs.html +109 -0
- package/docs/docs/types/WxUnitTuple.html +109 -0
- package/docs/docs/types/WxVars.html +109 -0
- package/docs/script/script.css +1 -1
- package/docs/script/script.js +6 -6
- package/package.json +8 -8
- package/src_example/index.ts +12 -7
package/dist/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Ae=Object.create;var H=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames,oe=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable;var se=(a,e,t)=>e in a?H(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,F=(a,e)=>{for(var t in e||(e={}))ie.call(e,t)&&se(a,t,e[t]);if(oe)for(var t of oe(e))Oe.call(e,t)&&se(a,t,e[t]);return a};var Ze=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var Ve=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ue(e))!ie.call(a,n)&&n!==t&&H(a,n,{get:()=>e[n],enumerable:!(r=_e(e,n))||r.enumerable});return a};var Xe=(a,e,t)=>(t=a!=null?Ae(Fe(a)):{},Ve(e||!a||!a.__esModule?H(t,"default",{value:a,enumerable:!0}):t,a));var g=(a,e,t)=>new Promise((r,n)=>{var o=c=>{try{i(t.next(c))}catch(l){n(l)}},s=c=>{try{i(t.throw(c))}catch(l){n(l)}},i=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);i((t=t.apply(a,e)).next())});var ke=Ze((Ht,Pe)=>{Pe.exports=window.L});var le={comment1:["'degC': ['K', 1, 273.15] -> degC = K * 1 + 273.15",0],comment2:["'hPa': ['Pa', 1000]' -> hPa = Pa * 1000 + 0 (0 - could be ommited)",0],K:["K",1],kelvin:["K",1],F:["K",.5555555555,255.372222222],C:["K",1,273.15],degC:["K",1,273.15],"kg/m^2/s":["kg/m^2/s",1],"Kg/m^2/s":["kg/m^2/s",1],"Kg m**-2 s**-1":["kg/m^2/s",1],"Kg m^-2 s^-1":["kg/m^2/s",1],"Kg m^{-2} s^-1":["kg/m^2/s",1],"mm/h":["kg/m^2/s",.00027777777],"mm/hr":["kg/m^2/s",.00027777777],"W/m^2":["W/m^2",1],"W m^-2":["W/m^2",1],"W m^{-2}":["W/m^2",1],"W/m**2":["W/m^2",1],"W m**-2":["W/m^2",1],"m/s":["m/s",1],"m s**-1":["m/s",1],"m s^-1":["m/s",1],"m.s^{-1}":["m/s",1],knot:["m/s",.514444],knots:["m/s",.514444],"km/h":["m/s",.27777777777],"km h^-1":["m/s",.27777777777],"km h**-1":["m/s",.27777777777],mph:["m/s",.44704],"miles/h":["m/s",.44704],s:["s",1],sec:["s",1],h:["s",3600],min:["s",60],m:["m",1],cm:["m",.01],km:["m",1e3],mile:["m",1609.344],miles:["m",1609.344],inch:["m",.0254],Pa:["Pa",1],hPa:["Pa",100],degree:["degree",1],radian:["degree",57.3],"mg/m^3":["mg/m^3",1],"mg m^-3":["mg/m^3",1],"mg.m^-3":["mg/m^3",1],"%":["%",1],"(0 - 1)":["%",100]};var ce={none:["#00000000","#00000000"],divergingbluered:["#2166acff","#92c5deff","#f7f7f7ff","#f4a582ff","#b2182bff"],rainbow:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbowzerro:["#ff000000","#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbow2:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff","#ff0000ff"],bluebird:["#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bluebirdzerro:["#0000ff00","#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bw:["#000000ff","#ffffffff"],wb:["#ffffffff","#000000ff"],redish:["#ff00ffff","#ff0000ff","#ffff00ff"],greenish:["#ffff00ff","#00ff00ff","#00ffffff"],blueish:["#ff00ffff","#0000ffff","#00ffffff"],hspastel:["#AC6EA4FF","#8E92BDFF","#ACD4DEFF","#E9DC8EFF","#E7A97DFF","#E59074FF","#BE7E68FF","#A88F86FF"]};var O={base:{parent:void 0,name:"base",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"rainbow",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"},custom:{parent:void 0,name:"custom",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"rainbow",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"}};var ue,me,de;function fe({colorStyles:a={},units:e={},colorSchemes:t={}}={}){h("WxTile lib setup: start"),ue=Object.assign({},le,e),me=Object.assign({},t,ce);let r=Object.assign({},a,O);de=Ee(r),h("WxTile lib setup: styles unrolled");try{g(this,null,function*(){yield document.fonts.load("32px barbs"),yield document.fonts.load("32px arrows")})}catch(n){h("WxTile lib setup: fonts not loaded")}h("WxTile lib setup is done.")}function A(){return de}function z(){return me}function Z(a,e,t){h("makeConverter: From=",a," To=",e);let r=m=>m;if(r.trivial=!0,a===e)return h("Trivial converter"),r;let n=Object.assign({},ue,t),o=n[a],s=n[e];if(!o||!s)return h("Inconvertible units. Trivial converter"),r;let[i,c,l]=o,[u,d,f]=s;if(i!==u||!c||!d)return h("Inconvertible units. Trivial converter"),r;let b=c/d,x=((l||0)-(f||0))/d;return x?m=>b*m+x:m=>b*m}function Ee(a){let e=Object.assign({},O);for(let o in a){let s=a[o];if(Array.isArray(s))for(let i=0;i<s.length;++i)e[o+"["+i+"]"]=Object.assign({},s[i]);else e[o]=Object.assign({},s)}let t=Object.assign({},O.base),r=(o,s)=>{if(s==="base")return t;let i=o[s];if(!i)return t;(!i.parent||!(i.parent in o))&&(i.parent="base");let c=r(o,i.parent);return Object.assign(i,Object.assign({},c,i,{parent:"base"}))},n={base:t};for(let o in e)n[o]=r(e,o);return n}function _(a){let e=new Map;return(t,...r)=>{let n=e.get(t);if(n)return n;let o=a(t,...r);return e.set(t,o),o.catch(s=>{s.name==="AbortError"&&e.delete(t)}),o}}function Ne(a,e){return g(this,null,function*(){return createImageBitmap(yield(yield fetch(a,e)).blob())})}function I(a,e,t=!0){let r=Object.assign(document.createElement("canvas"),{width:a,height:e,imageSmoothingEnabled:!1}).getContext("2d",{willReadFrequently:t});if(!r)throw new Error("Cannot get canvas context");return r}function Be(a){let{width:e,height:t}=a,r=I(e,t);return r.drawImage(a,0,0),r.getImageData(0,0,e,t)}function K(a,e){return g(this,null,function*(){return Be(yield Ne(a,e))})}function $e(a){a.data[34]<1&&h("Warning: image is in too old format. Check the version of the Splitter.");let e=new Uint16Array(a.data.buffer),t=new Uint16Array(e.length/2);for(let l=0;l<t.length;l++)t[l]=e[l*2];let r=new Uint8Array(8);for(let l=0;l<8;++l)r[l]=a.data[l*4+2];let n=new DataView(r.buffer),o=n.getFloat32(0,!0),s=n.getFloat32(4,!0),i=(s-o)/65535,c=qe(t);return{raw:t,dmin:o,dmax:s,dmul:i,integral:c,radius:0}}function J(a,e){return g(this,null,function*(){return $e(yield K(a,e))})}function qe(a){let e=new Uint32Array(66564),t=new Uint32Array(258*258);e[0]=a[0],t[0]=a[0]===0?0:1;for(let r=1;r<258;++r)e[r]=a[r]+e[r-1],e[258*r]=a[258*r]+e[258*r-258],t[r]=(a[r]===0?0:1)+t[r-1],t[258*r]=(a[258*r]===0?0:1)+t[258*r-258];for(let r=1,n=259;r<258;++r,++n)for(let o=1;o<258;++o,++n)e[n]=a[n]+e[n-258]+e[n-1]-e[n-258-1],t[n]=(a[n]===0?0:1)+t[n-258]+t[n-1]-t[n-258-1];return{integral:e,integralNZ:t}}function xe(a,e){if(e<0||e===a.radius)return a;a.radius=e;let t=258,{integral:r,integralNZ:n}=a.integral;for(let o=1;o<t;o++)for(let s=1;s<t;s++){if(!a.raw[t*o+s])continue;let i=Math.min(e,s-1,t-1-s),c=Math.min(e,o-1,t-1-o),l=t*(o-c-1)+s,u=t*(o+c)+s,d;if(n){let y=n[l-i-1],W=n[l+i],w=n[u-i-1],C=n[u+i];d=y+C-W-w}else d=(2*i+1)*(2*c+1);let f=r[l-i-1],b=r[l+i],x=r[u-i-1],m=r[u+i],p=f+m-b-x;a.raw[o*t+s]=p/d}return a}function T(a){let e=a>>0&255,t=a>>8&255,r=a>>16&255,n=e.toString(16),o=t.toString(16),s=r.toString(16);return n=n.length===2?n:"0"+n,o=o.length===2?o:"0"+o,s=s.length===2?s:"0"+s,"#"+n+o+s}function M(a){if(a[0]==="#"){if(a.length===4)return+("0xff"+a[3]+a[3]+a[2]+a[2]+a[1]+a[1]);if(a.length===7)return+("0xff"+a[5]+a[6]+a[3]+a[4]+a[1]+a[2]);if(a.length===9)return+("0x"+a[7]+a[8]+a[5]+a[6]+a[3]+a[4]+a[1]+a[2])}return h("wrong color format",a),0}function L(a,e){return g(this,null,function*(){let t=yield fetch(a,e);if(!t.ok)throw new Error("error:"+a+" - "+t.statusText);return t.json()})}function Q(a,e,t){let r=a>>0&255,n=a>>8&255,o=a>>16&255,s=a>>>24,i=e>>0&255,c=e>>8&255,l=e>>16&255,u=e>>>24,d=r+t*(i-r),f=n+t*(c-n),b=o+t*(l-o),x=s+t*(u-s);return d|f<<8|b<<16|x<<24}function ge(a,e,t){let r=[];for(let n=0;n<t;++n)r.push(n*(e-a)/(t-1)+a);return r}var he=!1;function Ye(a){console.log(a?"Logging on":"Logging off"),he=a}function h(...a){he&&console.log(...a)}function pe(a){return a[0]==="#"&&a.length===4?"#"+a[1]+a[1]+a[2]+a[2]+a[3]+a[3]:a}function V(a,{x:e,y:t,z:r}){return a.replace("{x}",`${e}`).replace("{y}",`${t}`).replace("{z}",`${r}`)}function X({x:a,y:e,z:t}){return`${t}-${a}-${e}`}var je="A".charCodeAt(0);var E=class{constructor(){this.qtree={nodes:null};this.qtreedepth=0}load(e,t){return g(this,null,function*(){try{let r=yield L(e,t);this.qtree=be(r,{pos:0})}catch(r){throw new Error(`Failed to load QTree: ${r.message}`)}this.qtreedepth=ye(this.qtree)})}check(e){let t=e.z-this.qtreedepth,r=t>=0,n=r?{x:e.x>>t,y:e.y>>t,z:this.qtreedepth}:F({},e);return We(this.qtree,n,r)}};function be(a,e){let t=a.charCodeAt(e.pos)-je;e.pos++;let r=[1,2,4,8].map(n=>t&n?be(a,e):null);return{nodes:r.some(n=>n)?r:null}}function ye(a){return a!=null&&a.nodes?1+Math.max(...a.nodes.map(ye)):0}function We(a,e,t){return a===null?"land":t&&!e.z?"mixed":a.nodes===null?"sea":e.z?(e.z--,We(a.nodes[(e.y>>e.z&1)<<1|e.x>>e.z&1],e,t)):"mixed"}var U=class{constructor({datasetName:e,instance:t,instanced:r,meta:n,wxapi:o}){if(!o.datasetsMetas.allDatasetsList.includes(e))throw new Error(`Dataset ${e} not found`);this.datasetName=e,this.instanced=r,this.instance=t,this.meta=n,this.wxapi=o}getValidTime(e=Date()){let t=this.getTimes();if(typeof e=="number"){if(e<=0)return t[0];if(e<t.length)return t[e]}let r=new Date(e).getTime(),n=t.find(o=>new Date(o).getTime()>=r);if(isNaN(r)||!n){let o=t.indexOf(e);return o===-1?t[t.length-1]:t[o]}return n}getTimes(){return this.instanced||this.meta.times}getVariables(){return this.meta.variables}getVariableMeta(e){return this.meta.variablesMeta[e]}getMaxZoom(){return this.meta.maxZoom}getBoundaries180(){var r;let e=(r=this.meta.boundaries)==null?void 0:r.boundaries180;if((e==null?void 0:e.length)!==1)return;let t=e[0];return[t.west,t.south,t.east,t.north]}getBoundaries(){return this.meta.boundaries}createURI(e,t,r="png"){if(!this.checkVariableValid(e))throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);let n=this.getValidTime(t),o=this.instanced?n:this.instance;return`${this.wxapi.dataServerURL+this.datasetName}/${o}/${e}/${n}/{z}/{x}/{y}.${r}`}checkVariableValid(e){return this.getVariableMeta(e)!==void 0}checkCombineVariableIfVector(e){let t=this.getVariableMeta(e);if(!t)throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);return t.vector||[e]}checkDatasetOutdated(){return g(this,null,function*(){return yield this.wxapi.initDone,(yield this.getDatasetInstance())===this.instance})}getDatasetInstance(){return g(this,null,function*(){let e=yield this.getDatasetInstances();return e[e.length-1]})}getDatasetInstances(){return g(this,null,function*(){try{let e=yield L(this.wxapi.dataServerURL+this.datasetName+"/instances.json",this.wxapi.requestInit);if(e.length===0)throw new Error(`No instances found for dataset ${this.datasetName}`);return e}catch(e){throw new Error(`getting dataset instances failure message: ${e.message} datasetName: ${this.datasetName}`)}})}};var ee=class{constructor({dataServerURL:e,maskURL:t="auto",qtreeURL:r="auto",requestInit:n,colorStyles:o,units:s,colorSchemes:i}){this.datasetsMetas={allDatasetsList:[]};this.qtree=new E;this.loadMaskFunc=()=>Promise.reject(new Error("maskURL not defined"));if(fe({colorStyles:o,units:s,colorSchemes:i}),this.dataServerURL=e,this.requestInit=n,r=r==="auto"?e+"seamask.qtree":r,t!=="none"){let c=_(K);this.maskURL=t=t==="auto"?e+"mask/":t,this.loadMaskFunc=l=>c(V(t,l),n)}this.initDone=Promise.all([L(e+"datasetsmeta.json",n),r!=="none"?this.qtree.load(r,n):Promise.resolve()]).then(([c,l])=>{c.allDatasetsList||(c.allDatasetsList=Object.keys(c)),this.datasetsMetas=c})}getDatasetShortMeta(e){if(e!=="allDatasetsList")return this.datasetsMetas[e]}getDatasetInatance(e){var t;return(t=this.getDatasetShortMeta(e))==null?void 0:t.instance}getDatasetVariables(e){return g(this,null,function*(){var t;return yield this.initDone,(t=this.datasetsMetas[e])==null?void 0:t.variables})}createDatasetManager(e){return g(this,null,function*(){yield this.initDone;let t=this.getDatasetShortMeta(e),r=t==null?void 0:t.instance;if(!r)throw new Error("Dataset/instance not found:"+e);let n=t.instanced,o=yield L(this.dataServerURL+e+"/"+r+"/meta.json",this.requestInit);return new U({datasetName:e,instanced:n,instance:r,meta:o,wxapi:this})})}createAllDatasetsManagers(){return g(this,null,function*(){return yield this.initDone,Promise.allSettled(this.datasetsMetas.allDatasetsList.map(t=>this.createDatasetManager(t)))})}filterDatasetsByVariableName(e){return g(this,null,function*(){return yield this.initDone,this.datasetsMetas.allDatasetsList.filter(t=>{var r,n,o;return(o=(n=(r=this.datasetsMetas[t])==null?void 0:r.variables)==null?void 0:n.includes)==null?void 0:o.call(n,e)})})}getAllDatasetsNames(){return g(this,null,function*(){return yield this.initDone,this.datasetsMetas.allDatasetsList})}};function Ge(a,e,t){return a>t?t:a<e?e:a}var N=class{constructor(e,t,[r,n],o){let s=n-r;this.levelIndex=new Uint32Array(65536),this.colorsI=new Uint32Array(65536);let i=[];this.DataToStyle=Z(t,e.units,e.extraUnits),this.DataToStyle.trivial&&(e.units=t),o&&(this.DataToKnots=Z(t,"knot"));let c=Z(e.units,t,e.extraUnits),l=m=>~~(65535*Ge((c(m)-r)/(n-r),0,1));if(Array.isArray(e.colorMap)){e.colorMap.sort((m,p)=>m[0]<p[0]?-1:m[0]>p[0]?1:0);for(let[m]of e.colorMap)i.push(l(m))}else{if(e.levels||(e.levels=ge(this.DataToStyle(r),this.DataToStyle(n),10)),e.levels.sort((m,p)=>m<p?-1:m>p?1:0),!e.colors){let m=z();e.colorScheme&&e.colorScheme in m?e.colors=m[e.colorScheme]:e.colors=m.wb}for(let m of e.levels)i.push(l(m))}let u=65536,d=Se(u,e);this.ticks=d.ticks;let f=d.ticks[0].data,x=d.ticks[d.ticks.length-1].data-f;for(let m=0;m<65536;++m){let p=s*m/65535+r,y=this.DataToStyle(p),W=Math.round((u-1)*(y-f)/x);W<=0?this.colorsI[m]=e.showBelowMin?d.colors[0]:0:W>=u?this.colorsI[m]=e.showAboveMax?d.colors[u-1]:0:this.colorsI[m]=d.colors[W]}this.colorsI[0]=0;for(let m=0;m<i[0];++m)this.levelIndex[m]=0;for(let m=0;m<i.length-1;m++)for(let p=i[m];p<i[m+1]+1;++p)this.levelIndex[p]=m;for(let m=i[i.length-1];m<65536;++m)this.levelIndex[m]=i.length-1}};function we(a){var t;if(a!==0&&-.1<a&&a<.1)return a.toExponential(2);let e=a.toString();return((t=e.split(".")[1])==null?void 0:t.length)>2?a.toFixed(2):e}function Se(a,e){let t={size:a,showBelowMin:e.showBelowMin,showAboveMax:e.showAboveMax,units:e.units,colors:new Uint32Array(a),ticks:[]},{colorMap:r,levels:n,colors:o}=e,s=e.fill!=="solid";if(r){let f=r[0][0],b=r[r.length-1][0]-f;for(let[x,m]of r){let p=~~((x-f)/b*(a-1)),y={data:x,dataString:we(x),color:m,pos:p};t.ticks.push(y)}for(let x=0;x<r.length-1;x++){let m=t.ticks[x].pos,p=t.ticks[x+1].pos,y=M(r[x][1]),W=s?M(r[x+1][1]):0;for(let w=m;w<p;++w)t.colors[w]=s?Q(y,W,(w-m)/(p-m)):y}return t.colors[a-1]=M(r[r.length-1][1]),t}if(!o||!n)return t;let i=0,c=0,l=-1;for(let f=0;f<a;++f){let b=f*(o.length-1)/a;l!==~~b&&(l=~~b,i=M(o[l]),c=o.length>l+1?M(o[l+1]):i),t.colors[f]=s?Q(i,c,b-l):i}t.colors[a-1]=M(o[o.length-1]);let u=n[0],d=(a-1)/(n[n.length-1]-u);for(let f of n){let b=~~((f-u)*d),x={data:f,dataString:we(f),color:T(t.colors[b]),pos:b};t.ticks.push(x)}return t}var He=2*Math.PI*6378137/256,B=2*Math.PI*6378137/2;function ze(a,e){let t=a/B*180,r=e/B*180;return r=180/Math.PI*(2*Math.atan(Math.exp(r*Math.PI/180))-Math.PI/2),[r,t]}function Ke(a,e,t){let r=Je(t),n=a*r-B,o=e*r-B;return[n,o]}function Je(a){return He/Math.pow(2,a)}function te(a,e,t){let[r,n]=ze(...Ke(a,e,t));return[n,-r]}function De(a,e){return[a*256,e*256]}function re(a,e,t){let r=((e-a)%360+540)%360-180;return(a+r*t+360)%360}function Qe(a,e,t,r,n,o,s,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 0:return 0;case 1:return a;case 2:return e;case 3:t=a,r=e;break;case 4:return t;case 5:e=a,r=t;break;case 6:r=e+t>>1,a=r;break;case 7:r=e+t>>1;break;case 8:return r;case 9:e=a+r>>1,t=e;break;case 10:a=e,t=r;break;case 11:t=a+r>>1;break;case 12:a=t,e=r;break;case 13:e=a+r>>1;break;case 14:a=e+t>>1;break}a=s+i*a,e=s+i*e,t=s+i*t,r=s+i*r;let l=re(a,e,n),u=re(t,r,n);return(re(l,u,o)-s)/i||1}function et(a,e,t,r,n,o,s,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 7:return n+o<1?n*(e-a)+o*(t-a)+a:0;case 14:return n+o<1?0:n*(r-t)+o*(r-e)+e+t-r;case 11:return o<n?(1-n)*(a-e)+o*(r-e)+e:0;case 13:return o<n?0:(1-n)*(t-r)+o*(t-a)+a+r-t;case 15:return n+o<1?n*(e-a)+o*(t-a)+a:n*(r-t)+o*(r-e)+e+t-r;default:return 0}}function Te(a,e,t){if(!t)return e;let r=.9999999/Math.pow(2,t.z),n=t.x*256*r,o=t.y*256*r,{raw:s,dmin:i,dmax:c,dmul:l}=e,u={raw:new Uint16Array(258*258),dmin:i,dmax:c,dmul:l},{raw:d}=u;for(let f=-1,b=0;f<=256;f++){let x=o+f*r,m=Math.floor(x),p=x-m;for(let y=-1;y<=256;y++,b++){let W=n+y*r,w=Math.floor(W),C=W-w,S=w+1+(m+1)*258,D=s[S],v=s[S+1],P=s[S+258],k=s[S+258+1];d[b]=a(D,v,P,k,C,p,i,l)}}return u}function Ce(a,e){return Te(et,a,e)}function Me(a,e){return Te(Qe,a,e)}function ve(a,e,t){let r=t==="sea";for(let n=3,o=0;o<256;o++)for(let s=0,i=(o+1)*258+1;s<256;s++,i++,n+=4)r===!e.data[n]&&(a.raw[i]=0);return a}function Le(a){let[e,t]=De(a.x,a.y),[r,n]=te(e,t,a.z),[o,s]=te(e+256,t+256,a.z);return{west:r,north:n,east:o,south:s}}function Ie(a,e){let t=a.z-e;if(t<=0)return{upCoords:a};let r={x:a.x>>>t,y:a.y>>>t,z:e},n={x:a.x&(1<<t)-1,y:a.y&(1<<t)-1,z:t};return{upCoords:r,subCoords:n}}var $=class{constructor(e){this.loadDataFunc=_(J);this.layer=e}load(e,t){return g(this,null,function*(){let r=yield this.cacheLoad(e,this.layer.tilesURIs,t);if(!r)return null;let{rawdata:n,subCoords:o,tileType:s}=r,{units:i}=this.layer.currentMeta,c=i==="degree"?Me:Ce,l=d=>c(xe(d,this.layer.style.blurRadius),o),u=n.map(l);return this._vectorMagnitudesPrepare(u),yield this._applyMask(u,e,s,!o&&n.length===1),{data:u,slines:this._createStreamLines(u)}})}cacheLoad(e,t,r){return g(this,null,function*(){if(!this._checkInsideBoundaries(e))return null;let n=this._checkTypeAndMask(e);if(!n)return null;let{upCoords:o,subCoords:s}=Ie(e,this.layer.wxdatasetManager.getMaxZoom()),i=t.map(u=>V(u,o)),c=Object.assign({},this.layer.wxdatasetManager.wxapi.requestInit,{signal:r==null?void 0:r.signal});return{rawdata:yield Promise.all(i.map(u=>this.loadDataFunc(u,c))),subCoords:s,tileType:n}})}clearCache(){this.loadDataFunc=_(J)}_applyMask(e,t,r,n){return g(this,null,function*(){let{style:o}=this.layer;if((o.mask==="land"||o.mask==="sea")&&r==="mixed"){if(n){let{raw:i,dmin:c,dmax:l,dmul:u}=e[0];e[0]={raw:new Uint16Array(i),dmin:c,dmax:l,dmul:u}}let s;try{s=yield this.layer.wxdatasetManager.wxapi.loadMaskFunc(t)}catch(i){o.mask=void 0,h("Can't load Mask. Masking is Turned OFF");return}ve(e[0],s,o.mask)}})}_vectorMagnitudesPrepare(e){if(e.length===1)return;e.unshift({raw:new Uint16Array(258*258),dmin:0,dmax:0,dmul:0});let[t,r,n]=e;t.dmax=1.42*Math.max(-r.dmin,r.dmax,-n.dmin,n.dmax),t.dmul=(t.dmax-t.dmin)/65535;for(let o=0;o<258*258;++o){if(!r.raw[o]||!n.raw[o])continue;let s=r.dmin+r.dmul*r.raw[o],i=n.dmin+n.dmul*n.raw[o];t.raw[o]=Math.sqrt(i*i+s*s)/t.dmul}}_checkTypeAndMask(e){let{mask:t}=this.layer.style;var r="mixed";if(!((t==="land"||t==="sea")&&(r=this.layer.wxdatasetManager.wxapi.qtree.check(e),t===r)))return r}_checkInsideBoundaries(e){let t=this.layer.wxdatasetManager.getBoundaries();if(t!=null&&t.boundaries180){let r=Le(e),n=o=>!(r.west>o.east||o.west>r.east||r.south>o.north||o.south>r.north);if(!t.boundaries180.some(n))return!1}return!0}_createStreamLines(e){if(e.length!==3)return[];let{style:t}=this.layer;if(t.streamLineColor==="none")return[];let r=[],[n,o,s]=e,i=(t.streamLineSpeedFactor||1)/n.dmax,c=t.addDegrees?.017453292519943*t.addDegrees:0,l=t.streamLineGridStep||64,u=t.streamLineSteps||300;for(let d=0;d<=256;d+=l)for(let f=0;f<=256;f+=l){if(!n.raw[1+f+(1+d)*258])continue;let b=[],x=f,m=d,p=-1,y=0,W=0;for(let S=0;S<=u&&x>=0&&x<=256&&m>=0&&m<=256;S++){S%(u/10)||b.push({x:~~x,y:~~m});let D=~~x+1+(~~m+1)*258;if(D!==p){if(!n.raw[D])break;p=D;let v=n.dmin+n.raw[D]*n.dmul,P=o.dmin+o.raw[D]*o.dmul,k=s.dmin+s.raw[D]*s.dmul,R=Math.atan2(P,k)+c;y=i*v*Math.sin(R),W=i*v*Math.cos(R)}x+=y,m-=W}let w=f,C=d;p=-1;for(let S=1;S<=u&&w>=0&&w<=256&&C>=0&&C<=256;S++){S%(u/10)||b.unshift({x:~~w,y:~~C});let D=~~w+1+(~~C+1)*258;if(D!==p){if(!n.raw[D])break;p=D;let v=n.dmin+n.raw[D]*n.dmul,P=o.dmin+o.raw[D]*o.dmul,k=s.dmin+s.raw[D]*s.dmul,R=Math.atan2(P,k)+c;y=i*v*Math.sin(R),W=i*v*Math.cos(R)}w-=y,C+=W}b.length>2&&r.push(b)}return r}};var q=class{constructor(e){this.layer=e}paint({data:e,ctxFill:t,ctxText:r,ctxStreamLines:n}){let{layer:o}=this,{units:s}=o.currentMeta,i=new ImageData(256,256),c=new Uint32Array(i.data.buffer);t.clearRect(0,0,256,256),r.clearRect(0,0,256,256),n.clearRect(0,0,256,256),tt(e.data[0],c,o);let l=rt(c,e.data[0],o);t.putImageData(i,0,0),at(l,r,o),nt(e.data,r,o),ot(e.data[0],r,s,o),st(e,r,o)}imprintVectorAnimationLinesStep({data:e,ctxFill:t,ctxStreamLines:r},n){let{layer:o}=this;r.clearRect(0,0,256,256),r.drawImage(t.canvas,0,0),!(e.slines.length===0||o.style.streamLineStatic||o.style.streamLineColor==="none")&&it(e,r,o,n)}};function tt(a,e,{CLUT:t,style:r}){let{raw:n}=a,{colorsI:o}=t;if(r.fill!=="none")for(let s=0,i=0,c=259;s<256;++s,c+=2)for(let l=0;l<256;++l,++i,++c)e[i]=o[n[c]];else e.fill(0)}function rt(a,e,{CLUT:t,style:r}){let{raw:n}=e,{levelIndex:o,colorsI:s}=t,i=[];if(r.isolineColor!=="none"){let c=r.isolineColor[0]==="#"?M(r.isolineColor):0;for(let l=0,u=0;l<256;l+=1)for(let d=0;d<256;d+=1){let f=(l+1)*258+(d+1),b=n[f],x=n[f+1],m=n[f+258];if(!b||!x||!m)continue;let p=o[b],y=o[x],W=o[m];if(p!==y||p!==W){let w=Math.max(p,y,W),C=Math.max(b,x,m),S=l*256+d;switch(r.isolineColor){case"inverted":a[S]=~s[C]|4278190080;break;case"fill":a[S]=s[C]|4278190080;break;default:a[S]=c;break}r.isolineText&&!(++u%255)&&d>20&&d<235&&l>20&&l<235&&i.push({x:d,y:l,d:b,dr:x,db:m,mli:w})}}}return i}function at(a,e,{CLUT:t}){if(a.length){e.font="1.1em Sans-serif",e.lineWidth=2,e.strokeStyle="white",e.fillStyle="black",e.textAlign="center",e.textBaseline="middle";for(let{x:r,y:n,d:o,dr:s,db:i,mli:c}of a){let l=t.ticks[c].dataString,u=Math.atan2(o-s,i-o);e.save(),e.translate(r,n),e.rotate(u<-1.57||u>1.57?u+3.14:u),e.strokeText(l,0,0),e.fillText(l,0,0),e.restore()}}}function nt(a,e,{CLUT:t,style:r}){if(!t.DataToKnots||r.vectorColor==="none"||r.vectorType==="none")return;if(a.length!==3)throw new Error("data.length !== 3");let[n,o,s]=a;switch(r.vectorType){case"barbs":e.font="40px barbs";break;case"arrows":e.font="50px arrows";break;default:e.font=r.vectorType}e.textAlign="center",e.textBaseline="middle",e.fillStyle=r.vectorColor;let i=r.addDegrees?.017453292519943*r.addDegrees:0,c=32;for(let l=c/2;l<256;l+=c)for(let u=c/2;u<256;u+=c){let d=u+1+(l+1)*258;if(!n.raw[d])continue;let f=Math.atan2(o.dmin+o.raw[d]*o.dmul,s.dmin+s.raw[d]*s.dmul),b=n.dmin+n.raw[d]*n.dmul,x=r.vectorType!=="barbs"?r.vectorFactor*.2:.2,m=Math.min(t.DataToKnots(b)*x,25)+65,p=String.fromCharCode(m);switch(r.vectorColor){case"inverted":e.fillStyle=T(~t.colorsI[n.raw[d]]);break;case"fill":e.fillStyle=T(t.colorsI[n.raw[d]]);break}e.save(),e.translate(u,l),e.rotate(f+i),e.fillText(p,0,0),e.restore()}}function ot(a,e,t,{CLUT:r,style:n}){if(t!=="degree")return;let o=.017453292519943*n.addDegrees;e.font="50px arrows",e.textAlign="center",e.textBaseline="middle",e.fillStyle=n.vectorColor;let s="L",i=32;for(let c=i/2;c<256;c+=i)for(let l=i/2;l<256;l+=i){let u=l+1+(c+1)*258;if(!a.raw[u])continue;let f=(a.dmin+a.raw[u]*a.dmul+180)*.01745329251;switch(n.vectorColor){case"inverted":e.fillStyle=T(~r.colorsI[a.raw[u]]);break;case"fill":e.fillStyle=T(r.colorsI[a.raw[u]]);break}e.save(),e.translate(l,c),e.rotate(f+o),e.fillText(s,0,0),e.restore()}}function st(a,e,{CLUT:t,style:r}){let{data:n,slines:o}=a;if(!o.length||!r.streamLineStatic||r.streamLineColor==="none")return;let s=n[0];e.lineWidth=1,e.strokeStyle=r.streamLineColor;for(let i=o.length;i--;){let c=o[i];for(let l=0;l<c.length-1;++l){let u=c[l],d=c[l+1],f=u.x+1+(u.y+1)*258;switch(r.streamLineColor){case"inverted":e.strokeStyle=T(~t.colorsI[s.raw[f]]);break;case"fill":e.strokeStyle=T(t.colorsI[s.raw[f]]);break}e.beginPath(),e.moveTo(u.x,u.y),e.lineTo(d.x,d.y),e.stroke()}}}function it(a,e,{CLUT:t,style:r},n){let{data:o,slines:s}=a,i=o[0],c=r.streamLineColor.substring(0,7);n=n>>5;for(let l=0;l<s.length;++l){let u=s[l],d=u.length-1,f=(n+(1+u[0].x)*(1+u[0].y))%30;for(let b=0;b<d;++b){let x=u[b],m=u[b+1],p=1-(f-b)/d;(p<0||p>1)&&(p=0);let y=(~~(p*255)).toString(16).padStart(2,"0"),W=1+~~((1.2-p)*5);e.lineWidth=W;let w=x.x+1+(x.y+1)*258;switch(r.streamLineColor){case"inverted":c=T(~t.colorsI[i.raw[w]]);break;case"fill":c=T(t.colorsI[i.raw[w]]);break}e.strokeStyle=c+y,e.beginPath(),e.moveTo(x.x,x.y),e.lineTo(m.x,m.y),e.stroke()}}}var Y=class{constructor({time:e,variables:t,wxdatasetManager:r,ext:n="png",wxstyleName:o="base"}){this.tilesCache=new Map;this.painter=new q(this);this.loader=new $(this);if(!(t!=null&&t.length)||t.length>2)throw new Error(`WxTileSource ${r.datasetName}: only 1 or 2 variables are supported but ${t.length} were given`);t.forEach(s=>{if(!r.checkVariableValid(s))throw new Error(`WxTileSource ${r.datasetName}: variable ${s} is not valid`)}),this.variables=t,this.wxdatasetManager=r,this.ext=n,this.currentMeta=this._getCurrentMeta(),[this.tilesURIs,this.time]=this._createURLsAndTime(e),[this.style,this.CLUT]=this._createCurrentStyleObject(A()[o]),h(`WxTileSource created ${r.datasetName}, ${t.join(", ")}, ${o}`)}get nonanimatable(){return this.variables.length<2||this.style.streamLineStatic||this.style.streamLineColor==="none"}getTime(){return this.time}clearCache(){this.tilesCache.clear(),this.loader.clearCache()}getCurrentStyleObjectCopy(){return Object.assign({},this.style)}updateCurrentStyleObject(e){[this.style,this.CLUT]=this._createCurrentStyleObject(e)}getTileData(e,t){let r=this.tilesCache.get(X(e));if(!r)return;let n=this._getPixelInfo(t,r.data.data);if(!n)return;let{raw:o,data:s}=n,i=o.map(u=>this.CLUT.colorsI[u]),c=i.map(T),l=s.map(u=>this.CLUT.DataToStyle(u));return{data:s,raw:o,rgba:i,hexColor:c,inStyleUnits:l,tilePoint:t,styleUnits:this.style.units,dataUnits:this.currentMeta.units}}setURLsAndTime(e){[this.tilesURIs,this.time]=this._createURLsAndTime(e)}loadTile(e,t){return g(this,null,function*(){return this._loadCacheDrawTile(e,this.tilesCache,t)})}preloadTime(e,t,r){return g(this,null,function*(){let[n]=this._createURLsAndTime(e);yield Promise.allSettled(t.map(o=>this.loader.cacheLoad(o,n,r)))})}reloadTiles(e,t){return g(this,null,function*(){var n;let r=new Map;yield Promise.allSettled(e.map(o=>this._loadCacheDrawTile(o,r,t))),(n=t==null?void 0:t.signal)!=null&&n.aborted||(this.tilesCache=r)})}_loadCacheDrawTile(e,t,r){return g(this,null,function*(){let n=t.get(X(e));if(n)return n;let o=null;try{o=yield this.loader.load(e,r)}catch(u){throw{status:404}}if(!o)throw{status:404};let s=I(256,256),i=s,c=this.variables.length===2?I(256,256):s,l={ctxFill:s,ctxText:i,ctxStreamLines:c,data:o};return this.painter.paint(l),t.set(X(e),l),l})}_createCurrentStyleObject(e){let t=Object.assign(this.getCurrentStyleObjectCopy(),e);t.streamLineColor=pe(t.streamLineColor);let r=this._prepareCLUT(t);return[t,r]}_getCurrentMeta(){let e=this.variables.map(s=>{let i=this.wxdatasetManager.getVariableMeta(s);if(!i)throw new Error(`WxTileSource ${this.wxdatasetManager.datasetName}: variable ${s} is not valid`);return i}),{min:t,max:r,units:n,vector:o}=e[0];return this.variables.length>1&&(t=0,r=1.42*Math.max(-e[0].min,e[0].max,-e[1].min,e[1].max)),{min:t,max:r,units:n,vector:o}}_getPixelInfo({x:e,y:t},r){var o,s;let n=(t+1)*258+(e+1);if(!!((s=(o=r==null?void 0:r[0])==null?void 0:o.raw)!=null&&s[n]))return{raw:r.map(i=>i.raw[n]),data:r.map(i=>i.raw[n]*i.dmul+i.dmin)}}_prepareCLUT(e){let{min:t,max:r,units:n}=this.currentMeta;return new N(e,n,[t,r],this.variables.length===2)}_createURLsAndTime(e){let t=this.wxdatasetManager.getValidTime(e);return[this.variables.map(n=>this.wxdatasetManager.createURI(n,t,this.ext)),t]}};var Re=Xe(ke()),j=class extends Re.default.GridLayer{};var G=class extends j{constructor(t,r){super(r);this.animation=!1;this.animationSeed=0;this.layer=new Y(t)}get wxdatasetManager(){return this.layer.wxdatasetManager}getMetadata(){return h(`WxTileSource getMetadata (${this.layer.wxdatasetManager.datasetName})`),F({},this.layer.currentMeta)}getVariables(){return h(`WxTileSource getVariables (${this.layer.wxdatasetManager.datasetName})`),[...this.layer.variables]}clearCache(){h(`WxTileSource clearCache (${this.layer.wxdatasetManager.datasetName})`),this.layer.clearCache()}getCurrentStyleObjectCopy(){return h(`WxTileSource getCurrentStyleObjectCopy (${this.layer.wxdatasetManager.datasetName})`),this.layer.getCurrentStyleObjectCopy()}getTime(){return h(`WxTileSource getTime (${this.layer.wxdatasetManager.datasetName})`),this.layer.getTime()}setTime(t,r){return g(this,null,function*(){var o;h(`WxTileSource setTime (${this.layer.wxdatasetManager.datasetName}) `,{time:t});let n=this.getTime();return this.layer.setURLsAndTime(t),yield this._reloadVisible(r),(o=r==null?void 0:r.signal)!=null&&o.aborted&&this.layer.setURLsAndTime(n),this.getTime()})}preloadTime(t,r){return g(this,null,function*(){return h(`WxTileSource preloadTime (${this.layer.wxdatasetManager.datasetName}) `,{time:t}),this.layer.preloadTime(t,this.coveringTiles(),r)})}startAnimation(){if(this.animation){h(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName}) already started`);return}if(this.layer.nonanimatable){h(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName}) nonanimatable`);return}h(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName})`),this.animation=!0;let t=r=>g(this,null,function*(){if(h(`WxTileSource animationStep (${this.layer.wxdatasetManager.datasetName})`),!this.animation||this.layer.nonanimatable){this.animation=!1;return}this.animationSeed=r,yield this._redrawTiles(),requestAnimationFrame(t)});requestAnimationFrame(t)}stopAnimation(){return g(this,null,function*(){return h(`WxTileSource stopAnimation (${this.layer.wxdatasetManager.datasetName})`),this.animation=!1,this._redrawTiles()})}setCoarseLevel(t=2){return g(this,null,function*(){return h(`WxTileSource setCoarseLevel (${this.layer.wxdatasetManager.datasetName})`,{level:t}),this.oldMaxZoom=this.layer.wxdatasetManager.getMaxZoom(),this.layer.wxdatasetManager.meta.maxZoom=Math.max(this.oldMaxZoom-t,1),this._reloadVisible()})}unsetCoarseLevel(){return g(this,null,function*(){if(h(`WxTileSource unsetCoarseLevel (${this.layer.wxdatasetManager.datasetName})`),this.oldMaxZoom)return this.layer.wxdatasetManager.meta.maxZoom=this.oldMaxZoom,this._reloadVisible()})}setStyleByName(t,r=!0){return g(this,null,function*(){return h(`WxTileSource setStyleByName (${this.layer.wxdatasetManager.datasetName})`),this.updateCurrentStyleObject(A()[t],r)})}updateCurrentStyleObject(t,r=!0,n){return g(this,null,function*(){if(h(`WxTileSource updateCurrentStyleObject (${this.layer.wxdatasetManager.datasetName})`,{style:t}),this.layer.updateCurrentStyleObject(t),this.startAnimation(),r)return this._reloadVisible(n)})}_redrawTiles(){return this.redrawRequested?this.redrawRequested:(this.redrawRequested=new Promise(t=>{requestAnimationFrame(()=>{h(`WxTileSource _redrawTiles (${this.layer.wxdatasetManager.datasetName})`),this.update(),t(),this.redrawRequested=void 0})}),this.redrawRequested)}_reloadVisible(t){return g(this,null,function*(){})}coveringTiles(){return[]}update(){}};var ae=class{constructor(e,t,r){this.coords=e;this.ctx=t;this.raster_data=r;this.draw(r.ctxFill.canvas)}draw(e){this.ctx.clearRect(0,0,256,256),this.ctx.drawImage(e,0,0)}},ne=class extends G{constructor(e,t){super(e,t),h("WxTileSource constructor: ",e)}getLayerInfoAtLatLon(e,t){if(h(`WxTileSource getLayerInfoAtLatLon (${this.layer.wxdatasetManager.datasetName})`,e),!this._map)return;let r=this._map.getZoom(),n=this._map.project(e,r),o=n.divideBy(256).floor(),s=n.subtract(o.multiplyBy(256)).floor();return this.layer.getTileData({x:o.x,y:o.y,z:r},s)}_reloadVisible(e){return g(this,null,function*(){var t;if(h(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName})`),yield this.layer.reloadTiles(this.coveringTiles(),e),(t=e==null?void 0:e.signal)!=null&&t.aborted){h(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName}) aborted`);return}return yield Promise.allSettled(this._ForEachWxTile(r=>g(this,null,function*(){r.raster_data=yield this.layer.loadTile(r.coords)}),"_reloadVisible")),this._redrawTiles()})}update(){this._ForEachWxTile(e=>{this.animation?(this.layer.painter.imprintVectorAnimationLinesStep(e.raster_data,this.animationSeed),e.draw(e.raster_data.ctxStreamLines.canvas)):e.draw(e.raster_data.ctxFill.canvas)},"_redrawTiles")}coveringTiles(){var t;h(`WxTileSource coveringTiles (${this.layer.wxdatasetManager.datasetName})`);let e=[];for(let r in this._tiles){let n=(t=this._tiles[r].el)==null?void 0:t.wxtile;n&&e.push(n.coords)}return e}_ForEachWxTile(e,t){var n;h(`WxTileSource _ForEachWxTile (${this.layer.wxdatasetManager.datasetName}) func=${t}`);let r=[];for(let o in this._tiles){let s=(n=this._tiles[o].el)==null?void 0:n.wxtile;s&&r.push(e(s))}return r}createTile(e,t){let r=I(256,256),n=r.canvas;return this.layer.loadTile(e).then(o=>{n.wxtile=new ae({x:e.x,y:e.y,z:e.z},r,o),t()}).catch(o=>{t(o)}),n}};export{h as WXLOG,ee as WxAPI,Se as WxCreateLegend,U as WxDataSetManager,z as WxGetColorSchemes,A as WxGetColorStyles,ne as WxTileSource,Ye as WxTilesLogging};
|
|
1
|
+
var _e=Object.create;var K=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames,oe=Object.getOwnPropertySymbols,Ne=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var ie=(a,e,t)=>e in a?K(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,X=(a,e)=>{for(var t in e||(e={}))le.call(e,t)&&ie(a,t,e[t]);if(oe)for(var t of oe(e))Ze.call(e,t)&&ie(a,t,e[t]);return a};var Fe=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var Ve=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Oe(e))!le.call(a,n)&&n!==t&&K(a,n,{get:()=>e[n],enumerable:!(r=Ue(e,n))||r.enumerable});return a};var Be=(a,e,t)=>(t=a!=null?_e(Ne(a)):{},Ve(e||!a||!a.__esModule?K(t,"default",{value:a,enumerable:!0}):t,a));var y=(a,e,t)=>new Promise((r,n)=>{var s=c=>{try{i(t.next(c))}catch(l){n(l)}},o=c=>{try{i(t.throw(c))}catch(l){n(l)}},i=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,o);i((t=t.apply(a,e)).next())});var Re=Fe((rr,ke)=>{ke.exports=window.L});var ce={comment1:["'degC': ['K', 1, 273.15] -> degC = K * 1 + 273.15",0],comment2:["'hPa': ['Pa', 1000]' -> hPa = Pa * 1000 + 0 (0 - could be ommited)",0],K:["K",1],kelvin:["K",1],F:["K",.5555555555,255.372222222],C:["K",1,273.15],degC:["K",1,273.15],"kg/m^2/s":["kg/m^2/s",1],"Kg/m^2/s":["kg/m^2/s",1],"Kg m**-2 s**-1":["kg/m^2/s",1],"Kg m^-2 s^-1":["kg/m^2/s",1],"Kg m^{-2} s^-1":["kg/m^2/s",1],"mm/h":["kg/m^2/s",.00027777777],"mm/hr":["kg/m^2/s",.00027777777],"W/m^2":["W/m^2",1],"W m^-2":["W/m^2",1],"W m^{-2}":["W/m^2",1],"W/m**2":["W/m^2",1],"W m**-2":["W/m^2",1],"m/s":["m/s",1],"m s**-1":["m/s",1],"m s^-1":["m/s",1],"m.s^{-1}":["m/s",1],knot:["m/s",.514444],knots:["m/s",.514444],"km/h":["m/s",.27777777777],"km h^-1":["m/s",.27777777777],"km h**-1":["m/s",.27777777777],mph:["m/s",.44704],"miles/h":["m/s",.44704],s:["s",1],sec:["s",1],h:["s",3600],min:["s",60],m:["m",1],cm:["m",.01],km:["m",1e3],mile:["m",1609.344],miles:["m",1609.344],inch:["m",.0254],Pa:["Pa",1],hPa:["Pa",100],degree:["degree",1],radian:["degree",57.3],"mg/m^3":["mg/m^3",1],"mg m^-3":["mg/m^3",1],"mg.m^-3":["mg/m^3",1],"%":["%",1],"(0 - 1)":["%",100]};var ue={none:["#00000000","#00000000"],divergingbluered:["#2166acff","#92c5deff","#f7f7f7ff","#f4a582ff","#b2182bff"],rainbow:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbowzerro:["#ff000000","#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbow2:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff","#ff0000ff"],bluebird:["#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bluebirdzerro:["#0000ff00","#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bw:["#000000ff","#ffffffff"],wb:["#ffffffff","#000000ff"],redish:["#ff00ffff","#ff0000ff","#ffff00ff"],greenish:["#ffff00ff","#00ff00ff","#00ffffff"],blueish:["#ff00ffff","#0000ffff","#00ffffff"],hspastel:["#AC6EA4FF","#8E92BDFF","#ACD4DEFF","#E9DC8EFF","#E7A97DFF","#E59074FF","#BE7E68FF","#A88F86FF"]};var $={base:{parent:void 0,name:"base",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"divergingbluered",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"},custom:{parent:void 0,name:"custom",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"rainbow",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"}};var me,fe,de;function xe({colorStyles:a={},units:e={},colorSchemes:t={}}={}){h("WxTile lib setup: start"),me=Object.assign({},ce,e),fe=Object.assign({},t,ue);let r=Object.assign({},a,$);de=Xe(r),h("WxTile lib setup: styles unrolled");try{y(this,null,function*(){yield document.fonts.load("32px barbs"),yield document.fonts.load("32px arrows")})}catch(n){h("WxTile lib setup: fonts not loaded")}h("WxTile lib setup is done.")}function A(){return de}function H(){return fe}function E(a,e,t){h("makeConverter: From=",a," To=",e);let r=m=>m;if(r.trivial=!0,a===e)return h("Trivial converter"),r;let n=Object.assign({},me,t),s=n[a],o=n[e];if(!s||!o)return h("Inconvertible units. Trivial converter"),r;let[i,c,l]=s,[u,f,d]=o;if(i!==u||!c||!f)return h("Inconvertible units. Trivial converter"),r;let g=c/f,x=((l||0)-(d||0))/f;return x?m=>g*m+x:m=>g*m}function Xe(a){let e=Object.assign({},$);for(let s in a){let o=a[s];if(Array.isArray(o))for(let i=0;i<o.length;++i)e[s+"["+i+"]"]=Object.assign({},o[i]);else e[s]=Object.assign({},o)}let t=Object.assign({},$.base),r=(s,o)=>{if(o==="base")return t;let i=s[o];if(!i)return t;(!i.parent||!(i.parent in s))&&(i.parent="base");let c=r(s,i.parent);return Object.assign(i,Object.assign({},c,i,{parent:"base"}))},n={base:t};for(let s in e)n[s]=r(e,s);return n}function _(a){let e=new Map;return(t,...r)=>{let n=e.get(t);if(n)return n;let s=a(t,...r);return e.set(t,s),s.catch(o=>{o.name==="AbortError"&&e.delete(t)}),s}}function $e(a,e){return y(this,null,function*(){return createImageBitmap(yield(yield fetch(a,e)).blob())})}function I(a,e,t=!0){let r=Object.assign(document.createElement("canvas"),{width:a,height:e,imageSmoothingEnabled:!1}).getContext("2d",{willReadFrequently:t});if(!r)throw new Error("Cannot get canvas context");return r}function Ee(a){let{width:e,height:t}=a,r=I(e,t);return r.drawImage(a,0,0),r.getImageData(0,0,e,t)}function J(a,e){return y(this,null,function*(){return Ee(yield $e(a,e))})}function qe(a){a.data[34]<1&&h("Warning: image is in too old format. Check the version of the Splitter.");let e=new Uint16Array(a.data.buffer),t=new Uint16Array(e.length/2);for(let l=0;l<t.length;l++)t[l]=e[l*2];let r=new Uint8Array(8);for(let l=0;l<8;++l)r[l]=a.data[l*4+2];let n=new DataView(r.buffer),s=n.getFloat32(0,!0),o=n.getFloat32(4,!0),i=(o-s)/65535,c=Ye(t);return{raw:t,dmin:s,dmax:o,dmul:i,integral:c,radius:0}}function Q(a,e){return y(this,null,function*(){return qe(yield J(a,e))})}function Ye(a){let e=new Uint32Array(66564),t=new Uint32Array(258*258);e[0]=a[0],t[0]=a[0]===0?0:1;for(let r=1;r<258;++r)e[r]=a[r]+e[r-1],e[258*r]=a[258*r]+e[258*r-258],t[r]=(a[r]===0?0:1)+t[r-1],t[258*r]=(a[258*r]===0?0:1)+t[258*r-258];for(let r=1,n=259;r<258;++r,++n)for(let s=1;s<258;++s,++n)e[n]=a[n]+e[n-258]+e[n-1]-e[n-258-1],t[n]=(a[n]===0?0:1)+t[n-258]+t[n-1]-t[n-258-1];return{integral:e,integralNZ:t}}function pe(a,e){if(e<0||e===a.radius)return a;a.radius=e;let t=258,{integral:r,integralNZ:n}=a.integral;for(let s=1;s<t;s++)for(let o=1;o<t;o++){if(!a.raw[t*s+o])continue;let i=Math.min(e,o-1,t-1-o),c=Math.min(e,s-1,t-1-s),l=t*(s-c-1)+o,u=t*(s+c)+o,f;if(n){let b=n[l-i-1],W=n[l+i],w=n[u-i-1],T=n[u+i];f=b+T-W-w}else f=(2*i+1)*(2*c+1);let d=r[l-i-1],g=r[l+i],x=r[u-i-1],m=r[u+i],p=d+m-g-x;a.raw[s*t+o]=p/f}return a}function M(a){let e=a>>0&255,t=a>>8&255,r=a>>16&255,n=e.toString(16),s=t.toString(16),o=r.toString(16);return n=n.length===2?n:"0"+n,s=s.length===2?s:"0"+s,o=o.length===2?o:"0"+o,"#"+n+s+o}function C(a){if(a[0]==="#"){if(a.length===4)return+("0xff"+a[3]+a[3]+a[2]+a[2]+a[1]+a[1]);if(a.length===7)return+("0xff"+a[5]+a[6]+a[3]+a[4]+a[1]+a[2]);if(a.length===9)return+("0x"+a[7]+a[8]+a[5]+a[6]+a[3]+a[4]+a[1]+a[2])}return h("wrong color format",a),0}function L(a,e){return y(this,null,function*(){let t=yield fetch(a,e);if(!t.ok)throw new Error("error:"+a+" - "+t.statusText);return t.json()})}function ee(a,e,t){let r=a>>0&255,n=a>>8&255,s=a>>16&255,o=a>>>24,i=e>>0&255,c=e>>8&255,l=e>>16&255,u=e>>>24,f=r+t*(i-r),d=n+t*(c-n),g=s+t*(l-s),x=o+t*(u-o);return f|d<<8|g<<16|x<<24}function ge(a,e,t){let r=[];for(let n=0;n<t;++n)r.push(n*(e-a)/(t-1)+a);return r}var he=!1;function je(a){console.log(a?"Logging on":"Logging off"),he=a}function h(...a){he&&console.log(...a)}function ye(a){return a[0]==="#"&&a.length===4?"#"+a[1]+a[1]+a[2]+a[2]+a[3]+a[3]:a}function q(a,{x:e,y:t,z:r}){return a.replace("{x}",`${e}`).replace("{y}",`${t}`).replace("{z}",`${r}`)}function Y({x:a,y:e,z:t}){return`${t}-${a}-${e}`}var Ge="A".charCodeAt(0);var U=class{constructor(){this.qtree={nodes:null};this.qtreedepth=0}load(e,t){return y(this,null,function*(){try{let r=yield L(e,t);this.qtree=be(r,{pos:0})}catch(r){throw new Error(`Failed to load QTree: ${r.message}`)}this.qtreedepth=We(this.qtree)})}check(e){let t=e.z-this.qtreedepth,r=t>=0,n=r?{x:e.x>>t,y:e.y>>t,z:this.qtreedepth}:X({},e);return we(this.qtree,n,r)}};function be(a,e){let t=a.charCodeAt(e.pos)-Ge;e.pos++;let r=[1,2,4,8].map(n=>t&n?be(a,e):null);return{nodes:r.some(n=>n)?r:null}}function We(a){return a!=null&&a.nodes?1+Math.max(...a.nodes.map(We)):0}function we(a,e,t){return a===null?"land":t&&!e.z?"mixed":a.nodes===null?"sea":e.z?(e.z--,we(a.nodes[(e.y>>e.z&1)<<1|e.x>>e.z&1],e,t)):"mixed"}var O=class{constructor({datasetName:e,instance:t,instanced:r,meta:n,wxapi:s}){if(!s.datasetsMetas.allDatasetsList.includes(e))throw new Error(`Dataset ${e} not found`);this.datasetName=e,this.instanced=r,this.instance=t,this.meta=n,this.wxapi=s}getValidTime(e=Date()){let t=this.getTimes();if(typeof e=="number"){if(e<=0)return t[0];if(e<t.length)return t[e]}let r=new Date(e).getTime(),n=t.find(s=>new Date(s).getTime()>=r);if(isNaN(r)||!n){let s=t.indexOf(e);return s===-1?t[t.length-1]:t[s]}return n}getTimes(){return this.instanced||this.meta.times}getVariables(){return this.meta.variables}getVariableMeta(e){return this.meta.variablesMeta[e]}getMaxZoom(){return this.meta.maxZoom}getBoundaries180(){var r;let e=(r=this.meta.boundaries)==null?void 0:r.boundaries180;if((e==null?void 0:e.length)!==1)return;let t=e[0];return[t.west,t.south,t.east,t.north]}getBoundaries(){return this.meta.boundaries}createURI(e,t,r="png"){if(!this.checkVariableValid(e))throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);let n=this.getValidTime(t),s=this.instanced?n:this.instance;return`${this.wxapi.dataServerURL+this.datasetName}/${s}/${e}/${n}/{z}/{x}/{y}.${r}`}checkVariableValid(e){return this.getVariableMeta(e)!==void 0}checkCombineVariableIfVector(e){let t=this.getVariableMeta(e);if(!t)throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);return t.vector||[e]}checkDatasetOutdated(){return y(this,null,function*(){return yield this.wxapi.initDone,(yield this.getDatasetInstance())===this.instance})}getDatasetInstance(){return y(this,null,function*(){let e=yield this.getDatasetInstances();return e[e.length-1]})}getDatasetInstances(){return y(this,null,function*(){try{let e=yield L(this.wxapi.dataServerURL+this.datasetName+"/instances.json",this.wxapi.requestInit);if(e.length===0)throw new Error(`No instances found for dataset ${this.datasetName}`);return e}catch(e){throw new Error(`getting dataset instances failure message: ${e.message} datasetName: ${this.datasetName}`)}})}};var te=class{constructor({dataServerURL:e,maskURL:t="auto",maskChannel:r="R",maskDepth:n=9,qtreeURL:s="auto",requestInit:o,colorStyles:i,units:c,colorSchemes:l}){this.maskURL="auto";this.datasetsMetas={allDatasetsList:[]};this.qtree=new U;this.loadMaskFunc=()=>Promise.reject(new Error("maskURL not defined"));if(xe({colorStyles:i,units:c,colorSchemes:l}),this.dataServerURL=e,this.requestInit=o,s=s==="auto"?e+"masks/9+1.seamask.qtree":s,t!=="none"){let u=_(J);this.maskURL=t=t==="auto"?e+"masks/{z}/{x}/{y}.png":t,this.loadMaskFunc=f=>u(q(t,f),o)}this.maskChannel=r==="R"?0:r==="G"?1:r==="B"?2:r==="A"?3:0,this.maskDepth=n,this.initDone=Promise.all([L(e+"datasetsmeta.json",o),s!=="none"?this.qtree.load(s,o):Promise.resolve()]).then(([u,f])=>{u.allDatasetsList||(u.allDatasetsList=Object.keys(u)),this.datasetsMetas=u})}getDatasetShortMeta(e){if(e!=="allDatasetsList")return this.datasetsMetas[e]}getDatasetInatance(e){var t;return(t=this.getDatasetShortMeta(e))==null?void 0:t.instance}getDatasetVariables(e){return y(this,null,function*(){var t;return yield this.initDone,(t=this.datasetsMetas[e])==null?void 0:t.variables})}createDatasetManager(e){return y(this,null,function*(){yield this.initDone;let t=this.getDatasetShortMeta(e),r=t==null?void 0:t.instance;if(!r)throw new Error("Dataset/instance not found:"+e);let n=t.instanced,s=yield L(this.dataServerURL+e+"/"+r+"/meta.json",this.requestInit);return new O({datasetName:e,instanced:n,instance:r,meta:s,wxapi:this})})}createAllDatasetsManagers(){return y(this,null,function*(){return yield this.initDone,Promise.allSettled(this.datasetsMetas.allDatasetsList.map(t=>this.createDatasetManager(t)))})}filterDatasetsByVariableName(e){return y(this,null,function*(){return yield this.initDone,this.datasetsMetas.allDatasetsList.filter(t=>{var r,n,s;return(s=(n=(r=this.datasetsMetas[t])==null?void 0:r.variables)==null?void 0:n.includes)==null?void 0:s.call(n,e)})})}getAllDatasetsNames(){return y(this,null,function*(){return yield this.initDone,this.datasetsMetas.allDatasetsList})}};function ze(a,e,t){return a>t?t:a<e?e:a}var N=class{constructor(e,t,[r,n],s){let o=n-r;this.levelIndex=new Uint32Array(65536),this.colorsI=new Uint32Array(65536);let i=[];this.DataToStyle=E(t,e.units,e.extraUnits),this.DataToStyle.trivial&&(e.units=t),s&&(this.DataToKnots=E(t,"knot"));let c=E(e.units,t,e.extraUnits),l=m=>~~(65535*ze((c(m)-r)/(n-r),0,1));if(Array.isArray(e.colorMap)){e.colorMap.sort((m,p)=>m[0]<p[0]?-1:m[0]>p[0]?1:0);for(let[m]of e.colorMap)i.push(l(m))}else{if(e.levels||(e.levels=ge(this.DataToStyle(r),this.DataToStyle(n),10)),e.levels.sort((m,p)=>m<p?-1:m>p?1:0),!e.colors){let m=H();e.colorScheme&&e.colorScheme in m?e.colors=m[e.colorScheme]:e.colors=m.wb}for(let m of e.levels)i.push(l(m))}let u=65536,f=De(u,e);this.ticks=f.ticks;let d=f.ticks[0].data,x=f.ticks[f.ticks.length-1].data-d;for(let m=0;m<65536;++m){let p=o*m/65535+r,b=this.DataToStyle(p),W=Math.round((u-1)*(b-d)/x);W<=0?this.colorsI[m]=e.showBelowMin?f.colors[0]:0:W>=u?this.colorsI[m]=e.showAboveMax?f.colors[u-1]:0:this.colorsI[m]=f.colors[W]}this.colorsI[0]=0;for(let m=0;m<i[0];++m)this.levelIndex[m]=0;for(let m=0;m<i.length-1;m++)for(let p=i[m];p<i[m+1]+1;++p)this.levelIndex[p]=m;for(let m=i[i.length-1];m<65536;++m)this.levelIndex[m]=i.length-1}};function Se(a){var t;if(a!==0&&-.1<a&&a<.1)return a.toExponential(2);let e=a.toString();return((t=e.split(".")[1])==null?void 0:t.length)>2?a.toFixed(2):e}function De(a,e){let t={size:a,showBelowMin:e.showBelowMin,showAboveMax:e.showAboveMax,units:e.units,colors:new Uint32Array(a),ticks:[]},{colorMap:r,levels:n,colors:s}=e,o=e.fill!=="solid";if(r){let d=r[0][0],g=r[r.length-1][0]-d;for(let[x,m]of r){let p=~~((x-d)/g*(a-1)),b={data:x,dataString:Se(x),color:m,pos:p};t.ticks.push(b)}for(let x=0;x<r.length-1;x++){let m=t.ticks[x].pos,p=t.ticks[x+1].pos,b=C(r[x][1]),W=o?C(r[x+1][1]):0;for(let w=m;w<p;++w)t.colors[w]=o?ee(b,W,(w-m)/(p-m)):b}return t.colors[a-1]=C(r[r.length-1][1]),t}if(!s||!n)return t;let i=0,c=0,l=-1;for(let d=0;d<a;++d){let g=d*(s.length-1)/a;l!==~~g&&(l=~~g,i=C(s[l]),c=s.length>l+1?C(s[l+1]):i),t.colors[d]=o?ee(i,c,g-l):i}t.colors[a-1]=C(s[s.length-1]);let u=n[0],f=(a-1)/(n[n.length-1]-u);for(let d of n){let g=~~((d-u)*f),x={data:d,dataString:Se(d),color:M(t.colors[g]),pos:g};t.ticks.push(x)}return t}var Ke=2*Math.PI*6378137/256,j=2*Math.PI*6378137/2;function He(a,e){let t=a/j*180,r=e/j*180;return r=180/Math.PI*(2*Math.atan(Math.exp(r*Math.PI/180))-Math.PI/2),[r,t]}function Je(a,e,t){let r=Qe(t),n=a*r-j,s=e*r-j;return[n,s]}function Qe(a){return Ke/Math.pow(2,a)}function re(a,e,t){let[r,n]=He(...Je(a,e,t));return[n,-r]}function Te(a,e){return[a*256,e*256]}function ae(a,e,t){let r=((e-a)%360+540)%360-180;return(a+r*t+360)%360}function et(a,e,t,r,n,s,o,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 0:return 0;case 1:return a;case 2:return e;case 3:t=a,r=e;break;case 4:return t;case 5:e=a,r=t;break;case 6:r=e+t>>1,a=r;break;case 7:r=e+t>>1;break;case 8:return r;case 9:e=a+r>>1,t=e;break;case 10:a=e,t=r;break;case 11:t=a+r>>1;break;case 12:a=t,e=r;break;case 13:e=a+r>>1;break;case 14:a=e+t>>1;break}a=o+i*a,e=o+i*e,t=o+i*t,r=o+i*r;let l=ae(a,e,n),u=ae(t,r,n);return(ae(l,u,s)-o)/i||1}function tt(a,e,t,r,n,s,o,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 7:return n+s<1?n*(e-a)+s*(t-a)+a:0;case 14:return n+s<1?0:n*(r-t)+s*(r-e)+e+t-r;case 11:return s<n?(1-n)*(a-e)+s*(r-e)+e:0;case 13:return s<n?0:(1-n)*(t-r)+s*(t-a)+a+r-t;case 15:return n+s<1?n*(e-a)+s*(t-a)+a:n*(r-t)+s*(r-e)+e+t-r;default:return 0}}function Me(a,e,t){let r=.9999999/Math.pow(2,t.z),n=t.x*256*r,s=t.y*256*r,{raw:o,dmin:i,dmax:c,dmul:l}=e,u={raw:new Uint16Array(258*258),dmin:i,dmax:c,dmul:l},{raw:f}=u;for(let d=-1,g=0;d<=256;d++){let x=s+d*r,m=Math.floor(x),p=x-m;for(let b=-1;b<=256;b++,g++){let W=n+b*r,w=Math.floor(W),T=W-w,S=w+1+(m+1)*258,D=o[S],v=o[S+1],P=o[S+258],k=o[S+258+1];f[g]=a(D,v,P,k,T,p,i,l)}}return u}function Ce(a,e){if(!e)return a;let t=1/Math.pow(2,e.z),r=e.x*256*t,n=e.y*256*t,{data:s}=a,o=new ImageData(256,256),{data:i}=o;for(let c=0,l=0;c<256;c++){let u=n+c*t,f=Math.floor(u);f===255&&(f=254);let d=u-f;for(let g=0;g<256;g++,l++){let x=r+g*t,m=Math.floor(x);m===255&&(m=254);let p=x-m,b=(m+f*256)*4+0,W=s[b],w=s[b+4],T=s[b+4*256],S=s[b+4*256+4],D=p+d<1?p*(w-W)+d*(T-W)+W:p*(S-T)+d*(S-w)+w+T-S;i[l*4]=D>127?255:0}}return o}function ve(a,e){return e?Me(tt,a,e):a}function Le(a,e){return e?Me(et,a,e):a}function Ie(a,{data:e},t,r){let n=r==="sea",{raw:s}=a;for(let o=t,i=259,c=0;c<256;i+=2,c++)for(let l=0;l<256;l++,i++,o+=4)n===!e[o]&&(s[i]=0);return a}function Pe(a){let[e,t]=Te(a.x,a.y),[r,n]=re(e,t,a.z),[s,o]=re(e+256,t+256,a.z);return{west:r,north:n,east:s,south:o}}function ne(a,e){let t=a.z-e;if(t<=0)return{upCoords:a};let r={x:a.x>>>t,y:a.y>>>t,z:e},n={x:a.x&(1<<t)-1,y:a.y&(1<<t)-1,z:t};return{upCoords:r,subCoords:n}}var Z=class{constructor(e){this.loadDataFunc=_(Q);this.layer=e}load(e,t){return y(this,null,function*(){let r=yield this.cacheLoad(e,this.layer.tilesURIs,t);if(!r)return null;let{rawdata:n,subCoords:s,tileType:o}=r,{units:i}=this.layer.currentMeta,c=i==="degree"?Le:ve,l=f=>c(pe(f,this.layer.style.blurRadius),s),u=n.map(l);return this._vectorMagnitudesPrepare(u),yield this._applyMask(u,e,o,!s&&n.length===1),{data:u,slines:this._createStreamLines(u)}})}cacheLoad(e,t,r){return y(this,null,function*(){if(!this._checkInsideBoundaries(e))return null;let n=this._checkTypeAndMask(e);if(!n)return null;let{upCoords:s,subCoords:o}=ne(e,this.layer.wxdatasetManager.getMaxZoom()),i=t.map(u=>q(u,s)),c=Object.assign({},this.layer.wxdatasetManager.wxapi.requestInit,{signal:r==null?void 0:r.signal});return{rawdata:yield Promise.all(i.map(u=>this.loadDataFunc(u,c))),subCoords:o,tileType:n}})}clearCache(){this.loadDataFunc=_(Q)}_applyMask(e,t,r,n){return y(this,null,function*(){let{style:s}=this.layer;if((s.mask==="land"||s.mask==="sea")&&r==="mixed"){if(n){let{raw:i,dmin:c,dmax:l,dmul:u}=e[0];e[0]={raw:new Uint16Array(i),dmin:c,dmax:l,dmul:u}}let o;try{let{upCoords:i,subCoords:c}=ne(t,this.layer.wxdatasetManager.wxapi.maskDepth);o=yield this.layer.wxdatasetManager.wxapi.loadMaskFunc(i),o=Ce(o,c)}catch(i){s.mask=void 0,h("Can't load Mask. Masking is disabled");return}Ie(e[0],o,this.layer.wxdatasetManager.wxapi.maskChannel,s.mask)}})}_vectorMagnitudesPrepare(e){if(e.length===1)return;e.unshift({raw:new Uint16Array(258*258),dmin:0,dmax:0,dmul:0});let[t,r,n]=e;t.dmax=1.42*Math.max(-r.dmin,r.dmax,-n.dmin,n.dmax),t.dmul=(t.dmax-t.dmin)/65535;for(let s=0;s<258*258;++s){if(!r.raw[s]||!n.raw[s])continue;let o=r.dmin+r.dmul*r.raw[s],i=n.dmin+n.dmul*n.raw[s];t.raw[s]=Math.sqrt(i*i+o*o)/t.dmul}}_checkTypeAndMask(e){let{mask:t}=this.layer.style;var r="mixed";if(!((t==="land"||t==="sea")&&(r=this.layer.wxdatasetManager.wxapi.qtree.check(e),t===r)))return r}_checkInsideBoundaries(e){let t=this.layer.wxdatasetManager.getBoundaries();if(t!=null&&t.boundaries180){let r=Pe(e),n=s=>!(r.west>s.east||s.west>r.east||r.south>s.north||s.south>r.north);if(!t.boundaries180.some(n))return!1}return!0}_createStreamLines(e){if(e.length!==3)return[];let{style:t}=this.layer;if(t.streamLineColor==="none")return[];let r=[],[n,s,o]=e,i=(t.streamLineSpeedFactor||1)/n.dmax,c=t.addDegrees?.017453292519943*t.addDegrees:0,l=t.streamLineGridStep||64,u=t.streamLineSteps||300;for(let f=0;f<=256;f+=l)for(let d=0;d<=256;d+=l){if(!n.raw[1+d+(1+f)*258])continue;let g=[],x=d,m=f,p=-1,b=0,W=0;for(let S=0;S<=u&&x>=0&&x<=256&&m>=0&&m<=256;S++){S%(u/10)||g.push({x:~~x,y:~~m});let D=~~x+1+(~~m+1)*258;if(D!==p){if(!n.raw[D])break;p=D;let v=n.dmin+n.raw[D]*n.dmul,P=s.dmin+s.raw[D]*s.dmul,k=o.dmin+o.raw[D]*o.dmul,R=Math.atan2(P,k)+c;b=i*v*Math.sin(R),W=i*v*Math.cos(R)}x+=b,m-=W}let w=d,T=f;p=-1;for(let S=1;S<=u&&w>=0&&w<=256&&T>=0&&T<=256;S++){S%(u/10)||g.unshift({x:~~w,y:~~T});let D=~~w+1+(~~T+1)*258;if(D!==p){if(!n.raw[D])break;p=D;let v=n.dmin+n.raw[D]*n.dmul,P=s.dmin+s.raw[D]*s.dmul,k=o.dmin+o.raw[D]*o.dmul,R=Math.atan2(P,k)+c;b=i*v*Math.sin(R),W=i*v*Math.cos(R)}w-=b,T+=W}g.length>2&&r.push(g)}return r}};var F=class{constructor(e){this.layer=e}paint({data:e,ctxFill:t,ctxText:r,ctxStreamLines:n}){let{layer:s}=this,{units:o}=s.currentMeta,i=new ImageData(256,256),c=new Uint32Array(i.data.buffer);t.clearRect(0,0,256,256),r.clearRect(0,0,256,256),n.clearRect(0,0,256,256),rt(e.data[0],c,s);let l=at(c,e.data[0],s);t.putImageData(i,0,0),nt(l,r,s),st(e.data,r,s),ot(e.data[0],r,o,s),it(e,r,s)}getPaintedCanvas(e,t,r){return t?(this.imprintVectorAnimationLinesStep(e,r),e.ctxStreamLines.canvas):e.ctxFill.canvas}imprintVectorAnimationLinesStep({data:e,ctxFill:t,ctxStreamLines:r},n){let{layer:s}=this;r.clearRect(0,0,256,256),r.drawImage(t.canvas,0,0),!(e.slines.length===0||s.style.streamLineStatic||s.style.streamLineColor==="none")&<(e,r,s,n)}};function rt(a,e,{CLUT:t,style:r}){let{raw:n}=a,{colorsI:s}=t;if(r.fill!=="none")for(let o=0,i=0,c=259;o<256;++o,c+=2)for(let l=0;l<256;++l,++i,++c)e[i]=s[n[c]];else e.fill(0)}function at(a,e,{CLUT:t,style:r}){let{raw:n}=e,{levelIndex:s,colorsI:o}=t,i=[];if(r.isolineColor!=="none"){let c=r.isolineColor[0]==="#"?C(r.isolineColor):0;for(let l=0,u=0;l<256;l+=1)for(let f=0;f<256;f+=1){let d=(l+1)*258+(f+1),g=n[d],x=n[d+1],m=n[d+258];if(!g||!x||!m)continue;let p=s[g],b=s[x],W=s[m];if(p!==b||p!==W){let w=Math.max(p,b,W),T=Math.max(g,x,m),S=l*256+f;switch(r.isolineColor){case"inverted":a[S]=~o[T]|4278190080;break;case"fill":a[S]=o[T]|4278190080;break;default:a[S]=c;break}r.isolineText&&!(++u%255)&&f>20&&f<235&&l>20&&l<235&&i.push({x:f,y:l,d:g,dr:x,db:m,mli:w})}}}return i}function nt(a,e,{CLUT:t}){if(a.length){e.font="1.1em Sans-serif",e.lineWidth=2,e.strokeStyle="white",e.fillStyle="black",e.textAlign="center",e.textBaseline="middle";for(let{x:r,y:n,d:s,dr:o,db:i,mli:c}of a){let l=t.ticks[c].dataString,u=Math.atan2(s-o,i-s);e.save(),e.translate(r,n),e.rotate(u<-1.57||u>1.57?u+3.14:u),e.strokeText(l,0,0),e.fillText(l,0,0),e.restore()}}}function st(a,e,{CLUT:t,style:r}){if(!t.DataToKnots||r.vectorColor==="none"||r.vectorType==="none")return;if(a.length!==3)throw new Error("data.length !== 3");let[n,s,o]=a;switch(r.vectorType){case"barbs":e.font="40px barbs";break;case"arrows":e.font="50px arrows";break;default:e.font=r.vectorType}e.textAlign="center",e.textBaseline="middle",e.fillStyle=r.vectorColor;let i=r.addDegrees?.017453292519943*r.addDegrees:0,c=32;for(let l=c/2;l<256;l+=c)for(let u=c/2;u<256;u+=c){let f=u+1+(l+1)*258;if(!n.raw[f])continue;let d=Math.atan2(s.dmin+s.raw[f]*s.dmul,o.dmin+o.raw[f]*o.dmul),g=n.dmin+n.raw[f]*n.dmul,x=r.vectorType!=="barbs"?r.vectorFactor*.2:.2,m=Math.min(t.DataToKnots(g)*x,25)+65,p=String.fromCharCode(m);switch(r.vectorColor){case"inverted":e.fillStyle=M(~t.colorsI[n.raw[f]]);break;case"fill":e.fillStyle=M(t.colorsI[n.raw[f]]);break}e.save(),e.translate(u,l),e.rotate(d+i),e.fillText(p,0,0),e.restore()}}function ot(a,e,t,{CLUT:r,style:n}){if(t!=="degree")return;let s=.017453292519943*n.addDegrees;e.font="50px arrows",e.textAlign="center",e.textBaseline="middle",e.fillStyle=n.vectorColor;let o="L",i=32;for(let c=i/2;c<256;c+=i)for(let l=i/2;l<256;l+=i){let u=l+1+(c+1)*258;if(!a.raw[u])continue;let d=(a.dmin+a.raw[u]*a.dmul+180)*.01745329251;switch(n.vectorColor){case"inverted":e.fillStyle=M(~r.colorsI[a.raw[u]]);break;case"fill":e.fillStyle=M(r.colorsI[a.raw[u]]);break}e.save(),e.translate(l,c),e.rotate(d+s),e.fillText(o,0,0),e.restore()}}function it(a,e,{CLUT:t,style:r}){let{data:n,slines:s}=a;if(!s.length||!r.streamLineStatic||r.streamLineColor==="none")return;let o=n[0];e.lineWidth=1,e.strokeStyle=r.streamLineColor;for(let i=s.length;i--;){let c=s[i];for(let l=0;l<c.length-1;++l){let u=c[l],f=c[l+1],d=u.x+1+(u.y+1)*258;switch(r.streamLineColor){case"inverted":e.strokeStyle=M(~t.colorsI[o.raw[d]]);break;case"fill":e.strokeStyle=M(t.colorsI[o.raw[d]]);break}e.beginPath(),e.moveTo(u.x,u.y),e.lineTo(f.x,f.y),e.stroke()}}}function lt(a,e,{CLUT:t,style:r},n){let{data:s,slines:o}=a,i=s[0],c=r.streamLineColor.substring(0,7);n=n>>5;for(let l=0;l<o.length;++l){let u=o[l],f=u.length-1,d=(n+(1+u[0].x)*(1+u[0].y))%30;for(let g=0;g<f;++g){let x=u[g],m=u[g+1],p=1-(d-g)/f;(p<0||p>1)&&(p=0);let b=(~~(p*255)).toString(16).padStart(2,"0"),W=1+~~((1.2-p)*5);e.lineWidth=W;let w=x.x+1+(x.y+1)*258;switch(r.streamLineColor){case"inverted":c=M(~t.colorsI[i.raw[w]]);break;case"fill":c=M(t.colorsI[i.raw[w]]);break}e.strokeStyle=c+b,e.beginPath(),e.moveTo(x.x,x.y),e.lineTo(m.x,m.y),e.stroke()}}}var V=class{constructor({time:e,variables:t,wxdatasetManager:r,ext:n="png",wxstyleName:s="base"}){this.tilesCache=new Map;this.painter=new F(this);this.loader=new Z(this);if(!(t!=null&&t.length)||t.length>2)throw new Error(`WxTileSource ${r.datasetName}: only 1 or 2 variables are supported but ${t.length} were given`);t.forEach(o=>{if(!r.checkVariableValid(o))throw new Error(`WxTileSource ${r.datasetName}: variable ${o} is not valid`)}),this.variables=t,this.wxdatasetManager=r,this.ext=n,this.currentMeta=this._getCurrentMeta(),[this.tilesURIs,this.time]=this._createURLsAndTime(e),[this.style,this.CLUT]=this._createCurrentStyleObject(A()[s]),h(`WxTileSource created ${r.datasetName}, ${t.join(", ")}, ${s}`)}get nonanimatable(){return this.variables.length<2||this.style.streamLineStatic||this.style.streamLineColor==="none"}getTime(){return this.time}clearCache(){this.tilesCache.clear(),this.loader.clearCache()}getCurrentStyleObjectCopy(){return Object.assign({},this.style)}updateCurrentStyleObject(e){[this.style,this.CLUT]=this._createCurrentStyleObject(e)}getTileData(e,t){let r=this.tilesCache.get(Y(e));if(!r)return;let n=this._getPixelInfo(t,r.data.data);if(!n)return;let{raw:s,data:o}=n,i=s.map(u=>this.CLUT.colorsI[u]),c=i.map(M),l=o.map(u=>this.CLUT.DataToStyle(u));return{data:o,raw:s,rgba:i,hexColor:c,inStyleUnits:l,tilePoint:t,styleUnits:this.style.units,dataUnits:this.currentMeta.units}}setURLsAndTime(e){[this.tilesURIs,this.time]=this._createURLsAndTime(e)}loadTile(e,t){return y(this,null,function*(){return this._loadCacheDrawTile(e,this.tilesCache,t)})}preloadTime(e,t,r){return y(this,null,function*(){let[n]=this._createURLsAndTime(e);yield Promise.allSettled(t.map(s=>this.loader.cacheLoad(s,n,r)))})}reloadTiles(e,t){return y(this,null,function*(){var n;let r=new Map;yield Promise.allSettled(e.map(s=>this._loadCacheDrawTile(s,r,t))),(n=t==null?void 0:t.signal)!=null&&n.aborted||(this.tilesCache=r)})}_loadCacheDrawTile(e,t,r){return y(this,null,function*(){let n=t.get(Y(e));if(n)return n;let s=yield this.loader.load(e,r);if(!s)return null;let o=I(256,256),i=o,c=this.variables.length===2?I(256,256):o,l={ctxFill:o,ctxText:i,ctxStreamLines:c,data:s};return this.painter.paint(l),t.set(Y(e),l),l})}_createCurrentStyleObject(e){let t=Object.assign(this.getCurrentStyleObjectCopy(),e);t.streamLineColor=ye(t.streamLineColor);let r=this._prepareCLUT(t);return[t,r]}_getCurrentMeta(){let e=this.variables.map(o=>{let i=this.wxdatasetManager.getVariableMeta(o);if(!i)throw new Error(`WxTileSource ${this.wxdatasetManager.datasetName}: variable ${o} is not valid`);return i}),{min:t,max:r,units:n,vector:s}=e[0];return this.variables.length>1&&(t=0,r=1.42*Math.max(-e[0].min,e[0].max,-e[1].min,e[1].max)),{min:t,max:r,units:n,vector:s}}_getPixelInfo({x:e,y:t},r){var s,o;let n=(t+1)*258+(e+1);if(!!((o=(s=r==null?void 0:r[0])==null?void 0:s.raw)!=null&&o[n]))return{raw:r.map(i=>i.raw[n]),data:r.map(i=>i.raw[n]*i.dmul+i.dmin)}}_prepareCLUT(e){let{min:t,max:r,units:n}=this.currentMeta;return new N(e,n,[t,r],this.variables.length===2)}_createURLsAndTime(e){let t=this.wxdatasetManager.getValidTime(e);return[this.variables.map(n=>this.wxdatasetManager.createURI(n,t,this.ext)),t]}};var Ae=Be(Re()),B=class extends Ae.default.GridLayer{};var G=class extends B{constructor(t,r){super(r);this.animation=!1;this.animationSeed=0;this.layer=new V(t)}get wxdatasetManager(){return this.layer.wxdatasetManager}getMetadata(){return h(`WxTileSource getMetadata (${this.layer.wxdatasetManager.datasetName})`),X({},this.layer.currentMeta)}getVariables(){return h(`WxTileSource getVariables (${this.layer.wxdatasetManager.datasetName})`),[...this.layer.variables]}clearCache(){h(`WxTileSource clearCache (${this.layer.wxdatasetManager.datasetName})`),this.layer.clearCache()}getCurrentStyleObjectCopy(){return h(`WxTileSource getCurrentStyleObjectCopy (${this.layer.wxdatasetManager.datasetName})`),this.layer.getCurrentStyleObjectCopy()}getTime(){return h(`WxTileSource getTime (${this.layer.wxdatasetManager.datasetName})`),this.layer.getTime()}setTime(t,r){return y(this,null,function*(){var s;h(`WxTileSource setTime (${this.layer.wxdatasetManager.datasetName}) `,{time:t});let n=this.getTime();return this.layer.setURLsAndTime(t),yield this._reloadVisible(r),(s=r==null?void 0:r.signal)!=null&&s.aborted&&this.layer.setURLsAndTime(n),this.getTime()})}preloadTime(t,r){return y(this,null,function*(){return h(`WxTileSource preloadTime (${this.layer.wxdatasetManager.datasetName}) `,{time:t}),this.layer.preloadTime(t,this.coveringTiles(),r)})}startAnimation(){if(this.animation){h(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName}) already started`);return}if(this.layer.nonanimatable){h(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName}) nonanimatable`);return}h(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName})`),this.animation=!0;let t=r=>y(this,null,function*(){if(h(`WxTileSource animationStep (${this.layer.wxdatasetManager.datasetName})`),!this.animation||this.layer.nonanimatable){this.animation=!1;return}this.animationSeed=r,yield this._redrawTiles(),requestAnimationFrame(t)});requestAnimationFrame(t)}stopAnimation(){return y(this,null,function*(){return h(`WxTileSource stopAnimation (${this.layer.wxdatasetManager.datasetName})`),this.animation=!1,this._redrawTiles()})}setCoarseLevel(t=2){return y(this,null,function*(){return h(`WxTileSource setCoarseLevel (${this.layer.wxdatasetManager.datasetName})`,{level:t}),this.oldMaxZoom=this.layer.wxdatasetManager.getMaxZoom(),this.layer.wxdatasetManager.meta.maxZoom=Math.max(this.oldMaxZoom-t,1),this._reloadVisible()})}unsetCoarseLevel(){return y(this,null,function*(){if(h(`WxTileSource unsetCoarseLevel (${this.layer.wxdatasetManager.datasetName})`),this.oldMaxZoom)return this.layer.wxdatasetManager.meta.maxZoom=this.oldMaxZoom,this._reloadVisible()})}setStyleByName(t,r=!0){return y(this,null,function*(){return h(`WxTileSource setStyleByName (${this.layer.wxdatasetManager.datasetName})`),this.updateCurrentStyleObject(A()[t],r)})}updateCurrentStyleObject(t,r=!0,n){return y(this,null,function*(){if(h(`WxTileSource updateCurrentStyleObject (${this.layer.wxdatasetManager.datasetName})`,{style:t}),this.layer.updateCurrentStyleObject(t),this.startAnimation(),r)return this._reloadVisible(n)})}_redrawTiles(){return this.redrawRequested?this.redrawRequested:(this.redrawRequested=new Promise(t=>{requestAnimationFrame(()=>{h(`WxTileSource _redrawTiles (${this.layer.wxdatasetManager.datasetName})`),this.update(),t(),this.redrawRequested=void 0})}),this.redrawRequested)}_reloadVisible(t){return y(this,null,function*(){})}coveringTiles(){return[]}update(){}};var z=class{constructor(e,t,r){this.coords=e;this.ctx=t;this.raster_data=r;this.draw(r==null?void 0:r.ctxFill.canvas)}draw(e){this.ctx.clearRect(0,0,256,256),e&&this.ctx.drawImage(e,0,0)}},se=class extends G{constructor(e,t){super(e,t),h("WxTileSource constructor: ",e)}getLayerInfoAtLatLon(e,t){if(h(`WxTileSource getLayerInfoAtLatLon (${this.layer.wxdatasetManager.datasetName})`,e),!this._map)return;let r=this._map.getZoom(),n=this._map.project(e,r),s=n.divideBy(256).floor(),o=n.subtract(s.multiplyBy(256)).floor();return this.layer.getTileData({x:s.x,y:s.y,z:r},o)}_reloadVisible(e){return y(this,null,function*(){var t;if(h(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName})`),yield this.layer.reloadTiles(this.coveringTiles(),e),(t=e==null?void 0:e.signal)!=null&&t.aborted){h(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName}) aborted`);return}return yield Promise.allSettled(this._ForEachWxTile(r=>y(this,null,function*(){r.raster_data=yield this.layer.loadTile(r.coords)}),"_reloadVisible")),this._redrawTiles()})}coveringTiles(){var t;h(`WxTileSource coveringTiles (${this.layer.wxdatasetManager.datasetName})`);let e=[];for(let r in this._tiles){let n=(t=this._tiles[r].el)==null?void 0:t.wxtile;n&&e.push(n.coords)}return e}update(){this._ForEachWxTile(e=>{e.draw(e.raster_data&&this.layer.painter.getPaintedCanvas(e.raster_data,this.animation,this.animationSeed))},"_redrawTiles")}_ForEachWxTile(e,t){var n;h(`WxTileSource _ForEachWxTile (${this.layer.wxdatasetManager.datasetName}) func=${t}`);let r=[];for(let s in this._tiles){let o=(n=this._tiles[s].el)==null?void 0:n.wxtile;o&&r.push(e(o))}return r}createTile(e,t){let r=I(256,256),n=r.canvas;return this.layer.loadTile(e).then(s=>{n.wxtile=new z(e,r,s)}).catch(()=>{n.wxtile=new z(e,r,null)}).finally(t),n}onRemove(){return h(`WxTileSource onRemove (${this.layer.wxdatasetManager.datasetName})`),this.animation=!1,this.clearCache(),this}};export{B as FrameworkParentClass,Z as Loader,F as Painter,U as QTree,N as RawCLUT,h as WXLOG,te as WxAPI,De as WxCreateLegend,O as WxDataSetManager,H as WxGetColorSchemes,A as WxGetColorStyles,V as WxLayer,se as WxTileSource,je as WxTilesLogging};
|
|
@@ -1,46 +1,56 @@
|
|
|
1
1
|
import { Converter, WxColorStyleStrict } from './wxtools';
|
|
2
|
-
/**
|
|
3
|
-
* @param {number} data - the data value
|
|
4
|
-
* @param {string} dataString - compact string representation of the data value
|
|
5
|
-
* @param {string} color - the color of the data value in web format
|
|
6
|
-
* @param {number} pos - the position of the data value on the legend in [0, legendSize]
|
|
7
|
-
*/
|
|
2
|
+
/** data values of the legend */
|
|
8
3
|
export interface WxTick {
|
|
4
|
+
/** the data value */
|
|
9
5
|
data: number;
|
|
6
|
+
/** compact string representation of the data value */
|
|
10
7
|
dataString: string;
|
|
8
|
+
/** the color of the data value in web format */
|
|
11
9
|
color: string;
|
|
10
|
+
/** the position of the data value on the legend in [0, legendSize] */
|
|
12
11
|
pos: number;
|
|
13
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Class contains information about the color style and the legend
|
|
15
|
+
* Based on the idea of CLUT (Color Look Up Table) to fill tiles with colors from the style
|
|
16
|
+
*/
|
|
14
17
|
export declare class RawCLUT {
|
|
18
|
+
/** convert data value to level index */
|
|
15
19
|
levelIndex: Uint32Array;
|
|
20
|
+
/** convert data value to color index */
|
|
16
21
|
colorsI: Uint32Array;
|
|
22
|
+
/** convert data value to style value */
|
|
17
23
|
DataToStyle: Converter;
|
|
24
|
+
/** convert data value to knots. Useful for styles for vector data to get the direction of the vector */
|
|
18
25
|
DataToKnots?: Converter;
|
|
26
|
+
/** data values of the legend */
|
|
19
27
|
ticks: WxTick[];
|
|
28
|
+
/**
|
|
29
|
+
* @param style the color style
|
|
30
|
+
* @param dUnits the units of the data
|
|
31
|
+
* @param minmax the array of minimum and maximum data values
|
|
32
|
+
* @param vector if true, the style is for vector data
|
|
33
|
+
* */
|
|
20
34
|
constructor(style: WxColorStyleStrict, dUnits: string, [dMin, dMax]: [number, number], vector: boolean);
|
|
21
35
|
}
|
|
22
|
-
/**
|
|
23
|
-
* @inteface WxLegend
|
|
24
|
-
* @description Legend object
|
|
25
|
-
* @property {number} size - size of the legend in pixels
|
|
26
|
-
* @property {boolean} showBelowMin - show color for values below min
|
|
27
|
-
* @property {boolean} showAboveMax - show color for values above max
|
|
28
|
-
* @property {string} units - units of the legend
|
|
29
|
-
* @property {number[]} colors - array of colors
|
|
30
|
-
* @property {WxTick[]} ticks - array of ticks
|
|
31
|
-
*/
|
|
36
|
+
/** Legend - data structure that contains information for rendering legends */
|
|
32
37
|
export interface WxLegend {
|
|
38
|
+
/** size of the legend in pixels */
|
|
33
39
|
size: number;
|
|
40
|
+
/** show color for values below min */
|
|
34
41
|
showBelowMin: boolean;
|
|
42
|
+
/** show color for values above max */
|
|
35
43
|
showAboveMax: boolean;
|
|
44
|
+
/** units of the legend */
|
|
36
45
|
units: string;
|
|
46
|
+
/** array of colors */
|
|
37
47
|
colors: Uint32Array;
|
|
48
|
+
/** array of ticks */
|
|
38
49
|
ticks: WxTick[];
|
|
39
50
|
}
|
|
40
|
-
/**
|
|
41
|
-
* @
|
|
42
|
-
* @param
|
|
43
|
-
* @
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
51
|
+
/** Create a legend for a given color style
|
|
52
|
+
* @param size - number of colors in the legend
|
|
53
|
+
* @param style - color style
|
|
54
|
+
* @returns legend
|
|
55
|
+
* */
|
|
46
56
|
export declare function WxCreateLegend(size: number, style: WxColorStyleStrict): WxLegend;
|
package/dist/es/utils/qtree.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { XYZ } from './wxtools';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
nodes: SubTrees;
|
|
2
|
+
/** Hierarchical quad-tree to encode the land/sea mask */
|
|
3
|
+
export interface Tree {
|
|
4
|
+
nodes: SubTreesN;
|
|
6
5
|
}
|
|
6
|
+
/** Tree or null */
|
|
7
|
+
export type TreeN = Tree | null;
|
|
8
|
+
/** 4 sub-trees of a quad-tree node */
|
|
9
|
+
export type SubTrees = [TreeN, TreeN, TreeN, TreeN];
|
|
10
|
+
/** SubTrees or null */
|
|
11
|
+
export type SubTreesN = SubTrees | null;
|
|
12
|
+
/** possible type of a tile */
|
|
7
13
|
export declare enum TileType {
|
|
8
14
|
Land = "land",
|
|
9
15
|
Mixed = "mixed",
|
|
10
16
|
Sea = "sea"
|
|
11
17
|
}
|
|
18
|
+
/** class QTree utilizes quad-tree structure to get the type of the tile at the given coord */
|
|
12
19
|
export declare class QTree {
|
|
13
20
|
qtree: Tree;
|
|
14
21
|
qtreedepth: number;
|
|
@@ -16,4 +23,3 @@ export declare class QTree {
|
|
|
16
23
|
load(input: RequestInfo, requestInit?: RequestInit | undefined): Promise<void>;
|
|
17
24
|
check(coord: XYZ): TileType;
|
|
18
25
|
}
|
|
19
|
-
export {};
|
|
@@ -1,139 +1,305 @@
|
|
|
1
|
+
/** x,y,z */
|
|
1
2
|
export interface XYZ {
|
|
2
3
|
x: number;
|
|
3
4
|
y: number;
|
|
4
5
|
z: number;
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
7
|
+
/** type for unit converter */
|
|
8
|
+
export type WxUnitTuple = [string, number, number?];
|
|
9
|
+
/** Type of an Object with all unit convertion tupels */
|
|
10
|
+
export interface WxUnits {
|
|
11
|
+
[unit: string]: WxUnitTuple | undefined;
|
|
9
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Type of an Object with all color schemes,
|
|
15
|
+
* each color scheme is an array of colors evenly distributed between min and max values in a {@link WxLegend} and {@link RawCLUT}*/
|
|
10
16
|
export interface WxColorSchemes {
|
|
11
17
|
[name: string]: string[] | undefined;
|
|
12
18
|
}
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
fill?: 'none' | 'gradient' | 'solid';
|
|
18
|
-
isolineColor?: 'none' | 'inverted' | 'fill' | string;
|
|
19
|
-
isolineText?: boolean;
|
|
20
|
-
vectorType?: 'none' | 'arrows' | 'barbs';
|
|
21
|
-
vectorColor?: 'none' | 'inverted' | 'fill' | string;
|
|
22
|
-
vectorFactor?: number;
|
|
23
|
-
streamLineColor?: 'none' | 'inverted' | 'fill' | string;
|
|
24
|
-
streamLineSpeedFactor?: number;
|
|
25
|
-
streamLineGridStep?: number;
|
|
26
|
-
streamLineSteps?: number;
|
|
27
|
-
streamLineStatic?: boolean;
|
|
28
|
-
showBelowMin?: boolean;
|
|
29
|
-
showAboveMax?: boolean;
|
|
30
|
-
colorScheme?: string;
|
|
31
|
-
colors?: string[];
|
|
32
|
-
colorMap?: colorMapTuple[];
|
|
33
|
-
levels?: number[];
|
|
34
|
-
blurRadius?: number;
|
|
35
|
-
addDegrees?: number;
|
|
36
|
-
units?: string;
|
|
37
|
-
extraUnits?: Units;
|
|
38
|
-
mask?: 'land' | 'sea' | 'none';
|
|
19
|
+
/** A [level,color] tuple */
|
|
20
|
+
export type colorMapTuple = [number, string];
|
|
21
|
+
/** Weak color style (may not have all fields of {@link WxColorStyleStrict}) */
|
|
22
|
+
export interface WxColorStyleWeak extends Partial<WxColorStyleStrict> {
|
|
39
23
|
}
|
|
40
|
-
|
|
24
|
+
/** interface of an object with all mixed color styles */
|
|
25
|
+
export interface WxColorStylesWeakMixed {
|
|
41
26
|
[name: string]: WxColorStyleWeak | WxColorStyleWeak[] | undefined;
|
|
42
27
|
}
|
|
28
|
+
/** interface of an object with all weak color styles */
|
|
43
29
|
export interface ColorStylesIncomplete {
|
|
44
30
|
[name: string]: WxColorStyleWeak | undefined;
|
|
45
31
|
}
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
/** Strict style interface */
|
|
33
|
+
export interface WxColorStyleStrict {
|
|
34
|
+
/** name of the style */
|
|
48
35
|
name: string;
|
|
36
|
+
/** name of a parent style to inherit from */
|
|
37
|
+
parent?: string;
|
|
38
|
+
/** fill schema. 'none' means no fill. 'solid' means solid fill. 'gradient' means gradient fill. */
|
|
49
39
|
fill: 'none' | 'gradient' | 'solid';
|
|
50
|
-
|
|
40
|
+
/**
|
|
41
|
+
* color of isolines.
|
|
42
|
+
* 'none' means no isolines.
|
|
43
|
+
* 'inverted' use inverted value of {@link fill} in each pixel.
|
|
44
|
+
* 'fill' means use value of {@link fill} in each pixel. */
|
|
45
|
+
isolineColor: 'none' | 'inverted' | 'fill' | `#${string}`;
|
|
46
|
+
/** if true then render isoline text values */
|
|
51
47
|
isolineText: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* 'none' means no vectors.
|
|
50
|
+
* 'arrows' means render vectors as arrows.
|
|
51
|
+
* 'barbs' means render vectors as barbs.*/
|
|
52
52
|
vectorType: 'none' | 'arrows' | 'barbs';
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
|
+
* color of vectors
|
|
55
|
+
* 'none' means no vectors.
|
|
56
|
+
* 'inverted' use inverted value of {@link fill} in each pixel.
|
|
57
|
+
* 'fill' means use value of {@link fill} in each pixel.
|
|
58
|
+
* '#RRGGBB' means use this color for vectors. */
|
|
59
|
+
vectorColor: 'none' | 'inverted' | 'fill' | `#${string}`;
|
|
60
|
+
/** factor to scale vector length */
|
|
54
61
|
vectorFactor: number;
|
|
55
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Draw streamlines.
|
|
64
|
+
* 'none' means no streamlines.
|
|
65
|
+
* 'inverted' use inverted value of {@link fill} in each pixel.
|
|
66
|
+
* 'fill' means use value of {@link fill} in each pixel.
|
|
67
|
+
* '#RRGGBB' means use this color for streamlines. */
|
|
68
|
+
streamLineColor: 'none' | 'inverted' | 'fill' | `#${string}`;
|
|
69
|
+
/** factor to scale streamlines length */
|
|
56
70
|
streamLineSpeedFactor: number;
|
|
71
|
+
/**
|
|
72
|
+
* Step to seed streamlines. Streamlines spread both ways from seed point.
|
|
73
|
+
* less value means more streamlines. */
|
|
57
74
|
streamLineGridStep?: number;
|
|
75
|
+
/** steps in each streamline */
|
|
58
76
|
streamLineSteps?: number;
|
|
77
|
+
/** if true then render streamlines as static lines.
|
|
78
|
+
* if false then render streamlines as animated lines. */
|
|
59
79
|
streamLineStatic: boolean;
|
|
80
|
+
/** if true then fill values below style's minimum. */
|
|
60
81
|
showBelowMin: boolean;
|
|
82
|
+
/** if true then fill values above style's maximum. */
|
|
61
83
|
showAboveMax: boolean;
|
|
84
|
+
/** color scheme name from the default set. May be extended in {@link WxAPI}*/
|
|
62
85
|
colorScheme: string;
|
|
86
|
+
/** colors. Used if presented instead of colorScheme */
|
|
63
87
|
colors?: string[];
|
|
88
|
+
/** color map. Used if presented instead of levels, colors, colorScheme*/
|
|
64
89
|
colorMap?: [number, string][];
|
|
90
|
+
/** levels. Used if presented, otherwise 10 levels are evenly calculated from given data */
|
|
65
91
|
levels?: number[];
|
|
92
|
+
/** radius for the BOX filter */
|
|
66
93
|
blurRadius: number;
|
|
94
|
+
/** rotate vectors by this angle */
|
|
67
95
|
addDegrees: number;
|
|
96
|
+
/** Units of the style (from the default set)*/
|
|
68
97
|
units: string;
|
|
69
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Additional units for the style to be used within {@link units}.
|
|
100
|
+
* @see {@link WxUnits} */
|
|
101
|
+
extraUnits?: WxUnits;
|
|
102
|
+
/**
|
|
103
|
+
* masking
|
|
104
|
+
* 'none' means no masking.
|
|
105
|
+
* 'sea' means mask sea.
|
|
106
|
+
* 'land' means mask land. */
|
|
70
107
|
mask?: 'land' | 'sea' | 'none';
|
|
71
108
|
}
|
|
72
|
-
|
|
109
|
+
/**
|
|
110
|
+
* @typedef {Object} WxColorStylesStrict
|
|
111
|
+
* @property {string} name - name of the style
|
|
112
|
+
*/
|
|
113
|
+
export interface WxColorStylesStrict {
|
|
73
114
|
base: WxColorStyleStrict;
|
|
74
115
|
[name: string]: WxColorStyleStrict | undefined;
|
|
75
116
|
}
|
|
117
|
+
/** Options for the wxtiles library */
|
|
76
118
|
export interface WxTilesLibOptions {
|
|
77
|
-
|
|
78
|
-
|
|
119
|
+
/** Additional Color styles to use for the library */
|
|
120
|
+
colorStyles?: WxColorStylesWeakMixed;
|
|
121
|
+
/** Additional color schemes to use for the library */
|
|
79
122
|
colorSchemes?: WxColorSchemes;
|
|
123
|
+
/** Additional units to use for the library */
|
|
124
|
+
units?: WxUnits;
|
|
80
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Initialize the wxtiles library
|
|
128
|
+
* @param options - options {@link WxTilesLibOptions} to initialize the library
|
|
129
|
+
*/
|
|
81
130
|
export declare function WxTilesLibSetup({ colorStyles, units, colorSchemes }?: WxTilesLibOptions): void;
|
|
82
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Get all {@link WxColorStylesStrict} used by the library
|
|
133
|
+
* */
|
|
134
|
+
export declare function WxGetColorStyles(): WxColorStylesStrict;
|
|
135
|
+
/**
|
|
136
|
+
* Get all {@link WxColorSchemes} used by the library
|
|
137
|
+
* */
|
|
83
138
|
export declare function WxGetColorSchemes(): WxColorSchemes;
|
|
139
|
+
/** A function type with extra properties. */
|
|
84
140
|
export interface Converter {
|
|
141
|
+
/** interface of a function - unit cinverter*/
|
|
85
142
|
(x: number): number;
|
|
143
|
+
/** true if the converter is a trivial one */
|
|
86
144
|
trivial?: boolean;
|
|
87
145
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Convert a value from one unit to another
|
|
148
|
+
* @param from - the unit to convert from
|
|
149
|
+
* @param to - the unit to convert to
|
|
150
|
+
* @param customUnits - custom units to use if needed
|
|
151
|
+
* @returns a function that converts a value from one unit to another
|
|
152
|
+
* @example
|
|
153
|
+
* const convert = makeConverter('m/s', 'km/h');
|
|
154
|
+
* const speed = convert(10); // speed is now 36
|
|
155
|
+
* */
|
|
156
|
+
export declare function makeConverter(from: string, to: string, customUnits?: WxUnits): Converter;
|
|
157
|
+
/** Function type to load image from URL, with additional properties */
|
|
158
|
+
export type UriLoaderPromiseFunc<T> = (url: string, ...props: any) => Promise<T>;
|
|
159
|
+
/** Makes a cachable function that loads image from URL, with additional properties */
|
|
91
160
|
export declare function cacheUriPromise<T>(fn: UriLoaderPromiseFunc<T>): UriLoaderPromiseFunc<T>;
|
|
161
|
+
/**
|
|
162
|
+
* abortable 'loadImage'
|
|
163
|
+
* @param url - image url
|
|
164
|
+
* @param requestInit - fetch requestInit
|
|
165
|
+
* */
|
|
92
166
|
export declare function loadImage(url: string, requestInit?: RequestInit): Promise<ImageBitmap>;
|
|
93
|
-
|
|
167
|
+
/** integral pare for fast box blur algorithm */
|
|
168
|
+
export interface IntegralPare {
|
|
169
|
+
/** Integral image */
|
|
94
170
|
integral: Uint32Array;
|
|
171
|
+
/** Integral image of ZEROs */
|
|
95
172
|
integralNZ: Uint32Array | null;
|
|
96
173
|
}
|
|
174
|
+
/** interface of a data read from a PNG tile */
|
|
97
175
|
export interface DataPicture {
|
|
98
176
|
raw: Uint16Array;
|
|
99
177
|
dmin: number;
|
|
100
178
|
dmax: number;
|
|
101
179
|
dmul: number;
|
|
102
180
|
}
|
|
103
|
-
|
|
181
|
+
/** One (scalar) or three (vector components + length component) {@link DataPictures} */
|
|
182
|
+
export type DataPictures = [DataPicture] | [DataPicture, DataPicture, DataPicture];
|
|
183
|
+
/**
|
|
184
|
+
* interface extends {@link DataPictures} with {@link IntegralPare} and current
|
|
185
|
+
* calculated radius of the box-filter */
|
|
104
186
|
export interface DataIntegral extends DataPicture {
|
|
105
187
|
integral: IntegralPare;
|
|
106
188
|
radius: number;
|
|
107
189
|
}
|
|
108
|
-
|
|
190
|
+
/** One (scalar) or two (vector) {@link DataIntegral} */
|
|
191
|
+
export type DataIntegrals = [DataIntegral] | [DataIntegral, DataIntegral];
|
|
192
|
+
/**
|
|
193
|
+
* Helper function to create a 2D canvas context
|
|
194
|
+
* @param width - width of the context
|
|
195
|
+
* @param height - height of the context
|
|
196
|
+
* @param willReadFrequently - if true, the context will be read frequently (browser will optimize it)
|
|
197
|
+
* @returns canvas context
|
|
198
|
+
*/
|
|
109
199
|
export declare function create2DContext(width: number, height: number, willReadFrequently?: boolean): CanvasRenderingContext2D;
|
|
200
|
+
/**
|
|
201
|
+
* Load ImageData to from URL with RequestInit
|
|
202
|
+
* @param url - image url
|
|
203
|
+
* @param requestInit - fetch requestInit
|
|
204
|
+
* @returns Promise of ImageData
|
|
205
|
+
*/
|
|
110
206
|
export declare function loadImageData(url: string, requestInit?: RequestInit): Promise<ImageData>;
|
|
207
|
+
/**
|
|
208
|
+
* Load {@link DataIntegral} from URL with RequestInit
|
|
209
|
+
* @param url - image url
|
|
210
|
+
* @param requestInit - fetch requestInit
|
|
211
|
+
* @returns Promise of {@link DataIntegral}
|
|
212
|
+
* */
|
|
111
213
|
export declare function loadDataIntegral(url: string, requestInit?: RequestInit): Promise<DataIntegral>;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
controllerHolder: AbortControllerHolder;
|
|
118
|
-
abort: () => void;
|
|
119
|
-
}
|
|
120
|
-
export declare function loadingFunctionCachedAbortable<T>(F: (url: string, requestInit?: RequestInit) => Promise<T>, requestInit?: RequestInit): AbortableCacheableURILoaderPromiseFunc<T>;
|
|
121
|
-
export declare function loadDataIntegralCachedAbortable(requestInit?: RequestInit): AbortableCacheableURILoaderPromiseFunc<DataIntegral>;
|
|
122
|
-
export declare function loadImageDataCachedAbortable(requestInit?: RequestInit): AbortableCacheableURILoaderPromiseFunc<ImageData>;
|
|
123
|
-
export declare function loadDataIntegralCachedAbortable_old(requestInit?: RequestInit): AbortableCacheableURILoaderPromiseFunc<DataIntegral>;
|
|
124
|
-
export declare function loadImageDataCachedAbortable_old(requestInit?: RequestInit): AbortableCacheableURILoaderPromiseFunc<ImageData>;
|
|
214
|
+
/**
|
|
215
|
+
* BoxBlur implementation based on {@link DataIntegral}
|
|
216
|
+
* @param data - {@link DataIntegral}
|
|
217
|
+
* @param radius - radius for the box-blur algorithm
|
|
218
|
+
* */
|
|
125
219
|
export declare function blurData(im: DataIntegral, radius: number): DataIntegral;
|
|
220
|
+
/**
|
|
221
|
+
* Convert Uin32 RGB color to web color
|
|
222
|
+
* @param color - Uin32 color
|
|
223
|
+
* @returns web color in format '#RRGGBB'
|
|
224
|
+
* */
|
|
126
225
|
export declare function RGBtoHEX(rgb: number): string;
|
|
226
|
+
/**
|
|
227
|
+
* Convert Uin32 RGBA color to web color
|
|
228
|
+
* @param color - Uin32 color
|
|
229
|
+
* @returns web color in format '#RRGGBBAA'
|
|
230
|
+
* */
|
|
127
231
|
export declare function RGBAtoHEX(rgba: number): string;
|
|
232
|
+
/**
|
|
233
|
+
* Convert web color to Uin32 RGB color
|
|
234
|
+
* @param color - web color in format '#RGB' or '#RRGGBB' or '#RRGGBBAA'
|
|
235
|
+
* @returns Uin32 color
|
|
236
|
+
* */
|
|
128
237
|
export declare function HEXtoRGBA(c: string): number;
|
|
238
|
+
/**
|
|
239
|
+
* json loader helper
|
|
240
|
+
* @template {any} T - type of the object to load
|
|
241
|
+
* @param url - url to json file
|
|
242
|
+
* @param requestInit - requestInit for fetch
|
|
243
|
+
* @returns json object
|
|
244
|
+
* */
|
|
129
245
|
export declare function fetchJson<T = any>(url: RequestInfo, requestInit?: RequestInit): Promise<T>;
|
|
246
|
+
/**
|
|
247
|
+
* Create element helper
|
|
248
|
+
* @param tag - tag name
|
|
249
|
+
* @param className - class name
|
|
250
|
+
* @param container - container to append element
|
|
251
|
+
* @returns created element
|
|
252
|
+
* */
|
|
130
253
|
export declare function createEl(tagName: string, className?: string, container?: HTMLElement): HTMLElement;
|
|
254
|
+
/**
|
|
255
|
+
* Color linear mixer
|
|
256
|
+
* @param color1 - color1 Uin32 RGBA
|
|
257
|
+
* @param color2 - color2 Uin32 RGBA
|
|
258
|
+
* @param k - koefficient
|
|
259
|
+
* @returns mixed color Uin32 RGBA
|
|
260
|
+
* */
|
|
131
261
|
export declare function mixColor(c1: number, c2: number, t: number): number;
|
|
262
|
+
/**
|
|
263
|
+
* Helper to create array of levels for a style
|
|
264
|
+
* @param min - min value
|
|
265
|
+
* @param max - max value
|
|
266
|
+
* @param n - number of levels
|
|
267
|
+
* @returns array of levels
|
|
268
|
+
* */
|
|
132
269
|
export declare function createLevels(min: number, max: number, n: number): number[];
|
|
270
|
+
/**
|
|
271
|
+
* Get closest existing time in array. If time is Date, strings will be converted to number to find closest time
|
|
272
|
+
* @param times - array of times
|
|
273
|
+
* @param time - time to find
|
|
274
|
+
* @returns closest time a value from array
|
|
275
|
+
* */
|
|
133
276
|
export declare function getClosestTimeString(times: string[], time: Date | string | number): string;
|
|
277
|
+
/**
|
|
278
|
+
* Set logging on/off
|
|
279
|
+
* @param logging - true to turn on logging
|
|
280
|
+
* */
|
|
134
281
|
export declare function WxTilesLogging(on: boolean): void;
|
|
282
|
+
/**
|
|
283
|
+
* Logging helper
|
|
284
|
+
* @param args - arguments to log
|
|
285
|
+
* */
|
|
135
286
|
export declare function WXLOG(...str: any): void;
|
|
287
|
+
/**
|
|
288
|
+
* Helper to convert short form of web color from '#RGB' to '#RRGGBB'
|
|
289
|
+
* @param color - web color in format '#RGB' or '#RRGGBB' or '#RRGGBBAA'
|
|
290
|
+
* @returns web color in format '#RRGGBB'
|
|
291
|
+
* */
|
|
136
292
|
export declare function refineColor(c: string): string;
|
|
293
|
+
/**
|
|
294
|
+
* Helper to fill URI template with values
|
|
295
|
+
* @param uri - URI template
|
|
296
|
+
* @param values - {@link XYZ} values to fill template
|
|
297
|
+
* @returns URI with values filled
|
|
298
|
+
* */
|
|
137
299
|
export declare function uriXYZ(uri: string, { x, y, z }: XYZ): string;
|
|
300
|
+
/**
|
|
301
|
+
* Calculate hash of {@link XYZ}
|
|
302
|
+
* @param xyz - {@link XYZ} to calculate hash
|
|
303
|
+
* @returns string hash
|
|
304
|
+
* */
|
|
138
305
|
export declare function HashXYZ({ x, y, z }: XYZ): string;
|
|
139
|
-
export {};
|