@metoceanapi/wxtiles-leaflet 2.1.0 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/es/controls/WxAPIControl.d.ts +1 -1
- package/dist/es/controls/WxInfoControl.d.ts +2 -1
- package/dist/es/controls/WxStyleEditorControl.d.ts +5 -0
- package/dist/es/customlayer/customlayer.d.ts +2 -0
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +2 -2
- package/dist/es/utils/tests_wxtools.d.ts +1 -0
- package/dist/es/utils/wxtools.d.ts +22 -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 -11
- package/dist/es/wxlayer/painter.d.ts +5 -0
- package/dist/es/wxlayer/wxlayer.d.ts +32 -14
- package/dist/es/wxsource/wxsource.d.ts +5 -0
- package/dist/web/index.js +2 -2
- package/docs/docs/assets/main.js +56 -52
- package/docs/docs/assets/search.js +1 -1
- package/docs/docs/assets/style.css +27 -5
- package/docs/docs/classes/CustomWxTilesLayer.html +68 -0
- package/docs/docs/classes/DataIntegral.html +13 -13
- package/docs/docs/classes/FrameworkParentClass.html +3 -3
- package/docs/docs/classes/Loader.html +1 -1
- package/docs/docs/classes/Painter.html +6 -6
- package/docs/docs/classes/WxAPI.html +5 -5
- package/docs/docs/classes/WxDataSetManager.html +119 -71
- package/docs/docs/classes/WxLayer.html +78 -40
- package/docs/docs/classes/WxLayerBaseImplementation.html +66 -19
- package/docs/docs/classes/WxTileSource.html +74 -22
- package/docs/docs/functions/WXLOG.html +3 -2
- package/docs/docs/functions/WxCreateLegend.html +2 -1
- package/docs/docs/functions/WxGetColorSchemes.html +3 -2
- package/docs/docs/functions/WxGetColorStyles.html +3 -2
- package/docs/docs/functions/WxTilesLogging.html +3 -2
- package/docs/docs/index.html +2 -1
- package/docs/docs/interfaces/ColorStylesIncomplete.html +2 -1
- package/docs/docs/interfaces/Converter.html +2 -2
- 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/WxAPIOptions.html +3 -3
- package/docs/docs/interfaces/WxColorSchemes.html +2 -1
- package/docs/docs/interfaces/WxColorStyleStrict.html +22 -0
- package/docs/docs/interfaces/WxColorStyleWeak.html +23 -0
- package/docs/docs/interfaces/WxColorStylesStrict.html +2 -2
- package/docs/docs/interfaces/WxColorStylesWeakMixed.html +2 -1
- 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/interfaces/WxTilesLibOptions.html +4 -4
- package/docs/docs/interfaces/WxUnits.html +2 -1
- package/docs/docs/interfaces/WxVariablesMetas.html +2 -1
- package/docs/docs/modules.html +3 -1
- package/docs/docs/types/DataIntegrals.html +3 -2
- package/docs/docs/types/DataPictures.html +3 -2
- package/docs/docs/types/SLine.html +2 -1
- package/docs/docs/types/SubTrees.html +2 -1
- package/docs/docs/types/SubTreesN.html +2 -1
- package/docs/docs/types/TreeN.html +2 -1
- package/docs/docs/types/UriLoaderPromiseFunc.html +3 -2
- package/docs/docs/types/WxDate.html +2 -1
- package/docs/docs/types/WxURIs.html +2 -1
- package/docs/docs/types/WxUnitTuple.html +2 -1
- package/docs/docs/types/WxVars.html +2 -1
- package/docs/examples/seaMaskAndAnimatedBlur.html +2 -2
- package/docs/examples/simpleDemo.html +2 -2
- package/docs/script/script.js +4 -4
- package/package.json +6 -7
- package/src_example/frwrkdeps.ts +1 -2
- package/src_example/start.ts +28 -24
- package/watch-public.mjs +99 -0
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;
|
|
@@ -29,6 +29,11 @@ export declare class WxStyleEditorControl {
|
|
|
29
29
|
unitsInput: HTMLInputElement;
|
|
30
30
|
extraUnitsInput: HTMLInputElement;
|
|
31
31
|
maskSelect: HTMLSelectElement;
|
|
32
|
+
animationSpeed: HTMLInputElement;
|
|
33
|
+
noiseTexturePow: HTMLInputElement;
|
|
34
|
+
vectorFieldFactor: HTMLInputElement;
|
|
35
|
+
animationIntensity: HTMLInputElement;
|
|
36
|
+
wavesCount: HTMLInputElement;
|
|
32
37
|
styleBase: WxColorStyleStrict;
|
|
33
38
|
parent: HTMLDivElement;
|
|
34
39
|
constructor();
|
package/dist/es/index.d.ts
CHANGED
|
@@ -33,3 +33,4 @@ export { Painter, type WxRasterData } from './wxlayer/painter';
|
|
|
33
33
|
export { Loader, type WxData, type SLine, type SLinePoint } from './wxlayer/loader';
|
|
34
34
|
export { QTree } from './utils/qtree';
|
|
35
35
|
export type { TileType, Tree, SubTrees, SubTreesN, TreeN } from './utils/qtree';
|
|
36
|
+
export { CustomWxTilesLayer } from './customlayer/customlayer';
|
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 Re=Object.create;var le=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Ne=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty;var Be=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var Ve=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $e(e))!Ue.call(a,n)&&n!==t&&le(a,n,{get:()=>e[n],enumerable:!(r=_e(e,n))||r.enumerable});return a};var Ze=(a,e,t)=>(t=a!=null?Re(Ne(a)):{},Ve(e||!a||!a.__esModule?le(t,"default",{value:a,enumerable:!0}):t,a));var ke=Be((Vt,Pe)=>{Pe.exports=window.L});var ce={comment1:["'degC': ['K', 1, 273.15] -> degC = K * 1 + 273.15",0],comment2:["'hPa': ['Pa', 1000]' -> hPa = Pa * 1000 + 0 (0 - could be ommited)",0],K:["K",1],kelvin:["K",1],F:["K",.5555555555,255.372222222],C:["K",1,273.15],degC:["K",1,273.15],"kg/m^2/s":["kg/m^2/s",1],"Kg/m^2/s":["kg/m^2/s",1],"Kg m**-2 s**-1":["kg/m^2/s",1],"Kg m^-2 s^-1":["kg/m^2/s",1],"Kg m^{-2} s^-1":["kg/m^2/s",1],"mm/h":["kg/m^2/s",.00027777777],"mm/hr":["kg/m^2/s",.00027777777],"W/m^2":["W/m^2",1],"W m^-2":["W/m^2",1],"W m^{-2}":["W/m^2",1],"W/m**2":["W/m^2",1],"W m**-2":["W/m^2",1],"m/s":["m/s",1],"m s**-1":["m/s",1],"m s^-1":["m/s",1],"m.s^{-1}":["m/s",1],knot:["m/s",.514444],knots:["m/s",.514444],"km/h":["m/s",.27777777777],"km h^-1":["m/s",.27777777777],"km h**-1":["m/s",.27777777777],mph:["m/s",.44704],"miles/h":["m/s",.44704],s:["s",1],sec:["s",1],h:["s",3600],min:["s",60],m:["m",1],cm:["m",.01],km:["m",1e3],mile:["m",1609.344],miles:["m",1609.344],inch:["m",.0254],Pa:["Pa",1],hPa:["Pa",100],degree:["degree",1],radian:["degree",57.3],"mg/m^3":["mg/m^3",1],"mg m^-3":["mg/m^3",1],"mg.m^-3":["mg/m^3",1],"%":["%",1],"(0 - 1)":["%",100]};var ue={none:["#00000000","#00000000"],divergingbluered:["#2166acff","#92c5deff","#f7f7f7ff","#f4a582ff","#b2182bff"],rainbow:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbowzerro:["#ff000000","#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbow2:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff","#ff0000ff"],bluebird:["#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bluebirdzerro:["#0000ff00","#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bw:["#000000ff","#ffffffff"],wb:["#ffffffff","#000000ff"],redish:["#ff00ffff","#ff0000ff","#ffff00ff"],greenish:["#ffff00ff","#00ff00ff","#00ffffff"],blueish:["#ff00ffff","#0000ffff","#00ffffff"],hspastel:["#AC6EA4FF","#8E92BDFF","#ACD4DEFF","#E9DC8EFF","#E7A97DFF","#E59074FF","#BE7E68FF","#A88F86FF"]};var X={base:{parent:void 0,name:"base",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"none",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",gl:{animationSpeed:1,noiseTexturePow:5,vectorFieldFactor:1,animationIntensity:5,wavesCount:4}},custom:{parent:void 0,name:"custom",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"rainbow",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"}};var me,fe,de;function xe({colorStyles:a={},units:e={},colorSchemes:t={}}={}){u("WxTile lib setup: start"),me=Object.assign({},ce,e),fe=Object.assign({},t,ue);let r=Object.assign({},a,X);de=Fe(r),u("WxTile lib setup: styles unrolled");try{(async()=>(await document.fonts.load("32px barbs"),await document.fonts.load("32px arrows")))()}catch{u("WxTile lib setup: fonts not loaded")}u("WxTile lib setup is done.")}function A(){return de}function J(){return fe}function O(a,e,t){u("makeConverter: From=",a," To=",e);let r=d=>d;if(r.trivial=!0,a===e)return u("Trivial converter"),r;let n=Object.assign({},me,t),s=n[a],i=n[e];if(!s||!i)return u("Inconvertible units. Trivial converter"),r;let[o,m,c]=s,[l,f,x]=i;if(o!==l||!m||!f)return u("Inconvertible units. Trivial converter"),r;let h=m/f,g=((c||0)-(x||0))/f;return g?d=>h*d+g:d=>h*d}function Fe(a){let e=Object.assign({},X);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({},X.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 m=r(s,o.parent);return Object.assign(o,Object.assign({},m,o,{parent:"base"}))},n={base:t};for(let s in e)n[s]=r(e,s);return n}function R(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}}async function Xe(a,e){let t=await fetch(a,e),r=await t.blob();if(!t.ok){let n=t.headers.get("x-reason");throw console.log(n),{name:"Tile loading failed",reason:n}}return await createImageBitmap(r,{premultiplyAlpha:"none"})}var H=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_=Ee(this.raw))}};function k(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 Oe(a){let{width:e,height:t}=a,r=k(e,t);return r.drawImage(a,0,0),r.getImageData(0,0,e,t)}async function Q(a,e){return Oe(await Xe(a,e))}function qe(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 m=0;m<t.length;m++)t[m]=e[m*2];let r=new Uint8Array(8);for(let m=0;m<8;++m)r[m]=a.data[m*4+2];let n=new DataView(r.buffer),s=n.getFloat32(0,!0),i=n.getFloat32(4,!0),o=(i-s)/65535;return new H(t,s,i,o)}async function ee(a,e){return qe(await Q(a,e))}function Ee(a){let e=new Uint32Array(66564),t=new Uint32Array(258*258);e[0]=a[0],t[0]=a[0]?1:0;for(let r=1;r<258;++r){e[r]=a[r]+e[r-1],t[r]=(a[r]?1:0)+t[r-1];let n=258*r;e[n]=a[n]+e[n-258],t[n]=(a[n]?1:0)+t[n-258]}for(let r=1;r<258;++r)for(let n=1;n<258;++n){let s=258*r+n;e[s]=a[s]+e[s-258]+e[s-1]-e[s-259],t[s]=(a[s]?1:0)+t[s-258]+t[s-1]-t[s-259]}return{integral:e,integralNZ:t[66563]===66564?null:t}}function Ye(a){let{integral:e}=a.integral;a.raw[0]=e[0];for(let t=1;t<258;t++){a.raw[t]=e[t]-e[t-1],a.raw[258*t]=e[258*t]-e[258*(t-1)];for(let r=1;r<258;r++){let n=258*t+r;a.raw[n]=e[n-259]+e[n]-e[n-258]-e[n-1]}}return a}function ge(a,e){if(e<0&&(e=0),e===a.radius)return a;if(a.radius=e,!e)return Ye(a);let{integral:t,integralNZ:r}=a.integral;for(let n=2;n<256;n++)for(let s=2;s<256;s++){let i=258*n+s;if(!a.raw[i])continue;let o=Math.min(e,s-1,256-s),m=Math.min(e,n-1,256-n),c=258*(n-m-1)+s,l=258*(n+m)+s,f;if(r){let W=r[c-o-1],y=r[c+o],b=r[l-o-1],S=r[l+o];f=W+S-y-b}else f=(2*o+1)*(2*m+1);let x=t[c-o-1],h=t[c+o],g=t[l-o-1],d=t[l+o],p=x+d-h-g;a.raw[i]=p/f}for(let n=2;n<256;n++){let s=258+n;if(a.raw[s]){let c=n,l=Math.min(e,c-1,256-c),f=258+c,x;if(r){let M=r[f-l-1];x=0+r[f+l]-0-M}else x=(2*l+1)*2;let h=0,g=0,d=t[f-l-1],p=t[f+l],y=(h+p-g-d)/x;a.raw[s-258]=y,a.raw[s]=y}let i=258*256+n;if(a.raw[i]){let c=n,l=Math.min(e,c-1,256-c),f=258*255+c,x=258*257+c,h=t[f-l-1],g=t[f+l],d=t[x-l-1],p=t[x+l],W=h+p-g-d,y;if(r){let S=r[f-l-1],M=r[f+l],w=r[x-l-1],D=r[x+l];y=S+D-M-w}else y=(2*l+1)*2;let b=W/y;a.raw[i]=b,a.raw[i+258]=b}let o=258*n+1;if(a.raw[o]){let c=n,l=Math.min(e,c-1,256-c),f=258*(c-l-1)+1,x=258*(c+l)+1,h;if(r){let M=r[f],w=0;h=0+r[x]-M-w}else h=(2*l+1)*2;let g=0,d=t[f],p=0,W=t[x],b=(g+W-d-p)/h;a.raw[o-1]=b,a.raw[o]=b}let m=258*n+256;if(a.raw[m]){let c=n,l=Math.min(e,c-1,256-c),f=258*(c-l-1)+256,x=258*(c+l)+256,h;if(r){let S=r[f-1],M=r[f+1],w=r[x-1],D=r[x+1];h=S+D-M-w}else h=2*(2*l+1);let g=t[f-1],d=t[f+1],p=t[x-1],W=t[x+1],b=(g+W-d-p)/h;a.raw[m]=b,a.raw[m+1]=b}}return a}function C(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 T(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}async function P(a,e){let t=await fetch(a,e);if(!t.ok)throw new Error("error:"+a+" - "+t.statusText);return t.json()}function te(a,e,t){let r=a>>0&255,n=a>>8&255,s=a>>16&255,i=a>>>24,o=e>>0&255,m=e>>8&255,c=e>>16&255,l=e>>>24,f=r+t*(o-r),x=n+t*(m-n),h=s+t*(c-s),g=i+t*(l-i);return f|x<<8|h<<16|g<<24}function he(a,e,t){let r=[];for(let n=0;n<t;++n)r.push(n*(e-a)/(t-1)+a);return r}var K=!1,u=(...a)=>{};function je(a){K=!!a,console.log("WXLOGing",K),u=typeof a=="function"?a:K?console.log:()=>{}}function re(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 E({x:a,y:e,z:t}){return`${t}-${a}-${e}`}var Ge="A".charCodeAt(0);var _=class{constructor(){this.qtree={nodes:null};this.qtreedepth=0;u("QTree.constructor")}async load(e,t){try{let r=await P(e,t);this.qtree=pe(r,{pos:0})}catch(r){throw new Error(`Failed to load QTree: ${r.message}`)}this.qtreedepth=be(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}:{...e};return ye(this.qtree,n,r)}};function pe(a,e){let t=a.charCodeAt(e.pos)-Ge;e.pos++;let r=[1,2,4,8].map(n=>t&n?pe(a,e):null);return{nodes:r.some(n=>n)?r:null}}function be(a){return a?.nodes?1+Math.max(...a.nodes.map(be)):0}function ye(a,e,t){return a===null?"land":t&&!e.z?"mixed":a.nodes===null?"sea":e.z?(e.z--,ye(a.nodes[(e.y>>e.z&1)<<1|e.x>>e.z&1],e,t)):"mixed"}function ze(a,e,t){return a>t?t:a<e?e:a}var $=class{constructor(e,t,[r,n],s){u("RawCLUT.constructor");let i=n-r;this.levelIndex=new Uint32Array(65536),this.colorsI=new Uint32Array(65536);let o=[];this.DataToStyle=O(t,e.units,e.extraUnits),this.DataToStyle.trivial&&(e.units=t),s&&(this.DataToKnots=O(t,"knot"));let m=O(e.units,t,e.extraUnits),c=d=>~~(65535*ze((m(d)-r)/(n-r),0,1));if(Array.isArray(e.colorMap)){e.colorMap.sort((d,p)=>d[0]<p[0]?-1:d[0]>p[0]?1:0);for(let[d]of e.colorMap)o.push(c(d))}else{if(e.levels||(e.levels=he(this.DataToStyle(r),this.DataToStyle(n),10)),e.levels.sort((d,p)=>d<p?-1:d>p?1:0),!e.colors){let d=J();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 l=65536,f=we(l,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 p=i*d/65535+r,W=this.DataToStyle(p),y=Math.round((l-1)*(W-x)/g);y<=0?this.colorsI[d]=e.showBelowMin?f.colors[0]:0:y>=l?this.colorsI[d]=e.showAboveMax?f.colors[l-1]:0:this.colorsI[d]=f.colors[y]}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 p=o[d];p<o[d+1]+1;++p)this.levelIndex[p]=d;for(let d=o[o.length-1];d<65536;++d)this.levelIndex[d]=o.length-1}};function We(a){if(a!==0&&-.1<a&&a<.1)return a.toExponential(2);let e=a.toString();return e.split(".")[1]?.length>2?a.toFixed(2):e}function we(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],h=r[r.length-1][0]-x;for(let[g,d]of r){let p=~~((g-x)/h*(a-1)),W={data:g,dataString:We(g),color:d,pos:p};t.ticks.push(W)}for(let g=0;g<r.length-1;g++){let d=t.ticks[g].pos,p=t.ticks[g+1].pos,W=T(r[g][1]),y=i?T(r[g+1][1]):0;for(let b=d;b<p;++b)t.colors[b]=i?te(W,y,(b-d)/(p-d)):W}return t.colors[a-1]=T(r[r.length-1][1]),t}if(!s||!n)return t;let o=0,m=0,c=-1;for(let x=0;x<a;++x){let h=x*(s.length-1)/a;c!==~~h&&(c=~~h,o=T(s[c]),m=s.length>c+1?T(s[c+1]):o),t.colors[x]=i?te(o,m,h-c):o}t.colors[a-1]=T(s[s.length-1]);let l=n[0],f=(a-1)/(n[n.length-1]-l);for(let x of n){let h=~~((x-l)*f),g={data:x,dataString:We(x),color:C(t.colors[h]),pos:h};t.ticks.push(g)}return t}var Ke=2*Math.PI*6378137/256,Y=2*Math.PI*6378137/2;function He(a,e){let t=a/Y*180,r=e/Y*180;return r=180/Math.PI*(2*Math.atan(Math.exp(r*Math.PI/180))-Math.PI/2),[r,t]}function Je(a,e,t){let r=Qe(t),n=a*r-Y,s=e*r-Y;return[n,s]}function Qe(a){return Ke/2**a}function ae(a,e,t){let[r,n]=He(...Je(a,e,t));return[n,-r]}function Se(a,e){return[a*256,e*256]}function ne(a,e,t){let r=((e-a)%360+540)%360-180;return(a+r*t+360)%360}function et(a,e,t,r,n,s,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=ne(a,e,n),l=ne(t,r,n),f=(ne(c,l,s)-i)/o;return f<1?1:f}function Me(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 De(a,e,t){let r=1/2**t.z,n=t.x*256*r-.5,s=t.y*256*r-.5,{raw:i,dmin:o,dmax:m,dmul:c}=e,l={raw:new Uint16Array(258*258),dmin:o,dmax:m,dmul:c},{raw:f}=l;for(let x=-1,h=0,g=s-r+1;x<=256;x++,g+=r){let d=Math.floor(g),p=g-d,W=d*258;for(let y=-1,b=n-r+1;y<=256;y++,h++,b+=r){let S=Math.floor(b),M=b-S,w=S+W,D=i[w],I=i[w+1],L=i[w+258],v=i[w+258+1];f[h]=a(D,I,L,v,M,p,o,c)}}return l}function Ce(a,e,t){if(!e)return a;let r=l=>l<0?0:l>254?254:l,n=1/2**e.z,s=e.x*256*n-.5,i=e.y*256*n-.5,{data:o}=a,m=new ImageData(256,256),{data:c}=m;for(let l=0,f=t,x=i;l<256;l++,x+=n){let h=~~r(x),g=x-h,d=h*256;for(let p=0,W=s;p<256;p++,f+=4,W+=n){let y=~~r(W),b=W-y,S=(y+d)*4+t,M=o[S],w=o[S+4],D=o[S+4*256],I=o[S+4*256+4],L=Me(M,w,D,I,b,g,0,0);c[f]=L>127?255:0}}return m}function Te(a,e){return e?De(Me,a,e):a}function Ie(a,e){return e?De(et,a,e):a}function Le(a,{data:e},t,r){let n=r==="sea",{raw:s}=a;for(let i=t,o=259,m=0;m<256;o+=2,m++)for(let c=0;c<256;c++,o++,i+=4)n===!e[i]&&(s[o]=0);return a}function ve(a){let[e,t]=Se(a.x,a.y),[r,n]=ae(e,t,a.z),[s,i]=ae(e+256,t+256,a.z);return{west:r,north:n,east:s,south:i}}function se(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 N=class{constructor(e){this.loadDataFunc=R(ee);this.layer=e}async load(e,t){let r=await this.cacheLoad(e,this.layer.tilesURIs,t);if(!r)return null;let{rawdata:n,subCoords:s,tileType:i}=r,{units:o}=this.layer.currentVariableMeta,m=o==="degree"?Ie:Te,c=f=>m(ge(f,this.layer.style.blurRadius),s),l=n.map(c);return this._vectorMagnitudesPrepare(l),await this._applyMask(l,e,i,!s&&n.length===1),{data:l,slines:this._createStreamLines(l)}}async cacheLoad(e,t,r){if(!this._checkInsideBoundaries(e))return null;let n=this._checkTypeAndMask(e);if(!n)return null;let{upCoords:s,subCoords:i}=se(e,this.layer.getCoarseMaxZoom()),o=t.map(l=>q(l,s)),m=Object.assign({},this.layer.wxdatasetManager.wxAPI.requestInit,{signal:r?.signal});return{rawdata:await Promise.all(o.map(l=>this.loadDataFunc(l,m))),subCoords:i,tileType:n}}clearCache(){this.loadDataFunc=R(ee)}async _applyMask(e,t,r,n){let{style:s}=this.layer;if((s.mask==="land"||s.mask==="sea")&&r==="mixed"){if(n){let{raw:m,dmin:c,dmax:l,dmul:f}=e[0];e[0]={raw:new Uint16Array(m),dmin:c,dmax:l,dmul:f}}let i,{wxAPI:o}=this.layer.wxdatasetManager;try{let{upCoords:m,subCoords:c}=se(t,o.maskDepth);i=await o.loadMaskFunc(m),i=Ce(i,c,o.maskChannel)}catch{s.mask=void 0,u("Can't load Mask. Masking is disabled");return}Le(e[0],i,o.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.layer.wxdatasetManager.wxAPI.qtree.check(e);return t===r?void 0:r}return"mixed"}_checkInsideBoundaries(e){let t=this.layer.getBoundaries();if(t?.boundaries180){let r=ve(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,m=t.addDegrees?.017453292519943*t.addDegrees:0,c=t.streamLineGridStep||64,l=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 h=[],g=x,d=f,p=-1,W=0,y=0;for(let M=0;M<=l&&g>=0&&g<=256&&d>=0&&d<=256;M++){M%(l/10)||h.push({x:~~g,y:~~d});let w=~~g+1+(~~d+1)*258;if(w!==p){if(!n.raw[w])break;p=w;let D=n.dmin+n.raw[w]*n.dmul,I=s.dmin+s.raw[w]*s.dmul,L=i.dmin+i.raw[w]*i.dmul,v=Math.atan2(I,L)+m;W=o*D*Math.sin(v),y=o*D*Math.cos(v)}g+=W,d-=y}let b=x,S=f;p=-1;for(let M=1;M<=l&&b>=0&&b<=256&&S>=0&&S<=256;M++){M%(l/10)||h.unshift({x:~~b,y:~~S});let w=~~b+1+(~~S+1)*258;if(w!==p){if(!n.raw[w])break;p=w;let D=n.dmin+n.raw[w]*n.dmul,I=s.dmin+s.raw[w]*s.dmul,L=i.dmin+i.raw[w]*i.dmul,v=Math.atan2(I,L)+m;W=o*D*Math.sin(v),y=o*D*Math.cos(v)}b-=W,S+=y}h.length>2&&r.push(h)}return r}};var U=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),m=new Uint32Array(o.data.buffer);t.clearRect(0,0,256,256),r.clearRect(0,0,256,256),n.clearRect(0,0,256,256),tt(e.data[0],m,s);let c=rt(m,e.data[0],s);t.putImageData(o,0,0),at(c,r,s),nt(e.data,r,s),st(e.data[0],r,i,s),ot(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")&&it(e,r,s,n)}};function tt(a,e,{CLUT:t,style:r}){let{raw:n}=a,{colorsI:s}=t;if(r.fill!=="none")for(let i=0,o=0,m=259;i<256;++i,m+=2)for(let c=0;c<256;++c,++o,++m)e[o]=s[n[m]];else e.fill(0)}function rt(a,e,{CLUT:t,style:r}){let{raw:n}=e,{levelIndex:s,colorsI:i}=t,o=[];if(r.isolineColor!=="none"){let m=r.isolineColor[0]==="#"?T(r.isolineColor):0;for(let c=0,l=0;c<256;c+=1)for(let f=0;f<256;f+=1){let x=(c+1)*258+(f+1),h=n[x],g=n[x+1],d=n[x+258];if(!h||!g||!d)continue;let p=s[h],W=s[g],y=s[d];if(p!==W||p!==y){let b=Math.max(p,W,y),S=Math.max(h,g,d),M=c*256+f;switch(r.isolineColor){case"inverted":a[M]=~i[S]|4278190080;break;case"fill":a[M]=i[S]|4278190080;break;default:a[M]=m;break}r.isolineText&&!(++l%255)&&f>20&&f<235&&c>20&&c<235&&o.push({x:f,y:c,d:h,dr:g,db:d,mli:b})}}}return o}function at(a,e,{CLUT:t}){if(a.length){e.font="1.1em Sans-serif",e.lineWidth=2,e.strokeStyle="white",e.fillStyle="black",e.textAlign="center",e.textBaseline="middle";for(let{x:r,y:n,d:s,dr:i,db:o,mli:m}of a){let c=t.ticks[m].dataString,l=Math.atan2(s-i,o-s);e.save(),e.translate(r,n),e.rotate(l<-1.57||l>1.57?l+3.14:l),e.strokeText(c,0,0),e.fillText(c,0,0),e.restore()}}}function nt(a,e,{CLUT:t,style:r}){if(!t.DataToKnots||r.vectorColor==="none"||r.vectorType==="none")return;if(a.length!==3)throw new Error("data.length !== 3");let[n,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,m=32;for(let c=m/2;c<256;c+=m)for(let l=m/2;l<256;l+=m){let f=l+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),h=n.dmin+n.raw[f]*n.dmul,g=r.vectorType!=="barbs"?r.vectorFactor*.5:.2,d=Math.min(~~(t.DataToKnots(h)*g),25)+65,p=String.fromCharCode(d);switch(r.vectorColor){case"inverted":e.fillStyle=C(~t.colorsI[n.raw[f]]);break;case"fill":e.fillStyle=C(t.colorsI[n.raw[f]]);break}e.save(),e.translate(l,c),e.rotate(x+o),e.fillText(p,0,0),e.restore()}}function st(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 m=o/2;m<256;m+=o)for(let c=o/2;c<256;c+=o){let l=c+1+(m+1)*258;if(!a.raw[l])continue;let x=(a.dmin+a.raw[l]*a.dmul+180)*.01745329251;switch(n.vectorColor){case"inverted":e.fillStyle=C(~r.colorsI[a.raw[l]]);break;case"fill":e.fillStyle=C(r.colorsI[a.raw[l]]);break}e.save(),e.translate(c,m),e.rotate(x+s),e.fillText(i,0,0),e.restore()}}function ot(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=re(r.streamLineColor));for(let o=s.length;o--;){let m=s[o];for(let c=0;c<m.length-1;++c){let l=m[c],f=m[c+1],x=l.x+1+(l.y+1)*258;switch(r.streamLineColor){case"inverted":e.strokeStyle=C(~t.colorsI[i.raw[x]]);break;case"fill":e.strokeStyle=C(t.colorsI[i.raw[x]]);break}e.beginPath(),e.moveTo(l.x,l.y),e.lineTo(f.x,f.y),e.stroke()}}}function it(a,e,{CLUT:t,style:r},n){let{data:s,slines:i}=a,o=s[0],m=r.streamLineColor[0]==="#"?re(r.streamLineColor).substring(0,7):"#000000";n=n>>5;for(let c=0;c<i.length;++c){let l=i[c],f=l.length-1,x=(n+(1+l[0].x)*(1+l[0].y))%30;for(let h=0;h<f;++h){let g=l[h],d=l[h+1],p=1-(x-h)/f;(p<0||p>1)&&(p=0);let W=(~~(p*255)).toString(16).padStart(2,"0"),y=1+~~((1.2-p)*5);e.lineWidth=y;let b=g.x+1+(g.y+1)*258;switch(r.streamLineColor){case"inverted":m=C(~t.colorsI[o.raw[b]]);break;case"fill":m=C(t.colorsI[o.raw[b]]);break}e.strokeStyle=m+W,e.beginPath(),e.moveTo(g.x,g.y),e.lineTo(d.x,d.y),e.stroke()}}}var j=class extends Map{clear(){u("TilesCache.clear()"),this.forEach(e=>{e.rd&&(e.rd.gl.deleteTexture(e.rd.vectorTextureU),e.rd.gl.deleteTexture(e.rd.vectorTextureV))}),super.clear()}},B=class{constructor(e){this.tilesCache=new j;this.coarseLevel=0;this.painter=new U(this);this.loader=new N(this);if(u(`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}`),!e.variables?.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(s=>{if(!e.wxdatasetManager.checkVariableValid(s))throw new Error(`datasetName: ${e.wxdatasetManager.datasetName}: variable ${s} is not valid`)}),this.variables=e.variables,this.wxdatasetManager=e.wxdatasetManager,[this.tilesURIs,this.time]=this._createURLsAndTime(e.time);let t=A(),r=t.base,n=e.wxstyleName&&t[e.wxstyleName];this.currentVariableMeta=this._getCurrentVariableMeta(),[this.style,this.CLUT]=this._createStyleAndCLUT({...r,...n,...e.wxstyle})}get nonanimatable(){return u("WxLayer.nonanimatabl()"),this.variables.length<2||this.style.streamLineStatic||this.style.streamLineColor==="none"}getMaxZoom(){return u("WxLayer.getMaxZoom"),this.wxdatasetManager.isInstanced()?this.wxdatasetManager.getInstanceMeta(this.getTime()).maxZoom:this.wxdatasetManager.getMaxZoom()}getCoarseMaxZoom(){return u("WxLayer.getCoarseMaxZoom"),this.getMaxZoom()-this.coarseLevel}getBoundaries(){return this.wxdatasetManager.isInstanced()?this.wxdatasetManager.getInstanceMeta(this.getTime()).boundaries:this.wxdatasetManager.getBoundaries()}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(E(e));if(!r)return;let n=this._getPixelInfo(t,r.data.data);if(!n)return;let{raw:s,data:i}=n,o=s.map(l=>this.CLUT.colorsI[l]),m=o.map(C),c=i.map(l=>this.CLUT.DataToStyle(l));return{data:i,raw:s,rgba:o,hexColor:m,inStyleUnits:c,tilePoint:t,styleUnits:this.style.units,dataUnits:this.currentVariableMeta.units}}setURLsAndTime(e){u(`WxLayer.setURLsAndTime time=${e}`),[this.tilesURIs,this.time]=this._createURLsAndTime(e),this.wxdatasetManager.isInstanced()&&(this.currentVariableMeta=this._getCurrentVariableMeta(),[this.style,this.CLUT]=this._createStyleAndCLUT())}async loadTile(e,t){return this._loadCacheDrawTile(e,this.tilesCache,t).catch(r=>{if(r.name==="AbortError")throw r;return null})}async preloadTime(e,t,r){u(`WxLayer.preloadTime time=${e}`);let[n]=this._createURLsAndTime(e);await Promise.allSettled(t.map(s=>this.loader.cacheLoad(s,n,r)))}async reloadTiles(e,t){u("WxLayer.reloadTiles");let r=new j;await Promise.allSettled(e.map(n=>this._loadCacheDrawTile(n,r,t))),t?.signal?.aborted?r.clear():(this.tilesCache.clear(),this.tilesCache=r)}async _loadCacheDrawTile(e,t,r){let n=t.get(E(e));if(n)return n;let s=await this.loader.load(e,r);if(!s)return null;let i=k(256,256),o=i,m=this.variables.length===2?k(256,256):i,c={ctxFill:i,ctxText:o,ctxStreamLines:m,data:s};return this.painter.paint(c),t.set(E(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){u(`WxLayer._getPixelInfo x=${e} y=${t}`);let n=(t+1)*258+(e+1);if(r?.[0]?.raw?.[n])return{raw:r.map(s=>s.raw[n]),data:r.map(s=>s.raw[n]*s.dmul+s.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 $(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 Ae=Ze(ke()),V=class extends Ae.default.GridLayer{constructor(t){super(t);this.id=t.id}};var G=class extends V{constructor(t,r){u(`WxLayerBaseImplementation.constructor (${r.id})`);super(r);this.animation=!1;this.animationSeed=0;this.layer=new B(t)}get wxdatasetManager(){return u(`WxLayerBaseImplementation.wxdatasetManager (${this.id})`),this.layer.wxdatasetManager}getCurrentVariableMeta(){return u(`WxLayerBaseImplementation.getCurrentVariableMeta (${this.id})`),{...this.layer.currentVariableMeta}}getDatasetMeta(){return this.layer.wxdatasetManager.getInstanceMeta(this.getTime())}getMetadata(){return u(`WxLayerBaseImplementation.getMetadata (${this.id})`),{...this.layer.currentVariableMeta}}getVariables(){return u(`WxLayerBaseImplementation.getVariables (${this.id})`),[...this.layer.variables]}clearCache(){u(`WxLayerBaseImplementation.clearCache (${this.id})`),this.layer.clearCache()}getCache(){return this.layer.tilesCache}getCurrentStyleObjectCopy(){return u(`WxLayerBaseImplementation.getCurrentStyleObjectCopy (${this.id})`),this.layer.getCurrentStyleObjectCopy()}getTime(){return u(`WxLayerBaseImplementation.getTime (${this.id})`),this.layer.getTime()}getTimes(){return u(`WxLayerBaseImplementation.getTimes (${this.id})`),this.layer.wxdatasetManager.getTimes()}async setTime(t,r){u(`WxLayerBaseImplementation.setTime (${this.id}) time=${t}`);let n=this.getTime();return this.layer.setURLsAndTime(t),await this._reloadVisible(r),r?.signal?.aborted&&this.layer.setURLsAndTime(n),this.getTime()}async preloadTime(t,r){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=async r=>{if(u(`WxLayerBaseImplementation.startAnimation (${this.id}) animationStep`),!this.animation||this.layer.nonanimatable){this.animation=!1;return}this.animationSeed=r,await this._redrawTiles(),requestAnimationFrame(t)};requestAnimationFrame(t)}async stopAnimation(){return u(`WxLayerBaseImplementation.stopAnimation (${this.id})`),this.animation=!1,this._redrawTiles()}async setCoarseLevel(t=2){this.layer.coarseLevel=Math.max(0,Math.min(t,this.wxdatasetManager.getMaxZoom()))}async unsetCoarseLevel(){return this.layer.coarseLevel=0,this._reloadVisible()}async setStyleByName(t,r=!0){return u(`WxLayerBaseImplementation.setStyleByName (${this.id}) wxstyleName=${t} reload=${r}`),this.updateCurrentStyleObject(A()[t],r)}async updateCurrentStyleObject(t,r=!0,n){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)}async _reloadVisible(t){}coveringTiles(){return[]}update(){}};var z=class{constructor(e,t,r){this.coords=e;this.ctx=t;this.raster_data=r;this.draw(r?.ctxFill.canvas)}draw(e){this.ctx.clearRect(0,0,256,256),e&&this.ctx.drawImage(e,0,0)}},Z=class extends G{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(),i=n.subtract(s.multiplyBy(256)).floor();return this.layer.getTileData({x:s.x,y:s.y,z:r},i)}async _reloadVisible(e){if(u(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName})`),await this.layer.reloadTiles(this.coveringTiles(),e),e?.signal?.aborted){u(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName}) aborted`);return}return await Promise.allSettled(this._ForEachWxTile(async t=>{t.raster_data=await this.layer.loadTile(t.coords)},"_reloadVisible")),this._redrawTiles()}coveringTiles(){u(`WxTileSource coveringTiles (${this.layer.wxdatasetManager.datasetName})`);let e=[];for(let t in this._tiles){let r=this._tiles[t].el?.wxtile;r&&e.push(r.coords)}return e}update(){u(`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){u(`WxTileSource _ForEachWxTile (${this.layer.wxdatasetManager.datasetName}) func=${t}`);let r=[];for(let n in this._tiles){let s=this._tiles[n].el?.wxtile;s&&r.push(e(s))}return r}createTile(e,t){let r=k(256,256),n=r.canvas;return this.layer.loadTile(e).then(s=>{n.wxtile=new z(e,r,s)}).catch(()=>{n.wxtile=new z(e,r,null)}).finally(t),n}onRemove(e){return super.onRemove(e),u(`WxTileSource onRemove (${this.layer.wxdatasetManager.datasetName})`),this.animation=!1,this}};var F=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,u(`WxDataSetManager.constructor: ${this.datasetName}`)}isInstanced(){return!!this.instanced}getValidTime(e=Date()){u(`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 u(`WxDataSetManager.getTimes: ${this.datasetName}`),this.instanced||this.datasetCurrentMeta.times}getVariables(){return u(`WxDataSetManager.getVariables: ${this.datasetName}`),this.datasetCurrentMeta.variables}getVariableMeta(e){return u(`WxDataSetManager.getVariableMeta: ${this.datasetName}, ${e}`),this.datasetCurrentMeta.variablesMeta[e]}getInstanceVariableMeta(e,t){return u(`WxDataSetManager.getInstanceVariableMeta: ${this.datasetName}, ${e}, ${t}`),this.getInstanceMeta(t).variablesMeta[e]}getMaxZoom(){return u(`WxDataSetManager.getMaxZoom: ${this.datasetName}`),this.datasetCurrentMeta.maxZoom}getBoundaries(){return u(`WxDataSetManager.getBoundaries: ${this.datasetName}`),this.datasetCurrentMeta.boundaries}getInstanceMeta(e){return u(`WxDataSetManager.getInstanceMeta: ${this.datasetName}, ${e}`),this.instanced&&this.metas.get(e)||this.datasetCurrentMeta}createURI(e,t,r="png"){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.instanced?t:this.datasetCurrentInstance;return`${this.wxAPI.dataServerURL+this.datasetName}/${n}/${e}/${t}/{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={...e,variables:this.checkCombineVariableIfVector(e.variable),wxdatasetManager:this};return new Z(r,t)}async checkDatasetOutdated(){return u(`WxDataSetManager.checkDatasetOutdated: ${this.datasetName}`),await this.wxAPI.initDone,await this.getDatasetInstance()===this.datasetCurrentInstance}async getDatasetInstance(){u(`WxDataSetManager.getDatasetInstance: ${this.datasetName}`);let e=await this.getDatasetInstances();return e[e.length-1]}async getDatasetInstances(){u(`WxDataSetManager.getDatasetInstances: ${this.datasetName}`);try{let e=await P(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 oe=class{constructor({dataServerURL:e,maskURL:t="none",maskChannel:r="R",maskDepth:n=11,qtreeURL:s="none",requestInit:i,colorStyles:o,units:m,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),xe({colorStyles:o,units:m,colorSchemes:c}),this.dataServerURL=e,this.requestInit=i,s=s==="auto"?e+"masks/11+1.seamask.qtree":s,t!=="none"){let l=R(Q);this.maskURL=t=t==="auto"?e+"masks/{z}/{x}/{y}.png":t,this.loadMaskFunc=f=>l(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([P(e+"datasetsmeta.json",i),s!=="none"?this.qtree.load(s,i):Promise.resolve()]).then(([l,f])=>{l.allDatasetsList||(l.allDatasetsList=Object.keys(l)),this.datasetsMetas=l,u("WxAPI.constructor initDone")})}getDatasetShortMeta(e){if(u("WxAPI.getDatasetShortMeta",e),e!=="allDatasetsList")return this.datasetsMetas[e]}getDatasetInatance(e){return u("WxAPI.getDatasetInatance",e),this.getDatasetShortMeta(e)?.instance}async getDatasetVariables(e){return await this.initDone,u("WxAPI.getDatasetVariables",e),this.datasetsMetas[e]?.variables}async createDatasetManager(e){await this.initDone,u("WxAPI.createDatasetManager",e);let t=this.getDatasetShortMeta(e),r=t?.instance;if(!r)throw new Error("Dataset/instance not found:"+e);let n=t.instanced,s=c=>P(this.dataServerURL+e+"/"+c+"/meta.json",this.requestInit),i=async c=>[c,await s(c)],o=await s(r),m=new Map(n?await Promise.all(n.map(i)):[[r,o]]);return new F({datasetName:e,datasetCurrentInstance:r,datasetCurrentMeta:o,instanced:n,metas:m,wxAPI:this})}async createAllDatasetsManagers(){return await this.initDone,u("WxAPI.createAllDatasetsManagers"),Promise.allSettled(this.datasetsMetas.allDatasetsList.map(t=>this.createDatasetManager(t)))}async filterDatasetsByVariableName(e){return await this.initDone,u("WxAPI.filterDatasetsByVariableName",e),this.datasetsMetas.allDatasetsList.filter(t=>this.datasetsMetas[t]?.variables?.includes?.(e))}async getAllDatasetsNames(){return await this.initDone,u("WxAPI.getAllDatasetsNames"),this.datasetsMetas.allDatasetsList}};var ie=class{};export{ie as CustomWxTilesLayer,V as FrameworkParentClass,N as Loader,U as Painter,_ as QTree,$ as RawCLUT,u as WXLOG,oe as WxAPI,we as WxCreateLegend,F as WxDataSetManager,J as WxGetColorSchemes,A as WxGetColorStyles,B as WxLayer,Z as WxTileSource,je as WxTilesLogging};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function tests(): Promise<void>;
|
|
@@ -123,6 +123,14 @@ export interface WxColorStyleStrict {
|
|
|
123
123
|
* - **'land'** - make land transparent.
|
|
124
124
|
* */
|
|
125
125
|
mask?: 'land' | 'sea' | 'none';
|
|
126
|
+
/** If true then use WebGL to render tiles */
|
|
127
|
+
gl?: {
|
|
128
|
+
animationSpeed?: number;
|
|
129
|
+
noiseTexturePow?: number;
|
|
130
|
+
vectorFieldFactor?: number;
|
|
131
|
+
animationIntensity?: number;
|
|
132
|
+
wavesCount?: number;
|
|
133
|
+
};
|
|
126
134
|
}
|
|
127
135
|
/**
|
|
128
136
|
* @typedef {Object} WxColorStylesStrict
|
|
@@ -208,7 +216,7 @@ export declare class DataIntegral implements DataPicture {
|
|
|
208
216
|
dmin: number;
|
|
209
217
|
dmax: number;
|
|
210
218
|
dmul: number;
|
|
211
|
-
integral_
|
|
219
|
+
private integral_?;
|
|
212
220
|
radius: number;
|
|
213
221
|
constructor(raw: Uint16Array, dmin: number, dmax: number, dmul: number);
|
|
214
222
|
get integral(): IntegralPare;
|
|
@@ -238,7 +246,19 @@ export declare function loadImageData(url: string, requestInit?: RequestInit): P
|
|
|
238
246
|
* */
|
|
239
247
|
export declare function loadDataIntegral(url: string, requestInit?: RequestInit): Promise<DataIntegral>;
|
|
240
248
|
/**
|
|
241
|
-
*
|
|
249
|
+
* Calculaates {@link IntegralPare} from raw data Uint16Array.
|
|
250
|
+
* Used for fast box-blur algo
|
|
251
|
+
* Integarl image: https://en.wikipedia.org/wiki/Summed-area_table.
|
|
252
|
+
* @param raw - raw data
|
|
253
|
+
* @returns IntegralPare
|
|
254
|
+
* */
|
|
255
|
+
export declare function buildIntegralPare(raw: Uint16Array): IntegralPare;
|
|
256
|
+
/**
|
|
257
|
+
* BoxBlur implementation based on integral image {@link DataIntegral}.
|
|
258
|
+
* Adaptaion of using in 'tiling' mode. Uses only one boudary line for each tile.
|
|
259
|
+
* Gives decent visual results, but not as good as bluring over the whole image.
|
|
260
|
+
* Sometimes distortion of the image is noticable on the edges of the tiles.
|
|
261
|
+
* Also it doesn't change/blur corners of the tiles.
|
|
242
262
|
* @param data - {@link DataIntegral}
|
|
243
263
|
* @param radius - radius for the box-blur algorithm
|
|
244
264
|
* */
|
|
@@ -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;
|
|
@@ -48,11 +49,6 @@ export declare class WxLayerBaseImplementation extends FrameworkParentClass impl
|
|
|
48
49
|
* a seed for the animation
|
|
49
50
|
* */
|
|
50
51
|
protected animationSeed: number;
|
|
51
|
-
/**
|
|
52
|
-
* @ignore
|
|
53
|
-
* Used to make coarse level requests for time animation
|
|
54
|
-
* */
|
|
55
|
-
protected readonly oldMaxZoom: number;
|
|
56
52
|
/**
|
|
57
53
|
* @ignore
|
|
58
54
|
* An instance of the layer
|
|
@@ -77,9 +73,16 @@ export declare class WxLayerBaseImplementation extends FrameworkParentClass impl
|
|
|
77
73
|
* Get the metadata of the current variable(s).
|
|
78
74
|
* @returns {WxVariableMeta} - The metadata of the current variable.
|
|
79
75
|
*/
|
|
76
|
+
getCurrentVariableMeta(): WxVariableMeta;
|
|
77
|
+
getDatasetMeta(): WxDatasetMeta;
|
|
78
|
+
/**
|
|
79
|
+
* Get the metadata of the current variable(s).
|
|
80
|
+
* @deprecated
|
|
81
|
+
* @returns {WxVariableMeta} - The metadata of the current variable.
|
|
82
|
+
*/
|
|
80
83
|
getMetadata(): WxVariableMeta;
|
|
81
84
|
/**
|
|
82
|
-
* Get current variables of the source.
|
|
85
|
+
* Get current variables (1 or 2) of the source/layer.
|
|
83
86
|
* @returns {WxVars} variables of the source.
|
|
84
87
|
*/
|
|
85
88
|
getVariables(): WxVars;
|
|
@@ -87,6 +90,7 @@ export declare class WxLayerBaseImplementation extends FrameworkParentClass impl
|
|
|
87
90
|
* Clears the cache of the source.
|
|
88
91
|
*/
|
|
89
92
|
clearCache(): void;
|
|
93
|
+
getCache(): TilesCache;
|
|
90
94
|
/**
|
|
91
95
|
* Get a copy of the current style of the source.
|
|
92
96
|
* @returns {WxColorStyleStrict} A copy of the current style of the source.
|
|
@@ -97,6 +101,7 @@ export declare class WxLayerBaseImplementation extends FrameworkParentClass impl
|
|
|
97
101
|
* @returns {string} The current time of the source from array of times.
|
|
98
102
|
*/
|
|
99
103
|
getTime(): string;
|
|
104
|
+
getTimes(): string[];
|
|
100
105
|
/**
|
|
101
106
|
* Set time and render the source. If the time is not available, the closest time will be used.
|
|
102
107
|
* @param {WxDate} time - Time to set.
|
|
@@ -153,6 +158,7 @@ export declare class WxLayerBaseImplementation extends FrameworkParentClass impl
|
|
|
153
158
|
/**
|
|
154
159
|
* @ignore
|
|
155
160
|
* A dummy function to be replaced by ancestor classes.
|
|
161
|
+
* Force reload and redraw all tiles.
|
|
156
162
|
*/
|
|
157
163
|
protected update(): void;
|
|
158
164
|
}
|
|
@@ -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,9 @@ 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;
|
|
90
|
+
/** @internal current coarsing zoom level */
|
|
91
|
+
coarseLevel: number;
|
|
87
92
|
/** @internal Painter object to render tiles */
|
|
88
93
|
readonly painter: Painter;
|
|
89
94
|
/** @internal Loader object to load and preprocess tiles */
|
|
@@ -91,6 +96,19 @@ export declare class WxLayer {
|
|
|
91
96
|
constructor(wxLayerOptions: WxLayerOptions);
|
|
92
97
|
/** Check if the layer is vector and may be animated according to style */
|
|
93
98
|
get nonanimatable(): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* @internal
|
|
101
|
+
* Get maximum zoom according to the layer's Dataset manager
|
|
102
|
+
* @returns {number} maximum zoom
|
|
103
|
+
*/
|
|
104
|
+
getMaxZoom(): number;
|
|
105
|
+
getCoarseMaxZoom(): number;
|
|
106
|
+
/**
|
|
107
|
+
* @internal
|
|
108
|
+
* Get boundaries zoom according to the layer's Dataset manager
|
|
109
|
+
* @returns {WxAllBoundariesMeta | undefined} boundaries
|
|
110
|
+
* */
|
|
111
|
+
getBoundaries(): WxAllBoundariesMeta | undefined;
|
|
94
112
|
/**
|
|
95
113
|
* @internal
|
|
96
114
|
* Get the current time step of the layer
|
|
@@ -126,11 +144,9 @@ export declare class WxLayer {
|
|
|
126
144
|
* @returns {Promise<viod>} */
|
|
127
145
|
reloadTiles(tiles: XYZ[], requestInit?: WxRequestInit): Promise<void>;
|
|
128
146
|
/** @ignore */
|
|
129
|
-
protected _loadCacheDrawTile(tile: XYZ, tilesCache:
|
|
130
|
-
/** @ignore */
|
|
131
|
-
protected _createStyleAndCLUT(style_?: WxColorStyleWeak): [WxColorStyleStrict, RawCLUT];
|
|
147
|
+
protected _loadCacheDrawTile(tile: XYZ, tilesCache: TilesCache, requestInit?: WxRequestInit): Promise<WxRasterData | null>;
|
|
132
148
|
/** @ignore creates/calculates meta data for vector layers */
|
|
133
|
-
protected
|
|
149
|
+
protected _getCurrentVariableMeta(): WxVariableMeta;
|
|
134
150
|
/** @ignore x, y - pixel on tile, data - data tile */
|
|
135
151
|
protected _getPixelInfo({ x, y }: {
|
|
136
152
|
x: number;
|
|
@@ -139,6 +155,8 @@ export declare class WxLayer {
|
|
|
139
155
|
raw: number[];
|
|
140
156
|
data: number[];
|
|
141
157
|
} | undefined;
|
|
158
|
+
/** @ignore */
|
|
159
|
+
protected _createStyleAndCLUT(style_?: WxColorStyleWeak): [WxColorStyleStrict, RawCLUT];
|
|
142
160
|
/** @ignore Create a new CLUT for the given style */
|
|
143
161
|
protected _prepareCLUT(style: WxColorStyleStrict): RawCLUT;
|
|
144
162
|
/** @ignore calculate valid timestep and URIs */
|