@metoceanapi/wxtiles-leaflet 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/dist/es/controls/WxAPIControl.d.ts +1 -1
- package/dist/es/controls/WxInfoControl.d.ts +2 -1
- package/dist/es/index.js +2 -2
- package/dist/es/wxAPI/WxDataSetManager.d.ts +35 -18
- package/dist/es/wxAPI/wxAPI.d.ts +1 -1
- package/dist/es/wxlayer/WxImplementation.d.ts +17 -6
- package/dist/es/wxlayer/loader.d.ts +2 -0
- package/dist/es/wxlayer/painter.d.ts +5 -0
- package/dist/es/wxlayer/wxlayer.d.ts +29 -14
- package/dist/es/wxsource/wxsource.d.ts +5 -0
- package/dist/web/index.js +2 -2
- package/docs/docs/assets/search.js +1 -1
- package/docs/docs/classes/DataIntegral.html +9 -9
- package/docs/docs/classes/FrameworkParentClass.html +3 -3
- package/docs/docs/classes/Loader.html +12 -5
- package/docs/docs/classes/Painter.html +6 -6
- package/docs/docs/classes/WxAPI.html +3 -3
- package/docs/docs/classes/WxDataSetManager.html +119 -71
- package/docs/docs/classes/WxLayer.html +62 -43
- package/docs/docs/classes/WxLayerBaseImplementation.html +66 -19
- package/docs/docs/classes/WxTileSource.html +74 -22
- package/docs/docs/functions/WXLOG.html +1 -1
- package/docs/docs/functions/WxTilesLogging.html +1 -1
- package/docs/docs/interfaces/DataPicture.html +5 -5
- package/docs/docs/interfaces/FrameworkOptions.html +2 -2
- package/docs/docs/interfaces/IntegralPare.html +3 -3
- package/docs/docs/interfaces/WxDataSetManagerOptions.html +29 -29
- package/docs/docs/interfaces/WxDatasetMeta.html +4 -4
- package/docs/docs/interfaces/WxLayerAPI.html +29 -29
- package/docs/docs/interfaces/WxLayerBaseAPI.html +20 -20
- package/docs/docs/interfaces/WxLayerOptions.html +6 -15
- package/docs/docs/interfaces/WxRasterData.html +18 -2
- package/docs/docs/interfaces/WxSourceLayerOptions.html +6 -16
- package/docs/docs/types/DataIntegrals.html +1 -1
- package/docs/docs/types/DataPictures.html +1 -1
- package/docs/script/script.js +4 -4
- package/package.json +1 -1
- package/src_example/frwrkdeps.ts +1 -2
- package/src_example/start.ts +25 -24
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,7 @@ export declare class WxAPIControl {
|
|
|
4
4
|
private readonly _div;
|
|
5
5
|
private readonly datasets;
|
|
6
6
|
private readonly variables;
|
|
7
|
-
onchange?: (dataset: string, variable: string,
|
|
7
|
+
onchange?: (dataset: string, variable: string, resetStyleAndFlyTo?: boolean) => Promise<void>;
|
|
8
8
|
constructor(wxapi: WxAPI, dataset?: string, variable?: string);
|
|
9
9
|
fillDatasets(dataset?: string, variable?: string): Promise<void>;
|
|
10
10
|
fillVariables(variable?: string): Promise<void>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { WxTileSource } from '../index';
|
|
2
2
|
export declare class WxInfoControl {
|
|
3
3
|
private readonly div;
|
|
4
|
+
private pos;
|
|
4
5
|
constructor();
|
|
5
6
|
onAdd(): HTMLDivElement;
|
|
6
7
|
onRemove(): void;
|
|
7
|
-
update(wxsource: WxTileSource | undefined, map: any,
|
|
8
|
+
update(wxsource: WxTileSource | undefined, map: any, pos_?: {
|
|
8
9
|
lng: number;
|
|
9
10
|
lat: number;
|
|
10
11
|
}): void;
|
package/dist/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var Be=Object.create;var H=Object.defineProperty,Ve=Object.defineProperties,Xe=Object.getOwnPropertyDescriptor,Oe=Object.getOwnPropertyDescriptors,Fe=Object.getOwnPropertyNames,ce=Object.getOwnPropertySymbols,Ne=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var me=(a,e,t)=>e in a?H(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,C=(a,e)=>{for(var t in e||(e={}))ue.call(e,t)&&me(a,t,e[t]);if(ce)for(var t of ce(e))Ze.call(e,t)&&me(a,t,e[t]);return a},fe=(a,e)=>Ve(a,Oe(e));var Ee=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var Ye=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Fe(e))!ue.call(a,n)&&n!==t&&H(a,n,{get:()=>e[n],enumerable:!(r=Xe(e,n))||r.enumerable});return a};var qe=(a,e,t)=>(t=a!=null?Be(Ne(a)):{},Ye(e||!a||!a.__esModule?H(t,"default",{value:a,enumerable:!0}):t,a));var h=(a,e,t)=>new Promise((r,n)=>{var s=l=>{try{i(t.next(l))}catch(c){n(c)}},o=l=>{try{i(t.throw(l))}catch(c){n(c)}},i=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);i((t=t.apply(a,e)).next())});var Ue=Ee((Gt,_e)=>{_e.exports=window.L});var de={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 xe={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 E={base:{parent:void 0,name:"base",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777777",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 pe,ge,he;function be({colorStyles:a={},units:e={},colorSchemes:t={}}={}){u("WxTile lib setup: start"),pe=Object.assign({},de,e),ge=Object.assign({},t,xe);let r=Object.assign({},a,E);he=je(r),u("WxTile lib setup: styles unrolled");try{h(this,null,function*(){yield document.fonts.load("32px barbs"),yield document.fonts.load("32px arrows")})}catch(n){u("WxTile lib setup: fonts not loaded")}u("WxTile lib setup is done.")}function _(){return he}function ee(){return ge}function Y(a,e,t){u("makeConverter: From=",a," To=",e);let r=f=>f;if(r.trivial=!0,a===e)return u("Trivial converter"),r;let n=Object.assign({},pe,t),s=n[a],o=n[e];if(!s||!o)return u("Inconvertible units. Trivial converter"),r;let[i,l,c]=s,[m,d,x]=o;if(i!==m||!l||!d)return u("Inconvertible units. Trivial converter"),r;let b=l/d,p=((c||0)-(x||0))/d;return p?f=>b*f+p:f=>b*f}function je(a){let e=Object.assign({},E);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({},E.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 l=r(s,i.parent);return Object.assign(i,Object.assign({},l,i,{parent:"base"}))},n={base:t};for(let s in e)n[s]=r(e,s);return n}function U(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 Ge(a,e){return h(this,null,function*(){return createImageBitmap(yield(yield fetch(a,e)).blob())})}var Q=class{constructor(e,t,r,n){this.raw=e;this.dmin=t;this.dmax=r;this.dmul=n;this.radius=0}get integral(){return this.integral_||(this.integral_=He(this.raw))}};function R(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 ze(a){let{width:e,height:t}=a,r=R(e,t);return r.drawImage(a,0,0),r.getImageData(0,0,e,t)}function te(a,e){return h(this,null,function*(){return ze(yield Ge(a,e))})}function Ke(a){a.data[34]<1&&u("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;return new Q(t,s,o,i)}function re(a,e){return h(this,null,function*(){return Ke(yield te(a,e))})}function He(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 ye(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),l=Math.min(e,s-1,t-1-s),c=t*(s-l-1)+o,m=t*(s+l)+o,d;if(n){let y=n[c-i-1],W=n[c+i],S=n[m-i-1],D=n[m+i];d=y+D-W-S}else d=(2*i+1)*(2*l+1);let x=r[c-i-1],b=r[c+i],p=r[m-i-1],f=r[m+i],g=x+f-b-p;a.raw[s*t+o]=g/d}return a}function T(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 v(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 u("wrong color format",a),0}function A(a,e){return h(this,null,function*(){let t=yield fetch(a,e);if(!t.ok)throw new Error("error:"+a+" - "+t.statusText);return t.json()})}function ae(a,e,t){let r=a>>0&255,n=a>>8&255,s=a>>16&255,o=a>>>24,i=e>>0&255,l=e>>8&255,c=e>>16&255,m=e>>>24,d=r+t*(i-r),x=n+t*(l-n),b=s+t*(c-s),p=o+t*(m-o);return d|x<<8|b<<16|p<<24}function We(a,e,t){let r=[];for(let n=0;n<t;++n)r.push(n*(e-a)/(t-1)+a);return r}var J=!1,u=(...a)=>{};function Je(a){J=!!a,console.log("WXLOGing",J),u=typeof a=="function"?a:J?console.log:()=>{}}function ne(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 j({x:a,y:e,z:t}){return`${t}-${a}-${e}`}var Qe="A".charCodeAt(0);var $=class{constructor(){this.qtree={nodes:null};this.qtreedepth=0;u("QTree.constructor")}load(e,t){return h(this,null,function*(){try{let r=yield A(e,t);this.qtree=Se(r,{pos:0})}catch(r){throw new Error(`Failed to load QTree: ${r.message}`)}this.qtreedepth=we(this.qtree),u(`QTree.load: qtreedepth=${this.qtreedepth}`)})}check(e){let t=e.z-this.qtreedepth,r=t>=0,n=r?{x:e.x>>t,y:e.y>>t,z:this.qtreedepth}:C({},e);return De(this.qtree,n,r)}};function Se(a,e){let t=a.charCodeAt(e.pos)-Qe;e.pos++;let r=[1,2,4,8].map(n=>t&n?Se(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 De(a,e,t){return a===null?"land":t&&!e.z?"mixed":a.nodes===null?"sea":e.z?(e.z--,De(a.nodes[(e.y>>e.z&1)<<1|e.x>>e.z&1],e,t)):"mixed"}function et(a,e,t){return a>t?t:a<e?e:a}var B=class{constructor(e,t,[r,n],s){u("RawCLUT.constructor");let o=n-r;this.levelIndex=new Uint32Array(65536),this.colorsI=new Uint32Array(65536);let i=[];this.DataToStyle=Y(t,e.units,e.extraUnits),this.DataToStyle.trivial&&(e.units=t),s&&(this.DataToKnots=Y(t,"knot"));let l=Y(e.units,t,e.extraUnits),c=f=>~~(65535*et((l(f)-r)/(n-r),0,1));if(Array.isArray(e.colorMap)){e.colorMap.sort((f,g)=>f[0]<g[0]?-1:f[0]>g[0]?1:0);for(let[f]of e.colorMap)i.push(c(f))}else{if(e.levels||(e.levels=We(this.DataToStyle(r),this.DataToStyle(n),10)),e.levels.sort((f,g)=>f<g?-1:f>g?1:0),!e.colors){let f=ee();e.colorScheme&&e.colorScheme in f?e.colors=f[e.colorScheme]:e.colors=f.wb}for(let f of e.levels)i.push(c(f))}let m=65536,d=Te(m,e);this.ticks=d.ticks;let x=d.ticks[0].data,p=d.ticks[d.ticks.length-1].data-x;for(let f=0;f<65536;++f){let g=o*f/65535+r,y=this.DataToStyle(g),W=Math.round((m-1)*(y-x)/p);W<=0?this.colorsI[f]=e.showBelowMin?d.colors[0]:0:W>=m?this.colorsI[f]=e.showAboveMax?d.colors[m-1]:0:this.colorsI[f]=d.colors[W]}this.colorsI[0]=0;for(let f=0;f<i[0];++f)this.levelIndex[f]=0;for(let f=0;f<i.length-1;f++)for(let g=i[f];g<i[f+1]+1;++g)this.levelIndex[g]=f;for(let f=i[i.length-1];f<65536;++f)this.levelIndex[f]=i.length-1}};function Me(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 Te(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 x=r[0][0],b=r[r.length-1][0]-x;for(let[p,f]of r){let g=~~((p-x)/b*(a-1)),y={data:p,dataString:Me(p),color:f,pos:g};t.ticks.push(y)}for(let p=0;p<r.length-1;p++){let f=t.ticks[p].pos,g=t.ticks[p+1].pos,y=v(r[p][1]),W=o?v(r[p+1][1]):0;for(let S=f;S<g;++S)t.colors[S]=o?ae(y,W,(S-f)/(g-f)):y}return t.colors[a-1]=v(r[r.length-1][1]),t}if(!s||!n)return t;let i=0,l=0,c=-1;for(let x=0;x<a;++x){let b=x*(s.length-1)/a;c!==~~b&&(c=~~b,i=v(s[c]),l=s.length>c+1?v(s[c+1]):i),t.colors[x]=o?ae(i,l,b-c):i}t.colors[a-1]=v(s[s.length-1]);let m=n[0],d=(a-1)/(n[n.length-1]-m);for(let x of n){let b=~~((x-m)*d),p={data:x,dataString:Me(x),color:T(t.colors[b]),pos:b};t.ticks.push(p)}return t}var tt=2*Math.PI*6378137/256,G=2*Math.PI*6378137/2;function rt(a,e){let t=a/G*180,r=e/G*180;return r=180/Math.PI*(2*Math.atan(Math.exp(r*Math.PI/180))-Math.PI/2),[r,t]}function at(a,e,t){let r=nt(t),n=a*r-G,s=e*r-G;return[n,s]}function nt(a){return tt/Math.pow(2,a)}function se(a,e,t){let[r,n]=rt(...at(a,e,t));return[n,-r]}function Ce(a,e){return[a*256,e*256]}function oe(a,e,t){let r=((e-a)%360+540)%360-180;return(a+r*t+360)%360}function st(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 c=oe(a,e,n),m=oe(t,r,n);return(oe(c,m,s)-o)/i||1}function Le(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 ve(a,e,t){let r=1/Math.pow(2,t.z),n=t.x*256*r-.5,s=t.y*256*r-.5,{raw:o,dmin:i,dmax:l,dmul:c}=e,m={raw:new Uint16Array(258*258),dmin:i,dmax:l,dmul:c},{raw:d}=m;for(let x=-1,b=0,p=s-r+1;x<=256;x++,p+=r){let f=Math.floor(p),g=p-f,y=f*258;for(let W=-1,S=n-r+1;W<=256;W++,b++,S+=r){let D=Math.floor(S),M=S-D,w=D+y,L=o[w],I=o[w+1],P=o[w+258],k=o[w+258+1];d[b]=a(L,I,P,k,M,g,i,c)}}return m}function Ie(a,e,t){if(!e)return a;let r=m=>m<0?0:m>254?254:m,n=1/Math.pow(2,e.z),s=e.x*256*n-.5,o=e.y*256*n-.5,{data:i}=a,l=new ImageData(256,256),{data:c}=l;for(let m=0,d=t,x=o;m<256;m++,x+=n){let b=~~r(x),p=x-b,f=b*256;for(let g=0,y=s;g<256;g++,d+=4,y+=n){let W=~~r(y),S=y-W,D=(W+f)*4+t,M=i[D],w=i[D+4],L=i[D+4*256],I=i[D+4*256+4],P=Le(M,w,L,I,S,p,0,0);c[d]=P>127?255:0}}return l}function Pe(a,e){return e?ve(Le,a,e):a}function ke(a,e){return e?ve(st,a,e):a}function Ae(a,{data:e},t,r){let n=r==="sea",{raw:s}=a;for(let o=t,i=259,l=0;l<256;i+=2,l++)for(let c=0;c<256;c++,i++,o+=4)n===!e[o]&&(s[i]=0);return a}function Re(a){let[e,t]=Ce(a.x,a.y),[r,n]=se(e,t,a.z),[s,o]=se(e+256,t+256,a.z);return{west:r,north:n,east:s,south:o}}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 V=class{constructor(e){this.loadDataFunc=U(re);this.layer=e}load(e,t){return h(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,l=i==="degree"?ke:Pe,c=d=>l(ye(d,this.layer.style.blurRadius),s),m=n.map(c);return this._vectorMagnitudesPrepare(m),yield this._applyMask(m,e,o,!s&&n.length===1),{data:m,slines:this._createStreamLines(m)}})}cacheLoad(e,t,r){return h(this,null,function*(){if(!this._checkInsideBoundaries(e))return null;let n=this._checkTypeAndMask(e);if(!n)return null;let{upCoords:s,subCoords:o}=ie(e,this.layer.wxdatasetManager.getMaxZoom()),i=t.map(m=>q(m,s)),l=Object.assign({},this.layer.wxdatasetManager.wxapi.requestInit,{signal:r==null?void 0:r.signal});return{rawdata:yield Promise.all(i.map(m=>this.loadDataFunc(m,l))),subCoords:o,tileType:n}})}clearCache(){this.loadDataFunc=U(re)}_applyMask(e,t,r,n){return h(this,null,function*(){let{style:s}=this.layer;if((s.mask==="land"||s.mask==="sea")&&r==="mixed"){if(n){let{raw:i,dmin:l,dmax:c,dmul:m}=e[0];e[0]={raw:new Uint16Array(i),dmin:l,dmax:c,dmul:m}}let o;try{let{upCoords:i,subCoords:l}=ie(t,this.layer.wxdatasetManager.wxapi.maskDepth);o=yield this.layer.wxdatasetManager.wxapi.loadMaskFunc(i),o=Ie(o,l,this.layer.wxdatasetManager.wxapi.maskChannel)}catch(i){s.mask=void 0,u("Can't load Mask. Masking is disabled");return}Ae(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;if(t==="land"||t==="sea"){let r=this.layer.wxdatasetManager.wxapi.qtree.check(e);return t===r?void 0:r}return"mixed"}_checkInsideBoundaries(e){let t=this.layer.wxdatasetManager.getBoundaries();if(t!=null&&t.boundaries180){let r=Re(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,l=t.addDegrees?.017453292519943*t.addDegrees:0,c=t.streamLineGridStep||64,m=t.streamLineSteps||300;for(let d=0;d<=256;d+=c)for(let x=0;x<=256;x+=c){if(!n.raw[1+x+(1+d)*258])continue;let b=[],p=x,f=d,g=-1,y=0,W=0;for(let M=0;M<=m&&p>=0&&p<=256&&f>=0&&f<=256;M++){M%(m/10)||b.push({x:~~p,y:~~f});let w=~~p+1+(~~f+1)*258;if(w!==g){if(!n.raw[w])break;g=w;let L=n.dmin+n.raw[w]*n.dmul,I=s.dmin+s.raw[w]*s.dmul,P=o.dmin+o.raw[w]*o.dmul,k=Math.atan2(I,P)+l;y=i*L*Math.sin(k),W=i*L*Math.cos(k)}p+=y,f-=W}let S=x,D=d;g=-1;for(let M=1;M<=m&&S>=0&&S<=256&&D>=0&&D<=256;M++){M%(m/10)||b.unshift({x:~~S,y:~~D});let w=~~S+1+(~~D+1)*258;if(w!==g){if(!n.raw[w])break;g=w;let L=n.dmin+n.raw[w]*n.dmul,I=s.dmin+s.raw[w]*s.dmul,P=o.dmin+o.raw[w]*o.dmul,k=Math.atan2(I,P)+l;y=i*L*Math.sin(k),W=i*L*Math.cos(k)}S-=y,D+=W}b.length>2&&r.push(b)}return r}};var X=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),l=new Uint32Array(i.data.buffer);t.clearRect(0,0,256,256),r.clearRect(0,0,256,256),n.clearRect(0,0,256,256),ot(e.data[0],l,s);let c=it(l,e.data[0],s);t.putImageData(i,0,0),lt(c,r,s),ct(e.data,r,s),mt(e.data[0],r,o,s),ut(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")&&ft(e,r,s,n)}};function ot(a,e,{CLUT:t,style:r}){let{raw:n}=a,{colorsI:s}=t;if(r.fill!=="none")for(let o=0,i=0,l=259;o<256;++o,l+=2)for(let c=0;c<256;++c,++i,++l)e[i]=s[n[l]];else e.fill(0)}function it(a,e,{CLUT:t,style:r}){let{raw:n}=e,{levelIndex:s,colorsI:o}=t,i=[];if(r.isolineColor!=="none"){let l=r.isolineColor[0]==="#"?v(r.isolineColor):0;for(let c=0,m=0;c<256;c+=1)for(let d=0;d<256;d+=1){let x=(c+1)*258+(d+1),b=n[x],p=n[x+1],f=n[x+258];if(!b||!p||!f)continue;let g=s[b],y=s[p],W=s[f];if(g!==y||g!==W){let S=Math.max(g,y,W),D=Math.max(b,p,f),M=c*256+d;switch(r.isolineColor){case"inverted":a[M]=~o[D]|4278190080;break;case"fill":a[M]=o[D]|4278190080;break;default:a[M]=l;break}r.isolineText&&!(++m%255)&&d>20&&d<235&&c>20&&c<235&&i.push({x:d,y:c,d:b,dr:p,db:f,mli:S})}}}return i}function lt(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:l}of a){let c=t.ticks[l].dataString,m=Math.atan2(s-o,i-s);e.save(),e.translate(r,n),e.rotate(m<-1.57||m>1.57?m+3.14:m),e.strokeText(c,0,0),e.fillText(c,0,0),e.restore()}}}function ct(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,l=32;for(let c=l/2;c<256;c+=l)for(let m=l/2;m<256;m+=l){let d=m+1+(c+1)*258;if(!n.raw[d])continue;let x=Math.atan2(s.dmin+s.raw[d]*s.dmul,o.dmin+o.raw[d]*o.dmul),b=n.dmin+n.raw[d]*n.dmul,p=r.vectorType!=="barbs"?r.vectorFactor*.2:.2,f=Math.min(t.DataToKnots(b)*p,25)+65,g=String.fromCharCode(f);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(m,c),e.rotate(x+i),e.fillText(g,0,0),e.restore()}}function mt(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 l=i/2;l<256;l+=i)for(let c=i/2;c<256;c+=i){let m=c+1+(l+1)*258;if(!a.raw[m])continue;let x=(a.dmin+a.raw[m]*a.dmul+180)*.01745329251;switch(n.vectorColor){case"inverted":e.fillStyle=T(~r.colorsI[a.raw[m]]);break;case"fill":e.fillStyle=T(r.colorsI[a.raw[m]]);break}e.save(),e.translate(c,l),e.rotate(x+s),e.fillText(o,0,0),e.restore()}}function ut(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,r.streamLineColor[0]==="#"&&(e.strokeStyle=ne(r.streamLineColor));for(let i=s.length;i--;){let l=s[i];for(let c=0;c<l.length-1;++c){let m=l[c],d=l[c+1],x=m.x+1+(m.y+1)*258;switch(r.streamLineColor){case"inverted":e.strokeStyle=T(~t.colorsI[o.raw[x]]);break;case"fill":e.strokeStyle=T(t.colorsI[o.raw[x]]);break}e.beginPath(),e.moveTo(m.x,m.y),e.lineTo(d.x,d.y),e.stroke()}}}function ft(a,e,{CLUT:t,style:r},n){let{data:s,slines:o}=a,i=s[0],l=r.streamLineColor[0]==="#"?ne(r.streamLineColor).substring(0,7):"#000000";n=n>>5;for(let c=0;c<o.length;++c){let m=o[c],d=m.length-1,x=(n+(1+m[0].x)*(1+m[0].y))%30;for(let b=0;b<d;++b){let p=m[b],f=m[b+1],g=1-(x-b)/d;(g<0||g>1)&&(g=0);let y=(~~(g*255)).toString(16).padStart(2,"0"),W=1+~~((1.2-g)*5);e.lineWidth=W;let S=p.x+1+(p.y+1)*258;switch(r.streamLineColor){case"inverted":l=T(~t.colorsI[i.raw[S]]);break;case"fill":l=T(t.colorsI[i.raw[S]]);break}e.strokeStyle=l+y,e.beginPath(),e.moveTo(p.x,p.y),e.lineTo(f.x,f.y),e.stroke()}}}var O=class{constructor(e){this.tilesCache=new Map;this.painter=new X(this);this.loader=new V(this);var s;if(u(`WxLayer.constructor:
|
|
1
|
+
var Be=Object.create;var J=Object.defineProperty,Ne=Object.defineProperties,Xe=Object.getOwnPropertyDescriptor,Oe=Object.getOwnPropertyDescriptors,Fe=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols,Ze=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable;var ue=(a,e,t)=>e in a?J(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,C=(a,e)=>{for(var t in e||(e={}))de.call(e,t)&&ue(a,t,e[t]);if(me)for(var t of me(e))Ee.call(e,t)&&ue(a,t,e[t]);return a},fe=(a,e)=>Ne(a,Oe(e));var Ye=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var qe=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Fe(e))!de.call(a,n)&&n!==t&&J(a,n,{get:()=>e[n],enumerable:!(r=Xe(e,n))||r.enumerable});return a};var je=(a,e,t)=>(t=a!=null?Be(Ze(a)):{},qe(e||!a||!a.__esModule?J(t,"default",{value:a,enumerable:!0}):t,a));var p=(a,e,t)=>new Promise((r,n)=>{var s=l=>{try{o(t.next(l))}catch(c){n(c)}},i=l=>{try{o(t.throw(l))}catch(c){n(c)}},o=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,i);o((t=t.apply(a,e)).next())});var $e=Ye((zt,Ue)=>{Ue.exports=window.L});var xe={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 ge={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 E={base:{parent:void 0,name:"base",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777777",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 he,pe,be;function ye({colorStyles:a={},units:e={},colorSchemes:t={}}={}){m("WxTile lib setup: start"),he=Object.assign({},xe,e),pe=Object.assign({},t,ge);let r=Object.assign({},a,E);be=Ge(r),m("WxTile lib setup: styles unrolled");try{p(this,null,function*(){yield document.fonts.load("32px barbs"),yield document.fonts.load("32px arrows")})}catch(n){m("WxTile lib setup: fonts not loaded")}m("WxTile lib setup is done.")}function _(){return be}function te(){return pe}function Y(a,e,t){m("makeConverter: From=",a," To=",e);let r=d=>d;if(r.trivial=!0,a===e)return m("Trivial converter"),r;let n=Object.assign({},he,t),s=n[a],i=n[e];if(!s||!i)return m("Inconvertible units. Trivial converter"),r;let[o,l,c]=s,[u,f,x]=i;if(o!==u||!l||!f)return m("Inconvertible units. Trivial converter"),r;let b=l/f,g=((c||0)-(x||0))/f;return g?d=>b*d+g:d=>b*d}function Ge(a){let e=Object.assign({},E);for(let s in a){let i=a[s];if(Array.isArray(i))for(let o=0;o<i.length;++o)e[s+"["+o+"]"]=Object.assign({},i[o]);else e[s]=Object.assign({},i)}let t=Object.assign({},E.base),r=(s,i)=>{if(i==="base")return t;let o=s[i];if(!o)return t;(!o.parent||!(o.parent in s))&&(o.parent="base");let l=r(s,o.parent);return Object.assign(o,Object.assign({},l,o,{parent:"base"}))},n={base:t};for(let s in e)n[s]=r(e,s);return n}function U(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(i=>i.name==="AbortError"&&e.delete(t)),s}}function ze(a,e){return p(this,null,function*(){return createImageBitmap(yield(yield fetch(a,e)).blob())})}var ee=class{constructor(e,t,r,n){this.raw=e;this.dmin=t;this.dmax=r;this.dmul=n;this.radius=0}get integral(){return this.integral_||(this.integral_=Je(this.raw))}};function R(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 Ke(a){let{width:e,height:t}=a,r=R(e,t);return r.drawImage(a,0,0),r.getImageData(0,0,e,t)}function re(a,e){return p(this,null,function*(){return Ke(yield ze(a,e))})}function He(a){a.data[34]<1&&m("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),i=n.getFloat32(4,!0),o=(i-s)/65535;return new ee(t,s,i,o)}function ae(a,e){return p(this,null,function*(){return He(yield re(a,e))})}function Je(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 We(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 i=1;i<t;i++){if(!a.raw[t*s+i])continue;let o=Math.min(e,i-1,t-1-i),l=Math.min(e,s-1,t-1-s),c=t*(s-l-1)+i,u=t*(s+l)+i,f;if(n){let y=n[c-o-1],W=n[c+o],w=n[u-o-1],M=n[u+o];f=y+M-W-w}else f=(2*o+1)*(2*l+1);let x=r[c-o-1],b=r[c+o],g=r[u-o-1],d=r[u+o],h=x+d-b-g;a.raw[s*t+i]=h/f}return a}function T(a){let e=a>>0&255,t=a>>8&255,r=a>>16&255,n=e.toString(16),s=t.toString(16),i=r.toString(16);return n=n.length===2?n:"0"+n,s=s.length===2?s:"0"+s,i=i.length===2?i:"0"+i,"#"+n+s+i}function L(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 m("wrong color format",a),0}function A(a,e){return p(this,null,function*(){let t=yield fetch(a,e);if(!t.ok)throw new Error("error:"+a+" - "+t.statusText);return t.json()})}function ne(a,e,t){let r=a>>0&255,n=a>>8&255,s=a>>16&255,i=a>>>24,o=e>>0&255,l=e>>8&255,c=e>>16&255,u=e>>>24,f=r+t*(o-r),x=n+t*(l-n),b=s+t*(c-s),g=i+t*(u-i);return f|x<<8|b<<16|g<<24}function we(a,e,t){let r=[];for(let n=0;n<t;++n)r.push(n*(e-a)/(t-1)+a);return r}var Q=!1,m=(...a)=>{};function Qe(a){Q=!!a,console.log("WXLOGing",Q),m=typeof a=="function"?a:Q?console.log:()=>{}}function se(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 j({x:a,y:e,z:t}){return`${t}-${a}-${e}`}var et="A".charCodeAt(0);var $=class{constructor(){this.qtree={nodes:null};this.qtreedepth=0;m("QTree.constructor")}load(e,t){return p(this,null,function*(){try{let r=yield A(e,t);this.qtree=Se(r,{pos:0})}catch(r){throw new Error(`Failed to load QTree: ${r.message}`)}this.qtreedepth=Me(this.qtree),m(`QTree.load: qtreedepth=${this.qtreedepth}`)})}check(e){let t=e.z-this.qtreedepth,r=t>=0,n=r?{x:e.x>>t,y:e.y>>t,z:this.qtreedepth}:C({},e);return De(this.qtree,n,r)}};function Se(a,e){let t=a.charCodeAt(e.pos)-et;e.pos++;let r=[1,2,4,8].map(n=>t&n?Se(a,e):null);return{nodes:r.some(n=>n)?r:null}}function Me(a){return a!=null&&a.nodes?1+Math.max(...a.nodes.map(Me)):0}function De(a,e,t){return a===null?"land":t&&!e.z?"mixed":a.nodes===null?"sea":e.z?(e.z--,De(a.nodes[(e.y>>e.z&1)<<1|e.x>>e.z&1],e,t)):"mixed"}function tt(a,e,t){return a>t?t:a<e?e:a}var V=class{constructor(e,t,[r,n],s){m("RawCLUT.constructor");let i=n-r;this.levelIndex=new Uint32Array(65536),this.colorsI=new Uint32Array(65536);let o=[];this.DataToStyle=Y(t,e.units,e.extraUnits),this.DataToStyle.trivial&&(e.units=t),s&&(this.DataToKnots=Y(t,"knot"));let l=Y(e.units,t,e.extraUnits),c=d=>~~(65535*tt((l(d)-r)/(n-r),0,1));if(Array.isArray(e.colorMap)){e.colorMap.sort((d,h)=>d[0]<h[0]?-1:d[0]>h[0]?1:0);for(let[d]of e.colorMap)o.push(c(d))}else{if(e.levels||(e.levels=we(this.DataToStyle(r),this.DataToStyle(n),10)),e.levels.sort((d,h)=>d<h?-1:d>h?1:0),!e.colors){let d=te();e.colorScheme&&e.colorScheme in d?e.colors=d[e.colorScheme]:e.colors=d.wb}for(let d of e.levels)o.push(c(d))}let u=65536,f=Ce(u,e);this.ticks=f.ticks;let x=f.ticks[0].data,g=f.ticks[f.ticks.length-1].data-x;for(let d=0;d<65536;++d){let h=i*d/65535+r,y=this.DataToStyle(h),W=Math.round((u-1)*(y-x)/g);W<=0?this.colorsI[d]=e.showBelowMin?f.colors[0]:0:W>=u?this.colorsI[d]=e.showAboveMax?f.colors[u-1]:0:this.colorsI[d]=f.colors[W]}this.colorsI[0]=0;for(let d=0;d<o[0];++d)this.levelIndex[d]=0;for(let d=0;d<o.length-1;d++)for(let h=o[d];h<o[d+1]+1;++h)this.levelIndex[h]=d;for(let d=o[o.length-1];d<65536;++d)this.levelIndex[d]=o.length-1}};function Te(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 Ce(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,i=e.fill!=="solid";if(r){let x=r[0][0],b=r[r.length-1][0]-x;for(let[g,d]of r){let h=~~((g-x)/b*(a-1)),y={data:g,dataString:Te(g),color:d,pos:h};t.ticks.push(y)}for(let g=0;g<r.length-1;g++){let d=t.ticks[g].pos,h=t.ticks[g+1].pos,y=L(r[g][1]),W=i?L(r[g+1][1]):0;for(let w=d;w<h;++w)t.colors[w]=i?ne(y,W,(w-d)/(h-d)):y}return t.colors[a-1]=L(r[r.length-1][1]),t}if(!s||!n)return t;let o=0,l=0,c=-1;for(let x=0;x<a;++x){let b=x*(s.length-1)/a;c!==~~b&&(c=~~b,o=L(s[c]),l=s.length>c+1?L(s[c+1]):o),t.colors[x]=i?ne(o,l,b-c):o}t.colors[a-1]=L(s[s.length-1]);let u=n[0],f=(a-1)/(n[n.length-1]-u);for(let x of n){let b=~~((x-u)*f),g={data:x,dataString:Te(x),color:T(t.colors[b]),pos:b};t.ticks.push(g)}return t}var rt=2*Math.PI*6378137/256,G=2*Math.PI*6378137/2;function at(a,e){let t=a/G*180,r=e/G*180;return r=180/Math.PI*(2*Math.atan(Math.exp(r*Math.PI/180))-Math.PI/2),[r,t]}function nt(a,e,t){let r=st(t),n=a*r-G,s=e*r-G;return[n,s]}function st(a){return rt/Math.pow(2,a)}function ie(a,e,t){let[r,n]=at(...nt(a,e,t));return[n,-r]}function Ie(a,e){return[a*256,e*256]}function oe(a,e,t){let r=((e-a)%360+540)%360-180;return(a+r*t+360)%360}function it(a,e,t,r,n,s,i,o){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=i+o*a,e=i+o*e,t=i+o*t,r=i+o*r;let c=oe(a,e,n),u=oe(t,r,n);return(oe(c,u,s)-i)/o||1}function Le(a,e,t,r,n,s,i,o){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 ve(a,e,t){let r=1/Math.pow(2,t.z),n=t.x*256*r-.5,s=t.y*256*r-.5,{raw:i,dmin:o,dmax:l,dmul:c}=e,u={raw:new Uint16Array(258*258),dmin:o,dmax:l,dmul:c},{raw:f}=u;for(let x=-1,b=0,g=s-r+1;x<=256;x++,g+=r){let d=Math.floor(g),h=g-d,y=d*258;for(let W=-1,w=n-r+1;W<=256;W++,b++,w+=r){let M=Math.floor(w),D=w-M,S=M+y,I=i[S],v=i[S+1],P=i[S+258],k=i[S+258+1];f[b]=a(I,v,P,k,D,h,o,c)}}return u}function Pe(a,e,t){if(!e)return a;let r=u=>u<0?0:u>254?254:u,n=1/Math.pow(2,e.z),s=e.x*256*n-.5,i=e.y*256*n-.5,{data:o}=a,l=new ImageData(256,256),{data:c}=l;for(let u=0,f=t,x=i;u<256;u++,x+=n){let b=~~r(x),g=x-b,d=b*256;for(let h=0,y=s;h<256;h++,f+=4,y+=n){let W=~~r(y),w=y-W,M=(W+d)*4+t,D=o[M],S=o[M+4],I=o[M+4*256],v=o[M+4*256+4],P=Le(D,S,I,v,w,g,0,0);c[f]=P>127?255:0}}return l}function ke(a,e){return e?ve(Le,a,e):a}function Ae(a,e){return e?ve(it,a,e):a}function Re(a,{data:e},t,r){let n=r==="sea",{raw:s}=a;for(let i=t,o=259,l=0;l<256;o+=2,l++)for(let c=0;c<256;c++,o++,i+=4)n===!e[i]&&(s[o]=0);return a}function _e(a){let[e,t]=Ie(a.x,a.y),[r,n]=ie(e,t,a.z),[s,i]=ie(e+256,t+256,a.z);return{west:r,north:n,east:s,south:i}}function le(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 B=class{constructor(e){this.loadDataFunc=U(ae);this.layer=e,this.wxAPI=e.wxdatasetManager.wxAPI}load(e,t){return p(this,null,function*(){let r=yield this.cacheLoad(e,this.layer.tilesURIs,t);if(!r)return null;let{rawdata:n,subCoords:s,tileType:i}=r,{units:o}=this.layer.currentVariableMeta,l=o==="degree"?Ae:ke,c=f=>l(We(f,this.layer.style.blurRadius),s),u=n.map(c);return this._vectorMagnitudesPrepare(u),yield this._applyMask(u,e,i,!s&&n.length===1),{data:u,slines:this._createStreamLines(u)}})}cacheLoad(e,t,r){return p(this,null,function*(){if(!this._checkInsideBoundaries(e))return null;let n=this._checkTypeAndMask(e);if(!n)return null;let{upCoords:s,subCoords:i}=le(e,this.layer.getMaxZoom()),o=t.map(u=>q(u,s)),l=Object.assign({},this.wxAPI.requestInit,{signal:r==null?void 0:r.signal});return{rawdata:yield Promise.all(o.map(u=>this.loadDataFunc(u,l))),subCoords:i,tileType:n}})}clearCache(){this.loadDataFunc=U(ae)}_applyMask(e,t,r,n){return p(this,null,function*(){let{style:s}=this.layer;if((s.mask==="land"||s.mask==="sea")&&r==="mixed"){if(n){let{raw:o,dmin:l,dmax:c,dmul:u}=e[0];e[0]={raw:new Uint16Array(o),dmin:l,dmax:c,dmul:u}}let i;try{let{upCoords:o,subCoords:l}=le(t,this.wxAPI.maskDepth);i=yield this.wxAPI.loadMaskFunc(o),i=Pe(i,l,this.wxAPI.maskChannel)}catch(o){s.mask=void 0,m("Can't load Mask. Masking is disabled");return}Re(e[0],i,this.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 i=r.dmin+r.dmul*r.raw[s],o=n.dmin+n.dmul*n.raw[s];t.raw[s]=Math.sqrt(o*o+i*i)/t.dmul}}_checkTypeAndMask(e){let{mask:t}=this.layer.style;if(t==="land"||t==="sea"){let r=this.wxAPI.qtree.check(e);return t===r?void 0:r}return"mixed"}_checkInsideBoundaries(e){let t=this.layer.getBoundaries();if(t!=null&&t.boundaries180){let r=_e(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,i]=e,o=(t.streamLineSpeedFactor||1)/n.dmax,l=t.addDegrees?.017453292519943*t.addDegrees:0,c=t.streamLineGridStep||64,u=t.streamLineSteps||300;for(let f=0;f<=256;f+=c)for(let x=0;x<=256;x+=c){if(!n.raw[1+x+(1+f)*258])continue;let b=[],g=x,d=f,h=-1,y=0,W=0;for(let D=0;D<=u&&g>=0&&g<=256&&d>=0&&d<=256;D++){D%(u/10)||b.push({x:~~g,y:~~d});let S=~~g+1+(~~d+1)*258;if(S!==h){if(!n.raw[S])break;h=S;let I=n.dmin+n.raw[S]*n.dmul,v=s.dmin+s.raw[S]*s.dmul,P=i.dmin+i.raw[S]*i.dmul,k=Math.atan2(v,P)+l;y=o*I*Math.sin(k),W=o*I*Math.cos(k)}g+=y,d-=W}let w=x,M=f;h=-1;for(let D=1;D<=u&&w>=0&&w<=256&&M>=0&&M<=256;D++){D%(u/10)||b.unshift({x:~~w,y:~~M});let S=~~w+1+(~~M+1)*258;if(S!==h){if(!n.raw[S])break;h=S;let I=n.dmin+n.raw[S]*n.dmul,v=s.dmin+s.raw[S]*s.dmul,P=i.dmin+i.raw[S]*i.dmul,k=Math.atan2(v,P)+l;y=o*I*Math.sin(k),W=o*I*Math.cos(k)}w-=y,M+=W}b.length>2&&r.push(b)}return r}};var N=class{constructor(e){this.layer=e}paint({data:e,ctxFill:t,ctxText:r,ctxStreamLines:n}){let{layer:s}=this,{units:i}=s.currentVariableMeta,o=new ImageData(256,256),l=new Uint32Array(o.data.buffer);t.clearRect(0,0,256,256),r.clearRect(0,0,256,256),n.clearRect(0,0,256,256),ot(e.data[0],l,s);let c=lt(l,e.data[0],s);t.putImageData(o,0,0),ct(c,r,s),mt(e.data,r,s),ut(e.data[0],r,i,s),dt(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")&&ft(e,r,s,n)}};function ot(a,e,{CLUT:t,style:r}){let{raw:n}=a,{colorsI:s}=t;if(r.fill!=="none")for(let i=0,o=0,l=259;i<256;++i,l+=2)for(let c=0;c<256;++c,++o,++l)e[o]=s[n[l]];else e.fill(0)}function lt(a,e,{CLUT:t,style:r}){let{raw:n}=e,{levelIndex:s,colorsI:i}=t,o=[];if(r.isolineColor!=="none"){let l=r.isolineColor[0]==="#"?L(r.isolineColor):0;for(let c=0,u=0;c<256;c+=1)for(let f=0;f<256;f+=1){let x=(c+1)*258+(f+1),b=n[x],g=n[x+1],d=n[x+258];if(!b||!g||!d)continue;let h=s[b],y=s[g],W=s[d];if(h!==y||h!==W){let w=Math.max(h,y,W),M=Math.max(b,g,d),D=c*256+f;switch(r.isolineColor){case"inverted":a[D]=~i[M]|4278190080;break;case"fill":a[D]=i[M]|4278190080;break;default:a[D]=l;break}r.isolineText&&!(++u%255)&&f>20&&f<235&&c>20&&c<235&&o.push({x:f,y:c,d:b,dr:g,db:d,mli:w})}}}return o}function ct(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:i,db:o,mli:l}of a){let c=t.ticks[l].dataString,u=Math.atan2(s-i,o-s);e.save(),e.translate(r,n),e.rotate(u<-1.57||u>1.57?u+3.14:u),e.strokeText(c,0,0),e.fillText(c,0,0),e.restore()}}}function mt(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,i]=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 o=r.addDegrees?.017453292519943*r.addDegrees:0,l=32;for(let c=l/2;c<256;c+=l)for(let u=l/2;u<256;u+=l){let f=u+1+(c+1)*258;if(!n.raw[f])continue;let x=Math.atan2(s.dmin+s.raw[f]*s.dmul,i.dmin+i.raw[f]*i.dmul),b=n.dmin+n.raw[f]*n.dmul,g=r.vectorType!=="barbs"?r.vectorFactor*.5:.2,d=Math.min(~~(t.DataToKnots(b)*g),25)+65,h=String.fromCharCode(d);switch(r.vectorColor){case"inverted":e.fillStyle=T(~t.colorsI[n.raw[f]]);break;case"fill":e.fillStyle=T(t.colorsI[n.raw[f]]);break}e.save(),e.translate(u,c),e.rotate(x+o),e.fillText(h,0,0),e.restore()}}function ut(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 i="L",o=32;for(let l=o/2;l<256;l+=o)for(let c=o/2;c<256;c+=o){let u=c+1+(l+1)*258;if(!a.raw[u])continue;let x=(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(c,l),e.rotate(x+s),e.fillText(i,0,0),e.restore()}}function dt(a,e,{CLUT:t,style:r}){let{data:n,slines:s}=a;if(!s.length||!r.streamLineStatic||r.streamLineColor==="none")return;let i=n[0];e.lineWidth=1,r.streamLineColor[0]==="#"&&(e.strokeStyle=se(r.streamLineColor));for(let o=s.length;o--;){let l=s[o];for(let c=0;c<l.length-1;++c){let u=l[c],f=l[c+1],x=u.x+1+(u.y+1)*258;switch(r.streamLineColor){case"inverted":e.strokeStyle=T(~t.colorsI[i.raw[x]]);break;case"fill":e.strokeStyle=T(t.colorsI[i.raw[x]]);break}e.beginPath(),e.moveTo(u.x,u.y),e.lineTo(f.x,f.y),e.stroke()}}}function ft(a,e,{CLUT:t,style:r},n){let{data:s,slines:i}=a,o=s[0],l=r.streamLineColor[0]==="#"?se(r.streamLineColor).substring(0,7):"#000000";n=n>>5;for(let c=0;c<i.length;++c){let u=i[c],f=u.length-1,x=(n+(1+u[0].x)*(1+u[0].y))%30;for(let b=0;b<f;++b){let g=u[b],d=u[b+1],h=1-(x-b)/f;(h<0||h>1)&&(h=0);let y=(~~(h*255)).toString(16).padStart(2,"0"),W=1+~~((1.2-h)*5);e.lineWidth=W;let w=g.x+1+(g.y+1)*258;switch(r.streamLineColor){case"inverted":l=T(~t.colorsI[o.raw[w]]);break;case"fill":l=T(t.colorsI[o.raw[w]]);break}e.strokeStyle=l+y,e.beginPath(),e.moveTo(g.x,g.y),e.lineTo(d.x,d.y),e.stroke()}}}var z=class extends Map{clear(){m("TilesCache.clear()"),this.forEach(e=>{!e.rd||(e.rd.gl.deleteTexture(e.rd.vectorTextureU),e.rd.gl.deleteTexture(e.rd.vectorTextureV))}),super.clear()}},X=class{constructor(e){this.tilesCache=new z;this.painter=new N(this);var s;if(m(`WxLayer.constructor:
|
|
2
2
|
datasetName: ${e.wxdatasetManager.datasetName},
|
|
3
3
|
variables: ${e.variables.join(", ")},
|
|
4
4
|
wxstyleName: ${e.wxstyleName},
|
|
5
5
|
wxstyle: ${JSON.stringify(e.wxstyle)},
|
|
6
|
-
time: ${e.time}`),!((s=e.variables)!=null&&s.length)||e.variables.length>2)throw new Error(`datasetName: ${e.wxdatasetManager.datasetName}: only 1 or 2 variables are supported but ${e.variables} was given`);e.variables.forEach(o=>{if(!e.wxdatasetManager.checkVariableValid(o))throw new Error(`datasetName: ${e.wxdatasetManager.datasetName}: variable ${o} is not valid`)}),this.variables=e.variables,this.wxdatasetManager=e.wxdatasetManager,this.ext=e.ext||"png",this.currentMeta=this._getCurrentMeta(),[this.tilesURIs,this.time]=this._createURLsAndTime(e.time);let t=_(),r=t.base,n=e.wxstyleName&&t[e.wxstyleName];[this.style,this.CLUT]=this._createStyleAndCLUT(C(C(C({},r),n),e.wxstyle))}get nonanimatable(){return u("WxLayer.nonanimatabl()"),this.variables.length<2||this.style.streamLineStatic||this.style.streamLineColor==="none"}getTime(){return u("WxLayer.getTime"),this.time}clearCache(){u("WxLayer.clearCache"),this.tilesCache.clear(),this.loader.clearCache()}getCurrentStyleObjectCopy(){return u("WxLayer.getCurrentStyleObjectCopy"),Object.assign({},this.style)}updateCurrentStyleObject(e){u(`WxLayer.updateCurrentStyleObject ${JSON.stringify(e)}`),[this.style,this.CLUT]=this._createStyleAndCLUT(e)}getTileData(e,t){let r=this.tilesCache.get(j(e));if(!r)return;let n=this._getPixelInfo(t,r.data.data);if(!n)return;let{raw:s,data:o}=n,i=s.map(m=>this.CLUT.colorsI[m]),l=i.map(T),c=o.map(m=>this.CLUT.DataToStyle(m));return{data:o,raw:s,rgba:i,hexColor:l,inStyleUnits:c,tilePoint:t,styleUnits:this.style.units,dataUnits:this.currentMeta.units}}setURLsAndTime(e){u(`WxLayer.setURLsAndTime time=${e}`),[this.tilesURIs,this.time]=this._createURLsAndTime(e)}loadTile(e,t){return h(this,null,function*(){return this._loadCacheDrawTile(e,this.tilesCache,t).catch(()=>null)})}preloadTime(e,t,r){return h(this,null,function*(){u(`WxLayer.preloadTime time=${e}`);let[n]=this._createURLsAndTime(e);yield Promise.allSettled(t.map(s=>this.loader.cacheLoad(s,n,r)))})}reloadTiles(e,t){return h(this,null,function*(){var n;u("WxLayer.reloadTiles");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 h(this,null,function*(){let n=t.get(j(e));if(n)return n;let s=yield this.loader.load(e,r);if(!s)return null;let o=R(256,256),i=o,l=this.variables.length===2?R(256,256):o,c={ctxFill:o,ctxText:i,ctxStreamLines:l,data:s};return this.painter.paint(c),t.set(j(e),c),c})}_createStyleAndCLUT(e){let t=Object.assign(this.getCurrentStyleObjectCopy(),e),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(`WxLayer ${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;u(`WxLayer._getPixelInfo x=${e} y=${t}`);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 B(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 $e=qe(Ue()),F=class extends $e.default.GridLayer{constructor(t){super(t);this.id=t.id}};var z=class extends F{constructor(t,r){u(`WxLayerBaseImplementation.constructor (${r.id})`);super(r);this.animation=!1;this.animationSeed=0;this.layer=new O(t),this.oldMaxZoom=this.layer.wxdatasetManager.meta.maxZoom}get wxdatasetManager(){return u(`WxLayerBaseImplementation.wxdatasetManager (${this.id})`),this.layer.wxdatasetManager}getMetadata(){return u(`WxLayerBaseImplementation.getMetadata (${this.id})`),C({},this.layer.currentMeta)}getVariables(){return u(`WxLayerBaseImplementation.getVariables (${this.id})`),[...this.layer.variables]}clearCache(){u(`WxLayerBaseImplementation.clearCache (${this.id})`),this.layer.clearCache()}getCurrentStyleObjectCopy(){return u(`WxLayerBaseImplementation.getCurrentStyleObjectCopy (${this.id})`),this.layer.getCurrentStyleObjectCopy()}getTime(){return u(`WxLayerBaseImplementation.getTime (${this.id})`),this.layer.getTime()}setTime(t,r){return h(this,null,function*(){var s;u(`WxLayerBaseImplementation.setTime (${this.id}) 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 h(this,null,function*(){return u(`WxLayerBaseImplementation.preloadTime (${this.id}) time=${t}`),this.layer.preloadTime(t,this.coveringTiles(),r)})}startAnimation(){if(this.animation){u(`WxLayerBaseImplementation.startAnimation (${this.id}) already started`);return}if(this.layer.nonanimatable){u(`WxLayerBaseImplementation.startAnimation (${this.id}) nonanimatable`);return}u(`WxLayerBaseImplementation.startAnimation (${this.id})`),this.animation=!0;let t=r=>h(this,null,function*(){if(u(`WxLayerBaseImplementation.startAnimation (${this.id}) animationStep`),!this.animation||this.layer.nonanimatable){this.animation=!1;return}this.animationSeed=r,yield this._redrawTiles(),requestAnimationFrame(t)});requestAnimationFrame(t)}stopAnimation(){return h(this,null,function*(){return u(`WxLayerBaseImplementation.stopAnimation (${this.id})`),this.animation=!1,this._redrawTiles()})}setCoarseLevel(t=2){return h(this,null,function*(){u(`WxLayerBaseImplementation.setCoarseLevel (${this.id}) level=${t}`);let r=Math.max(this.oldMaxZoom-t,0);if(this.layer.wxdatasetManager.meta.maxZoom!==r)return this.layer.wxdatasetManager.meta.maxZoom=r,this._reloadVisible()})}unsetCoarseLevel(){return h(this,null,function*(){if(u(`WxLayerBaseImplementation.unsetCoarseLevel (${this.id})`),this.layer.wxdatasetManager.meta.maxZoom!==this.oldMaxZoom)return this.layer.wxdatasetManager.meta.maxZoom=this.oldMaxZoom,this._reloadVisible()})}setStyleByName(t,r=!0){return h(this,null,function*(){return u(`WxLayerBaseImplementation.setStyleByName (${this.id}) wxstyleName=${t} reload=${r}`),this.updateCurrentStyleObject(_()[t],r)})}updateCurrentStyleObject(t,r=!0,n){return h(this,null,function*(){if(u(`WxLayerBaseImplementation.updateCurrentStyleObject (${this.id}) style=${t} reload=${r}`),this.layer.updateCurrentStyleObject(t),this.startAnimation(),r)return this._reloadVisible(n)})}_redrawTiles(){return this.redrawRequested?this.redrawRequested:(this.redrawRequested=new Promise(t=>{requestAnimationFrame(()=>{u(`WxTileSource _redrawTiles (${this.id})`),this.update(),t(),this.redrawRequested=void 0})}),this.redrawRequested)}_reloadVisible(t){return h(this,null,function*(){})}coveringTiles(){return[]}update(){}};var K=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)}},N=class extends z{constructor(e,t){super(e,t),u("WxTileSource constructor: ",e)}getLayerInfoAtLatLon(e,t){if(u(`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 h(this,null,function*(){var t;if(u(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName})`),yield this.layer.reloadTiles(this.coveringTiles(),e),(t=e==null?void 0:e.signal)!=null&&t.aborted){u(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName}) aborted`);return}return yield Promise.allSettled(this._ForEachWxTile(r=>h(this,null,function*(){r.raster_data=yield this.layer.loadTile(r.coords)}),"_reloadVisible")),this._redrawTiles()})}coveringTiles(){var t;u(`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;u(`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=R(256,256),n=r.canvas;return this.layer.loadTile(e).then(s=>{n.wxtile=new K(e,r,s)}).catch(()=>{n.wxtile=new K(e,r,null)}).finally(t),n}onRemove(e){return super.onRemove(e),u(`WxTileSource onRemove (${this.layer.wxdatasetManager.datasetName})`),this.animation=!1,this}};var Z=class{constructor({datasetName:e,instance:t,instanced:r,meta:n,metas:s,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.metas=s,this.wxapi=o,u(`WxDataSetManager.constructor: ${this.datasetName}`)}getValidTime(e=Date()){u(`WxDataSetManager.getValidTime: ${this.datasetName}, ${e}`);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 u(`WxDataSetManager.getTimes: ${this.datasetName}`),this.instanced||this.meta.times}getVariables(){return u(`WxDataSetManager.getVariables: ${this.datasetName}`),this.meta.variables}getVariableMeta(e){return u(`WxDataSetManager.getVariableMeta: ${this.datasetName}, ${e}`),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"){var o;if(u(`WxDataSetManager.createURI: ${this.datasetName}, ${e}, ${t}`),!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.meta=((o=this.metas)==null?void 0:o.get(s))||this.meta,`${this.wxapi.dataServerURL+this.datasetName}/${s}/${e}/${n}/{z}/{x}/{y}.${r}`}checkVariableValid(e){return u(`WxDataSetManager.checkVariableValid: ${this.datasetName}, ${e}`),this.getVariableMeta(e)!==void 0}checkCombineVariableIfVector(e){u(`WxDataSetManager.checkCombineVariableIfVector: ${this.datasetName}, ${e}`);let t=this.getVariableMeta(e);if(!t)throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);return t.vector||[e]}createSourceLayer(e,t){u(`WxDataSetManager.createSourceLayer: ${this.datasetName}`);let r=fe(C({},e),{variables:this.checkCombineVariableIfVector(e.variable),wxdatasetManager:this});return new N(r,t)}checkDatasetOutdated(){return h(this,null,function*(){return u(`WxDataSetManager.checkDatasetOutdated: ${this.datasetName}`),yield this.wxapi.initDone,(yield this.getDatasetInstance())===this.instance})}getDatasetInstance(){return h(this,null,function*(){u(`WxDataSetManager.getDatasetInstance: ${this.datasetName}`);let e=yield this.getDatasetInstances();return e[e.length-1]})}getDatasetInstances(){return h(this,null,function*(){u(`WxDataSetManager.getDatasetInstances: ${this.datasetName}`);try{let e=yield A(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 le=class{constructor({dataServerURL:e,maskURL:t="none",maskChannel:r="R",maskDepth:n=11,qtreeURL:s="none",requestInit:o,colorStyles:i,units:l,colorSchemes:c}){this.maskURL="auto";this.datasetsMetas={allDatasetsList:[]};this.qtree=new $;this.loadMaskFunc=()=>Promise.reject(new Error("maskURL not defined"));if(u("WxAPI.constructor",e),be({colorStyles:i,units:l,colorSchemes:c}),this.dataServerURL=e,this.requestInit=o,s=s==="auto"?e+"masks/11+1.seamask.qtree":s,t!=="none"){let m=U(te);this.maskURL=t=t==="auto"?e+"masks/{z}/{x}/{y}.png":t,this.loadMaskFunc=d=>m(q(t,d),o)}this.maskChannel=r==="R"?0:r==="G"?1:r==="B"?2:r==="A"?3:0,this.maskDepth=n,this.initDone=Promise.all([A(e+"datasetsmeta.json",o),s!=="none"?this.qtree.load(s,o):Promise.resolve()]).then(([m,d])=>{m.allDatasetsList||(m.allDatasetsList=Object.keys(m)),this.datasetsMetas=m,u("WxAPI.constructor initDone")})}getDatasetShortMeta(e){if(u("WxAPI.getDatasetShortMeta",e),e!=="allDatasetsList")return this.datasetsMetas[e]}getDatasetInatance(e){var t;return u("WxAPI.getDatasetInatance",e),(t=this.getDatasetShortMeta(e))==null?void 0:t.instance}getDatasetVariables(e){return h(this,null,function*(){var t;return yield this.initDone,u("WxAPI.getDatasetVariables",e),(t=this.datasetsMetas[e])==null?void 0:t.variables})}createDatasetManager(e){return h(this,null,function*(){yield this.initDone,u("WxAPI.createDatasetManager",e);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=l=>A(this.dataServerURL+e+"/"+l+"/meta.json",this.requestInit),o=yield s(r),i=n&&new Map;return n&&(yield Promise.all(n.map(l=>h(this,null,function*(){i.set(l,yield s(l))})))),new Z({datasetName:e,instanced:n,instance:r,meta:o,metas:i,wxapi:this})})}createAllDatasetsManagers(){return h(this,null,function*(){return yield this.initDone,u("WxAPI.createAllDatasetsManagers"),Promise.allSettled(this.datasetsMetas.allDatasetsList.map(t=>this.createDatasetManager(t)))})}filterDatasetsByVariableName(e){return h(this,null,function*(){return yield this.initDone,u("WxAPI.filterDatasetsByVariableName",e),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 h(this,null,function*(){return yield this.initDone,u("WxAPI.getAllDatasetsNames"),this.datasetsMetas.allDatasetsList})}};export{F as FrameworkParentClass,V as Loader,X as Painter,$ as QTree,B as RawCLUT,u as WXLOG,le as WxAPI,Te as WxCreateLegend,Z as WxDataSetManager,ee as WxGetColorSchemes,_ as WxGetColorStyles,O as WxLayer,N as WxTileSource,Je as WxTilesLogging};
|
|
6
|
+
time: ${e.time}`),!((s=e.variables)!=null&&s.length)||e.variables.length>2)throw new Error(`datasetName: ${e.wxdatasetManager.datasetName}: only 1 or 2 variables are supported but ${e.variables} was given`);e.variables.forEach(i=>{if(!e.wxdatasetManager.checkVariableValid(i))throw new Error(`datasetName: ${e.wxdatasetManager.datasetName}: variable ${i} is not valid`)}),this.variables=e.variables,this.wxdatasetManager=e.wxdatasetManager,this.loader=new B(this),[this.tilesURIs,this.time]=this._createURLsAndTime(e.time);let t=_(),r=t.base,n=e.wxstyleName&&t[e.wxstyleName];this.currentVariableMeta=this._getCurrentVariableMeta(),[this.style,this.CLUT]=this._createStyleAndCLUT(C(C(C({},r),n),e.wxstyle))}get nonanimatable(){return m("WxLayer.nonanimatabl()"),this.variables.length<2||this.style.streamLineStatic||this.style.streamLineColor==="none"}getMaxZoom(){return m("WxLayer.getMaxZoom"),this.wxdatasetManager.isInstanced()?this.wxdatasetManager.getInstanceMeta(this.getTime()).maxZoom:this.wxdatasetManager.getMaxZoom()}getBoundaries(){return this.wxdatasetManager.isInstanced()?this.wxdatasetManager.getInstanceMeta(this.getTime()).boundaries:this.wxdatasetManager.getBoundaries()}getTime(){return m("WxLayer.getTime"),this.time}clearCache(){m("WxLayer.clearCache"),this.tilesCache.clear(),this.loader.clearCache()}getCurrentStyleObjectCopy(){return m("WxLayer.getCurrentStyleObjectCopy"),Object.assign({},this.style)}updateCurrentStyleObject(e){m(`WxLayer.updateCurrentStyleObject ${JSON.stringify(e)}`),[this.style,this.CLUT]=this._createStyleAndCLUT(e)}getTileData(e,t){let r=this.tilesCache.get(j(e));if(!r)return;let n=this._getPixelInfo(t,r.data.data);if(!n)return;let{raw:s,data:i}=n,o=s.map(u=>this.CLUT.colorsI[u]),l=o.map(T),c=i.map(u=>this.CLUT.DataToStyle(u));return{data:i,raw:s,rgba:o,hexColor:l,inStyleUnits:c,tilePoint:t,styleUnits:this.style.units,dataUnits:this.currentVariableMeta.units}}setURLsAndTime(e){m(`WxLayer.setURLsAndTime time=${e}`),[this.tilesURIs,this.time]=this._createURLsAndTime(e),this.wxdatasetManager.isInstanced()&&(this.currentVariableMeta=this._getCurrentVariableMeta(),[this.style,this.CLUT]=this._createStyleAndCLUT())}loadTile(e,t){return p(this,null,function*(){return this._loadCacheDrawTile(e,this.tilesCache,t).catch(r=>{if(r.name==="AbortError")throw r;return null})})}preloadTime(e,t,r){return p(this,null,function*(){m(`WxLayer.preloadTime time=${e}`);let[n]=this._createURLsAndTime(e);yield Promise.allSettled(t.map(s=>this.loader.cacheLoad(s,n,r)))})}reloadTiles(e,t){return p(this,null,function*(){var n;m("WxLayer.reloadTiles");let r=new z;yield Promise.allSettled(e.map(s=>this._loadCacheDrawTile(s,r,t))),(n=t==null?void 0:t.signal)!=null&&n.aborted?r.clear():(this.tilesCache.clear(),this.tilesCache=r)})}_loadCacheDrawTile(e,t,r){return p(this,null,function*(){let n=t.get(j(e));if(n)return n;let s=yield this.loader.load(e,r);if(!s)return null;let i=R(256,256),o=i,l=this.variables.length===2?R(256,256):i,c={ctxFill:i,ctxText:o,ctxStreamLines:l,data:s};return this.painter.paint(c),t.set(j(e),c),c})}_getCurrentVariableMeta(){let e=this.variables.map(i=>{let o=this.wxdatasetManager.getInstanceVariableMeta(i,this.time);if(!o)throw new Error(`WxLayer ${this.wxdatasetManager.datasetName}: variable ${i} is not valid`);return o}),{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,i;m(`WxLayer._getPixelInfo x=${e} y=${t}`);let n=(t+1)*258+(e+1);if(!!((i=(s=r==null?void 0:r[0])==null?void 0:s.raw)!=null&&i[n]))return{raw:r.map(o=>o.raw[n]),data:r.map(o=>o.raw[n]*o.dmul+o.dmin)}}_createStyleAndCLUT(e){let t=Object.assign({},this.style,e),r=this._prepareCLUT(t);return[t,r]}_prepareCLUT(e){let{min:t,max:r,units:n}=this.currentVariableMeta;return new V(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)),t]}};var Ve=je($e()),O=class extends Ve.default.GridLayer{constructor(t){super(t);this.id=t.id}};var K=class extends O{constructor(t,r){m(`WxLayerBaseImplementation.constructor (${r.id})`);super(r);this.animation=!1;this.animationSeed=0;this.layer=new X(t),this.oldMaxZoom=this.layer.getMaxZoom()}get wxdatasetManager(){return m(`WxLayerBaseImplementation.wxdatasetManager (${this.id})`),this.layer.wxdatasetManager}getCurrentVariableMeta(){return m(`WxLayerBaseImplementation.getCurrentVariableMeta (${this.id})`),C({},this.layer.currentVariableMeta)}getDatasetMeta(){return this.layer.wxdatasetManager.getInstanceMeta(this.getTime())}getMetadata(){return m(`WxLayerBaseImplementation.getMetadata (${this.id})`),C({},this.layer.currentVariableMeta)}getVariables(){return m(`WxLayerBaseImplementation.getVariables (${this.id})`),[...this.layer.variables]}clearCache(){m(`WxLayerBaseImplementation.clearCache (${this.id})`),this.layer.clearCache()}getCache(){return this.layer.tilesCache}getCurrentStyleObjectCopy(){return m(`WxLayerBaseImplementation.getCurrentStyleObjectCopy (${this.id})`),this.layer.getCurrentStyleObjectCopy()}getTime(){return m(`WxLayerBaseImplementation.getTime (${this.id})`),this.layer.getTime()}getTimes(){return m(`WxLayerBaseImplementation.getTimes (${this.id})`),this.layer.wxdatasetManager.getTimes()}setTime(t,r){return p(this,null,function*(){var s;m(`WxLayerBaseImplementation.setTime (${this.id}) 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 p(this,null,function*(){return m(`WxLayerBaseImplementation.preloadTime (${this.id}) time=${t}`),this.layer.preloadTime(t,this.coveringTiles(),r)})}startAnimation(){if(this.animation){m(`WxLayerBaseImplementation.startAnimation (${this.id}) already started`);return}if(this.layer.nonanimatable){m(`WxLayerBaseImplementation.startAnimation (${this.id}) nonanimatable`);return}m(`WxLayerBaseImplementation.startAnimation (${this.id})`),this.animation=!0;let t=r=>p(this,null,function*(){if(m(`WxLayerBaseImplementation.startAnimation (${this.id}) animationStep`),!this.animation||this.layer.nonanimatable){this.animation=!1;return}this.animationSeed=r,yield this._redrawTiles(),requestAnimationFrame(t)});requestAnimationFrame(t)}stopAnimation(){return p(this,null,function*(){return m(`WxLayerBaseImplementation.stopAnimation (${this.id})`),this.animation=!1,this._redrawTiles()})}setCoarseLevel(t=2){return p(this,null,function*(){})}unsetCoarseLevel(){return p(this,null,function*(){})}setStyleByName(t,r=!0){return p(this,null,function*(){return m(`WxLayerBaseImplementation.setStyleByName (${this.id}) wxstyleName=${t} reload=${r}`),this.updateCurrentStyleObject(_()[t],r)})}updateCurrentStyleObject(t,r=!0,n){return p(this,null,function*(){if(m(`WxLayerBaseImplementation.updateCurrentStyleObject (${this.id}) style=${t} reload=${r}`),this.layer.updateCurrentStyleObject(t),this.startAnimation(),r)return this._reloadVisible(n)})}_redrawTiles(){return this.redrawRequested?this.redrawRequested:(this.redrawRequested=new Promise(t=>{requestAnimationFrame(()=>{m(`WxTileSource _redrawTiles (${this.id})`),this.update(),t(),this.redrawRequested=void 0})}),this.redrawRequested)}_reloadVisible(t){return p(this,null,function*(){})}coveringTiles(){return[]}update(){}};var H=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)}},F=class extends K{constructor(e,t){super(e,t),m("WxTileSource constructor: ",e)}getLayerInfoAtLatLon(e,t){if(m(`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(),i=n.subtract(s.multiplyBy(256)).floor();return this.layer.getTileData({x:s.x,y:s.y,z:r},i)}_reloadVisible(e){return p(this,null,function*(){var t;if(m(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName})`),yield this.layer.reloadTiles(this.coveringTiles(),e),(t=e==null?void 0:e.signal)!=null&&t.aborted){m(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName}) aborted`);return}return yield Promise.allSettled(this._ForEachWxTile(r=>p(this,null,function*(){r.raster_data=yield this.layer.loadTile(r.coords)}),"_reloadVisible")),this._redrawTiles()})}coveringTiles(){var t;m(`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(){m(`WxTileSource update (${this.layer.wxdatasetManager.datasetName})`),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;m(`WxTileSource _ForEachWxTile (${this.layer.wxdatasetManager.datasetName}) func=${t}`);let r=[];for(let s in this._tiles){let i=(n=this._tiles[s].el)==null?void 0:n.wxtile;i&&r.push(e(i))}return r}createTile(e,t){let r=R(256,256),n=r.canvas;return this.layer.loadTile(e).then(s=>{n.wxtile=new H(e,r,s)}).catch(()=>{n.wxtile=new H(e,r,null)}).finally(t),n}onRemove(e){return super.onRemove(e),m(`WxTileSource onRemove (${this.layer.wxdatasetManager.datasetName})`),this.animation=!1,this}};var Z=class{constructor({datasetName:e,datasetCurrentInstance:t,instanced:r,datasetCurrentMeta:n,metas:s,wxAPI:i}){if(!i.datasetsMetas.allDatasetsList.includes(e))throw new Error(`Dataset ${e} not found`);this.datasetName=e,this.instanced=r,this.datasetCurrentInstance=t,this.datasetCurrentMeta=n,this.metas=s,this.wxAPI=i,m(`WxDataSetManager.constructor: ${this.datasetName}`)}isInstanced(){return!!this.instanced}getValidTime(e=Date()){m(`WxDataSetManager.getValidTime: ${this.datasetName}, ${e}`);let t=this.getTimes();if(e==="")return t[t.length-1];if(typeof e=="string"){let s=t.indexOf(e);if(s!==-1)return t[s]}if(typeof e=="number"){if(e<=0)return t[0];if(e<t.length)return t[e]}let r=new Date(e).getTime();return isNaN(r)?t[t.length-1]:t.find(s=>new Date(s).getTime()>=r)||t[t.length-1]}getTimes(){return m(`WxDataSetManager.getTimes: ${this.datasetName}`),this.instanced||this.datasetCurrentMeta.times}getVariables(){return m(`WxDataSetManager.getVariables: ${this.datasetName}`),this.datasetCurrentMeta.variables}getVariableMeta(e){return m(`WxDataSetManager.getVariableMeta: ${this.datasetName}, ${e}`),this.datasetCurrentMeta.variablesMeta[e]}getInstanceVariableMeta(e,t){return m(`WxDataSetManager.getInstanceVariableMeta: ${this.datasetName}, ${e}, ${t}`),this.getInstanceMeta(t).variablesMeta[e]}getMaxZoom(){return m(`WxDataSetManager.getMaxZoom: ${this.datasetName}`),this.datasetCurrentMeta.maxZoom}getBoundaries(){return m(`WxDataSetManager.getBoundaries: ${this.datasetName}`),this.datasetCurrentMeta.boundaries}getInstanceMeta(e){return m(`WxDataSetManager.getInstanceMeta: ${this.datasetName}, ${e}`),this.instanced&&this.metas.get(e)||this.datasetCurrentMeta}createURI(e,t,r="png"){if(m(`WxDataSetManager.createURI: ${this.datasetName}, ${e}, ${t}`),!this.checkVariableValid(e))throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);let n=this.instanced?t:this.datasetCurrentInstance;return`${this.wxAPI.dataServerURL+this.datasetName}/${n}/${e}/${t}/{z}/{x}/{y}.${r}`}checkVariableValid(e){return m(`WxDataSetManager.checkVariableValid: ${this.datasetName}, ${e}`),this.getVariableMeta(e)!==void 0}checkCombineVariableIfVector(e){m(`WxDataSetManager.checkCombineVariableIfVector: ${this.datasetName}, ${e}`);let t=this.getVariableMeta(e);if(!t)throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);return t.vector||[e]}createSourceLayer(e,t){m(`WxDataSetManager.createSourceLayer: ${this.datasetName}`);let r=fe(C({},e),{variables:this.checkCombineVariableIfVector(e.variable),wxdatasetManager:this});return new F(r,t)}checkDatasetOutdated(){return p(this,null,function*(){return m(`WxDataSetManager.checkDatasetOutdated: ${this.datasetName}`),yield this.wxAPI.initDone,(yield this.getDatasetInstance())===this.datasetCurrentInstance})}getDatasetInstance(){return p(this,null,function*(){m(`WxDataSetManager.getDatasetInstance: ${this.datasetName}`);let e=yield this.getDatasetInstances();return e[e.length-1]})}getDatasetInstances(){return p(this,null,function*(){m(`WxDataSetManager.getDatasetInstances: ${this.datasetName}`);try{let e=yield A(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} (they are likely removed from API)`)}})}};var ce=class{constructor({dataServerURL:e,maskURL:t="none",maskChannel:r="R",maskDepth:n=11,qtreeURL:s="none",requestInit:i,colorStyles:o,units:l,colorSchemes:c}){this.maskURL="auto";this.datasetsMetas={allDatasetsList:[]};this.qtree=new $;this.loadMaskFunc=()=>Promise.reject(new Error("maskURL not defined"));if(m("WxAPI.constructor",e),ye({colorStyles:o,units:l,colorSchemes:c}),this.dataServerURL=e,this.requestInit=i,s=s==="auto"?e+"masks/11+1.seamask.qtree":s,t!=="none"){let u=U(re);this.maskURL=t=t==="auto"?e+"masks/{z}/{x}/{y}.png":t,this.loadMaskFunc=f=>u(q(t,f),i)}this.maskChannel=r==="R"?0:r==="G"?1:r==="B"?2:r==="A"?3:0,this.maskDepth=n,this.initDone=Promise.all([A(e+"datasetsmeta.json",i),s!=="none"?this.qtree.load(s,i):Promise.resolve()]).then(([u,f])=>{u.allDatasetsList||(u.allDatasetsList=Object.keys(u)),this.datasetsMetas=u,m("WxAPI.constructor initDone")})}getDatasetShortMeta(e){if(m("WxAPI.getDatasetShortMeta",e),e!=="allDatasetsList")return this.datasetsMetas[e]}getDatasetInatance(e){var t;return m("WxAPI.getDatasetInatance",e),(t=this.getDatasetShortMeta(e))==null?void 0:t.instance}getDatasetVariables(e){return p(this,null,function*(){var t;return yield this.initDone,m("WxAPI.getDatasetVariables",e),(t=this.datasetsMetas[e])==null?void 0:t.variables})}createDatasetManager(e){return p(this,null,function*(){yield this.initDone,m("WxAPI.createDatasetManager",e);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=c=>A(this.dataServerURL+e+"/"+c+"/meta.json",this.requestInit),i=c=>p(this,null,function*(){return[c,yield s(c)]}),o=yield s(r),l=new Map(n?yield Promise.all(n.map(i)):[[r,o]]);return new Z({datasetName:e,datasetCurrentInstance:r,datasetCurrentMeta:o,instanced:n,metas:l,wxAPI:this})})}createAllDatasetsManagers(){return p(this,null,function*(){return yield this.initDone,m("WxAPI.createAllDatasetsManagers"),Promise.allSettled(this.datasetsMetas.allDatasetsList.map(t=>this.createDatasetManager(t)))})}filterDatasetsByVariableName(e){return p(this,null,function*(){return yield this.initDone,m("WxAPI.filterDatasetsByVariableName",e),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 p(this,null,function*(){return yield this.initDone,m("WxAPI.getAllDatasetsNames"),this.datasetsMetas.allDatasetsList})}};export{O as FrameworkParentClass,B as Loader,N as Painter,$ as QTree,V as RawCLUT,m as WXLOG,ce as WxAPI,Ce as WxCreateLegend,Z as WxDataSetManager,te as WxGetColorSchemes,_ as WxGetColorStyles,X as WxLayer,F as WxTileSource,Qe as WxTilesLogging};
|
|
@@ -18,7 +18,7 @@ export interface WxDataSetManagerOptions {
|
|
|
18
18
|
* @internal
|
|
19
19
|
* current instance of the dataset
|
|
20
20
|
* */
|
|
21
|
-
|
|
21
|
+
datasetCurrentInstance: string;
|
|
22
22
|
/**
|
|
23
23
|
* @internal
|
|
24
24
|
* Array of instanced time steps
|
|
@@ -28,17 +28,17 @@ export interface WxDataSetManagerOptions {
|
|
|
28
28
|
* @internal
|
|
29
29
|
* Dataset's meta data
|
|
30
30
|
* */
|
|
31
|
-
|
|
31
|
+
datasetCurrentMeta: WxDatasetMeta;
|
|
32
32
|
/**
|
|
33
33
|
* @internal
|
|
34
34
|
* Dataset's metas for an instanced dataset
|
|
35
35
|
* */
|
|
36
|
-
metas
|
|
36
|
+
metas: Map<string, WxDatasetMeta>;
|
|
37
37
|
/**
|
|
38
38
|
* @internal
|
|
39
39
|
* The {@link WxAPI} instance to use to interact with the *WxTiles* API
|
|
40
40
|
* */
|
|
41
|
-
|
|
41
|
+
wxAPI: WxAPI;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Class for managing WX datasets.
|
|
@@ -51,18 +51,19 @@ export interface WxDataSetManagerOptions {
|
|
|
51
51
|
export declare class WxDataSetManager {
|
|
52
52
|
/** dataset's name */
|
|
53
53
|
readonly datasetName: string;
|
|
54
|
-
/** if not empty, returns dataset's instances to be used as time steps in the dataset */
|
|
55
|
-
readonly instanced?: string[];
|
|
56
54
|
/** Get dataset's current instance. */
|
|
57
|
-
readonly
|
|
55
|
+
private readonly datasetCurrentInstance;
|
|
58
56
|
/** dataset's meta */
|
|
59
|
-
|
|
57
|
+
private readonly datasetCurrentMeta;
|
|
58
|
+
/** if not empty, returns dataset's instances to be used as time steps in the dataset */
|
|
59
|
+
private readonly instanced?;
|
|
60
60
|
/** dataset's metas for an instanced dataset */
|
|
61
|
-
readonly metas
|
|
61
|
+
private readonly metas;
|
|
62
62
|
/** a reference to the wxAPI object */
|
|
63
|
-
readonly
|
|
63
|
+
readonly wxAPI: WxAPI;
|
|
64
64
|
/** Do not use this constructor directly, use {@link WxAPI.createDatasetManager} instead. */
|
|
65
|
-
constructor({ datasetName,
|
|
65
|
+
constructor({ datasetName, datasetCurrentInstance, instanced, datasetCurrentMeta, metas, wxAPI }: WxDataSetManagerOptions);
|
|
66
|
+
isInstanced(): boolean;
|
|
66
67
|
/**
|
|
67
68
|
* Get closets valid time to the given time.
|
|
68
69
|
* @argument {WxDate} time - either a number of a step in dataset's time array or seconds since epoch or a Date object
|
|
@@ -82,24 +83,32 @@ export declare class WxDataSetManager {
|
|
|
82
83
|
/**
|
|
83
84
|
* Get dataset's variable meta.
|
|
84
85
|
* @argument {string} variable - variable name
|
|
85
|
-
* @returns {WxVariableMeta} -
|
|
86
|
+
* @returns {WxVariableMeta | undefined} - dataset variable's meta
|
|
86
87
|
* */
|
|
87
88
|
getVariableMeta(variable: string): WxVariableMeta | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* For instanced dataset, get variable's meta.
|
|
91
|
+
* @argument {string} variable - variable name
|
|
92
|
+
* @argument {string} instance - instance name
|
|
93
|
+
* @returns {WxVariableMeta | undefined} - dataset variable's meta for the given instance
|
|
94
|
+
* */
|
|
95
|
+
getInstanceVariableMeta(variable: string, instance: string): WxVariableMeta | undefined;
|
|
88
96
|
/**
|
|
89
97
|
* Get dataset's native maximum zoom level.
|
|
90
98
|
* @returns {number} - maximum zoom level of the dataset
|
|
91
99
|
* */
|
|
92
100
|
getMaxZoom(): number;
|
|
93
|
-
/**
|
|
94
|
-
* Get dataset's boundaries.
|
|
95
|
-
* @returns {[west, north, east, south] | undefined} - dataset's boundaries
|
|
96
|
-
* */
|
|
97
|
-
getBoundaries180(): [number, number, number, number] | undefined;
|
|
98
101
|
/**
|
|
99
102
|
* Get dataset's boundaries.
|
|
100
103
|
* @returns {WxAllBoundariesMeta | undefined} - dataset's boundaries
|
|
101
104
|
* */
|
|
102
105
|
getBoundaries(): WxAllBoundariesMeta | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Get dataset's metadata for the given instance.
|
|
108
|
+
* @param {string} instance
|
|
109
|
+
* @returns {WxDatasetMeta}
|
|
110
|
+
*/
|
|
111
|
+
getInstanceMeta(instance: string): WxDatasetMeta;
|
|
103
112
|
/**
|
|
104
113
|
* Createts dataset's current URI ready for fetching tiles.
|
|
105
114
|
* @argument {string} variable - variable of the dataset
|
|
@@ -107,7 +116,7 @@ export declare class WxDataSetManager {
|
|
|
107
116
|
* @argument {'png'} ext - must be PNG
|
|
108
117
|
* @returns {string} - dataset's current URI ready for fetching tiles
|
|
109
118
|
* */
|
|
110
|
-
createURI(variable: string,
|
|
119
|
+
createURI(variable: string, validTime: string, ext?: 'png'): string;
|
|
111
120
|
/**
|
|
112
121
|
* Check if given variable is available in the dataset.
|
|
113
122
|
* @argument {string} variable - variable name
|
|
@@ -120,18 +129,26 @@ export declare class WxDataSetManager {
|
|
|
120
129
|
* @returns {WxVars} - [variable] or [variable.eastward, variable.northward]
|
|
121
130
|
* */
|
|
122
131
|
checkCombineVariableIfVector(variable: string): WxVars;
|
|
132
|
+
/**
|
|
133
|
+
* @param {WxSourceLayerOptions} options - layer options
|
|
134
|
+
* @param {WxSourceLayerOptions} frwOptions - framework options
|
|
135
|
+
* @returns {WxTileSource}
|
|
136
|
+
*/
|
|
123
137
|
createSourceLayer(options: WxSourceLayerOptions, frwOptions: FrameworkOptions): WxTileSource;
|
|
124
138
|
/**
|
|
139
|
+
* A part of WxAPI (is not used internally)
|
|
125
140
|
* Check if dataset's instance updated (fresh data is arrived) since datasset object was created
|
|
126
141
|
* @returns {boolean} - true if dataset's instance updated since datasset object was created
|
|
127
142
|
* */
|
|
128
143
|
checkDatasetOutdated(): Promise<boolean>;
|
|
129
144
|
/**
|
|
145
|
+
* A part of WxAPI (is not used internally)
|
|
130
146
|
* Get dataset's instance.
|
|
131
147
|
* @returns {Promise<string>} - dataset's instance
|
|
132
148
|
* */
|
|
133
149
|
protected getDatasetInstance(): Promise<string>;
|
|
134
150
|
/**
|
|
151
|
+
* A part of WxAPI (is not used internally)
|
|
135
152
|
* Get dataset's instances.
|
|
136
153
|
* @returns {Promise<string[]>} - dataset's all instances
|
|
137
154
|
* */
|
package/dist/es/wxAPI/wxAPI.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type WxColorStyleWeak, type XYZ, type WxColorStyleStrict } from '../utils/wxtools';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import type { WxRequestInit, WxDate, WxVars, WxLayerOptions, WxLngLat, WxTileInfo, TilesCache } from './wxlayer';
|
|
3
|
+
import { WxLayer } from './wxlayer';
|
|
4
|
+
import type { WxDatasetMeta, WxVariableMeta } from '../wxAPI/wxAPI';
|
|
5
|
+
import { FrameworkParentClass, type FrameworkOptions } from '../wxsource/wxsourcetypes';
|
|
6
|
+
import type { WxDataSetManager } from '../wxAPI/WxDataSetManager';
|
|
6
7
|
/**
|
|
7
8
|
* Mandatory Interface to be implemented by a {@link WxLayerBaseImplementation}
|
|
8
9
|
*/
|
|
9
10
|
export interface WxLayerBaseAPI {
|
|
10
11
|
wxdatasetManager: WxDataSetManager;
|
|
11
|
-
|
|
12
|
+
getCurrentVariableMeta(): WxVariableMeta;
|
|
12
13
|
getVariables(): WxVars;
|
|
13
14
|
clearCache(): void;
|
|
14
15
|
getCurrentStyleObjectCopy(): WxColorStyleStrict;
|
|
@@ -77,9 +78,16 @@ export declare class WxLayerBaseImplementation extends FrameworkParentClass impl
|
|
|
77
78
|
* Get the metadata of the current variable(s).
|
|
78
79
|
* @returns {WxVariableMeta} - The metadata of the current variable.
|
|
79
80
|
*/
|
|
81
|
+
getCurrentVariableMeta(): WxVariableMeta;
|
|
82
|
+
getDatasetMeta(): WxDatasetMeta;
|
|
83
|
+
/**
|
|
84
|
+
* Get the metadata of the current variable(s).
|
|
85
|
+
* @deprecated
|
|
86
|
+
* @returns {WxVariableMeta} - The metadata of the current variable.
|
|
87
|
+
*/
|
|
80
88
|
getMetadata(): WxVariableMeta;
|
|
81
89
|
/**
|
|
82
|
-
* Get current variables of the source.
|
|
90
|
+
* Get current variables (1 or 2) of the source/layer.
|
|
83
91
|
* @returns {WxVars} variables of the source.
|
|
84
92
|
*/
|
|
85
93
|
getVariables(): WxVars;
|
|
@@ -87,6 +95,7 @@ export declare class WxLayerBaseImplementation extends FrameworkParentClass impl
|
|
|
87
95
|
* Clears the cache of the source.
|
|
88
96
|
*/
|
|
89
97
|
clearCache(): void;
|
|
98
|
+
getCache(): TilesCache;
|
|
90
99
|
/**
|
|
91
100
|
* Get a copy of the current style of the source.
|
|
92
101
|
* @returns {WxColorStyleStrict} A copy of the current style of the source.
|
|
@@ -97,6 +106,7 @@ export declare class WxLayerBaseImplementation extends FrameworkParentClass impl
|
|
|
97
106
|
* @returns {string} The current time of the source from array of times.
|
|
98
107
|
*/
|
|
99
108
|
getTime(): string;
|
|
109
|
+
getTimes(): string[];
|
|
100
110
|
/**
|
|
101
111
|
* Set time and render the source. If the time is not available, the closest time will be used.
|
|
102
112
|
* @param {WxDate} time - Time to set.
|
|
@@ -153,6 +163,7 @@ export declare class WxLayerBaseImplementation extends FrameworkParentClass impl
|
|
|
153
163
|
/**
|
|
154
164
|
* @ignore
|
|
155
165
|
* A dummy function to be replaced by ancestor classes.
|
|
166
|
+
* Force reload and redraw all tiles.
|
|
156
167
|
*/
|
|
157
168
|
protected update(): void;
|
|
158
169
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TileType } from '../utils/qtree';
|
|
2
2
|
import { type DataIntegral, type DataIntegrals, type DataPictures, UriLoaderPromiseFunc, type XYZ } from '../utils/wxtools';
|
|
3
|
+
import { WxAPI } from '../wxAPI/wxAPI';
|
|
3
4
|
import { WxRequestInit, WxURIs, type WxLayer } from './wxlayer';
|
|
4
5
|
/** Point on pixel grid */
|
|
5
6
|
export interface SLinePoint {
|
|
@@ -23,6 +24,7 @@ export interface WxData {
|
|
|
23
24
|
export declare class Loader {
|
|
24
25
|
/** refference to the Layer {@link WxLayer} in which this loader is used */
|
|
25
26
|
protected readonly layer: WxLayer;
|
|
27
|
+
protected readonly wxAPI: WxAPI;
|
|
26
28
|
/** function to load, decode and cache data from URL */
|
|
27
29
|
protected loadDataFunc: UriLoaderPromiseFunc<DataIntegral>;
|
|
28
30
|
/** Do not use constructor directly */
|
|
@@ -20,6 +20,11 @@ export interface WxRasterData {
|
|
|
20
20
|
* {@link WxData} data object for this tile
|
|
21
21
|
* */
|
|
22
22
|
data: WxData;
|
|
23
|
+
rd?: {
|
|
24
|
+
vectorTextureU: WebGLTexture;
|
|
25
|
+
vectorTextureV: WebGLTexture;
|
|
26
|
+
gl: WebGLRenderingContext;
|
|
27
|
+
};
|
|
23
28
|
}
|
|
24
29
|
/**
|
|
25
30
|
* Calss for rendering a single tile.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RawCLUT } from '../utils/RawCLUT';
|
|
2
2
|
import type { WxColorStyleStrict, XYZ, DataPictures, WxColorStyleWeak } from '../utils/wxtools';
|
|
3
|
-
import {
|
|
4
|
-
import { WxDataSetManager } from '../wxAPI/WxDataSetManager';
|
|
3
|
+
import type { WxAllBoundariesMeta, WxVariableMeta } from '../wxAPI/wxAPI';
|
|
4
|
+
import type { WxDataSetManager } from '../wxAPI/WxDataSetManager';
|
|
5
5
|
import { Loader } from './loader';
|
|
6
6
|
import { Painter, type WxRasterData } from './painter';
|
|
7
7
|
/** Type used to set a time step for the layer. */
|
|
@@ -53,29 +53,32 @@ export interface WxLayerOptions {
|
|
|
53
53
|
/** Dataset Manager */
|
|
54
54
|
wxdatasetManager: WxDataSetManager;
|
|
55
55
|
/** initial time step */
|
|
56
|
-
time
|
|
57
|
-
/** extension of data tiles at the backend */
|
|
58
|
-
ext?: 'png';
|
|
56
|
+
time: WxDate;
|
|
59
57
|
/** initial style name */
|
|
60
58
|
wxstyleName?: string;
|
|
61
59
|
/** initial style, applyed on top of style passed by name {@link wxstyleName} */
|
|
62
60
|
wxstyle?: WxColorStyleWeak;
|
|
63
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
* Used in {@link WxLayerBaseImplementation} cache of tiles
|
|
65
|
+
* */
|
|
66
|
+
export declare class TilesCache extends Map<string, WxRasterData> {
|
|
67
|
+
clear(): void;
|
|
68
|
+
}
|
|
64
69
|
/**
|
|
65
70
|
* @internal
|
|
66
71
|
* Used in {@link WxLayerBaseImplementation} to manipulate the the layer's style, data and time
|
|
67
72
|
* */
|
|
68
73
|
export declare class WxLayer {
|
|
69
|
-
/** @internal PNG only!*/
|
|
70
|
-
protected readonly ext: 'png';
|
|
71
74
|
/** @internal Variables to be displayed by the layer */
|
|
72
75
|
readonly variables: WxVars;
|
|
73
76
|
/** @internal Data manager created this layer */
|
|
74
77
|
readonly wxdatasetManager: WxDataSetManager;
|
|
75
|
-
/** @internal Current Meta data for the layer*/
|
|
76
|
-
readonly currentMeta: WxVariableMeta;
|
|
77
78
|
/** @internal Current time*/
|
|
78
79
|
protected time: string;
|
|
80
|
+
/** @internal Current variable's Meta data of the layer*/
|
|
81
|
+
currentVariableMeta: WxVariableMeta;
|
|
79
82
|
/** @internal current URIs to fetch tiles */
|
|
80
83
|
tilesURIs: WxURIs;
|
|
81
84
|
/** @internal current Style Object */
|
|
@@ -83,7 +86,7 @@ export declare class WxLayer {
|
|
|
83
86
|
/** @internal Current "Color lookup table" object */
|
|
84
87
|
CLUT: RawCLUT;
|
|
85
88
|
/** @internal cahced URI->data */
|
|
86
|
-
|
|
89
|
+
tilesCache: TilesCache;
|
|
87
90
|
/** @internal Painter object to render tiles */
|
|
88
91
|
readonly painter: Painter;
|
|
89
92
|
/** @internal Loader object to load and preprocess tiles */
|
|
@@ -91,6 +94,18 @@ export declare class WxLayer {
|
|
|
91
94
|
constructor(wxLayerOptions: WxLayerOptions);
|
|
92
95
|
/** Check if the layer is vector and may be animated according to style */
|
|
93
96
|
get nonanimatable(): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* @internal
|
|
99
|
+
* Get maximum zoom according to the layer's Dataset manager
|
|
100
|
+
* @returns {number} maximum zoom
|
|
101
|
+
*/
|
|
102
|
+
getMaxZoom(): number;
|
|
103
|
+
/**
|
|
104
|
+
* @internal
|
|
105
|
+
* Get boundaries zoom according to the layer's Dataset manager
|
|
106
|
+
* @returns {WxAllBoundariesMeta | undefined} boundaries
|
|
107
|
+
* */
|
|
108
|
+
getBoundaries(): WxAllBoundariesMeta | undefined;
|
|
94
109
|
/**
|
|
95
110
|
* @internal
|
|
96
111
|
* Get the current time step of the layer
|
|
@@ -126,11 +141,9 @@ export declare class WxLayer {
|
|
|
126
141
|
* @returns {Promise<viod>} */
|
|
127
142
|
reloadTiles(tiles: XYZ[], requestInit?: WxRequestInit): Promise<void>;
|
|
128
143
|
/** @ignore */
|
|
129
|
-
protected _loadCacheDrawTile(tile: XYZ, tilesCache:
|
|
130
|
-
/** @ignore */
|
|
131
|
-
protected _createStyleAndCLUT(style_?: WxColorStyleWeak): [WxColorStyleStrict, RawCLUT];
|
|
144
|
+
protected _loadCacheDrawTile(tile: XYZ, tilesCache: TilesCache, requestInit?: WxRequestInit): Promise<WxRasterData | null>;
|
|
132
145
|
/** @ignore creates/calculates meta data for vector layers */
|
|
133
|
-
protected
|
|
146
|
+
protected _getCurrentVariableMeta(): WxVariableMeta;
|
|
134
147
|
/** @ignore x, y - pixel on tile, data - data tile */
|
|
135
148
|
protected _getPixelInfo({ x, y }: {
|
|
136
149
|
x: number;
|
|
@@ -139,6 +152,8 @@ export declare class WxLayer {
|
|
|
139
152
|
raw: number[];
|
|
140
153
|
data: number[];
|
|
141
154
|
} | undefined;
|
|
155
|
+
/** @ignore */
|
|
156
|
+
protected _createStyleAndCLUT(style_?: WxColorStyleWeak): [WxColorStyleStrict, RawCLUT];
|
|
142
157
|
/** @ignore Create a new CLUT for the given style */
|
|
143
158
|
protected _prepareCLUT(style: WxColorStyleStrict): RawCLUT;
|
|
144
159
|
/** @ignore calculate valid timestep and URIs */
|
|
@@ -4,6 +4,10 @@ import { type WxRequestInit, type WxTileInfo, type WxLngLat, WxLayerOptions } fr
|
|
|
4
4
|
import { type WxRasterData } from '../wxlayer/painter';
|
|
5
5
|
import { WxLayerBaseImplementation, type WxLayerAPI } from '../wxlayer/WxImplementation';
|
|
6
6
|
import { FrameworkOptions } from './wxsourcetypes';
|
|
7
|
+
/**
|
|
8
|
+
* @ignore
|
|
9
|
+
* A class to represent a tile
|
|
10
|
+
**/
|
|
7
11
|
declare class WxTile {
|
|
8
12
|
coords: XYZ;
|
|
9
13
|
ctx: CanvasRenderingContext2D;
|
|
@@ -30,6 +34,7 @@ declare class WxTile {
|
|
|
30
34
|
// create a layer source
|
|
31
35
|
const wxsource = new WxTileSource({ wxdatasetManager, variables }, { id: 'wxsource', attribution: 'WxTiles' });
|
|
32
36
|
* ```
|
|
37
|
+
* Or use the {@link WxDataSetManager.createSourceLayer} method to create a layer/source in one step.
|
|
33
38
|
*/
|
|
34
39
|
export declare class WxTileSource extends WxLayerBaseImplementation implements WxLayerAPI {
|
|
35
40
|
/**
|